Mercurial > pub > dyncall > dyncall
comparison doc/disas_examples/arm64.aapcs.disas @ 497:cb19b2fe2422
- more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
author | Tassilo Philipp |
---|---|
date | Wed, 23 Mar 2022 15:24:31 +0100 |
parents | 0fc22b5feac7 |
children | fc614cb865c6 |
comparison
equal
deleted
inserted
replaced
496:da5232da6270 | 497:cb19b2fe2422 |
---|---|
2166 278: ff 83 03 91 add sp, sp, #224 | 2166 278: ff 83 03 91 add sp, sp, #224 |
2167 27c: c0 03 5f d6 ret | 2167 27c: c0 03 5f d6 ret |
2168 | 2168 |
2169 | 2169 |
2170 | 2170 |
2171 ; ---------- C++ trivial and non-trivial aggrs passed to C funcs ----------> | |
2172 ; | |
2173 ; struct Trivial { int a; }; | |
2174 ; struct NonTrivial { int a; NonTrivial() : a(0) {} NonTrivial(const NonTrivial& rhs) : a(rhs.a) { } }; | |
2175 ; | |
2176 ; extern "C" { | |
2177 ; | |
2178 ; void f1(struct Trivial s) { } | |
2179 ; void f2(struct NonTrivial s) { } | |
2180 ; | |
2181 ; void f() | |
2182 ; { | |
2183 ; struct Trivial t; | |
2184 ; struct NonTrivial n; | |
2185 ; int a=1; | |
2186 ; a += 123; | |
2187 ; f1(t); | |
2188 ; a -= 123; | |
2189 ; f2(n); | |
2190 ; a -= 12; | |
2191 ; } | |
2192 ; } | |
2193 | |
2194 | |
2195 | |
2196 ; output from freebsd-13.0_r348764-arm64 w/ clang 8.0.0 | |
2197 | |
2198 0000000000210250 f1: | |
2199 210250: ff 43 00 d1 sub sp, sp, #16 | |
2200 210254: e8 33 00 91 add x8, sp, #12 | |
2201 210258: e9 03 00 2a mov w9, w0 | |
2202 21025c: 09 01 00 b9 str w9, [x8] | |
2203 210260: ff 43 00 91 add sp, sp, #16 | |
2204 210264: c0 03 5f d6 ret | |
2205 | |
2206 0000000000210268 f2: | |
2207 210268: c0 03 5f d6 ret | |
2208 | |
2209 000000000021026c f: | |
2210 21026c: ff 43 01 d1 sub sp, sp, #80 ; | |
2211 210270: fd 7b 04 a9 stp x29, x30, [sp, #64] ; | |
2212 210274: fd 03 01 91 add x29, sp, #64 ; | |
2213 210278: e8 03 00 32 orr w8, wzr, #0x1 ; | |
2214 21027c: e2 03 7e b2 orr x2, xzr, #0x4 ; | |
2215 210280: a1 13 00 d1 sub x1, x29, #4 ; | |
2216 210284: a9 23 00 d1 sub x9, x29, #8 ; | |
2217 210288: aa 43 00 d1 sub x10, x29, #16 ; | |
2218 21028c: ab 53 00 d1 sub x11, x29, #20 ; | |
2219 210290: e0 03 09 aa mov x0, x9 ; | |
2220 210294: a8 83 1e b8 stur w8, [x29, #-24] ; | |
2221 210298: e2 13 00 f9 str x2, [sp, #32] ; | |
2222 21029c: e1 0f 00 f9 str x1, [sp, #24] ; | |
2223 2102a0: e9 0b 00 f9 str x9, [sp, #16] ; | |
2224 2102a4: ea 07 00 f9 str x10, [sp, #8] ; | |
2225 2102a8: eb 03 00 f9 str x11, [sp] ; | |
2226 2102ac: 1f 00 00 94 bl #124 <_ZN10NonTrivialC2Ev> ; | |
2227 2102b0: a8 83 5e b8 ldur w8, [x29, #-24] ; | |
2228 2102b4: a8 43 1f b8 stur w8, [x29, #-12] ; | |
2229 2102b8: ac 43 5f b8 ldur w12, [x29, #-12] ; | |
2230 2102bc: 8c ed 01 11 add w12, w12, #123 ; | |
2231 2102c0: ac 43 1f b8 stur w12, [x29, #-12] ; | |
2232 2102c4: e0 07 40 f9 ldr x0, [sp, #8] ; | |
2233 2102c8: e1 0f 40 f9 ldr x1, [sp, #24] ; | |
2234 2102cc: e2 13 40 f9 ldr x2, [sp, #32] ; | |
2235 2102d0: 50 00 00 94 bl #320 <memcpy@plt> ; | |
2236 2102d4: e9 07 40 f9 ldr x9, [sp, #8] ; | |
2237 2102d8: 28 01 40 b9 ldr w8, [x9] ; | |
2238 2102dc: ea 03 08 2a mov w10, w8 ; | |
2239 2102e0: 40 7d 40 d3 ubfx x0, x10, #0, #32 ; | |
2240 2102e4: db ff ff 97 bl #-148 <f1> ; | |
2241 2102e8: a8 43 5f b8 ldur w8, [x29, #-12] ; | |
2242 2102ec: 08 ed 01 71 subs w8, w8, #123 ; | |
2243 2102f0: a8 43 1f b8 stur w8, [x29, #-12] ; | |
2244 2102f4: e0 03 40 f9 ldr x0, [sp] ; | ptr to dest of copy of n | |
2245 2102f8: e1 0b 40 f9 ldr x1, [sp, #16] ; | copy n ptr to n | |
2246 2102fc: 11 00 00 94 bl #68 <_ZN10NonTrivialC2ERKS_> ; | NonTrivial::NonTrivial(const NonTrivial&) / copy ctor | |
2247 210300: e0 03 40 f9 ldr x0, [sp] ; f2 arg 0 (ptr to copy of struct NonTrivial), via ptr as non-trivial | |
2248 210304: d9 ff ff 97 bl #-156 <f2> ; call f2(struct NonTrivial) | |
2249 210308: a8 43 5f b8 ldur w8, [x29, #-12] ; | |
2250 21030c: 08 31 00 71 subs w8, w8, #12 ; | |
2251 210310: a8 43 1f b8 stur w8, [x29, #-12] ; | |
2252 210314: fd 7b 44 a9 ldp x29, x30, [sp, #64] ; | |
2253 210318: ff 43 01 91 add sp, sp, #80 ; | |
2254 21031c: c0 03 5f d6 ret ; | |
2255 | |
2256 ; ... snip, removed code of ctor and copy ctor ... | |
2257 | |
2258 | |
2259 | |
2171 ; vim: ft=asm68k | 2260 ; vim: ft=asm68k |
2172 | 2261 |