PrintVRegOrUnit

llvm-svn: 189124
This commit is contained in:
Andrew Trick 2013-08-23 17:48:53 +00:00
parent e4c1ba762d
commit 475a9911ca
2 changed files with 24 additions and 0 deletions

View File

@ -901,6 +901,7 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintReg &PR) {
/// Usage: OS << PrintRegUnit(Unit, TRI) << '\n';
///
class PrintRegUnit {
protected:
const TargetRegisterInfo *TRI;
unsigned Unit;
public:
@ -914,6 +915,21 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintRegUnit &PR) {
return OS;
}
/// PrintVRegOrUnit - It is often convenient to track virtual registers and
/// physical register units in the same list.
class PrintVRegOrUnit : protected PrintRegUnit {
public:
PrintVRegOrUnit(unsigned VRegOrUnit, const TargetRegisterInfo *tri)
: PrintRegUnit(VRegOrUnit, tri) {}
void print(raw_ostream&) const;
};
static inline raw_ostream &operator<<(raw_ostream &OS,
const PrintVRegOrUnit &PR) {
PR.print(OS);
return OS;
}
} // End llvm namespace
#endif

View File

@ -73,6 +73,14 @@ void PrintRegUnit::print(raw_ostream &OS) const {
OS << '~' << TRI->getName(*Roots);
}
void PrintVRegOrUnit::print(raw_ostream &OS) const {
if (TRI && TRI->isVirtualRegister(Unit)) {
OS << "%vreg" << TargetRegisterInfo::virtReg2Index(Unit);
return;
}
PrintRegUnit::print(OS);
}
/// getAllocatableClass - Return the maximal subclass of the given register
/// class that is alloctable, or NULL.
const TargetRegisterClass *