qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Song Gao" <gaosong@loongson.cn>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Aleksandar Rikalo" <arikalo@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"David Hildenbrand" <david@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	qemu-ppc@nongnu.org, qemu-s390x@nongnu.org
Subject: Re: [PATCH 04/21] target/mips: Explicitly set 2-NaN propagation rule
Date: Fri, 25 Oct 2024 16:46:03 -0300	[thread overview]
Message-ID: <ed9a4ac3-1b89-4ed8-9839-01df7fb4d989@linaro.org> (raw)
In-Reply-To: <20241025141254.2141506-5-peter.maydell@linaro.org>

On 25/10/24 11:12, Peter Maydell wrote:
> Set the 2-NaN propagation rule explicitly in the float_status words
> we use.
> 
> For active_fpu.fp_status, we do this in a new fp_reset() function
> which mirrors the existing msa_reset() function in doing "first call
> restore to set the fp status parts that depend on CPU state, then set
> the fp status parts that are constant".
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   target/mips/fpu_helper.h       | 22 ++++++++++++++++++++++
>   target/mips/cpu.c              |  2 +-
>   target/mips/msa.c              | 17 +++++++++++++++++
>   fpu/softfloat-specialize.c.inc | 18 ++----------------
>   4 files changed, 42 insertions(+), 17 deletions(-)
> 
> diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
> index ad1116e8c10..7c3c7897b45 100644
> --- a/target/mips/fpu_helper.h
> +++ b/target/mips/fpu_helper.h
> @@ -44,6 +44,28 @@ static inline void restore_fp_status(CPUMIPSState *env)
>       restore_snan_bit_mode(env);
>   }
>   
> +static inline void fp_reset(CPUMIPSState *env)
> +{
> +    restore_fp_status(env);
> +
> +    /*
> +     * According to MIPS specifications, if one of the two operands is
> +     * a sNaN, a new qNaN has to be generated. This is done in
> +     * floatXX_silence_nan(). For qNaN inputs the specifications
> +     * says: "When possible, this QNaN result is one of the operand QNaN
> +     * values." In practice it seems that most implementations choose
> +     * the first operand if both operands are qNaN. In short this gives
> +     * the following rules:
> +     *  1. A if it is signaling
> +     *  2. B if it is signaling
> +     *  3. A (quiet)
> +     *  4. B (quiet)
> +     * A signaling NaN is always silenced before returning it.
> +     */
> +    set_float_2nan_prop_rule(float_2nan_prop_s_ab,
> +                             &env->active_fpu.fp_status);
> +}
> +
>   /* MSA */
>   
>   enum CPUMIPSMSADataFormat {
> diff --git a/target/mips/cpu.c b/target/mips/cpu.c
> index 9724e71a5e0..d0a43b6d5c7 100644
> --- a/target/mips/cpu.c
> +++ b/target/mips/cpu.c
> @@ -407,9 +407,9 @@ static void mips_cpu_reset_hold(Object *obj, ResetType type)
>       }
>   
>       msa_reset(env);
> +    fp_reset(env);
>   
>       compute_hflags(env);
> -    restore_fp_status(env);
>       restore_pamask(env);
>       cs->exception_index = EXCP_NONE;
>   
> diff --git a/target/mips/msa.c b/target/mips/msa.c
> index 61f1a9a5936..9dffc428f5c 100644
> --- a/target/mips/msa.c
> +++ b/target/mips/msa.c
> @@ -49,6 +49,23 @@ void msa_reset(CPUMIPSState *env)
>       set_float_detect_tininess(float_tininess_after_rounding,
>                                 &env->active_tc.msa_fp_status);
>   
> +    /*
> +     * According to MIPS specifications, if one of the two operands is
> +     * a sNaN, a new qNaN has to be generated. This is done in
> +     * floatXX_silence_nan(). For qNaN inputs the specifications
> +     * says: "When possible, this QNaN result is one of the operand QNaN
> +     * values." In practice it seems that most implementations choose
> +     * the first operand if both operands are qNaN. In short this gives
> +     * the following rules:
> +     *  1. A if it is signaling
> +     *  2. B if it is signaling
> +     *  3. A (quiet)
> +     *  4. B (quiet)
> +     * A signaling NaN is always silenced before returning it.
> +     */
> +    set_float_2nan_prop_rule(float_2nan_prop_s_ab,
> +                             &env->active_tc.msa_fp_status);

Alternatively pass float_status* to fp_reset() and call it here as

        mips_fp_reset(&env->active_tc.msa_fp_status);

