Coursework for Compilers Module Imperial College EIE. A C90 to MIPS compiler.
Frontend: uses Flex as the lexer, Yacc as the parser - generates an AST in C++. Backend generates MIPS assembly code from the AST.
Nikhil Narayanan
Bryan Tan
- QEMU MIPS Emulator: install using
sudo apt install qemu-user
- MIPS Reference Compiler: install using
sudo apt install qemu-user
- Bison: install using
sudo apt install bison
- Flex: install using
sudo apt install flex
- MIPS Linux GNU: install using
sudo apt install gcc-mips-linux-gnu
The compiler can be built by running the following command in the top-level directory:
make bin/c_compiler
The compilation function is invoked using the flag -S
, with the source file and output file specified on the command line:
bin/c_compiler -S [source-file.c] -o [dest-file.s]
Contains a large number of example inputs, divided into various categories. The following scripts can be run to test the compiler on the testcases:
- Run one testcase:
./test_compiler <name-of-testcase>
- Run all testcases:
./test_compiler