Support multiple basic blocks and "cif" nodes.
[sbcl/llvm.git] / README.LLVM
blob17aced9757c72f487cb1f82c111089363c1518f4
1 This is currently a set of hacks off to the side of SBCL to implement
2 LLVM compilation. It depends on CL-LLVM, which you can get from:
3   http://repo.or.cz/w/cl-llvm.git
5 There are two parts:
7 1) llvm/compile.lisp: Hacked up copies of a few functions in SBCL to
8 compile an expression, but stop after IR1.
9 2) llvm/llvm.lisp: emit LLVM code from IR1.
11 While this is a branch of SBCL, I've not actually modified anything in
12 SBCL at the moment...so to run this code, 
13  (require 'cl-llvm)
14  (load (compile-file "llvm/compile.lisp"))
15  (load (compile-file "llvm/llvm.lisp"))
17 Then, try compiling a function:
18  (llvm-compile '(lambda (x) (+ x 5)))
20 And try running it:
21  (run-fun * 3)
23 It's not been entirely clear whether it's a good idea to emit LLVM
24 code from IR1 or IR2, but I'm going with IR1. I think this is the
25 right thing to do, because LLVM, despite its "LL" name, really is
26 designed to be used in quite a high level.
28 In particular, I don't think SBCL's stack analysis, copy propagation,
29 or vop selection are likely to be useful. I'd like to just let LLVM
30 handle as many of the optimizations as is feasible.
32 Of course, one thing that *is* useful that SBCL does and LLVM does not
33 is representation selection.
35 Here's my current plan of record for replacing rep-selection:
37 - Where given the choice (registers/stack), store all unboxable items
38   unboxed. Do all immediate operations (non-generic arithmetic) on
39   unboxed values.
41 - When moving values to other forms, they will need to be
42   boxed. Simply do it on demand.
44 - Use magic to allow LLVM to optimize away redundant shifts/boxing
45   calls/etc. And I hope magic turns out to be powerful enough for
46   this. :)
50 Todo list:
51 * Implement cif/branching.
52 * Finish off the rest of the simple stuff so I can support most kinds
53   of lisp expressions (NODES: cast, cset; REF: special, global;
54   CONSTANTS: floats, complexes, bignum, character; OTHER: ??)
55 * Automatically generate calling-convention-adapting wrapper.
56 * Create an LLVM calling convention that supports m-v-return (...and
57   implement m-v-return). Could either use the existing SBCL
58   calling-convention or a new one.
59 * GC: Scavenge constant vectors in LLVM-compiled functions.
60 * Unwind. This is probably going to be hard...
61 * GC: collection of LLVM-compiled functions/modules. (not particularly
62   important for near future)