This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: target hook to reverse bitfield allocations
- From: Michael Matz <matz at suse dot de>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 10 Mar 2011 14:31:41 +0100 (CET)
- Subject: Re: RFC: target hook to reverse bitfield allocations
- References: <201103092245.p29MjZQ5018956@greed.delorie.com>
Hi,
On Wed, 9 Mar 2011, DJ Delorie wrote:
> To avoid having two completely independent definitions of the
> peripheral register structures, would it be acceptable to add a target
> hook to tell gcc to reverse the bitfields? This can be done in
> finish_record_layout() by adjusting bit offsets, but is only defined
> for targets where switching bitfield base types starts a new
> allocation (i.e. "long x:4;" and "char x;" can't overlap) or where the
> user is careful to avoid such a situation.
Not going into the debate about sensibility of such a mean, but IMHO:
there is nothing target specific about this, hence no target hook. It
should be an attribute on either the struct type, or even on the
individual FIELD_DECLs (which doesn't necessarily mean the use has to
annotate each field, how that attribute is going to be set via frontends
means, i.e. a real attribute on the fields, or on the type, or via pragmas
isn't interesting for the design of this thing). And I think the
adjustments should not be done after the fact in finish_record_layout, but
rather right in place_field, where also the fields alignment and mode are
properly tracked.
Ciao,
Michael.