|
@@ -6765,19 +6765,19 @@ and \code{pushq} subtracts $8$ from the \code{rsp}.
|
|
|
Figure~\ref{fig:running-example-x86} shows the x86 code generated for
|
|
|
the running example (figure~\ref{fig:reg-eg}). To demonstrate both the
|
|
|
use of registers and the stack, we limit the register allocator for
|
|
|
-this example to use just two registers: \code{rbx} and \code{rcx}. In
|
|
|
-the prelude\index{subject}{prelude} of the \code{main} function, we
|
|
|
-push \code{rbx} onto the stack because it is a callee-saved register
|
|
|
-and it was assigned to a variable by the register allocator. We
|
|
|
-subtract \code{8} from the \code{rsp} at the end of the prelude to
|
|
|
-reserve space for the one spilled variable. After that subtraction,
|
|
|
-the \code{rsp} is aligned to 16 bytes.
|
|
|
+this example to use just two registers: \code{rcx} (color $0$) and
|
|
|
+\code{rbx} (color $1$). In the prelude\index{subject}{prelude} of the
|
|
|
+\code{main} function, we push \code{rbx} onto the stack because it is
|
|
|
+a callee-saved register and it was assigned to a variable by the
|
|
|
+register allocator. We subtract \code{8} from the \code{rsp} at the
|
|
|
+end of the prelude to reserve space for the one spilled variable.
|
|
|
+After that subtraction, the \code{rsp} is aligned to 16 bytes.
|
|
|
|
|
|
Moving on to the program proper, we see how the registers were
|
|
|
allocated.
|
|
|
%
|
|
|
\racket{Variables \code{v}, \code{x}, and \code{z} were assigned to
|
|
|
- \code{rbx}, and variables \code{w} and \code{tmp} was assigned to \code{rcx}.}
|
|
|
+ \code{rbx}, and variables \code{w} and \code{t} was assigned to \code{rcx}.}
|
|
|
%
|
|
|
\python{Variables \code{v}, \code{x}, \code{y}, and \code{tmp\_0}
|
|
|
were assigned to \code{rcx} and variables \code{w} and \code{tmp\_1}
|
|
@@ -6802,23 +6802,15 @@ done in the prelude. We move the stack pointer up by \code{8} bytes
|
|
|
\begin{tcolorbox}[colback=white]
|
|
|
% var_test_28.rkt
|
|
|
% (use-minimal-set-of-registers! #t)
|
|
|
- % and only rbx rcx
|
|
|
-%old:
|
|
|
-% tmp 0 rbx
|
|
|
-% z 1 rcx
|
|
|
-% y 0 rbx
|
|
|
-% w 2 16(%rbp)
|
|
|
-% v 0 rbx
|
|
|
-% x 0 rbx
|
|
|
-
|
|
|
-%new: rcx, rbx
|
|
|
-% tmp 0 rcx
|
|
|
-% z 1 rbx
|
|
|
-% w 0 rcx
|
|
|
-% y 2 rbp -16
|
|
|
-% v 1 rbx
|
|
|
-% x 1 rbx
|
|
|
-
|
|
|
+ % 0 -> rcx
|
|
|
+ % 1 -> rbx
|
|
|
+ %
|
|
|
+ % t 0 rcx
|
|
|
+ % z 1 rbx
|
|
|
+ % w 0 rcx
|
|
|
+ % y 2 rbp -16
|
|
|
+ % v 1 rbx
|
|
|
+ % x 1 rbx
|
|
|
{\if\edition\racketEd
|
|
|
\begin{lstlisting}
|
|
|
start:
|