From 22518d52828733a3fc2b0d827b1dbccefef46355 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 26 Jan 2017 22:04:38 +0100 Subject: Actually compile to an object file --- .gitignore | 2 ++ main.hs | 21 +++++++++++---------- 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 -- cgit v1.2.3-70-g09d2