]> git.ipfire.org Git - thirdparty/qemu.git/commit
softfloat: Allow runtime choice of NaN propagation for muladd
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)
commit7a944c30f72380e543b58342e12105dcf98d8496
tree49951b0341cbc0907ab481ff33a77dfb35bc80f2
parentd62c734d52147ec312d1ada0e1bc7fa479838575
softfloat: Allow runtime choice of NaN propagation for muladd

IEEE 758 does not define a fixed rule for which NaN to pick as the
result if both operands of a 3-operand fused multiply-add operation
are NaNs.  As a result different architectures have ended up with
different rules for propagating NaNs.

QEMU currently hardcodes the NaN propagation logic into the binary
because pickNaNMulAdd() has an ifdef ladder for different targets.
We want to make the propagation rule instead be selectable at
runtime, because:
 * 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

In this commit we add an enum for the propagation rule, the field in
float_status, and the corresponding getters and setters.  We change
pickNaNMulAdd to honour this, but because all targets still leave
this field at its default 0 value, the fallback logic will pick the
rule type with the old ifdef ladder.

It's valid not to set a propagation rule if default_nan_mode is
enabled, because in that case there's no need to pick a NaN; all the
callers of pickNaNMulAdd() catch this case and skip calling it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-16-peter.maydell@linaro.org
fpu/softfloat-specialize.c.inc
include/fpu/softfloat-helpers.h
include/fpu/softfloat-types.h