annotate doc/manual/callconvs/callconv_sparc.tex @ 190:06ee88ce4962

- doc and comment fixes
author Tassilo Philipp
date Tue, 14 Mar 2017 00:07:31 +0100
parents e210193f6cf1
children 600bd90afdb7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 %
186
e210193f6cf1 - doc cleanups and correction about support, added bibitems, etc.
Tassilo Philipp
parents: 159
diff changeset
3 % Copyright (c) 2012-2017 Daniel Adler <dadler@uni-goettingen.de>,
159
164cf1663b7c - sparc dcb support entries in changelog
cslag
parents: 157
diff changeset
4 % Tassilo Philipp <tphilipp@potion-studios.com>
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 % Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 % purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 % copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 %//////////////////////////////////////////////////////////////////////////////
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 \subsection{SPARC Calling Convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 \paragraph{Overview}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 The SPARC family of processors is based on the SPARC instruction set architecture, which comes in basically tree revisions,
186
e210193f6cf1 - doc cleanups and correction about support, added bibitems, etc.
Tassilo Philipp
parents: 159
diff changeset
25 V7, V8 and V9.\cite{SPARCRef} The former two are 32-bit whereas the latter refers to the 64-bit SPARC architecture (see next chapter).
e210193f6cf1 - doc cleanups and correction about support, added bibitems, etc.
Tassilo Philipp
parents: 159
diff changeset
26 SPARC uses big endian byte order.\\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 \paragraph{\product{dyncall} support}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
186
e210193f6cf1 - doc cleanups and correction about support, added bibitems, etc.
Tassilo Philipp
parents: 159
diff changeset
30 \product{dyncall} fully supports the SPARC 32-bit instruction set (V7 and V8), for calls and callbacks.
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 \subsubsection{SPARC (32-bit) Calling Convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 \paragraph{Register usage}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 \item 32 32-bit integer/pointer registers
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38 \item 32 floating point registers (usable as 8 quad precision, 16 double precision or 32 single precision registers)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 \item 32 registers are accessible at a time (8 are global ones (g*), whereas the rest forms a register window with 8 input (i*), 8 output (o*) and 8 local (l*) ones)
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
40 \item calling a function shifts the register window, the old output registers become the new input registers (old local and input ones are not accessible anymore)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
44 \begin{tabular*}{0.95\textwidth}{lll}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 Name & Alias & Brief description\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 {\bf \%g0} & & Read-only, hardwired to 0 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 {\bf \%g1-\%g7} & & Global \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 {\bf \%o0 and \%i0} & & Output and input argument 0, return value \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 {\bf \%o1-\%o5 and \%i1-\%i5} & & Output and input argument registers \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 {\bf \%o6 and \%i6} & & Stack and frame pointer \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52 {\bf \%o7 and \%i7} & & Return address (caller writes to o7, callee uses i7) \\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 0
diff changeset
53 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 \caption{Register usage on sparc calling convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55 \end{table}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 \paragraph{Parameter passing}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 \begin{itemize}
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
59 \item stack grows down
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
60 \item stack parameter order: right-to-left
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
61 \item caller cleans up the stack
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
62 \item stack always aligned to 8 bytes
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 \item first 6 integers and floats are passed independently in registers using \%o0-\%o5
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64 \item for every other argument the stack is used
190
06ee88ce4962 - doc and comment fixes
Tassilo Philipp
parents: 186
diff changeset
65 \item all arguments \textless=\ 32 bit are passed as 32 bit values
06ee88ce4962 - doc and comment fixes
Tassilo Philipp
parents: 186
diff changeset
66 \item 64 bit arguments are passed like two consecutive \textless=\ 32 bit values
157
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
67 \item minimum stack size is 64 bytes, b/c stack pointer must always point at enough space to store all \%i* and \%l* registers, used when running out of register windows
49549739228c - sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents: 95
diff changeset
68 \item if needed, register spill area is adjacent to parameters
190
06ee88ce4962 - doc and comment fixes
Tassilo Philipp
parents: 186
diff changeset
69 \item results are expected by caller to be returned in \%o0/\%o1 (after reg window restore, meaning callee writes to \%i0/\%i1) for integers, \%f0/\%f1 for floats, and for structs/unions a pointer to them is used as a hidden stack parameter (see below)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 \paragraph{Stack layout}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 Stack directly after function prolog:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 \begin{figure}[h]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 \begin{tabular}{5|3|1 1}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 & \vdots & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80 \hhline{~=~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
81 local data & \hspace{4cm} & & \mrrbrace{10}{caller's frame} \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 padding & & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85 \mrlbrace{7}{parameter area} & argument x & \mrrbrace{3}{stack parameters} & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 & \ldots & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87 & argument 6 & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 & input argument 5 spill & \mrrbrace{3}{spill area} & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
89 & \ldots & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
90 & input argument 0 spill & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
91 & struct/union return pointer & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
92 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93 register save area (\%i* and \%l*) & & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94 \hhline{~=~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
95 local data and padding & & & \mrrbrace{3}{current frame} \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 parameter area & & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 & \vdots & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 \end{tabular}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
102 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105 \caption{Stack layout on sparc calling convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
106 \end{figure}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
107