| 1 |
\section{The Sparc Back End} |
| 2 |
|
| 3 |
The Sparc back end can function in two different modes: |
| 4 |
\begin{description} |
| 5 |
\item[Sparc V8] This is V8 instruction set is used. In this mode the processor |
| 6 |
behaves like a 32-bit processor. In this mode we assume we |
| 7 |
have 16 floating point registers numbered \verb|%f0, %f2, %f4, ..., %f30|. |
| 8 |
These are all in IEEE double precision. |
| 9 |
\item[Sparc V9] This generates code assuming the V9 instruction set is used. |
| 10 |
In this mode the processor functions at 64-bit. In this mode the |
| 11 |
floating point processors can number from \verb|%f0, %f2, %f4, ..., %f62|. |
| 12 |
These are all in IEEE double precision. |
| 13 |
|
| 14 |
New V9 instructions include the 64-bit extended version of multiplications, |
| 15 |
divisions, shifts, and load and store. |
| 16 |
\begin{verbatim} |
| 17 |
MULX SMULX DIVX SLLX SRLX SRAX LDX STX |
| 18 |
\end{verbatim} |
| 19 |
|
| 20 |
Also, V9 includes conditional moves and more general form of branches. |
| 21 |
\begin{description} |
| 22 |
\item[MOVcc] conditional moves on condition code |
| 23 |
\item[FMOVcc] conditional moves on condition code |
| 24 |
\item[MOVR] conditional moves on integer condition |
| 25 |
\item[BR] branch on integer register with prediction |
| 26 |
\item[BP] branch on integer condition with prediction |
| 27 |
\end{description} |
| 28 |
\end{description} |
| 29 |
|
| 30 |
\subsection{General Setup for V8} |
| 31 |
|
| 32 |
The SPARC architecture has 32 general purpose registers |
| 33 |
(\verb|%g0| is always 0) |
| 34 |
and 32 single precision floating point registers. |
| 35 |
|
| 36 |
Some Ugliness: double precision floating point registers are |
| 37 |
register pairs. There are no double precision moves, negation and absolute |
| 38 |
values. These require two single precision operations. I've created |
| 39 |
composite instructions \verb|FMOVd|, |
| 40 |
\verb|FNEGd| and |
| 41 |
\verb|FABSd| to stand for these. |
| 42 |
|
| 43 |
All integer arithmetic instructions can optionally set the condition |
| 44 |
code register. We use this to simplify certain comparisons with zero |
| 45 |
in the instruction selection process. |
| 46 |
|
| 47 |
Integer multiplication, division and conversion from integer to floating |
| 48 |
go thru the pseudo instruction interface, since older sparcs do not |
| 49 |
implement these instructions in hardware. |
| 50 |
|
| 51 |
In addition, the trap instruction for detecting overflow is a parameter. |
| 52 |
This allows different trap vectors to be used. |
| 53 |
|
| 54 |
\subsection{General Setup for V9} |
| 55 |
|
| 56 |
\subsection{Specializing the Sparc Back End} |