Jeremy Siek 4 lat temu
rodzic
commit
3c8f85d6cf
1 zmienionych plików z 18 dodań i 12 usunięć
  1. 18 12
      book.tex

+ 18 - 12
book.tex

@@ -2646,7 +2646,7 @@ start:
     jmp conclusion
 \end{lstlisting}
 \end{minipage}
-\caption{A running example program for register allocation.}
+\caption{A running example for register allocation.}
 \label{fig:reg-eg}
 \end{figure}
 
@@ -2940,12 +2940,12 @@ The conclusion reads from \ttm{rax} and \ttm{rsp}, so the alist should
 map \code{conclusion} to the set $\{\ttm{rax},\ttm{rsp}\}$.
 
 Let us walk through the above example, applying these formulas
-starting with the instruction on line 5. We collect the answers in the
-below listing.  The $L_{\mathsf{after}}$ for the \code{addq b, c}
-instruction is $\emptyset$ because it is the last instruction
-(formula~\ref{eq:live-last-empty}).  The $L_{\mathsf{before}}$ for
-this instruction is $\{\ttm{b},\ttm{c}\}$ because it reads from
-variables \code{b} and \code{c}
+starting with the instruction on line 5. We collect the answers in
+Figure~\ref{fig:liveness-example-0}.  The $L_{\mathsf{after}}$ for the
+\code{addq b, c} instruction is $\emptyset$ because it is the last
+instruction (formula~\ref{eq:live-last-empty}).  The
+$L_{\mathsf{before}}$ for this instruction is $\{\ttm{b},\ttm{c}\}$
+because it reads from variables \code{b} and \code{c}
 (formula~\ref{eq:live-before-after-minus-writes-plus-reads}), that is
 \[
    L_{\mathsf{before}}(5) = (\emptyset - \{\ttm{c}\}) \cup \{ \ttm{b}, \ttm{c} \} = \{ \ttm{b}, \ttm{c} \}
@@ -2969,7 +2969,8 @@ live-before for \code{movq \$30, b} is $\{\ttm{a}\}$ because it writes to a
 variable that is not live and does not read from a variable.
 Finally, the live-before for \code{movq \$5, a} is $\emptyset$
 because it writes to variable \code{a}.
-\begin{center}
+
+\begin{figure}[tbp]
 \begin{minipage}{0.45\textwidth}
 \begin{lstlisting}[numbers=left,numberstyle=\tiny]
 movq $5, a
@@ -2994,11 +2995,16 @@ L_{\mathsf{before}}(5)=  \{\ttm{b},\ttm{c}\},
 L_{\mathsf{after}}(5)=  \emptyset
 \end{align*}
 \end{minipage}
-\end{center}
+\caption{Example output of liveness analysis on a short example.}
+\label{fig:liveness-example-0}
+\end{figure}
 
-Figure~\ref{fig:live-eg} shows the results of liveness analysis for
-the running example program, with the live-before and live-after sets
-shown between each instruction to make the figure easy to read.
+\begin{exercise}\normalfont
+  Perform liveness analysis on the running example in
+  Figure~\ref{fig:reg-eg}, computing the live-before and live-after
+  sets for each instruction. Compare your answers to the solution
+  shown in Figure~\ref{fig:live-eg}.
+\end{exercise}
 
 \begin{figure}[tp]
 \hspace{20pt}