Noeud « Next »: , Noeud « Previous »: T9 Given Code, Noeud « Up »: T9



4.11.4 T9 Code to Write

src/liveness/interference-graph.hh
src/liveness/interference-graph.cc
Unfortunately, the way the moves were encoded in the tarball we delivered for T8 is not right for T9. We could have used glue code to provide backward compatibility, but it was a poor solution yielding low quality code. Therefore the interface of the InterferenceGraph was upgraded, which will require some modifications in your existing code.

Rest assured that little work will actually be needed: the main modification is related to the fact that moves are now encoded as a list of pairs, while before we had a map mapping a node to the set of nodes in its move-related to.

src/regalloc/color.hh
Implement the graph coloring. The skeleton we provided is an exact copy of the implementation of the code suggest by Andrew Appel in the section 11.4 “Graph Coloring Implementation” of his book. A lot of comments that are verbatim copies of his comments are left in the code. Note that there are some error in this book, reported on his web page (voir Modern Compiler Implementation).

Pay attention to misc::set: there is a lot of syntactic sugar provided to implement set operations. The code of Color can range from ugly and obfuscated to readable and very close to its specification.

src/regalloc/libregalloc.cc
Run the register allocation on each code fragment. Remove the useless moves.
src/codegen/mips/codegen.cc
If your compiler supports spills, implement Codegen::rewrite_program.