Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Lennart Augustsson <lennart <at> augustsson.net>
Subject: ANN: llvm-0.4.0.1
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Monday 22nd December 2008 07:39:52 UTC (over 8 years ago)
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
 
CD: 3ms