diff options
author | Tim Northover <Tim.Northover@arm.com> | 2013-01-08 16:56:23 +0000 |
---|---|---|
committer | Tim Northover <Tim.Northover@arm.com> | 2013-01-08 16:56:23 +0000 |
commit | 7bb9992cceda7c0c0deca013661b131ee9686d8e (patch) | |
tree | 7423ec99353591f420520203d6cb5f266fc06081 /llvm/lib/CodeGen | |
parent | 6e67bed48ccc70b73b8a041d2c651b15ec86cd35 (diff) | |
download | bcm5719-llvm-7bb9992cceda7c0c0deca013661b131ee9686d8e.tar.gz bcm5719-llvm-7bb9992cceda7c0c0deca013661b131ee9686d8e.zip |
Allow the asm printer to print fp128 values properly.
llvm-svn: 171866
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 9e43524ad01..aa64698644a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1784,27 +1784,30 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, unsigned AddrSpace, return; } - if (CFP->getType()->isX86_FP80Ty()) { + if (CFP->getType()->isX86_FP80Ty() || CFP->getType()->isFP128Ty()) { // all long double variants are printed as hex // API needed to prevent premature destruction APInt API = CFP->getValueAPF().bitcastToAPInt(); const uint64_t *p = API.getRawData(); if (AP.isVerbose()) { // Convert to double so we can print the approximate val as a comment. - APFloat DoubleVal = CFP->getValueAPF(); - bool ignored; - DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, - &ignored); - AP.OutStreamer.GetCommentOS() << "x86_fp80 ~= " - << DoubleVal.convertToDouble() << '\n'; + SmallString<8> StrVal; + CFP->getValueAPF().toString(StrVal); + + const char *TyNote = CFP->getType()->isFP128Ty() ? "fp128 " : "x86_fp80 "; + AP.OutStreamer.GetCommentOS() << TyNote << StrVal << '\n'; } + // The 80-bit type is made of a 64-bit and 16-bit value, the 128-bit has 2 + // 64-bit words. + uint32_t TrailingSize = CFP->getType()->isFP128Ty() ? 8 : 2; + if (AP.TM.getDataLayout()->isBigEndian()) { - AP.OutStreamer.EmitIntValue(p[1], 2, AddrSpace); + AP.OutStreamer.EmitIntValue(p[1], TrailingSize, AddrSpace); AP.OutStreamer.EmitIntValue(p[0], 8, AddrSpace); } else { AP.OutStreamer.EmitIntValue(p[0], 8, AddrSpace); - AP.OutStreamer.EmitIntValue(p[1], 2, AddrSpace); + AP.OutStreamer.EmitIntValue(p[1], TrailingSize, AddrSpace); } // Emit the tail padding for the long double. |