Skip to content

Commit

Permalink
softfloat: Rename float*_is_nan() functions to float*_is_quiet_nan()
Browse files Browse the repository at this point in the history
The softfloat functions float*_is_nan() were badly misnamed,
because they return true only for quiet NaNs, not for all NaNs.
Rename them to float*_is_quiet_nan() to more accurately reflect
what they do.

This change was produced by:
 perl -p -i -e 's/_is_nan/_is_quiet_nan/g' $(git grep -l is_nan)
(with the results manually checked.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
  • Loading branch information
pm215 authored and aurel32 committed Jan 2, 2011
1 parent f96a383 commit 1856987
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 67 deletions.
6 changes: 3 additions & 3 deletions fpu/softfloat-native.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ int float32_is_signaling_nan( float32 a1)
return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
}

int float32_is_nan( float32 a1 )
int float32_is_quiet_nan( float32 a1 )
{
float32u u;
uint64_t a;
Expand Down Expand Up @@ -411,7 +411,7 @@ int float64_is_signaling_nan( float64 a1)

}

int float64_is_nan( float64 a1 )
int float64_is_quiet_nan( float64 a1 )
{
float64u u;
uint64_t a;
Expand Down Expand Up @@ -504,7 +504,7 @@ int floatx80_is_signaling_nan( floatx80 a1)
&& ( u.i.low == aLow );
}

