summaryrefslogtreecommitdiff
path: root/codegen.hs
diff options
context:
space:
mode:
Diffstat (limited to 'codegen.hs')
-rw-r--r--codegen.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/codegen.hs b/codegen.hs
index bf620e4..b8d8c54 100644
--- a/codegen.hs
+++ b/codegen.hs
@@ -441,6 +441,24 @@ genExpression (ExBinOp bo e1 e2 (Just t)) = do
(TypeUInt _) -> addInstr $ A.ICmp A.ULT e1op' e2op' []
_ -> undefined
return $ A.LocalReference (A.IntegerType 1) (A.Name label)
+ GEqual -> do
+ sharedType <- commonTypeM (fromJust (exTypeOf e1)) (fromJust (exTypeOf e2))
+ e1op' <- castOperand e1op sharedType
+ e2op' <- castOperand e2op sharedType
+ label <- case sharedType of
+ (TypeInt _) -> addInstr $ A.ICmp A.SGE e1op' e2op' []
+ (TypeUInt _) -> addInstr $ A.ICmp A.UGE e1op' e2op' []
+ _ -> undefined
+ return $ A.LocalReference (A.IntegerType 1) (A.Name label)
+ LEqual -> do
+ sharedType <- commonTypeM (fromJust (exTypeOf e1)) (fromJust (exTypeOf e2))
+ e1op' <- castOperand e1op sharedType
+ e2op' <- castOperand e2op sharedType
+ label <- case sharedType of
+ (TypeInt _) -> addInstr $ A.ICmp A.SLE e1op' e2op' []
+ (TypeUInt _) -> addInstr $ A.ICmp A.ULE e1op' e2op' []
+ _ -> undefined
+ return $ A.LocalReference (A.IntegerType 1) (A.Name label)
BoolOr -> do
e1op' <- castToBool e1op
e2op' <- castToBool e2op