1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Constants.cpp: getElementAsAPFloat(): Don't handle constant value via host's float/double, just handle with APInt/APFloat.

x87 FPU didn't keep SNAN, but demoted to QNAN.

llvm-svn: 230013
This commit is contained in:
NAKAMURA Takumi 2015-02-20 14:24:49 +00:00
parent 3cdf060580
commit 5d88ffd396

View File

@ -2715,18 +2715,15 @@ uint64_t ConstantDataSequential::getElementAsInteger(unsigned Elt) const {
/// type, return the specified element as an APFloat.
APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
const char *EltPtr = getElementPointer(Elt);
auto EltVal = *reinterpret_cast<const uint64_t *>(EltPtr);
switch (getElementType()->getTypeID()) {
default:
llvm_unreachable("Accessor can only be used when element is float/double!");
case Type::FloatTyID: {
const float *FloatPrt = reinterpret_cast<const float *>(EltPtr);
return APFloat(*const_cast<float *>(FloatPrt));
}
case Type::DoubleTyID: {
const double *DoublePtr = reinterpret_cast<const double *>(EltPtr);
return APFloat(*const_cast<double *>(DoublePtr));
}
case Type::FloatTyID:
return APFloat(APFloat::IEEEsingle, APInt(32, EltVal));
case Type::DoubleTyID:
return APFloat(APFloat::IEEEdouble, APInt(64, EltVal));
}
}