|
@@ -2460,7 +2460,7 @@ start:
|
|
|
\end{minipage}
|
|
|
\end{tabular} \\
|
|
|
|
|
|
-In the output of \code{select-instructions}, there is a entry for
|
|
|
+In the output of \code{select-instructions}, there is an entry for
|
|
|
\code{locals-types} in the $\itm{info}$ of the \code{Program} node,
|
|
|
which is needed here so that we have the list of variables that should
|
|
|
be assigned to homes. The support code computes the
|
|
@@ -2801,7 +2801,7 @@ If there are more than six arguments, then the convention is to use
|
|
|
space on the frame of the caller for the rest of the
|
|
|
arguments. However, in Chapter~\ref{ch:functions} we arrange to never
|
|
|
need more than six arguments. For now, the only function we care about
|
|
|
-is \code{read\_int} and it takes zero argument.
|
|
|
+is \code{read\_int} and it takes zero arguments.
|
|
|
%
|
|
|
The register \code{rax} is for the return value of a function.
|
|
|
|
|
@@ -2812,7 +2812,7 @@ example from the caller point of view and then from the callee point
|
|
|
of view.
|
|
|
|
|
|
The program makes two calls to the \code{read} function. Also, the
|
|
|
-variable \code{x} is in-use during the second call to \code{read}, so
|
|
|
+variable \code{x} is in use during the second call to \code{read}, so
|
|
|
we need to make sure that the value in \code{x} does not get
|
|
|
accidentally wiped out by the call to \code{read}. One obvious
|
|
|
approach is to save all the values in caller-saved registers to the
|
|
@@ -2826,16 +2826,16 @@ location in the first place. Or better yet, if we can arrange for
|
|
|
\code{x} to be placed in a callee-saved register, then it won't need
|
|
|
to be saved and restored during function calls.
|
|
|
|
|
|
-The approach that we recommend for variables that are in-use during a
|
|
|
+The approach that we recommend for variables that are in use during a
|
|
|
function call is to either assign them to callee-saved registers or to
|
|
|
spill them to the stack. On the other hand, for variables that are not
|
|
|
-in-use during a function call, we try the following alternatives in
|
|
|
+in use during a function call, we try the following alternatives in
|
|
|
order 1) look for an available caller-saved register (to leave room
|
|
|
for other variables in the callee-saved register), 2) look for a
|
|
|
callee-saved register, and 3) spill the variable to the stack.
|
|
|
|
|
|
It is straightforward to implement this approach in a graph coloring
|
|
|
-register allocator. First, we know which variables are in-use during
|
|
|
+register allocator. First, we know which variables are in use during
|
|
|
every function call because we compute that information for every
|
|
|
instruction (Section~\ref{sec:liveness-analysis-r1}). Second, when we
|
|
|
build the interference graph (Section~\ref{sec:build-interference}),
|
|
@@ -3146,7 +3146,7 @@ locations if they are live at the same time, that is, if they
|
|
|
interfere with each other.
|
|
|
|
|
|
The most obvious way to compute the interference graph is to look at
|
|
|
-the set of live location between each statement in the program and add
|
|
|
+the set of live locations between each statement in the program and add
|
|
|
an edge to the graph for every pair of variables in the same set.
|
|
|
This approach is less than ideal for two reasons. First, it can be
|
|
|
expensive because it takes $O(n^2)$ time to look at every pair in a
|
|
@@ -3305,7 +3305,7 @@ sure that two variables do not get mapped to the same register if the
|
|
|
two variables interfere with each other. Thinking about the
|
|
|
interference graph, this means that adjacent vertices must be mapped
|
|
|
to different registers. If we think of registers as colors, the
|
|
|
-register allocation problem becomes the widely-studied graph coloring
|
|
|
+register allocation problem becomes the widely studied graph coloring
|
|
|
problem~\citep{Balakrishnan:1996ve,Rosen:2002bh}.
|
|
|
|
|
|
The reader may be more familiar with the graph coloring problem than he
|
|
@@ -3395,7 +3395,7 @@ such as \code{rax}, are assigned to negative integers. In particular,
|
|
|
we assign $-1$ to \code{rax} and $-2$ to \code{rsp}.
|
|
|
|
|
|
One might wonder why we include registers at all in the liveness
|
|
|
-analysis and interference graph, for example, we never allocate a
|
|
|
+analysis and interference graph. For example, we never allocate a
|
|
|
variable to \code{rax} and \code{rsp}, so it would be harmless to
|
|
|
leave them out. As we see in Chapter~\ref{ch:tuples}, when we begin
|
|
|
to use register for passing arguments to functions, it will be
|
|
@@ -3403,7 +3403,7 @@ necessary for those registers to appear in the interference graph
|
|
|
because those registers will also be assigned to variables, and we
|
|
|
don't want those two uses to encroach on each other. Regarding
|
|
|
registers such as \code{rax} and \code{rsp} that are not used for
|
|
|
-variables, we could omit them from the interference graph but that
|
|
|
+variables, we could omit them from the interference graph, but that
|
|
|
would require adding special cases to our algorithm, which would
|
|
|
complicate the logic for little gain.
|
|
|
|
|
@@ -3741,7 +3741,7 @@ notify the priority queue when their saturation changes.
|
|
|
\begin{description}
|
|
|
\item[$\LP\code{make-pqueue}\,\itm{cmp}\RP$] constructs an empty
|
|
|
priority queue that uses the $\itm{cmp}$ predicate to determine
|
|
|
- whether its first argument has lower or equal priority to its
|
|
|
+ whether its first argument has priority lower than or equal to its
|
|
|
second argument.
|
|
|
\item[$\LP\code{pqueue-count}\,\itm{queue}\RP$] returns the number of
|
|
|
items in the queue.
|
|
@@ -7465,7 +7465,7 @@ If there are
|
|
|
more than six arguments, then the convention is to use space on the
|
|
|
frame of the caller for the rest of the arguments. However, to ease
|
|
|
the implementation of efficient tail calls
|
|
|
-(Section~\ref{sec:tail-call}), we arrange to never need more than six
|
|
|
+(Section~\ref{sec:tail-call}), we arrange never to need more than six
|
|
|
arguments.
|
|
|
%
|
|
|
Also recall that the register \code{rax} is for the return value of
|