summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp41
1 files changed, 15 insertions, 26 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 9ffd830a9f5..2cfea650872 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1945,33 +1945,22 @@ static void emitGlobalConstantDataSequential(const DataLayout &DL,
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);
}
}
OpenPOWER on IntegriCloud