diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2026-02-10 22:39:01 +0100 |
|---|---|---|
| committer | Thomas Huth <thuth@redhat.com> | 2026-02-12 08:43:13 +0100 |
| commit | f5682b9deef3d572bbe780e04857166b77870718 (patch) | |
| tree | a6a298d7ba0986890e500bb73b9c9a9b95bd52a9 | |
| parent | 5b251330e4822810543b280f39678030e58e2d5a (diff) | |
| download | qemu-f5682b9deef3d572bbe780e04857166b77870718.tar.gz qemu-f5682b9deef3d572bbe780e04857166b77870718.tar.bz2 qemu-f5682b9deef3d572bbe780e04857166b77870718.zip | |
target/s390x: Extract s390_get_bfp_rounding_mode()
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 <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20260210214044.1174699-3-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
| -rw-r--r-- | target/s390x/tcg/fpu_helper.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/target/s390x/tcg/fpu_helper.c b/target/s390x/tcg/fpu_helper.c index 1ba43715ac..7a3ff501a4 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; } |
