[06/24] include/fpu/softfloat: implement float16_chs helper

Message ID 20180204041136.17525-7-richard.henderson@linaro.org
State New
Headers show
Series
  • re-factor and add fp16 using glibc soft-fp
Related show

Commit Message

Richard Henderson Feb. 4, 2018, 4:11 a.m.
From: Alex Bennée <alex.bennee@linaro.org>


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>

---
 include/fpu/softfloat.h | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.14.3

Patch

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 1d34f2c3eb..f75aa59100 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -272,6 +272,15 @@  static inline float16 float16_abs(float16 a)
      */
     return make_float16(float16_val(a) & 0x7fff);
 }
+
+static inline float16 float16_chs(float16 a)
+{
+    /* Note that chs does *not* handle NaN specially, nor does
+     * it flush denormal inputs to zero.
+     */
+    return make_float16(float16_val(a) ^ 0x8000);
+}
+
 /*----------------------------------------------------------------------------
 | The pattern for a default generated half-precision NaN.
 *----------------------------------------------------------------------------*/