jon at ffconsultancy.com
Sat Nov 24 21:37:57 PST 2007
On Sunday 25 November 2007 05:27, Jan Rehders wrote:
> >> . 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.
Right, that is not dissimilar to what I had in mind.
> > 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.
Yeah. Given that LLVM is written in C++ and C++ is notoriously difficult to
interface to (from OCaml at least), I was surprised to see a binary API
approach rather than a looser binding via some intermediate representation
like generating .ll files from OCaml code.
Is your .ll emitter in OCaml available?
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
More information about the llvm-dev