|
@@ -5506,13 +5506,13 @@ Run the script to test the \code{patch\_instructions} pass.
|
|
\end{exercise}
|
|
\end{exercise}
|
|
|
|
|
|
|
|
|
|
-\section{Print x86}
|
|
|
|
|
|
+\section{Prelude and Conclusion}
|
|
\label{sec:print-x86-reg-alloc}
|
|
\label{sec:print-x86-reg-alloc}
|
|
\index{subject}{calling conventions}
|
|
\index{subject}{calling conventions}
|
|
\index{subject}{prelude}\index{subject}{conclusion}
|
|
\index{subject}{prelude}\index{subject}{conclusion}
|
|
|
|
|
|
-Recall that the \code{print\_x86} pass generates the prelude and
|
|
|
|
-conclusion instructions to satisfy the x86 calling conventions
|
|
|
|
|
|
+Recall that this pass generates the prelude and conclusion
|
|
|
|
+instructions to satisfy the x86 calling conventions
|
|
(Section~\ref{sec:calling-conventions}). With the addition of the
|
|
(Section~\ref{sec:calling-conventions}). With the addition of the
|
|
register allocator, the callee-saved registers used by the register
|
|
register allocator, the callee-saved registers used by the register
|
|
allocator must be saved in the prelude and restored in the conclusion.
|
|
allocator must be saved in the prelude and restored in the conclusion.
|
|
@@ -5523,10 +5523,10 @@ In the \code{allocate\_registers} pass,
|
|
%
|
|
%
|
|
\python{add a field named \code{used\_callee} to the \code{X86Program} AST node}
|
|
\python{add a field named \code{used\_callee} to the \code{X86Program} AST node}
|
|
%
|
|
%
|
|
-that stores the set of
|
|
|
|
-callee-saved registers that were assigned to variables. The
|
|
|
|
-\code{print\_x86} pass can then access this information to decide which
|
|
|
|
-callee-saved registers need to be saved and restored.
|
|
|
|
|
|
+that stores the set of callee-saved registers that were assigned to
|
|
|
|
+variables. The \code{prelude\_and\_conclusion} pass can then access
|
|
|
|
+this information to decide which callee-saved registers need to be
|
|
|
|
+saved and restored.
|
|
%
|
|
%
|
|
When calculating the size of the frame to adjust the \code{rsp} in the
|
|
When calculating the size of the frame to adjust the \code{rsp} in the
|
|
prelude, make sure to take into account the space used for saving the
|
|
prelude, make sure to take into account the space used for saving the
|
|
@@ -5672,10 +5672,10 @@ main:
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
\begin{exercise}\normalfont
|
|
\begin{exercise}\normalfont
|
|
-Update the \code{print\_x86} pass as described in this section.
|
|
|
|
|
|
+Update the \code{prelude\_and\_conclusion} pass as described in this section.
|
|
%
|
|
%
|
|
\racket{
|
|
\racket{
|
|
-In the \code{run-tests.rkt} script, reinstate \code{print\_x86} in the
|
|
|
|
|
|
+In the \code{run-tests.rkt} script, add \code{prelude\_and\_conclusion} to the
|
|
list of passes and the call to \code{compiler-tests}.}
|
|
list of passes and the call to \code{compiler-tests}.}
|
|
%
|
|
%
|
|
Run the script to test the complete compiler for \LangVar{} that
|
|
Run the script to test the complete compiler for \LangVar{} that
|