This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
rs6000 struct returns
- To: gcc at gcc dot gnu dot org
- Subject: rs6000 struct returns
- From: "James L. Dein" <jdein at windriver dot com>
- Date: Mon, 19 Mar 2001 17:00:44 -0800 (PST)
- Reply-To: "James L. Dein" <jdein at windriver dot com>
According to the SVR4 ABI for rs6000, which is subsumed by the EABI, small
structs should be returned in r3/r4, if they fit. However, gcc is not doing
that: instead, all structs are being returned just like large structs, i.e., via
a secret pointer arg to an area allocated by the caller.
Can anyone suggest how to implement the correct behavior? It appears that
returning structs in single regs is easy to implement, but there is no support
for returning in more than one reg.
For example:
barf.c:
struct barf {
int gleep;
int glorp;
};
struct barf flirm(int a, int b)
{
struct barf zorg;
zorg.gleep = a;
zorg.glorp = b;
return zorg;
}
prompt> $dir/gcc-cross -O2 -S -meabi -B $dir/ -v barf.c -o barf.new.s
Reading specs from /folk/mrs/net/gcc-ppc/gcc/specs
Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld
--target=powerpc-elf
gcc version 3.1 20010314 (experimental)
/folk/mrs/net/gcc-ppc/gcc/cc1 -lang-c -v -iprefix
/folk/mrs/net/gcc-ppc/gcc/../lib/gcc-lib/powerpc-elf/3.1/ -isystem
/folk/mrs/net/gcc-ppc/gcc/include -D__GNUC__=3 -D__GNUC_MINOR__=1
-D__GNUC_PATCHLEVEL__=0 -DPPC -Dunix -D__svr4__ -D__PPC__ -D__unix__ -D__svr4__
-D__PPC -D__unix -Asystem=unix -Asystem=svr4 -Acpu=powerpc -Amachine=powerpc
-D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -D_CALL_SYSV
-D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine=bigendian -D_ARCH_PPC barf.c
-mcall-sysv -quiet -dumpbase barf.c -meabi -O2 -version -o barf.new.s
GNU CPP version 3.1 20010314 (experimental) (cpplib) (PowerPC System V.4)
GNU C version 3.1 20010314 (experimental) (powerpc-elf)
compiled by GNU C version 2.97 20010108 (experimental).
ignoring nonexistent directory
"/folk/mrs/net/gcc-ppc/lib/gcc-lib/powerpc-elf/3.1/include"
ignoring nonexistent directory "/folk/mrs/net/gcc-ppc/powerpc-elf/sys-include"
ignoring nonexistent directory "/folk/mrs/net/gcc-ppc/powerpc-elf/include"
ignoring nonexistent directory "/usr/local/lib/gcc-lib/powerpc-elf/3.1/include"
ignoring nonexistent directory "/usr/local/powerpc-elf/sys-include"
ignoring nonexistent directory "/usr/local/powerpc-elf/include"
#include "..." search starts here:
#include <...> search starts here:
/folk/mrs/net/gcc-ppc/gcc/include
End of search list.
prompt>
barf.new.s:
.file "barf.c"
gcc2_compiled.:
.section ".text"
.align 2
.globl flirm
.type flirm,@function
flirm:
mr 11,4
mr 9,3 # r3 copied to r9 -- why?
mr 12,5
stw 11,0(9) # first word stored through pointer
stw 12,4(9) # 2nd word stored through pointer
blr
.Lfe1:
.size flirm,.Lfe1-flirm
.ident "GCC: (GNU) 3.1 20010314 (experimental)"
Jim Dein