forked from OSchip/llvm-project
[RegisterBank] Add printable capabilities for future debugging.
llvm-svn: 265473
This commit is contained in:
parent
2d390b6c8b
commit
c94fbee9f6
|
@ -19,6 +19,7 @@
|
|||
namespace llvm {
|
||||
// Forward declarations.
|
||||
class RegisterBankInfo;
|
||||
class raw_ostream;
|
||||
class TargetRegisterClass;
|
||||
class TargetRegisterInfo;
|
||||
|
||||
|
@ -73,7 +74,24 @@ public:
|
|||
bool operator!=(const RegisterBank &OtherRB) const {
|
||||
return !this->operator==(OtherRB);
|
||||
}
|
||||
|
||||
/// Dump the register mask on dbgs() stream.
|
||||
/// The dump is verbose.
|
||||
void dump(const TargetRegisterInfo *TRI = nullptr) const;
|
||||
|
||||
/// Print the register mask on OS.
|
||||
/// If IsForDebug is false, then only the name of the register bank
|
||||
/// is printed. Otherwise, all the fields are printing.
|
||||
/// TRI is then used to print the name of the register classes that
|
||||
/// this register bank covers.
|
||||
void print(raw_ostream &OS, bool IsForDebug = false,
|
||||
const TargetRegisterInfo *TRI = nullptr) const;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const RegisterBank &RegBank) {
|
||||
RegBank.print(OS);
|
||||
return OS;
|
||||
}
|
||||
} // End namespace llvm.
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,3 +48,37 @@ bool RegisterBank::operator==(const RegisterBank &OtherRB) const {
|
|||
"ID does not uniquely identify a RegisterBank");
|
||||
return &OtherRB == this;
|
||||
}
|
||||
|
||||
void RegisterBank::dump(const TargetRegisterInfo *TRI) const {
|
||||
print(dbgs(), /* IsForDebug */ true, TRI);
|
||||
}
|
||||
|
||||
void RegisterBank::print(raw_ostream &OS, bool IsForDebug,
|
||||
const TargetRegisterInfo *TRI) const {
|
||||
OS << getName();
|
||||
if (!IsForDebug)
|
||||
return;
|
||||
OS << "(ID:" << getID() << ", Size:" << getSize() << ")\n"
|
||||
<< "isValid:" << isValid() << '\n'
|
||||
<< "Number of Covered register classes: " << ContainedRegClasses.count()
|
||||
<< '\n';
|
||||
// Print all the subclasses if we can.
|
||||
// This register classes may not be properly initialized yet.
|
||||
if (!TRI || ContainedRegClasses.empty())
|
||||
return;
|
||||
assert(ContainedRegClasses.size() == TRI->getNumRegClasses() &&
|
||||
"TRI does not match the initialization process?");
|
||||
bool IsFirst = true;
|
||||
OS << "Covered register classes:\n";
|
||||
for (unsigned RCId = 0, End = TRI->getNumRegClasses(); RCId != End; ++RCId) {
|
||||
const TargetRegisterClass &RC = *TRI->getRegClass(RCId);
|
||||
|
||||
if (!contains(RC))
|
||||
continue;
|
||||
|
||||
if (!IsFirst)
|
||||
OS << ", ";
|
||||
OS << TRI->getRegClassName(&RC);
|
||||
IsFirst = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue