diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-30 09:34:05 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-30 09:34:05 +0100 |
commit | 9b71b9206cd6854877262de2aa1c76421aa899be (patch) | |
tree | 0669bcea396f97ab5456051b6a695f994ad330b5 /codegen.hs | |
parent | 1cb1af774cdf0bd8c3f8da257c789184d349bc8c (diff) |
Implement >= and <=
Diffstat (limited to 'codegen.hs')
-rw-r--r-- | codegen.hs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |