LLVM & Incremental Compilation

Hi people!

I'm looking for a back-end compiler for a language project of mine, LLVM
looks promising, but I'd like to clear a few things up first:

1. What relation does LLVM bear with GCC; why would somebody use LLVM
for a compiler back-end over GCC (aside from the Virtual Machine)? How
do the goals of GCC and LLVM differ as compiler toolkits?

2. How conducive to Incremental Compilation is LLVM? I would like to be
able to compile and execute code in the same process immediately. An
example of this would be in an interactive programming environment, or a
Common Lisp style of compilation.

3. Is LLVM able to support advanced runtime features as continuations,
garbage collection and resuming exception handling. Would there be
anything in LLVM that would prevent these sorts of features? Is there
anything in the LLVM runtime that is assumed (dynamic typing, etc). Or
is LLVM as it's title sugests: Low-Level, so it won't get in your way?

Thanks for your time!

Tim.

Hi people!
I'm looking for a back-end compiler for a language project of mine, LLVM
looks promising, but I'd like to clear a few things up first:

1. What relation does LLVM bear with GCC; why would somebody use LLVM
for a compiler back-end over GCC (aside from the Virtual Machine)? How
do the goals of GCC and LLVM differ as compiler toolkits?

There are many differences in goals and implementation. LLVM does use a hacked on version of GCC for it's C and C++ parsers, but does not rely on it for anything else. GCC has advantages over LLVM (more target support etc), and LLVM has advantages over GCC (JIT compilation, easier to work with, interprocedural optimization, can use it to build non GPL tools, ...). This is really a big question that has many nuances, but that is at least part of it.

2. How conducive to Incremental Compilation is LLVM? I would like to be
able to compile and execute code in the same process immediately. An
example of this would be in an interactive programming environment, or a
Common Lisp style of compilation.

That is no problem. You can take a look at the llvm/examples/* directories, there are examples that build LLVM code on the fly and execute it.

3. Is LLVM able to support advanced runtime features as continuations,
garbage collection and resuming exception handling. Would there be
anything in LLVM that would prevent these sorts of features? Is there
anything in the LLVM runtime that is assumed (dynamic typing, etc). Or
is LLVM as it's title sugests: Low-Level, so it won't get in your way?

I believe that the only thing that we are presently missing is guaranteed tail calls, but it will be added in the near future. LLVM does not assume anything about your runtime, as you say, it doesn't get in your way. :slight_smile:

-Chris

3. Is LLVM able to support advanced runtime features as continuations,
garbage collection and resuming exception handling. Would there be
anything in LLVM that would prevent these sorts of features? Is there
anything in the LLVM runtime that is assumed (dynamic typing, etc). Or
is LLVM as it's title sugests: Low-Level, so it won't get in your way?

I believe that the only thing that we are presently missing is guaranteed tail calls, but it will be added in the near future. LLVM does not assume anything about your runtime, as you say, it doesn't get in your way. :slight_smile:

I would add a couple of minor caveats to this. Continuations are not a first-class feature in LLVM so any transformations that use them are not directly expressible - you would have to do those in a front-end if desired. Also, although you can *implement* any of the above language features in LLVM, I think the code for closures (and therefore any first-class functions) requires excessive use of void pointers and casts.

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/

And is there any chance that closure implementation could be made easier ?
If LLVM is to be used as a platform for new computer languages, tis would be important. I think that closures would be on the top of the expected features list for a "modern" language.

  -- Sébastien

That is entirely possible. However, LLVM evolution is driven by experience. This means we prefer to implement something the straight-forward way using existing features if we can, instead of adding a bunch of stuff to LLVM all of the time. This shows us exactly what the problems are, and allows us to understand what a good solution would look like.

If you propose a simple extension "in the spirit of LLVM" and demonstrate how it makes the produced code better in some way, there is a good chance that we'll accept it. However, if the extension is language or target specific, is not "low level", is complex, etc, we probably won't.

-Chris

Cool, that's good to know :slight_smile:

I don't have an LLVM project right now, but the more I see the evolution of the project, the more I know that I should start to use it :wink:

So nothing right now, but hopefully in a not-to-far-away future...

  -- Sébastien

Thanks Chris (& others who replied),

Tim.