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: Ian Lance Taylor <iant at google dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 09 Mar 2011 16:43:44 -0800
- Subject: Re: RFC: target hook to reverse bitfield allocations
- References: <201103092245.p29MjZQ5018956@greed.delorie.com>
DJ Delorie <dj@redhat.com> writes:
> In the RX chip (and others, of course), the memory-mapped peripherals
> have a fixed bit-ordering independent of the endianness of data.
> However, GCC defines bitfields in structures differently for different
> endians - effectively always beginning allocations with the lowest
> addressed byte.
First I have to say that people should not use bitfields to access
memory mapped peripherals. However, at least this case is not as bad as
the volatile bitfields issue.
It seems to me that the answer is not a target hook to reverse
bitfields, it is some way of saying how bitfields should be counted
within a larger structure. E.g., BITFIELDS_BIG_ENDIAN. The default
would simply be BITS_BIG_ENDIAN as it presumably is today.
> (alternately, there could be a target-independent attribute (such as
> above), but in the RX case, compatibility with other RX compilers
> means the target needs to use a pragma)
If you need type attributes for this beyond a simple macro, then I agree
that they should be target independent.
Ian