Message ID | 1303230655-31280-1-git-send-email-peter.maydell@linaro.org |
---|---|
State | Accepted |
Commit | ec444452b8753a372de30b22d9b4765a799db612 |
Headers | show |
On Tue, Apr 19, 2011 at 05:30:55PM +0100, Peter Maydell wrote: > When we catch the special case of an input NaN in ARM float to int > helper functions, set the Invalid flag as well as returning the > correct result. > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > target-arm/helper.c | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) Thanks, applied. > diff --git a/target-arm/helper.c b/target-arm/helper.c > index 12127de..d5f2ace 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -2542,6 +2542,7 @@ float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env) > uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env) > { > if (float32_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float32_to_uint32(x, &env->vfp.fp_status); > @@ -2550,6 +2551,7 @@ uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env) > uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env) > { > if (float64_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float64_to_uint32(x, &env->vfp.fp_status); > @@ -2558,6 +2560,7 @@ uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env) > uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env) > { > if (float32_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float32_to_int32(x, &env->vfp.fp_status); > @@ -2566,6 +2569,7 @@ uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env) > uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env) > { > if (float64_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float64_to_int32(x, &env->vfp.fp_status); > @@ -2574,6 +2578,7 @@ uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env) > uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env) > { > if (float32_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status); > @@ -2582,6 +2587,7 @@ uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env) > uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env) > { > if (float64_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status); > @@ -2590,6 +2596,7 @@ uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env) > uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env) > { > if (float32_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float32_to_int32_round_to_zero(x, &env->vfp.fp_status); > @@ -2598,6 +2605,7 @@ uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env) > uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env) > { > if (float64_is_any_nan(x)) { > + float_raise(float_flag_invalid, &env->vfp.fp_status); > return 0; > } > return float64_to_int32_round_to_zero(x, &env->vfp.fp_status); > @@ -2636,6 +2644,7 @@ uint##fsz##_t VFP_HELPER(to##name, p)(float##fsz x, uint32_t shift, \ > { \ > float##fsz tmp; \ > if (float##fsz##_is_any_nan(x)) { \ > + float_raise(float_flag_invalid, &env->vfp.fp_status); \ > return 0; \ > } \ > tmp = float##fsz##_scalbn(x, shift, &env->vfp.fp_status); \ > -- > 1.7.1 > > >
diff --git a/target-arm/helper.c b/target-arm/helper.c index 12127de..d5f2ace 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2542,6 +2542,7 @@ float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env) uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env) { if (float32_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float32_to_uint32(x, &env->vfp.fp_status); @@ -2550,6 +2551,7 @@ uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env) uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env) { if (float64_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float64_to_uint32(x, &env->vfp.fp_status); @@ -2558,6 +2560,7 @@ uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env) uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env) { if (float32_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float32_to_int32(x, &env->vfp.fp_status); @@ -2566,6 +2569,7 @@ uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env) uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env) { if (float64_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float64_to_int32(x, &env->vfp.fp_status); @@ -2574,6 +2578,7 @@ uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env) uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env) { if (float32_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status); @@ -2582,6 +2587,7 @@ uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env) uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env) { if (float64_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status); @@ -2590,6 +2596,7 @@ uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env) uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env) { if (float32_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float32_to_int32_round_to_zero(x, &env->vfp.fp_status); @@ -2598,6 +2605,7 @@ uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env) uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env) { if (float64_is_any_nan(x)) { + float_raise(float_flag_invalid, &env->vfp.fp_status); return 0; } return float64_to_int32_round_to_zero(x, &env->vfp.fp_status); @@ -2636,6 +2644,7 @@ uint##fsz##_t VFP_HELPER(to##name, p)(float##fsz x, uint32_t shift, \ { \ float##fsz tmp; \ if (float##fsz##_is_any_nan(x)) { \ + float_raise(float_flag_invalid, &env->vfp.fp_status); \ return 0; \ } \ tmp = float##fsz##_scalbn(x, shift, &env->vfp.fp_status); \
When we catch the special case of an input NaN in ARM float to int helper functions, set the Invalid flag as well as returning the correct result. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- target-arm/helper.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)