As you enhance your compiler with optimizations remember that the two main concerns are safety and profitability. We only want to modify the code in ways that improve it while still maintaining its meaning. Therefore you should only include optimizations that you can guarantee will always be correct.
To get the starting point code for this project do update75.
Implement two choices from the following list as optimizations that will be done prior to code generation. This phase of the optimization will take the abstract syntax tree as input and return an updated abstract syntax tree as output. You may implement these optimizations by directly walking the abstract syntax tree, or by building a data flow graph of basic blocks.
You must also implement peephole optimization. This phase of the optimization will take place on the code table containing MIPS instructions as input and return an updated code table as output. Search and replace at least three different MIPS code patterns that occur relatively often and can be easily improved.
Your compiler should be implemented so that it can be invoked in the following ways.
python compiler.py foo.c-- foo.mips
python compiler.py -o1 foo.c-- foo.mips
python compiler.py -o2 foo.c-- foo.mips
python compiler.py -o3 foo.c-- foo.mips
Compiling test.c-- Output test.mips preOpt True postOpt True Executing preOptimizations Passes: 2 Executing postOptimizations Reduction in lines of assembly code: 5
In your directory for this project, include a subdirectory called optTests. This directory should contain at least two test programs for each optimization that you implemented. Also include a file called TEST-SUMMARY that lists each test name and its purpose.
Once you have successfully completed all required aspects of the C-- compiler (including optimizations), you can then attempt additional features for extra credit. An incomplete implementation of the required functionality plus an added feature will result in a lower grade than a complete implementation of the required functionality without any additional features.
Possible additional features include:
In your project directory you must include a text file called report.txt. Using at most two pages, give an overview of the design of your compiler. Explain the overall approach as well as each major component. You should describe the optimizations that you've included, as well as any additional features you've provided. If there are any aspects of your compiler that have not been fully implemented or are not working properly, your should discuss them here.
Run handin75 to turn in your complete compiler. Make sure that your cs75/projects/4 directory contains all of the code necessary to run your compiler.