softfloat: expand out STATUS macro

Expand out and remove the STATUS macro.

Backports commit a2f2d288b5a06e6c680c387c9980d91363f59c61 from qemu
This commit is contained in:
Peter Maydell 2018-02-12 13:40:41 -05:00 committed by Lioncash
parent 48e9546efc
commit 997ca2f6ea
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7
3 changed files with 121 additions and 121 deletions

View File

@ -172,7 +172,7 @@ const float128 float128_default_nan
void float_raise( int8 flags, float_status *status)
{
STATUS(float_exception_flags) |= flags;
status->float_exception_flags |= flags;
}
/*----------------------------------------------------------------------------
@ -275,7 +275,7 @@ static float16 commonNaNToFloat16(commonNaNT a, float_status *status)
{
uint16_t mantissa = a.high>>54;
if (STATUS(default_nan_mode)) {
if (status->default_nan_mode) {
return float16_default_nan;
}
@ -380,7 +380,7 @@ static float32 commonNaNToFloat32( commonNaNT a, float_status *status)
{
uint32_t mantissa = a.high>>41;
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
return float32_default_nan;
}
@ -629,8 +629,9 @@ static float32 propagateFloat32NaN( float32 a, float32 b, float_status *status)
float_raise(float_flag_invalid, status);
}
if ( STATUS(default_nan_mode) )
if (status->default_nan_mode) {
return float32_default_nan;
}
if ((uint32_t)(av<<1) < (uint32_t)(bv<<1)) {
aIsLargerSignificand = 0;
@ -679,7 +680,7 @@ static float32 propagateFloat32MulAddNaN(float32 a, float32 b,
bIsQuietNaN, bIsSignalingNaN,
cIsQuietNaN, cIsSignalingNaN, infzero, status);
if (STATUS(default_nan_mode)) {
if (status->default_nan_mode) {
/* Note that this check is after pickNaNMulAdd so that function
* has an opportunity to set the Invalid flag.
*/
@ -795,7 +796,7 @@ static float64 commonNaNToFloat64( commonNaNT a, float_status *status)
{
uint64_t mantissa = a.high>>12;
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
return float64_default_nan;
}
@ -831,8 +832,9 @@ static float64 propagateFloat64NaN( float64 a, float64 b, float_status *status)
float_raise(float_flag_invalid, status);
}
if ( STATUS(default_nan_mode) )
if (status->default_nan_mode) {
return float64_default_nan;
}
if ((uint64_t)(av<<1) < (uint64_t)(bv<<1)) {
aIsLargerSignificand = 0;
@ -881,7 +883,7 @@ static float64 propagateFloat64MulAddNaN(float64 a, float64 b,
bIsQuietNaN, bIsSignalingNaN,
cIsQuietNaN, cIsSignalingNaN, infzero, status);
if (STATUS(default_nan_mode)) {
if (status->default_nan_mode) {
/* Note that this check is after pickNaNMulAdd so that function
* has an opportunity to set the Invalid flag.
*/
@ -1013,7 +1015,7 @@ static floatx80 commonNaNToFloatx80( commonNaNT a, float_status *status)
{
floatx80 z;
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
z.low = floatx80_default_nan_low;
z.high = floatx80_default_nan_high;
return z;
@ -1050,7 +1052,7 @@ static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b, float_status *stat
float_raise(float_flag_invalid, status);
}
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
a.low = floatx80_default_nan_low;
a.high = floatx80_default_nan_high;
return a;
@ -1169,7 +1171,7 @@ static float128 commonNaNToFloat128( commonNaNT a, float_status *status)
{
float128 z;
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
z.low = float128_default_nan_low;
z.high = float128_default_nan_high;
return z;
@ -1200,7 +1202,7 @@ static float128 propagateFloat128NaN( float128 a, float128 b, float_status *stat
float_raise(float_flag_invalid, status);
}
if ( STATUS(default_nan_mode) ) {
if ( status->default_nan_mode) {
a.low = float128_default_nan_low;
a.high = float128_default_nan_high;
return a;

View File

@ -151,7 +151,7 @@ static int32 roundAndPackInt32( flag zSign, uint64_t absZ, float_status *status)
int8 roundIncrement, roundBits;
int32_t z;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
switch (roundingMode) {
case float_round_nearest_even:
@ -179,7 +179,7 @@ static int32 roundAndPackInt32( flag zSign, uint64_t absZ, float_status *status)
float_raise( float_flag_invalid, status);
return zSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundBits ) status->float_exception_flags |= float_flag_inexact;
return z;
}
@ -202,7 +202,7 @@ static int64 roundAndPackInt64( flag zSign, uint64_t absZ0, uint64_t absZ1, floa
flag roundNearestEven, increment;
int64_t z;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
switch (roundingMode) {
case float_round_nearest_even:
@ -235,7 +235,7 @@ static int64 roundAndPackInt64( flag zSign, uint64_t absZ0, uint64_t absZ1, floa
zSign ? (int64_t) LIT64( 0x8000000000000000 )
: LIT64( 0x7FFFFFFFFFFFFFFF );
}
if ( absZ1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( absZ1 ) status->float_exception_flags |= float_flag_inexact;
return z;
}
@ -256,7 +256,7 @@ static int64 roundAndPackUint64(flag zSign, uint64_t absZ0,
int8 roundingMode;
flag roundNearestEven, increment;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = (roundingMode == float_round_nearest_even);
switch (roundingMode) {
case float_round_nearest_even:
@ -290,7 +290,7 @@ static int64 roundAndPackUint64(flag zSign, uint64_t absZ0,
}
if (absZ1) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return absZ0;
}
@ -334,7 +334,7 @@ static inline flag extractFloat32Sign( float32 a )
*----------------------------------------------------------------------------*/
float32 float32_squash_input_denormal(float32 a, float_status *status)
{
if (STATUS(flush_inputs_to_zero)) {
if (status->flush_inputs_to_zero) {
if (extractFloat32Exp(a) == 0 && extractFloat32Frac(a) != 0) {
float_raise(float_flag_input_denormal, status);
return make_float32(float32_val(a) & 0x80000000);
@ -409,7 +409,7 @@ static float32 roundAndPackFloat32(flag zSign, int_fast16_t zExp, uint32_t zSig,
int8 roundIncrement, roundBits;
flag isTiny;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
switch (roundingMode) {
case float_round_nearest_even:
@ -439,12 +439,12 @@ static float32 roundAndPackFloat32(flag zSign, int_fast16_t zExp, uint32_t zSig,
return packFloat32( zSign, 0xFF, - ( roundIncrement == 0 ));
}
if ( zExp < 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloat32(zSign, 0, 0);
}
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
( status->float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
|| ( zSig + roundIncrement < 0x80000000 );
shift32RightJamming( zSig, - zExp, &zSig );
@ -455,7 +455,7 @@ static float32 roundAndPackFloat32(flag zSign, int_fast16_t zExp, uint32_t zSig,
}
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundBits ) status->float_exception_flags |= float_flag_inexact;
zSig = ( zSig + roundIncrement )>>7;
zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
if ( zSig == 0 ) zExp = 0;
@ -521,7 +521,7 @@ static inline flag extractFloat64Sign( float64 a )
*----------------------------------------------------------------------------*/
float64 float64_squash_input_denormal(float64 a, float_status *status)
{
if (STATUS(flush_inputs_to_zero)) {
if (status->flush_inputs_to_zero) {
if (extractFloat64Exp(a) == 0 && extractFloat64Frac(a) != 0) {
float_raise(float_flag_input_denormal, status);
return make_float64(float64_val(a) & (1ULL << 63));
@ -596,7 +596,7 @@ static float64 roundAndPackFloat64(flag zSign, int_fast16_t zExp, uint64_t zSig,
int_fast16_t roundIncrement, roundBits;
flag isTiny;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
switch (roundingMode) {
case float_round_nearest_even:
@ -625,12 +625,12 @@ static float64 roundAndPackFloat64(flag zSign, int_fast16_t zExp, uint64_t zSig,
return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 ));
}
if ( zExp < 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloat64(zSign, 0, 0);
}
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
( status->float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
|| ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );
shift64RightJamming( zSig, - zExp, &zSig );
@ -641,7 +641,7 @@ static float64 roundAndPackFloat64(flag zSign, int_fast16_t zExp, uint64_t zSig,
}
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundBits ) status->float_exception_flags |= float_flag_inexact;
zSig = ( zSig + roundIncrement )>>10;
zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
if ( zSig == 0 ) zExp = 0;
@ -770,7 +770,7 @@ static floatx80
flag roundNearestEven, increment, isTiny;
int64 roundIncrement, roundMask, roundBits;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
@ -809,12 +809,12 @@ static floatx80
goto overflow;
}
if ( zExp <= 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloatx80(zSign, 0, 0);
}
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
( status->float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ( zSig0 <= zSig0 + roundIncrement );
shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
@ -823,7 +823,7 @@ static floatx80
if (isTiny && roundBits) {
float_raise(float_flag_underflow, status);
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundBits ) status->float_exception_flags |= float_flag_inexact;
zSig0 += roundIncrement;
if ( (int64_t) zSig0 < 0 ) zExp = 1;
roundIncrement = roundMask + 1;
@ -834,7 +834,7 @@ static floatx80
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundBits ) status->float_exception_flags |= float_flag_inexact;
zSig0 += roundIncrement;
if ( zSig0 < (uint64_t)roundIncrement ) {
++zExp;
@ -885,7 +885,7 @@ static floatx80
}
if ( zExp <= 0 ) {
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
( status->float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ! increment
|| ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
@ -894,7 +894,7 @@ static floatx80
if (isTiny && zSig1) {
float_raise(float_flag_underflow, status);
}
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( zSig1 ) status->float_exception_flags |= float_flag_inexact;
switch (roundingMode) {
case float_round_nearest_even:
case float_round_ties_away:
@ -921,7 +921,7 @@ static floatx80
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( zSig1 ) status->float_exception_flags |= float_flag_inexact;
if ( increment ) {
++zSig0;
if ( zSig0 == 0 ) {
@ -1108,7 +1108,7 @@ static float128
int8 roundingMode;
flag roundNearestEven, increment, isTiny;
roundingMode = STATUS(float_rounding_mode);
roundingMode = status->float_rounding_mode;
roundNearestEven = ( roundingMode == float_round_nearest_even );
switch (roundingMode) {
case float_round_nearest_even:
@ -1155,12 +1155,12 @@ static float128
return packFloat128( zSign, 0x7FFF, 0, 0 );
}
if ( zExp < 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloat128(zSign, 0, 0, 0);
}
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
( status->float_detect_tininess == float_tininess_before_rounding )
|| ( zExp < -1 )
|| ! increment
|| lt128(
@ -1194,7 +1194,7 @@ static float128
}
}
}
if ( zSig2 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( zSig2 ) status->float_exception_flags |= float_flag_inexact;
if ( increment ) {
add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
@ -1566,13 +1566,13 @@ int32 float32_to_int32_round_to_zero( float32 a, float_status *status)
return (int32_t) 0x80000000;
}
else if ( aExp <= 0x7E ) {
if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( aExp | aSig ) status->float_exception_flags |= float_flag_inexact;
return 0;
}
aSig = ( aSig | 0x00800000 )<<8;
z = aSig>>( - shiftCount );
if ( (uint32_t) ( aSig<<( shiftCount & 31 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
if ( aSign ) z = - z;
return z;
@ -1611,7 +1611,7 @@ int_fast16_t float32_to_int16_round_to_zero(float32 a, float_status *status)
}
else if ( aExp <= 0x7E ) {
if ( aExp | aSig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
@ -1619,7 +1619,7 @@ int_fast16_t float32_to_int16_round_to_zero(float32 a, float_status *status)
aSig = ( aSig | 0x00800000 )<<8;
z = aSig>>( - shiftCount );
if ( (uint32_t) ( aSig<<( shiftCount & 31 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
if ( aSign ) {
z = - z;
@ -1725,7 +1725,7 @@ uint64 float32_to_uint64(float32 a, float_status *status)
uint64 float32_to_uint64_round_to_zero(float32 a, float_status *status)
{
int64_t v;
signed char current_rounding_mode = STATUS(float_rounding_mode);
signed char current_rounding_mode = status->float_rounding_mode;
set_float_rounding_mode(float_round_to_zero, status);
v = float32_to_uint64(a, status);
set_float_rounding_mode(current_rounding_mode, status);
@ -1765,14 +1765,14 @@ int64 float32_to_int64_round_to_zero( float32 a, float_status *status)
return (int64_t) LIT64( 0x8000000000000000 );
}
else if ( aExp <= 0x7E ) {
if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( aExp | aSig ) status->float_exception_flags |= float_flag_inexact;
return 0;
}
aSig64 = aSig | 0x00800000;
aSig64 <<= 40;
z = aSig64>>( - shiftCount );
if ( (uint64_t) ( aSig64<<( shiftCount & 63 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
if ( aSign ) z = - z;
return z;
@ -1899,9 +1899,9 @@ float32 float32_round_to_int( float32 a, float_status *status)
}
if ( aExp <= 0x7E ) {
if ( (uint32_t) ( float32_val(a)<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
aSign = extractFloat32Sign( a );
switch ( STATUS(float_rounding_mode) ) {
switch ( status->float_rounding_mode ) {
case float_round_nearest_even:
if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
return packFloat32( aSign, 0x7F, 0 );
@ -1923,7 +1923,7 @@ float32 float32_round_to_int( float32 a, float_status *status)
lastBitMask <<= 0x96 - aExp;
roundBitsMask = lastBitMask - 1;
z = float32_val(a);
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
z += lastBitMask>>1;
if ((z & roundBitsMask) == 0) {
@ -1949,7 +1949,7 @@ float32 float32_round_to_int( float32 a, float_status *status)
abort();
}
z &= ~ roundBitsMask;
if ( z != float32_val(a) ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( z != float32_val(a) ) status->float_exception_flags |= float_flag_inexact;
return make_float32(z);
}
@ -2015,7 +2015,7 @@ static float32 addFloat32Sigs( float32 a, float32 b, flag zSign, float_status *s
return a;
}
if ( aExp == 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
if (aSig | bSig) {
float_raise(float_flag_output_denormal, status);
}
@ -2075,7 +2075,7 @@ static float32 subFloat32Sigs( float32 a, float32 b, flag zSign, float_status *s
}
if ( bSig < aSig ) goto aBigger;
if ( aSig < bSig ) goto bBigger;
return packFloat32( STATUS(float_rounding_mode) == float_round_down, 0, 0 );
return packFloat32( status->float_rounding_mode == float_round_down, 0, 0 );
bExpBigger:
if ( bExp == 0xFF ) {
if (bSig) {
@ -2490,7 +2490,7 @@ float32 float32_muladd(float32 a, float32 b, float32 c, int flags, float_status
/* Adding two exact zeroes */
if (pSign == cSign) {
zSign = pSign;
} else if (STATUS(float_rounding_mode) == float_round_down) {
} else if (status->float_rounding_mode == float_round_down) {
zSign = 1;
} else {
zSign = 0;
@ -2498,7 +2498,7 @@ float32 float32_muladd(float32 a, float32 b, float32 c, int flags, float_status
return packFloat32(zSign ^ signflip, 0, 0);
}
/* Exact zero plus a denorm */
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloat32(cSign ^ signflip, 0, 0);
}
@ -2606,7 +2606,7 @@ float32 float32_muladd(float32 a, float32 b, float32 c, int flags, float_status
} else {
/* Exact zero */
zSign = signflip;
if (STATUS(float_rounding_mode) == float_round_down) {
if (status->float_rounding_mode == float_round_down) {
zSign ^= 1;
}
return packFloat32(zSign, 0, 0);
@ -3083,7 +3083,7 @@ int32 float64_to_int32_round_to_zero( float64 a, float_status *status )
}
else if ( aExp < 0x3FF ) {
if (aExp || aSig) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
@ -3099,7 +3099,7 @@ int32 float64_to_int32_round_to_zero( float64 a, float_status *status )
return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( ( aSig<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
@ -3133,7 +3133,7 @@ int_fast16_t float64_to_int16_round_to_zero(float64 a, float_status *status)
}
else if ( aExp < 0x3FF ) {
if (aExp || aSig) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
@ -3151,7 +3151,7 @@ int_fast16_t float64_to_int16_round_to_zero(float64 a, float_status *status)
return aSign ? (int32_t) 0xffff8000 : 0x7FFF;
}
if ( ( aSig<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
}
@ -3240,13 +3240,13 @@ int64 float64_to_int64_round_to_zero( float64 a, float_status *status )
else {
if ( aExp < 0x3FE ) {
if (aExp | aSig) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
z = aSig>>( - shiftCount );
if ( (uint64_t) ( aSig<<( shiftCount & 63 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
}
if ( aSign ) z = - z;
@ -3356,7 +3356,7 @@ static float32 roundAndPackFloat16(flag zSign, int_fast16_t zExp,
mask = 0x00001fff;
}
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
increment = (mask + 1) >> 1;
if ((zSig & mask) == increment) {
@ -3392,7 +3392,7 @@ static float32 roundAndPackFloat16(flag zSign, int_fast16_t zExp,
if (zExp < 0) {
/* Note that flush-to-zero does not affect half-precision results */
is_tiny =
(STATUS(float_detect_tininess) == float_tininess_before_rounding)
(status->float_detect_tininess == float_tininess_before_rounding)
|| (zExp < -1)
|| (!rounding_bumps_exp);
}
@ -3666,9 +3666,9 @@ float64 float64_round_to_int( float64 a, float_status *status )
}
if ( aExp < 0x3FF ) {
if ( (uint64_t) ( float64_val(a)<<1 ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
aSign = extractFloat64Sign( a );
switch ( STATUS(float_rounding_mode) ) {
switch ( status->float_rounding_mode ) {
case float_round_nearest_even:
if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) {
return packFloat64( aSign, 0x3FF, 0 );
@ -3691,7 +3691,7 @@ float64 float64_round_to_int( float64 a, float_status *status )
lastBitMask <<= 0x433 - aExp;
roundBitsMask = lastBitMask - 1;
z = float64_val(a);
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
z += lastBitMask >> 1;
if ((z & roundBitsMask) == 0) {
@ -3718,7 +3718,7 @@ float64 float64_round_to_int( float64 a, float_status *status )
}
z &= ~ roundBitsMask;
if ( z != float64_val(a) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return make_float64(z);
@ -3728,10 +3728,10 @@ float64 float64_trunc_to_int( float64 a, float_status *status)
{
int oldmode;
float64 res;
oldmode = STATUS(float_rounding_mode);
STATUS(float_rounding_mode) = float_round_to_zero;
oldmode = status->float_rounding_mode;
status->float_rounding_mode = float_round_to_zero;
res = float64_round_to_int(a, status);
STATUS(float_rounding_mode) = oldmode;
status->float_rounding_mode = oldmode;
return res;
}
@ -3796,7 +3796,7 @@ static float64 addFloat64Sigs( float64 a, float64 b, flag zSign, float_status *s
return a;
}
if ( aExp == 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
if (aSig | bSig) {
float_raise(float_flag_output_denormal, status);
}
@ -3856,7 +3856,7 @@ static float64 subFloat64Sigs( float64 a, float64 b, flag zSign, float_status *s
}
if ( bSig < aSig ) goto aBigger;
if ( aSig < bSig ) goto bBigger;
return packFloat64( STATUS(float_rounding_mode) == float_round_down, 0, 0 );
return packFloat64( status->float_rounding_mode == float_round_down, 0, 0 );
bExpBigger:
if ( bExp == 0x7FF ) {
if (bSig) {
@ -4263,7 +4263,7 @@ float64 float64_muladd(float64 a, float64 b, float64 c, int flags, float_status
/* Adding two exact zeroes */
if (pSign == cSign) {
zSign = pSign;
} else if (STATUS(float_rounding_mode) == float_round_down) {
} else if (status->float_rounding_mode == float_round_down) {
zSign = 1;
} else {
zSign = 0;
@ -4271,7 +4271,7 @@ float64 float64_muladd(float64 a, float64 b, float64 c, int flags, float_status
return packFloat64(zSign ^ signflip, 0, 0);
}
/* Exact zero plus a denorm */
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
float_raise(float_flag_output_denormal, status);
return packFloat64(cSign ^ signflip, 0, 0);
}
@ -4387,7 +4387,7 @@ float64 float64_muladd(float64 a, float64 b, float64 c, int flags, float_status
} else {
/* Exact zero */
zSign = signflip;
if (STATUS(float_rounding_mode) == float_round_down) {
if (status->float_rounding_mode == float_round_down) {
zSign ^= 1;
}
return packFloat64(zSign, 0, 0);
@ -4802,7 +4802,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a, float_status *status )
}
else if ( aExp < 0x3FFF ) {
if (aExp || aSig) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
@ -4817,7 +4817,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a, float_status *status )
return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( ( aSig<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
@ -4904,13 +4904,13 @@ int64 floatx80_to_int64_round_to_zero( floatx80 a, float_status *status )
}
else if ( aExp < 0x3FFF ) {
if (aExp | aSig) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
z = aSig>>( - shiftCount );
if ( (uint64_t) ( aSig<<( shiftCount & 63 ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
if ( aSign ) z = - z;
return z;
@ -5039,9 +5039,9 @@ floatx80 floatx80_round_to_int( floatx80 a, float_status *status )
&& ( (uint64_t) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
return a;
}
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
aSign = extractFloatx80Sign( a );
switch ( STATUS(float_rounding_mode) ) {
switch ( status->float_rounding_mode ) {
case float_round_nearest_even:
if ( ( aExp == 0x3FFE ) && (uint64_t) ( extractFloatx80Frac( a )<<1 )
) {
@ -5070,7 +5070,7 @@ floatx80 floatx80_round_to_int( floatx80 a, float_status *status )
lastBitMask <<= 0x403E - aExp;
roundBitsMask = lastBitMask - 1;
z = a;
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
z.low += lastBitMask>>1;
if ((z.low & roundBitsMask) == 0) {
@ -5101,7 +5101,7 @@ floatx80 floatx80_round_to_int( floatx80 a, float_status *status )
z.low = LIT64( 0x8000000000000000 );
}
if (z.low != a.low) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
@ -5171,7 +5171,7 @@ static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign, float_statu
roundAndPack:
return
roundAndPackFloatx80(
STATUS(floatx80_rounding_precision), zSign, zExp, zSig0, zSig1, status );
status->floatx80_rounding_precision, zSign, zExp, zSig0, zSig1, status );
}
@ -5213,7 +5213,7 @@ static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign, float_statu
zSig1 = 0;
if ( bSig < aSig ) goto aBigger;
if ( aSig < bSig ) goto bBigger;
return packFloatx80( STATUS(float_rounding_mode) == float_round_down, 0, 0 );
return packFloatx80( status->float_rounding_mode == float_round_down, 0, 0 );
bExpBigger:
if ( bExp == 0x7FFF ) {
if ( (uint64_t) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b, status );
@ -5239,7 +5239,7 @@ static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign, float_statu
normalizeRoundAndPack:
return
normalizeRoundAndPackFloatx80(
STATUS(floatx80_rounding_precision), zSign, zExp, zSig0, zSig1, status );
status->floatx80_rounding_precision, zSign, zExp, zSig0, zSig1, status );
}
@ -5352,7 +5352,7 @@ floatx80 floatx80_mul( floatx80 a, floatx80 b, float_status *status )
}
return
roundAndPackFloatx80(
STATUS(floatx80_rounding_precision), zSign, zExp, zSig0, zSig1, status );
status->floatx80_rounding_precision, zSign, zExp, zSig0, zSig1, status );
}
@ -5436,7 +5436,7 @@ floatx80 floatx80_div( floatx80 a, floatx80 b, float_status *status )
}
return
roundAndPackFloatx80(
STATUS(floatx80_rounding_precision), zSign, zExp, zSig0, zSig1, status );
status->floatx80_rounding_precision, zSign, zExp, zSig0, zSig1, status );
}
@ -5610,7 +5610,7 @@ floatx80 floatx80_sqrt( floatx80 a, float_status *status )
zSig0 |= doubleZSig0;
return
roundAndPackFloatx80(
STATUS(floatx80_rounding_precision), 0, zExp, zSig0, zSig1, status );
status->floatx80_rounding_precision, 0, zExp, zSig0, zSig1, status );
}
@ -5927,7 +5927,7 @@ int32 float128_to_int32_round_to_zero( float128 a, float_status *status )
goto invalid;
}
else if ( aExp < 0x3FFF ) {
if ( aExp || aSig0 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( aExp || aSig0 ) status->float_exception_flags |= float_flag_inexact;
return 0;
}
aSig0 |= LIT64( 0x0001000000000000 );
@ -5942,7 +5942,7 @@ int32 float128_to_int32_round_to_zero( float128 a, float_status *status )
return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( ( aSig0<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
@ -6019,7 +6019,7 @@ int64 float128_to_int64_round_to_zero( float128 a, float_status *status )
aSig0 &= LIT64( 0x0000FFFFFFFFFFFF );
if ( ( a.high == LIT64( 0xC03E000000000000 ) )
&& ( aSig1 < LIT64( 0x0002000000000000 ) ) ) {
if ( aSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( aSig1 ) status->float_exception_flags |= float_flag_inexact;
}
else {
float_raise( float_flag_invalid, status);
@ -6031,20 +6031,20 @@ int64 float128_to_int64_round_to_zero( float128 a, float_status *status )
}
z = ( aSig0<<shiftCount ) | ( aSig1>>( ( - shiftCount ) & 63 ) );
if ( (uint64_t) ( aSig1<<shiftCount ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
}
else {
if ( aExp < 0x3FFF ) {
if ( aExp | aSig0 | aSig1 ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return 0;
}
z = aSig0>>( - shiftCount );
if ( aSig1
|| ( shiftCount && (uint64_t) ( aSig0<<( shiftCount & 63 ) ) ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
}
if ( aSign ) z = - z;
@ -6183,7 +6183,7 @@ float128 float128_round_to_int( float128 a, float_status *status )
lastBitMask = ( lastBitMask<<( 0x406E - aExp ) )<<1;
roundBitsMask = lastBitMask - 1;
z = a;
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
if ( lastBitMask ) {
add128( z.high, z.low, 0, lastBitMask>>1, &z.high, &z.low );
@ -6225,9 +6225,9 @@ float128 float128_round_to_int( float128 a, float_status *status )
else {
if ( aExp < 0x3FFF ) {
if ( ( ( (uint64_t) ( a.high<<1 ) ) | a.low ) == 0 ) return a;
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
aSign = extractFloat128Sign( a );
switch ( STATUS(float_rounding_mode) ) {
switch ( status->float_rounding_mode ) {
case float_round_nearest_even:
if ( ( aExp == 0x3FFE )
&& ( extractFloat128Frac0( a )
@ -6257,7 +6257,7 @@ float128 float128_round_to_int( float128 a, float_status *status )
roundBitsMask = lastBitMask - 1;
z.low = 0;
z.high = a.high;
switch (STATUS(float_rounding_mode)) {
switch (status->float_rounding_mode) {
case float_round_nearest_even:
z.high += lastBitMask>>1;
if ( ( ( z.high & roundBitsMask ) | a.low ) == 0 ) {
@ -6287,7 +6287,7 @@ float128 float128_round_to_int( float128 a, float_status *status )
z.high &= ~ roundBitsMask;
}
if ( ( z.low != a.low ) || ( z.high != a.high ) ) {
STATUS(float_exception_flags) |= float_flag_inexact;
status->float_exception_flags |= float_flag_inexact;
}
return z;
@ -6353,7 +6353,7 @@ static float128 addFloat128Sigs( float128 a, float128 b, flag zSign, float_statu
}
add128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 );
if ( aExp == 0 ) {
if (STATUS(flush_to_zero)) {
if (status->flush_to_zero) {
if (zSig0 | zSig1) {
float_raise(float_flag_output_denormal, status);
}
@ -6422,7 +6422,7 @@ static float128 subFloat128Sigs( float128 a, float128 b, flag zSign, float_statu
if ( aSig0 < bSig0 ) goto bBigger;
if ( bSig1 < aSig1 ) goto aBigger;
if ( aSig1 < bSig1 ) goto bBigger;
return packFloat128( STATUS(float_rounding_mode) == float_round_down, 0, 0, 0 );
return packFloat128( status->float_rounding_mode == float_round_down, 0, 0, 0 );
bExpBigger:
if ( bExp == 0x7FFF ) {
if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b, status );
@ -7320,7 +7320,7 @@ uint64_t float64_to_uint64(float64 a, float_status *status)
uint64_t float64_to_uint64_round_to_zero (float64 a, float_status *status)
{
int64_t v;
signed char current_rounding_mode = STATUS(float_rounding_mode);
signed char current_rounding_mode = status->float_rounding_mode;
set_float_rounding_mode(float_round_to_zero, status);
v = float64_to_uint64(a, status);
set_float_rounding_mode(current_rounding_mode, status);
@ -7682,7 +7682,7 @@ floatx80 floatx80_scalbn( floatx80 a, int n, float_status *status )
}
aExp += n;
return normalizeRoundAndPackFloatx80( STATUS(floatx80_rounding_precision),
return normalizeRoundAndPackFloatx80( status->floatx80_rounding_precision,
aSign, aExp, aSig, 0, status );
}

View File

@ -108,8 +108,6 @@ typedef int64_t int64;
#define LIT64( a ) a##LL
#define STATUS(field) status->field
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point ordering relations
*----------------------------------------------------------------------------*/
@ -229,59 +227,59 @@ typedef struct float_status {
static inline void set_float_detect_tininess(int val, float_status *status)
{
STATUS(float_detect_tininess) = val;
status->float_detect_tininess = val;
}
static inline void set_float_rounding_mode(int val, float_status *status)
{
STATUS(float_rounding_mode) = val;
status->float_rounding_mode = val;
}
static inline void set_float_exception_flags(int val, float_status *status)
{
STATUS(float_exception_flags) = val;
status->float_exception_flags = val;
}
static inline void set_floatx80_rounding_precision(int val, float_status *status)
{
STATUS(floatx80_rounding_precision) = val;
status->floatx80_rounding_precision = val;
}
static inline void set_flush_to_zero(flag val, float_status *status)
{
STATUS(flush_to_zero) = val;
status->flush_to_zero = val;
}
static inline void set_flush_inputs_to_zero(flag val, float_status *status)
{
STATUS(flush_inputs_to_zero) = val;
status->flush_inputs_to_zero = val;
}
static inline void set_default_nan_mode(flag val, float_status *status)
{
STATUS(default_nan_mode) = val;
status->default_nan_mode = val;
}
static inline int get_float_detect_tininess(float_status *status)
{
return STATUS(float_detect_tininess);
return status->float_detect_tininess;
}
static inline int get_float_rounding_mode(float_status *status)
{
return STATUS(float_rounding_mode);
return status->float_rounding_mode;
}
static inline int get_float_exception_flags(float_status *status)
{
return STATUS(float_exception_flags);
return status->float_exception_flags;
}
static inline int get_floatx80_rounding_precision(float_status *status)
{
return STATUS(floatx80_rounding_precision);
return status->floatx80_rounding_precision;
}
static inline flag get_flush_to_zero(float_status *status)
{
return STATUS(flush_to_zero);
return status->flush_to_zero;
}
static inline flag get_flush_inputs_to_zero(float_status *status)
{
return STATUS(flush_inputs_to_zero);
return status->flush_inputs_to_zero;
}
static inline flag get_default_nan_mode(float_status *status)
{
return STATUS(default_nan_mode);
return status->default_nan_mode;
}
/*----------------------------------------------------------------------------