diff mbox

[09/20] softfloat-native: add float*_is_any_nan() functions

Message ID 1303160412-8107-10-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno April 18, 2011, 9 p.m. UTC
Add float*_is_any_nan() functions to match the softfloat API.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 fpu/softfloat-native.c |   26 ++++++++++++++++++++++++++
 fpu/softfloat-native.h |    3 +++
 2 files changed, 29 insertions(+), 0 deletions(-)

Comments

Peter Maydell April 19, 2011, 12:42 p.m. UTC | #1
On 18 April 2011 22:00, Aurelien Jarno <aurelien@aurel32.net> wrote:

> @@ -511,4 +530,11 @@ int floatx80_is_quiet_nan( floatx80 a1 )
>     return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (uint64_t) ( u.i.low<<1 );
>  }
>
> +int floatx80_is_any_nan( floatx80 a1 )
> +{
> +    floatx80u u;
> +    u.f = a1;
> +    return ((u.i.high & 0x7FFF) == 0x7FFF) && ( u.i.low<<1 );
> +}
> +
>  #endif

As you can just see from the context, the new function is
actually identical to the existing floatx80_is_quiet_nan(),
but the latter is wrong, not this patch :-)

Nobody seems to use floatx80_is_quiet_nan() so if we're just
going to nuke softfloat-native shortly there's no point fixing
it I guess.

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

-- PMM
Aurelien Jarno April 20, 2011, 9:22 a.m. UTC | #2
On Tue, Apr 19, 2011 at 01:42:00PM +0100, Peter Maydell wrote:
> On 18 April 2011 22:00, Aurelien Jarno <aurelien@aurel32.net> wrote:
> 
> > @@ -511,4 +530,11 @@ int floatx80_is_quiet_nan( floatx80 a1 )
> >     return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (uint64_t) ( u.i.low<<1 );
> >  }
> >
> > +int floatx80_is_any_nan( floatx80 a1 )
> > +{
> > +    floatx80u u;
> > +    u.f = a1;
> > +    return ((u.i.high & 0x7FFF) == 0x7FFF) && ( u.i.low<<1 );
> > +}
> > +
> >  #endif
> 
> As you can just see from the context, the new function is
> actually identical to the existing floatx80_is_quiet_nan(),
> but the latter is wrong, not this patch :-)
> 
> Nobody seems to use floatx80_is_quiet_nan() so if we're just
> going to nuke softfloat-native shortly there's no point fixing
> it I guess.
> 

IIRC, we already discovered that when changing the name of the nan()
functions. I also don't plan to fix it, it's one more reason to kill
softfloat-native.
diff mbox

Patch

diff --git a/fpu/softfloat-native.c b/fpu/softfloat-native.c
index 50355a4..8848651 100644
--- a/fpu/softfloat-native.c
+++ b/fpu/softfloat-native.c
@@ -263,6 +263,15 @@  int float32_is_quiet_nan( float32 a1 )
     return ( 0xFF800000 < ( a<<1 ) );
 }
 
+int float32_is_any_nan( float32 a1 )
+{
+    float32u u;
+    uint32_t a;
+    u.f = a1;
+    a = u.i;
+    return (a & ~(1 << 31)) > 0x7f800000U;
+}
+
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE double-precision conversion routines.
 *----------------------------------------------------------------------------*/
@@ -422,6 +431,16 @@  int float64_is_quiet_nan( float64 a1 )
 
 }
 
+int float64_is_any_nan( float64 a1 )
+{
+    float64u u;
+    uint64_t a;
+    u.f = a1;
+    a = u.i;
+
+    return (a & ~(1ULL << 63)) > LIT64 (0x7FF0000000000000 );
+}
+
 #ifdef FLOATX80
 
 /*----------------------------------------------------------------------------
@@ -511,4 +530,11 @@  int floatx80_is_quiet_nan( floatx80 a1 )
     return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (uint64_t) ( u.i.low<<1 );
 }
 
+int floatx80_is_any_nan( floatx80 a1 )
+{
+    floatx80u u;
+    u.f = a1;
+    return ((u.i.high & 0x7FFF) == 0x7FFF) && ( u.i.low<<1 );
+}
+
 #endif
diff --git a/fpu/softfloat-native.h b/fpu/softfloat-native.h
index f497e64..6afb74a 100644
--- a/fpu/softfloat-native.h
+++ b/fpu/softfloat-native.h
@@ -255,6 +255,7 @@  int float32_compare( float32, float32 STATUS_PARAM );
 int float32_compare_quiet( float32, float32 STATUS_PARAM );
 int float32_is_signaling_nan( float32 );
 int float32_is_quiet_nan( float32 );
+int float32_is_any_nan( float32 );
 
 INLINE float32 float32_abs(float32 a)
 {
@@ -375,6 +376,7 @@  INLINE int float64_unordered_quiet( float64 a, float64 b STATUS_PARAM)
 int float64_compare( float64, float64 STATUS_PARAM );
 int float64_compare_quiet( float64, float64 STATUS_PARAM );
 int float64_is_signaling_nan( float64 );
+int float64_is_any_nan( float64 );
 int float64_is_quiet_nan( float64 );
 
 INLINE float64 float64_abs(float64 a)
@@ -492,6 +494,7 @@  int floatx80_compare( floatx80, floatx80 STATUS_PARAM );
 int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
 int floatx80_is_signaling_nan( floatx80 );
 int floatx80_is_quiet_nan( floatx80 );
+int floatx80_is_any_nan( floatx80 );
 
 INLINE floatx80 floatx80_abs(floatx80 a)
 {