diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-12-08 02:37:48 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-12-08 02:37:48 +0000 |
commit | 3135ba9b381aa010a98c7a3b48c9d2338783d480 (patch) | |
tree | 2bd4ad552f85f109a481a81e7607b2f9e0917db7 /llvm/lib/CodeGen | |
parent | a98a3be2c49c04bca67a65a46d8e5fa65adc0f68 (diff) | |
download | bcm5719-llvm-3135ba9b381aa010a98c7a3b48c9d2338783d480.tar.gz bcm5719-llvm-3135ba9b381aa010a98c7a3b48c9d2338783d480.zip |
AsmPrinter: Use emitGlobalConstantFP to emit elements of constant data
It's strange to duplicate the logic for emitting FP values into
emitGlobalConstantDataSequential, and it's even stranger that we end
up printing the verbose assembly comments differently between the two
paths. Just call into emitGlobalConstantFP rather than crudely
duplicating its logic.
llvm-svn: 254988
Diffstat (limited to 'llvm/lib/CodeGen')
-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()); |