[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/22] fpu/softfloat: implement float16_squash_input_
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PULL 01/22] fpu/softfloat: implement float16_squash_input_denormal |
Date: |
Wed, 21 Feb 2018 11:05:01 +0000 |
This will be required when expanding the MINMAX() macro for 16
bit/half-precision operations.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 433c5dad2d..3a4ab1355f 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3488,6 +3488,21 @@ static float16 roundAndPackFloat16(flag zSign, int zExp,
return packFloat16(zSign, zExp, zSig >> 13);
}
+/*----------------------------------------------------------------------------
+| If `a' is denormal and we are in flush-to-zero mode then set the
+| input-denormal exception and return zero. Otherwise just return the value.
+*----------------------------------------------------------------------------*/
+float16 float16_squash_input_denormal(float16 a, float_status *status)
+{
+ if (status->flush_inputs_to_zero) {
+ if (extractFloat16Exp(a) == 0 && extractFloat16Frac(a) != 0) {
+ float_raise(float_flag_input_denormal, status);
+ return make_float16(float16_val(a) & 0x8000);
+ }
+ }
+ return a;
+}
+
static void normalizeFloat16Subnormal(uint32_t aSig, int *zExpPtr,
uint32_t *zSigPtr)
{
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 0f96a0edd1..d5e99667b6 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -277,6 +277,7 @@ void float_raise(uint8_t flags, float_status *status);
| If `a' is denormal and we are in flush-to-zero mode then set the
| input-denormal exception and return zero. Otherwise just return the value.
*----------------------------------------------------------------------------*/
+float16 float16_squash_input_denormal(float16 a, float_status *status);
float32 float32_squash_input_denormal(float32 a, float_status *status);
float64 float64_squash_input_denormal(float64 a, float_status *status);
--
2.15.1
- [Qemu-devel] [PULL 00/22] re-factor softfloat and add fp16 functions, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 01/22] fpu/softfloat: implement float16_squash_input_denormal,
Alex Bennée <=
- [Qemu-devel] [PULL 03/22] fpu/softfloat-types: new header to prevent excessive re-builds, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 02/22] include/fpu/softfloat: remove USE_SOFTFLOAT_STRUCT_TYPES, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 06/22] include/fpu/softfloat: implement float16_chs helper, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 05/22] include/fpu/softfloat: implement float16_abs helper, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 07/22] include/fpu/softfloat: implement float16_set_sign helper, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 10/22] fpu/softfloat: move the extract functions to the top of the file, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 04/22] target/*/cpu.h: remove softfloat.h, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 19/22] fpu/softfloat: re-factor scalbn, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 08/22] include/fpu/softfloat: add some float16 constants, Alex Bennée, 2018/02/21
- [Qemu-devel] [PULL 09/22] fpu/softfloat: improve comments on ARM NaN propagation, Alex Bennée, 2018/02/21