CS 6013 - Modern Compilers, Theory and Practice

Assignment 7:

This assignment is the last part of a multi part project to write an optimizing compiler for Minijava. In this assignment, we start with programs in miniRA format and translate them to MIPS assembly, after doing three of your own chosen peephole optimizations (See the Muchnick or Dragon book for reference).

Use JTB and JavaCC and write in Java one or more visitors which translate miniRA programs to assembly form. Your main file should be called Codegen.java, if P.miniRA contains a program to be assembled then

java Codegen < P.miniRA > P.s

should create P.s in MIPS assembly form and is semantically equivalent to P.miniRA. Note, your program must take input from standard input and write to standard output (so that we can use redirection). Further, submit a README.txt (should be present in the same directory as Codegen.java), that gives a short overview of the different peephole optimizations that you perform.

To check that a program is in miniRA form, you could tie the miniRA.jj and Main.java to build a parser. To ensure that your generated .s program is semantically equivalent to the miniRA program, you can use the MIPS interpreter (download) to compare the output of P.miniRA with the output of the .s program generated by Codegen. A sample Main.java can be found here.

Grading policy
Your homework will be graded for a total of 100 marks.
[ under development ]