[LLVMdev] Scheme compiler.

Tobias Nurmiranta spyck at lysator.liu.se
Sat Jul 17 11:08:39 PDT 2004

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).

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

More information about the llvm-dev mailing list