Jeremy Siek 4 жил өмнө
parent
commit
4607ef64b8
1 өөрчлөгдсөн 13 нэмэгдсэн , 33 устгасан
  1. 13 33
      book.tex

+ 13 - 33
book.tex

@@ -10377,51 +10377,31 @@ C_4 & ::= & \gray{ \PROGRAMDEFS{\itm{info}}{\LP\Def\ldots\RP} }
 \section{Instruction Selection}
 \section{Instruction Selection}
 \label{sec:select-r6}
 \label{sec:select-r6}
 
 
-\paragraph{Inject}
-
-We recommend compiling an \key{inject} as follows if the type is
-\key{Integer} or \key{Boolean}.  The \key{salq} instruction shifts the
-destination to the left by the number of bits specified its source
-argument (in this case $3$, the length of the tag) and it preserves
-the sign of the integer. We use the \key{orq} instruction to combine
-the tag and the value to form the tagged value.  \\
-\begin{tabular}{lll}
-\begin{minipage}{0.4\textwidth}
-\begin{lstlisting}
-(assign |\itm{lhs}| (inject |$e$| |$T$|))
-\end{lstlisting}
-\end{minipage}
-&
-$\Rightarrow$
-&
-\begin{minipage}{0.5\textwidth}
+\paragraph{Make-Any}
+
+We recommend compiling the \key{make-any} primitive as follows if the
+tag is for \key{Integer} or \key{Boolean}.  The \key{salq} instruction
+shifts the destination to the left by the number of bits specified its
+source argument (in this case $3$, the length of the tag) and it
+preserves the sign of the integer. We use the \key{orq} instruction to
+combine the tag and the value to form the tagged value.  \\
 \begin{lstlisting}
 \begin{lstlisting}
+(Assign |\itm{lhs}| (Prim 'make-any (list |$e$| (Int |$\itm{tag}$|))))
+|$\Rightarrow$|
 (movq |$e'$| |\itm{lhs}'|)
 (movq |$e'$| |\itm{lhs}'|)
 (salq (int 3) |\itm{lhs}'|)
 (salq (int 3) |\itm{lhs}'|)
-(orq (int |$\itm{tagof}(T)$|) |\itm{lhs}'|)
+(orq (int |$\itm{tag}$|) |\itm{lhs}'|)
 \end{lstlisting}
 \end{lstlisting}
-\end{minipage}
-\end{tabular}  \\
 The instruction selection for vectors and procedures is different
 The instruction selection for vectors and procedures is different
 because their is no need to shift them to the left. The rightmost 3
 because their is no need to shift them to the left. The rightmost 3
 bits are already zeros as described above. So we just combine the
 bits are already zeros as described above. So we just combine the
 value and the tag using \key{orq}.  \\
 value and the tag using \key{orq}.  \\
-\begin{tabular}{lll}
-\begin{minipage}{0.4\textwidth}
-\begin{lstlisting}
-(assign |\itm{lhs}| (inject |$e$| |$T$|))
-\end{lstlisting}
-\end{minipage}
-&
-$\Rightarrow$
-&
-\begin{minipage}{0.5\textwidth}
 \begin{lstlisting}
 \begin{lstlisting}
+(Assign |\itm{lhs}| (Prim 'make-any (list |$e$| (Int |$\itm{tag}$|))))
+|$\Rightarrow$|
 (movq |$e'$| |\itm{lhs}'|)
 (movq |$e'$| |\itm{lhs}'|)
 (orq (int |$\itm{tagof}(T)$|) |\itm{lhs}'|)
 (orq (int |$\itm{tagof}(T)$|) |\itm{lhs}'|)
 \end{lstlisting}
 \end{lstlisting}
-\end{minipage}
-\end{tabular} 
 
 
 \paragraph{Tag of Any}
 \paragraph{Tag of Any}