Mercurial > pub > dyncall > dyncall
comparison doc/disas_examples/arm64.aapcs.disas @ 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 | cb19b2fe2422 |
children |
comparison
equal
deleted
inserted
replaced
498:fd9ba3a6d348 | 499:fc614cb865c6 |
---|---|
1854 d4: e9 43 00 91 add x9, sp, #16 ; | 1854 d4: e9 43 00 91 add x9, sp, #16 ; |
1855 d8: bf c3 1f b8 stur wzr, [x29, #-4] ; | 1855 d8: bf c3 1f b8 stur wzr, [x29, #-4] ; |
1856 dc: e8 07 00 f9 str x8, [sp, #8] ; | 1856 dc: e8 07 00 f9 str x8, [sp, #8] ; |
1857 e0: e9 03 00 f9 str x9, [sp] ; | 1857 e0: e9 03 00 f9 str x9, [sp] ; |
1858 e4: c7 ff ff 97 bl #-228 <f0> ; return address -> r30/lr, and call | 1858 e4: c7 ff ff 97 bl #-228 <f0> ; return address -> r30/lr, and call |
1859 e8: ea 03 00 2a mov w10, w0 ; | 1859 e8: ea 03 00 2a mov w10, w0 ; retval via w0, as small struct |
1860 ec: e8 07 40 f9 ldr x8, [sp, #8] ; | 1860 ec: e8 07 40 f9 ldr x8, [sp, #8] ; |
1861 f0: 0a 01 00 39 strb w10, [x8] ; | 1861 f0: 0a 01 00 39 strb w10, [x8] ; |
1862 f4: e8 03 40 f9 ldr x8, [sp] ; ptr to retval struct, as sizeof(struct Big) > 16 | 1862 f4: e8 03 40 f9 ldr x8, [sp] ; ptr to retval struct, as sizeof(struct Big) > 16 |
1863 f8: d3 ff ff 97 bl #-180 <f1> ; return address -> r30/lr, and call | 1863 f8: d3 ff ff 97 bl #-180 <f1> ; return address -> r30/lr, and call |
1864 fc: e8 0f 40 f9 ldr x8, [sp, #24] ; | 1864 fc: e8 0f 40 f9 ldr x8, [sp, #24] ; |
2255 | 2255 |
2256 ; ... snip, removed code of ctor and copy ctor ... | 2256 ; ... snip, removed code of ctor and copy ctor ... |
2257 | 2257 |
2258 | 2258 |
2259 | 2259 |
2260 ; ---------- C++ trivial and non-trivial aggrs as return values ----------> | |
2261 ; | |
2262 ; struct Trivial { int a; }; | |
2263 ; struct NonTrivial { int a; NonTrivial() : a(0) {} NonTrivial(const NonTrivial& rhs) : a(rhs.a) { } }; | |
2264 ; | |
2265 ; extern "C" { | |
2266 ; struct Trivial f1() { return Trivial(); } | |
2267 ; } | |
2268 ; | |
2269 ; struct NonTrivial f2() { return NonTrivial(); } | |
2270 ; | |
2271 ; extern "C" { | |
2272 ; void f() | |
2273 ; { | |
2274 ; int a=1; | |
2275 ; a += 123; | |
2276 ; struct Trivial t = f1(); | |
2277 ; a -= 123; | |
2278 ; struct NonTrivial n = f2(); | |
2279 ; a -= 12; | |
2280 ; } | |
2281 ; } | |
2282 | |
2283 | |
2284 | |
2285 ; output from freebsd-13.0_r348764-arm64 w/ clang 8.0.0 | |
2286 | |
2287 0000000000210250 f1: | |
2288 210250: ff 83 00 d1 sub sp, sp, #32 | |
2289 210254: fe 0b 00 f9 str x30, [sp, #16] | |
2290 210258: 08 00 80 52 mov w8, #0 | |
2291 21025c: e2 03 7e b2 orr x2, xzr, #0x4 | |
2292 210260: e9 33 00 91 add x9, sp, #12 | |
2293 210264: e0 03 09 aa mov x0, x9 | |
2294 210268: e1 03 08 2a mov w1, w8 | |
2295 21026c: e9 03 00 f9 str x9, [sp] | |
2296 210270: 64 00 00 94 bl #400 <memset@plt> | |
2297 210274: e9 03 40 f9 ldr x9, [sp] | |
2298 210278: 28 01 40 b9 ldr w8, [x9] | |
2299 21027c: e0 03 08 2a mov w0, w8 | |
2300 210280: 00 7c 40 d3 ubfx x0, x0, #0, #32 | |
2301 210284: fe 0b 40 f9 ldr x30, [sp, #16] | |
2302 210288: ff 83 00 91 add sp, sp, #32 | |
2303 21028c: c0 03 5f d6 ret | |
2304 | |
2305 0000000000210290 _Z2f2v: | |
2306 210290: fd 7b bf a9 stp x29, x30, [sp, #-16]! | |
2307 210294: fd 03 00 91 mov x29, sp | |
2308 210298: e0 03 08 aa mov x0, x8 ; ptr to retval space -> x0 | |
2309 21029c: 29 00 00 94 bl #164 <_ZN10NonTrivialC2Ev> | |
2310 2102a0: fd 7b c1 a8 ldp x29, x30, [sp], #16 | |
2311 2102a4: c0 03 5f d6 ret | |
2312 | |
2313 00000000002102a8 f: | |
2314 2102a8: ff c3 00 d1 sub sp, sp, #48 ; | |
2315 2102ac: fd 7b 02 a9 stp x29, x30, [sp, #32] ; | |
2316 2102b0: fd 83 00 91 add x29, sp, #32 ; | |
2317 2102b4: e8 03 00 32 orr w8, wzr, #0x1 ; | |
2318 2102b8: a9 23 00 d1 sub x9, x29, #8 ; | |
2319 2102bc: aa 33 00 d1 sub x10, x29, #12 ; | |
2320 2102c0: a8 c3 1f b8 stur w8, [x29, #-4] ; | |
2321 2102c4: a8 c3 5f b8 ldur w8, [x29, #-4] ; | |
2322 2102c8: 08 ed 01 11 add w8, w8, #123 ; | |
2323 2102cc: a8 c3 1f b8 stur w8, [x29, #-4] ; | |
2324 2102d0: e9 07 00 f9 str x9, [sp, #8] ; | |
2325 2102d4: ea 03 00 f9 str x10, [sp] ; | |
2326 2102d8: de ff ff 97 bl #-136 <f1> ; call f1() | |
2327 2102dc: e8 03 00 2a mov w8, w0 ; retval via w0, as small struct | |
2328 2102e0: e9 07 40 f9 ldr x9, [sp, #8] ; | |
2329 2102e4: 28 01 00 b9 str w8, [x9] ; | |
2330 2102e8: a8 c3 5f b8 ldur w8, [x29, #-4] ; | |
2331 2102ec: 08 ed 01 71 subs w8, w8, #123 ; | |
2332 2102f0: a8 c3 1f b8 stur w8, [x29, #-4] ; | |
2333 2102f4: e8 03 40 f9 ldr x8, [sp] ; ptr to retval struct via dedicated reg x8, as non-trivial aggr | |
2334 2102f8: e6 ff ff 97 bl #-104 <_Z2f2v> ; call f2() | |
2335 2102fc: ab c3 5f b8 ldur w11, [x29, #-4] ; | |
2336 210300: 6b 31 00 71 subs w11, w11, #12 ; | |
2337 210304: ab c3 1f b8 stur w11, [x29, #-4] ; | |
2338 210308: fd 7b 42 a9 ldp x29, x30, [sp, #32] ; | |
2339 21030c: ff c3 00 91 add sp, sp, #48 ; | |
2340 210310: c0 03 5f d6 ret ; | |
2341 | |
2342 | |
2343 | |
2260 ; vim: ft=asm68k | 2344 ; vim: ft=asm68k |
2261 | 2345 |