From: Jason R Thorpe <thorpej@wasabisystems.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: Michael Elizabeth Chastain <mec@shout.net>,
gdb-patches@sources.redhat.com, gcc@gcc.gnu.org
Subject: Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
Date: Sun, 02 Jun 2002 11:51:00 -0000 [thread overview]
Message-ID: <20020602115105.E27682@dr-evil.shagadelic.org> (raw)
In-Reply-To: <3CF902B0.50405@cygnus.com>; from ac131313@cygnus.com on Sat, Jun 01, 2002 at 01:21:52PM -0400
On Sat, Jun 01, 2002 at 01:21:52PM -0400, Andrew Cagney wrote:
> Yep! The attached fixes it. Looks like PPC/NetBSD's custom GCC has a
> fixed struct return (I'm pretty sure that mainline GCC is broken).
Hmmmmm, both our 2.91 and 2.95 based compilers use:
#define RETURN_IN_MEMORY(TYPE) \
(TYPE_MODE (TYPE) == BLKmode \
&& (DEFAULT_ABI != ABI_SOLARIS || int_size_in_bytes (TYPE) > 8))
...and don't override this anywhere. The DEFAULT_ABI ends up as ABI_V4,
and not ABI_SOLARIS, so we definitely should be using the AIX structure
return convention there.
However, the following:
struct test_struct {
int a;
int b;
};
static struct test_struct test_struct = { 1,2 };
struct test_struct
test(void)
{
return test_struct;
}
...does indeed produce code that appears to follow the SVR4 ABI rules:
.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)"
...and adding another member to the structure (this making it > 8 bytes)
produces an in-memory return:
.file "test.c"
gcc2_compiled.:
.section ".data"
.align 2
.type test_struct,@object
.size test_struct,12
test_struct:
.long 1
.long 2
.space 4
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 9,test_struct@ha
la 11,test_struct@l(9)
lwz 10,test_struct@l(9)
lwz 8,8(11)
lwz 0,4(11)
stw 10,0(3)
stw 0,4(3)
stw 8,8(3)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 2.95.3 20010315 (release) (NetBSD nb1)"
AHA! I see why. In the 2.91 and 2.95 compilers, config/netbsd.h
defines DEFAULT_PCC_STRUCT_RETURN to 0, which causes GCC's
aggregate_value_p() to effecively give the SVR4 ABI semantics.
Yes, gcc 3.1 and gcc-current are definitely broken in this regard for
NetBSD, then (I haven't had a chance to do much gcc work on powerpc-netbsd,
but I'm obviously going to have to pay a bit more attention to it now).
I'll fix that up soon, and will simply remove the broken abi struct return
stuff from ppcnbsd-tdep.c.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
next prev parent reply other threads:[~2002-06-02 18:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-01 8:46 Michael Elizabeth Chastain
2002-06-01 10:21 ` [rfa:ppc] Fix PPC/NBSD struct return; Was: " Andrew Cagney
2002-06-01 15:03 ` Jason R Thorpe
2002-06-02 11:15 ` Jason R Thorpe
2002-06-02 11:51 ` Jason R Thorpe [this message]
2002-06-02 12:24 ` Zack Weinberg
2002-06-02 13:29 ` Jason R Thorpe
2002-06-03 6:13 ` Andrew Cagney
2002-06-03 11:30 ` Michael Snyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020602115105.E27682@dr-evil.shagadelic.org \
--to=thorpej@wasabisystems.com \
--cc=ac131313@cygnus.com \
--cc=gcc@gcc.gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=mec@shout.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox