[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/21] fpu/softfloat: Add LoongArch specializations for pickNaN*
From: |
Richard Henderson |
Subject: |
[PULL 08/21] fpu/softfloat: Add LoongArch specializations for pickNaN* |
Date: |
Tue, 19 Jul 2022 23:29:47 +0530 |
From: Song Gao <gaosong@loongson.cn>
The muladd (inf,zero,nan) case sets InvalidOp and returns the
input value 'c', and prefer sNaN over qNaN, in c,a,b order.
Binary operations prefer sNaN over qNaN and a,b order.
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20220716085426.3098060-3-gaosong@loongson.cn>
[rth: Add specialization for pickNaN]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat-specialize.c.inc | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 943e3301d2..9096fb302b 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -390,7 +390,8 @@ bool float32_is_signaling_nan(float32 a_, float_status
*status)
static int pickNaN(FloatClass a_cls, FloatClass b_cls,
bool aIsLargerSignificand, float_status *status)
{
-#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA)
+#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) \
+ || defined(TARGET_LOONGARCH64)
/* ARM mandated NaN propagation rules (see FPProcessNaNs()), take
* the first of:
* 1. A if it is signaling
@@ -574,6 +575,29 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass
b_cls, FloatClass c_cls,
return 1;
}
}
+#elif defined(TARGET_LOONGARCH64)
+ /*
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'
+ */
+ if (infzero) {
+ float_raise(float_flag_invalid | float_flag_invalid_imz, status);
+ return 2;
+ }
+ /* Prefer sNaN over qNaN, in the c, a, b order. */
+ if (is_snan(c_cls)) {
+ return 2;
+ } else if (is_snan(a_cls)) {
+ return 0;
+ } else if (is_snan(b_cls)) {
+ return 1;
+ } else if (is_qnan(c_cls)) {
+ return 2;
+ } else if (is_qnan(a_cls)) {
+ return 0;
+ } else {
+ return 1;
+ }
#elif defined(TARGET_PPC)
/* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
* to return an input NaN if we have one (ie c) rather than generating
--
2.34.1
- [PULL 00/21] loongarch patch queue, Richard Henderson, 2022/07/19
- [PULL 01/21] tests/docker/dockerfiles: Add debian-loongarch-cross.docker, Richard Henderson, 2022/07/19
- [PULL 02/21] target/loongarch: Fix loongarch_cpu_class_by_name, Richard Henderson, 2022/07/19
- [PULL 03/21] hw/intc/loongarch_pch_pic: Fix bugs for update_irq function, Richard Henderson, 2022/07/19
- [PULL 04/21] target/loongarch/cpu: Fix coverity errors about excp_names, Richard Henderson, 2022/07/19
- [PULL 05/21] target/loongarch/tlb_helper: Fix coverity integer overflow error, Richard Henderson, 2022/07/19
- [PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error, Richard Henderson, 2022/07/19
- [PULL 07/21] target/loongarch/cpu: Fix cpucfg default value, Richard Henderson, 2022/07/19
- [PULL 08/21] fpu/softfloat: Add LoongArch specializations for pickNaN*,
Richard Henderson <=
- [PULL 09/21] target/loongarch: Fix float_convd/float_convs test failing, Richard Henderson, 2022/07/19
- [PULL 11/21] tests/tcg/loongarch64: Add clo related instructions test, Richard Henderson, 2022/07/19
- [PULL 10/21] tests/tcg/loongarch64: Add float reference files, Richard Henderson, 2022/07/19
- [PULL 12/21] tests/tcg/loongarch64: Add div and mod related instructions test, Richard Henderson, 2022/07/19
- [PULL 13/21] tests/tcg/loongarch64: Add fclass test, Richard Henderson, 2022/07/19
- [PULL 14/21] tests/tcg/loongarch64: Add fp comparison instructions test, Richard Henderson, 2022/07/19
- [PULL 16/21] hw/loongarch: Add fw_cfg table support, Richard Henderson, 2022/07/19
- [PULL 17/21] hw/loongarch: Add uefi bios loading support, Richard Henderson, 2022/07/19
- [PULL 15/21] tests/tcg/loongarch64: Add pcadd related instructions test, Richard Henderson, 2022/07/19
- [PULL 18/21] hw/loongarch: Add linux kernel booting support, Richard Henderson, 2022/07/19