diff options
author | Dan Gohman <gohman@apple.com> | 2009-10-31 20:19:03 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-10-31 20:19:03 +0000 |
commit | 0ba90f3e34b826b039bdfece1415ef032c4ad3f5 (patch) | |
tree | 64bbadd030315d5ff4d3a7d24cf60856186e48dd | |
parent | 499a9377a3dcce85f39f04b2ab39c3dffa3025ef (diff) | |
download | external_llvm-0ba90f3e34b826b039bdfece1415ef032c4ad3f5.zip external_llvm-0ba90f3e34b826b039bdfece1415ef032c4ad3f5.tar.gz external_llvm-0ba90f3e34b826b039bdfece1415ef032c4ad3f5.tar.bz2 |
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
-rw-r--r-- | lib/CodeGen/MachineBasicBlock.cpp | 31 | ||||
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 71 | ||||
-rw-r--r-- | lib/CodeGen/MachineInstr.cpp | 47 | ||||
-rw-r--r-- | lib/CodeGen/MachineVerifier.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/PostRASchedulerList.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 |
6 files changed, 97 insertions, 66 deletions
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 4d1370a..7fbdb12 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -20,6 +20,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Assembly/Writer.h" #include <algorithm> using namespace llvm; @@ -161,11 +162,11 @@ void MachineBasicBlock::dump() const { static inline void OutputReg(raw_ostream &os, unsigned RegNo, const TargetRegisterInfo *TRI = 0) { - if (!RegNo || TargetRegisterInfo::isPhysicalRegister(RegNo)) { + if (RegNo != 0 && TargetRegisterInfo::isPhysicalRegister(RegNo)) { if (TRI) os << " %" << TRI->get(RegNo).Name; else - os << " %mreg(" << RegNo << ")"; + os << " %physreg" << RegNo; } else os << " %reg" << RegNo; } @@ -178,19 +179,23 @@ void MachineBasicBlock::print(raw_ostream &OS) const { return; } - const BasicBlock *LBB = getBasicBlock(); + if (Alignment) { OS << "Alignment " << Alignment << "\n"; } + + OS << "BB#" << getNumber() << ": "; + + const char *Comma = ""; + if (const BasicBlock *LBB = getBasicBlock()) { + OS << Comma << "derived from LLVM BB "; + WriteAsOperand(OS, LBB, /*PrintType=*/false); + Comma = ", "; + } + if (isLandingPad()) { OS << Comma << "EH LANDING PAD"; Comma = ", "; } + if (hasAddressTaken()) { OS << Comma << "ADDRESS TAKEN"; Comma = ", "; } OS << '\n'; - if (LBB) OS << LBB->getName() << ": "; - OS << (const void*)this - << ", LLVM BB @" << (const void*) LBB << ", ID#" << getNumber(); - if (Alignment) OS << ", Alignment " << Alignment; - if (isLandingPad()) OS << ", EH LANDING PAD"; - if (hasAddressTaken()) OS << ", ADDRESS TAKEN"; - OS << ":\n"; const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo(); if (!livein_empty()) { - OS << "Live Ins:"; + OS << " Live Ins:"; for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) OutputReg(OS, *I, TRI); OS << '\n'; @@ -199,7 +204,7 @@ void MachineBasicBlock::print(raw_ostream &OS) const { if (!pred_empty()) { OS << " Predecessors according to CFG:"; for (const_pred_iterator PI = pred_begin(), E = pred_end(); PI != E; ++PI) - OS << ' ' << *PI << " (#" << (*PI)->getNumber() << ')'; + OS << " BB#" << (*PI)->getNumber(); OS << '\n'; } @@ -212,7 +217,7 @@ void MachineBasicBlock::print(raw_ostream &OS) const { if (!succ_empty()) { OS << " Successors according to CFG:"; for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI) - OS << ' ' << *SI << " (#" << (*SI)->getNumber() << ')'; + OS << " BB#" << (*SI)->getNumber(); OS << '\n'; } } diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 0835a5c..5a1d9e6 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -52,7 +52,7 @@ namespace { } bool runOnMachineFunction(MachineFunction &MF) { - OS << Banner; + OS << "# " << Banner << ":\n"; MF.print(OS); return false; } @@ -303,7 +303,7 @@ void MachineFunction::dump() const { } void MachineFunction::print(raw_ostream &OS) const { - OS << "# Machine code for " << Fn->getName() << "():\n"; + OS << "# Machine code for function " << Fn->getName() << ":\n"; // Print Frame Information FrameInfo->print(*this, OS); @@ -317,34 +317,43 @@ void MachineFunction::print(raw_ostream &OS) const { const TargetRegisterInfo *TRI = getTarget().getRegisterInfo(); if (RegInfo && !RegInfo->livein_empty()) { - OS << "Live Ins:"; + OS << "Function Live Ins: "; for (MachineRegisterInfo::livein_iterator I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) { if (TRI) - OS << " " << TRI->getName(I->first); + OS << "%" << TRI->getName(I->first); else - OS << " Reg #" << I->first; + OS << " %physreg" << I->first; if (I->second) - OS << " in VR#" << I->second << ' '; + OS << " in reg%" << I->second; + + if (next(I) != E) + OS << ", "; } OS << '\n'; } if (RegInfo && !RegInfo->liveout_empty()) { - OS << "Live Outs:"; + OS << "Function Live Outs: "; for (MachineRegisterInfo::liveout_iterator - I = RegInfo->liveout_begin(), E = RegInfo->liveout_end(); I != E; ++I) + I = RegInfo->liveout_begin(), E = RegInfo->liveout_end(); I != E; ++I){ if (TRI) - OS << ' ' << TRI->getName(*I); + OS << '%' << TRI->getName(*I); else - OS << " Reg #" << *I; + OS << "%physreg" << *I; + + if (next(I) != E) + OS << " "; + } OS << '\n'; } - for (const_iterator BB = begin(), E = end(); BB != E; ++BB) + for (const_iterator BB = begin(), E = end(); BB != E; ++BB) { + OS << '\n'; BB->print(OS); + } - OS << "\n# End machine code for " << Fn->getName() << "().\n\n"; + OS << "\n# End machine code for function " << Fn->getName() << ".\n\n"; } namespace llvm { @@ -471,12 +480,16 @@ MachineFrameInfo::getPristineRegs(const MachineBasicBlock *MBB) const { void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{ + if (Objects.empty()) return; + const TargetFrameInfo *FI = MF.getTarget().getFrameInfo(); int ValOffset = (FI ? FI->getOffsetOfLocalArea() : 0); + OS << "Frame Objects:\n"; + for (unsigned i = 0, e = Objects.size(); i != e; ++i) { const StackObject &SO = Objects[i]; - OS << " <fi#" << (int)(i-NumFixedObjects) << ">: "; + OS << " fi#" << (int)(i-NumFixedObjects) << ": "; if (SO.Size == ~0ULL) { OS << "dead\n"; continue; @@ -484,15 +497,14 @@ void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{ if (SO.Size == 0) OS << "variable sized"; else - OS << "size is " << SO.Size << " byte" << (SO.Size != 1 ? "s," : ","); - OS << " alignment is " << SO.Alignment << " byte" - << (SO.Alignment != 1 ? "s," : ","); + OS << "size=" << SO.Size; + OS << ", align=" << SO.Alignment; if (i < NumFixedObjects) - OS << " fixed"; + OS << ", fixed"; if (i < NumFixedObjects || SO.SPOffset != -1) { int64_t Off = SO.SPOffset - ValOffset; - OS << " at location [SP"; + OS << ", at location [SP"; if (Off > 0) OS << "+" << Off; else if (Off < 0) @@ -501,9 +513,6 @@ void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{ } OS << "\n"; } - - if (HasVarSizedObjects) - OS << " Stack frame contains variable sized objects\n"; } void MachineFrameInfo::dump(const MachineFunction &MF) const { @@ -547,12 +556,17 @@ MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old, } void MachineJumpTableInfo::print(raw_ostream &OS) const { - // FIXME: this is lame, maybe we could print out the MBB numbers or something - // like {1, 2, 4, 5, 3, 0} + if (JumpTables.empty()) return; + + OS << "Jump Tables:\n"; + for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) { - OS << " <jt#" << i << "> has " << JumpTables[i].MBBs.size() - << " entries\n"; + OS << " jt#" << i << ": "; + for (unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j) + OS << " BB#" << JumpTables[i].MBBs[j]->getNumber(); } + + OS << '\n'; } void MachineJumpTableInfo::dump() const { print(errs()); } @@ -664,13 +678,16 @@ unsigned MachineConstantPool::getConstantPoolIndex(MachineConstantPoolValue *V, } void MachineConstantPool::print(raw_ostream &OS) const { + if (Constants.empty()) return; + + OS << "Constant Pool:\n"; for (unsigned i = 0, e = Constants.size(); i != e; ++i) { - OS << " <cp#" << i << "> is"; + OS << " cp#" << i << ": "; if (Constants[i].isMachineConstantPoolEntry()) Constants[i].Val.MachineCPVal->print(OS); else OS << *(Value*)Constants[i].Val.ConstVal; - OS << " , alignment=" << Constants[i].getAlignment(); + OS << ", align=" << Constants[i].getAlignment(); OS << "\n"; } } diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index c27ecff..5744c8a5 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -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"; diff --git a/lib/CodeGen/MachineVerifier.cpp b/lib/CodeGen/MachineVerifier.cpp index 45981d7..99812e0 100644 --- a/lib/CodeGen/MachineVerifier.cpp +++ b/lib/CodeGen/MachineVerifier.cpp @@ -243,7 +243,7 @@ void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB) { report(msg, MBB->getParent()); *OS << "- basic block: " << MBB->getBasicBlock()->getNameStr() << " " << (void*)MBB - << " (#" << MBB->getNumber() << ")\n"; + << " (BB#" << MBB->getNumber() << ")\n"; } void MachineVerifier::report(const char *msg, const MachineInstr *MI) { @@ -745,7 +745,7 @@ void MachineVerifier::checkPHIOps(const MachineBasicBlock *MBB) { PrE = MBB->pred_end(); PrI != PrE; ++PrI) { if (!seen.count(*PrI)) { report("Missing PHI operand", BBI); - *OS << "MBB #" << (*PrI)->getNumber() + *OS << "BB#" << (*PrI)->getNumber() << " is a predecessor according to the CFG.\n"; } } @@ -780,7 +780,7 @@ void MachineVerifier::visitMachineFunctionAfter() { report("Live-in physical register is not live-out from predecessor", MFI); *OS << "Register " << TRI->getName(*I) - << " is not live-out from MBB #" << (*PrI)->getNumber() + << " is not live-out from BB#" << (*PrI)->getNumber() << ".\n"; } } diff --git a/lib/CodeGen/PostRASchedulerList.cpp b/lib/CodeGen/PostRASchedulerList.cpp index 96146e9..7e85c48 100644 --- a/lib/CodeGen/PostRASchedulerList.cpp +++ b/lib/CodeGen/PostRASchedulerList.cpp @@ -258,7 +258,7 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) { if (bbcnt++ % DebugDiv != DebugMod) continue; errs() << "*** DEBUG scheduling " << Fn.getFunction()->getNameStr() << - ":MBB ID#" << MBB->getNumber() << " ***\n"; + ":BB#" << MBB->getNumber() << " ***\n"; } #endif @@ -453,7 +453,7 @@ bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI, /// incorrect by instruction reordering. /// void SchedulePostRATDList::FixupKills(MachineBasicBlock *MBB) { - DEBUG(errs() << "Fixup kills for BB ID#" << MBB->getNumber() << '\n'); + DEBUG(errs() << "Fixup kills for BB#" << MBB->getNumber() << '\n'); std::set<unsigned> killedRegs; BitVector ReservedRegs = TRI->getReservedRegs(MF); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 0af0746..98e7317 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -5754,9 +5754,9 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const { } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(this)) { if (G && R->getReg() && TargetRegisterInfo::isPhysicalRegister(R->getReg())) { - OS << " " << G->getTarget().getRegisterInfo()->getName(R->getReg()); + OS << " %" << G->getTarget().getRegisterInfo()->getName(R->getReg()); } else { - OS << " #" << R->getReg(); + OS << " %reg" << R->getReg(); } } else if (const ExternalSymbolSDNode *ES = dyn_cast<ExternalSymbolSDNode>(this)) { |