Assignment 3: Intermediate Code Generation

This assignment is the second part of a multi part project to write an optimizing compiler for Minijava. We start with typechecked Minijava programs and generate programs in MicroIR format. Akin to a standard optimizing compiler, in this assignment, we will implement a module that translates programs in a high level language (minijava) to programs in intermediate form (microIR).

Use JTB and JavaCC and write in Java one or more visitors which translate MiniJava programs to MicroIR form. Your main file should be called, if contains a program to be simplified then

java P3 < > P.microIR

should create P.microIR in MicroIR form and is semantically equivalent to Note, your program must take input from standard input and write to standard output (so that we can use redirection).

To check that a program is in MicroIR form, you could tie the MicroIR.jj and to build a parser. To ensure that your MicroIR program is semantically equivalent to the Minijava program, you can use the MicroIR interpreter (download) to compare the output of with the output of the microIR program generated by our translator; say the generated microIR code is stored in P.microIR, then to invoke the interpreter use: java -jar pgi.jar < P.microIR ]. A sample can be found here.

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