On Sun, May 30, 2010 at 11:26 PM, Aaron Tomb <at...@galois.com> wrote:
>
> On May 30, 2010, at 7:01 AM, Tom Hawkins wrote:
>
>> Is there any work being done to read LLVM object code into Haskell?
>> I've looked through the llvm library [1], but it appears focused on
>> code generation.
>>
>> -Tom
>
> I was just looking through the Haddock pages for the llvm package with the 
> same question in mind, and realized that there is some support for reading 
> and dissecting bitcode files. It has a pretty low-level and un-Haskell-ish 
> interface, though.
>
> For instance, the LLVM.FFI.BitReader module has some functions that'll get 
> you a ModuleRef from some bitcode. It looks as though getFirstGlobal and 
> getNextGlobal will iterate through top-level things in a ModuleRef, including 
> functions. Alternatively, it looks like getNamedFunction will give you a 
> handle to a particular function. And there are functions to get the basic 
> blocks of a function, and to get the instructions of a basic block.
>
> All of these functions are in the IO monad, though, so they'd only really be 
> pleasant to use if you immediately built up a new AST, perhaps in some 
> special-purpose intermediate language, or perhaps in something resembling 
> LLVM structure, before doing any analysis.
>
> If anyone knows of a better way, I'm also very interested. Or, if anyone has 
> made any attempt to build higher-level abstractions out of the low-level 
> functions provided, I'm very interested. Maybe at some point I'll take a 
> crack at the latter myself.

Not quite related, but I'm currently hacking around to get the
LLVM.FFI bits of the llvm library rewritten to use c2hs, hopefully
with a slightly nicer low-level API that may help.

- Dave

>
> Aaron
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to