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

@ -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';
}
}