softfloat: Convert integer to floatx80 to FloatParts

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2020-11-21 17:40:25 -08:00
parent f9a95a7800
commit 5f9529006e

View File

@ -3345,6 +3345,19 @@ float128 int32_to_float128(int32_t a, float_status *status)
return int64_to_float128(a, status);
}
floatx80 int64_to_floatx80(int64_t a, float_status *status)
{
FloatParts128 p;
parts_sint_to_float(&p, a, 0, status);
return floatx80_round_pack_canonical(&p, status);
}
floatx80 int32_to_floatx80(int32_t a, float_status *status)
{
return int64_to_floatx80(a, status);
}
/*
* Unsigned Integer to floating-point conversions
*/
@ -5033,51 +5046,6 @@ static float128 normalizeRoundAndPackFloat128(bool zSign, int32_t zExp,
}
/*----------------------------------------------------------------------------
| Returns the result of converting the 32-bit two's complement integer `a'
| to the extended double-precision floating-point format. The conversion
| is performed according to the IEC/IEEE Standard for Binary Floating-Point
| Arithmetic.
*----------------------------------------------------------------------------*/
floatx80 int32_to_floatx80(int32_t a, float_status *status)
{
bool zSign;
uint32_t absA;
int8_t shiftCount;
uint64_t zSig;
if ( a == 0 ) return packFloatx80( 0, 0, 0 );
zSign = ( a < 0 );
absA = zSign ? - a : a;
shiftCount = clz32(absA) + 32;
zSig = absA;
return packFloatx80( zSign, 0x403E - shiftCount, zSig<<shiftCount );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the 64-bit two's complement integer `a'
| to the extended double-precision floating-point format. The conversion
| is performed according to the IEC/IEEE Standard for Binary Floating-Point
| Arithmetic.
*----------------------------------------------------------------------------*/
floatx80 int64_to_floatx80(int64_t a, float_status *status)
{
bool zSign;
uint64_t absA;
int8_t shiftCount;
if ( a == 0 ) return packFloatx80( 0, 0, 0 );
zSign = ( a < 0 );
absA = zSign ? - a : a;
shiftCount = clz64(absA);
return packFloatx80( zSign, 0x403E - shiftCount, absA<<shiftCount );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the single-precision floating-point value
| `a' to the extended double-precision floating-point format. The conversion