CSL 862 / CS 902. Minijava Register Allocator

This assignment is the second part of a multi part project to write an optimizing compiler for Minijava. We start with optimized MiniIR programs and generate programs in MiniRA format. Akin to a standard optimizing compiler, in this assignment, we will implement a module that register allocates programs in an intermediate language (MiniIR) and generates programs with pseudos replaced by registers (MiniRA).

The MiniIR grammar can be found both in javaCC and html format. The MiniRA 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 MiniRA form, you could tie the MiniIR.jj and Main.java to build a parser. Sample translations to the sample MiniIR programs can be found here To ensure that your MiniRA program is semantically equivalent to the MiniIR program, you can use the MiniRA interpreter (download) to compare the output of RegAlloc (say it is stored in P.miniRA) with the input program P.miniIR [ To invoke the interpreter use: java -jar kgi.jar < P.miniRA ] Use JTB and JavaCC and write in Java one or more visitors which translate MiniIR programs to MiniRA form. Your main file should be called RegAlloc.java, if P.miniIR contains a program to be register allocated then

java RegAlloc < P.miniIR > P.miniRA

should create P.miniRA in MiniRA form and is semantically equivalent to P.miniIR. 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. Of these 50 marks will be for the public testcases, 10 marks for the contributed testcases and 40 marks for the instructors testcases. Students can get upto 10 bonus points by contributing good testcases. Details can be found here.