Assignment 04 - microIR to miniRA Translator
Release Date | 27/09/2022 |
Deadline | 02/10/2022, 23:59 hours |
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. Register Allocation must be carried out using the Linear Scan algorithm.
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 P4.java, if A.microIR contains a program to be register allocated then
$ javac P4.java
$ java P4 < A.microIR > A.RA
should create A.RA in miniRA form and is semantically equivalent to A.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 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 A.microIR with the output of the miniRA program generated by your register allocator; say the generated miniRA code is stored in A.miniRA, then to invoke the interpreter use: java -jar kgi.jar < A.miniRA ]
Note: Please do not alter the directory structure of RollN0_P4
.
Only edit GJDepthFirst.java
and P4.java
Resources
The source files are on Github.
Get the source by cloning the entire repo:
$ git clone https://github.com/kayceesrk/cs3300_m22
If you have already cloned the repo, you can get the latest updates by:
$ cd cs3300_m22 # go to the cloned repo
$ git pull
The microIR grammar specification is BNF-microIR.
The miniRA grammar specification is BNF-miniRA.
Submission
Rename the folder RollN0_P4
with your roll number. For example, if your roll
number is cs99b999
, then the folder should be named cs99b999_P4
. Remove all
the .class
files before submission. For example, you can do:
$ cd cs99b999_P4
$ find . -name "*.class" | xargs rm
Then produce the compressed gzip archive as follows:
$ tar cvzf cs99b999_P4.tar.gz cs99b999_P4
Submit the .tar.gz
file.
Note: You should thoroughly test your code. Some sample mini java programs are provided for testing. Create positive and negative tests per feature and test your code before submission. Please ensure that there are no compilation errors. If there are compilation errors, that code will yield zero marks.