This assignment is the last part of a multi part project to write an optimizing compiler for Minijava.
We start with optimized MiniRA programs and generate
MIPS programs . Akin to a standard optimizing compiler,
in this assignment, we will implement a module that does assembly
code generation.
The MiniRA grammar can be
found both in javaCC and html
format.
The MIPS grammar can be
found both in javaCC and html
format.
A sample Main.java can be found here.
A set of sample testcases can be found here.
To check that a program is in MIPS form, you could tie the
mips.jj and Main.java to build a parser.
Sample translations to the sample MIPS programs can be found
here
To ensure that your MIPS program is semantically equivalent to
the MiniRA program, you can use the MIPS
(interpreter) to compare the output
of CodeGen (say it is stored in P.s) with the input program
P.miniRA.
Use JTB and JavaCC and write in Java one or more visitors which
translate MiniRA programs to MIPS form.
Your main file should be called CodeGen.java,
if P.miniRA contains a program in miniRA form
java CodeGen < P.miniRA > P.s
should create P.s in MIPS form and is semantically equivalent to
P.miniRA.
Note, your program must take input from standard input and write to standard output.
Grading policy
Your homework will be graded for a total of 100 marks (all public
testcases).