|
@@ -10377,51 +10377,31 @@ C_4 & ::= & \gray{ \PROGRAMDEFS{\itm{info}}{\LP\Def\ldots\RP} }
|
|
|
\section{Instruction Selection}
|
|
|
\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}
|
|
|
+(Assign |\itm{lhs}| (Prim 'make-any (list |$e$| (Int |$\itm{tag}$|))))
|
|
|
+|$\Rightarrow$|
|
|
|
(movq |$e'$| |\itm{lhs}'|)
|
|
|
(salq (int 3) |\itm{lhs}'|)
|
|
|
-(orq (int |$\itm{tagof}(T)$|) |\itm{lhs}'|)
|
|
|
+(orq (int |$\itm{tag}$|) |\itm{lhs}'|)
|
|
|
\end{lstlisting}
|
|
|
-\end{minipage}
|
|
|
-\end{tabular} \\
|
|
|
The instruction selection for vectors and procedures is different
|
|
|
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
|
|
|
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}
|
|
|
+(Assign |\itm{lhs}| (Prim 'make-any (list |$e$| (Int |$\itm{tag}$|))))
|
|
|
+|$\Rightarrow$|
|
|
|
(movq |$e'$| |\itm{lhs}'|)
|
|
|
(orq (int |$\itm{tagof}(T)$|) |\itm{lhs}'|)
|
|
|
\end{lstlisting}
|
|
|
-\end{minipage}
|
|
|
-\end{tabular}
|
|
|
|
|
|
\paragraph{Tag of Any}
|
|
|
|