diff mbox series

[v2,03/20] include/fpu/softfloat: implement float16_abs helper

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

Commit Message

Alex Bennée Jan. 9, 2018, 12:22 p.m. UTC
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: Philippe Mathieu-Daudé <f4bug@amsat.org>

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

-- 
2.15.1

Comments

Peter Maydell Jan. 12, 2018, 1:42 p.m. UTC | #1
On 9 January 2018 at 12:22, Alex Bennée <alex.bennee@linaro.org> wrote:
> 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: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---

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

>  1 file changed, 7 insertions(+)

>

> diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h

> index 52af1412de..cfc615008d 100644

> --- a/include/fpu/softfloat.h

> +++ b/include/fpu/softfloat.h

> @@ -347,6 +347,13 @@ static inline int float16_is_zero_or_denormal(float16 a)

>      return (float16_val(a) & 0x7c00) == 0;

>  }

>

> +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.

>  *----------------------------------------------------------------------------*/

> --

> 2.15.1


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>


thanks
-- PMM
diff mbox series

Patch

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 52af1412de..cfc615008d 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -347,6 +347,13 @@  static inline int float16_is_zero_or_denormal(float16 a)
     return (float16_val(a) & 0x7c00) == 0;
 }
 
+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.
 *----------------------------------------------------------------------------*/