From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Thu, 03 Feb 2011 07:08:57 PST." References: <2c752317a96b7b8b980ad37e92ff6f01@terzarima.net> <20110203021608.006575B67@mail.bitblocks.com> <2c48b8397b29ededd862efa6de0baf70@brasstown.quanstro.net> From: Bakul Shah Date: Thu, 3 Feb 2011 09:41:29 -0800 Message-Id: <20110203174129.C984D5B91@mail.bitblocks.com> Subject: Re: [9fans] Modern development language for Plan 9, WAS: Re: RESOLVED: recoving important header file rudely Topicbox-Message-UUID: aaf8fe88-ead6-11e9-9d60-3106f5b1d025 On Thu, 03 Feb 2011 07:08:57 PST David Leimbach wrote: > On Wednesday, February 2, 2011, erik quanstrom 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.