From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DFJFA-0001B0-B8 for qemu-devel@nongnu.org; Sat, 26 Mar 2005 16:54:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DFJF4-000196-Ko for qemu-devel@nongnu.org; Sat, 26 Mar 2005 16:54:52 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DFJF3-00014y-Ch for qemu-devel@nongnu.org; Sat, 26 Mar 2005 16:54:49 -0500 Received: from [65.74.133.9] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1DFIzi-0000oF-UN for qemu-devel@nongnu.org; Sat, 26 Mar 2005 16:38:59 -0500 From: Paul Brook Date: Sat, 26 Mar 2005 21:38:54 +0000 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_uZdRCMy/+VTOfpz" Message-Id: <200503262138.54778.paul@codesourcery.com> Subject: [Qemu-devel] [patch] vfp register ordering Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_uZdRCMy/+VTOfpz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline In most VFP implementations the registers are defined such that single precision registers s0 and s1 map onto the low and high halves of double precision register d0. The attached patch modifies the qemu implementation to be consistent with this. Paul --Boundary-00=_uZdRCMy/+VTOfpz Content-Type: text/x-diff; charset="us-ascii"; name="patch.qemu_vfp_s0" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.qemu_vfp_s0" Index: target-arm/cpu.h =================================================================== RCS file: /cvsroot/qemu/qemu/target-arm/cpu.h,v retrieving revision 1.8 diff -u -p -r1.8 cpu.h --- target-arm/cpu.h 13 Mar 2005 18:50:12 -0000 1.8 +++ target-arm/cpu.h 26 Mar 2005 21:27:45 -0000 @@ -35,9 +35,9 @@ precision respectively. Doing runtime conversions is tricky because VFP registers may contain integer values (eg. as the result of a FTOSI instruction). - A double precision register load/store must also load/store the - corresponding single precision pair, although it is undefined how - these overlap. */ + s<2n> maps to the least significant half of d + s<2n+1> maps to the most significant half of d + */ typedef struct CPUARMState { uint32_t regs[16]; @@ -71,10 +71,7 @@ typedef struct CPUARMState { memory was written */ /* VFP coprocessor state. */ struct { - union { - float32 s[32]; - float64 d[16]; - } regs; + float64 regs[16]; /* We store these fpcsr fields separately for convenience. */ int vec_len; Index: target-arm/translate.c =================================================================== RCS file: /cvsroot/qemu/qemu/target-arm/translate.c,v retrieving revision 1.18 diff -u -p -r1.18 translate.c --- target-arm/translate.c 22 Feb 2005 19:27:29 -0000 1.18 +++ target-arm/translate.c 26 Mar 2005 21:27:45 -0000 @@ -385,28 +385,41 @@ VFP_OP(st) #undef VFP_OP +static inline long +vfp_reg_offset (int dp, int reg) +{ + if (dp) + return offsetof(CPUARMState, vfp.regs[reg]); + else if (reg & 1) { + return offsetof(CPUARMState, vfp.regs[reg >> 1]) + + offsetof(CPU_DoubleU, l.upper); + } else { + return offsetof(CPUARMState, vfp.regs[reg >> 1]) + + offsetof(CPU_DoubleU, l.lower); + } +} static inline void gen_mov_F0_vreg(int dp, int reg) { if (dp) - gen_op_vfp_getreg_F0d(offsetof(CPUARMState, vfp.regs.d[reg])); + gen_op_vfp_getreg_F0d(vfp_reg_offset(dp, reg)); else - gen_op_vfp_getreg_F0s(offsetof(CPUARMState, vfp.regs.s[reg])); + gen_op_vfp_getreg_F0s(vfp_reg_offset(dp, reg)); } static inline void gen_mov_F1_vreg(int dp, int reg) { if (dp) - gen_op_vfp_getreg_F1d(offsetof(CPUARMState, vfp.regs.d[reg])); + gen_op_vfp_getreg_F1d(vfp_reg_offset(dp, reg)); else - gen_op_vfp_getreg_F1s(offsetof(CPUARMState, vfp.regs.s[reg])); + gen_op_vfp_getreg_F1s(vfp_reg_offset(dp, reg)); } static inline void gen_mov_vreg_F0(int dp, int reg) { if (dp) - gen_op_vfp_setreg_F0d(offsetof(CPUARMState, vfp.regs.d[reg])); + gen_op_vfp_setreg_F0d(vfp_reg_offset(dp, reg)); else - gen_op_vfp_setreg_F0s(offsetof(CPUARMState, vfp.regs.s[reg])); + gen_op_vfp_setreg_F0s(vfp_reg_offset(dp, reg)); } /* Disassemble a VFP instruction. Returns nonzero if an error occured @@ -2120,9 +2133,9 @@ void cpu_dump_state(CPUState *env, FILE env->cpsr & (1 << 28) ? 'V' : '-'); for (i = 0; i < 16; i++) { - s0.s = env->vfp.regs.s[i * 2]; - s1.s = env->vfp.regs.s[i * 2 + 1]; - d.d = env->vfp.regs.d[i]; + d.d = env->vfp.regs[i]; + s0.i = d.l.lower; + s1.i = d.l.upper; cpu_fprintf(f, "s%02d=%08x(%8f) s%02d=%08x(%8f) d%02d=%08x%08x(%8f)\n", i * 2, (int)s0.i, s0.s, i * 2 + 1, (int)s0.i, s0.s, --Boundary-00=_uZdRCMy/+VTOfpz--