CS 3310 - Language Translators

Assignment 5: Register allocation

This assignment is the fourth part of a multi part project to write an optimizing compiler for Minijava. In this assignment, we start with programs in (microIR) format and translate them to (miniRA).

Use JTB and JavaCC and write in Java one or more visitors which translate MicroIR programs to MiniRA form. Your main file should be called P5.java, if P.microIR contains a program to be register allocated then

java P5 < P.microIR > P.RA

should create P.RA in miniRA form and is semantically equivalent to P.microIR. 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 miniRA form, you could tie the miniRA.jj and Main.java to build a parser. To ensure that your miniRA program is semantically equivalent to the MiniIR program, you can use the interpreter of miniRA (download) to compare the output of P.microIR with the output of the miniRA program generated by your register allocator; say the generated miniRA code is stored in P.miniRA, then to invoke the interpreter use: java -jar kgi.jar < P.miniRA ]. A sample Main.java can be found here.

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