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