Toy Compiler for Compiler 2016 Course
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea AST framework Mar 26, 2016
design
lib test correctness pass (except 2 testcase) May 5, 2016
src/com/abcdabcd987/compiler2016
test/com/abcdabcd987/compiler2016 function inlining May 12, 2016
testcase run all testcase correctly! 2 testcases excceed limit. May 6, 2016
.gitignore test correctness pass (except 2 testcase) May 5, 2016
compiler2016.iml add lib/ Apr 6, 2016
finalvars.sh
makefile final term env bugfix May 7, 2016
midtermvars.sh midterm Apr 6, 2016
readme.md update readme May 18, 2016

readme.md

Compiler 2016

This is a toy compiler for the course Compiler 2016 at ACM Class, SJTU. The source language is Mx*. The target is MIPS assembly (in SPIM format).

You can refer to my presentation slides (or on SlideShare) to know something about this compiler and also what I've learnt during the course.

When debugging this compiler, I wrote another project LLIRInterpreter which reads text IR and does interpretation.

Feature (what you can find in the source code)

  • Copy elimination
  • Function inlining
  • SSA Transform
    • Construction
    • Destruction
    • Naive dead code elimination
    • Simple constant propagation
  • Register Allocation
    • Local bottom-up allocator
    • Interference graph coloring allocator

Usage

$ java com.abcdabcd987.compiler2016.Mill --help
Mill - Mx* language implementation made with love by abcdabcd987
Usage: mill [options] [input]
Options:
  -help              Print this help message
  -o <file>          Write output to <file>
  -reg-alloc <val>   Set register allocator to <val>
                     Available register allocators:
                       no:    Don't allocate at all. (CISC-like)
                       local: Local bottom-up allocator
                       color: Global allocation by interference graph coloring
  -print-ast         Print the abstract semantic tree
  -print-ir          Print the intermediate representation
  -print-ssa-ir      Print the intermediate representation after SSA transforms
  -no-inline         Disable function inlining
  -no-ssa            Disable single static assignment analysis and transforms
  -no-naive-dce      Disable naive dead code elimination
  -no-scp            Disable simple constant propagate