Remove sign-extend arg to LLVMConstInt calls.
[sbcl/llvm.git] / README.LLVM
blobc5525961e68f1cff5b3e77a891301bdcf5158db5
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. :)
49 List of issues I'm having with LLVM:
50 * JIT doesn't support inline target-asm.
51 * JIT doesn't support TLS (neither fresh nor existing in outside executable)
52 * Appears that you cannot run inlining optimization on a single
53   function via a FunctionPassManager, only the entire module via
54   PassManager.
57 Things in LLVM that look sketchy that I haven't actually hit yet:
58 * Debug info support seems pretty poor currently. It looks likely that
59   that'll be fixed before it actually bothers me, though.
61 Todo list:
62 * Load-time evaluation (interning symbols, user-level LTV, constants, etc.)
63 * Finish off the rest of the simple stuff so I can support most kinds
64   of lisp expressions
65   NODES: cast
66   REF: special, global
67   SET: special, global
68   CONSTANTS: floats, complexes, bignum, character, cons, structures, vectors...
69   OTHER: ??
70 * Automatically generate calling-convention-adapting wrapper.
71 * Create an LLVM calling convention that supports m-v-return (...and
72   implement m-v-return). Could either use the existing SBCL
73   calling-convention or a new one.
74 * GC: Scavenge constant vectors in LLVM-compiled functions.
75 * Unwind. This is probably going to be hard...
76 * GC: collection of LLVM-compiled functions/modules. (not particularly
77   important for near future)