diff options
author | Dale Johannesen <dalej@apple.com> | 2010-04-06 22:45:26 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2010-04-06 22:45:26 +0000 |
commit | d706c64ce2ac8c507f021d451e2f647512b0c4ec (patch) | |
tree | d609cd27f8decf36f13d4245dd1b6ed177d6a015 /lib/Target/X86/AsmPrinter/X86MCInstLower.cpp | |
parent | 2fb774fa3bd93106fceaa80e792c91409a4eb4bc (diff) | |
download | external_llvm-d706c64ce2ac8c507f021d451e2f647512b0c4ec.zip external_llvm-d706c64ce2ac8c507f021d451e2f647512b0c4ec.tar.gz external_llvm-d706c64ce2ac8c507f021d451e2f647512b0c4ec.tar.bz2 |
Revert 100573, it's causing some testsuite problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/AsmPrinter/X86MCInstLower.cpp')
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86MCInstLower.cpp | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index 9b23408..a290eb0 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -326,10 +326,76 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const { } } +void X86AsmPrinter::PrintDebugValueComment(const MachineInstr *MI, + raw_ostream &O) { + // FIXME: if this is implemented for another target before it goes + // away completely, the common part should be moved into AsmPrinter. + O << '\t' << MAI->getCommentString() << "DEBUG_VALUE: "; + unsigned NOps = MI->getNumOperands(); + // cast away const; DIetc do not take const operands for some reason. + DIVariable V((MDNode*)(MI->getOperand(NOps-1).getMetadata())); + O << V.getName(); + O << " <- "; + if (NOps==3) { + // Register or immediate value. Register 0 means undef. + assert(MI->getOperand(0).isReg() || + MI->getOperand(0).isImm() || + MI->getOperand(0).isFPImm()); + if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == 0) { + // Suppress offset in this case, it is not meaningful. + O << "undef"; + OutStreamer.AddBlankLine(); + return; + } + + if (MI->getOperand(0).isFPImm()) { + // This is more naturally done in printOperand, but since the only use + // 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, O); + } else { + if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == 0) { + // Suppress offset in this case, it is not meaningful. + O << "undef"; + OutStreamer.AddBlankLine(); + return; + } + // Frame address. Currently handles register +- offset only. + assert(MI->getOperand(0).isReg() && MI->getOperand(3).isImm()); + O << '['; printOperand(MI, 0, O); O << '+'; printOperand(MI, 3, O); + O << ']'; + } + O << "+"; + printOperand(MI, NOps-2, O); +} + + void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { X86MCInstLower MCInstLowering(OutContext, Mang, *this); switch (MI->getOpcode()) { - + case TargetOpcode::DBG_VALUE: + if (isVerbose() && OutStreamer.hasRawTextSupport()) { + std::string TmpStr; + raw_string_ostream OS(TmpStr); + PrintDebugValueComment(MI, OS); + OutStreamer.EmitRawText(StringRef(OS.str())); + } + return; + case X86::MOVPC32r: { MCInst TmpInst; // This is a pseudo op for a two instruction sequence with a label, which |