This project, USCC, builds out a working compiler for a C language subset called USC (language reference). USCC uses the LLVM framework as its code generation engine.
Implemented a LL(1) parser
that parses the program into AST. [Handout] [Report]
Implemented scoped symbol table that enable scoped identifier declarations, and type checking/conversion that enables conversion between char
and int
. [Handout] [Report].
Implemented an IREmitter
that lowers various types of AST node (e.g., While
statement, If
statement) to LLVM IR using llvm::IRBuilder
. [Handout] [Report]
Implemented a fairly new approach to generate SSA form as outlined in this paper, which directly generate SSA form from the high-level AST, without generating non-SSA form first as in Clang/LLVM. [Handout] [Report]
Implemented three LLVM optimization passes, including constant branch folding, dead block removal and loop invariant code motion (LICM).
Implemented a graph-coloring register allocator with LLVM infrastructure (using RegAllocBase
interface), following this helpful tutorial. The algorithm is described in the Chatin-Brigg’s paper.