summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-26 22:04:38 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-26 22:04:38 +0100
commit22518d52828733a3fc2b0d827b1dbccefef46355 (patch)
tree93cb566d2126944a173f9ab7fda0463845ce6319
parent311a353fea97e74eb049180da51b5395561975cc (diff)
Actually compile to an object file
-rw-r--r--.gitignore2
-rw-r--r--main.hs21
2 files changed, 13 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index aea9637..63bb50a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ main
ll/gen
ll/test.s
ll/test
+
+output_gen
diff --git a/main.hs b/main.hs
index 3f3a81b..ad9627b 100644
--- a/main.hs
+++ b/main.hs
@@ -5,9 +5,10 @@ import Control.Monad.Except
import Data.Either
import System.Environment
import System.Exit
+import qualified Data.ByteString as BS
import qualified LLVM.General as General
import qualified LLVM.General.Context as General
--- import qualified LLVM.General.Target as General
+import qualified LLVM.General.Target as General
import Check
import Codegen
@@ -50,8 +51,8 @@ main = do
putStrLn $ pshow checked
llvmMod <- either die return $ codegen checked "Module" fname
- -- putStrLn "Module:"
- -- print llvmMod
+ putStrLn "Module:"
+ print llvmMod
putStrLn "Calling withContext:"
General.withContext $ \context -> do
@@ -61,10 +62,10 @@ main = do
llvmasm <- General.moduleLLVMAssembly genmod
putStr llvmasm
putStrLn ""
- -- assert $ General.withHostTargetMachine $ \machine -> do
- -- General.getTargetMachineTriple machine >>= putStrLn
- -- putStrLn ""
- -- assert (General.moduleTargetAssembly machine genmod)
- -- >>= putStr
- -- bs <- assert $ General.moduleObject machine genmod
- -- BS.writeFile "output_gen.o" bs
+ assert $ General.withHostTargetMachine $ \machine -> do
+ General.getTargetMachineTriple machine >>= putStrLn
+ putStrLn ""
+ assert (General.moduleTargetAssembly machine genmod)
+ >>= putStr
+ bs <- assert $ General.moduleObject machine genmod
+ BS.writeFile "output_gen.o" bs