From 0ba90f3e34b826b039bdfece1415ef032c4ad3f5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sat, 31 Oct 2009 20:19:03 +0000 Subject: 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 --- lib/CodeGen/MachineBasicBlock.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 4d1370aed9..7fbdb128fd 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 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'; } } -- cgit v1.2.3-18-g5258