[LLVMdev] OCaml

Jan Rehders cmdkeen at gmx.de
Sat Nov 24 21:27:14 PST 2007


>> . Some interface to LLVM from OCaml
>> What work has already been done on this and similar ideas? What is  
>> the
>> easiest
>> way to interface a front-end written in OCaml with an LLVM backend?

I've written a compiler front end for a custom language in OCaml which  
features compilation and an interactive toplevel. Until now I am  
interfacing LLVM by emitting .ll files which contain a textual  
representation of the LLVM IR language and using some primitive custom  
bindings to interface the ExecutionEngine which drives the toplevel.  
When a function is evaluated it is compiled and converted into text  
form, sent to the toplevel, parsed again and fed into the jitting-VM.  
Exchanging values between the toplevel GUI frontend and compiled code  
works over some C functions with OCaml bindings to exchange s- 
expressions. This is clumsy but it works at least.

> There are some ocaml bindings in CVS by Gordon Henriksen :-
>        http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/
> Dont know anything about them but they seem pritty extensive.

You can find them in $LLVM_HOME/bindings/ocaml. According to their  
author they are not yet complete enough for a full front end but when  
I looked at them some weeks ago they seemed to already cover the code  
generation part completely.


More information about the llvm-dev mailing list