This is the final phase of the php-- compiler project. Your goal is to implement register allocation by building control-flow graphs, performing liveness analysis and then applying a simple coloring algorithm to the interference graphs generated from liveness.
You will want to begin by downloading the entire project.
You need work to in a handful of files, roughly one per subtask for this assignment. Look for "TODO" comments to indicate where you should be concentrating your efforts.
Control-flow graphs. You need to complete the FlowGraph constructor so that it properly builds a cfg for a given list of assembly instructions. You only need to assure that edges in the underlying directed graph are added: either to the next node (instruction) in the sequence, or to the targets of a jump or conditional.
You can test your construction of cfgs by uncommenting the appropriate line in the CompleteFunctions class. That will employ the writeDot method supplied with FlowGraph to generate "dot" output that can be pasted into a file and then viewed as a directed graph using the Graphviz suite. An example dot file generated for this simple php-- function is here; an example of what Graphviz (and the underlying "dot" software) can generate is here.)
Liveness. You only need to implement the iterative step from the previous values of the in and out computation to the new values. The rest is taken care of for you. (You can test this by uncommenting the appropriate lines in CompleteFunctions - it will print out something like this.)
Interference graphs. This is an undirected graph constructed such that each node corresponds to a temp and an edge between two nodes (temps) indicates that the two interfere - they have overlapping live ranges and cannot be stored in the same register. There are several ways to construct such a graph; I recommend following the provided shell code and then filling out the loop body (which will include an inner loop) to add an edge from every defined temp to every live-out temp at that node where the first temp is defined (except in the case where both temps in question are the two parts of a move instruction).
You can test your construction of interference graphs by uncommenting the appropriate line in the CompleteFunctions class. That will employ the writeNeato method supplied with InterferenceGraph to generate output that can be pasted into a file and then viewed as an interference graph using the Graphviz suite. An example undirected dot ("neato") file is here; an example of what Graphviz (and the underlying "neato" software) can generate is here.)
Coloring. Implement a simplified version of the coloring algorithms you have read about. You need not concern yourself with coalescing nodes, or redoing the coloring upon spills. You can test this (and, thus, the full compiler!) by running the generated MIPS assembly language in spim.
Upload a zipped archive of your final project here. Make sure you include a README file that explains that status of your project: what parts you did not have time to complete, if any; what special features to which you wish to draw attention; and any known bugs.