On 5/17/23 00:42, Thomas Huth wrote:
+static inline int ldl_p(const void *ptr)
+{
+ return tswap32(ldl_he_p(ptr));
Not an ideal formulation for some hosts, e.g. Power < 3.0, because there is no separate
bswap instruction. Power 2.07 only has bswapping-load/store. Keeping the bswap adjacent
to the memory operation helps the compiler.
+static inline uint64_t ldn_p(const void *ptr, int sz)
+{
+ if (target_needs_bswap()) {
+#if HOST_BIG_ENDIAN
+ return ldn_le_p(ptr, sz);
+#else
+ return ldn_be_p(ptr, sz);
+#endif
+ } else {
+ return ldn_he_p(ptr, sz);
+ }
Better to avoid #if for if. And even better to merge to one test:
if (HOST_BIG_ENDIAN ^ target_needs_bswap()) {
return ldn_le_p(ptr, sz);
} else {
return ldn_be_p(ptr, sz);
}
r~