comparison doc/manual/callconvs/callconv_ppc32.tex @ 473:ead041d93e36

- ppc doc and disas examples related to aggregates
author Tassilo Philipp
date Wed, 16 Feb 2022 16:44:11 +0100
parents b47168dacba6
children 6c72cb768099
comparison
equal deleted inserted replaced
472:e5820b7a3fbc 473:ead041d93e36
93 \item vector parameters are aligned on 16-byte boundaries 93 \item vector parameters are aligned on 16-byte boundaries
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
99 \item all other aggregates are passed as a sequence of words (like integer parameters)
98 \end{itemize} 100 \end{itemize}
99 101
100 102
101 \paragraph{Return values} 103 \paragraph{Return values}
102 104
103 \begin{itemize} 105 \begin{itemize}
104 \item return values of integer \textless=\ 32bit or pointer type use gpr3 106 \item return values of integer \textless=\ 32bit or pointer type use gpr3
105 \item 64 bit integers use gpr3 and gpr4 (hiword in gpr3, loword in gpr4) 107 \item 64 bit integers use gpr3 and gpr4 (hiword in gpr3, loword in gpr4)
106 \item floating point values are returned via fpr1 108 \item floating point values are returned via fpr1
107 \item structures \textless=\ 64 bits use gpr3 and gpr4 109 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4
108 \item for types \textgreater\ 64 bits, a secret first parameter with an address to the return value is passed 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
109 \end{itemize} 111 \end{itemize}
110 112
111 113
112 \paragraph{Stack layout} 114 \paragraph{Stack layout}
113 115
194 \end{table} 196 \end{table}
195 197
196 \paragraph{Parameter passing} 198 \paragraph{Parameter passing}
197 199
198 \begin{itemize} 200 \begin{itemize}
199 \item Stack pointer (r1) is always 16-byte aligned. The EABI differs here - it is 8-byte alignment. 201 \item Stack pointer (r1) is always 16-byte aligned. The EABI differs here - it is 8-byte alignment
200 \item 8 general-purpose registers (r3-r10) for integer and pointer types. 202 \item 8 general-purpose registers (r3-r10) for integer and pointer types
201 \item 8 floating-pointer registers (f1-f8) for float (promoted to double) and double types. 203 \item 8 floating-pointer registers (f1-f8) for float (promoted to double) and double types
202 \item Additional arguments are passed on the stack directly after the back-chain and saved return address (8 bytes structure) on the callers stack frame. 204 \item Additional arguments are passed on the stack directly after the back-chain and saved return address (8 bytes structure) on the callers stack frame
203 \item 64-bit integer data types are passed in general-purpose registers as a whole in two 205 \item 64-bit integer data types are passed in general-purpose registers as a whole in two
204 32-bit general purpose registers (an odd and an even e.g. r3 and r4), skipping an even integer register 206 32-bit general purpose registers (an odd and an even e.g. r3 and r4), skipping an even integer register
205 or passed on the stack; they are never splitted into a register and stack part 207 or passed on the stack; they are never splitted into a register and stack part
206 \item Ellipsis calls set CR bit 6 208 \item Ellipsis calls set CR bit 6
207 \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 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
208 \item no spill area is used on stack, iterating over varargs requires a specific va\_list implementation 210 \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)
209 \end{itemize} 212 \end{itemize}
210 213
211 \paragraph{Return values} 214 \paragraph{Return values}
212 215
213 \begin{itemize} 216 \begin{itemize}
214 \item 32-bit integers use register r3, 64-bit use registers r3 and r4 (hiword in r3, loword in r4). 217 \item 32-bit integers use register r3, 64-bit use registers r3 and r4 (hiword in r3, loword in r4)
215 \item floating-point values are returned using register f1. 218 \item floating-point values are returned using register f1
219 \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
216 \end{itemize} 221 \end{itemize}
217 222
218 223
219 \paragraph{Stack layout} 224 \paragraph{Stack layout}
220 225