[LLVMdev] OCaml

Jon Harrop jon at ffconsultancy.com
Sun Nov 25 13:17:59 PST 2007


On Sunday 25 November 2007 21:00, Chris Lattner wrote:
> >> Lexing is the one issue though.
> >
> > How do you mean?
>
> I think he's observing that a majority of the tutorial code is
> actually spent on the lexer and parser, not on the llvm-specific pieces.

Right.

> > I'm just fiddling around with it now. The lexer, parser and AST
> > written using camlp4 might look something like this in OCaml:
>
> Sure, the existing tutorial would be shorter if the lexer/parser used
> lex/yacc too, but that wasn't the goal :).  The goal was the make it
> as simple and easy for newbies to understand, even if they didn't have
> any previous compiler experience.

Absolutely.

I think the most productive angle for me would be to write a higher-level 
front-end in OCaml rather than simply translating the existing tutorial into 
OCaml.

Ultimately, a minimal compiler for a statically-typed functional programming 
language that gave good performance for some cases (probably non-GC-intensive 
numeric code) would be an incredibly compelling demo for the use of LLVM in 
general compiler writing. This looks perfectly feasible to me.

I got the impression from some of the blurb that I read that the optimizer in 
LLVM might even be able to automate localized unboxing. Is that true? If so, 
that would make things a lot easier...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e



More information about the llvm-dev mailing list