Clear softfpu exception state for round, trunc, ceil and floor
MIPS FPU instructions should start with a clean softfpu status. This is done for the arithmetic operations and cvt instructions, but not for round, trunc, ceil and floor.
Chris
Signature · 2 lines
Chris Dearman Desk: +1 408 530 5092 Cell: +1 408 398 5531 MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
PATCH 1/1 Clear softfpu exception state for round, trunc, ceil and floor
Signed-off-by Chris Dearman <[email protected]>
--- target-mips/op_helper.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
target-mips/op_helper.c +16 -0
@@ -2294,6 +2294,7 @@ uint64_t helper_float_roundl_d(uint64_t fdt0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_nearest_even, &env->active_fpu.fp_status); dt2 =float64_to_int64 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2307,6 +2308,7 @@ uint64_t helper_float_roundl_s(uint32_t fst0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_nearest_even, &env->active_fpu.fp_status); dt2 =float32_to_int64 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2320,6 +2322,7 @@ uint32_t helper_float_roundw_d(uint64_t fdt0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_nearest_even, &env->active_fpu.fp_status); wt2 =float64_to_int32 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2333,6 +2336,7 @@ uint32_t helper_float_roundw_s(uint32_t fst0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_nearest_even, &env->active_fpu.fp_status); wt2 =float32_to_int32 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2346,6 +2350,7 @@ uint64_t helper_float_truncl_d(uint64_t fdt0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status); dt2 =float64_to_int64_round_to_zero (fdt0, &env->active_fpu.fp_status);update_fcr31 ();if (GET_FP_CAUSE (env->active_fpu.fcr31) & (FP_OVERFLOW |FP_INVALID ))
@@ -2357,6 +2362,7 @@ uint64_t helper_float_truncl_s(uint32_t fst0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status); dt2 =float32_to_int64_round_to_zero (fst0, &env->active_fpu.fp_status);update_fcr31 ();if (GET_FP_CAUSE (env->active_fpu.fcr31) & (FP_OVERFLOW |FP_INVALID ))
@@ -2368,6 +2374,7 @@ uint32_t helper_float_truncw_d(uint64_t fdt0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status); wt2 =float64_to_int32_round_to_zero (fdt0, &env->active_fpu.fp_status);update_fcr31 ();if (GET_FP_CAUSE (env->active_fpu.fcr31) & (FP_OVERFLOW |FP_INVALID ))
@@ -2379,6 +2386,7 @@ uint32_t helper_float_truncw_s(uint32_t fst0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status); wt2 =float32_to_int32_round_to_zero (fst0, &env->active_fpu.fp_status);update_fcr31 ();if (GET_FP_CAUSE (env->active_fpu.fcr31) & (FP_OVERFLOW |FP_INVALID ))
@@ -2390,6 +2398,7 @@ uint64_t helper_float_ceill_d(uint64_t fdt0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_up, &env->active_fpu.fp_status); dt2 =float64_to_int64 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2403,6 +2412,7 @@ uint64_t helper_float_ceill_s(uint32_t fst0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_up, &env->active_fpu.fp_status); dt2 =float32_to_int64 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2416,6 +2426,7 @@ uint32_t helper_float_ceilw_d(uint64_t fdt0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_up, &env->active_fpu.fp_status); wt2 =float64_to_int32 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2429,6 +2440,7 @@ uint32_t helper_float_ceilw_s(uint32_t fst0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_up, &env->active_fpu.fp_status); wt2 =float32_to_int32 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2442,6 +2454,7 @@ uint64_t helper_float_floorl_d(uint64_t fdt0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_down, &env->active_fpu.fp_status); dt2 =float64_to_int64 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2455,6 +2468,7 @@ uint64_t helper_float_floorl_s(uint32_t fst0) {uint64_t dt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_down, &env->active_fpu.fp_status); dt2 =float32_to_int64 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2468,6 +2482,7 @@ uint32_t helper_float_floorw_d(uint64_t fdt0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_down, &env->active_fpu.fp_status); wt2 =float64_to_int32 (fdt0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
@@ -2481,6 +2496,7 @@ uint32_t helper_float_floorw_s(uint32_t fst0) {uint32_t wt2; +set_float_exception_flags (0 , &env->active_fpu.fp_status);set_float_rounding_mode (float_round_down, &env->active_fpu.fp_status); wt2 =float32_to_int32 (fst0, &env->active_fpu.fp_status);RESTORE_ROUNDING_MODE ;
Quoted 4 lines · Chris Dearman
MIPS FPU instructions should start with a clean softfpu status. This is done for the arithmetic operations and cvt instructions, but not for round, trunc, ceil and floor.
Good catch, I have applied the patch.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net