From e390c1ec7f2a2ef480d73536014ec18b02b5ab3b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 2 Mar 2021 11:55:48 -0500 Subject: [PATCH] target/arm: Use neon_element_offset in vfp_reg_offset This seems a bit more readable than using offsetof CPU_DoubleU. Backports d8719785fde2f5041986853a314c05c6f567d3cb --- qemu/target/arm/translate.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index 60bf91b1..a122e7e6 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -1167,18 +1167,13 @@ neon_element_offset(int reg, int element, MemOp size) return neon_full_reg_offset(reg) + ofs; } -static inline long vfp_reg_offset(bool dp, unsigned reg) +/* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */ +static long vfp_reg_offset(bool dp, unsigned reg) { if (dp) { - return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); + return neon_element_offset(reg, 0, MO_64); } else { - long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]); - if (reg & 1) { - ofs += offsetof(CPU_DoubleU, l.upper); - } else { - ofs += offsetof(CPU_DoubleU, l.lower); - } - return ofs; + return neon_element_offset(reg >> 1, reg & 1, MO_32); } }