|
1 | 1 | # C0_Compiler
|
2 |
| -Project of 'Compiler Technology' Course of SCSE,BUAA |
3 |
| -没完工呢 |
| 2 | +Final Project of ' Design of Compiler Technology' Course of SCSE,BUAA |
| 3 | +### Overview |
| 4 | +This is the repository for the project of "Design of Compiler Technology".This project contains a simple compiler which can translate a 'C0' language to MIPS assembly language. |
| 5 | +### About the 'C0 language' |
| 6 | +C0 language is a slightly modified and simplified High-level programming language based on C language. The grammar of this 'C0' language is LL(1) grammar.<br> |
| 7 | +The Grammar of this C0 language is shown bellow. |
| 8 | +[!](Annotation 2019-09-26 123820.jpg) |
| 9 | +### About the simple compiler |
| 10 | +This compiler contains a 'frontend' and a 'backend.<br> |
| 11 | +In the front end we implemented Lexical analysis,Grammar analysis ( recursive-descend method), and the fault handling. The front end can translate the original C0 language to midcode. |
| 12 | +The backend translates midcode to the target assembly language : mips. The following optimization is Implemented: |
| 13 | + |
| 14 | +- Active variables analysis |
| 15 | +- automatic inline function |
| 16 | +- DAG optimization (elimination of shared expression) |
| 17 | +- Elimination of dead code |
| 18 | +- substitution for assign instruction |
| 19 | +- constant proporgation and substitution |
| 20 | +- peephole optimization |
| 21 | +- Simple calculation in compilation phase |
| 22 | +- graph coloring algorithm for distribution of global register |
| 23 | +- distribution of temporary register based on active variables analysis |
| 24 | +### Development Environment |
| 25 | +Editor:VS2019<br> |
| 26 | +Complier: clang++ 8.0 msvc g++7.2.0<br> |
| 27 | +Debugger: gdb debugger of msvc |
| 28 | +### How to use this compiler |
| 29 | +In command line: |
| 30 | +``` |
| 31 | +usage: C0compiler.exe sourcefile |
| 32 | +[-o outputfile] |
| 33 | +[-d debugInformation] |
| 34 | +[-rdi recursiveDescendInformationFile] |
| 35 | +[-h] help document |
| 36 | +[-opt] turn on the optimization |
| 37 | +``` |
| 38 | +if no argument is passed to the complier,the program will be run under HomeWork Acceptance Test Mode. Under such circumstance,the source file must be "testfile.txt" and the output file must be "mips.txt" |
| 39 | + |
0 commit comments