diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index b8604240b5d..f1f3547750b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1873,6 +1873,8 @@ static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C, const Constant *BaseCV = nullptr, uint64_t Offset = 0); +static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP); + /// isRepeatedByteSequence - Determine whether the given value is /// composed of a repeated sequence of identical bytes and return the /// byte value. If it is not a repeated sequence, return -1. @@ -1951,22 +1953,8 @@ static void emitGlobalConstantDataSequential(const DataLayout &DL, ElementByteSize); } } else { - // 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); - } + for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) + emitGlobalConstantFP(cast<ConstantFP>(CDS->getElementAsConstant(I)), AP); } unsigned Size = DL.getTypeAllocSize(CDS->getType()); |