diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-03-13 17:01:47 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-03-13 17:01:47 +0000 |
commit | 7a0e1f41ceeb658791a1456ffc7f8f9edca7da19 (patch) | |
tree | eab50fb37085ad2dc6e8aa283f334defd538fa8c /target-i386 | |
parent | 4ecc31906d7535c4ad88fcc63968bef412dd67ba (diff) | |
download | hqemu-7a0e1f41ceeb658791a1456ffc7f8f9edca7da19.zip hqemu-7a0e1f41ceeb658791a1456ffc7f8f9edca7da19.tar.gz |
soft float support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1336 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-i386')
-rw-r--r-- | target-i386/cpu.h | 14 | ||||
-rw-r--r-- | target-i386/exec.h | 70 | ||||
-rw-r--r-- | target-i386/helper.c | 78 | ||||
-rw-r--r-- | target-i386/op.c | 49 | ||||
-rw-r--r-- | target-i386/ops_sse.h | 126 |
5 files changed, 126 insertions, 211 deletions
diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 154d8bf..ce65c34 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -36,6 +36,8 @@ #include "cpu-defs.h" +#include "softfloat.h" + #if defined(__i386__) && !defined(CONFIG_SOFTMMU) #define USE_CODE_COPY #endif @@ -332,14 +334,14 @@ enum { CC_OP_NB, }; -#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD) +#ifdef FLOATX80 #define USE_X86LDOUBLE #endif #ifdef USE_X86LDOUBLE -typedef long double CPU86_LDouble; +typedef floatx80 CPU86_LDouble; #else -typedef double CPU86_LDouble; +typedef float64 CPU86_LDouble; #endif typedef struct SegmentCache { @@ -354,8 +356,8 @@ typedef union { uint16_t _w[8]; uint32_t _l[4]; uint64_t _q[2]; - float _s[4]; - double _d[2]; + float32 _s[4]; + float64 _d[2]; } XMMReg; typedef union { @@ -441,6 +443,7 @@ typedef struct CPUX86State { } fpregs[8]; /* emulator internal variables */ + float_status fp_status; CPU86_LDouble ft0; union { float f; @@ -449,6 +452,7 @@ typedef struct CPUX86State { int64_t i64; } fp_convert; + float_status sse_status; uint32_t mxcsr; XMMReg xmm_regs[CPU_NB_REGS]; XMMReg xmm_t0; diff --git a/target-i386/exec.h b/target-i386/exec.h index c4e59c4..137774f 100644 --- a/target-i386/exec.h +++ b/target-i386/exec.h @@ -139,44 +139,6 @@ extern int loglevel; #include "cpu.h" #include "exec-all.h" -/* XXX: add a generic FPU library */ - -static inline double float32_to_float64(float a) -{ - return a; -} - -static inline float float64_to_float32(double a) -{ - return a; -} - -#if defined(__powerpc__) -/* better to call an helper on ppc */ -float int32_to_float32(int32_t a); -double int32_to_float64(int32_t a); -#else -static inline float int32_to_float32(int32_t a) -{ - return (float)a; -} - -static inline double int32_to_float64(int32_t a) -{ - return (double)a; -} -#endif - -static inline float int64_to_float32(int64_t a) -{ - return (float)a; -} - -static inline double int64_to_float64(int64_t a) -{ - return (double)a; -} - typedef struct CCTable { int (*compute_all)(void); /* return all the flags */ int (*compute_c)(void); /* return the C flag */ @@ -358,9 +320,11 @@ static inline void stfl(target_ulong ptr, float v) #ifdef USE_X86LDOUBLE /* use long double functions */ -#define lrint lrintl -#define llrint llrintl -#define fabs fabsl +#define floatx_to_int32 floatx80_to_int32 +#define floatx_to_int64 floatx80_to_int64 +#define floatx_abs floatx80_abs +#define floatx_chs floatx80_chs +#define floatx_round_to_int floatx80_round_to_int #define sin sinl #define cos cosl #define sqrt sqrtl @@ -370,17 +334,14 @@ static inline void stfl(target_ulong ptr, float v) #define atan2 atan2l #define floor floorl #define ceil ceill -#define rint rintl -#endif - -#if !defined(_BSD) -extern int lrint(CPU86_LDouble x); -extern int64_t llrint(CPU86_LDouble x); #else -#define lrint(d) ((int)rint(d)) -#define llrint(d) ((int)rint(d)) +#define floatx_to_int32 float64_to_int32 +#define floatx_to_int64 float64_to_int64 +#define floatx_abs float64_abs +#define floatx_chs float64_chs +#define floatx_round_to_int float64_round_to_int #endif -extern CPU86_LDouble fabs(CPU86_LDouble x); + extern CPU86_LDouble sin(CPU86_LDouble x); extern CPU86_LDouble cos(CPU86_LDouble x); extern CPU86_LDouble sqrt(CPU86_LDouble x); @@ -390,7 +351,6 @@ extern CPU86_LDouble tan(CPU86_LDouble x); extern CPU86_LDouble atan2(CPU86_LDouble, CPU86_LDouble); extern CPU86_LDouble floor(CPU86_LDouble x); extern CPU86_LDouble ceil(CPU86_LDouble x); -extern CPU86_LDouble rint(CPU86_LDouble x); #define RC_MASK 0xc00 #define RC_NEAR 0x000 @@ -400,13 +360,6 @@ extern CPU86_LDouble rint(CPU86_LDouble x); #define MAXTAN 9223372036854775808.0 -#ifdef __arm__ -/* we have no way to do correct rounding - a FPU emulator is needed */ -#define FE_DOWNWARD FE_TONEAREST -#define FE_UPWARD FE_TONEAREST -#define FE_TOWARDZERO FE_TONEAREST -#endif - #ifdef USE_X86LDOUBLE /* only for x86 */ @@ -596,6 +549,7 @@ float approx_rsqrt(float a); float approx_rcp(float a); double helper_sqrt(double a); int fpu_isnan(double a); +void update_fp_status(void); extern const uint8_t parity_table[256]; extern const uint8_t rclw_table[32]; diff --git a/target-i386/helper.c b/target-i386/helper.c index 53b85d3..64cb51a 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -2541,13 +2541,11 @@ void helper_fbld_ST0_A0(void) void helper_fbst_ST0_A0(void) { - CPU86_LDouble tmp; int v; target_ulong mem_ref, mem_end; int64_t val; - tmp = rint(ST0); - val = (int64_t)tmp; + val = floatx_to_int64(ST0, &env->fp_status); mem_ref = A0; mem_end = mem_ref + 9; if (val < 0) { @@ -2740,29 +2738,7 @@ void helper_fsincos(void) void helper_frndint(void) { - CPU86_LDouble a; - - a = ST0; -#ifdef __arm__ - switch(env->fpuc & RC_MASK) { - default: - case RC_NEAR: - asm("rndd %0, %1" : "=f" (a) : "f"(a)); - break; - case RC_DOWN: - asm("rnddm %0, %1" : "=f" (a) : "f"(a)); - break; - case RC_UP: - asm("rnddp %0, %1" : "=f" (a) : "f"(a)); - break; - case RC_CHOP: - asm("rnddz %0, %1" : "=f" (a) : "f"(a)); - break; - } -#else - a = rint(a); -#endif - ST0 = a; + ST0 = floatx_round_to_int(ST0, &env->fp_status); } void helper_fscale(void) @@ -3263,25 +3239,43 @@ float approx_rcp(float a) return 1.0 / a; } -/* XXX: find a better solution */ -double helper_sqrt(double a) +void update_fp_status(void) { - return sqrt(a); -} + int rnd_type; -/* XXX: move that to another file */ -#if defined(__powerpc__) -/* better to call an helper on ppc */ -float int32_to_float32(int32_t a) -{ - return (float)a; -} - -double int32_to_float64(int32_t a) -{ - return (double)a; -} + /* set rounding mode */ + switch(env->fpuc & RC_MASK) { + default: + case RC_NEAR: + rnd_type = float_round_nearest_even; + break; + case RC_DOWN: + rnd_type = float_round_down; + break; + case RC_UP: + rnd_type = float_round_up; + break; + case RC_CHOP: + rnd_type = float_round_to_zero; + break; + } + set_float_rounding_mode(rnd_type, &env->fp_status); +#ifdef FLOATX80 + switch((env->fpuc >> 8) & 3) { + case 0: + rnd_type = 32; + break; + case 2: + rnd_type = 64; + break; + case 3: + default: + rnd_type = 80; + break; + } + set_floatx80_rounding_precision(rnd_type, &env->fp_status); #endif +} #if !defined(CONFIG_USER_ONLY) diff --git a/target-i386/op.c b/target-i386/op.c index dc0dcea..bbc2b19 100644 --- a/target-i386/op.c +++ b/target-i386/op.c @@ -1598,26 +1598,6 @@ CCTable cc_table[CC_OP_NB] = { functions comes from the LGPL'ed x86 emulator found in the Willows TWIN windows emulator. */ -#if defined(__powerpc__) -extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble); - -/* correct (but slow) PowerPC rint() (glibc version is incorrect) */ -double qemu_rint(double x) -{ - double y = 4503599627370496.0; - if (fabs(x) >= y) - return x; - if (x < 0) - y = -y; - y = (x + y) - y; - if (y == 0.0) - y = copysign(y, x); - return y; -} - -#define rint qemu_rint -#endif - /* fp load FT0 */ void OPPROTO op_flds_FT0_A0(void) @@ -1866,7 +1846,7 @@ void OPPROTO op_fist_ST0_A0(void) int val; d = ST0; - val = lrint(d); + val = floatx_to_int32(d, &env->fp_status); if (val != (int16_t)val) val = -32768; stw(A0, val); @@ -1883,7 +1863,7 @@ void OPPROTO op_fistl_ST0_A0(void) int val; d = ST0; - val = lrint(d); + val = floatx_to_int32(d, &env->fp_status); stl(A0, val); FORCE_RET(); } @@ -1898,7 +1878,7 @@ void OPPROTO op_fistll_ST0_A0(void) int64_t val; d = ST0; - val = llrint(d); + val = floatx_to_int64(d, &env->fp_status); stq(A0, val); FORCE_RET(); } @@ -2101,12 +2081,12 @@ void OPPROTO op_fdivr_STN_ST0(void) /* misc FPU operations */ void OPPROTO op_fchs_ST0(void) { - ST0 = -ST0; + ST0 = floatx_chs(ST0); } void OPPROTO op_fabs_ST0(void) { - ST0 = fabs(ST0); + ST0 = floatx_abs(ST0); } void OPPROTO op_fxam_ST0(void) @@ -2251,25 +2231,8 @@ void OPPROTO op_fnstcw_A0(void) void OPPROTO op_fldcw_A0(void) { - int rnd_type; env->fpuc = lduw(A0); - /* set rounding mode */ - switch(env->fpuc & RC_MASK) { - default: - case RC_NEAR: - rnd_type = FE_TONEAREST; - break; - case RC_DOWN: - rnd_type = FE_DOWNWARD; - break; - case RC_UP: - rnd_type = FE_UPWARD; - break; - case RC_CHOP: - rnd_type = FE_TOWARDZERO; - break; - } - fesetround(rnd_type); + update_fp_status(); } void OPPROTO op_fclex(void) diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h index 8472a34..be1d68b 100644 --- a/target-i386/ops_sse.h +++ b/target-i386/ops_sse.h @@ -654,10 +654,10 @@ void OPPROTO op_ ## name ## ps (void)\ Reg *d, *s;\ d = (Reg *)((char *)env + PARAM1);\ s = (Reg *)((char *)env + PARAM2);\ - d->XMM_S(0) = F(d->XMM_S(0), s->XMM_S(0));\ - d->XMM_S(1) = F(d->XMM_S(1), s->XMM_S(1));\ - d->XMM_S(2) = F(d->XMM_S(2), s->XMM_S(2));\ - d->XMM_S(3) = F(d->XMM_S(3), s->XMM_S(3));\ + d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ + d->XMM_S(1) = F(32, d->XMM_S(1), s->XMM_S(1));\ + d->XMM_S(2) = F(32, d->XMM_S(2), s->XMM_S(2));\ + d->XMM_S(3) = F(32, d->XMM_S(3), s->XMM_S(3));\ }\ \ void OPPROTO op_ ## name ## ss (void)\ @@ -665,15 +665,15 @@ void OPPROTO op_ ## name ## ss (void)\ Reg *d, *s;\ d = (Reg *)((char *)env + PARAM1);\ s = (Reg *)((char *)env + PARAM2);\ - d->XMM_S(0) = F(d->XMM_S(0), s->XMM_S(0));\ + d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ }\ void OPPROTO op_ ## name ## pd (void)\ {\ Reg *d, *s;\ d = (Reg *)((char *)env + PARAM1);\ s = (Reg *)((char *)env + PARAM2);\ - d->XMM_D(0) = F(d->XMM_D(0), s->XMM_D(0));\ - d->XMM_D(1) = F(d->XMM_D(1), s->XMM_D(1));\ + d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ + d->XMM_D(1) = F(64, d->XMM_D(1), s->XMM_D(1));\ }\ \ void OPPROTO op_ ## name ## sd (void)\ @@ -681,16 +681,16 @@ void OPPROTO op_ ## name ## sd (void)\ Reg *d, *s;\ d = (Reg *)((char *)env + PARAM1);\ s = (Reg *)((char *)env + PARAM2);\ - d->XMM_D(0) = F(d->XMM_D(0), s->XMM_D(0));\ + d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ } -#define FPU_ADD(a, b) (a) + (b) -#define FPU_SUB(a, b) (a) - (b) -#define FPU_MUL(a, b) (a) * (b) -#define FPU_DIV(a, b) (a) / (b) -#define FPU_MIN(a, b) (a) < (b) ? (a) : (b) -#define FPU_MAX(a, b) (a) > (b) ? (a) : (b) -#define FPU_SQRT(a, b) helper_sqrt(b) +#define FPU_ADD(size, a, b) float ## size ## _add(a, b, &env->sse_status) +#define FPU_SUB(size, a, b) float ## size ## _sub(a, b, &env->sse_status) +#define FPU_MUL(size, a, b) float ## size ## _mul(a, b, &env->sse_status) +#define FPU_DIV(size, a, b) float ## size ## _div(a, b, &env->sse_status) +#define FPU_MIN(size, a, b) (a) < (b) ? (a) : (b) +#define FPU_MAX(size, a, b) (a) > (b) ? (a) : (b) +#define FPU_SQRT(size, a, b) float ## size ## _sqrt(b, &env->sse_status) SSE_OP_S(add, FPU_ADD) SSE_OP_S(sub, FPU_SUB) @@ -710,8 +710,8 @@ void OPPROTO op_cvtps2pd(void) s = (Reg *)((char *)env + PARAM2); s0 = s->XMM_S(0); s1 = s->XMM_S(1); - d->XMM_D(0) = float32_to_float64(s0); - d->XMM_D(1) = float32_to_float64(s1); + d->XMM_D(0) = float32_to_float64(s0, &env->sse_status); + d->XMM_D(1) = float32_to_float64(s1, &env->sse_status); } void OPPROTO op_cvtpd2ps(void) @@ -719,8 +719,8 @@ void OPPROTO op_cvtpd2ps(void) Reg *d, *s; d = (Reg *)((char *)env + PARAM1); s = (Reg *)((char *)env + PARAM2); - d->XMM_S(0) = float64_to_float32(s->XMM_D(0)); - d->XMM_S(1) = float64_to_float32(s->XMM_D(1)); + d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status); + d->XMM_S(1) = float64_to_float32(s->XMM_D(1), &env->sse_status); d->Q(1) = 0; } @@ -729,7 +729,7 @@ void OPPROTO op_cvtss2sd(void) Reg *d, *s; d = (Reg *)((char *)env + PARAM1); s = (Reg *)((char *)env + PARAM2); - d->XMM_D(0) = float32_to_float64(s->XMM_S(0)); + d->XMM_D(0) = float32_to_float64(s->XMM_S(0), &env->sse_status); } void OPPROTO op_cvtsd2ss(void) @@ -737,7 +737,7 @@ void OPPROTO op_cvtsd2ss(void) Reg *d, *s; d = (Reg *)((char *)env + PARAM1); s = (Reg *)((char *)env + PARAM2); - d->XMM_S(0) = float64_to_float32(s->XMM_D(0)); + d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status); } /* integer to float */ @@ -745,10 +745,10 @@ void OPPROTO op_cvtdq2ps(void) { XMMReg *d = (XMMReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->XMM_S(0) = int32_to_float32(s->XMM_L(0)); - d->XMM_S(1) = int32_to_float32(s->XMM_L(1)); - d->XMM_S(2) = int32_to_float32(s->XMM_L(2)); - d->XMM_S(3) = int32_to_float32(s->XMM_L(3)); + d->XMM_S(0) = int32_to_float32(s->XMM_L(0), &env->sse_status); + d->XMM_S(1) = int32_to_float32(s->XMM_L(1), &env->sse_status); + d->XMM_S(2) = int32_to_float32(s->XMM_L(2), &env->sse_status); + d->XMM_S(3) = int32_to_float32(s->XMM_L(3), &env->sse_status); } void OPPROTO op_cvtdq2pd(void) @@ -758,49 +758,49 @@ void OPPROTO op_cvtdq2pd(void) int32_t l0, l1; l0 = (int32_t)s->XMM_L(0); l1 = (int32_t)s->XMM_L(1); - d->XMM_D(0) = int32_to_float64(l0); - d->XMM_D(1) = int32_to_float64(l1); + d->XMM_D(0) = int32_to_float64(l0, &env->sse_status); + d->XMM_D(1) = int32_to_float64(l1, &env->sse_status); } void OPPROTO op_cvtpi2ps(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); MMXReg *s = (MMXReg *)((char *)env + PARAM2); - d->XMM_S(0) = int32_to_float32(s->MMX_L(0)); - d->XMM_S(1) = int32_to_float32(s->MMX_L(1)); + d->XMM_S(0) = int32_to_float32(s->MMX_L(0), &env->sse_status); + d->XMM_S(1) = int32_to_float32(s->MMX_L(1), &env->sse_status); } void OPPROTO op_cvtpi2pd(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); MMXReg *s = (MMXReg *)((char *)env + PARAM2); - d->XMM_D(0) = int32_to_float64(s->MMX_L(0)); - d->XMM_D(1) = int32_to_float64(s->MMX_L(1)); + d->XMM_D(0) = int32_to_float64(s->MMX_L(0), &env->sse_status); + d->XMM_D(1) = int32_to_float64(s->MMX_L(1), &env->sse_status); } void OPPROTO op_cvtsi2ss(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); - d->XMM_S(0) = int32_to_float32(T0); + d->XMM_S(0) = int32_to_float32(T0, &env->sse_status); } void OPPROTO op_cvtsi2sd(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); - d->XMM_D(0) = int32_to_float64(T0); + d->XMM_D(0) = int32_to_float64(T0, &env->sse_status); } #ifdef TARGET_X86_64 void OPPROTO op_cvtsq2ss(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); - d->XMM_S(0) = int64_to_float32(T0); + d->XMM_S(0) = int64_to_float32(T0, &env->sse_status); } void OPPROTO op_cvtsq2sd(void) { XMMReg *d = (Reg *)((char *)env + PARAM1); - d->XMM_D(0) = int64_to_float64(T0); + d->XMM_D(0) = int64_to_float64(T0, &env->sse_status); } #endif @@ -809,18 +809,18 @@ void OPPROTO op_cvtps2dq(void) { XMMReg *d = (XMMReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->XMM_L(0) = lrint(s->XMM_S(0)); - d->XMM_L(1) = lrint(s->XMM_S(1)); - d->XMM_L(2) = lrint(s->XMM_S(2)); - d->XMM_L(3) = lrint(s->XMM_S(3)); + d->XMM_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status); + d->XMM_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status); + d->XMM_L(2) = float32_to_int32(s->XMM_S(2), &env->sse_status); + d->XMM_L(3) = float32_to_int32(s->XMM_S(3), &env->sse_status); } void OPPROTO op_cvtpd2dq(void) { XMMReg *d = (XMMReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->XMM_L(0) = lrint(s->XMM_D(0)); - d->XMM_L(1) = lrint(s->XMM_D(1)); + d->XMM_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status); + d->XMM_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status); d->XMM_Q(1) = 0; } @@ -828,41 +828,41 @@ void OPPROTO op_cvtps2pi(void) { MMXReg *d = (MMXReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->MMX_L(0) = lrint(s->XMM_S(0)); - d->MMX_L(1) = lrint(s->XMM_S(1)); + d->MMX_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status); + d->MMX_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status); } void OPPROTO op_cvtpd2pi(void) { MMXReg *d = (MMXReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->MMX_L(0) = lrint(s->XMM_D(0)); - d->MMX_L(1) = lrint(s->XMM_D(1)); + d->MMX_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status); + d->MMX_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status); } void OPPROTO op_cvtss2si(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int32_t)lrint(s->XMM_S(0)); + T0 = float32_to_int32(s->XMM_S(0), &env->sse_status); } void OPPROTO op_cvtsd2si(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int32_t)lrint(s->XMM_D(0)); + T0 = float64_to_int32(s->XMM_D(0), &env->sse_status); } #ifdef TARGET_X86_64 void OPPROTO op_cvtss2sq(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = llrint(s->XMM_S(0)); + T0 = float32_to_int64(s->XMM_S(0), &env->sse_status); } void OPPROTO op_cvtsd2sq(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = llrint(s->XMM_D(0)); + T0 = float64_to_int64(s->XMM_D(0), &env->sse_status); } #endif @@ -871,18 +871,18 @@ void OPPROTO op_cvttps2dq(void) { XMMReg *d = (XMMReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->XMM_L(0) = (int32_t)s->XMM_S(0); - d->XMM_L(1) = (int32_t)s->XMM_S(1); - d->XMM_L(2) = (int32_t)s->XMM_S(2); - d->XMM_L(3) = (int32_t)s->XMM_S(3); + d->XMM_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status); + d->XMM_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status); + d->XMM_L(2) = float32_to_int32_round_to_zero(s->XMM_S(2), &env->sse_status); + d->XMM_L(3) = float32_to_int32_round_to_zero(s->XMM_S(3), &env->sse_status); } void OPPROTO op_cvttpd2dq(void) { XMMReg *d = (XMMReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->XMM_L(0) = (int32_t)s->XMM_D(0); - d->XMM_L(1) = (int32_t)s->XMM_D(1); + d->XMM_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status); + d->XMM_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status); d->XMM_Q(1) = 0; } @@ -890,41 +890,41 @@ void OPPROTO op_cvttps2pi(void) { MMXReg *d = (MMXReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->MMX_L(0) = (int32_t)(s->XMM_S(0)); - d->MMX_L(1) = (int32_t)(s->XMM_S(1)); + d->MMX_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status); + d->MMX_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status); } void OPPROTO op_cvttpd2pi(void) { MMXReg *d = (MMXReg *)((char *)env + PARAM1); XMMReg *s = (XMMReg *)((char *)env + PARAM2); - d->MMX_L(0) = (int32_t)(s->XMM_D(0)); - d->MMX_L(1) = (int32_t)(s->XMM_D(1)); + d->MMX_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status); + d->MMX_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status); } void OPPROTO op_cvttss2si(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int32_t)(s->XMM_S(0)); + T0 = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status); } void OPPROTO op_cvttsd2si(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int32_t)(s->XMM_D(0)); + T0 = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status); } #ifdef TARGET_X86_64 void OPPROTO op_cvttss2sq(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int64_t)(s->XMM_S(0)); + T0 = float32_to_int64_round_to_zero(s->XMM_S(0), &env->sse_status); } void OPPROTO op_cvttsd2sq(void) { XMMReg *s = (XMMReg *)((char *)env + PARAM1); - T0 = (int64_t)(s->XMM_D(0)); + T0 = float64_to_int64_round_to_zero(s->XMM_D(0), &env->sse_status); } #endif |