On Thu, 03 Feb 2011 07:08:57 PST David Leimbach <leim...@gmail.com>  wrote:
> On Wednesday, February 2, 2011, erik quanstrom <quans...@quanstro.net> wrote:
> >> It is a C/C++/Obj-C compiler & does static analysis, has
> >> backends for multiple processor types as well as C as a
> >> target, a lot of optimization tricks etc. See llvm.org. But
> >> frankly, I think they have lost the plot. C is basically a
> >> portable assembly programming language & in my highly biased
> >> opinion a C compiler should do no more than peephole
> >> optimizations. If you want more, might as well use a high
> >> level language.
> >
> > preach it, brother. i couldn't agree more.
> >
> > - erik
> >
> >
> Well LLVM uses its internal ASTs for a lot of the optimizations doesnt
> it?  My understanding is LLVM is a stack of software that you compose
> other programming language tools by including the libraries you want.
> One might be able to remove the optimizing behaviors one doesn't want
> pretty easily, or write one's own optimizing layer that's stripped
> down.  Then one could have the "do what I said" compiler instead of
> the "do what you think I meant" one.

I agree with their goal but not its execution.  I think a
toolkit for manipulating graph based program representations
to build optimizing compilers is a great idea but did they
do it in C++?

Consider what `stalin' does in about 3300 lines of Scheme
code. It translates R4RS scheme to C and takes a lot of time
doing so but the code is generates is blazingly fast. The
kind of globally optimized C code you or I wouldn't have the
patience to write. Or the ability to keep all that context in
one's head to do as good a job. Stalin compiles itself to
over 660K lines of C code! Then you give this C code to gcc
and it munches away for many minutes and finally dies on a
2GB system! If gcc was capable of only doing peephole
optimizing, it would've been able to generate code much more
quickly and without need gigabytes of memory.

Given funding and a lot of free time it would make more sense
to build a language agnostic optimizing toolkit by learning
& stealing concepts/code from Stalin. Ideally:

< src src-to-graph | optimizer | graph-to-C | cc > obj

Where pipes are two way.

> I believe there are occasions for each type of compiler really.

Yes.

> It might seem really big and bloated but I still think what they've
> done is kind of neat.  Making a real compiler in Haskell or O'Caml is
> pretty damned easy with LLVM bindings.
> 
> I wonder how difficult it is to target Plan 9 with LLVM.

Reply via email to