From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: Re: [PATCH 04/10] fpu: Make targets specify whether floatx80 Inf can have Int bit clear
Date: Fri, 21 Feb 2025 14:12:03 +0100 [thread overview]
Message-ID: <999fbc69-aa91-4b7f-b0ab-2270b89d0f5a@linaro.org> (raw)
In-Reply-To: <20250217125055.160887-5-peter.maydell@linaro.org>
On 17/2/25 13:50, Peter Maydell wrote:
> In Intel terminology, a floatx80 Infinity with the explicit integer
> bit clear is a "pseudo-infinity"; for x86 these are not valid
> infinity values. m68k is looser and does not care whether the
> Integer bit is set or clear in an infinity.
>
> Move this setting to runtime rather than using an ifdef in
> floatx80_is_infinity(). (This requires us to pass in the
> float_status to that function now.)
>
> Since this was the last use of the floatx80_infinity global constant,
> we remove it and its definition here.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/fpu/softfloat-types.h | 5 +++++
> include/fpu/softfloat.h | 20 ++++++++++++--------
> target/i386/tcg/fpu_helper.c | 20 +++++++++++---------
> target/m68k/cpu.c | 4 +++-
> target/m68k/fpu_helper.c | 2 +-
> fpu/softfloat-specialize.c.inc | 10 ----------
> 6 files changed, 32 insertions(+), 29 deletions(-)
Passing float_status argument to floatx80_is_infinity in a preliminary
patch, this becomes simpler (to my taste...):
4 files changed, 19 insertions(+), 18 deletions(-)
-- >8 --
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index dd22ecdbe60..e1732beba4f 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -332,0 +333,5 @@ typedef enum __attribute__((__packed__)) {
+ /*
+ * Are Pseudo-infinities (Inf with the Integer bit zero) valid?
+ * If so, floatx80_is_infinity() will return true for them.
+ */
+ floatx80_pseudo_inf_valid = 2,
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 1fa759779ea..1c8f3cbb78d 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -963 +962,0 @@ float128 floatx80_to_float128(floatx80, float_status
*status);
-extern const floatx80 floatx80_infinity;
@@ -1001,6 +1000,11 @@ static inline bool floatx80_is_infinity(floatx80
a, float_status *status)
-#if defined(TARGET_M68K)
- return (a.high & 0x7fff) == floatx80_infinity.high && !(a.low << 1);
-#else
- return (a.high & 0x7fff) == floatx80_infinity.high &&
- a.low == floatx80_infinity.low;
-#endif
+ /*
+ * It's target-specific whether the Integer bit is permitted
+ * to be 0 in a valid Infinity value. (x86 says no, m68k says yes).
+ */
+ bool intbit = a.low >> 63;
+
+ if (!intbit &&
+ !(status->floatx80_behaviour & floatx80_pseudo_inf_valid)) {
+ return false;
+ }
+ return (a.high & 0x7fff) == 0x7fff && !(a.low << 1);
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index df66e8ba22a..56b23de21fe 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -112,0 +113 @@ static void m68k_cpu_reset_hold(Object *obj, ResetType
type)
+ * * input Infinities may have the Integer bit either 0 or 1
@@ -114 +115,2 @@ static void m68k_cpu_reset_hold(Object *obj, ResetType
type)
- set_floatx80_behaviour(floatx80_default_inf_int_bit_is_zero,
+ set_floatx80_behaviour(floatx80_default_inf_int_bit_is_zero |
+ floatx80_pseudo_inf_valid,
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 73789e97d77..8327f727861 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -240,10 +239,0 @@ floatx80 floatx80_default_inf(bool zSign,
float_status *status)
-#define floatx80_infinity_high 0x7FFF
-#if defined(TARGET_M68K)
-#define floatx80_infinity_low UINT64_C(0x0000000000000000)
-#else
-#define floatx80_infinity_low UINT64_C(0x8000000000000000)
-#endif
-
-const floatx80 floatx80_infinity
- = make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low);
-
---
next prev parent reply other threads:[~2025-02-21 13:12 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 12:50 [PATCH 00/10] fpu: Remove remaining target ifdefs and build only once Peter Maydell
2025-02-17 12:50 ` [PATCH 01/10] fpu: Make targets specify floatx80 default Inf at runtime Peter Maydell
2025-02-17 18:09 ` Richard Henderson
2025-02-21 14:42 ` Philippe Mathieu-Daudé
2025-02-21 15:16 ` Peter Maydell
2025-02-17 12:50 ` [PATCH 02/10] target/m68k: Avoid using floatx80_infinity global const Peter Maydell
2025-02-17 18:10 ` Richard Henderson
2025-02-21 13:51 ` Philippe Mathieu-Daudé
2025-02-17 12:50 ` [PATCH 03/10] target/i386: " Peter Maydell
2025-02-17 18:10 ` Richard Henderson
2025-02-21 13:40 ` Philippe Mathieu-Daudé
2025-02-17 12:50 ` [PATCH 04/10] fpu: Make targets specify whether floatx80 Inf can have Int bit clear Peter Maydell
2025-02-17 18:13 ` Richard Henderson
2025-02-21 13:12 ` Philippe Mathieu-Daudé [this message]
2025-02-17 12:50 ` [PATCH 05/10] fpu: Make floatx80 invalid encoding settable at runtime Peter Maydell
2025-02-17 18:45 ` Richard Henderson
2025-02-21 13:14 ` Philippe Mathieu-Daudé
2025-02-17 12:50 ` [PATCH 06/10] fpu: Move m68k_denormal fmt flag into floatx80_behaviour Peter Maydell
2025-02-17 19:14 ` Richard Henderson
2025-02-20 17:12 ` Peter Maydell
2025-02-20 18:39 ` Richard Henderson
2025-02-20 18:54 ` Peter Maydell
2025-02-21 14:14 ` Philippe Mathieu-Daudé
2025-02-21 22:24 ` Richard Henderson
2025-02-17 12:50 ` [PATCH 07/10] fpu: Always decide no_signaling_nans() at runtime Peter Maydell
2025-02-17 13:13 ` Philippe Mathieu-Daudé
2025-02-17 19:25 ` Richard Henderson
2025-02-17 12:50 ` [PATCH 08/10] fpu: Always decide snan_bit_is_one() " Peter Maydell
2025-02-17 13:15 ` Philippe Mathieu-Daudé
2025-02-17 19:26 ` Richard Henderson
2025-02-17 12:50 ` [PATCH 09/10] fpu: Don't compile-time disable hardfloat for PPC targets Peter Maydell
2025-02-17 19:27 ` Richard Henderson
2025-02-17 12:50 ` [PATCH 10/10] fpu: Build only once Peter Maydell
2025-02-17 19:28 ` Richard Henderson
2025-02-20 8:48 ` [PATCH 00/10] fpu: Remove remaining target ifdefs and build " Philippe Mathieu-Daudé
2025-02-20 9:00 ` Philippe Mathieu-Daudé
2025-02-21 10:48 ` Philippe Mathieu-Daudé
2025-02-21 13:05 ` Philippe Mathieu-Daudé
2025-02-21 13:28 ` Peter Maydell
2025-02-21 13:48 ` Philippe Mathieu-Daudé
2025-02-21 14:41 ` Philippe Mathieu-Daudé
2025-02-21 15:19 ` Peter Maydell
2025-02-21 16:21 ` Philippe Mathieu-Daudé
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=999fbc69-aa91-4b7f-b0ab-2270b89d0f5a@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=eduardo@habkost.net \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).