summaryrefslogtreecommitdiffstats
path: root/fpu
diff options
context:
space:
mode:
authorAlex Bennée2017-07-03 15:30:06 +0200
committerAlex Bennée2018-02-21 11:20:14 +0100
commit210cbd4910ae9e41e0a1785b96890ea2c291b381 (patch)
tree91c1773b4d572283cd3e3e1a20db7db7b892b9c9 /fpu
parentMerge remote-tracking branch 'remotes/kraxel/tags/ui-20180220-pull-request' i... (diff)
downloadqemu-210cbd4910ae9e41e0a1785b96890ea2c291b381.tar.gz
qemu-210cbd4910ae9e41e0a1785b96890ea2c291b381.tar.xz
qemu-210cbd4910ae9e41e0a1785b96890ea2c291b381.zip
fpu/softfloat: implement float16_squash_input_denormal
This will be required when expanding the MINMAX() macro for 16 bit/half-precision operations. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'fpu')
-rw-r--r--fpu/softfloat.c15
1 files changed, 15 insertions, 0 deletions
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)
{