An open API service indexing awesome lists of open source software.

https://github.com/gangliao/tiger

implement a full compiler based on c++ 11
https://github.com/gangliao/tiger

backend code-generator compiler cplusplus-11 front-end graph-coloring parser scanner

Last synced: 2 months ago
JSON representation

implement a full compiler based on c++ 11

Awesome Lists containing this project

README

        

## TIGER - A Tiny Full Compiler

[![Build Status](https://travis-ci.com/gangliao/TIGER.svg?token=bQUUVqcsZpghUieTvsMM&branch=master)](https://travis-ci.com/gangliao/TIGER/builds)

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

0. 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.

1. build:

```bash
# cd project dir
cd Tiger-Compiler
# build scanner, parser, generator
mkdir build && cd build
# cmake building tool
cmake ..
make -j4
```

2. run:

You can parsing test cases named `*.tiger` under `/testCases2` to generate IR code.
Default it will utilize **CFG optimized technique** to generate MIPS asm code.

```bash
# verbose mode: "-d to implement a verbose mode"
./src/parser -d
```

If you want to use the **naive** mode to generate asm code, simply issue:

```bash
./src/parser -d -naive
```

3. test:

In [testCases2](testCases2) directory, it includes a test script `test.sh` to execute all test cases and
generate the corresponding asm files `*.naive.s` and `*.cfg.s`.

After souce code is compiled, you can simply issue the commands:

```bash
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 ?

### Desgin Internals

[Tiger Compiler Front End - Design Internals](design_doc/front_end.md)

[Tiger Compiler Back End - Design Internals](design_doc/back_end.md)

### Test Cases

We passed all tests cases which provided by TA.

Please check out the details in report [Phase2_Testing_and_Output.pdf](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.)