For DIVIDE TO INTEGER it will be helpful to pass final-quotient rounding mode around explicitly rather than setting it in fpu_status implicitly. To facilitate this, extract a function for converting the mask to the rounding mode.
Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Ilya Leoshkevich <[email protected]> --- target/s390x/tcg/fpu_helper.c | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/target/s390x/tcg/fpu_helper.c b/target/s390x/tcg/fpu_helper.c index 1ba43715ac1..7a3ff501a46 100644 --- a/target/s390x/tcg/fpu_helper.c +++ b/target/s390x/tcg/fpu_helper.c @@ -56,6 +56,35 @@ uint8_t s390_softfloat_exc_to_ieee(unsigned int exc) return s390_exc; } +static int s390_get_bfp_rounding_mode(CPUS390XState *env, int m3) +{ + switch (m3) { + case 0: + /* current mode */ + return env->fpu_status.float_rounding_mode; + case 1: + /* round to nearest with ties away from 0 */ + return float_round_ties_away; + case 3: + /* round to prepare for shorter precision */ + return float_round_to_odd; + case 4: + /* round to nearest with ties to even */ + return float_round_nearest_even; + case 5: + /* round to zero */ + return float_round_to_zero; + case 6: + /* round to +inf */ + return float_round_up; + case 7: + /* round to -inf */ + return float_round_down; + default: + g_assert_not_reached(); + } +} + /* Should be called after any operation that may raise IEEE exceptions. */ static void handle_exceptions(CPUS390XState *env, bool XxC, uintptr_t retaddr) { @@ -416,37 +445,8 @@ int s390_swap_bfp_rounding_mode(CPUS390XState *env, int m3) { int ret = env->fpu_status.float_rounding_mode; - switch (m3) { - case 0: - /* current mode */ - break; - case 1: - /* round to nearest with ties away from 0 */ - set_float_rounding_mode(float_round_ties_away, &env->fpu_status); - break; - case 3: - /* round to prepare for shorter precision */ - set_float_rounding_mode(float_round_to_odd, &env->fpu_status); - break; - case 4: - /* round to nearest with ties to even */ - set_float_rounding_mode(float_round_nearest_even, &env->fpu_status); - break; - case 5: - /* round to zero */ - set_float_rounding_mode(float_round_to_zero, &env->fpu_status); - break; - case 6: - /* round to +inf */ - set_float_rounding_mode(float_round_up, &env->fpu_status); - break; - case 7: - /* round to -inf */ - set_float_rounding_mode(float_round_down, &env->fpu_status); - break; - default: - g_assert_not_reached(); - } + set_float_rounding_mode(s390_get_bfp_rounding_mode(env, m3), + &env->fpu_status); return ret; } -- 2.52.0
