|
@@ -3197,8 +3197,20 @@ created programs on the \code{interp-x86} interpreter
|
|
|
(Appendix~\ref{appendix:interp}).
|
|
|
\end{exercise}
|
|
|
|
|
|
+
|
|
|
\section{Patch Instructions}
|
|
|
-\label{sec:patch-instructions-r2}
|
|
|
+
|
|
|
+The necessary changes to patch instructions are straightforward.
|
|
|
+
|
|
|
+\begin{exercise}\normalfont
|
|
|
+Update \code{patch-instructions} to handle the new x86 instructions
|
|
|
+and \code{if} statement. Test your compiler using your previously
|
|
|
+created programs on the \code{interp-x86} interpreter
|
|
|
+(Appendix~\ref{appendix:interp}).
|
|
|
+\end{exercise}
|
|
|
+
|
|
|
+\section{Lower Conditionals (New Pass)}
|
|
|
+\label{sec:lower-conditionals}
|
|
|
|
|
|
In the \code{select-instructions} pass we decided to procrastinate in
|
|
|
the lowering of the \key{if} statement (thereby making liveness
|
|
@@ -3236,9 +3248,9 @@ $\Rightarrow$
|
|
|
\end{tabular}
|
|
|
|
|
|
\begin{exercise}\normalfont
|
|
|
-Update your \code{patch-instruction} pass to handle $R_2$ and test
|
|
|
-your compiler using your previously created programs on the
|
|
|
-\code{interp-x86} interpreter (Appendix~\ref{appendix:interp}).
|
|
|
+Implement the \code{lower-conditionals} pass. Test your compiler using
|
|
|
+your previously created programs on the \code{interp-x86} interpreter
|
|
|
+(Appendix~\ref{appendix:interp}).
|
|
|
\end{exercise}
|
|
|
|
|
|
|
|
@@ -3337,8 +3349,9 @@ if_end1327:
|
|
|
|
|
|
\node (x86-2) at (3,-2) {\large $\text{x86}^{*}$};
|
|
|
\node (x86-3) at (6,-2) {\large $\text{x86}^{*}$};
|
|
|
-\node (x86-4) at (9,-2) {\large $\text{x86}$};
|
|
|
-\node (x86-5) at (12,-2) {\large $\text{x86}^{\dagger}$};
|
|
|
+\node (x86-4) at (9,-2) {\large $\text{x86}^{*}$};
|
|
|
+\node (x86-5) at (12,-2) {\large $\text{x86}$};
|
|
|
+\node (x86-6) at (12,-4) {\large $\text{x86}^{\dagger}$};
|
|
|
|
|
|
\node (x86-2-1) at (3,-4) {\large $\text{x86}^{*}$};
|
|
|
\node (x86-2-2) at (6,-4) {\large $\text{x86}^{*}$};
|
|
@@ -3351,7 +3364,8 @@ if_end1327:
|
|
|
\path[->,bend right=15] (x86-2-1) edge [below] node {\ttfamily\footnotesize build-inter.} (x86-2-2);
|
|
|
\path[->,bend right=15] (x86-2-2) edge [right] node {\ttfamily\footnotesize allocate-reg.} (x86-3);
|
|
|
\path[->,bend left=15] (x86-3) edge [above] node {\ttfamily\footnotesize patch-instr.} (x86-4);
|
|
|
-\path[->,bend left=15] (x86-4) edge [above] node {\ttfamily\footnotesize print-x86} (x86-5);
|
|
|
+\path[->,bend left=15] (x86-4) edge [above] node {\ttfamily\footnotesize lower-cond.} (x86-5);
|
|
|
+\path[->,bend right=15] (x86-5) edge [left] node {\ttfamily\footnotesize print-x86} (x86-6);
|
|
|
\end{tikzpicture}
|
|
|
\caption{Diagram of the passes for compiling $R_2$, including the
|
|
|
new type checking pass.}
|