CS 6013 - Modern Compilers, Theory and Practice

Assignment 4: Constant Propagation.

This assignment is the fourth 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 SSAMiniIR format.

Use JTB and JavaCC, to write in Java one or more visitors which implement Intra procedural constant propagation (Sparse Conditional Constant - WegmenZadeck style). Your main file should be called P4.java, if P.miniIR contains a program to be optimized in SSAminiIR form, then

java P4 < P.miniIR > Pc.SSAminiIR

should create Pc.SSAminiIR in SSAMiniIR form and is semantically equivalent to P.miniIR with some of the variables replaced with constants. The first line of the SSAminiIR file contains information about the number of phi nodes the SSA transformed miniIR program will contain (when we use the pruned SSA algorithm). 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 SSAminiIR form, you could tie the SSAminiIR.jj and Main.java to build a parser. To ensure that your optimized SSAminiIR program is semantically equivalent to the input MiniIR program, you can use the interpreter of SSAminiIR (same as that of miniIR) to compare the output of P.miniIR with the output of the Pc.SSAminiIR program generated by P4; say the generated SSAminiIR code is stored in Pc.SSAminiIR, then to invoke the interpreter use: java -jar pgi.jar < Pc.SSAminiIR ].

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.