This is the mail archive of the
mailing list for the GCC project.
Byte swapping support
- From: Jürg Billeter <juerg dot billeter at codethink dot co dot uk>
- To: gcc at gcc dot gnu dot org, Eric Botcazou <ebotcazou at adacore dot com>
- Date: Tue, 12 Sep 2017 11:32:52 +0200
- Subject: Byte swapping support
- Authentication-results: sourceware.org; auth=none
To support applications that assume big-endian memory layout on little-
endian systems, I'm considering adding support for reversing the
storage order to GCC. In contrast to the existing scalar storage order
support for structs, the goal is to reverse the storage order for all
memory operations to achieve maximum compatibility with the behavior on
big-endian systems, as far as observable by the application.
The plan is to insert byte swapping instructions as part of the RTL
expansion of GIMPLE assignments that access memory. This would leverage
code that was added for -fsso-struct, keeping the code simple and
maintainable. It should not be necessary to insert byte swapping
instructions for spilled registers.
Is this something that GCC upstream would be interested to accept?
To facilitate byte swapping at endian boundaries (kernel or libraries),
I'm also considering developing a new GCC builtin that can byte-swap
whole structs in memory. There are limitations to this, e.g., unions
could not be supported in general. However, I still expect this to be
Any comments or suggestions?