Mercurial > pub > dyncall > dyncall
comparison doc/manual/callconvs/callconv_ppc32.tex @ 499:fc614cb865c6
- doc and disasexample additions specific to non-trivial C++ aggregates as return values (incl. fixes to doc and additional LSB specific PPC32 section)
author | Tassilo Philipp |
---|---|
date | Mon, 04 Apr 2022 15:50:52 +0200 |
parents | 6c72cb768099 |
children | 585dcb68f55d |
comparison
equal
deleted
inserted
replaced
498:fd9ba3a6d348 | 499:fc614cb865c6 |
---|---|
94 \item composite parameters with size of 1 or 2 bytes occupy low-order bytes of their 4-byte area. INCONSISTENT with other 32-bit PPC | 94 \item composite parameters with size of 1 or 2 bytes occupy low-order bytes of their 4-byte area. INCONSISTENT with other 32-bit PPC |
95 binary interfaces. In AIX and mac OS 9, padding bytes always follow the data structure | 95 binary interfaces. In AIX and mac OS 9, padding bytes always follow the data structure |
96 \item composite parameters 3 bytes or larger in size occupy high-order bytes | 96 \item composite parameters 3 bytes or larger in size occupy high-order bytes |
97 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy higher-address bytes) in their 4-byte slot on the stack, requiring extra-care for big-endian targets | 97 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy higher-address bytes) in their 4-byte slot on the stack, requiring extra-care for big-endian targets |
98 \item aggregates (struct, union) with only one (non-aggregate / non-array) field are passed as if the field itself would be passed | 98 \item aggregates (struct, union) with only one (non-aggregate / non-array) field are passed as if the field itself would be passed |
99 \item {\it non-trivial} C++ aggregates (as defined by the language) of any size, are passed indirectly via a pointer to a copy of the aggregate | |
99 \item all other aggregates are passed as a sequence of words (like integer parameters) | 100 \item all other aggregates are passed as a sequence of words (like integer parameters) |
100 \end{itemize} | 101 \end{itemize} |
101 | 102 |
102 | 103 |
103 \paragraph{Return values} | 104 \paragraph{Return values} |
104 | 105 |
105 \begin{itemize} | 106 \begin{itemize} |
106 \item return values of integer \textless=\ 32bit or pointer type use gpr3 | 107 \item return values of integer \textless=\ 32bit or pointer type use gpr3 |
107 \item 64 bit integers use gpr3 and gpr4 (hiword in gpr3, loword in gpr4) | 108 \item 64 bit integers use gpr3 and gpr4 (hiword in gpr3, loword in gpr4) |
108 \item floating point values are returned via fpr1 | 109 \item floating point values are returned via fpr1 |
109 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4 | 110 \item for all aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param |
110 \item for all other aggregates and types \textgreater\ 64 bits, a secret first parameter with an address to a caller allocated space is passed to the function (in gpr3), which is written to by the callee | 111 (meaning in gpr3), and callee writes return value to this space; the ptr to the aggregate is returned in gpr3 |
111 \end{itemize} | 112 \end{itemize} |
112 | 113 |
113 | 114 |
114 \paragraph{Stack layout} | 115 \paragraph{Stack layout} |
115 | 116 |
207 or passed on the stack; they are never splitted into a register and stack part | 208 or passed on the stack; they are never splitted into a register and stack part |
208 \item Ellipsis calls set CR bit 6 | 209 \item Ellipsis calls set CR bit 6 |
209 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy high-order bytes) in their 4-byte area, requiring extra-care for big-endian targets | 210 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy high-order bytes) in their 4-byte area, requiring extra-care for big-endian targets |
210 \item no spill area is used on stack, iterating over varargs requires a specific va\_list implementation | 211 \item no spill area is used on stack, iterating over varargs requires a specific va\_list implementation |
211 \item aggregates (struct, union) and types \textgreater\ 64 bits are passed indirectly, as a pointer to the data (or a copy of it, if necessary to avoid modification) | 212 \item aggregates (struct, union) and types \textgreater\ 64 bits are passed indirectly, as a pointer to the data (or a copy of it, if necessary to avoid modification) |
213 \item {\it non-trivial} C++ aggregates (as defined by the language) of any size, are passed indirectly via a pointer to a copy of the aggregate | |
212 \end{itemize} | 214 \end{itemize} |
213 | 215 |
214 \paragraph{Return values} | 216 \paragraph{Return values} |
215 | 217 |
216 \begin{itemize} | 218 \begin{itemize} |
217 \item 32-bit integers use register r3, 64-bit use registers r3 and r4 (hiword in r3, loword in r4) | 219 \item 32-bit integers use register r3, 64-bit use registers r3 and r4 (hiword in r3, loword in r4) |
218 \item floating-point values are returned using register f1 | 220 \item floating-point values are returned using register f1 |
221 \item for {\it non-trivial} C++ aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | |
222 (meaning in gpr3), and callee writes return value to this space; the ptr to the aggregate is returned in gpr3 | |
219 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4 | 223 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4 |
220 \item for all other aggregates and types \textgreater\ 64 bits, a secret first parameter with an address to a caller allocated space is passed to the function (in gpr3), which is written to by the callee | 224 \item for all other aggregates and types \textgreater\ 64 bits, a secret first parameter with an address to a caller allocated space is passed to the function (in gpr3), which is written to by the callee |
221 \end{itemize} | 225 \end{itemize} |
222 | 226 |
223 | 227 |
250 \hhline{~-~~} | 254 \hhline{~-~~} |
251 & \vdots & & \\ | 255 & \vdots & & \\ |
252 \end{tabular} | 256 \end{tabular} |
253 \caption{Stack layout on System V ABI for PowerPC 32-bit calling convention} | 257 \caption{Stack layout on System V ABI for PowerPC 32-bit calling convention} |
254 \end{figure} | 258 \end{figure} |
259 | |
260 | |
261 \subsubsection{System V PPC 32-bit / Linux Standard Base version} | |
262 | |
263 This is in essence the same as the System V PPC 32-bit calling convention, but differs for aggregate return values: | |
264 % @@@STRUCT make this more obvious | |
265 | |
266 \begin{itemize} | |
267 \item for all aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | |
268 (meaning in gpr3), and callee writes return value to this space; the ptr to the aggregate is returned in gpr3 | |
269 \end{itemize} | |
255 | 270 |
256 | 271 |
257 \clearpage | 272 \clearpage |
258 | 273 |
259 \subsubsection{System V syscalls} | 274 \subsubsection{System V syscalls} |