int floatx80_is_nan( floatx80 a1 )
int floatx80_is_quiet_nan( floatx80 a1 )
{
floatx80u u;
u.f = a1;
Expand Down
6 changes: 3 additions & 3 deletions fpu/softfloat-native.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ INLINE int float32_unordered( float32 a, float32 b STATUS_PARAM)
int float32_compare( float32, float32 STATUS_PARAM );
int float32_compare_quiet( float32, float32 STATUS_PARAM );
int float32_is_signaling_nan( float32 );
int float32_is_nan( float32 );
int float32_is_quiet_nan( float32 );

INLINE float32 float32_abs(float32 a)
{
Expand Down Expand Up @@ -351,7 +351,7 @@ INLINE int float64_unordered( 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_nan( float64 );
int float64_is_quiet_nan( float64 );

INLINE float64 float64_abs(float64 a)
{
Expand Down Expand Up @@ -455,7 +455,7 @@ INLINE int floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM)
int floatx80_compare( floatx80, floatx80 STATUS_PARAM );
int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
int floatx80_is_signaling_nan( floatx80 );
int floatx80_is_nan( floatx80 );
int floatx80_is_quiet_nan( floatx80 );

INLINE floatx80 floatx80_abs(floatx80 a)
{
Expand Down
24 changes: 12 additions & 12 deletions fpu/softfloat-specialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct {
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float32_is_nan( float32 a_ )
int float32_is_quiet_nan( float32 a_ )
{
uint32_t a = float32_val(a_);
#if SNAN_BIT_IS_ONE
Expand Down Expand Up @@ -166,9 +166,9 @@ static float32 propagateFloat32NaN( float32 a, float32 b STATUS_PARAM)
if ( STATUS(default_nan_mode) )
return float32_default_nan;

aIsNaN = float32_is_nan( a );
aIsNaN = float32_is_quiet_nan( a );
aIsSignalingNaN = float32_is_signaling_nan( a );
bIsNaN = float32_is_nan( b );
bIsNaN = float32_is_quiet_nan( b );
bIsSignalingNaN = float32_is_signaling_nan( b );
av = float32_val(a);
bv = float32_val(b);
Expand Down Expand Up @@ -223,7 +223,7 @@ static float32 propagateFloat32NaN( float32 a, float32 b STATUS_PARAM)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float64_is_nan( float64 a_ )
int float64_is_quiet_nan( float64 a_ )
{
bits64 a = float64_val(a_);
#if SNAN_BIT_IS_ONE
Expand Down Expand Up @@ -320,9 +320,9 @@ static float64 propagateFloat64NaN( float64 a, float64 b STATUS_PARAM)
if ( STATUS(default_nan_mode) )
return float64_default_nan;

aIsNaN = float64_is_nan( a );
aIsNaN = float64_is_quiet_nan( a );
aIsSignalingNaN = float64_is_signaling_nan( a );
bIsNaN = float64_is_nan( b );
bIsNaN = float64_is_quiet_nan( b );
bIsSignalingNaN = float64_is_signaling_nan( b );
av = float64_val(a);
bv = float64_val(b);
Expand Down Expand Up @@ -377,7 +377,7 @@ static float64 propagateFloat64NaN( float64 a, float64 b STATUS_PARAM)
| quiet NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int floatx80_is_nan( floatx80 a )
int floatx80_is_quiet_nan( floatx80 a )
{
#if SNAN_BIT_IS_ONE
bits64 aLow;
Expand Down Expand Up @@ -462,9 +462,9 @@ static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b STATUS_PARAM)
return a;
}

aIsNaN = floatx80_is_nan( a );
aIsNaN = floatx80_is_quiet_nan( a );
aIsSignalingNaN = floatx80_is_signaling_nan( a );
bIsNaN = floatx80_is_nan( b );
bIsNaN = floatx80_is_quiet_nan( b );
bIsSignalingNaN = floatx80_is_signaling_nan( b );
#if SNAN_BIT_IS_ONE
a.low &= ~LIT64( 0xC000000000000000 );
Expand Down Expand Up @@ -511,7 +511,7 @@ static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b STATUS_PARAM)
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/

int float128_is_nan( float128 a )
int float128_is_quiet_nan( float128 a )
{
#if SNAN_BIT_IS_ONE
return
Expand Down Expand Up @@ -588,9 +588,9 @@ static float128 propagateFloat128NaN( float128 a, float128 b STATUS_PARAM)
return a;
}

aIsNaN = float128_is_nan( a );
aIsNaN = float128_is_quiet_nan( a );
aIsSignalingNaN = float128_is_signaling_nan( a );
bIsNaN = float128_is_nan( b );
bIsNaN = float128_is_quiet_nan( b );
bIsSignalingNaN = float128_is_signaling_nan( b );
#if SNAN_BIT_IS_ONE
a.high &= ~LIT64( 0x0000800000000000 );
Expand Down
8 changes: 4 additions & 4 deletions fpu/softfloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int float32_le_quiet( float32, float32 STATUS_PARAM );
int float32_lt_quiet( float32, float32 STATUS_PARAM );
int float32_compare( float32, float32 STATUS_PARAM );
int float32_compare_quiet( float32, float32 STATUS_PARAM );
int float32_is_nan( float32 );
int float32_is_quiet_nan( float32 );
int float32_is_signaling_nan( float32 );
float32 float32_maybe_silence_nan( float32 );
float32 float32_scalbn( float32, int STATUS_PARAM );
Expand Down Expand Up @@ -367,7 +367,7 @@ int float64_le_quiet( float64, float64 STATUS_PARAM );
int float64_lt_quiet( float64, float64 STATUS_PARAM );
int float64_compare( float64, float64 STATUS_PARAM );
int float64_compare_quiet( float64, float64 STATUS_PARAM );
int float64_is_nan( float64 a );
int float64_is_quiet_nan( float64 a );
int float64_is_signaling_nan( float64 );
float64 float64_maybe_silence_nan( float64 );
float64 float64_scalbn( float64, int STATUS_PARAM );
Expand Down Expand Up @@ -437,7 +437,7 @@ int floatx80_lt( floatx80, floatx80 STATUS_PARAM );
int floatx80_eq_signaling( floatx80, floatx80 STATUS_PARAM );
int floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM );
int floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM );
int floatx80_is_nan( floatx80 );
int floatx80_is_quiet_nan( floatx80 );
int floatx80_is_signaling_nan( floatx80 );
floatx80 floatx80_scalbn( floatx80, int STATUS_PARAM );

Expand Down Expand Up @@ -503,7 +503,7 @@ int float128_le_quiet( float128, float128 STATUS_PARAM );
int float128_lt_quiet( float128, float128 STATUS_PARAM );
int float128_compare( float128, float128 STATUS_PARAM );
int float128_compare_quiet( float128, float128 STATUS_PARAM );
int float128_is_nan( float128 );
int float128_is_quiet_nan( float128 );
int float128_is_signaling_nan( float128 );
float128 float128_scalbn( float128, int STATUS_PARAM );

Expand Down
14 changes: 7 additions & 7 deletions linux-user/arm/nwfpe/fpa11_cprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,21 @@ static unsigned int PerformComparison(const unsigned int opcode)
{
case typeSingle:
//printk("single.\n");
if (float32_is_nan(fpa11->fpreg[Fn].fSingle))
if (float32_is_quiet_nan(fpa11->fpreg[Fn].fSingle))
goto unordered;
rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle, &fpa11->fp_status);
break;

case typeDouble:
//printk("double.\n");
if (float64_is_nan(fpa11->fpreg[Fn].fDouble))
if (float64_is_quiet_nan(fpa11->fpreg[Fn].fDouble))
goto unordered;
rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble, &fpa11->fp_status);
break;

case typeExtended:
//printk("extended.\n");
if (floatx80_is_nan(fpa11->fpreg[Fn].fExtended))
if (floatx80_is_quiet_nan(fpa11->fpreg[Fn].fExtended))
goto unordered;
rFn = fpa11->fpreg[Fn].fExtended;
break;
Expand All @@ -225,7 +225,7 @@ static unsigned int PerformComparison(const unsigned int opcode)
{
//printk("Fm is a constant: #%d.\n",Fm);
rFm = getExtendedConstant(Fm);
if (floatx80_is_nan(rFm))
if (floatx80_is_quiet_nan(rFm))
goto unordered;
}
else
Expand All @@ -235,21 +235,21 @@ static unsigned int PerformComparison(const unsigned int opcode)
{
case typeSingle:
//printk("single.\n");
if (float32_is_nan(fpa11->fpreg[Fm].fSingle))
if (float32_is_quiet_nan(fpa11->fpreg[Fm].fSingle))
goto unordered;
rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle, &fpa11->fp_status);
break;

case typeDouble:
//printk("double.\n");
if (float64_is_nan(fpa11->fpreg[Fm].fDouble))
if (float64_is_quiet_nan(fpa11->fpreg[Fm].fDouble))
goto unordered;
rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble, &fpa11->fp_status);
break;

case typeExtended:
//printk("extended.\n");
if (floatx80_is_nan(fpa11->fpreg[Fm].fExtended))
if (floatx80_is_quiet_nan(fpa11->fpreg[Fm].fExtended))
goto unordered;
rFm = fpa11->fpreg[Fm].fExtended;
break;
Expand Down
2 changes: 1 addition & 1 deletion target-alpha/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ uint64_t helper_cmptun (uint64_t a, uint64_t b)
fa = t_to_float64(a);
fb = t_to_float64(b);

if (float64_is_nan(fa) || float64_is_nan(fb))
if (float64_is_quiet_nan(fa) || float64_is_quiet_nan(fb))
return 0x4000000000000000ULL;
else
return 0;
Expand Down
6 changes: 3 additions & 3 deletions target-m68k/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,10 @@ float64 HELPER(sub_cmp_f64)(CPUState *env, float64 a, float64 b)
/* ??? Should flush denormals to zero. */
float64 res;
res = float64_sub(a, b, &env->fp_status);
if (float64_is_nan(res)) {
if (float64_is_quiet_nan(res)) {
/* +/-inf compares equal against itself, but sub returns nan. */
if (!float64_is_nan(a)
&& !float64_is_nan(b)) {
if (!float64_is_quiet_nan(a)
&& !float64_is_quiet_nan(b)) {
res = float64_zero;
if (float64_lt_quiet(a, res, &env->fp_status))
res = float64_chs(res);
Expand Down
2 changes: 1 addition & 1 deletion target-microblaze/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ uint32_t helper_fcmp_un(uint32_t a, uint32_t b)
r = 1;
}

if (float32_is_nan(fa.f) || float32_is_nan(fb.f)) {
if (float32_is_quiet_nan(fa.f) || float32_is_quiet_nan(fb.f)) {
r = 1;
}

Expand Down
8 changes: 4 additions & 4 deletions target-mips/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2877,10 +2877,10 @@ static int float64_is_unordered(int sig, float64 a, float64 b STATUS_PARAM)
{
if (float64_is_signaling_nan(a) ||
float64_is_signaling_nan(b) ||
(sig && (float64_is_nan(a) || float64_is_nan(b)))) {
(sig && (float64_is_quiet_nan(a) || float64_is_quiet_nan(b)))) {
float_raise(float_flag_invalid, status);
return 1;
} else if (float64_is_nan(a) || float64_is_nan(b)) {
} else if (float64_is_quiet_nan(a) || float64_is_quiet_nan(b)) {
return 1;
} else {
return 0;
Expand Down Expand Up @@ -2935,10 +2935,10 @@ static flag float32_is_unordered(int sig, float32 a, float32 b STATUS_PARAM)
{
if (float32_is_signaling_nan(a) ||
float32_is_signaling_nan(b) ||
(sig && (float32_is_nan(a) || float32_is_nan(b)))) {
(sig && (float32_is_quiet_nan(a) || float32_is_quiet_nan(b)))) {
float_raise(float_flag_invalid, status);
return 1;
} else if (float32_is_nan(a) || float32_is_nan(b)) {
} else if (float32_is_quiet_nan(a) || float32_is_quiet_nan(b)) {
return 1;
} else {
return 0;
Expand Down
Loading

0 comments on commit 1856987

Please sign in to comment.