diff options
-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; |