Name: llvm-hs-kaleidoscope
Owner: llvm-hs
Description: Kaleidoscope Tutorial using llvm-hs
Created: 2017-01-20 09:31:38.0
Updated: 2018-05-02 08:52:33.0
Pushed: 2018-02-24 12:37:26.0
Size: 26
Language: Haskell
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A minimal LLVM builder. Basically the same code as the Haskell Kaleidoscope tutorial uses but without going through a frontend AST.
If you want to roll a custom LLVM compiler backend this might be a good starting point for the backend.
Check that your installed LLVM version is precisely 5.0.
vm-config --version
To build using stack:
ack build
ack exec main
To build using cabal:
bal sandbox init
bal install --only-dependencies
bal build
To run:
bal run
rocessing executable 'standalone' for tutorial-0.2.0.0...
duleID = 'my cool jit'
ne double @main() {
try:
ret double 3.000000e+01
uated to: 30.0
Code is split across
The main program will use the embedded LLVM Monad to define a small program which will add two constants together.
Module :: AST.Module
Module = emptyModule "my cool jit"
c :: LLVM ()
c = do
fine double "main" [] $ \ptrToMain -> do
let a = cons $ C.Float (F.Double 10)
let b = cons $ C.Float (F.Double 20)
res <- fadd a b
ret res
:: IO (AST.Module)
= do
t ast = runLLVM initModule logic
nJIT ast
turn ast
This will generate and JIT compile into the following IR and use the LLVM execution engine to JIT it to machine code.
duleID = 'my cool jit'
ne double @main() {
y:
= fadd double 1.000000e+01, 2.000000e+01
t double %1