forked from OSchip/llvm-project
parent
8728c3376a
commit
9acbf5aaf9
|
@ -1618,7 +1618,8 @@ APFloat::convertFromHexadecimalString(const char *p,
|
|||
}
|
||||
|
||||
APFloat::opStatus
|
||||
APFloat::convertFromString(const char *p, roundingMode rounding_mode) {
|
||||
APFloat::convertFromString(const char *p, roundingMode rounding_mode)
|
||||
{
|
||||
/* Handle a leading minus sign. */
|
||||
if(*p == '-')
|
||||
sign = 1, p++;
|
||||
|
@ -1635,7 +1636,8 @@ APFloat::convertFromString(const char *p, roundingMode rounding_mode) {
|
|||
// For good performance it is desirable for different APFloats
|
||||
// to produce different integers.
|
||||
uint32_t
|
||||
APFloat::getHashValue() const {
|
||||
APFloat::getHashValue() const
|
||||
{
|
||||
if (category==fcZero) return sign<<8 | semantics->precision ;
|
||||
else if (category==fcInfinity) return sign<<9 | semantics->precision;
|
||||
else if (category==fcNaN) return 1<<10 | semantics->precision;
|
||||
|
@ -1658,7 +1660,8 @@ APFloat::getHashValue() const {
|
|||
// the actual IEEE respresentations. We compensate for that here.
|
||||
|
||||
APInt
|
||||
APFloat::convertF80LongDoubleAPFloatToAPInt() const {
|
||||
APFloat::convertF80LongDoubleAPFloatToAPInt() const
|
||||
{
|
||||
assert(semantics == (const llvm::fltSemantics* const)&x87DoubleExtended);
|
||||
assert (partCount()==2);
|
||||
|
||||
|
@ -1691,7 +1694,8 @@ APFloat::convertF80LongDoubleAPFloatToAPInt() const {
|
|||
}
|
||||
|
||||
APInt
|
||||
APFloat::convertDoubleAPFloatToAPInt() const {
|
||||
APFloat::convertDoubleAPFloatToAPInt() const
|
||||
{
|
||||
assert(semantics == (const llvm::fltSemantics*)&IEEEdouble);
|
||||
assert (partCount()==1);
|
||||
|
||||
|
@ -1721,7 +1725,8 @@ APFloat::convertDoubleAPFloatToAPInt() const {
|
|||
}
|
||||
|
||||
APInt
|
||||
APFloat::convertFloatAPFloatToAPInt() const {
|
||||
APFloat::convertFloatAPFloatToAPInt() const
|
||||
{
|
||||
assert(semantics == (const llvm::fltSemantics*)&IEEEsingle);
|
||||
assert (partCount()==1);
|
||||
|
||||
|
@ -1750,26 +1755,30 @@ APFloat::convertFloatAPFloatToAPInt() const {
|
|||
}
|
||||
|
||||
APInt
|
||||
APFloat::convertToAPInt() const {
|
||||
APFloat::convertToAPInt() const
|
||||
{
|
||||
if (semantics == (const llvm::fltSemantics* const)&IEEEsingle)
|
||||
return convertFloatAPFloatToAPInt();
|
||||
else if (semantics == (const llvm::fltSemantics* const)&IEEEdouble)
|
||||
return convertDoubleAPFloatToAPInt();
|
||||
else if (semantics == (const llvm::fltSemantics* const)&x87DoubleExtended)
|
||||
return convertF80LongDoubleAPFloatToAPInt();
|
||||
else
|
||||
|
||||
assert(0);
|
||||
abort();
|
||||
}
|
||||
|
||||
float
|
||||
APFloat::convertToFloat() const {
|
||||
APFloat::convertToFloat() const
|
||||
{
|
||||
assert(semantics == (const llvm::fltSemantics* const)&IEEEsingle);
|
||||
APInt api = convertToAPInt();
|
||||
return api.bitsToFloat();
|
||||
}
|
||||
|
||||
double
|
||||
APFloat::convertToDouble() const {
|
||||
APFloat::convertToDouble() const
|
||||
{
|
||||
assert(semantics == (const llvm::fltSemantics* const)&IEEEdouble);
|
||||
APInt api = convertToAPInt();
|
||||
return api.bitsToDouble();
|
||||
|
@ -1781,7 +1790,8 @@ APFloat::convertToDouble() const {
|
|||
/// exponent = 0, integer bit set. (formerly "psuedodenormals")
|
||||
/// exponent!=0 nor all 1's, integer bit not set. (formerly "unnormals")
|
||||
void
|
||||
APFloat::initFromF80LongDoubleAPInt(const APInt &api) {
|
||||
APFloat::initFromF80LongDoubleAPInt(const APInt &api)
|
||||
{
|
||||
assert(api.getBitWidth()==80);
|
||||
uint64_t i1 = api.getRawData()[0];
|
||||
uint64_t i2 = api.getRawData()[1];
|
||||
|
@ -1815,7 +1825,8 @@ APFloat::initFromF80LongDoubleAPInt(const APInt &api) {
|
|||
}
|
||||
|
||||
void
|
||||
APFloat::initFromDoubleAPInt(const APInt &api) {
|
||||
APFloat::initFromDoubleAPInt(const APInt &api)
|
||||
{
|
||||
assert(api.getBitWidth()==64);
|
||||
uint64_t i = *api.getRawData();
|
||||
uint64_t myexponent = (i >> 52) & 0x7ff;
|
||||
|
@ -1847,7 +1858,8 @@ APFloat::initFromDoubleAPInt(const APInt &api) {
|
|||
}
|
||||
|
||||
void
|
||||
APFloat::initFromFloatAPInt(const APInt & api) {
|
||||
APFloat::initFromFloatAPInt(const APInt & api)
|
||||
{
|
||||
assert(api.getBitWidth()==32);
|
||||
uint32_t i = (uint32_t)*api.getRawData();
|
||||
uint32_t myexponent = (i >> 23) & 0xff;
|
||||
|
@ -1883,7 +1895,8 @@ APFloat::initFromFloatAPInt(const APInt & api) {
|
|||
/// breaks when we get to PPC128 and IEEE128 (but both cannot exist in the
|
||||
/// same compile...)
|
||||
void
|
||||
APFloat::initFromAPInt(const APInt& api) {
|
||||
APFloat::initFromAPInt(const APInt& api)
|
||||
{
|
||||
if (api.getBitWidth() == 32)
|
||||
return initFromFloatAPInt(api);
|
||||
else if (api.getBitWidth()==64)
|
||||
|
@ -1894,17 +1907,19 @@ APFloat::initFromAPInt(const APInt& api) {
|
|||
assert(0);
|
||||
}
|
||||
|
||||
APFloat::APFloat(const APInt& api) {
|
||||
APFloat::APFloat(const APInt& api)
|
||||
{
|
||||
initFromAPInt(api);
|
||||
}
|
||||
|
||||
APFloat::APFloat(float f) {
|
||||
APFloat::APFloat(float f)
|
||||
{
|
||||
APInt api = APInt(32, 0);
|
||||
initFromAPInt(api.floatToBits(f));
|
||||
}
|
||||
|
||||
APFloat::APFloat(double d) {
|
||||
APFloat::APFloat(double d)
|
||||
{
|
||||
APInt api = APInt(64, 0);
|
||||
initFromAPInt(api.doubleToBits(d));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue