15-411 Compiler Design
For those interested in retargeting their compiler to the LLVM, it has
been installed in AFS so it can be accessed from the lab machines.
to your path or directly call the commands there from the shell.
Most relevant are:
- llvm-as file.ll assembles an llvm source file file.ll to bitcode file.bc
- llvm-lli file.bc arg1... interprets bitcode file.bc, passing it arg1...
- llvm-llc -march=x86-64 file.bc compiles bitcode file.bc to x86-64 assembly file.s
The gcc front end to llvm does not seem to work (gcc on lab machines
is too old). You can obtain llvm assembly source (.ll files) from C source
by using the on-line demo of LLVM and cutting/pasting
Documentation and help on LLVM is available at http://llvm.org.
- You will have to convert to SSA form to produce llvm source.
This is described in section 19.1 of the textbook.
- There is an alternative method for producing SSA form,
using mem2reg, one of the ``optimization'' passes of the LLVM tool set.
See Chapter 4.7
of the LLVM Tutorial.
- The llvm, like C, leaves the result of certain operations undefined
(e.g., division by 0), so you may need to turn them into function calls (and
make sure they are not inlined for optimization).
| Labs & Assignments
| Lab Machines