Skip to content

Commit f453fd6

Browse files
committed
show llvm generated machine code
1 parent 8bba112 commit f453fd6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

grin/app/Main.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import qualified CodeGenX64 as CGX64
1818
import qualified CodeGenLLVM as CGLLVM
1919
import qualified JITLLVM
2020
import VarGen
21+
import System.Process
2122

2223
import Data.IntMap as IntMap
2324
import Data.Map as Map
@@ -72,7 +73,13 @@ main = do
7273

7374
putStrLn "* LLVM codegen *"
7475
let mod = CGLLVM.codeGen $ Program grin
75-
CGLLVM.toLLVM (printf "%s.ll" fname) mod
76+
llName = printf "%s.ll" fname
77+
sName = printf "%s.s" fname
78+
CGLLVM.toLLVM llName mod
79+
80+
putStrLn "* LLVM X64 codegen *"
81+
callProcess "llc-5.0" [llName]
82+
readFile sName >>= putStrLn
7683

7784
putStrLn "* LLVM JIT run *"
7885
JITLLVM.eagerJit mod

grin/grin.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ executable grin
5959
, recursion-schemes
6060
, ansi-wl-pprint
6161
, containers
62+
, process
6263
default-language: Haskell2010
6364

6465
test-suite grin-test

0 commit comments

Comments
 (0)