So we keep the comment in one place.

Regardless,

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



  reply	other threads:[~2024-10-25 19:47 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 14:12 [PATCH 00/21] softfloat: Set 2-NaN propagation rule in float_status, not at compile time Peter Maydell
2024-10-25 14:12 ` [PATCH 01/21] softfloat: Allow 2-operand NaN propagation rule to be set at runtime Peter Maydell
2024-10-28 12:07   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 02/21] tests/fp: Explicitly set 2-NaN propagation rule Peter Maydell
2024-10-25 19:27   ` Philippe Mathieu-Daudé
2024-10-28 12:07   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 03/21] target/arm: " Peter Maydell
2024-10-28 12:10   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 04/21] target/mips: " Peter Maydell
2024-10-25 19:46   ` Philippe Mathieu-Daudé [this message]
2024-10-25 14:12 ` [PATCH 05/21] target/loongarch: " Peter Maydell
2024-10-28 12:13   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 06/21] target/hppa: " Peter Maydell
2024-10-28 12:14   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 07/21] target/s390x: " Peter Maydell
2024-10-25 17:45   ` Ilya Leoshkevich
2024-10-26  4:40   ` Philippe Mathieu-Daudé
2024-10-28 12:15   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 08/21] target/ppc: " Peter Maydell
2024-10-28 12:16   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 09/21] target/m68k: " Peter Maydell
2024-10-26  4:36   ` Philippe Mathieu-Daudé
2024-10-28 12:18   ` Richard Henderson
2024-10-29 10:10   ` Peter Maydell
2024-10-25 14:12 ` [PATCH 10/21] target/m68k: Initialize float_status fields in gdb set/get functions Peter Maydell
2024-10-26  4:35   ` Philippe Mathieu-Daudé
2024-10-28 12:19   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 11/21] target/sparc: Move cpu_put_fsr(env, 0) call to reset Peter Maydell
2024-10-26  4:32   ` Philippe Mathieu-Daudé
2024-10-26 20:00   ` Mark Cave-Ayland
2024-10-28 12:20   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 12/21] target/sparc: Explicitly set 2-NaN propagation rule Peter Maydell
2024-10-26 20:03   ` Mark Cave-Ayland
2024-10-28 12:20   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 13/21] target/xtensa: Factor out calls to set_use_first_nan() Peter Maydell
2024-10-25 15:54   ` Max Filippov
2024-10-28 12:21   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 14/21] target/xtensa: Explicitly set 2-NaN propagation rule Peter Maydell
2024-10-25 15:54   ` Max Filippov
2024-10-26  4:38   ` Philippe Mathieu-Daudé
2024-10-28 12:22   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 15/21] target/i386: Set 2-NaN propagation rule explicitly Peter Maydell
2024-10-28 12:24   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 16/21] target/alpha: Explicitly set 2-NaN propagation rule Peter Maydell
2024-10-26  4:39   ` Philippe Mathieu-Daudé
2024-10-28 12:25   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 17/21] target/microblaze: Move setting of float rounding mode to reset Peter Maydell
2024-10-28 12:25   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 18/21] target/microblaze: Explicitly set 2-NaN propagation rule Peter Maydell
2024-10-26  4:39   ` Philippe Mathieu-Daudé
2024-10-28 12:26   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 19/21] target/openrisc: " Peter Maydell
2024-10-26  4:40   ` Philippe Mathieu-Daudé
2024-10-28 12:26   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 20/21] target/rx: " Peter Maydell
2024-10-26  4:29   ` Philippe Mathieu-Daudé
2024-10-28 12:27   ` Richard Henderson
2024-10-25 14:12 ` [PATCH 21/21] softfloat: Remove fallback rule from pickNaN() Peter Maydell
2024-10-26  4:31   ` Philippe Mathieu-Daudé
2024-10-28 12:28   ` Richard Henderson
2024-10-25 14:49 ` [PATCH 00/21] softfloat: Set 2-NaN propagation rule in float_status, not at compile time Helge Deller
2024-10-25 14:59   ` Peter Maydell
2024-10-25 18:29     ` Helge Deller

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=ed9a4ac3-1b89-4ed8-9839-01df7fb4d989@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=arikalo@gmail.com \
    --cc=atar4qemu@gmail.com \
    --cc=danielhb413@gmail.com \
    --cc=david@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=gaosong@loongson.cn \
    --cc=iii@linux.ibm.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=npiggin@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shorne@gmail.com \
    --cc=thuth@redhat.com \
    --cc=ysato@users.sourceforge.jp \
    /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).