瀏覽代碼

change regarding liveness

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

+ 54 - 56
book.tex

@@ -2167,7 +2167,8 @@ stack locations or registers.
 
 \begin{figure}
 \begin{minipage}{0.45\textwidth}
-Source program:
+  $R_1$ program:
+% s0_22.rkt
 \begin{lstlisting}
 (program ()
   (let ([v 1])
@@ -2181,20 +2182,23 @@ Source program:
 \begin{minipage}{0.45\textwidth}
 After instruction selection:
 \begin{lstlisting}
-(program (v w x y z t.1 t.2)
-  (movq (int 1) (var v))
-  (movq (int 46) (var w))
-  (movq (var v) (var x))
-  (addq (int 7) (var x))
-  (movq (var x) (var y))
-  (addq (int 4) (var y))
-  (movq (var x) (var z))
-  (addq (var w) (var z))
-  (movq (var y) (var t.1))
-  (negq (var t.1))
-  (movq (var z) (var t.2))
-  (addq (var t.1) (var t.2))
-  (movq (var t.2) (reg rax)))
+(program
+ ((locals . (v w x y z t.1 t.2)))
+ ((start .
+   (block ()
+     (movq (int 1) (var v))
+     (movq (int 46) (var w))
+     (movq (var v) (var x))
+     (addq (int 7) (var x))
+     (movq (var x) (var y))
+     (addq (int 4) (var y))
+     (movq (var x) (var z))
+     (addq (var w) (var z))
+     (movq (var y) (var t.1))
+     (negq (var t.1))
+     (movq (var z) (reg rax))
+     (addq (var t.1) (reg rax))
+     (jmp conclusion)))))
 \end{lstlisting}
 \end{minipage}
 \caption{An example program for register allocation.}
@@ -2314,62 +2318,56 @@ $L_{\mathtt{after}}$ set to make the figure easy to read.
 \hspace{20pt}
 \begin{minipage}{0.45\textwidth}
 \begin{lstlisting}[numbers=left]
-  (program (v w x y z t.1 t.2)
-    (movq (int 1) (var v))
-    (movq (int 46) (var w))
-    (movq (var v) (var x))
-    (addq (int 7) (var x))
-    (movq (var x) (var y))
-    (addq (int 4) (var y))
-    (movq (var x) (var z))
-    (addq (var w) (var z))
-    (movq (var y) (var t.1))
-    (negq (var t.1))
-    (movq (var z) (var t.2))
-    (addq (var t.1) (var t.2))
-    (movq (var t.2) (reg rax)))
+(block ()
+  (movq (int 1) (var v))
+  (movq (int 46) (var w))
+  (movq (var v) (var x))
+  (addq (int 7) (var x))
+  (movq (var x) (var y))
+  (addq (int 4) (var y))
+  (movq (var x) (var z))
+  (addq (var w) (var z))
+  (movq (var y) (var t.1))
+  (negq (var t.1))
+  (movq (var z) (reg rax))
+  (addq (var t.1) (reg rax))
+  (jmp conclusion))
 \end{lstlisting}
 \end{minipage}
 \vrule\hspace{10pt}
 \begin{minipage}{0.45\textwidth}
 \begin{lstlisting}
-
-|$\{ v \}$|
-|$\{ v, w \}$|
-|$\{ w, x \}$|
-|$\{ w, x \}$|
-|$\{ w, x, y\}$|
-|$\{ w, x, y \}$|
-|$\{ w, y, z \}$|
-|$\{ y, z \}$|
-|$\{ t.1, z \}$|
-|$\{ t.1, z \}$|
-|$\{t.1,t.2\}$|
-|$\{t.2\}$|
+|$\{\}$|
+|$\{v \}$|
+|$\{v,w\}$|
+|$\{w,x\}$|
+|$\{w,x\}$|
+|$\{w,x,y\}$|
+|$\{w,x,y\}$|
+|$\{w,y,z\}$|
+|$\{y,z\}$|
+|$\{z,t.1\}$|
+|$\{z,t.1\}$|
+|$\{t.1\}$|
+|$\{\}$|
 |$\{\}$|
 \end{lstlisting}
 \end{minipage}
 
-\caption{An example program annotated with live-after sets.}
+\caption{An example block annotated with live-after sets.}
 \label{fig:live-eg}
 \end{figure}
 
 \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{program}
-node alongside the list of variables as follows.
-\begin{lstlisting}
-   (program (|$\Var^{*}$| |$\itm{live}$-$\itm{afters}$|) |$\Instr^{+}$|)
-\end{lstlisting}
-We recommend organizing your code to use a helper function that takes a
-list of statements and an initial live-after set (typically empty) and
-returns the list of statements and the list of live-after sets.  For
-this chapter, returning the list of statements is unnecessary, as they
-will be unchanged, but in Chapter~\ref{ch:bool-types} we introduce
-\key{if} statements and will need to annotate them with the live-after
-sets of the two branches.
-
+of lists of variables) in the $\itm{info}$ field of the \key{block}
+construct.
+%
+We recommend organizing your code to use a helper function that takes
+a list of instructions and an initial live-after set (typically empty)
+and returns the list of live-after sets.
+%
 We recommend creating helper functions to 1) compute the set of
 variables that appear in an argument (of an instruction), 2) compute
 the variables read by an instruction which corresponds to the $R$