[rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
Jason R Thorpe
thorpej@wasabisystems.com
Sun Jun 2 18:13:00 GMT 2002
On Sun, Jun 02, 2002 at 08:43:16PM -0400, Kevin B. Hendricks wrote:
> So based on what I have read this code may have to be modified for NetBSD
> ppc.
I think your assumption is correct.
> To prevent confusion, please specifiy whether or not you are (or will be)
> using small structure returns in registers for any of
>
> gcc 2.95.X
> gcc 3.0.X
> gcc 3.1
>
> for NetBSD ppc.
2.95.x -- NetBSD/powerpc was not supported in the stock GCC 2.95.3 release.
The native in-tree compiler for NetBSD/powerpc, which is 2.95.3-based,
returns small structures in registers.
3.0.x -- I don't know, I'd have to check.
3.1 -- *INCORRECTLY* returns small structures in memory. 3.1.1 will
correct the problem, and return small structures in registers, to match
the 2.95.3-based native in-tree compiler.
Please consider "returns small structures in registers, per the SVR4 ABI"
to be the expected behavior for NetBSD/powerpc.
> Is there any value in keeping NetBSD PPC in sync with PPC Linux for these
> issues? Does you decision here impact NetBSD's ppc ability to run PPC
> Linux binaries like the Blackdown JDK, etc under Linux emulation?
No, running binaries under Linux emulation will not be affected, since those
binaries are linked at run-time against Linux shared libraries.
> Either way I would appreciate knowing your plans so that I can fix the
> bridge code in NetBSD for ppc (for both gcc 3.X and gcc 2.95.X).
See above. If your bridge code for NetBSD/powerpc currently assumes the
"return in memory" behavior of Linux, then it is incorrect.
Attached are 4 files:
test.c -- function which returns an 8 byte structure
test.s-2.95.3-native -- asm output from the 2.95.3-based
native compiler which will ship with NetBSD 1.6. The output
is the same as the 2.91-based compiler that NetBSD 1.5 shipped.
test.s-3.2-broken -- asm output from gcc 3.1 and gcc-current
before the compiler was fixed.
test.s-3.2-working -- asm output from gcc 3.1(.1) and gcc-current
after the compiler was fixed.
Note that I have checked the necessary fix into the GCC mainline and
the 3.1 branch (so the fix will be in 3.1.1).
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
struct test_struct {
int a;
int b;
};
static struct test_struct test_struct = { 1,2 };
struct test_struct
test(void)
{
return test_struct;
}
-------------- next part --------------
.file "test.c"
gcc2_compiled.:
.section ".sdata","aw"
.align 2
.type test_struct,@object
.size test_struct,8
test_struct:
.long 1
.long 2
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 9,test_struct@ha
la 9,test_struct@l(9)
lwz 3,0(9)
lwz 4,4(9)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 2.95.3 20010315 (release) (NetBSD nb1)"
-------------- next part --------------
.file "test.c"
.section ".data"
.align 2
.type test_struct,@object
.size test_struct,8
test_struct:
.long 1
.long 2
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 11,test_struct@ha
la 11,test_struct@l(11)
lfd 0,0(11)
stfd 0,0(3)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 3.2 20020602 (experimental)"
-------------- next part --------------
.file "test.c"
.section ".data"
.align 2
.type test_struct,@object
.size test_struct,8
test_struct:
.long 1
.long 2
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 9,test_struct@ha
la 9,test_struct@l(9)
lwz 3,0(9)
lwz 4,4(9)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 3.2 20020602 (experimental)"
More information about the Gcc
mailing list