We can use the registerfields API to safely set the individual fields and avoid open coding magic numbers. The EC and IL fields are still driven by defines but we could convert them later.
Signed-off-by: Alex Bennée <[email protected]> --- target/arm/syndrome.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index bff61f052cc..86a2d5ea9d0 100644 --- a/target/arm/syndrome.h +++ b/target/arm/syndrome.h @@ -26,6 +26,7 @@ #define TARGET_ARM_SYNDROME_H #include "qemu/bitops.h" +#include "hw/core/registerfields.h" /* Valid Syndrome Register EC field values */ enum arm_exception_class { @@ -352,11 +353,24 @@ static inline uint32_t syn_breakpoint(int same_el) | ARM_EL_IL | 0x22; } +FIELD(WFX_ISS, TI, 0, 2) +FIELD(WFX_ISS, RV, 14, 1) +FIELD(WFX_ISS, RN, 15, 5) +FIELD(WFX_ISS, COND, 20, 4) +FIELD(WFX_ISS, CV, 24, 1) + static inline uint32_t syn_wfx(int cv, int cond, int ti, bool is_16bit) { - return (EC_WFX_TRAP << ARM_EL_EC_SHIFT) | - (is_16bit ? 0 : (1 << ARM_EL_IL_SHIFT)) | - (cv << 24) | (cond << 20) | ti; + uint32_t res = (EC_WFX_TRAP << ARM_EL_EC_SHIFT); + + res = FIELD_DP32(res, WFX_ISS, CV, cv); + res = FIELD_DP32(res, WFX_ISS, COND, cond); + res = FIELD_DP32(res, WFX_ISS, TI, ti); + + if (!is_16bit) { + res |= ARM_EL_IL; + } + return res; } static inline uint32_t syn_illegalstate(void) -- 2.47.3
