diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-26 22:04:17 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-26 22:04:17 +0100 |
commit | 311a353fea97e74eb049180da51b5395561975cc (patch) | |
tree | f6bc87d1de85ff0e8014eeca4a2ea578f48a9442 | |
parent | 56b305928143e7411e9fc39dc8d33d8078dd63eb (diff) |
Also fix stores... See HEAD^
-rw-r--r-- | codegen.hs | 10 | ||||
-rw-r--r-- | simple.nl | 2 |
2 files changed, 3 insertions, 9 deletions
@@ -114,12 +114,12 @@ variableStoreOperand :: Name -> CGMonad A.Operand variableStoreOperand name = get >>= (maybe getGlobal getLocal . Map.lookup name . variables) where getLocal :: (Type, LLName) -> CGMonad A.Operand - getLocal (t, nm) = return $ A.LocalReference (toLLVMType t) (A.Name nm) + getLocal (t, nm) = return $ A.LocalReference (A.ptr (toLLVMType t)) (A.Name nm) getGlobal :: CGMonad A.Operand getGlobal = do (t, nm) <- lookupGlobalVar name - return $ A.ConstantOperand $ A.C.GlobalReference (toLLVMType t) (A.Name nm) + return $ A.ConstantOperand $ A.C.GlobalReference (A.ptr (toLLVMType t)) (A.Name nm) variableOperand :: Name -> CGMonad A.Operand variableOperand name = get >>= (maybe getGlobal getLocal . Map.lookup name . variables) @@ -258,12 +258,6 @@ genSingle _ _ = undefined genExpression :: Expression -> CGMonad A.Operand genExpression (ExLit lit (Just t)) = literalToOperand lit t --- genExpression (ExLit (LitInt i) (Just t@(TypeInt sz))) = do --- aname <- getNewName "t" --- void $ addNamedInstr $ A.Name aname A.:= A.Alloca (toLLVMType t) Nothing 0 [] --- void $ addInstr $ A.Store False (A.LocalReference (toLLVMType t) (A.Name aname)) --- (A.ConstantOperand (A.C.Int (fromIntegral sz) i)) Nothing 0 [] --- return aname genExpression (ExBinOp bo e1 e2 (Just t)) = do e1op <- genExprArgument e1 e2op <- genExprArgument e2 @@ -5,7 +5,7 @@ int g_var; int main(i32 argc, ptr(ptr(i8)) argv) { //int i = g_var; - int i; + int i = 40; //i = g_var + 2 + 3; int a = i + 2; return a; |