Jeremy Siek 6 年之前
父節點
當前提交
984b0365fd
共有 1 個文件被更改,包括 71 次插入24 次删除
  1. 71 24
      book.tex

+ 71 - 24
book.tex

@@ -1,3 +1,6 @@
+% Why direct style instead of continuation passing style?
+
+
 \documentclass[11pt]{book}
 \usepackage[T1]{fontenc}
 \usepackage[utf8]{inputenc}
@@ -1300,12 +1303,14 @@ procedure call.
 
 The compiler will need a convenient representation for manipulating
 x86 programs, so we define an abstract syntax for x86 in
-Figure~\ref{fig:x86-ast-a}. The $\Int$ field of the \key{program} AST
-node records the number of bytes of stack space needed for variables
-in the program. (Some of the intermediate languages will store other
+Figure~\ref{fig:x86-ast-a}. We refer to this language as $x86_0$ with
+a subscript $0$ because later we introduce extended versions of this
+assembly language. The $\Int$ field of the \key{program} AST node
+records the number of bytes of stack space needed for variables in the
+program. (Some of the intermediate languages will store other
 information in that part of the S-expression for the purposes of
 communicating auxiliary data from one step of the compiler to the
-next. )
+next.
 
 \begin{figure}[tp]
 \fbox{
@@ -1328,7 +1333,7 @@ x86_0 &::= & (\key{program} \;\Int \; \Instr^{+})
 \]
 \end{minipage}
 }
-\caption{Abstract syntax for x86 assembly.}
+\caption{Abstract syntax for $x86_0$ assembly.}
 \label{fig:x86-ast-a}
 \end{figure}
 
@@ -1473,9 +1478,9 @@ pass.
 \[
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
 \node (1) at (0,0)  {\large $C_0$};
-\node (2) at (3,0)  {\large $\text{x86}^{*}$};
-\node (3) at (6,0)  {\large $\text{x86}^{*}$};
-\node (4) at (9,0) {\large $\text{x86}$};
+\node (2) at (3,0)  {\large $\text{x86}^{*}_0$};
+\node (3) at (6,0)  {\large $\text{x86}^{*}_0$};
+\node (4) at (9,0) {\large $\text{x86}_0$};
 
 \path[->,bend left=15] (1) edge [above] node {\ttfamily\footnotesize select-instr.} (2);
 \path[->,bend left=15] (2) edge [above] node {\ttfamily\footnotesize assign-homes} (3);
@@ -2027,10 +2032,10 @@ programs.
 \node (R1-2) at (3,2)  {\large $R_1$};
 \node (C0-1) at (3,0)  {\large $C_0$};
 
-\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-2) at (3,-2)  {\large $\text{x86}^{*}_0$};
+\node (x86-3) at (6,-2)  {\large $\text{x86}^{*}_0$};
+\node (x86-4) at (9,-2) {\large $\text{x86}_0$};
+\node (x86-5) at (12,-2) {\large $\text{x86}^{\dagger}_0$};
 
 \path[->,bend left=15] (R1) edge [above] node {\ttfamily\footnotesize uniquify} (R1-2);
 \path[->,bend left=15] (R1-2) edge [right] node {\ttfamily\footnotesize flatten} (C0-1);
@@ -5764,12 +5769,12 @@ programs.
 
 \begin{figure}[p]
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
-\node (R3) at (0,2)  {\large $R_4$};
-\node (R3-2) at (3,2)  {\large $R_4$};
-\node (R3-3) at (6,2)  {\large $R_4$};
-\node (R3-4) at (9,2)  {\large $R_3$};
-\node (C2-1) at (6,0)  {\large $C_2$};
-\node (C2-3) at (3,0)  {\large $C_2$};
+\node (R4) at (0,2)  {\large $R_4$};
+\node (R4-2) at (3,2)  {\large $R_4$};
+\node (R4-3) at (6,2)  {\large $R_4$};
+\node (F1) at (9,2)  {\large $F_1$};
+\node (C3-1) at (6,0)  {\large $C_3$};
+\node (C3-3) at (3,0)  {\large $C_3$};
 
 \node (x86-2) at (3,-2)  {\large $\text{x86}^{*}$};
 \node (x86-3) at (6,-2)  {\large $\text{x86}^{*}$};
@@ -5780,12 +5785,12 @@ programs.
 \node (x86-2-1) at (3,-4)  {\large $\text{x86}^{*}$};
 \node (x86-2-2) at (6,-4)  {\large $\text{x86}^{*}$};
 
