From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6488 invoked by alias); 10 Oct 2003 16:32:18 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 6479 invoked from network); 10 Oct 2003 16:32:17 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 10 Oct 2003 16:32:17 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h9AGWGM22548 for ; Fri, 10 Oct 2003 12:32:16 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h9AGWGc03553 for ; Fri, 10 Oct 2003 12:32:16 -0400 Received: from localhost.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id h9AGWF95009036 for ; Fri, 10 Oct 2003 12:32:15 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 01DCB2CCB5; Fri, 10 Oct 2003 12:43:27 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16262.57775.717281.437954@localhost.redhat.com> Date: Fri, 10 Oct 2003 16:32:00 -0000 To: gdb-patches@sources.redhat.com Subject: Re: [RFA] sh-tdep.c (sh_use_struct_convention): Restructure and fix In-Reply-To: <20031010150127.GK14344@cygbert.vinschen.de> References: <20031004113939.GK11435@cygbert.vinschen.de> <16261.53197.951881.194874@localhost.redhat.com> <20031010072929.GF14344@cygbert.vinschen.de> <20031010150127.GK14344@cygbert.vinschen.de> X-SW-Source: 2003-10/txt/msg00360.txt.bz2 Corinna Vinschen writes: > On Fri, Oct 10, 2003 at 09:29:29AM +0200, Corinna Vinschen wrote: > > And even though I have to admit, that I'm not 100% sure (perhaps > > I miss a case) I think the implementation should match at least 99% > > of the description. > > > > The difference between the old and the new code is given by allowing > > 4 byte structs (erm, aggregates) with more than one element, but a size > > of 4 byte for the first element. This sounds somewhat weird, but that's > > exactly the case if the 4 byte agregate is a bitfield or contains a > > bitfield. So the change in this patch solves exactly these bitfields > > as return type problem. > > ...and I just found out what this patch does *not* cover. It does > not cover the case of bitfields of size 1 or 2 bytes :-( > Argh, I just noticed this mail. > I rewrote the implementation of sh_use_struct_convention and tested it > again. Below is the entire implementation instead of the patch. I think > this is easier to read. I also tried to match the comments even better > to the actual code. Is that ok to check in? > > Btw., this time, there *are* tests missing. The testsuite doesn't check > for returning bitfield types of size 1 and 2 bytes. I'm going to add > two tests to call-rt-st.exp which I hope to submit at least Monday. > > Corinna > > ========== SNIP =========== > static int > sh_use_struct_convention (int gcc_p, struct type *type) > { > int len = TYPE_LENGTH (type); > int nelem = TYPE_NFIELDS (type); > > /* Non-power of 2 length types and types bigger than 8 bytes (which don't > fit in two registers anyway) use struct convention. */ > if (len != 1 && len != 2 && len != 4 && len != 8) > return 1; > > /* Scalar types and aggregate types with exactly one field are aligned > by definition. They are returned in registers. */ > if (nelem <= 1) > return 0; > > /* If the first field in the aggregate has the same length as the entire > aggregate type, the type is returned in registers. */ > if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == len) > return 0; > > /* If the size of the aggregate is 8 bytes and the first field is > of size 4 bytes its alignment is equal to long long's alignment, > so it's returned in registers. */ > if (len == 8 && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4) > return 0; > > /* Otherwise use struct convention. */ > return 1; > } Much better, however, I would still like to know what the behavior is for a struct of 2 chars. Probably this needs another test case. elena > ========== SNAP =========== > > > -- > Corinna Vinschen > Cygwin Developer > Red Hat, Inc.