|
@@ -29,9 +29,16 @@
|
|
% Computer Modern is already the default. -Jeremy
|
|
% Computer Modern is already the default. -Jeremy
|
|
%\renewcommand{\ttdefault}{cmtt}
|
|
%\renewcommand{\ttdefault}{cmtt}
|
|
|
|
|
|
|
|
+\if{0}
|
|
% Peanut gallery comments:
|
|
% Peanut gallery comments:
|
|
\definecolor{comment-red}{rgb}{0.8,0,0}
|
|
\definecolor{comment-red}{rgb}{0.8,0,0}
|
|
\newcommand{\rn}[1]{{\color{comment-red}{(RRN: #1)}}}
|
|
\newcommand{\rn}[1]{{\color{comment-red}{(RRN: #1)}}}
|
|
|
|
+\newcommand{\margincomment}[1]{\marginpar{#1}}
|
|
|
|
+\else
|
|
|
|
+\newcommand{\rn}[1]{}
|
|
|
|
+\newcommand{\margincomment}[1]{}
|
|
|
|
+% \newcommand{\margincomment}[1]{}
|
|
|
|
+\fi
|
|
|
|
|
|
\lstset{%
|
|
\lstset{%
|
|
language=Lisp,
|
|
language=Lisp,
|
|
@@ -88,7 +95,7 @@ moredelim=[is][\color{red}]{~}{~}
|
|
\title{\Huge \textbf{Essentials of Compilation} \\
|
|
\title{\Huge \textbf{Essentials of Compilation} \\
|
|
\huge An Incremental Approach}
|
|
\huge An Incremental Approach}
|
|
|
|
|
|
-\author{\textsc{Jeremy G. Siek} \\
|
|
|
|
|
|
+\author{\textsc{Jeremy G. Siek, Ryan R. Newton} \\
|
|
%\thanks{\url{http://homes.soic.indiana.edu/jsiek/}} \\
|
|
%\thanks{\url{http://homes.soic.indiana.edu/jsiek/}} \\
|
|
Indiana University \\
|
|
Indiana University \\
|
|
\\
|
|
\\
|
|
@@ -222,6 +229,7 @@ parts of x86-64 assembly language that are needed.
|
|
% \item Miscellaneous material (e.g. suggested readings etc).
|
|
% \item Miscellaneous material (e.g. suggested readings etc).
|
|
%\end{itemize}
|
|
%\end{itemize}
|
|
|
|
|
|
|
|
+\if{0}
|
|
\section*{Acknowledgments}
|
|
\section*{Acknowledgments}
|
|
|
|
|
|
Need to give thanks to
|
|
Need to give thanks to
|
|
@@ -242,6 +250,8 @@ Need to give thanks to
|
|
\noindent \url{http://homes.soic.indiana.edu/jsiek} \\
|
|
\noindent \url{http://homes.soic.indiana.edu/jsiek} \\
|
|
\noindent Spring 2016
|
|
\noindent Spring 2016
|
|
|
|
|
|
|
|
+\fi{} %% End Preface
|
|
|
|
+
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\chapter{Preliminaries}
|
|
\chapter{Preliminaries}
|
|
\label{ch:trees-recur}
|
|
\label{ch:trees-recur}
|
|
@@ -1036,7 +1046,7 @@ main:
|
|
\label{fig:p0-x86}
|
|
\label{fig:p0-x86}
|
|
%\end{wrapfigure}
|
|
%\end{wrapfigure}
|
|
\end{figure}
|
|
\end{figure}
|
|
-%% \marginpar{Consider using italics for the texts in these figures.
|
|
|
|
|
|
+%% \margincomment{Consider using italics for the texts in these figures.
|
|
%% It can get confusing to differentiate them from the main text.}
|
|
%% It can get confusing to differentiate them from the main text.}
|
|
%% It looks pretty ugly in italics.-Jeremy
|
|
%% It looks pretty ugly in italics.-Jeremy
|
|
|
|
|
|
@@ -1332,7 +1342,7 @@ The topic of Chapter~\ref{ch:register-allocation} is implementing a
|
|
smarter approach in which we make a best-effort to map variables to
|
|
smarter approach in which we make a best-effort to map variables to
|
|
registers, resorting to the stack only when necessary.
|
|
registers, resorting to the stack only when necessary.
|
|
|
|
|
|
-%% \marginpar{\scriptsize I'm confused: shouldn't `select instructions' do this?
|
|
|
|
|
|
+%% \margincomment{\scriptsize I'm confused: shouldn't `select instructions' do this?
|
|
%% After all, that selects the x86 instructions. Even if it is separate,
|
|
%% After all, that selects the x86 instructions. Even if it is separate,
|
|
%% if we perform `patching' before register allocation, we aren't forced to rely on
|
|
%% if we perform `patching' before register allocation, we aren't forced to rely on
|
|
%% \key{rax} as much. This can ultimately make a more-performant result. --
|
|
%% \key{rax} as much. This can ultimately make a more-performant result. --
|
|
@@ -1858,7 +1868,7 @@ passes described in this Chapter. The x86$^{*}$ language extends x86
|
|
with variables and looser rules regarding instruction arguments. The
|
|
with variables and looser rules regarding instruction arguments. The
|
|
x86$^{\dagger}$ language is the concrete syntax (string) for x86.
|
|
x86$^{\dagger}$ language is the concrete syntax (string) for x86.
|
|
|
|
|
|
-\marginpar{\footnotesize To do: add a challenge section. Perhaps
|
|
|
|
|
|
+\margincomment{\footnotesize To do: add a challenge section. Perhaps
|
|
extending the partial evaluation to $R_0$? \\ --Jeremy}
|
|
extending the partial evaluation to $R_0$? \\ --Jeremy}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
@@ -1989,7 +1999,7 @@ Figure~\ref{fig:live-eg} shows the results of live variables analysis
|
|
for the running example, with each instruction aligned with its
|
|
for the running example, with each instruction aligned with its
|
|
$L_{\mathtt{after}}$ set to make the figure easy to read.
|
|
$L_{\mathtt{after}}$ set to make the figure easy to read.
|
|
|
|
|
|
-\marginpar{JM: I think you should walk through the explanation of this formula,
|
|
|
|
|
|
+\margincomment{JM: I think you should walk through the explanation of this formula,
|
|
connecting it back to the example from before. \\
|
|
connecting it back to the example from before. \\
|
|
JS: Agreed.}
|
|
JS: Agreed.}
|
|
|
|
|
|
@@ -2098,7 +2108,7 @@ following.
|
|
$\mathit{label}$), then add an edge $(r,v)$ for every caller-save
|
|
$\mathit{label}$), then add an edge $(r,v)$ for every caller-save
|
|
register $r$ and every variable $v \in L_{\mathsf{after}}(k)$.
|
|
register $r$ and every variable $v \in L_{\mathsf{after}}(k)$.
|
|
\end{itemize}
|
|
\end{itemize}
|
|
-\marginpar{JM: I think you could give examples of each one of these
|
|
|
|
|
|
+\margincomment{JM: I think you could give examples of each one of these
|
|
using the example program and use those to help explain why these
|
|
using the example program and use those to help explain why these
|
|
rules are correct.\\
|
|
rules are correct.\\
|
|
JS: Agreed.}
|
|
JS: Agreed.}
|
|
@@ -2886,7 +2896,7 @@ opportunity for move biasing and visually inspect the output x86
|
|
programs to make sure that your move biasing is working properly.
|
|
programs to make sure that your move biasing is working properly.
|
|
\end{exercise}
|
|
\end{exercise}
|
|
|
|
|
|
-\marginpar{\footnotesize To do: another neat challenge would be to do
|
|
|
|
|
|
+\margincomment{\footnotesize To do: another neat challenge would be to do
|
|
live range splitting~\citep{Cooper:1998ly}. \\ --Jeremy}
|
|
live range splitting~\citep{Cooper:1998ly}. \\ --Jeremy}
|
|
|
|
|
|
|
|
|
|
@@ -3749,7 +3759,7 @@ all. If the condition is a \code{let}, we can optimize based on the
|
|
form of its body. If the condition is a \code{not}, then we can flip
|
|
form of its body. If the condition is a \code{not}, then we can flip
|
|
the two branches.
|
|
the two branches.
|
|
%
|
|
%
|
|
-\marginpar{\tiny We could do even better by converting to basic
|
|
|
|
|
|
+\margincomment{\tiny We could do even better by converting to basic
|
|
blocks.\\ --Jeremy}
|
|
blocks.\\ --Jeremy}
|
|
%
|
|
%
|
|
On the other hand, if the condition is a \code{and}
|
|
On the other hand, if the condition is a \code{and}
|
|
@@ -3845,11 +3855,11 @@ if_end21289:
|
|
\chapter{Tuples and Garbage Collection}
|
|
\chapter{Tuples and Garbage Collection}
|
|
\label{ch:tuples}
|
|
\label{ch:tuples}
|
|
|
|
|
|
-\marginpar{\scriptsize To do: look through Andre's code comments for extra
|
|
|
|
|
|
+\margincomment{\scriptsize To do: look through Andre's code comments for extra
|
|
things to discuss in this chapter. \\ --Jeremy}
|
|
things to discuss in this chapter. \\ --Jeremy}
|
|
-\marginpar{\scriptsize To do: Flesh out this chapter, e.g., make sure
|
|
|
|
|
|
+\margincomment{\scriptsize To do: Flesh out this chapter, e.g., make sure
|
|
all the IR grammars are spelled out! \\ --Jeremy}
|
|
all the IR grammars are spelled out! \\ --Jeremy}
|
|
-\marginpar{\scriptsize Introduce has-type, but after flatten, remove it,
|
|
|
|
|
|
+\margincomment{\scriptsize Introduce has-type, but after flatten, remove it,
|
|
but keep type annotations on vector creation and local variables, function
|
|
but keep type annotations on vector creation and local variables, function
|
|
parameters, etc. \\ --Jeremy}
|
|
parameters, etc. \\ --Jeremy}
|
|
|
|
|
|
@@ -4119,7 +4129,7 @@ ToSpace.
|
|
\label{fig:copying-collector}
|
|
\label{fig:copying-collector}
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
-%% \marginpar{\tiny Need to add comment somewhere about the goodness
|
|
|
|
|
|
+%% \margincomment{\tiny Need to add comment somewhere about the goodness
|
|
%% of copying collection, especially that it doesn't touch
|
|
%% of copying collection, especially that it doesn't touch
|
|
%% the garbage, so its time complexity only depends on the
|
|
%% the garbage, so its time complexity only depends on the
|
|
%% amount of live data.\\ --Jeremy}
|
|
%% amount of live data.\\ --Jeremy}
|
|
@@ -4284,7 +4294,7 @@ points to the first element of the root stack.
|
|
As long as there is room left in the FromSpace, your generated code
|
|
As long as there is room left in the FromSpace, your generated code
|
|
can allocate tuples simply by moving the \code{free\_ptr} forward.
|
|
can allocate tuples simply by moving the \code{free\_ptr} forward.
|
|
%
|
|
%
|
|
-\marginpar{\tiny Should we dedicate a register to the free pointer? \\
|
|
|
|
|
|
+\margincomment{\tiny Should we dedicate a register to the free pointer? \\
|
|
--Jeremy}
|
|
--Jeremy}
|
|
%
|
|
%
|
|
The amount of room left in FromSpace is the difference between the
|
|
The amount of room left in FromSpace is the difference between the
|
|
@@ -4777,7 +4787,7 @@ x86_2 &::= & (\key{program} \;(\itm{stackSpills} \; \itm{rootstackSpills}) \;(\k
|
|
\label{sec:print-x86-gc}
|
|
\label{sec:print-x86-gc}
|
|
|
|
|
|
|
|
|
|
-\marginpar{\scriptsize We need to show the translation to x86 and what
|
|
|
|
|
|
+\margincomment{\scriptsize We need to show the translation to x86 and what
|
|
to do about global-value. \\ --Jeremy}
|
|
to do about global-value. \\ --Jeremy}
|
|
|
|
|
|
Figure~\ref{fig:print-x86-output-gc} shows the output of the
|
|
Figure~\ref{fig:print-x86-output-gc} shows the output of the
|
|
@@ -4869,7 +4879,7 @@ if_end30967:
|
|
\end{figure}
|
|
\end{figure}
|
|
|
|
|
|
|
|
|
|
-\marginpar{\scriptsize Suggest an implementation strategy
|
|
|
|
|
|
+\margincomment{\scriptsize Suggest an implementation strategy
|
|
in which the students first do the code gen and test that
|
|
in which the students first do the code gen and test that
|
|
without GC (just use a big heap), then after that is debugged,
|
|
without GC (just use a big heap), then after that is debugged,
|
|
implement the GC. \\ --Jeremy}
|
|
implement the GC. \\ --Jeremy}
|
|
@@ -5035,10 +5045,10 @@ Figure~\ref{fig:interp-R4}.
|
|
\section{Functions in x86}
|
|
\section{Functions in x86}
|
|
\label{sec:fun-x86}
|
|
\label{sec:fun-x86}
|
|
|
|
|
|
-\marginpar{\tiny Make sure callee save registers are discussed
|
|
|
|
|
|
+\margincomment{\tiny Make sure callee save registers are discussed
|
|
in enough depth, especially updating Fig 6.4 \\ --Jeremy }
|
|
in enough depth, especially updating Fig 6.4 \\ --Jeremy }
|
|
|
|
|
|
-\marginpar{\tiny Talk about the return address on the
|
|
|
|
|
|
+\margincomment{\tiny Talk about the return address on the
|
|
stack and what callq and retq does.\\ --Jeremy }
|
|
stack and what callq and retq does.\\ --Jeremy }
|
|
|
|
|
|
The x86 architecture provides a few features to support the
|
|
The x86 architecture provides a few features to support the
|
|
@@ -5141,7 +5151,7 @@ $8n-8$\key{(\%rsp)} & $8n+8$(\key{\%rbp})& argument $n$ \\
|
|
|
|
|
|
\section{The compilation of functions}
|
|
\section{The compilation of functions}
|
|
|
|
|
|
-\marginpar{\scriptsize To do: discuss the need to push and
|
|
|
|
|
|
+\margincomment{\scriptsize To do: discuss the need to push and
|
|
pop call-live pointers (vectors and functions)
|
|
pop call-live pointers (vectors and functions)
|
|
to the root stack \\ --Jeremy}
|
|
to the root stack \\ --Jeremy}
|
|
|
|
|