-\path[->,bend left=15] (R3) edge [above] node {\ttfamily\footnotesize\color{red} typecheck} (R3-2);
-\path[->,bend left=15] (R3-2) edge [above] node {\ttfamily\footnotesize uniquify} (R3-3);
-\path[->,bend left=15] (R3-3) edge [above] node {\ttfamily\footnotesize\color{red} reveal-functions} (R3-4);
-\path[->,bend left=15] (R3-4) edge [right] node {\ttfamily\footnotesize expose-alloc.} (C2-1);
-\path[->,bend right=15] (C2-1) edge [above] node {\ttfamily\footnotesize flatten} (C2-3);
-\path[->,bend right=15] (C2-3) edge [left] node {\ttfamily\footnotesize\color{red} select-instr.} (x86-2);
+\path[->,bend left=15] (R4) edge [above] node {\ttfamily\footnotesize\color{red} typecheck} (R4-2);
+\path[->,bend left=15] (R4-2) edge [above] node {\ttfamily\footnotesize uniquify} (R4-3);
+\path[->,bend left=15] (R4-3) edge [above] node {\ttfamily\footnotesize\color{red} reveal-functions} (F1);
+\path[->,bend left=15] (F1) edge [right] node {\ttfamily\footnotesize expose-alloc.} (C3-1);
+\path[->,bend right=15] (C3-1) edge [above] node {\ttfamily\footnotesize flatten} (C3-3);
+\path[->,bend right=15] (C3-3) edge [left] node {\ttfamily\footnotesize\color{red} select-instr.} (x86-2);
 \path[->,bend left=15] (x86-2) edge [right] node {\ttfamily\footnotesize\color{red} uncover-live} (x86-2-1);
 \path[->,bend right=15] (x86-2-1) edge [below] node {\ttfamily\footnotesize \color{red}build-inter.} (x86-2-2);
 \path[->,bend right=15] (x86-2-2) edge [right] node {\ttfamily\footnotesize\color{red} allocate-reg.} (x86-3);
@@ -6156,6 +6161,48 @@ $\Downarrow$
 \end{figure}
 
 
+
+\begin{figure}[p]
+\begin{tikzpicture}[baseline=(current  bounding  box.center)]
+\node (R3) at (0,2)  {\large $R_4$};
+\node (R3-2) at (3,2)  {\large $R_4$};
+\node (R3-3) at (6,2)  {\large $R_4$};
+\node (R3-4) at (9,2)  {\large $R_3$};
+\node (C2-1) at (6,0)  {\large $C_2$};
+\node (C2-3) at (3,0)  {\large $C_2$};
+
+\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}$};
+\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}^{*}$};
+
+\path[->,bend left=15] (R3) edge [above] node {\ttfamily\footnotesize\color{red} typecheck} (R3-2);
+\path[->,bend left=15] (R3-2) edge [above] node {\ttfamily\footnotesize uniquify} (R3-3);
+\path[->,bend left=15] (R3-3) edge [above] node {\ttfamily\footnotesize\color{red} reveal-functions} (R3-4);
+\path[->,bend left=15] (R3-4) edge [right] node {\ttfamily\footnotesize expose-alloc.} (C2-1);
+\path[->,bend right=15] (C2-1) edge [above] node {\ttfamily\footnotesize flatten} (C2-3);
+\path[->,bend right=15] (C2-3) edge [left] node {\ttfamily\footnotesize\color{red} select-instr.} (x86-2);
+\path[->,bend left=15] (x86-2) edge [right] node {\ttfamily\footnotesize\color{red} uncover-live} (x86-2-1);
+\path[->,bend right=15] (x86-2-1) edge [below] node {\ttfamily\footnotesize \color{red}build-inter.} (x86-2-2);
+\path[->,bend right=15] (x86-2-2) edge [right] node {\ttfamily\footnotesize\color{red} allocate-reg.} (x86-3);
+\path[->,bend left=15] (x86-3) edge [above] node {\ttfamily\footnotesize lower-cond.} (x86-4);
+\path[->,bend left=15] (x86-4) edge [above] node {\ttfamily\footnotesize patch-instr.} (x86-5);
+\path[->,bend right=15] (x86-5) edge [left] node {\ttfamily\footnotesize\color{red} print-x86} (x86-6);
+\end{tikzpicture}
+\caption{Diagram of the passes for $R_5$, a language with lexically-scoped
+  functions.}
+\label{fig:R5-passes}
+\end{figure}
+
+Figure~\ref{fig:R5-passes} provides an overview of all the passes needed
+for the compilation of $R_5$.
+
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \chapter{Dynamic Typing}
 \label{ch:type-dynamic}