Higher-level OCaml bindings

I'm still meddling with different ways to exploit LLVM's awesome JIT
compilation capabilities from OCaml. Although I've managed to get minimal
compilers up and running with relatively little effort, I can't help but
think that I'm spending a significant amount of time reinventing the C
front-end.

Would it make sense to have higher-level OCaml bindings to the current CLang
front-end to make code generation even easier?

Does CLang use a suitable intermediate representation for this to be possible?

Just an idea...

The higher level IR that clang uses is basically a C AST. This interface is under constant flux though. If you wanted to do this, it would be very reasonable to just cons up some C code and send it through the clang parser. Clang works great in a JIT environment.

-Chris

Great! Sounds like CIL should do the trick:

  http://manju.cs.berkeley.edu/cil/

:slight_smile:

Huh?

-Chris

CIL should provide the AST type already in OCaml with a pretty printer to
generate C code as a string that can be fed straight into CLang for JIT
compilation. Then all I need is bindings to actually invoke CLang from OCaml
with a string containing the source code.

I'm particularly interested in making FFI to existing C libraries as easy as
possible using code compiled by my compiler. I can't think of a better way
than explicitly using C as an intermediate language. :slight_smile:

Thanks,