This assignment is the second part of a multi part project to write an optimizing compiler for Minijava.
We start with MiniIR programs and after doing constant
propagation (P3), generate programs in sminiIR format.
Use JTB and JavaCC, to write in Java one or more visitors which
implement Intra procedural constant propagation (Kildall
style).
Your main file should be called P3.java,
if P.miniIR contains a program to be optimized in miniIR form
then
java P3 < P.miniIR > Pc.sminiIR
should create Pc.sminiIR in sminiIR form and is semantically equivalent to
P.miniIR with some of the variables replaced with constants.
Note, your program must take input program from standard input and write to standard output (so that we can use redirection).
To check that your generated program is in sminiIR form, you could tie the sminiIR.jj and Main.java to build a parser.
To ensure that your optimized sminiIR program is semantically equivalent to
the input MiniIR program, you can use the interpreter of sminiIR (same as that of miniIR)
to compare the output of P.miniIR with the output of the Pc.sminiIR program generated by P3; say the generated sminiIR code is stored in Pc.sminiIR, then to invoke the interpreter use: java -jar pgi.jar < Pc.sminiIR ].
Grading policy
Your homework will be graded for a total of 100 marks.
20 marks for the contributed
testcases and 80 marks for the TAs testcases.
[ under development ]