This package depends on the files from Project 5. It includes the idiv patch.
Remember that you may change the provided code so long as you keep the interfaces the same (so that we can use everyone's testers on everyone's assignments).
This is a group project. Groups of size 1 or 2 are acceptable.
The file full_basic_opt.mli defines an interface that the rest of the fullopt compiler uses to invoke optimizations at different points throughout the compilation process. Example implementations of each of these functions are provided in full_basic_opt.ml. (The examples do not encode a particularly good optimization.)
Your job is to use this interface to write at least one simple optimization that improves the quality of the generated code. The optimization should not rely on any dataflow analysis (although if you want to go that route, let us know). Extra credit will be assigned for implementing more than one optimization pass. We suggest that you choose from the following list of possible optimizations:
For (each of) the optimizations you implement, provide a short description of the algorithm used and an example of the transformation being applied to a snippet of code (either as an AST or instruction sequence). You should also gather quantitative evidence to show that your method has improved the generated code: if you're targeting speed, develop some micro-benchmarks and calculate the speedup. If you're trying to reduce code size, demonstrate your success by running your compiler on larger examples and giving instruction counts. (The demos from previous projects are good candidates. It's easy to update examples from arrproc to full OAT.)
You can receive extra credit for this assignment by implementing more than one of the optimizations listed above. You can also receive credit by implementing the same optimization at both the AST level and at the machine code level. You will not receive credit for the same optimization more than once at the same coarse level of abstraction (so you won't get points for submitting both untyped constant folding and typed constant folding or for submitting both IL constant folding and X86lite/X86 constant folding). If you have any questions (or wish to implement an optimization that is not in the above list), please contact us.
Remember that you are likely to see an improvement in performance if you experiment with running different sequences of your optimizations. For example, you could run several passes of constant folding and constant propagation (or of constant folding and unreachable code elimination). Document your results.
Edit the included readme.txt file, making sure to fill in your name(s) and email address(es).
You should also spend some time to ensure that your code is readable and well-commented. We have some suggestions and requirements for your programming style. You will definitely lose points for the file submission requirements (code must compile, 80 column limit, no tabs); however, barring any particularly egregious cases, you may take the remaining rules as suggestions.
Part of your grade will be based on testing. Some example tests and utility functions are provided in full_test.ml. You must use the testing framework provided and explicitly note any modifications in your readme.txt file. We ask that you name your test cases regularly: choose a username from those in your group. All test names and files should contain that username followed by an underscore as a prefix. (For example, if your username is cat and you have written a test case called alive, that test should be called cat_alive.)
The grading breakdown for this project is as follows:
Each optimization you complete for extra credit is worth another +10% (with a maximum of 4). You will be expected to document each new optimization as well as provide an analysis of the effects the optimizations have on one another. We will count your best optimization toward the 80% in the regular assignment breakdown.
Remember that your raw score will be scaled— that is, more difficult assignments will be worth more than less difficult assignments, even if the more difficult assignment has fewer available points.
First, make sure to clean your project with omake clean. All of the files you've written should be in projects/fullopt. Submit your assignment on ENIAC. Your project must run on ENIAC, including all test cases. Be sure to submit from ENIAC and not from some other Linux machine; otherwise you will get an error.
Switch to the projects directory and type: