Home

Awesome

miniC->MIPS Compiler Project

This is a toy compiler that I am working on. It is written in C++. It uses the following libraries:

The goal of this project is to turn a toy C-like language (miniC) into MIPS32 assembly. The output will then be assembled (with an assembler written by me) into machine code. This machine code can then run on a virtual machine (also created by me). It is an exercise with compilers and computer architecture.

Compilation

To build the project, run the following command from the root directory:

mkdir build && cd build && cmake .. && make

This will generate an executable called compiler which accepts a program as an argument and outputs the compiled code to an assembly file (default is a.asm).

The compiler currently supports a few command line options:

FlagNameArgument(s)Description
<none>[files]specifies input files (max of one supported at the moment)
-vverbose<none>enables comments to be generated in the output file
-ooutput<file>specifies an output file

Testing

To generate tests, run the following command from inside the build directory:

cmake .. -Dtests=ON && make

Then, run the generated compiler_tests executable to run unit tests.

Documentation

You can generate documentation by running doxygen Doxyfile from the root directory. This will generate a docs folder with the documentation inside.

Structure

The compiler is split up into several folders (generated folders are starred).

foldercontent
docs*documentation generated by doxygen
examplesexample miniC code
includehpp, ih
langlanguage specification for flex/bison
srccpp
testtests

:octocat: