This project is a toy compiler for Mx* language to RISC-V assembly, implemented in Java.
It is a course project.
It reads code from code.txt
, prints IR in ir.txt
and prints RISC-V assembly in test.s
. The input file is test.in
.
Contents | Descriptions |
---|---|
Parser | Using ANTLR 4. |
AST | Nothing special. |
IR | The quadruple IR. |
Optimization | Function Inlining. |
Load global variables in advance and postpone store. | |
Loop-invariant code motion (on SSA). | |
Sparse conditional constant propagation (on SSA). | |
Common subexpression elimination (on SSA). | |
Dead code elimination (on SSA). | |
Control flow graph simplification (on both SSA and non-SSA). | |
...... (some others) | |
Register Allocation | Graph coloring. |
Assembly | RISC-V. |
B2 baseline (highest baseline in that course project) passed.
Slightly better than GCC O1.