qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected
@ 2024-11-28 10:42 Peter Maydell
  2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
                   ` (24 more replies)
  0 siblings, 25 replies; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
	Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
	Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
	Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
	Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
	Max Filippov

This patchset does the same thing we already did for pickNaN() to
pickNaNMulAdd() -- it replaces the compile-time ifdef ladder that
selected target-specific NaN propagation behaviour with checking some
runtime selectable settings in the float_status.  The motivation is:
 * this will let us have multiple targets in one QEMU binary
 * the Arm FEAT_AFP architectural feature includes letting
   the guest select a NaN propagation rule at runtime
                 
The current ifdef ladder merges two different kinds of
implementation-specific behaviour:
 * handling of the (inf * zero) + NaN special case
 * selection of a NaN to propagate when more than one input is a NaN

The refactoring splits these out into two different settings, because
what a target chose for one of them isn't correlated with its
choice on the other one.

Mostly this series is not intended to have any guest visible behaviour
changes. There is one exception: the "default implementation" at the
bottom of the old ifdef ladder did not raise Invalid for the (0 * inf)
+ NaN case. This is definitely not correct, and basically any targets
using that part of the ifdef ladder had a bug because they didn't
implement their actual correct behaviour. The architectures using the
default case are i386, hppa, sh4 and tricore, and they will now raise
the Invalid exception in this case. (I checked the architecture manuals
for those architectures and they all say it should raise Invalid.)
Fixing this bug in the first patch means we don't need to have runtime
selection of a behaviour that's not actually what these targets do.
(It also means we can reorder the code to avoid calling pickNaNMulAdd()
for any target which sets default_nan_mode, as we do for pickNaN().)

The rest of the patchset is structured like the pickNaN() refactoring
-- introduce the runtime selection field in the float_status word, but
leave the ifdef ladder in place as fallback, then convert each target
one at at time.  We do the info-zero-nan setting first, then the NaN
propagation order setting.

Finally, once we're done we can remove the use_first_nan field, which
was an Xtensa-specific way to select the NaN propagation rules at
runtime.

Tested with 'make check-functional' and 'make check-avocado'
and 'make check-tcg'.

thanks
-- PMM

Peter Maydell (25):
  fpu: handle raising Invalid for infzero in pick_nan_muladd
  fpu: Check for default_nan_mode before calling pickNaNMulAdd
  softfloat: Allow runtime choice of inf * 0 + NaN result
  tests/fp: Explicitly set inf-zero-nan rule
  target/arm: Set FloatInfZeroNaNRule explicitly
  target/s390: Set FloatInfZeroNaNRule explicitly
  target/ppc: Set FloatInfZeroNaNRule explicitly
  target/mips: Set FloatInfZeroNaNRule explicitly
  target/sparc: Set FloatInfZeroNaNRule explicitly
  target/xtensa: Set FloatInfZeroNaNRule explicitly
  target/x86: Set FloatInfZeroNaNRule explicitly
  target/loongarch: Set FloatInfZeroNaNRule explicitly
  target/hppa: Set FloatInfZeroNaNRule explicitly
  softfloat: Allow runtime choice of NaN propagation for muladd
  tests/fp: Explicitly set 3-NaN propagation rule
  target/arm: Set Float3NaNPropRule explicitly
  target/loongarch: Set Float3NaNPropRule explicitly
  target/ppc: Set Float3NaNPropRule explicitly
  target/s390x: Set Float3NaNPropRule explicitly
  target/sparc: Set Float3NaNPropRule explicitly
  target/mips: Set Float3NaNPropRule explicitly
  target/xtensa: Set Float3NaNPropRule explicitly
  target/i386: Set Float3NaNPropRule explicitly
  target/hppa: Set Float3NaNPropRule explicitly
  fpu: Remove use_first_nan field from float_status

 include/fpu/softfloat-helpers.h   |  27 +++-
 include/fpu/softfloat-types.h     |  61 ++++++++-
 target/mips/fpu_helper.h          |  13 ++
 target/arm/cpu.c                  |   8 ++
 target/hppa/fpu_helper.c          |  10 ++
 target/i386/tcg/fpu_helper.c      |   9 ++
 target/loongarch/tcg/fpu_helper.c |   6 +
 target/mips/msa.c                 |   7 +
 target/ppc/cpu_init.c             |  15 +++
 target/s390x/cpu.c                |   3 +
 target/sparc/cpu.c                |   4 +
 target/xtensa/cpu.c               |   2 +
 target/xtensa/fpu_helper.c        |   3 +-
 tests/fp/fp-bench.c               |   6 +
 tests/fp/fp-test.c                |   6 +
 fpu/softfloat-parts.c.inc         |  19 ++-
 fpu/softfloat-specialize.c.inc    | 206 ++++++++----------------------
 17 files changed, 236 insertions(+), 169 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2024-11-28 17:58 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
2024-11-28 13:07   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
2024-11-28 13:09   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
2024-11-28 13:26   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
2024-11-28 13:26   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
2024-11-28 13:27   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
2024-11-28 13:28   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
2024-11-28 13:28   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
2024-11-28 13:29   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
2024-11-28 13:30   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
2024-11-28 13:30   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
2024-11-28 14:04   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
2024-11-28 14:09   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
2024-11-28 14:10   ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
2024-11-28 17:49   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
2024-11-28 17:49   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
2024-11-28 17:51   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
2024-11-28 17:52   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
2024-11-28 17:53   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
2024-11-28 17:53   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
2024-11-28 17:53   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
2024-11-28 17:54   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
2024-11-28 17:55   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
2024-11-28 17:56   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
2024-11-28 17:57   ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
2024-11-28 17:58   ` Richard Henderson

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).