[Haskell-cafe] ANN / CFP - LLVM bindings for Haskell
Bryan O'Sullivan
bos at serpentine.com
Thu Jan 3 06:43:49 EST 2008
This is an early release of Haskell bindings for the popular LLVM
compiler infrastructure project.
If you don't know what LLVM is, it's a wonderful toybox of compiler
components, from a complete toolchain supporting multiple architectures
through a set of well-defined APIs and IR formats that are designed for
building interesting software with.
The official LLVM home page is here:
http://llvm.org/
The Haskell bindings are based on Gordon Henriksen's C bindings. The C
bindings are almost untyped, but the Haskell bindings re-add type safety
to prevent runtime crashes and general badness.
Currently, the entire code generation system is implemented, with most
LLVM data types supported (notably absent are structs). Also plugged in
is JIT support, so you can generate code at runtime from Haskell and run
it immediately. I've attached an example.
Please join in the hacking fun!
darcs get http://darcs.serpentine.com/llvm
If you want a source tarball, fetch it from here:
http://darcs.serpentine.com/llvm/llvm-0.0.2.tar.gz
(Hackage can't host code that uses GHC 6.8.2's language extension names
yet.)
There's very light documentation at present, but it ought to be enough
to get you going.
<b
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fibonacci.hs
Type: text/x-haskell
Size: 1626 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080103/0a989399/Fibonacci.bin
-------------- next part --------------
define i32 @fib(i32) {
entry:
icmp sle i32 %0, 2 ; <i1>:1 [#uses=1]
br i1 %1, label %return, label %recurse
return: ; preds = %entry
ret i32 1
recurse: ; preds = %entry
sub i32 %0, 1 ; <i32>:2 [#uses=1]
call i32 @fib( i32 %2 ) ; <i32>:3 [#uses=1]
sub i32 %0, 2 ; <i32>:4 [#uses=1]
call i32 @fib( i32 %4 ) ; <i32>:5 [#uses=1]
add i32 %3, %5 ; <i32>:6 [#uses=1]
ret i32 %6
}
fib 10 = 55
More information about the Haskell-Cafe
mailing list