summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2010-02-04 01:33:43 +0000
committerDale Johannesen <dalej@apple.com>2010-02-04 01:33:43 +0000
commitc4b94e02af43821dfb0cd35ff4f5e5f118f426dc (patch)
tree4f19ab9cfb45103daf5a0180e83dc864311f8b0d
parentaf6ce14d679e2a87d2de6a3e26ce6a1f34d1f879 (diff)
downloadllvm-c4b94e02af43821dfb0cd35ff4f5e5f118f426dc.tar.gz
llvm-c4b94e02af43821dfb0cd35ff4f5e5f118f426dc.tar.bz2
llvm-c4b94e02af43821dfb0cd35ff4f5e5f118f426dc.tar.xz
Rewrite FP constant handling in DEBUG_VALUE yet
again, so it more or less handles long double. Restore \n removed in latest MC frenzy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95271 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/AsmPrinter/X86MCInstLower.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
index 2e0fd98fa6..ef9a0eb28f 100644
--- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
+++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
@@ -25,6 +25,7 @@
#include "llvm/Target/Mangler.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Type.h"
using namespace llvm;
@@ -430,14 +431,25 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
if (MI->getOperand(0).getType()==MachineOperand::MO_Register &&
MI->getOperand(0).getReg()==0) {
// Suppress offset in this case, it is not meaningful.
- O << "undef";
+ O << "undef\n";
return;
} else if (MI->getOperand(0).getType()==MachineOperand::MO_FPImmediate) {
// This is more naturally done in printOperand, but since the only use
- // of such an operand is in this comment and that is temporary, we
- // prefer to keep this localized.
- O << '$';
- MI->getOperand(0).print(O, &TM);
+ // of such an operand is in this comment and that is temporary (and it's
+ // ugly), we prefer to keep this localized.
+ // The include of Type.h may be removable when this code is.
+ if (MI->getOperand(0).getFPImm()->getType()->isFloatTy() ||
+ MI->getOperand(0).getFPImm()->getType()->isDoubleTy())
+ MI->getOperand(0).print(O, &TM);
+ else {
+ // There is no good way to print long double. Convert a copy to
+ // double. Ah well, it's only a comment.
+ bool ignored;
+ APFloat APF = APFloat(MI->getOperand(0).getFPImm()->getValueAPF());
+ APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
+ &ignored);
+ O << "(long double) " << APF.convertToDouble();
+ }
} else
printOperand(MI, 0);
} else {