Make -print-machineinstrs more readable.

- Be consistent when referring to MachineBasicBlocks: BB#0.
 - Be consistent when referring to virtual registers: %reg1024.
 - Be consistent when referring to unknown physical registers: %physreg10.
 - Be consistent when referring to known physical registers: %RAX
 - Be consistent when referring to register 0: %reg0
 - Be consistent when printing alignments: align=16
 - Print jump table contents.
 - Don't print host addresses, in general.
 - and various other cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85682 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-10-31 20:19:03 +00:00
parent 499a9377a3
commit 0ba90f3e34
6 changed files with 97 additions and 66 deletions

View File

@ -205,7 +205,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
if (TM)
OS << "%" << TM->getRegisterInfo()->get(getReg()).Name;
else
OS << "%mreg" << getReg();
OS << "%physreg" << getReg();
}
if (getSubReg() != 0)
@ -251,9 +251,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
OS << getFPImm()->getValueAPF().convertToDouble();
break;
case MachineOperand::MO_MachineBasicBlock:
OS << "mbb<"
<< ((Value*)getMBB()->getBasicBlock())->getName()
<< "," << (void*)getMBB() << '>';
OS << "<BB#" << getMBB()->getNumber() << ">";
break;
case MachineOperand::MO_FrameIndex:
OS << "<fi#" << getIndex() << '>';
@ -277,10 +275,8 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
OS << '>';
break;
case MachineOperand::MO_BlockAddress:
OS << "<blockaddress: ";
WriteAsOperand(OS, getBlockAddress()->getFunction(), /*PrintType=*/false);
OS << ", ";
WriteAsOperand(OS, getBlockAddress()->getBasicBlock(), /*PrintType=*/false);
OS << "<";
WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false);
OS << '>';
break;
default:
@ -1064,16 +1060,24 @@ void MachineInstr::dump() const {
}
void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
// Specialize printing if op#0 is definition
unsigned StartOp = 0;
if (getNumOperands() && getOperand(0).isReg() && getOperand(0).isDef()) {
getOperand(0).print(OS, TM);
OS << " = ";
++StartOp; // Don't print this operand again!
unsigned StartOp = 0, e = getNumOperands();
// Print explicitly defined operands on the left of an assignment syntax.
for (; StartOp < e && getOperand(StartOp).isReg() &&
getOperand(StartOp).isDef() &&
!getOperand(StartOp).isImplicit();
++StartOp) {
if (StartOp != 0) OS << ", ";
getOperand(StartOp).print(OS, TM);
}
if (StartOp != 0)
OS << " = ";
// Print the opcode name.
OS << getDesc().getName();
// Print the rest of the operands.
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
if (i != StartOp)
OS << ",";
@ -1081,8 +1085,11 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
getOperand(i).print(OS, TM);
}
bool HaveSemi = false;
if (!memoperands_empty()) {
OS << ", Mem:";
if (!HaveSemi) OS << ";"; HaveSemi = true;
OS << " mem:";
for (mmo_iterator i = memoperands_begin(), e = memoperands_end();
i != e; ++i) {
OS << **i;
@ -1092,14 +1099,16 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
}
if (!debugLoc.isUnknown()) {
if (!HaveSemi) OS << ";"; HaveSemi = true;
// TODO: print InlinedAtLoc information
const MachineFunction *MF = getParent()->getParent();
DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc);
DICompileUnit CU(DLT.Scope);
if (!CU.isNull())
OS << " [dbg: "
<< CU.getDirectory() << '/' << CU.getFilename() << ","
<< DLT.Line << ","
<< DLT.Col << "]";
OS << " dbg:" << CU.getDirectory() << '/' << CU.getFilename() << ":"
<< DLT.Line << ":" << DLT.Col;
}
OS << "\n";