|
@@ -1575,8 +1575,12 @@ test your passes on the example programs.
|
|
|
In the \key{select-instructions} pass we begin the work of translating
|
|
|
from $C_0$ to x86. The target language of this pass is a pseudo-x86
|
|
|
language that still uses variables, so we add an AST node of the form
|
|
|
-$\VAR{\itm{var}}$ to the x86 abstract syntax. The
|
|
|
-\key{select-instructions} pass deals with the differing format of
|
|
|
+$\VAR{\itm{var}}$ to the x86 abstract syntax. Also, the \key{program}
|
|
|
+form should still list the variables (similar to $C_0$):
|
|
|
+\[
|
|
|
+ (\key{program}\;(\Var^{*})\;\Instr^{+})
|
|
|
+\]
|
|
|
+The \key{select-instructions} pass deals with the differing format of
|
|
|
arithmetic operations. For example, in $C_0$ an addition operation can
|
|
|
take the form below. To translate to x86, we need to use the
|
|
|
\key{addq} instruction which does an in-place update. So we must first
|
|
@@ -1687,11 +1691,15 @@ above to
|
|
|
\end{lstlisting}
|
|
|
|
|
|
In the process of assigning stack locations to variables, it is
|
|
|
-convenient to compute and store the size of the frame in the
|
|
|
-$\itm{info}$ field of the \key{program} node which will be needed
|
|
|
-later to generate the procedure conclusion. Some operating systems
|
|
|
-place restrictions on the frame size. For example, Mac OS X requires
|
|
|
-the frame size to be a multiple of 16 bytes.
|
|
|
+convenient to compute and store the size of the frame in the first
|
|
|
+field of the \key{program} node which will be needed later to generate
|
|
|
+the procedure conclusion.
|
|
|
+\[
|
|
|
+ (\key{program}\;\Int\;\Instr^{+})
|
|
|
+\]
|
|
|
+Some operating systems place restrictions on
|
|
|
+the frame size. For example, Mac OS X requires the frame size to be a
|
|
|
+multiple of 16 bytes.
|
|
|
|
|
|
\begin{exercise}
|
|
|
\normalfont Implement the \key{assign-homes} pass and test it on all
|