Mercurial > pub > dyncall > dyncall
comparison doc/disas_examples/sparc.sparc.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 | c73c59c8b553 |
children | fc614cb865c6 |
comparison
equal
deleted
inserted
replaced
496:da5232da6270 | 497:cb19b2fe2422 |
---|---|
998 108: 81 c3 e0 08 retl | 998 108: 81 c3 e0 08 retl |
999 10c: 01 00 00 00 nop | 999 10c: 01 00 00 00 nop |
1000 | 1000 |
1001 | 1001 |
1002 | 1002 |
1003 ; ---------- C++ trivial and non-trivial aggrs passed to C funcs ----------> | |
1004 ; | |
1005 ; struct Trivial { int a; }; | |
1006 ; struct NonTrivial { int a; NonTrivial() : a(0) {} NonTrivial(const NonTrivial& rhs) : a(rhs.a) { } }; | |
1007 ; | |
1008 ; extern "C" { | |
1009 ; | |
1010 ; void f1(struct Trivial s) { } | |
1011 ; void f2(struct NonTrivial s) { } | |
1012 ; | |
1013 ; void f() | |
1014 ; { | |
1015 ; struct Trivial t; | |
1016 ; struct NonTrivial n; | |
1017 ; int a=1; | |
1018 ; a += 123; | |
1019 ; f1(t); | |
1020 ; a -= 123; | |
1021 ; f2(n); | |
1022 ; a -= 12; | |
1023 ; } | |
1024 ; } | |
1025 | |
1026 | |
1027 | |
1028 ; output from debian-4.0_r3-sparc w/ gcc 4.1.2 | |
1029 | |
1030 00010484 <f1>: | |
1031 10484: 9d e3 bf 98 save %sp, -104, %sp | |
1032 10488: 81 e8 00 00 restore | |
1033 1048c: 81 c3 e0 08 retl | |
1034 10490: 01 00 00 00 nop | |
1035 | |
1036 00010494 <f2>: | |
1037 10494: 9d e3 bf 98 save %sp, -104, %sp | |
1038 10498: f0 27 a0 44 st %i0, [ %fp + 0x44 ] | |
1039 1049c: 81 e8 00 00 restore | |
1040 104a0: 81 c3 e0 08 retl | |
1041 104a4: 01 00 00 00 nop | |
1042 | |
1043 000104a8 <f>: | |
1044 104a8: 9d e3 bf 80 save %sp, -128, %sp ; | |
1045 104ac: 82 07 bf e8 add %fp, -24, %g1 ; | |
1046 104b0: 90 10 00 01 mov %g1, %o0 ; | |
1047 104b4: 40 00 00 26 call 1054c <_ZN10NonTrivialC1Ev> ; NonTrivial::NonTrivial() / ctor | |
1048 104b8: 01 00 00 00 nop ; | |
1049 104bc: 82 10 20 01 mov 1, %g1 ! 1 <_init-0x102cb> ; | |
1050 104c0: c2 27 bf f4 st %g1, [ %fp + -12 ] ; | |
1051 104c4: c2 07 bf f4 ld [ %fp + -12 ], %g1 ; | |
1052 104c8: 82 00 60 7b add %g1, 0x7b, %g1 ; | |
1053 104cc: c2 27 bf f4 st %g1, [ %fp + -12 ] ; | |
1054 104d0: c2 07 bf ec ld [ %fp + -20 ], %g1 ; | |
1055 104d4: c2 27 bf e4 st %g1, [ %fp + -28 ] ; | |
1056 104d8: 82 07 bf e4 add %fp, -28, %g1 ; | |
1057 104dc: 90 10 00 01 mov %g1, %o0 ; | |
1058 104e0: 7f ff ff e9 call 10484 <f1> ; call f1(struct Trivial) | |
1059 104e4: 01 00 00 00 nop ; | |
1060 104e8: c2 07 bf f4 ld [ %fp + -12 ], %g1 ; | |
1061 104ec: 82 00 7f 85 add %g1, -123, %g1 ; | |
1062 104f0: c2 27 bf f4 st %g1, [ %fp + -12 ] ; | |
1063 104f4: 82 07 bf f0 add %fp, -16, %g1 ; | |
1064 104f8: 84 07 bf e8 add %fp, -24, %g2 ; | |
1065 104fc: 90 10 00 01 mov %g1, %o0 ; | ptr to dest of copy of n | |
1066 10500: 92 10 00 02 mov %g2, %o1 ; | copy n ptr to n | |
1067 10504: 40 00 00 19 call 10568 <_ZN10NonTrivialC1ERKS_> ; | NonTrivial::NonTrivial(const NonTrivial&) / copy ctor | |
1068 10508: 01 00 00 00 nop ; | |
1069 1050c: 82 07 bf f0 add %fp, -16, %g1 ; | | |
1070 10510: 90 10 00 01 mov %g1, %o0 ; | f2 arg 0 (ptr to copy of struct NonTrivial), via ptr as non-trivial | |
1071 10514: 7f ff ff e0 call 10494 <f2> ; call f2(struct NonTrivial) | |
1072 10518: 01 00 00 00 nop ; | |
1073 1051c: c2 07 bf f4 ld [ %fp + -12 ], %g1 ; | |
1074 10520: 82 00 7f f4 add %g1, -12, %g1 ; | |
1075 10524: c2 27 bf f4 st %g1, [ %fp + -12 ] ; | |
1076 10528: 81 e8 00 00 restore ; | |
1077 1052c: 81 c3 e0 08 retl ; | |
1078 10530: 01 00 00 00 nop ; | |
1079 | |
1080 ; ... snip, removed code of ctor and copy ctor ... | |
1081 | |
1082 | |
1083 | |
1003 ; vim: ft=asm | 1084 ; vim: ft=asm |
1004 | 1085 |