This is the mail archive of the
mailing list for the GCC project.
Re: Byte swapping support
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jürg Billeter <juerg dot billeter at codethink dot co dot uk>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, Eric Botcazou <ebotcazou at adacore dot com>
- Date: Tue, 12 Sep 2017 08:52:58 -0700
- Subject: Re: Byte swapping support
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org>
On Tue, Sep 12, 2017 at 2:32 AM, Jürg Billeter
> 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
> very useful.
> Any comments or suggestions?
> Best regards,
Can you use __attribute__ ((scalar_storage_order)) in GCC 7?