CS980-01
Project Assignment 6
Fall 2007
Due Monday December 17


Color the interference graph you constructed in the last assignment to map virtual registers to real registers.

See Cooper and Torczon 13.5.5 for a discussion of coloring interference graphs.

Continue to analyze each function in the input program independently. That is, color an interference graph for each function in the input program.

Integrate the code for this assignment with your code from the last three assignments.

The top priority for the assignment is to get correctly executing code for the Intel EM64T.

This means allocating time to debug the version of pcc3 that you are using. If you are sharing a version of pcc3, then you may work together in this debugging.

However, in doing the coloring itself, you should work independently.

This also means developing an initial, sub-optimal approach to do the coloring. For coloring I recommend you utilize the subset of the real registers that are not used for any other purpose (such as passing arguments, returning values, multiply, divide, etc.). In particular, consider using only rbx, r10-r15, and xmm8-xmm15. Some of these registers are callee-saved (rbx and r12-r15), which means that if you use them then you will need to save them upon entry to the function and restore them prior to exit of the function. You should save them into the frame, which will require increasing the size of the frame for this purpose.

The program that will be used for grading is a suite of ten benchmarks collected into a single file. The key goal for this assignment is to get this program executing using our register-based code-generation approach on the Intel EM64T.

I have a stack-based version of pcc3 that correctly compiles this benchmark. Please pick up and look at this compiler and the code it generates, if you feel it would help you in any way with this assignment.

You can also compile and execute this program using gcc.

The correct output from the benchmark program is available in file. (However, of course, you can re-create this output using gcc or the stack-based pcc3.) Executing the code generated by your code generator for this program should produce identical output to this file.

Once you have the benchmark program executing correctly, then time its performance. On gauss.unh.edu run 100 iterations of the benchmark and use the Unix "time" command to time the execution when there is no output. See the comments at the top of the benchmark in order to set the number of iterations and to turn off the output. (And note that you must preprocess the benchmark file before you run it through your version of pcc3.)

Use the user time reported by "time". Run the benchmark program several times to be sure the execution time is repeatable. Record the time rounded to tenths of a second.

Here are timings I took today that you should compare yourself to:

  1. stack-base pcc3: 6.2 seconds
  2. gcc: .9 seconds
  3. gcc -O: .5 seconds

I am not sure if the benchmark program will cause your code generator to have to spill virtual registers to memory. If so, you should allocate space in the frame for the spilled values. And you should choose the virtual register to spill as the one with highest number of edges (i.e. the one with the highest degree).

If the benchmark program does not cause a spill, then contrive an example program to demonstrate that you can successfully spill and reload register contents.

Once you have code correctly executing, including spilling, then for full credit try to do extend your approach to better utilize all the registers. I outlined one approach in class which involved extending the interference graph to include the real registers that are used in the input code your register allocator processes. The real registers would be in essence pre-colored nodes in the interference graph. And then try coalescing two nodes of the graph if they are both used in the same copy instruction and the two nodes are not connected in the graph.

You also are free to come up with your own approach. However, the goal is to improve the quality of the code generated as measured by execution time. Therefore when the improvement is complete, time it on the benchmark program as discussed above.

Points will be assigned in the following way:

For grading you should submit the following:

  1. the source code for the version of pcc3 you are using;
  2. the source code for your code generator;
  3. a README file that indicates how to build and execute your code generator;
  4. an example program to illustrate spilling, if necessary;
  5. and, a brief report that explains the approach you have taken to coloring the interference graph and producing executable code, and that contains and analyzes any timing data you collected.
Please submit the report in PDF format.

To submit this assignment you should tar and gzip up the above items and e-mail me the resulting file. Also, if you want me to re-evaluate an earlier assignment (either assignment 4 or 5) then please let me know either in your e-mail message or in your README file.

This assignment is due at 1:30pm on Monday December 17. However, these is a two-day grace period that ends at 1:30pm on Wednesday November 19. No assignments may be submitted after this time without my prior approval.


Last modified on November 20, 2007.

Comments and questions should be directed to hatcher@unh.edu