From bb4d4bb376c6ae4d2dfa6e59dfa4e87a75d3a672 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 10 Feb 2011 11:28:56 +0000 Subject: softfloat: Add float16 type and float16 NaN handling functions Add a float16 type to softfloat, rather than using bits16 directly. Also add the missing functions float16_is_quiet_nan(), float16_is_signaling_nan() and float16_maybe_silence_nan(), which are needed for the float16 conversion routines. Signed-off-by: Peter Maydell Signed-off-by: Aurelien Jarno --- fpu/softfloat.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'fpu/softfloat.h') diff --git a/fpu/softfloat.h b/fpu/softfloat.h index 4a5345ceca..2296adb4c6 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -119,6 +119,11 @@ enum { x86/gcc 3.x seems to struggle a bit, so leave them disabled by default. */ //#define USE_SOFTFLOAT_STRUCT_TYPES #ifdef USE_SOFTFLOAT_STRUCT_TYPES +typedef struct { + uint16_t v; +} float16; +#define float16_val(x) (((float16)(x)).v) +#define make_float16(x) __extension__ ({ float16 f16_val = {x}; f16_val; }) typedef struct { uint32_t v; } float32; @@ -131,10 +136,13 @@ typedef struct { #define float64_val(x) (((float64)(x)).v) #define make_float64(x) __extension__ ({ float64 f64_val = {x}; f64_val; }) #else +typedef uint16_t float16; typedef uint32_t float32; typedef uint64_t float64; +#define float16_val(x) (x) #define float32_val(x) (x) #define float64_val(x) (x) +#define make_float16(x) (x) #define make_float32(x) (x) #define make_float64(x) (x) #endif @@ -253,8 +261,15 @@ float128 int64_to_float128( int64_t STATUS_PARAM ); /*---------------------------------------------------------------------------- | Software half-precision conversion routines. *----------------------------------------------------------------------------*/ -bits16 float32_to_float16( float32, flag STATUS_PARAM ); -float32 float16_to_float32( bits16, flag STATUS_PARAM ); +float16 float32_to_float16( float32, flag STATUS_PARAM ); +float32 float16_to_float32( float16, flag STATUS_PARAM ); + +/*---------------------------------------------------------------------------- +| Software half-precision operations. +*----------------------------------------------------------------------------*/ +int float16_is_quiet_nan( float16 ); +int float16_is_signaling_nan( float16 ); +float16 float16_maybe_silence_nan( float16 ); /*---------------------------------------------------------------------------- | Software IEC/IEEE single-precision conversion routines. -- cgit v1.2.3-55-g7522