softfloat-native removal and i386 improvement
PATCH v2 2/9 target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef
In reply to Aurelien Jarnotarget-mips has been switched to softfloat only long ago, but a #ifndef CONFIG_SOFTFLOAT has been forgotten. Remove it.
--- gdbstub.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
gdbstub.c +0 -4
@@ -1105,10 +1105,6 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n) env->active_fpu.fcr31 = tmp &0xFF83FFFF ;/* set rounding mode */ RESTORE_ROUNDING_MODE ; -#ifndef CONFIG_SOFTFLOAT -/* no floating point exception for native float */ -SET_FP_ENABLE (env->active_fpu.fcr31,0 ); -#endif break ;case 71 : env->active_fpu.fcr0 = tmp;break ; }
Signature · 1 line
1.7.5.1
PATCH v2 1/9 target-ppc: remove old CONFIG_SOFTFLOAT #ifdef
In reply to Aurelien Jarnotarget-ppc has been switched to softfloat only long ago, but a few #ifdef CONFIG_SOFTFLOAT have been forgotten. Remove them.
--- target-ppc/helper.h | 2 -- target-ppc/op_helper.c | 11 ----------- target-ppc/translate.c | 2 -- 3 files changed, 0 insertions(+), 15 deletions(-)
target-ppc/helper.h +0 -2
@@ -51,9 +51,7 @@ DEF_HELPER_FLAGS_1(cntlzw32, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32) DEF_HELPER_FLAGS_2(brinc, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) DEF_HELPER_0(float_check_status, void) -#ifdef CONFIG_SOFTFLOAT DEF_HELPER_0(reset_fpstatus, void) -#endif DEF_HELPER_2(compute_fprf, i32, i64, i32) DEF_HELPER_2(store_fpscr, void, i64, i32)DEF_HELPER_1 (fpscr_clrbit, void, i32)
target-ppc/op_helper.c +0 -11
@@ -971,7 +971,6 @@ void helper_store_fpscr (uint64_t arg, uint32_t mask)void helper_float_check_status (void ) { -#ifdef CONFIG_SOFTFLOAT if (env->exception_index ==POWERPC_EXCP_PROGRAM && (env->error_code &POWERPC_EXCP_FP )) {/* Differred floating-point exception after target FPR update */
@@ -989,22 +988,12 @@ void helper_float_check_status (void)float_inexact_excp (); } } -#else -if (env->exception_index ==POWERPC_EXCP_PROGRAM && - (env->error_code &POWERPC_EXCP_FP )) { -/* Differred floating-point exception after target FPR update */ -if (msr_fe0 !=0 || msr_fe1 !=0 ) -helper_raise_exception_err (env->exception_index, env->error_code); - } -#endif } -#ifdef CONFIG_SOFTFLOAT void helper_reset_fpstatus (void ) {set_float_exception_flags (0 , &env->fp_status); } -#endif /* fadd - fadd. */ uint64_t helper_fadd (uint64_t arg1,uint64_t arg2)
target-ppc/translate.c +0 -2
@@ -215,9 +215,7 @@ struct opc_handler_t {static inline void gen_reset_fpstatus (void ) { -#ifdef CONFIG_SOFTFLOAT gen_helper_reset_fpstatus (); -#endif }static inline void gen_compute_fprf (TCGv_i64 arg,int set_fprf,int set_rc)
Signature · 1 line
1.7.5.1
v2 cover softfloat-native removal and i386 improvement
This patch series finally removes softfloat-native as it is not used by default in any target. In then laters improves the target-i386 code as it does not need to be compatible with softfloat-native anymore.
v1 -> v2:
fix mips/gdbstub
reorder patches to fix target-i386 bisection
dropped log2 patches
Aurelien Jarno (9):
target-ppc: remove old CONFIG_SOFTFLOAT #ifdef target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef
target-i386: remove old code handling float64
softfloat-native: remove
softfloat: always enable floatx80 and float128 support
target-i386: use floatx80 constants in helper_fld*_ST0()
softfloat: add float*_is_zero_or_denormal()
target-i386: cleanup helper_fxam_ST0()
target-i386: add support for FPU exceptions
Makefile.target | 3 +- configure | 2 - cpu-all.h | 7 +- fpu/softfloat-native.c | 540 -------------------------------------------- fpu/softfloat-native.h | 531 ------------------------------------------- fpu/softfloat-specialize.h | 7 - fpu/softfloat.c | 62 ----- fpu/softfloat.h | 76 ++----- gdbstub.c | 4 - target-i386/cpu.h | 37 ++-- target-i386/exec.h | 144 +------------ target-i386/helper.c | 41 +++- target-i386/machine.c | 104 +--------- target-i386/op_helper.c | 329 +++++++++++---------------- target-ppc/helper.h | 2 - target-ppc/op_helper.c | 11 - target-ppc/translate.c | 2 - 17 files changed, 208 insertions(+), 1694 deletions(-) delete mode 100644 fpu/softfloat-native.c delete mode 100644 fpu/softfloat-native.h
Signature · 1 line
1.7.5.1
PATCH v2 5/9 softfloat: always enable floatx80 and float128 support
Now that softfloat-native is gone, there is no real point on not always enabling floatx80 and float128 support.
--- cpu-all.h | 2 - fpu/softfloat-specialize.h | 7 ----- fpu/softfloat.c | 62 -------------------------------------------- fpu/softfloat.h | 47 --------------------------------- 4 files changed, 0 insertions(+), 118 deletions(-)
cpu-all.h +0 -2
@@ -137,7 +137,6 @@ typedef union {uint64_t ll; } CPU_DoubleU; -#if defined(FLOATX80) typedef union { floatx80 d; struct {
@@ -145,7 +144,6 @@ typedef union {uint16_t upper; } l; } CPU_LDoubleU; -#endif typedef union { float128 q;
fpu/softfloat-specialize.h +0 -7
@@ -523,8 +523,6 @@ static float64 propagateFloat64NaN( float64 a, float64 b STATUS_PARAM) } } -#ifdef FLOATX80 -/*---------------------------------------------------------------------------- | Returns 1 if the extended double-precision floating-point value `a' is a | quiet NaN; otherwise returns 0. This slightly differs from the same
@@ -681,10 +679,6 @@ static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b STATUS_PARAM) } } -#endif - -#ifdef FLOAT128 -/*---------------------------------------------------------------------------- | Returns 1 if the quadruple-precision floating-point value `a' is a quiet | NaN; otherwise returns 0.
@@ -820,4 +814,3 @@ static float128 propagateFloat128NaN( float128 a, float128 b STATUS_PARAM) } } -#endif
fpu/softfloat.c +0 -62
220 lines not on this page · raw message
fpu/softfloat.h +0 -47
144 lines not on this page · raw message
Signature · 1 line
1.7.5.1
PATCH v2 4/9 softfloat-native: remove
In reply to Aurelien JarnoRemove softfloat-native support, all targets are now using softfloat instead.
--- Makefile.target | 3 +- configure | 2 - cpu-all.h | 5 +- fpu/softfloat-native.c | 540 ------------------------------------------------ fpu/softfloat-native.h | 531 ----------------------------------------------- fpu/softfloat.h | 14 -- 6 files changed, 2 insertions(+), 1093 deletions(-)
Makefile.target +1 -2
@@ -71,8 +71,7 @@ all: $(PROGS) stap # cpu emulator library libobj-y = exec.o translate-all.o cpu-exec.o translate.o libobj-y += tcg/tcg.o -libobj-$(CONFIG_SOFTFLOAT) += fpu/softfloat.o -libobj-$(CONFIG_NOSOFTFLOAT) += fpu/softfloat-native.o +libobj-y += fpu/softfloat.o libobj-y += op_helper.o helper.o ifeq ($(TARGET_BASE_ARCH), i386) libobj-y += cpuid.o
configure +0 -2
@@ -3385,8 +3385,6 @@ if test ! -z "$gdb_xml_files" ; then echo "TARGET_XML_FILES=$list" >> $config_target_mak fi -echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak - if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then echo "TARGET_HAS_BFLT=y" >> $config_target_mak fi
cpu-all.h +1 -4
@@ -123,8 +123,7 @@ typedef union {endian ! */ typedef union { float64 d; -#if defined(HOST_WORDS_BIGENDIAN) \ - || (defined(__arm__) && !defined(__VFP_FP__) && !defined(CONFIG_SOFTFLOAT)) +#if defined(HOST_WORDS_BIGENDIAN) struct { uint32_t upper; uint32_t lower;
@@ -148,7 +147,6 @@ typedef union { } CPU_LDoubleU;#endif -#if defined(CONFIG_SOFTFLOAT) typedef union { float128 q; #if defined(HOST_WORDS_BIGENDIAN)
@@ -175,7 +173,6 @@ typedef union { } ll;#endif } CPU_QuadU; -#endif /* CPU memory access without any memory or io remapping */
fpu/softfloat-native.c deleted +0 -540
540 lines not on this page · raw message
fpu/softfloat-native.h deleted +0 -531
531 lines not on this page · raw message
fpu/softfloat.h +0 -14
@@ -81,16 +81,9 @@ typedef int64_t int64;| input or output the `floatx80' type will be defined. The same applies to | the `FLOAT128' macro and the quadruple-precision format `float128'. *----------------------------------------------------------------------------*/ -#ifdef CONFIG_SOFTFLOAT /* bit exact soft float support */ #define FLOATX80 #define FLOAT128 -#else -/* native float support */ -#if (defined(__i386__) || defined(__x86_64__)) && !defined(CONFIG_BSD ) -#define FLOATX80 -#endif -#endif /* !CONFIG_SOFTFLOAT */ #define STATUS_PARAM , float_status *status#define STATUS (field) status->field
@@ -106,7 +99,6 @@ enum { float_relation_unordered = 2 }; -#ifdef CONFIG_SOFTFLOAT /*---------------------------------------------------------------------------- | Software IEC/IEEE floating-point types. *----------------------------------------------------------------------------*/
@@ -699,10 +691,4 @@ INLINE int float128_is_any_nan(float128 a)#endif -#else /* CONFIG_SOFTFLOAT */ - -#include "softfloat-native.h" - -#endif /* !CONFIG_SOFTFLOAT */ -#endif /* !SOFTFLOAT_H */
Signature · 1 line
1.7.5.1
PATCH v2 6/9 target-i386: use floatx80 constants in helper_fld*_ST0()
In reply to Aurelien JarnoInstead of using a table which doesn't correspond to anything from physical in the CPU, use directly the constants in helper_fld*_ST0().
--- target-i386/op_helper.c | 27 ++++++++------------------- 1 files changed, 8 insertions(+), 19 deletions(-)
target-i386/op_helper.c +8 -19
@@ -99,17 +99,6 @@ static const uint8_t rclb_table[32] = {#define floatx80_l2e make_floatx80( 0x3fff, 0xb8aa3b295c17f0bcLL )#define floatx80_l2t make_floatx80( 0x4000, 0xd49a784bcd1b8afeLL ) -static const floatx80 f15rk[7 ] = -{ - floatx80_zero, - floatx80_one, - floatx80_pi, - floatx80_lg2, - floatx80_ln2, - floatx80_l2e, - floatx80_l2t, -}; -/* broken thread support */ static spinlock_t global_cpu_lock =SPIN_LOCK_UNLOCKED ;
@@ -3816,42 +3805,42 @@ void helper_fabs_ST0(void)void helper_fld1_ST0 (void ) { -ST0 = f15rk[1 ]; +ST0 = floatx80_one; }void helper_fldl2t_ST0 (void ) { -ST0 = f15rk[6 ]; +ST0 = floatx80_l2t; }void helper_fldl2e_ST0 (void ) { -ST0 = f15rk[5 ]; +ST0 = floatx80_l2e; }void helper_fldpi_ST0 (void ) { -ST0 = f15rk[2 ]; +ST0 = floatx80_pi; }void helper_fldlg2_ST0 (void ) { -ST0 = f15rk[3 ]; +ST0 = floatx80_lg2; }void helper_fldln2_ST0 (void ) { -ST0 = f15rk[4 ]; +ST0 = floatx80_ln2; }void helper_fldz_ST0 (void ) { -ST0 = f15rk[0 ]; +ST0 = floatx80_zero; }void helper_fldz_FT0 (void ) { -FT0 = f15rk[0 ]; +FT0 = floatx80_zero; }uint32_t helper_fnstsw (void )
Signature · 1 line
1.7.5.1
PATCH v2 8/9 target-i386: cleanup helper_fxam_ST0()
In reply to Aurelien JarnoRewrite helper_fxam_ST0() using only softfloat functions.
--- target-i386/op_helper.c | 30 ++++++++++++------------------ 1 files changed, 12 insertions(+), 18 deletions(-)
target-i386/op_helper.c +12 -18
@@ -4241,29 +4241,23 @@ void helper_fcos(void)void helper_fxam_ST0 (void ) { -CPU_LDoubleU temp; -int expdif; - - temp.d =ST0 ; - env->fpus &= (~0x4700 );/* (C3,C2,C1,C0) <-- 0000 */ -if (SIGND (temp)) + +if (floatx80_is_neg (ST0 )) { env->fpus |=0x200 ;/* C1 <-- 1 */ + }/* XXX: test fptags too */ - expdif =EXPD (temp); -if (expdif ==MAXEXPD ) { -if (MANTD (temp) ==0x8000000000000000ULL ) - env->fpus |=0x500 /*Infinity*/ ; -else - env->fpus |=0x100 /*NaN*/ ; - }else if (expdif ==0 ) { -if (MANTD (temp) ==0 ) - env->fpus |=0x4000 /*Zero*/ ; -else - env->fpus |=0x4400 /*Denormal*/ ; +if (floatx80_is_infinity (ST0 )) { + env->fpus |=0x500 ;/* (C3,C2,C0) <-- 011 */ + }else if (floatx80_is_any_nan (ST0 )) { + env->fpus |=0x100 ;/* (C3,C2,C0) <-- 001 */ + }else if (floatx80_is_zero (ST0 )) { + env->fpus |=0x4000 ;/* (C3,C2,C0) <-- 100 */ + }else if (floatx80_is_zero_or_denormal (ST0 )) { + env->fpus |=0x4400 ;/* (C3,C2,C0) <-- 110 */ }else { - env->fpus |=0x400 ; + env->fpus |=0x400 ;/* (C3,C2,C0) <-- 010 */ } }
Signature · 1 line
1.7.5.1
PATCH v2 9/9 target-i386: add support for FPU exceptions
In reply to Aurelien JarnoThis patch adds support for FPU exceptions. It keeps the exception in the softfloat status, and copy them back to env->fpus when needed by oring them. When loading a new value to env->fpus, it starts with a clean softfloat status.
--- target-i386/cpu.h | 15 +++++++++++++++ target-i386/exec.h | 12 ------------ target-i386/helper.c | 36 ++++++++++++++++++++++++++++++++++++ target-i386/machine.c | 3 ++- target-i386/op_helper.c | 32 ++++++++++++++++---------------- 5 files changed, 69 insertions(+), 29 deletions(-)
target-i386/cpu.h +15 -0
@@ -121,6 +121,19 @@#define VIP_MASK 0x00100000#define ID_MASK 0x00200000 +/* FPU flags */ +#define FPUS_IE (1 << 0) +#define FPUS_DE (1 << 1) +#define FPUS_ZE (1 << 2) +#define FPUS_OE (1 << 3) +#define FPUS_UE (1 << 4) +#define FPUS_PE (1 << 5) +#define FPUS_SF (1 << 6) +#define FPUS_SE (1 << 7) +#define FPUS_B (1 << 15) + +#define FPUC_EM 0x3f +/* hidden flags - used internally by qemu to represent additional cpu states. Only the CPL, INHIBIT_IRQ, SMM and SVMI are not redundant. We avoid using the IOPL_MASK, TF_MASK and VM_MASK bit
@@ -877,6 +890,8 @@ void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);/* helper.c */ +void cpu_x86_set_fpus (CPUX86State *s,uint16_t val); +void cpu_x86_update_fpus (CPUX86State *s);int cpu_x86_handle_mmu_fault (CPUX86State *env,target_ulong addr,int is_write,int mmu_idx,int is_softmmu);#define cpu_handle_mmu_fault cpu_x86_handle_mmu_fault
target-i386/exec.h +0 -12
@@ -144,18 +144,6 @@ static inline void helper_fstt(floatx80 f, target_ulong ptr)stw (ptr +8 , temp.l.upper); } -#define FPUS_IE (1 << 0) -#define FPUS_DE (1 << 1) -#define FPUS_ZE (1 << 2) -#define FPUS_OE (1 << 3) -#define FPUS_UE (1 << 4) -#define FPUS_PE (1 << 5) -#define FPUS_SF (1 << 6) -#define FPUS_SE (1 << 7) -#define FPUS_B (1 << 15) - -#define FPUC_EM 0x3f -static inline uint32_t compute_eflags (void ) {return env->eflags |helper_cc_compute_all (CC_OP ) | (DF &DF_MASK );
target-i386/helper.c +36 -0
@@ -396,6 +396,7 @@ void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,for (i =0 ; i <8 ; i++) { fptag |= ((!env->fptags[i]) << i); } +cpu_x86_update_fpus (env); cpu_fprintf(f, "FCW=%04x FSW=%04x [ST=%d] FTW=%02x MXCSR=%08x\n", env->fpuc, (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11,
@@ -1238,6 +1239,41 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,return 1 ; } +void cpu_x86_set_fpus (CPUX86State *s,uint16_t val) +{ +set_float_exception_flags (0 , &s->fp_status); + s->fpus = val; +} + +void cpu_x86_update_fpus (CPUX86State *s) +{ +int xcpt =get_float_exception_flags (&s->fp_status); + +if (xcpt) { +if (xcpt & float_flag_invalid) { + s->fpus |=FPUS_IE ; + } +if (xcpt & float_flag_input_denormal) { + s->fpus |=FPUS_DE ; + } +if (xcpt & float_flag_divbyzero) { + s->fpus |=FPUS_ZE ; + } +if (xcpt & float_flag_overflow) { + s->fpus |=FPUS_OE ; + } +if (xcpt & float_flag_underflow) { + s->fpus |=FPUS_UE ; + } +if (xcpt & float_flag_inexact) { + s->fpus |=FPUS_PE ; + } +if (s->fpus & (~s->fpuc &FPUC_EM )) { + s->fpus |=FPUS_SE |FPUS_B ; + } + } +} +CPUX86State *cpu_x86_init (const char *cpu_model) {CPUX86State *env;
target-i386/machine.c +2 -1
@@ -241,6 +241,7 @@ static void cpu_pre_save(void *opaque)int i;/* FPU */ +cpu_x86_update_fpus (env); env->fpus_vmstate = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ; env->fptag_vmstate =0 ;for (i =0 ; i <8 ; i++) {
@@ -257,7 +258,7 @@ static int cpu_post_load(void *opaque, int version_id)/* XXX: restore FPU round state */ env->fpstt = (env->fpus_vmstate >>11 ) &7 ; - env->fpus = env->fpus_vmstate & ~0x3800 ; +cpu_x86_set_fpus (env, env->fpus_vmstate & ~0x3800 ); env->fptag_vmstate ^=0xff ;for (i =0 ; i <8 ; i++) { env->fptags[i] = (env->fptag_vmstate >> i) &1 ;
target-i386/op_helper.c +16 -16
@@ -3447,18 +3447,8 @@ static inline floatx80 double_to_floatx80(double a)return float64_to_floatx80 (u.f64, &env->fp_status); } -static void fpu_set_exception (int mask) -{ - env->fpus |= mask; -if (env->fpus & (~env->fpuc &FPUC_EM )) - env->fpus |=FPUS_SE |FPUS_B ; -} -static inline floatx80 helper_fdiv (floatx80 a,floatx80 b) { -if (floatx80_is_zero (b)) { -fpu_set_exception (FPUS_ZE ); - }return floatx80_div (a, b, &env->fp_status); }
@@ -3845,6 +3835,7 @@ void helper_fldz_FT0(void)uint32_t helper_fnstsw (void ) { +cpu_x86_update_fpus (env);return (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ; }
@@ -3897,18 +3888,19 @@ void helper_fldcw(uint32_t val)void helper_fclex (void ) { - env->fpus &=0x7f00 ; +cpu_x86_set_fpus (env, env->fpus &0x7f00 ); }void helper_fwait (void ) { +cpu_x86_update_fpus (env);if (env->fpus &FPUS_SE )fpu_raise_exception (); }void helper_fninit (void ) { - env->fpus =0 ; +cpu_x86_set_fpus (env,0 ); env->fpstt =0 ; env->fpuc =0x37f ; env->fptags[0 ] =1 ;
@@ -4208,7 +4200,13 @@ void helper_fscale(void)if (floatx80_is_any_nan (ST1 )) {ST0 =ST1 ; }else { -int n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status); +int n, x; + +/* The float to int conversion should not generate any exception. */ + x =get_float_exception_flags (&env->fp_status); + n =floatx80_to_int32_round_to_zero (ST1 , &env->fp_status); +set_float_exception_flags (x, &env->fp_status); +ST0 =floatx80_scalbn (ST0 , n, &env->fp_status); } }
@@ -4267,6 +4265,7 @@ void helper_fstenv(target_ulong ptr, int data32)uint64_t mant;CPU_LDoubleU tmp; +cpu_x86_update_fpus (env); fpus = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ; fptag =0 ;for (i=7 ; i>=0 ; i--) {
@@ -4324,7 +4323,7 @@ void helper_fldenv(target_ulong ptr, int data32) fptag =lduw (ptr +4 ); } env->fpstt = (fpus >>11 ) &7 ; - env->fpus = fpus & ~0x3800 ; +cpu_x86_set_fpus (env, fpus & ~0x3800 );for (i =0 ;i <8 ; i++) { env->fptags[i] = ((fptag &3 ) ==3 ); fptag >>=2 ;
@@ -4346,7 +4345,7 @@ void helper_fsave(target_ulong ptr, int data32) }/* fninit */ - env->fpus =0 ; +cpu_x86_set_fpus (env,0 ); env->fpstt =0 ; env->fpuc =0x37f ; env->fptags[0 ] =1 ;
@@ -4385,6 +4384,7 @@ void helper_fxsave(target_ulong ptr, int data64)raise_exception (EXCP0D_GPF ); } +cpu_x86_update_fpus (env); fpus = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ; fptag =0 ;for (i =0 ; i <8 ; i++) {
@@ -4450,7 +4450,7 @@ void helper_fxrstor(target_ulong ptr, int data64) fpus =lduw (ptr +2 ); fptag =lduw (ptr +4 ); env->fpstt = (fpus >>11 ) &7 ; - env->fpus = fpus & ~0x3800 ; +cpu_x86_set_fpus (env, fpus & ~0x3800 ); fptag ^=0xff ;for (i =0 ;i <8 ; i++) { env->fptags[i] = ((fptag >> i) &1 );
Signature · 1 line
1.7.5.1
PATCH v2 3/9 target-i386: remove old code handling float64
In reply to Aurelien JarnoNow that target-i386 uses softfloat, floatx80 is always available and there is no need anymore to have code handling both float64 and floax80.
--- target-i386/cpu.h | 22 +--- target-i386/exec.h | 132 +----------------------- target-i386/helper.c | 5 - target-i386/machine.c | 101 ------------------ target-i386/op_helper.c | 266 +++++++++++++++++++---------------------------- 5 files changed, 115 insertions(+), 411 deletions(-)
target-i386/cpu.h +4 -18
@@ -532,16 +532,6 @@ enum { CC_OP_NB, }; -#ifdef FLOATX80 -#define USE_X86LDOUBLE -#endif - -#ifdef USE_X86LDOUBLE -typedef floatx80 CPU86_LDouble ; -#else -typedef float64 CPU86_LDouble ; -#endif - typedef struct SegmentCache { uint32_t selector; target_ulong base;
@@ -594,11 +584,7 @@ typedef union {#define MMX_Q (n) qtypedef union { -#ifdef USE_X86LDOUBLE -CPU86_LDouble d __attribute__((aligned (16 ))); -#else -CPU86_LDouble d; -#endif +floatx80 d __attribute__((aligned (16 )));MMXReg mmx; }FPReg ;
@@ -654,7 +640,7 @@ typedef struct CPUX86State {/* emulator internal variables */ float_status fp_status; -CPU86_LDouble ft0; +floatx80 ft0;float_status mmx_status;/* for 3DNow! float ops */ float_status sse_status;
@@ -865,8 +851,8 @@ static inline void cpu_x86_set_cpl(CPUX86State *s, int cpl)/* op_helper.c */ /* used for debug or cpu save/restore */ -void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,CPU86_LDouble f); -CPU86_LDouble cpu_set_fp80 (uint64_t mant,uint16_t upper); +void cpu_get_fp80 (uint64_t *pmant,uint16_t *pexp,floatx80 f); +floatx80 cpu_set_fp80 (uint64_t mant,uint16_t upper);/* cpu-exec.c */ /* the following helpers are only usable in user mode simulation as
target-i386/exec.h +4 -128
170 lines not on this page · raw message
target-i386/helper.c +0 -5
@@ -403,15 +403,10 @@ void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf, fptag, env->mxcsr);for (i=0 ;i<8 ;i++) { -#if defined(USE_X86LDOUBLE )CPU_LDoubleU u; u.d = env->fpregs[i].d;cpu_fprintf (f,"FPR%d=%016" PRIx64" %04x" , i, u.l.lower, u.l.upper); -#else -cpu_fprintf (f,"FPR%d=%016" PRIx64, - i, env->fpregs[i].mmx.q); -#endif if ((i &1 ) ==1 )cpu_fprintf (f,"\n" );else
target-i386/machine.c +0 -101
120 lines not on this page · raw message
target-i386/op_helper.c +107 -159
712 lines not on this page · raw message
Signature · 1 line
1.7.5.1
PATCH v2 7/9 softfloat: add float*_is_zero_or_denormal()
In reply to Aurelien Jarnofloat*_is_zero_or_denormal() is available for float32, but not for float64, floatx80 and float128. Fix that.
--- fpu/softfloat.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
fpu/softfloat.h +15 -0
@@ -449,6 +449,11 @@ INLINE int float64_is_any_nan(float64 a)return ((float64_val (a) & ~(1ULL <<63 )) >0x7ff0000000000000ULL ); } +INLINE int float64_is_zero_or_denormal(float64 a) +{ +return (float64_val (a) &0x7ff0000000000000LL ) ==0 ; +} + INLINE float64 float64_set_sign(float64 a, int sign) { return make_float64((float64_val(a) & 0x7fffffffffffffffULL)
@@ -538,6 +543,11 @@ INLINE int floatx80_is_zero(floatx80 a)return (a.high &0x7fff ) ==0 && a.low ==0 ; } +INLINE int floatx80_is_zero_or_denormal(floatx80 a) +{ +return (a.high &0x7fff ) ==0 ; +} + INLINE int floatx80_is_any_nan(floatx80 a) {return ((a.high &0x7fff ) ==0x7fff ) && (a.low<<1 );
@@ -626,6 +636,11 @@ INLINE int float128_is_zero(float128 a)return (a.high &0x7fffffffffffffffLL ) ==0 && a.low ==0 ; } +INLINE int float128_is_zero_or_denormal(float128 a) +{ +return (a.high &0x7fff000000000000LL ) ==0 ; +} + INLINE int float128_is_any_nan(float128 a) { return ((a.high >> 48) & 0x7fff) == 0x7fff &&
Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH v2 8/9] target-i386: cleanup helper_fxam_ST0()
In reply to Aurelien JarnoQuoted 3 lines · Aurelien Jarno
Rewrite
helper_fxam_ST0()using only softfloat functions.Signed-off-by Aurelien Jarno <[email protected]>
(Sorry I didn't get round to this one earlier; I think I did the easy patches and stalled on the ones I'd have to pull out the x86 manuals for :-))
Quoted 1 line
/* XXX: test fptags too */
You could fix this XXX while you were here; it's just adding
if (env->fptags[env->fpstt]) {
env->fpus |= 0x4100; /* (C3,C2,C0) <-- 101 */
} else ...to the top of the ladder, right?
(Catching the "Unsupported" case would be slightly more tedious, we'd need to identify all the floatx80 weirdo bitpatterns as per the table in the architecture manual. Could use a FIXME/XXX comment on that account, maybe.)
Quoted 16 lines
- expdif = EXPD(temp);
- if (expdif == MAXEXPD) {
- if (MANTD(temp) ==0x8000000000000000ULL)
- env->fpus |= 0x500 /*Infinity*/;
- else
- env->fpus |= 0x100 /*NaN*/;
- } else if (expdif == 0) {
- if (MANTD(temp) == 0)
- env->fpus |= 0x4000 /*Zero*/;
- else
- env->fpus |=0x4400/*Denormal*/;
+ if (floatx80_is_infinity(ST0)) {
+ env->fpus |= 0x500; /* (C3,C2,C0) <-- 011 */
+ } else if (floatx80_is_any_nan(ST0)) {
+ env->fpus |= 0x100; /* (C3,C2,C0) <-- 001 */
+ } else if (floatx80_is_zero(ST0)) {
Quoted 8 lines
+ env->fpus |=
0x4000; /* (C3,C2,C0) <-- 100 */
+ } else if (floatx80_is_zero_or_denormal(ST0)) {
+ env->fpus |=0x4400; /* (C3,C2,C0) <-- 110 */ } else {
- env->fpus |=0x400;
+ env->fpus |= 0x400; /* (C3,C2,C0) <-- 010 */ }
}
This all looks right. The C0/C1/C2/C3 bits seem to get enough use in this and other functions to merit FPUS_* constants, although that should probably be a different patch.
There's also code in helper_fstenv() which is currently doing manual identification of zero/NaN/inf/denorm.
-- PMM
Re: [Qemu-devel] [PATCH v2 2/9] target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef
In reply to Aurelien JarnoQuoted 4 lines · Aurelien Jarno
target-mips has been switched to softfloat only long ago, but a #ifndef
CONFIG_SOFTFLOAThas been forgotten. Remove it.Signed-off-by Aurelien Jarno <[email protected]>
Re: [Qemu-devel] [PATCH v2 6/9] target-i386: use floatx80 constants in helper_fld*_ST0()
In reply to Aurelien JarnoQuoted 5 lines · Aurelien Jarno
Instead of using a table which doesn't correspond to anything from physical in the CPU, use directly the constants in helper_fld*_ST0().
Cc Andreas Färber <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
Re: [Qemu-devel] [PATCH v2 3/9] target-i386: remove old code handling float64
In reply to Aurelien JarnoQuoted 4 lines · Aurelien Jarno
Now that target-i386 uses softfloat, floatx80 is always available and there is no need anymore to have code handling both float64 and floax80.
Signed-off-by Aurelien Jarno <[email protected]>
Re: [Qemu-devel] [PATCH v2 9/9] target-i386: add support for FPU exceptions
In reply to Aurelien JarnoQuoted 6 lines · Aurelien Jarno
This patch adds support for FPU exceptions. It keeps the exception in the softfloat status, and copy them back to
env->fpuswhen needed by oring them. When loading a new value toenv->fpus, it starts with a clean softfloat status.Signed-off-by Aurelien Jarno <[email protected]>
gdbstub.c still looks at env->fpus directly without calling cpu_x86_update_fpus() first; it should probably go through helper_fnstsw() now (or if you like a utility function that does what helper_fnstsw() does now).
Similarly the code in helper_fstenv() and cpu_pre_save() that does:
cpu_x86_update_fpus(env);
SOMETHING = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;could be usefully abstracted away into a call to this utility fn.
For the rest, it looks OK, but the cpu_x86_update_fpus() and cpu_x86_set_fpus() functions feel a bit like they're only half an abstraction layer -- so sometimes it's OK to tweak env->fpus directly and sometimes you need to use the functions. That means it's tricky to tell from eyeballing or grepping the code whether an update_fpus() call got missed out. Maybe it would be better to have a set of functions such that you could mandate that all env->fpus accesses went via the functions?
A random nitpick:
Quoted 5 lines
target-i386/op_helper.c +0
-1@@ -4208,7 +4200,13 @@ void helper_fscale(void) if (floatx80_is_any_nan(ST1)) { ST0 = ST1; } else { - int n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status);
target-i386/op_helper.c void helper_fscale(void) · line 4212
Quoted 10 lines
target-i386/op_helper.c +7
-0+ int n, x; + + /* The float to int conversion should not generate any exception. */ + x = get_float_exception_flags(&env->fp_status); + n = floatx80_to_int32_round_to_zero(ST1, &env->fp_status); + set_float_exception_flags(x, &env->fp_status); + ST0 = floatx80_scalbn(ST0, n, &env->fp_status); } }
...doesn't this mean you won't set the #D flag if ST1 is denormal?
I'm unconvinced about scalbn as a softfloat primitive. It gets used:
* by ARM for the VCVT fixed-point conversions, as a combination of scalbn + float-to-int or int-to-float + scalbn
* by PPC for the same reason (vctuxs, vctsxs, vcfux, vcfsx)
* by x86 here as a float-to-int + scalbn, for FSCALE
and I think that in all three cases the attempt to implement a floating point op by composing two softfloat primitives causes problems with getting the floating point exception flags right. (In the fixedpoint conversion case the issue is that for instance if the input is a negative number we should only set InvalidOp but the scalbn is likely to result in our also setting Inexact. But if you don't let the scalbn set any flags at all then you have to special case when the input is a NaN or denormal, which is equally awkward.)
-- PMM
Re: [Qemu-devel] [PATCH v2 6/9] target-i386: use floatx80 constants in helper_fld*_ST0()
In reply to Aurelien JarnoAm 23.05.2011 um 23:42 schrieb Aurelien Jarno:
Quoted 5 lines
Instead of using a table which doesn't correspond to anything from physical in the CPU, use directly the constants in helper_fld*_ST0().
Cc Andreas Färber <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
I'm still wondering *why* the table doesn't work though... cf. reply to Peter. I'll try some simplified sample code.
Andreas
Quoted 81 lines
---
target-i386/op_helper.c| 27 ++++++++-------------------1 files changed, 8 insertions(+), 19 deletions(-)target-i386/op_helper.c +8
-19@@ -99,17 +99,6 @@ static const uint8_t rclb_table[32] = {#define floatx80_l2e make_floatx80( 0x3fff, 0xb8aa3b295c17f0bcLL )#define floatx80_l2t make_floatx80( 0x4000, 0xd49a784bcd1b8afeLL ) -static const floatx80 f15rk[7 ] = -{ - floatx80_zero, - floatx80_one, - floatx80_pi, - floatx80_lg2, - floatx80_ln2, - floatx80_l2e, - floatx80_l2t, -}; -/* broken thread support */ static spinlock_t global_cpu_lock =SPIN_LOCK_UNLOCKED ;@@ -3816,42 +3805,42 @@ void helper_fabs_ST0(void)void helper_fld1_ST0 (void ) { -ST0 = f15rk[1 ]; +ST0 = floatx80_one; }void helper_fldl2t_ST0 (void ) { -ST0 = f15rk[6 ]; +ST0 = floatx80_l2t; }void helper_fldl2e_ST0 (void ) { -ST0 = f15rk[5 ]; +ST0 = floatx80_l2e; }void helper_fldpi_ST0 (void ) { -ST0 = f15rk[2 ]; +ST0 = floatx80_pi; }void helper_fldlg2_ST0 (void ) { -ST0 = f15rk[3 ]; +ST0 = floatx80_lg2; }void helper_fldln2_ST0 (void ) { -ST0 = f15rk[4 ]; +ST0 = floatx80_ln2; }void helper_fldz_ST0 (void ) { -ST0 = f15rk[0 ]; +ST0 = floatx80_zero; }void helper_fldz_FT0 (void ) { -FT0 = f15rk[0 ]; +FT0 = floatx80_zero; }uint32_t helper_fnstsw (void )Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH v2 1/9] target-ppc: remove old CONFIG_SOFTFLOAT #ifdef
In reply to Aurelien JarnoAm 23.05.2011 um 23:42 schrieb Aurelien Jarno:
Quoted 6 lines
target-ppc has been switched to softfloat only long ago, but a few #ifdef
CONFIG_SOFTFLOAThave been forgotten. Remove them.Cc Alexander Graf <[email protected]>Reviewed-by Peter Maydell <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
Only removes now-useless #ifdefs and dead code. The dead code in helper_float_check_status() differs from the softfloat code path in that the softfloat path also evaluations the softfloat status and calls some exception helpers. So we're not losing anything.
Quoted 76 lines
---
target-ppc/helper.h | 2 -- target-ppc/op_helper.c | 11 ----------- target-ppc/translate.c | 2 -- 3 files changed, 0 insertions(+), 15 deletions(-)target-ppc/helper.h +0
-2@@ -51,9 +51,7 @@ DEF_HELPER_FLAGS_1(cntlzw32, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32) DEF_HELPER_FLAGS_2(brinc, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) DEF_HELPER_0(float_check_status, void) -#ifdef CONFIG_SOFTFLOAT DEF_HELPER_0(reset_fpstatus, void) -#endif DEF_HELPER_2(compute_fprf, i32, i64, i32)DEF_HELPER_2 (store_fpscr, void, i64, i32)
DEF_HELPER_1(fpscr_clrbit, void, i32)target-ppc/op_helper.c +0
-1@@ -971,7 +971,6 @@ void helper_store_fpscr (uint64_t arg, uint32_t mask)void helper_float_check_status (void ) { -#ifdef CONFIG_SOFTFLOAT if (env->exception_index ==POWERPC_EXCP_PROGRAM && (env->error_code &POWERPC_EXCP_FP )) {/* Differred floating-point exception after target FPRupdate */
target-ppc/op_helper.c +0
-4@@ -989,22 +988,12 @@ void helper_float_check_status (void)float_inexact_excp (); } } -#else -if (env->exception_index ==POWERPC_EXCP_PROGRAM && - (env->error_code &POWERPC_EXCP_FP )) { -/* Differred floating-point exception after target FPR update */
target-ppc/op_helper.c +0
-2-if (msr_fe0 !=0 || msr_fe1 !=0 ) - helper_raise_exception_err(env->exception_index, env-Quoted 1 line
error_code);target-ppc/op_helper.c +0
-2- } -#endif }
-#ifdef
CONFIG_SOFTFLOAT
voidhelper_reset_fpstatus(void){ set_float_exception_flags(0, &env->fp_status); }-#endif
/* fadd - fadd. */
uint64_thelper_fadd(uint64_targ1,uint64_targ2)target-ppc/translate.c +0
-2@@ -215,9 +215,7 @@ struct opc_handler_t {static inline void gen_reset_fpstatus (void ) { -#ifdef CONFIG_SOFTFLOAT gen_helper_reset_fpstatus (); -#endif }static inline void gen_compute_fprf (TCGv_i64 arg,int set_fprf,int set_rc)Signature · 1 line
1.7.5.1
Re: [Qemu-devel] [PATCH v2 2/9] target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef
In reply to Aurelien JarnoAm 23.05.2011 um 23:42 schrieb Aurelien Jarno:
Quoted 4 lines
target-mips has been switched to softfloat only long ago, but a #ifndef
CONFIG_SOFTFLOAThas been forgotten. Remove it.Signed-off-by Aurelien Jarno <[email protected]>
Quoted 22 lines
---
gdbstub.c| 4 ----1 files changed, 0 insertions(+), 4 deletions(-)gdbstub.c +0
-4@@ -1105,10 +1105,6 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n) env->active_fpu.fcr31 = tmp &0xFF83FFFF ;/* set rounding mode */ RESTORE_ROUNDING_MODE ; -#ifndef CONFIG_SOFTFLOAT -/* no floating point exception for native float */ -SET_FP_ENABLE (env->active_fpu.fcr31,0 ); -#endif break ;case 71 : env->active_fpu.fcr0 = tmp;break ;}Signature · 1 line
1.7.5.1