Mercurial > pub > dyncall > dyncall
comparison doc/manual/callconvs/callconv_arm32.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 | 75cb8f79d725 |
children | 0909837648d2 |
comparison
equal
deleted
inserted
replaced
498:fd9ba3a6d348 | 499:fc614cb865c6 |
---|---|
87 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) | 87 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) |
88 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack | 88 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack |
89 \item parameters \textless=\ 32 bits are passed as 32 bit words | 89 \item parameters \textless=\ 32 bits are passed as 32 bit words |
90 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS) | 90 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS) |
91 \item aggregates (struct, union) are passed by value (after rounding up the size to the nearest multiple of 4), as a sequence of words (splitting across registers and stack is allowed) | 91 \item aggregates (struct, union) are passed by value (after rounding up the size to the nearest multiple of 4), as a sequence of words (splitting across registers and stack is allowed) |
92 \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 | |
92 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) | 93 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) |
93 \end{itemize} | 94 \end{itemize} |
94 | 95 |
95 \paragraph{Return values} | 96 \paragraph{Return values} |
96 | 97 |
97 \begin{itemize} | 98 \begin{itemize} |
98 \item return values \textless=\ 32 bits use r0 | 99 \item return values \textless=\ 32 bits use r0 |
99 \item 64 bit return values use r0 and r1 | 100 \item 64 bit return values use r0 and r1 |
101 \item for {\it non-trivial} C++ aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | |
102 (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 | |
100 \item aggregates (struct, union) \textless=\ 32 bits are returned like an integer (in r0) | 103 \item aggregates (struct, union) \textless=\ 32 bits are returned like an integer (in r0) |
101 \item aggregates (struct, union) \textgreater\ 32 bits the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 | 104 \item aggregates (struct, union) \textgreater\ 32 bits the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 |
102 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 | 105 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 |
103 \end{itemize} | 106 \end{itemize} |
104 | 107 |
173 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) | 176 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) |
174 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack | 177 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack |
175 \item parameters \textless=\ 32 bits are passed as 32 bit words | 178 \item parameters \textless=\ 32 bits are passed as 32 bit words |
176 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS) | 179 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS) |
177 \item aggregates (struct, union) are passed by value (after rounding up the size to the nearest multiple of 4), as a sequence of words (splitting across registers and stack is allowed) | 180 \item aggregates (struct, union) are passed by value (after rounding up the size to the nearest multiple of 4), as a sequence of words (splitting across registers and stack is allowed) |
181 \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 | |
178 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) | 182 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) |
179 \end{itemize} | 183 \end{itemize} |
180 | 184 |
181 \paragraph{Return values} | 185 \paragraph{Return values} |
182 | 186 |
183 \begin{itemize} | 187 \begin{itemize} |
184 \item return values \textless=\ 32 bits use r0 | 188 \item return values \textless=\ 32 bits use r0 |
185 \item 64 bit return values use r0 and r1 | 189 \item 64 bit return values use r0 and r1 |
190 \item for {\it non-trivial} C++ aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | |
191 (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 | |
186 \item aggregates (struct, union) \textless=\ 32 bits are returned like an integer (in r0) | 192 \item aggregates (struct, union) \textless=\ 32 bits are returned like an integer (in r0) |
187 \item aggregates (struct, union) \textgreater\ 32 bits the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 | 193 \item aggregates (struct, union) \textgreater\ 32 bits the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 |
188 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 | 194 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 |
189 \end{itemize} | 195 \end{itemize} |
190 | 196 |
367 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words (for first 4 integer arguments) to a reserved stack area adjacent to the other parameters on the stack | 373 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words (for first 4 integer arguments) to a reserved stack area adjacent to the other parameters on the stack |
368 \item parameters \textless=\ 32 bits are passed as 32 bit words | 374 \item parameters \textless=\ 32 bits are passed as 32 bit words |
369 \item aggregates (struct, union) with 1 to 4 identical floating-point members (either float or double) are passed field-by-field, except if passed as a vararg | 375 \item aggregates (struct, union) with 1 to 4 identical floating-point members (either float or double) are passed field-by-field, except if passed as a vararg |
370 \item aggregates that could be passed via floating point register are never split across those and the stack, so if not enough registers are available an aggregate is | 376 \item aggregates that could be passed via floating point register are never split across those and the stack, so if not enough registers are available an aggregate is |
371 passed entirely via the stack (implying above rule that any still unused float registers will be skipped for any subsequent arg) | 377 passed entirely via the stack (implying above rule that any still unused float registers will be skipped for any subsequent arg) |
378 \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 | |
372 \item all other aggregates (struct, union), after rounding up the size to the nearest multiple of 4, are passed as a sequence of dwords, like integers (splitting across registers and stack is allowed) | 379 \item all other aggregates (struct, union), after rounding up the size to the nearest multiple of 4, are passed as a sequence of dwords, like integers (splitting across registers and stack is allowed) |
373 \item callee spills, caller reserves spill area space, though | 380 \item callee spills, caller reserves spill area space, though |
374 \end{itemize} | 381 \end{itemize} |
375 | 382 |
376 \paragraph{Return values} | 383 \paragraph{Return values} |
377 | 384 |
378 \begin{itemize} | 385 \begin{itemize} |
379 \item non floating point return values \textless=\ 32 bits use r0 | 386 \item non floating point return values \textless=\ 32 bits use r0 |
380 \item non floating point 64-bit return values use r0 and r1 | 387 \item non floating point 64-bit return values use r0 and r1 |
381 \item floating point return value uses s0 (for float) or d0 (for double), respectively | 388 \item floating point return value uses s0 (for float) or d0 (for double), respectively |
389 \item for {\it non-trivial} C++ aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | |
390 (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 | |
382 \item aggregates (struct, union) with 1 to 4 identical floating-point members are returned in s0-s3 (for float) or d0-d3 (for double), respectively | 391 \item aggregates (struct, union) with 1 to 4 identical floating-point members are returned in s0-s3 (for float) or d0-d3 (for double), respectively |
383 \item all other aggregates \textless=\ 32 bits are returned via r0 | 392 \item all other aggregates \textless=\ 32 bits are returned via r0 |
384 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param | 393 \item for all other aggregates, the caller allocates space, passes pointer to it to the callee as a hidden first param |
385 (meanin in r0), and callee writes return value to this space; the ptr to the aggregate is returned in x0 | 394 (meaning in r0), and callee writes return value to this space; the ptr to the aggregate is returned in r0 |
386 \end{itemize} | 395 \end{itemize} |
387 | 396 |
388 \paragraph{Stack layout} | 397 \paragraph{Stack layout} |
389 | 398 |
390 % verified/amended: TP nov 2019 (see also doc/disas_examples/arm.armhf.disas) | 399 % verified/amended: TP nov 2019 (see also doc/disas_examples/arm.armhf.disas) |