From facbc9ef66dd34edb473201edb9abfc9ca0db40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 8 Mar 2018 10:00:23 -0500 Subject: [PATCH] include/fpu/softfloat: implement float16_abs helper This will be required when expanding the MINMAX() macro for 16 bit/half-precision operations. Backports commit 28136775cd99c628f7d7c642b04eb87f062efef8 from qemu --- qemu/include/fpu/softfloat.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qemu/include/fpu/softfloat.h b/qemu/include/fpu/softfloat.h index ab9ae929..989a9072 100644 --- a/qemu/include/fpu/softfloat.h +++ b/qemu/include/fpu/softfloat.h @@ -252,6 +252,14 @@ static inline int float16_is_any_nan(float16 a) return ((float16_val(a) & ~0x8000) > 0x7c00); } +static inline float16 float16_abs(float16 a) +{ + /* Note that abs does *not* handle NaN specially, nor does + * it flush denormal inputs to zero. + */ + return make_float16(float16_val(a) & 0x7fff); +} + /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/