aboutsummaryrefslogtreecommitdiff
path: root/CodeGen.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-08-20 11:57:02 +0200
committertomsmeding <tom.smeding@gmail.com>2017-08-20 11:57:02 +0200
commitf8d264f2b18fccdc3b96d8fb66656128a25137f2 (patch)
treec4da71e1b7bed93b9f2728503212b6fc43cc9e32 /CodeGen.hs
parent965f8bf85d7850be074bad735d815b15a85a3de0 (diff)
Separate lib into object file
Diffstat (limited to 'CodeGen.hs')
-rw-r--r--CodeGen.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/CodeGen.hs b/CodeGen.hs
index 774696f..764a900 100644
--- a/CodeGen.hs
+++ b/CodeGen.hs
@@ -9,7 +9,6 @@ import Data.List
import Data.Maybe
import Data.Map.Strict ((!))
import qualified Data.Map.Strict as Map
-import Text.Heredoc
import Debug.Trace
import AST
@@ -66,8 +65,10 @@ codegen (IRProgram vars funcs) = do
X64.verify x64
varcg <- liftM unlines $ mapM codegenVar vars
x64opt <- x64Optimise x64
- return $ [there|prologue.asm|] ++ "\n" ++ X64.stringify x64opt ++
- "\nsection .data\n" ++ (if length vars > 0 then varcg else "db 0 ; keep dyld happy\n")
+ return $ "extern putc, putint, getc, _builtin_malloc\n" ++
+ "global main\ndefault rel\nsection .text\n" ++
+ X64.stringify x64opt ++
+ "\nsection .data\n" ++ varcg
codegenVar :: DVar -> Error String