diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2017-07-03 14:33:08 +0100 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2018-02-21 10:20:26 +0000 |
commit | 28136775cd99c628f7d7c642b04eb87f062efef8 (patch) | |
tree | 2b1a6cb1ea585ea00beb9378fee5dc96eb79799b /include/fpu | |
parent | 24f91e81b65fcdd0552d1f0fcb0ea7cfe3829c19 (diff) |
include/fpu/softfloat: implement float16_abs helper
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>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/fpu')
-rw-r--r-- | include/fpu/softfloat.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index f3b9008f78..1d34f2c3eb 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -265,6 +265,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. *----------------------------------------------------------------------------*/ |