From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: Re: [PATCH 06/10] fpu: Move m68k_denormal fmt flag into floatx80_behaviour
Date: Thu, 20 Feb 2025 18:54:16 +0000 [thread overview]
Message-ID: <CAFEAcA_uPWSgwpygQiSBzCLsBV+HH5Pun1E9RGw16Z3SMj4REQ@mail.gmail.com> (raw)
In-Reply-To: <d7a0260d-5cdb-4e87-b12c-32e1dee4df1c@linaro.org>
On Thu, 20 Feb 2025 at 18:39, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 2/20/25 09:12, Peter Maydell wrote:
> > That suggests that we are correctly implementing the x87
> > required behaviour in QEMU, and so that the TODO comment
> > I add in this patch isn't right. But then I'm a bit confused
> > about what the code is actually doing. Why do we need to look
> > at fmt->m68k_denormal in the input (canonicalize) code (i.e.
> > to have different behaviour here for x86 and m68k), if
> > both x86 and m68k accept these pseudodenormals as input?
> >
> > Is the difference that for x86 we accept but canonicalize
> > into the equivalent normal number immediately on input,
> > whereas for m68k we accept and leave the pseudodenormal
> > as a pseudodenormal (well, m68k calls these a kind of
> > normal number) ?
> The difference is in interpretation: x86 ignores the explicit integer bit of the
> pseudo-denormal, m68k considers it part of the input value. This gives m68k one extra bit
> of range in their denormal, which allows representation of smaller numbers.
Ah, I see. So I suppose:
(1) we should call the floatx80_status flag
"floatx80_pseudo_denormal_valid" since it affects both inputs
and outputs, and document it in the enum like:
+ /*
+ * If the exponent is 0 and the Integer bit is set, Intel call
+ * this a "pseudo-denormal"; x86 supports that only on input
+ * (treating them as denormals by ignoring the Integer bit).
+ * For m68k, the integer bit is considered validly part of the
+ * input value when the exponent is 0, and may be 0 or 1,
+ * giving extra range. They may also be generated as outputs.
+ * (The m68k manual actually calls these values part of the
+ * normalized number range, not the denormalized number range.)
+ *
+ * By default you get the Intel behaviour where the Integer
+ * bit is ignored; if this is set then the Integer bit value
+ * is honoured, m68k-style.
+ *
+ * Either way, floatx80_invalid_encoding() will always accept
+ * pseudo-denormals.
+ */
+ floatx80_pseudo_denormal_valid = 16,
(2) the comment I add in canonicalize should instead read:
+ /*
+ * It's target-dependent how to handle the case of exponent 0
+ * and Integer bit set. Intel calls these "pseudodenormals",
+ * and treats them as if the integer bit was 0, and never
+ * produces them on output. This is the default behaviour for QEMU.
+ * For m68k, the integer bit is considered validly part of the
+ * input value when the exponent is 0, and may be 0 or 1,
+ * giving extra range. They may also be generated as outputs.
+ * (The m68k manual actually calls these values part of the
+ * normalized number range, not the denormalized number range,
+ * but that distinction is not important for us, because
+ * m68k doesn't care about the input_denormal_used status flag.)
+ * floatx80_pseudo_denormal_valid selects the m68k behaviour,
+ * which changes both how we canonicalize such a value and
+ * how we uncanonicalize results.
+ */
?
thanks
-- PMM
next prev parent reply other threads:[~2025-02-20 18:54 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é
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 [this message]
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=CAFEAcA_uPWSgwpygQiSBzCLsBV+HH5Pun1E9RGw16Z3SMj4REQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=eduardo@habkost.net \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--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).