We have now released version 0.4.0.1 of the Haskell LLVM bindings.
(This release that is quite incompatible with the old 0.0.2 release.)

LLVM is a virtual machine and the bindings allow you to generate code
for this virtual machine.  This code can then be executed by a JIT
or written to a file for further processing by the LLVM tools.

The LLVM bindings has two layers.  You can either use the low level
bindings that is just the same as the C bindings for the LLVM.  This
level is quite unsafe as there is very little type checking.
The recommended way is a high level binding (somewhat less complete)
which eliminates many errors by leveraging the Haskell type system.

A simple example, generating code for a function that adds two
numbers and then calling it from Haskell:

import Data.Int
import LLVM.Core
import LLVM.ExecutionEngine

cgplus :: CodeGenModule (Function (Int32 -> Int32 -> IO Int32))
cgplus =
    createFunction InternalLinkage $ \ x y -> do
        r <- add x y
        ret r

main = do
    ioplus <- simpleFunction cgplus
    let plus = unsafePurify ioplus

    print $ plus 20 22


Enjoy!
    Bryan O'Sullivan
    Lennart Augustsson
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to