REG_WORDS_BIG_ENDIAN
Jeff Law
law@redhat.com
Fri Jul 13 07:25:00 GMT 2018
On 07/12/2018 06:19 PM, Michael Eager wrote:
> Hi All --
>
> I'm updating GCC on a dual-endianity processor. In little-endian mode,
> memory is little-endian, but the core remains big-endian. Double-word
> values are in even/odd register pairs, with the MSW in the
> lower-numbered (even) register. Values in memory are stored with LSW in
> the low-address word.
How unpleasant.
>
> From info:
> REG_WORDS_BIG_ENDIAN [Macro]
> Â On some machines, the order of words in a multiword object differs
> Â between registers in memory. In such a situation, define this macro
> Â to describe the order of words in a register. The macro
> Â WORDS_BIG_ENDIAN controls the order of words in memory.
>
> I set REG_WORDS_BIG_ENDIAN to 1 and WORDS_BIG_ENDIAN to the memory
> endianity.
>
> None of the targets in the GCC repo define this. Does anyone know of an
> out-of-repo target which sets REG_WORDS_BIG_ENDIAN?
The closest in-tree target is probably c6x, allows selecting big/little
for WORDS_BIG_ENDIAN, but REG_WORDS_BIG_ENDIAN is always 0.
>
> Most test cases pass, but I'm finding a few cases which fail to
> calculate a subreg correctly. Subreg_lowpart_offset() is called while
> emitting RTL, for example, to truncate a DImode integer to SImode. But
> subreg_lowpart_offset() does not know whether it is computing the offset
> of a memory value or register value. It returns the word offset
> according to memory endianity, ignoring REG_WORDS_BIG_ENDIAN. (This is
> also the case with subreg_size_lowpart_offset()).
I think you'd probably want to avoid (subreg (mem)) if at all possible.
That's probably good advice in general anyway.
>
> I'm working on a patch to pass the inner RTX to subreg_lowpart_offset(),
> but this function is called in many places and it isn't always clear
> what object the subreg applies to, or even if there is an object. For
> example, maybe_mode_change() calls subreg_size_lowpart_offset() before
> generating a REG rtx. This seems to be the wrong approach.
>
> There are other subreg functions which seem to be specifically for
> registers, like subreg_get_info() and subreg_regno_offset(). It isn't
> clear whether these can replace any of the calls to
> subreg_lowpart_offset().
About the only advice I'd have would be to look at the c6x and see if
it's handling any of this stuff correctly. BUt I suspect you're largely
going to be on your own.
Jeff
More information about the Gcc-help
mailing list