On 4/28/22 07:56, Víctor Colombo wrote:
A solution I could think that might be easy is: rename PPC_BIT to
PPC_BIT_ULL (behaves like BIT_ULL but 'inverted'), and create a new
PPC_BIT macro that just inverts the bit value
#define PPC_BIT_ULL(bit) (0x8000000000000000ULL >> (bit))
#define PPC_BIT(bit) (63 - (bit))
There's also room for a big-endian set of registerfield macros.
(Don't forget s390x does the same thing, so "PPC" isn't appropriate
generically.)
Something like
#define BE_FIELD_W(reg, field, regwidth, start, length) \
FIELD(reg, field, regwidth - start - length, length)
#define BE_FIELD32(reg, field, start, length) \
BE_FIELD_(reg, field, 32, start, length)
#define BE_FIELD64(reg, field, start, length) \
BE_FIELD_(reg, field, 64, start, length)
at which point the usual FIELD_EX* and FIELD_DP* macros will work.
r~