mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 22:34:39 +00:00
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
2a098581a8
commit
b9aca1a178
@ -336,8 +336,6 @@ namespace llvm {
|
||||
|
||||
/// 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;
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/Support/DebugLoc.h"
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
@ -132,9 +131,6 @@ public:
|
||||
class MCInst {
|
||||
unsigned Opcode;
|
||||
SmallVector<MCOperand, 8> Operands;
|
||||
|
||||
// FIXME: This is a hack!
|
||||
DebugLoc Loc;
|
||||
public:
|
||||
MCInst() : Opcode(~0U) {}
|
||||
|
||||
@ -142,9 +138,6 @@ public:
|
||||
|
||||
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(); }
|
||||
|
@ -1390,9 +1390,11 @@ void AsmPrinter::processDebugLoc(DebugLoc DL) {
|
||||
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;
|
||||
}
|
||||
@ -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
|
||||
/// 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
|
||||
@ -1614,7 +1615,7 @@ void AsmPrinter::printLabel(const MachineInstr *MI) 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
|
||||
@ -1780,9 +1781,7 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
||||
|
||||
/// 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());
|
||||
|
||||
@ -1799,27 +1798,6 @@ void AsmPrinter::EmitComments(const MachineInstr &MI) const {
|
||||
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.
|
||||
///
|
||||
|
@ -1709,6 +1709,7 @@ void DwarfDebug::BeginFunction(MachineFunction *MF) {
|
||||
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
|
||||
DICompileUnit(DLT.CompileUnit));
|
||||
Asm->printLabel(LabelID);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
if (TimePassesIsEnabled)
|
||||
|
@ -1031,6 +1031,9 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
// 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) {
|
||||
|
@ -176,7 +176,13 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
++EmittedInsts;
|
||||
processDebugLoc(II->getDebugLoc());
|
||||
|
||||
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();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
processDebugLoc(II->getDebugLoc());
|
||||
|
||||
printInstruction(II);
|
||||
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||
EmitComments(*II);
|
||||
O << '\n';
|
||||
|
||||
++EmittedInsts;
|
||||
}
|
||||
}
|
||||
|
@ -410,6 +410,10 @@ void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
++EmittedInsts;
|
||||
processDebugLoc(MI->getDebugLoc());
|
||||
printInstruction(MI);
|
||||
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
|
@ -145,8 +145,14 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
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,
|
||||
|
@ -275,8 +275,15 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,13 @@ PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
||||
}
|
||||
|
||||
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
processDebugLoc(MI->getDebugLoc());
|
||||
|
||||
printInstruction(MI);
|
||||
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -603,6 +603,10 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
}
|
||||
|
||||
printInstruction(MI);
|
||||
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
|
@ -129,6 +129,11 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
// Print the assembly for the instruction.
|
||||
processDebugLoc(II->getDebugLoc());
|
||||
printInstruction(II);
|
||||
|
||||
if (VerboseAsm && !II->getDebugLoc().isUnknown())
|
||||
EmitComments(*II);
|
||||
O << '\n';
|
||||
|
||||
++EmittedInsts;
|
||||
}
|
||||
}
|
||||
|
@ -153,8 +153,14 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
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) {
|
||||
|
@ -702,6 +702,10 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
printInstructionThroughMCStreamer(MI);
|
||||
else
|
||||
printInstruction(MI);
|
||||
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
||||
|
@ -437,6 +437,10 @@ void X86IntelAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
|
||||
// Call the autogenerated instruction printer routines.
|
||||
printInstruction(MI);
|
||||
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
bool X86IntelAsmPrinter::doInitialization(Module &M) {
|
||||
|
@ -267,7 +267,6 @@ MCOperand X86ATTAsmPrinter::LowerSymbolOperand(const MachineOperand &MO,
|
||||
void X86ATTAsmPrinter::
|
||||
printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
MCInst TmpInst;
|
||||
TmpInst.setDebugLoc(MI->getDebugLoc());
|
||||
switch (MI->getOpcode()) {
|
||||
case TargetInstrInfo::DBG_LABEL:
|
||||
case TargetInstrInfo::EH_LABEL:
|
||||
|
@ -279,7 +279,6 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF)
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
O << "\t";
|
||||
printMachineInstruction(II);
|
||||
}
|
||||
|
||||
@ -313,10 +312,7 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
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();
|
||||
@ -368,6 +364,9 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
return;
|
||||
}
|
||||
printInstruction(MI);
|
||||
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
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;",
|
||||
AsmWriterOperand::isLiteralStatementOperand));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user