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
Hi all, For completeness: I'm assuming http://darcs.serpentine.com/llvm is the site for the LLVM Haskell bindings, according to the earlier announcement http://groups.google.com/group/fa.haskell/browse_thread/thread/35575d8bb 8a5b31c. Groetjes, <>< Marnix -----Original Message----- From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Lennart Augustsson Sent: Monday, December 22, 2008 8:40 To: Haskell; Haskell Cafe Subject: [Haskell] ANN: llvm-0.4.0.1 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 mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (2)
-
Lennart Augustsson -
Marnix Klooster