The goal of this assignment is to improve the quality of your code by implementing high-quality register allocation and various optimizations in your compiler. In addition to code, your compiler will generate CFG diagrams showing the effects of various optimizations. You will also submit test programs that show off the effectiveness of your optimizer. Using various benchmark programs, we will compare the performance of your compiler against the compilers produced by other groups, and the compiler that has the most effective optimizations will earn a bonus.
For this assignment, there are three optimizations that you are required to implement:
For each optimization, you should think carefully about what program representation it is best done on. We suggest working through some example programs to convince yourself that you have the right analysis and program transformations worked out before doing implementation.
You are required to implement one of the following optimizations:
To be able to optimize code successfully, your compiler must be able to construct control-flow graphs for IR, and it must be able to flatten CFGs back into inline code for code generation purposes.
The compiler must also be able to generate displayable versions of CFGs in dot format, allowing easily visualization with Graphviz or other tools that accept this format. You will find this capability useful for debugging your optimizations, so get it working early on!
Your driver must support at least the following command-line interface:
java -jar <YOUR_JAR> <OPTIONS> <SOURCE_FILE>
As in previous assignments, your driver should accept the file name of an Iota9 source file. If the file is invalid Iota (syntactic or semantic), you should report a helpful error message including the position of the invalid code and a description of the problem. If the program is valid, you should compile it, and output the assembly to a file, with the name determined as given above in the description of the -o option.
For example, java -jar acm22_ahj5_mo85.jar +Oreg hello.i9
should output the assembly code the compiler produces for the program
hello.i9
into hello.s
, using register allocation
but no other optimizations.
You may add additional flags and options as long as you support these requirements.
Correctness is still essential, but now we also care about performance. We will evaluate the effectiveness of your compilers on a variety of small benchmark programs. The group whose compiler generates the best code will earn a bonus. Compilers that generate broken code will be penalized. The real bragging rights will be earned after PA7, when we will have a final performance contest with a wider variety of benchmark programs.
We have updated libi9 with a timer module that helps measure how long code takes. Please download the updated version and see include/timer.i9 for details.
For fun and good karma, you are encouraged to submit programs that you think are good performance benchmarks.
Each benchmark test case will be a valid Iota9 source file. It should conform to the format restrictions described in the previous programming assignment description for functional test cases.
We encourage each group to submit up to three short benchmark programs. Designing these benchmarks early is likely to help you develop more effective optimizations. We suggest you aim for benchmarks that take between 1 and 5 seconds unoptimized. Very short time intervals are hard to measure reliably; and long-running benchmarks will make your performance testing runs too time-consuming. Where possible, your benchmarks should also produce verifiable results, and ideally, self-verify.
If we do use your benchmarks to evaluate compiler projects, we are likely to change them, so don't try to specialize your compilers to recognize your own benchmarks.
As before, you are building upon your work from Programming Assignment 5. The protocol is the same as in prior assignments: you are required to develop and implement tests that expose any problems with your implementation, and then fix the problems.
As in previous assignments, please ensure that all your Java code lives in a package containing the NetId of at least one of your group members. Your code should compile without errors or warnings. Your code should not contain any superfluous print or debug statements.
Submit the following:
*.class
).Main-Class
to be your driver. This
will enable us to run your JAR file directly. See Sun's tutorial for
help with this.*.java
, *.flex
, *.cup
, etc.). Do not forget to
include your source. Failure to do so will likely
result in a 0 for this assignment..jar
, .zip
, or
.tar.gz
) containing your testing code and test cases..zip
, or .tar.gz
)
containing up to three benchmarks your group would like to submit.