From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@kernel.org>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v2 2/4] target/s390x: Extract s390_get_bfp_rounding_mode()
Date: Tue, 27 Jan 2026 16:31:43 +0100 [thread overview]
Message-ID: <20260127153736.62730-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20260127153736.62730-1-iii@linux.ibm.com>
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.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
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
next prev parent reply other threads:[~2026-01-27 15:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 15:31 [PATCH v2 0/4] target/s390x: Implement DIVIDE TO INTEGER Ilya Leoshkevich
2026-01-27 15:31 ` [PATCH v2 1/4] target/s390x: Dump Floating-Point-Control Register Ilya Leoshkevich
2026-01-27 15:31 ` Ilya Leoshkevich [this message]
2026-01-28 5:25 ` [PATCH v2 2/4] target/s390x: Extract s390_get_bfp_rounding_mode() Richard Henderson
2026-01-27 15:31 ` [PATCH v2 3/4] target/s390x: Implement DIVIDE TO INTEGER Ilya Leoshkevich
2026-01-28 5:50 ` Richard Henderson
2026-01-28 13:19 ` Ilya Leoshkevich
2026-01-28 20:38 ` Richard Henderson
2026-01-29 18:24 ` Ilya Leoshkevich
2026-02-02 6:03 ` Richard Henderson
2026-01-27 15:31 ` [PATCH v2 4/4] tests/tcg/s390x: Test " Ilya Leoshkevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260127153736.62730-3-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=david@kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.