|
@@ -4741,9 +4741,15 @@ Implement the compiler pass \code{allocate-registers}.
|
|
|
where \code{coloring} is a \code{Map} whose keys are vertices
|
|
|
and whose values are integer colors. The \code{color}
|
|
|
function takes a graph and an initial precoloring, which should be
|
|
|
- used to pre-set negative colors for vertices that already represent
|
|
|
- registers, including \code{rax}, \code{rsp}, and the
|
|
|
- caller-save registers. It then colors the remaining
|
|
|
+ used to pre-set colors for vertices that already represent
|
|
|
+ registers. (The registers you never want to used for storing variables
|
|
|
+ should be given negative numbers: these include \code{rax} and \code{rsp}.
|
|
|
+ The other registers that might appear in the graph are the caller-save
|
|
|
+ registers---if you have constructed the graph correctly, there will be
|
|
|
+ vertices for all the caller-save registers \emph{if} there are one or
|
|
|
+ more \code{callq} instructions in the function. These caller-save registers
|
|
|
+ should be pre-assigned colors $0,1,2,3,\ldots$. Can you see why?)
|
|
|
+ It then colors the remaining
|
|
|
vertices with colors 0,1,$\ldots$, trying to assign the smallest
|
|
|
possible color to each vertex. (The implementation of \code{color}
|
|
|
follows the general approach described in the book, but dispenses
|