This assignment is the third part of a multi part project to write an optimizing compiler for Minijava.
We start with MiniIR programs and after doing constant
propagation (ConstProp), generate programs in MiniIR format.
The MiniIR 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 MiniIR form, you could tie the
MiniIR.jj and Main.java to build a parser.
To ensure that your MiniIR program is semantically equivalent to
the original MiniIR program, you can use the MiniIR interpreter
(download) to compare the output
of your constant propagation module (say it is stored in Pc.miniIR) with the input program
P.miniIR [ To invoke the interpreter use: java -jar pgi.jar <
P.miniIR ]
Use JTB and JavaCC and write in Java one or more visitors which
implement (a) Intra procedural constant propagation (Kildall
style) and (b) Interprocedural constant propagation (similar to
Wegmen, Zadeck).
Your main file should be called ConstProp.java,
if P.miniIR contains a program to be optimized then
java ConstProp < P.miniIR > Pc.miniIR
should create Pc.miniIR in MiniIR form and is semantically equivalent to
P.miniIR with some of the variables replaced with constants.
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.
20 marks for the contributed
testcases and 80 marks for the instructors testcases.
Students can get upto 10 bonus points by contributing good testcases. Details can be found
here.