Mercurial > pub > dyncall > dyncall
annotate doc/manual/callconvs/callconv_sparc.tex @ 159:164cf1663b7c
- sparc dcb support entries in changelog
- doc cleanup for sparc cconv appendix
- todo cleanup
author | cslag |
---|---|
date | Thu, 29 Dec 2016 06:27:56 -0600 |
parents | 49549739228c |
children | e210193f6cf1 |
rev | line source |
---|---|
0 | 1 %////////////////////////////////////////////////////////////////////////////// |
2 % | |
159 | 3 % Copyright (c) 2012-2016 Daniel Adler <dadler@uni-goettingen.de>, |
4 % Tassilo Philipp <tphilipp@potion-studios.com> | |
0 | 5 % |
6 % Permission to use, copy, modify, and distribute this software for any | |
7 % purpose with or without fee is hereby granted, provided that the above | |
8 % copyright notice and this permission notice appear in all copies. | |
9 % | |
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 % | |
18 %////////////////////////////////////////////////////////////////////////////// | |
19 | |
20 \subsection{SPARC Calling Convention} | |
21 | |
22 \paragraph{Overview} | |
23 | |
24 The SPARC family of processors is based on the SPARC instruction set architecture, which comes in basically tree revisions, | |
95 | 25 V7, V8 and V9. The former two are 32-bit whereas the latter refers to the 64-bit SPARC architecture (see next chapter). SPARC is big endian.\\ |
0 | 26 |
27 \paragraph{\product{dyncall} support} | |
28 | |
29 \product{dyncall} fully supports the SPARC 32-bit instruction set (V7 and V8), \product{dyncallback} support is missing, though. | |
30 | |
31 \subsubsection{SPARC (32-bit) Calling Convention} | |
32 | |
33 \paragraph{Register usage} | |
34 | |
35 \begin{itemize} | |
36 \item 32 32-bit integer/pointer registers | |
37 \item 32 floating point registers (usable as 8 quad precision, 16 double precision or 32 single precision registers) | |
38 \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
|
39 \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 | 40 \end{itemize} |
41 | |
42 \begin{table}[h] | |
77 | 43 \begin{tabular*}{0.95\textwidth}{lll} |
0 | 44 Name & Alias & Brief description\\ |
45 \hline | |
46 {\bf \%g0} & & Read-only, hardwired to 0 \\ | |
47 {\bf \%g1-\%g7} & & Global \\ | |
48 {\bf \%o0 and \%i0} & & Output and input argument 0, return value \\ | |
49 {\bf \%o1-\%o5 and \%i1-\%i5} & & Output and input argument registers \\ | |
50 {\bf \%o6 and \%i6} & & Stack and frame pointer \\ | |
51 {\bf \%o7 and \%i7} & & Return address (caller writes to o7, callee uses i7) \\ | |
76 | 52 \end{tabular*} |
0 | 53 \caption{Register usage on sparc calling convention} |
54 \end{table} | |
55 | |
56 \paragraph{Parameter passing} | |
57 \begin{itemize} | |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
58 \item stack grows down |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
59 \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
|
60 \item caller cleans up the stack |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
61 \item stack always aligned to 8 bytes |
0 | 62 \item first 6 integers and floats are passed independently in registers using \%o0-\%o5 |
63 \item for every other argument the stack is used | |
157
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
64 \item all arguments <= 32 bit are passed as 32 bit values |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
65 \item 64 bit arguments are passed like two consecutive <= 32 bit values |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
66 \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
|
67 \item if needed, register spill area is adjacent to parameters |
49549739228c
- sparc callback asm and args code (still some stack alignment issues, currently)
cslag
parents:
95
diff
changeset
|
68 \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 | 69 \end{itemize} |
70 | |
71 \paragraph{Stack layout} | |
72 | |
73 Stack directly after function prolog:\\ | |
74 | |
75 \begin{figure}[h] | |
76 \begin{tabular}{5|3|1 1} | |
77 \hhline{~-~~} | |
78 & \vdots & & \\ | |
79 \hhline{~=~~} | |
92 | 80 local data & \hspace{4cm} & & \mrrbrace{10}{caller's frame} \\ |
0 | 81 \hhline{~-~~} |
82 padding & & & \\ | |
83 \hhline{~-~~} | |
84 \mrlbrace{7}{parameter area} & argument x & \mrrbrace{3}{stack parameters} & \\ | |
85 & \ldots & & \\ | |
86 & argument 6 & & \\ | |
87 & input argument 5 spill & \mrrbrace{3}{spill area} & \\ | |
88 & \ldots & & \\ | |
89 & input argument 0 spill & & \\ | |
90 & struct/union return pointer & & \\ | |
91 \hhline{~-~~} | |
92 register save area (\%i* and \%l*) & & & \\ | |
93 \hhline{~=~~} | |
94 local data and padding & & & \mrrbrace{3}{current frame} \\ | |
95 \hhline{~-~~} | |
96 parameter area & & & \\ | |
97 \hhline{~-~~} | |
98 & \vdots & & \\ | |
99 \hhline{~-~~} | |
100 \end{tabular} | |
101 \\ | |
102 \\ | |
103 \\ | |
104 \caption{Stack layout on sparc calling convention} | |
105 \end{figure} | |
106 |