Re: Unaligned access trade-offs for SFrame FRE layout
Jens Remus <[email protected]> Thu, 18 Sep 2025 12:39:18 +0200
| Newsgroups | org.kernel.vger.linux-toolchains |
|---|---|
| Organization | IBM Deutschland Research & Development GmbH |
| Message-ID | <[email protected]> |
On 9/16/2025 5:58 PM, Steven Rostedt wrote: > 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. This would allow for endianness bugs for the native case only on s390 (and other big-endian architectures). Load Reversed takes longer than a normal Load, as it obviously needs to reverse the register contents. Regards, Jens -- Jens Remus Linux on Z Development (D3303) +49-7031-16-1128 Office [email protected] IBM IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294 IBM Data Privacy Statement: https://www.ibm.com/privacy/