Re: Unaligned access trade-offs for SFrame FRE layout

Steven Rostedt <[email protected]> Tue, 16 Sep 2025 11:58:01 -0400
Newsgroups org.kernel.vger.linux-toolchains
Message-ID <[email protected]>
On Mon, 15 Sep 2025 23:05:09 -0700
Fangrui Song <[email protected]> wrote:

> From a linker and binary utilities perspective, I'd even suggest  
> adopting a universal little-endian format regardless of the target
> system's native endianness.
> This would eliminate the need for endianness templates in the C++ code
> and simplify toolchain implementation across platforms.
> 
> On the big-endian z/Architecture, this is efficient: the LOAD REVERSED
> instructions are used by the bswap versions in the following program,
> not even requiring extra instructions.
> #define WIDTH(x) \
> typedef __UINT##x##_TYPE__ [[gnu::aligned(1)]] uint##x; \
> uint##x load_inc##x(uint##x *p) { return *p+1; } \
> uint##x load_bswap_inc##x(uint##x *p) { return __builtin_bswap##x(*p)+1; }; \
> uint##x load_eq##x(uint##x *p) { return *p==3; } \
> uint##x load_bswap_eq##x(uint##x *p) { return __builtin_bswap##x(*p)==3; }; \
> 
> WIDTH(16);
> WIDTH(32);
> WIDTH(64);

I would like to hear the comments from Jens on this, as he's adapting
SFrames for the s390 which I believe is big-endian.

-- Steve