AP.OutStreamer->EmitIntValue(CDS->getElementAsInteger(i),
ElementByteSize);
}
- } else if (ElementByteSize == 4) {
- // FP Constants are printed as integer constants to avoid losing
- // precision.
- assert(CDS->getElementType()->isFloatTy());
- for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
- union {
- float F;
- uint32_t I;
- };
-
- F = CDS->getElementAsFloat(i);
- if (AP.isVerbose())
- AP.OutStreamer->GetCommentOS() << "float " << F << '\n';
- AP.OutStreamer->EmitIntValue(I, 4);
- }
} else {
- assert(CDS->getElementType()->isDoubleTy());
- for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
- union {
- double F;
- uint64_t I;
- };
-
- F = CDS->getElementAsDouble(i);
- if (AP.isVerbose())
- AP.OutStreamer->GetCommentOS() << "double " << F << '\n';
- AP.OutStreamer->EmitIntValue(I, 8);
+ // FP Constants are printed as integer constants to avoid losing precision.
+ for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
+ APFloat Num = CDS->getElementAsAPFloat(I);
+ if (AP.isVerbose()) {
+ if (ElementByteSize == 4)
+ AP.OutStreamer->GetCommentOS() << "float " << Num.convertToFloat()
+ << '\n';
+ else if (ElementByteSize == 8)
+ AP.OutStreamer->GetCommentOS() << "double " << Num.convertToDouble()
+ << '\n';
+ else
+ llvm_unreachable("Unexpected float width");
+ }
+ AP.OutStreamer->EmitIntValue(Num.bitcastToAPInt().getLimitedValue(),
+ ElementByteSize);
}
}