mirror of
https://github.com/qemu/qemu.git
synced 2025-01-26 15:40:11 +08:00
hw/registerfields: Add FIELD_SEX<N> and FIELD_SDP<N>
Add new macros to manipulate signed fields within the register. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20220301215958.157011-2-richard.henderson@linaro.org Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
4c579e15bd
commit
d5e51efb9f
@ -59,6 +59,19 @@
|
||||
extract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH)
|
||||
|
||||
#define FIELD_SEX8(storage, reg, field) \
|
||||
sextract8((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH)
|
||||
#define FIELD_SEX16(storage, reg, field) \
|
||||
sextract16((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH)
|
||||
#define FIELD_SEX32(storage, reg, field) \
|
||||
sextract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH)
|
||||
#define FIELD_SEX64(storage, reg, field) \
|
||||
sextract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH)
|
||||
|
||||
/* Extract a field from an array of registers */
|
||||
#define ARRAY_FIELD_EX32(regs, reg, field) \
|
||||
FIELD_EX32((regs)[R_ ## reg], reg, field)
|
||||
@ -95,7 +108,40 @@
|
||||
_d; })
|
||||
#define FIELD_DP64(storage, reg, field, val) ({ \
|
||||
struct { \
|
||||
uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
uint64_t v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
} _v = { .v = val }; \
|
||||
uint64_t _d; \
|
||||
_d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH, _v.v); \
|
||||
_d; })
|
||||
|
||||
#define FIELD_SDP8(storage, reg, field, val) ({ \
|
||||
struct { \
|
||||
signed int v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
} _v = { .v = val }; \
|
||||
uint8_t _d; \
|
||||
_d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH, _v.v); \
|
||||
_d; })
|
||||
#define FIELD_SDP16(storage, reg, field, val) ({ \
|
||||
struct { \
|
||||
signed int v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
} _v = { .v = val }; \
|
||||
uint16_t _d; \
|
||||
_d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH, _v.v); \
|
||||
_d; })
|
||||
#define FIELD_SDP32(storage, reg, field, val) ({ \
|
||||
struct { \
|
||||
signed int v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
} _v = { .v = val }; \
|
||||
uint32_t _d; \
|
||||
_d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
R_ ## reg ## _ ## field ## _LENGTH, _v.v); \
|
||||
_d; })
|
||||
#define FIELD_SDP64(storage, reg, field, val) ({ \
|
||||
struct { \
|
||||
int64_t v:R_ ## reg ## _ ## field ## _LENGTH; \
|
||||
} _v = { .v = val }; \
|
||||
uint64_t _d; \
|
||||
_d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \
|
||||
|
Loading…
Reference in New Issue
Block a user