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
> > Except that in this case we want to reverse *only* structures that
> > represent peripherals, *not* other structures.
>
> I'm sorry, that just seems frigging ridiculous.
Ridiculous? Why? I see no reason why we should dictate how other
people write their software, or design their chips. Can we stick
to reasons other than "because I don't want them to do that" ?
I didn't design gcc's structure layout rules. GCC's current rules
*cannot* work with anything other than lowest-addressed-byte-first
(lsb for little-endian, msb for big-endian). But on bi-endian chips,
it's impossible to define a structure that means the same thing
bit-wise regardless of byte-endian. Even in libgcc, we jump though
hoops to define endian-independent structures!
So we have two conflicting restrictions - GCC cannot reverse most
structures because of overlap issues, but must offer an
endian-independent way to define a structure.
The only way is to have a per-structure way of requesting the swap,
with the default being the old (reliable) way, and the swap being the
caveat programmer way.
> A target hook doesn't seem like the right approach to me. There is
> nothing particularly target specific about this concept. I don't
> know to map the target specific pragma to a type attribute, but it
> must be possible.
Perhaps the target could hook the "default attributes" stuff to apply
the attributes based on the current pragma?