Hi, now I've had some free coding time. On Mon, 14 Jun 2004, Chris Lattner wrote:> Writing a scheme front-end for LLVM sounds like a great project: please > keep us informed how it goes, and when it gets mostly functional, let us > know so we can add a link on the web site. :) > > -ChrisJust to keep you informed. My small scheme compiler[1] of 1K lines is now self applicable, with the types fixnum, symbols, strings, functions and vectors (cons cells are seen as vectors of size 2). You can for example do: cat compile.ss|mzscheme --script compile.ss|llvm-as -o=ccomp.bc echo '(display "hello")'|lli ccomp.bc|llvm-as -o=hello2.bc But be warned, the resulting programs are painfully slow :). Next step is to implement garbage collection for it, since it right now just joyfully mallocs away :). (It actually runs out of memory if I try to compile compile.ss with ccomp.bc, i.e "cat compile.ss|lli ccomp.bc".) A question: would it be difficult to make my compiled compiler (ccomp.bc) call functions in llvm for creation of basic blocks and instructions, instead of using text format? (See under "LLVM primitives" in the scheme code.). I'll try to read up on how to use the JIT facilities, but I won't say no to any hints :). , Tobias [1] http://www.ida.liu.se/~tobnu/compile.ss
On Sat, 17 Jul 2004, Tobias Nurmiranta wrote:> > Hi, now I've had some free coding time. > > On Mon, 14 Jun 2004, Chris Lattner wrote: > > Writing a scheme front-end for LLVM sounds like a great project: please > > keep us informed how it goes, and when it gets mostly functional, let us > > know so we can add a link on the web site. :) > > > > -Chris > > Just to keep you informed. My small scheme compiler[1] of 1K lines is now > self applicable, with the types fixnum, symbols, strings, functions and > vectors (cons cells are seen as vectors of size 2).That is wonderful! Wow, you did this just ~1 month? :)> You can for example do: > > cat compile.ss|mzscheme --script compile.ss|llvm-as -o=ccomp.bc > echo '(display "hello")'|lli ccomp.bc|llvm-as -o=hello2.bcYou're right, it does work even :)> But be warned, the resulting programs are painfully slow :). Next step is > to implement garbage collection for it, since it right now just joyfully > mallocs away :). (It actually runs out of memory if I try to compile > compile.ss with ccomp.bc, i.e "cat compile.ss|lli ccomp.bc".)Cool, ok. Have you seen the LLVM GC support that is already available: http://llvm.cs.uiuc.edu/docs/GarbageCollection.html It should be able to support scheme well, though there may be some missing bits.> A question: would it be difficult to make my compiled compiler > (ccomp.bc) call functions in llvm for creation of basic blocks and > instructions, instead of using text format? (See under "LLVM primitives" > in the scheme code.). I'll try to read up on how to use the JIT > facilities, but I won't say no to any hints :).Actually we were just talking about this recently. I believe that Patrick (among other things) is working on a C API to the LLVM IR classes. Given a C-style API, it will definitely be callable from LLVM code (that's kinda the point of Patrick's work). Maybe he can say some more about where this stands?> [1] http://www.ida.liu.se/~tobnu/compile.ssThis is very neat. If you put together a little web page for it, and send me a blurb, I would be very happy to add this to the projects page. :) As you continue development on it, would you be interested in integrating this into the LLVM tree? -Chris -- http://llvm.cs.uiuc.edu/ http://nondot.org/sabre/
Hi, thanks for your mail! On Sat, 17 Jul 2004, Chris Lattner wrote:> > That is wonderful! Wow, you did this just ~1 month? :)Yes :), even less, but that is since I used the structure from SICP, see the URL below.> Cool, ok. Have you seen the LLVM GC support that is already available: > http://llvm.cs.uiuc.edu/docs/GarbageCollection.html > > It should be able to support scheme well, though there may be some missing > bits.Yes, I will read/use it closer and try to use it, and say if I miss something. It's GCs and persistent memories my Ph.d work is supposed to be about :). The scheme compiler is just a small hack for now so that I can easely understand and debug later on. But maybe I'll get obsessed. :)> Actually we were just talking about this recently. I believe that Patrick > (among other things) is working on a C API to the LLVM IR classes. Given > a C-style API, it will definitely be callable from LLVM code (that's kinda > the point of Patrick's work). Maybe he can say some more about where this > stands?Ok, I look forward to it!> > [1] http://www.ida.liu.se/~tobnu/compile.ss > > This is very neat. If you put together a little web page for it, and send > me a blurb, I would be very happy to add this to the projects page. :)Ok, here you go, http://www.ida.liu.se/~tobnu/scheme2llvm/ (what's a blurb? :)> As you continue development on it, would you be interested in integrating > this into the LLVM tree?Sure, it could probably at least be used as an example of how to use the GC support. Maybe smaller and easier to understand compared to a complete JVM. :) , Tobias