forked from OSchip/llvm-project
remove DebugLoc from MCInst and eliminate "Comment printing" from
the MCInst path of the asmprinter. Instead, pull comment printing out of the autogenerated asmprinter into each target that uses the autogenerated asmprinter. This causes code duplication into each target, but in a way that will be easier to clean up later when more asmprinter stuff is commonized into the base AsmPrinter class. This also fixes an xcore strangeness where it inserted two tabs before every instruction. llvm-svn: 81396
This commit is contained in:
parent
5333ec33b3
commit
321bc99a74
|
|
@ -336,8 +336,6 @@ namespace llvm {
|
||||||
|
|
||||||
/// EmitComments - Pretty-print comments for instructions
|
/// EmitComments - Pretty-print comments for instructions
|
||||||
void EmitComments(const MachineInstr &MI) const;
|
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
|
/// EmitComments - Pretty-print comments for basic blocks
|
||||||
void EmitComments(const MachineBasicBlock &MBB) const;
|
void EmitComments(const MachineBasicBlock &MBB) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/DebugLoc.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
@ -132,9 +131,6 @@ public:
|
||||||
class MCInst {
|
class MCInst {
|
||||||
unsigned Opcode;
|
unsigned Opcode;
|
||||||
SmallVector<MCOperand, 8> Operands;
|
SmallVector<MCOperand, 8> Operands;
|
||||||
|
|
||||||
// FIXME: This is a hack!
|
|
||||||
DebugLoc Loc;
|
|
||||||
public:
|
public:
|
||||||
MCInst() : Opcode(~0U) {}
|
MCInst() : Opcode(~0U) {}
|
||||||
|
|
||||||
|
|
@ -142,9 +138,6 @@ public:
|
||||||
|
|
||||||
unsigned getOpcode() const { return Opcode; }
|
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]; }
|
const MCOperand &getOperand(unsigned i) const { return Operands[i]; }
|
||||||
MCOperand &getOperand(unsigned i) { return Operands[i]; }
|
MCOperand &getOperand(unsigned i) { return Operands[i]; }
|
||||||
unsigned getNumOperands() const { return Operands.size(); }
|
unsigned getNumOperands() const { return Operands.size(); }
|
||||||
|
|
|
||||||
|
|
@ -1390,9 +1390,11 @@ void AsmPrinter::processDebugLoc(DebugLoc DL) {
|
||||||
if (!DL.isUnknown()) {
|
if (!DL.isUnknown()) {
|
||||||
DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
|
DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
|
||||||
|
|
||||||
if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT)
|
if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
|
||||||
printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
|
printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
|
||||||
DICompileUnit(CurDLT.CompileUnit)));
|
DICompileUnit(CurDLT.CompileUnit)));
|
||||||
|
O << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
PrevDLT = CurDLT;
|
PrevDLT = CurDLT;
|
||||||
}
|
}
|
||||||
|
|
@ -1594,17 +1596,16 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
O << "\n\t" << MAI->getCommentString() << MAI->getInlineAsmEnd() << '\n';
|
O << "\n\t" << MAI->getCommentString() << MAI->getInlineAsmEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printImplicitDef - This method prints the specified machine instruction
|
/// printImplicitDef - This method prints the specified machine instruction
|
||||||
/// that is an implicit def.
|
/// that is an implicit def.
|
||||||
void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
|
void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
|
||||||
if (VerboseAsm) {
|
if (!VerboseAsm) return;
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
O.PadToColumn(MAI->getCommentColumn());
|
||||||
O << MAI->getCommentString() << " implicit-def: "
|
O << MAI->getCommentString() << " implicit-def: "
|
||||||
<< TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
|
<< TRI->getAsmName(MI->getOperand(0).getReg());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printLabel - This method prints a local label used by debug and
|
/// printLabel - This method prints a local label used by debug and
|
||||||
|
|
@ -1614,7 +1615,7 @@ void AsmPrinter::printLabel(const MachineInstr *MI) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::printLabel(unsigned Id) const {
|
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
|
/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
|
||||||
|
|
@ -1780,9 +1781,7 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
||||||
|
|
||||||
/// EmitComments - Pretty-print comments for instructions
|
/// EmitComments - Pretty-print comments for instructions
|
||||||
void AsmPrinter::EmitComments(const MachineInstr &MI) const {
|
void AsmPrinter::EmitComments(const MachineInstr &MI) const {
|
||||||
if (!VerboseAsm ||
|
assert(VerboseAsm && !MI.getDebugLoc().isUnknown());
|
||||||
MI.getDebugLoc().isUnknown())
|
|
||||||
return;
|
|
||||||
|
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
|
DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
|
||||||
|
|
||||||
|
|
@ -1799,27 +1798,6 @@ void AsmPrinter::EmitComments(const MachineInstr &MI) const {
|
||||||
O << ":" << DLT.Col;
|
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
|
/// PrintChildLoopComment - Print comments about child loops within
|
||||||
/// the loop for this basic block, with nesting.
|
/// the loop for this basic block, with nesting.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1709,6 +1709,7 @@ void DwarfDebug::BeginFunction(MachineFunction *MF) {
|
||||||
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
|
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
|
||||||
DICompileUnit(DLT.CompileUnit));
|
DICompileUnit(DLT.CompileUnit));
|
||||||
Asm->printLabel(LabelID);
|
Asm->printLabel(LabelID);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TimePassesIsEnabled)
|
if (TimePassesIsEnabled)
|
||||||
|
|
|
||||||
|
|
@ -1031,6 +1031,9 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
processDebugLoc(MI->getDebugLoc());
|
processDebugLoc(MI->getDebugLoc());
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ARMAsmPrinter::doInitialization(Module &M) {
|
bool ARMAsmPrinter::doInitialization(Module &M) {
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,13 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
|
processDebugLoc(II->getDebugLoc());
|
||||||
|
|
||||||
printInstruction(II);
|
printInstruction(II);
|
||||||
|
|
||||||
|
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*II);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,13 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
|
processDebugLoc(II->getDebugLoc());
|
||||||
|
|
||||||
printInstruction(II);
|
printInstruction(II);
|
||||||
|
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*II);
|
||||||
|
O << '\n';
|
||||||
|
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,10 @@ void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
processDebugLoc(MI->getDebugLoc());
|
processDebugLoc(MI->getDebugLoc());
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,14 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
|
|
||||||
|
processDebugLoc(MI->getDebugLoc());
|
||||||
|
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,15 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
|
processDebugLoc(II->getDebugLoc());
|
||||||
|
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
printInstruction(II);
|
printInstruction(II);
|
||||||
|
|
||||||
|
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*II);
|
||||||
|
O << '\n';
|
||||||
|
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,13 @@ PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
|
processDebugLoc(MI->getDebugLoc());
|
||||||
|
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -603,6 +603,10 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,11 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
processDebugLoc(II->getDebugLoc());
|
processDebugLoc(II->getDebugLoc());
|
||||||
printInstruction(II);
|
printInstruction(II);
|
||||||
|
|
||||||
|
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*II);
|
||||||
|
O << '\n';
|
||||||
|
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,14 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
|
|
||||||
|
processDebugLoc(MI->getDebugLoc());
|
||||||
|
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum) {
|
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum) {
|
||||||
|
|
|
||||||
|
|
@ -702,6 +702,10 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
printInstructionThroughMCStreamer(MI);
|
printInstructionThroughMCStreamer(MI);
|
||||||
else
|
else
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,10 @@ void X86IntelAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
|
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,6 @@ MCOperand X86ATTAsmPrinter::LowerSymbolOperand(const MachineOperand &MO,
|
||||||
void X86ATTAsmPrinter::
|
void X86ATTAsmPrinter::
|
||||||
printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||||
MCInst TmpInst;
|
MCInst TmpInst;
|
||||||
TmpInst.setDebugLoc(MI->getDebugLoc());
|
|
||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
case TargetInstrInfo::DBG_LABEL:
|
case TargetInstrInfo::DBG_LABEL:
|
||||||
case TargetInstrInfo::EH_LABEL:
|
case TargetInstrInfo::EH_LABEL:
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,6 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF)
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
O << "\t";
|
|
||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,10 +312,7 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||||
const MachineOperand &MO = MI->getOperand(opNum);
|
const MachineOperand &MO = MI->getOperand(opNum);
|
||||||
switch (MO.getType()) {
|
switch (MO.getType()) {
|
||||||
case MachineOperand::MO_Register:
|
case MachineOperand::MO_Register:
|
||||||
if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
|
|
||||||
O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
|
O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
|
||||||
else
|
|
||||||
llvm_unreachable("not implemented");
|
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_Immediate:
|
case MachineOperand::MO_Immediate:
|
||||||
O << MO.getImm();
|
O << MO.getImm();
|
||||||
|
|
@ -368,6 +364,9 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||||
|
EmitComments(*MI);
|
||||||
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XCoreAsmPrinter::doInitialization(Module &M) {
|
bool XCoreAsmPrinter::doInitialization(Module &M) {
|
||||||
|
|
|
||||||
|
|
@ -323,10 +323,6 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, Record *AsmWriter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Operands.push_back(
|
|
||||||
AsmWriterOperand("EmitComments(*MI);\n",
|
|
||||||
AsmWriterOperand::isLiteralStatementOperand));
|
|
||||||
AddLiteralString("\\n");
|
|
||||||
Operands.push_back(AsmWriterOperand("return;",
|
Operands.push_back(AsmWriterOperand("return;",
|
||||||
AsmWriterOperand::isLiteralStatementOperand));
|
AsmWriterOperand::isLiteralStatementOperand));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue