diff mbox series

[v1,03/19] include/fpu/softfloat: implement float16_chs helper

Message ID 20171211125705.16120-4-alex.bennee@linaro.org
State Superseded
Headers show
Series re-factor softfloat and add fp16 functions | expand

Commit Message

Alex Bennée Dec. 11, 2017, 12:56 p.m. UTC
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

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

-- 
2.15.1

Comments

Richard Henderson Dec. 18, 2017, 9:41 p.m. UTC | #1
On 12/11/2017 04:56 AM, Alex Bennée wrote:
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  include/fpu/softfloat.h | 9 +++++++++

>  1 file changed, 9 insertions(+)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
diff mbox series

Patch

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index edf402d422..32036382c6 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -381,6 +381,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.
 *----------------------------------------------------------------------------*/