Higher-level OCaml bindings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Higher-level OCaml bindings

Jon Harrop

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...

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Higher-level OCaml bindings

Chris Lattner
On Thu, 14 Feb 2008, Jon Harrop wrote:
> 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?

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

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Higher-level OCaml bindings

Jon Harrop
On Thursday 14 February 2008 16:33:25 Chris Lattner wrote:
> On Thu, 14 Feb 2008, Jon Harrop wrote:
> > Does CLang use a suitable intermediate representation for this to be
> > possible?
>
> 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.

Great! Sounds like CIL should do the trick:

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

:-)

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Higher-level OCaml bindings

Chris Lattner
On Thu, 14 Feb 2008, Jon Harrop wrote:
>> 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.
>
> Great! Sounds like CIL should do the trick:
>
>  http://manju.cs.berkeley.edu/cil/

Huh?

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Higher-level OCaml bindings

Jon Harrop
On Thursday 14 February 2008 17:24:04 Chris Lattner wrote:

> On Thu, 14 Feb 2008, Jon Harrop wrote:
> >> 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.
> >
> > Great! Sounds like CIL should do the trick:
> >
> >  http://manju.cs.berkeley.edu/cil/
>
> Huh?

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. :-)

Thanks,
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev