From 3543796a929faec42154134ae427d771d20ebffa Mon Sep 17 00:00:00 2001 From: Azim Muradov Date: Fri, 4 Oct 2024 20:36:55 +0300 Subject: [PATCH] Refactor LLVM IR binary operations generation --- lib/CodeGen/Llvm/LlvmIrGen.hs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/CodeGen/Llvm/LlvmIrGen.hs b/lib/CodeGen/Llvm/LlvmIrGen.hs index 43f83d4..bc4d80a 100644 --- a/lib/CodeGen/Llvm/LlvmIrGen.hs +++ b/lib/CodeGen/Llvm/LlvmIrGen.hs @@ -144,19 +144,17 @@ genComp = \case ArithOp PlusOp -> LLVM.add ArithOp MinusOp -> LLVM.sub ArithOp MulOp -> LLVM.mul - ArithOp DivOp -> - ( \lhs'' rhs'' -> do - divF <- findFun (Txt "miniml_div") - LLVM.call divF [lhs'', rhs''] - ) + ArithOp DivOp -> \lhs'' rhs'' -> do + divF <- findFun (Txt "miniml_div") + LLVM.call divF [lhs'', rhs''] CompOp cOp -> let cOpF = case cOp of - EqOp -> LLVM.icmp LLVM.EQ - NeOp -> LLVM.icmp LLVM.NE - LtOp -> LLVM.icmp LLVM.SLT - LeOp -> LLVM.icmp LLVM.SLE - GtOp -> LLVM.icmp LLVM.SGT - GeOp -> LLVM.icmp LLVM.SGE + EqOp -> LLVM.eq + NeOp -> LLVM.ne + LtOp -> LLVM.slt + LeOp -> LLVM.sle + GtOp -> LLVM.sgt + GeOp -> LLVM.sge in (\a b -> cOpF a b >>= boolToInt) opF lhs' rhs' CompUnOp op x -> do