TIGER
implement a full compiler based on c++ 11
Install / Use
/learn @gangliao/TIGERREADME
TIGER - A Tiny Full Compiler
This tiny compiler includes both front end and back end.
Front end: Grammar Rules, LL(1) Parse Table, Syntax and Semantic Check and Intermediate Code.
Back end: IR Optimization (Intra-block CFG optimization), MIPS Register Allocation, Instruction Selection and Code Generation.
You can access https://github.com/gangliao/TIGER to view the documentation!
How to Build
-
development environment
Currently, this project repository is maintained on github publicly and also been deployed on Travis CI. It supports both Ubuntu and Mac OS X.
-
build:
# cd project dir cd Tiger-Compiler # build scanner, parser, generator mkdir build && cd build # cmake building tool cmake .. make -j4 -
run:
You can parsing test cases named
*.tigerunder/testCases2to generate IR code. Default it will utilize CFG optimized technique to generate MIPS asm code.# verbose mode: "-d to implement a verbose mode" ./src/parser <filename> -dIf you want to use the naive mode to generate asm code, simply issue:
./src/parser <filename> -d -naive -
test:
In testCases2 directory, it includes a test script
test.shto execute all test cases and generate the corresponding asm files*.naive.sand*.cfg.s.After souce code is compiled, you can simply issue the commands:
cd testCases2 sh ./test.sh
Demo
NOTE: This demo is gif graph format. If you have problem to view it in the markdown file,
you can directly open it which located at img/demo.gif.
This Demo shows that
(1) [Compile Source Code] How to compile and generate parser binary ?
(2) [Compiler Front End] How to transfrom raw tiger program into IR code ?
(3) [Compiler Back End] How to generate optimized MIPS asm code via IR code ?
<a href="img/demo.gif" target="_blank"><img src="img/demo.gif" width="1000" /></a>
Desgin Internals
Tiger Compiler Front End - Design Internals
Tiger Compiler Back End - Design Internals
Test Cases
We passed all tests cases which provided by TA.
Please check out the details in report Phase2_Testing_and_Output.pdf from current directory, which includes test cases and their quality comparisons for naive and CFG intra-block register allocation.
Accomplishment
- [x] Register allocation code
- [x] Naive
- [x] CFG and intra block allocation
- [ ] EBB and intra-EBB allocation
- [x] Whole function register allocation
- [x] Live Range Analysis and Graph Coloring
- [x] Instruction selection and generation code
- [x] Passes tests using generated code executing on simulator.
- [x] Report (desgin Internals, how to build, run, code quality comparisions, etc.)
