/// EmitComments - Pretty-print comments for instructions
void EmitComments(const MachineInstr &MI) const;
- /// EmitComments - Pretty-print comments for instructions
- void EmitComments(const MCInst &MI) const;
/// EmitComments - Pretty-print comments for basic blocks
void EmitComments(const MachineBasicBlock &MBB) const;
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/DebugLoc.h"
namespace llvm {
class raw_ostream;
class MCInst {
unsigned Opcode;
SmallVector<MCOperand, 8> Operands;
-
- // FIXME: This is a hack!
- DebugLoc Loc;
public:
MCInst() : Opcode(~0U) {}
unsigned getOpcode() const { return Opcode; }
- void setDebugLoc(DebugLoc L) { Loc = L; }
- DebugLoc getDebugLoc() const { return Loc; }
-
const MCOperand &getOperand(unsigned i) const { return Operands[i]; }
MCOperand &getOperand(unsigned i) { return Operands[i]; }
unsigned getNumOperands() const { return Operands.size(); }
if (!DL.isUnknown()) {
DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
- if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT)
+ if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
DICompileUnit(CurDLT.CompileUnit)));
+ O << '\n';
+ }
PrevDLT = CurDLT;
}
}
}
}
- O << "\n\t" << MAI->getCommentString() << MAI->getInlineAsmEnd() << '\n';
+ O << "\n\t" << MAI->getCommentString() << MAI->getInlineAsmEnd();
}
/// printImplicitDef - This method prints the specified machine instruction
/// that is an implicit def.
void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
- if (VerboseAsm) {
- O.PadToColumn(MAI->getCommentColumn());
- O << MAI->getCommentString() << " implicit-def: "
- << TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
- }
+ if (!VerboseAsm) return;
+ O.PadToColumn(MAI->getCommentColumn());
+ O << MAI->getCommentString() << " implicit-def: "
+ << TRI->getAsmName(MI->getOperand(0).getReg());
}
/// printLabel - This method prints a local label used by debug and
}
void AsmPrinter::printLabel(unsigned Id) const {
- O << MAI->getPrivateGlobalPrefix() << "label" << Id << ":\n";
+ O << MAI->getPrivateGlobalPrefix() << "label" << Id << ':';
}
/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
/// EmitComments - Pretty-print comments for instructions
void AsmPrinter::EmitComments(const MachineInstr &MI) const {
- if (!VerboseAsm ||
- MI.getDebugLoc().isUnknown())
- return;
+ assert(VerboseAsm && !MI.getDebugLoc().isUnknown());
DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
O << ":" << DLT.Col;
}
-/// EmitComments - Pretty-print comments for instructions
-void AsmPrinter::EmitComments(const MCInst &MI) const {
- if (!VerboseAsm ||
- MI.getDebugLoc().isUnknown())
- return;
-
- DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
-
- // Print source line info
- O.PadToColumn(MAI->getCommentColumn());
- O << MAI->getCommentString() << " SrcLine ";
- if (DLT.CompileUnit) {
- std::string Str;
- DICompileUnit CU(DLT.CompileUnit);
- O << CU.getFilename(Str) << " ";
- }
- O << DLT.Line;
- if (DLT.Col != 0)
- O << ":" << DLT.Col;
-}
-
/// PrintChildLoopComment - Print comments about child loops within
/// the loop for this basic block, with nesting.
///
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
DICompileUnit(DLT.CompileUnit));
Asm->printLabel(LabelID);
+ O << '\n';
}
if (TimePassesIsEnabled)
// Call the autogenerated instruction printer routines.
processDebugLoc(MI->getDebugLoc());
printInstruction(MI);
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
bool ARMAsmPrinter::doInitialization(Module &M) {
II != E; ++II) {
// Print the assembly for the instruction.
++EmittedInsts;
+ processDebugLoc(II->getDebugLoc());
+
printInstruction(II);
+
+ if (VerboseAsm && !II->getDebugLoc().isUnknown())
+ EmitComments(*II);
+ O << '\n';
}
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
+ processDebugLoc(II->getDebugLoc());
+
printInstruction(II);
+ if (VerboseAsm && !II->getDebugLoc().isUnknown())
+ EmitComments(*II);
+ O << '\n';
+
++EmittedInsts;
}
}
++EmittedInsts;
processDebugLoc(MI->getDebugLoc());
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
/// runOnMachineFunction - This uses the printMachineInstruction()
void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
+ processDebugLoc(MI->getDebugLoc());
+
// Call the autogenerated instruction printer routines.
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
+ processDebugLoc(II->getDebugLoc());
+
// Print the assembly for the instruction.
printInstruction(II);
+
+ if (VerboseAsm && !II->getDebugLoc().isUnknown())
+ EmitComments(*II);
+ O << '\n';
+
++EmittedInsts;
}
}
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
+ processDebugLoc(MI->getDebugLoc());
+
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
return true;
}
}
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
/// runOnMachineFunction - This uses the printMachineInstruction()
// Print the assembly for the instruction.
processDebugLoc(II->getDebugLoc());
printInstruction(II);
+
+ if (VerboseAsm && !II->getDebugLoc().isUnknown())
+ EmitComments(*II);
+ O << '\n';
+
++EmittedInsts;
}
}
void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
+ processDebugLoc(MI->getDebugLoc());
+
// Call the autogenerated instruction printer routines.
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum) {
printInstructionThroughMCStreamer(MI);
else
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// Call the autogenerated instruction printer routines.
printInstruction(MI);
+
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
bool X86IntelAsmPrinter::doInitialization(Module &M) {
void X86ATTAsmPrinter::
printInstructionThroughMCStreamer(const MachineInstr *MI) {
MCInst TmpInst;
- TmpInst.setDebugLoc(MI->getDebugLoc());
switch (MI->getOpcode()) {
case TargetInstrInfo::DBG_LABEL:
case TargetInstrInfo::EH_LABEL:
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- O << "\t";
printMachineInstruction(II);
}
const MachineOperand &MO = MI->getOperand(opNum);
switch (MO.getType()) {
case MachineOperand::MO_Register:
- if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
- O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
- else
- llvm_unreachable("not implemented");
+ O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
break;
case MachineOperand::MO_Immediate:
O << MO.getImm();
return;
}
printInstruction(MI);
+ if (VerboseAsm && !MI->getDebugLoc().isUnknown())
+ EmitComments(*MI);
+ O << '\n';
}
bool XCoreAsmPrinter::doInitialization(Module &M) {
}
}
- Operands.push_back(
- AsmWriterOperand("EmitComments(*MI);\n",
- AsmWriterOperand::isLiteralStatementOperand));
- AddLiteralString("\\n");
Operands.push_back(AsmWriterOperand("return;",
AsmWriterOperand::isLiteralStatementOperand));
}