Compiler Forms - lgxZJ/Tiger-Compiler GitHub Wiki
The front end of this compiler consists of following phases:
- Lexical Analysis
- Syntax Analysis(Parsing)
- Abstract Syntax
- Semantic Analysis
- Activation Records
- Translation to Intermediate Code
The back end of this compiler consists of following phases:
- Basic Blocks and Traces
- Instruction Selection
- Liveness Analysis
- Register Allocation
The following picture in Tiger Book illustrates why there is a need to divide a compiler into two ends (IR stands for Intermediate Code):
We can see that, without IR to separate compilers into two ends, If we want to compile five different languages into four different machines, we have to write 5*4 (namely 20) compilers. But if we do use IR to divide one compiler into two parts, then we have to merely implement 5 front ends and 4 back ends which greatly reduces the whole work! (Programmers are lazy-_-)
Other benefits includes:
- Better modularity
- Better portability
- Better code reuse