Patch ping
I posted a patch implementing arm vfp emulation over a week ago, and it seems to have passed without comment:
http://lists.gnu.org/archive/html/qemu-devel/2005-02/msg00131.html
Paul
Quoted 3 lines · Paul Brook
I posted a patch implementing arm vfp emulation over a week ago, and it seems to have passed without comment:
http://lists.gnu.org/archive/html/qemu-devel/2005-02/msg00131.html
It seems that you like C macros :-) Can you suppress the operations to read or write FP registers ? You can add just a few ops to read or write to a constant offset in the CPU state. It seems that a generic IEEE library is needed in QEMU now because most CPUs need the same operations...
Fabrice.
Re: [Qemu-devel] Arm VFP
Quoted 3 lines
It seems that you like C macros :-) Can you suppress the operations to read or write FP registers ? You can add just a few ops to read or write to a constant offset in the CPU state.
Done, as attached.
This does result in slightly worse code, requiring an additional constant load. It doesn't seem too effect my x86 host too badly, presumably the OOO core hides much of the cost of loading the constant.
Before:
flds 0x120(%ebp)
fstpl 0x1a8(%ebp)
After:
mov $ __op_param1,%eax fldl 0x114(%ebp,%eax,8) fstpl 0x1a8(%ebp)
Paul
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.57
Makefile.target +4 -0
@@ -259,6 +259,10 @@ ifeq ($(TARGET_BASE_ARCH), sparc) LIBOBJS+= op_helper.o helper.o endif +ifeq ($(TARGET_BASE_ARCH), arm) +LIBOBJS+= op_helper.o +endif + # NOTE: the disassembler code is only needed for debugging LIBOBJS+=disas.o ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
Index: cpu-exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-exec.c,v
retrieving revision 1.50
cpu-exec.c +3 -1
@@ -346,7 +346,8 @@ int cpu_exec(CPUState *env1) cs_base = env->segs[R_CS ].base; pc = cs_base + env->eip;#elif defined(TARGET_ARM ) - flags = env->thumb; + flags = env->thumb | (env->vfp.vec_len <<1 ) + | (env->vfp.vec_stride <<4 ); cs_base =0 ; pc = env->regs[15 ];#elif defined(TARGET_SPARC )
@@ -619,6 +620,7 @@ int cpu_exec(CPUState *env1)#endif #elif defined(TARGET_ARM) env->cpsr =compute_cpsr (); +/* XXX: Save/restore host fpu exception state?. */ #elif defined(TARGET_SPARC)#elif defined(TARGET_PPC)#else
Index: target-arm/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.6
cpu.h +28 -0
@@ -29,6 +29,14 @@#define EXCP_PREFETCH_ABORT 3#define EXCP_DATA_ABORT 4 +/* We currently assume float and double are IEEE single and double +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. */ + typedef struct CPUARMState { uint32_t regs[16]; uint32_t cpsr;
@@ -50,6 +58,7 @@ typedef struct CPUARMState {int interrupt_request;struct TranslationBlock *current_tb;int user_mode_only; +uint32_t address;/* in order to avoid passing too many arguments to the memory write helpers, we store some rarely used information in the CPU
@@ -58,6 +67,25 @@ typedef struct CPUARMState {written */ unsigned long mem_write_vaddr;/* target virtual addr at which the memory was written */ +/* VFP coprocessor state. */ +struct { +union { +float s[32 ]; +double d[16 ]; + } regs; + +/* We store these fpcsr fields separately for convenience. */ +int vec_len; +int vec_stride; + +uint32_t fpscr; + +/* Temporary variables if we don't have spare fp regs. */ +float tmp0s, tmp1s; +double tmp0d, tmp1d; + + } vfp; +/* user data */ void *opaque; } CPUARMState;
Index: target-arm/exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/exec.h,v
retrieving revision 1.4
exec.h +28 -4
@@ -24,13 +24,16 @@ register uint32_t T0 asm(AREG1); register uint32_t T1 asm(AREG2); register uint32_t T2 asm(AREG3); +/* TODO: Put these in FP regs on targets that have such things. */ +/* It is ok for FT0s and FT0d to overlap. Likewise FT1s and FT1d. */ +#define FT0s env->vfp.tmp0s +#define FT1s env->vfp.tmp1s +#define FT0d env->vfp.tmp0d +#define FT1d env->vfp.tmp1d +#include "cpu.h" #include "exec-all.h" -void cpu_lock (void ); -void cpu_unlock (void ); -void cpu_loop_exit (void ); -/* Implemented CPSR bits. */ #define CACHED_CPSR_BITS 0xf8000000static inline int compute_cpsr (void )
@@ -51,3 +54,24 @@ static inline void regs_to_env(void)int cpu_arm_handle_mmu_fault (CPUState *env,target_ulong address,int rw,int is_user,int is_softmmu); + +/* In op_helper.c */ + +void cpu_lock (void ); +void cpu_unlock (void ); +void cpu_loop_exit (void ); + +void raise_exception (int ); + +void do_vfp_abss (void ); +void do_vfp_absd (void ); +void do_vfp_negs (void ); +void do_vfp_negd (void ); +void do_vfp_sqrts (void ); +void do_vfp_sqrtd (void ); +void do_vfp_cmps (void ); +void do_vfp_cmpd (void ); +void do_vfp_cmpes (void ); +void do_vfp_cmped (void ); +void do_vfp_set_fpscr (void ); +void do_vfp_get_fpscr (void );
Index: target-arm/op.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/op.c,v
retrieving revision 1.8
op.c +244 -6
267 lines not on this page · raw message
Index: target-arm/op_helper.c
===================================================================
RCS file: target-arm/op_helper.c
op_helper.c new file +229 -0
229 lines not on this page · raw message
Index: target-arm/translate.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/translate.c,v retrieving revision 1.17
translate.c +562 -3
617 lines not on this page · raw message