comparison doc/disas_examples/mips.o32.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 6c72cb768099
children fd9ba3a6d348
comparison
equal deleted inserted replaced
496:da5232da6270 497:cb19b2fe2422
1752 154: 27bd0060 addiu sp,sp,96 1752 154: 27bd0060 addiu sp,sp,96
1753 ... 1753 ...
1754 1754
1755 1755
1756 1756
1757 ; ---------- C++ trivial and non-trivial aggrs passed to C funcs ---------->
1758 ;
1759 ; struct Trivial { int a; };
1760 ; struct NonTrivial { int a; NonTrivial() : a(0) {} NonTrivial(const NonTrivial& rhs) : a(rhs.a) { } };
1761 ;
1762 ; extern "C" {
1763 ;
1764 ; void f1(struct Trivial s) { }
1765 ; void f2(struct NonTrivial s) { }
1766 ;
1767 ; void f()
1768 ; {
1769 ; struct Trivial t;
1770 ; struct NonTrivial n;
1771 ; int a=1;
1772 ; a += 123;
1773 ; f1(t);
1774 ; a -= 123;
1775 ; f2(n);
1776 ; a -= 12;
1777 ; }
1778 ; }
1779
1780
1781
1782 ; output from freebsd-12.0_r333647-malta_mipsebhf w/ gcc 4.2.1 *and* -mhard-float ----->
1783
1784 004008c0 <f1>:
1785 4008c0: 3c1c0002 lui gp,0x2
1786 4008c4: 279c8330 addiu gp,gp,-31952
1787 4008c8: 0399e021 addu gp,gp,t9
1788 4008cc: 27bdfff8 addiu sp,sp,-8
1789 4008d0: afbe0000 sw s8,0(sp)
1790 4008d4: 03a0f021 move s8,sp
1791 4008d8: afc40008 sw a0,8(s8)
1792 4008dc: 03c0e821 move sp,s8
1793 4008e0: 8fbe0000 lw s8,0(sp)
1794 4008e4: 03e00008 jr ra
1795 4008e8: 27bd0008 addiu sp,sp,8
1796
1797 004008ec <f2>:
1798 4008ec: 3c1c0002 lui gp,0x2
1799 4008f0: 279c8304 addiu gp,gp,-31996
1800 4008f4: 0399e021 addu gp,gp,t9
1801 4008f8: 27bdfff8 addiu sp,sp,-8
1802 4008fc: afbe0000 sw s8,0(sp)
1803 400900: 03a0f021 move s8,sp
1804 400904: afc40008 sw a0,8(s8)
1805 400908: 03c0e821 move sp,s8
1806 40090c: 8fbe0000 lw s8,0(sp)
1807 400910: 03e00008 jr ra
1808 400914: 27bd0008 addiu sp,sp,8
1809
1810 00400918 <f>:
1811 400918: 3c1c0002 lui gp,0x2 ;
1812 40091c: 279c82d8 addiu gp,gp,-32040 ;
1813 400920: 0399e021 addu gp,gp,t9 ;
1814 400924: 27bdffd0 addiu sp,sp,-48 ;
1815 400928: afbf002c sw ra,44(sp) ;
1816 40092c: afbe0028 sw s8,40(sp) ;
1817 400930: 03a0f021 move s8,sp ;
1818 400934: afbc0010 sw gp,16(sp) ;
1819 400938: 27c20024 addiu v0,s8,36 ;
1820 40093c: 00402021 move a0,v0 ;
1821 400940: 8f998064 lw t9,-32668(gp) ; |
1822 400944: 0320f809 jalr t9 ; | NonTrivial::NonTrivial() / ctor
1823 400948: 00000000 nop ;
1824 40094c: 8fdc0010 lw gp,16(s8) ;
1825 400950: 24020001 li v0,1 ;
1826 400954: afc20018 sw v0,24(s8) ;
1827 400958: 8fc20018 lw v0,24(s8) ;
1828 40095c: 2442007b addiu v0,v0,123 ;
1829 400960: afc20018 sw v0,24(s8) ;
1830 400964: 8fc40020 lw a0,32(s8) ;
1831 400968: 8f998060 lw t9,-32672(gp) ; |
1832 40096c: 0320f809 jalr t9 ; | call f1(struct Trivial)
1833 400970: 00000000 nop ;
1834 400974: 8fdc0010 lw gp,16(s8) ;
1835 400978: 8fc20018 lw v0,24(s8) ;
1836 40097c: 2442ff85 addiu v0,v0,-123 ;
1837 400980: afc20018 sw v0,24(s8) ;
1838 400984: 27c2001c addiu v0,s8,28 ;
1839 400988: 27c30024 addiu v1,s8,36 ;
1840 40098c: 00402021 move a0,v0 ; | ptr to dest of copy of n
1841 400990: 00602821 move a1,v1 ; | ptr to n
1842 400994: 8f998050 lw t9,-32688(gp) ; | copy n |
1843 400998: 0320f809 jalr t9 ; | | NonTrivial::NonTrivial(const NonTrivial&) / copy ctor
1844 40099c: 00000000 nop ;
1845 4009a0: 8fdc0010 lw gp,16(s8) ;
1846 4009a4: 27c2001c addiu v0,s8,28 ; get ptr to copy of n -> v0
1847 4009a8: 00402021 move a0,v0 ; f2 arg 0 (ptr to copy of struct NonTrivial), via ptr as non-trivial
1848 4009ac: 8f998058 lw t9,-32680(gp) ; |
1849 4009b0: 0320f809 jalr t9 ; | call f2(struct NonTrivial)
1850 4009b4: 00000000 nop ;
1851 4009b8: 8fdc0010 lw gp,16(s8) ;
1852 4009bc: 8fc20018 lw v0,24(s8) ;
1853 4009c0: 2442fff4 addiu v0,v0,-12 ;
1854 4009c4: afc20018 sw v0,24(s8) ;
1855 4009c8: 03c0e821 move sp,s8 ;
1856 4009cc: 8fbf002c lw ra,44(sp) ;
1857 4009d0: 8fbe0028 lw s8,40(sp) ;
1858 4009d4: 03e00008 jr ra ;
1859 4009d8: 27bd0030 addiu sp,sp,48 ;
1860
1861 ; ... snip, removed code of ctor and copy ctor ...
1862
1863
1864
1757 ; vim: ft=asm 1865 ; vim: ft=asm
1758 1866