Skip to content

Commit

Permalink
Refactor LLVM IR binary operations generation
Browse files Browse the repository at this point in the history
  • Loading branch information
AzimMuradov committed Oct 4, 2024
1 parent d96ae03 commit 6c8afcf
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/CodeGen/Llvm/LlvmIrGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c8afcf

Please sign in to comment.