|
@@ -851,7 +851,7 @@ $R_0$ expressions.
|
|
|
[(Prim 'read '())
|
|
|
(define r (read))
|
|
|
(cond [(fixnum? r) r]
|
|
|
- [else (error 'interp-R1 "expected an integer" r)])]
|
|
|
+ [else (error 'interp-R0 "expected an integer" r)])]
|
|
|
[(Prim '- (list e))
|
|
|
(define v (interp-exp e))
|
|
|
(fx- 0 v)]
|
|
@@ -1254,11 +1254,11 @@ criteria in the following diagram.
|
|
|
In the next section we introduce enough of the x86 assembly
|
|
|
language to compile $R_1$.
|
|
|
|
|
|
-\section{The x86 Assembly Language}
|
|
|
+\section{The x86$_0$ Assembly Language}
|
|
|
\label{sec:x86}
|
|
|
|
|
|
Figure~\ref{fig:x86-0-concrete} defines the concrete syntax for the subset of
|
|
|
-the x86 assembly language needed for this chapter.
|
|
|
+the x86 assembly language needed for this chapter, which we call x86$_0$.
|
|
|
%
|
|
|
An x86 program begins with a \code{main} label followed by a sequence
|
|
|
of instructions. In the grammar, the superscript $+$ is used to
|
|
@@ -1317,7 +1317,7 @@ the x86 instructions used in this book.
|
|
|
\]
|
|
|
\end{minipage}
|
|
|
}
|
|
|
-\caption{The concrete syntax of the $x86_0$ assembly language (AT\&T syntax).}
|
|
|
+\caption{The concrete syntax of the x86$_0$ assembly language (AT\&T syntax).}
|
|
|
\label{fig:x86-0-concrete}
|
|
|
\end{figure}
|
|
|
|
|
@@ -1492,7 +1492,7 @@ returns the stack pointer to where it was prior to the procedure call.
|
|
|
|
|
|
The compiler needs a convenient representation for manipulating x86
|
|
|
programs, so we define an abstract syntax for x86 in
|
|
|
-Figure~\ref{fig:x86-0-ast}. We refer to this language as $x86_0$ with
|
|
|
+Figure~\ref{fig:x86-0-ast}. We refer to this language as x86$_0$ with
|
|
|
a subscript $0$ because later we introduce extended versions of this
|
|
|
assembly language. The main difference compared to the concrete syntax
|
|
|
of x86 (Figure~\ref{fig:x86-0-concrete}) is that it does not allow labeled
|
|
@@ -1527,7 +1527,7 @@ x86_0 &::= & \PROGRAM{\itm{info}}{\CFG{\key{(}\itm{label} \,\key{.}\, \Block \ke
|
|
|
\]
|
|
|
\end{minipage}
|
|
|
}
|
|
|
-\caption{The abstract syntax of $x86_0$ assembly.}
|
|
|
+\caption{The abstract syntax of x86$_0$ assembly.}
|
|
|
\label{fig:x86-0-ast}
|
|
|
\end{figure}
|
|
|
|
|
@@ -1813,7 +1813,7 @@ C_0 & ::= & \PROGRAM{\itm{info}}{\CFG{\key{(}\itm{label}\,\key{.}\,\Tail\key{)}^
|
|
|
\subsection{The dialects of x86}
|
|
|
|
|
|
The x86$^{*}_0$ language, pronounced ``pseudo x86'', is the output of
|
|
|
-the pass \key{select-instructions}. It extends $x86_0$ with an
|
|
|
+the pass \key{select-instructions}. It extends x86$_0$ with an
|
|
|
unbounded number of program-scope variables and has looser rules
|
|
|
regarding instruction arguments. The x86$^{\dagger}$ language, the
|
|
|
output of \key{print-x86}, is the concrete syntax for x86.
|
|
@@ -2852,8 +2852,10 @@ sets shown between each instruction to make the figure easy to read.
|
|
|
\begin{exercise}\normalfont
|
|
|
Implement the compiler pass named \code{uncover-live} that computes
|
|
|
the live-after sets. We recommend storing the live-after sets (a list
|
|
|
-of lists of variables) in the $\itm{info}$ field of the \key{Block}
|
|
|
-structure.
|
|
|
+of a set of variables) in the $\itm{info}$ field of the \key{Block}
|
|
|
+structure. We recommend using the
|
|
|
+\href{https://docs.racket-lang.org/reference/sets.html}{\code{racket/set}}
|
|
|
+package for representing sets of variables.
|
|
|
%
|
|
|
We recommend organizing your code to use a helper function that takes
|
|
|
a list of instructions and an initial live-after set (typically empty)
|
|
@@ -4052,7 +4054,7 @@ modern computer architectures.
|
|
|
\end{exercise}
|
|
|
|
|
|
|
|
|
-\section{XOR, Comparisons, and Control Flow in x86}
|
|
|
+\section{The x86$_1$ Language}
|
|
|
\label{sec:x86-1}
|
|
|
|
|
|
To implement the new logical operations, the comparison operations,
|
|
@@ -4115,7 +4117,7 @@ x86_1 &::= & \gray{\PROGRAM{\itm{info}}{\CFG{\key{(}\itm{label} \,\key{.}\, \Blo
|
|
|
\]
|
|
|
\end{minipage}
|
|
|
}
|
|
|
-\caption{The abstract syntax of $x86_1$ (extends x86$_0$ of Figure~\ref{fig:x86-0-ast}).}
|
|
|
+\caption{The abstract syntax of x86$_1$ (extends x86$_0$ of Figure~\ref{fig:x86-0-ast}).}
|
|
|
\label{fig:x86-1}
|
|
|
\end{figure}
|
|
|
|
|
@@ -5788,7 +5790,7 @@ start:
|
|
|
|
|
|
\clearpage
|
|
|
|
|
|
-\section{Select Instructions}
|
|
|
+\section{Select Instructions and the x86$_2$ Language}
|
|
|
\label{sec:select-instructions-gc}
|
|
|
|
|
|
%% void (rep as zero)
|
|
@@ -5893,7 +5895,7 @@ x86_2 &::= & \gray{ (\key{program} \;\itm{info} \;(\key{type}\;\itm{type})\; \I
|
|
|
\end{figure}
|
|
|
|
|
|
The syntax of the $x86_2$ language is defined in
|
|
|
-Figure~\ref{fig:x86-2}. It differs from $x86_1$ just in the addition
|
|
|
+Figure~\ref{fig:x86-2}. It differs from x86$_1$ just in the addition
|
|
|
of the form for global variables.
|
|
|
%
|
|
|
Figure~\ref{fig:select-instr-output-gc} shows the output of the
|
|
@@ -6560,7 +6562,7 @@ where $\itm{mainDef}$ is
|
|
|
\end{lstlisting}
|
|
|
|
|
|
|
|
|
-\section{Reveal Functions}
|
|
|
+\section{Reveal Functions and the $F_1$ language}
|
|
|
\label{sec:reveal-functions-r4}
|
|
|
|
|
|
Going forward, the syntax of $R_4$ is inconvenient for purposes of
|
|
@@ -6711,7 +6713,7 @@ processing function definitions. Each function definition in $C_3$ has
|
|
|
its own set of local variables, so the code for function definitions
|
|
|
should be similar to the case for the \code{program} form in $C_2$.
|
|
|
|
|
|
-\section{Select Instructions}
|
|
|
+\section{Select Instructions and the x86$_3$ Language}
|
|
|
\label{sec:select-r4}
|
|
|
|
|
|
The output of select instructions is a program in the x86$_3$
|