mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-20 12:31:40 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
defae370b0
commit
bb19cd98c6
@ -2715,18 +2715,15 @@ uint64_t ConstantDataSequential::getElementAsInteger(unsigned Elt) const {
|
|||||||
/// type, return the specified element as an APFloat.
|
/// type, return the specified element as an APFloat.
|
||||||
APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
|
APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
|
||||||
const char *EltPtr = getElementPointer(Elt);
|
const char *EltPtr = getElementPointer(Elt);
|
||||||
|
auto EltVal = *reinterpret_cast<const uint64_t *>(EltPtr);
|
||||||
|
|
||||||
switch (getElementType()->getTypeID()) {
|
switch (getElementType()->getTypeID()) {
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Accessor can only be used when element is float/double!");
|
llvm_unreachable("Accessor can only be used when element is float/double!");
|
||||||
case Type::FloatTyID: {
|
case Type::FloatTyID:
|
||||||
const float *FloatPrt = reinterpret_cast<const float *>(EltPtr);
|
return APFloat(APFloat::IEEEsingle, APInt(32, EltVal));
|
||||||
return APFloat(*const_cast<float *>(FloatPrt));
|
case Type::DoubleTyID:
|
||||||
}
|
return APFloat(APFloat::IEEEdouble, APInt(64, EltVal));
|
||||||
case Type::DoubleTyID: {
|
|
||||||
const double *DoublePtr = reinterpret_cast<const double *>(EltPtr);
|
|
||||||
return APFloat(*const_cast<double *>(DoublePtr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user