Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 12d3dc7

Browse files
committed
PrintVRegOrUnit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189124 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 751c6d2 commit 12d3dc7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/llvm/Target/TargetRegisterInfo.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintReg &PR) {
901901
/// Usage: OS << PrintRegUnit(Unit, TRI) << '\n';
902902
///
903903
class PrintRegUnit {
904+
protected:
904905
const TargetRegisterInfo *TRI;
905906
unsigned Unit;
906907
public:
@@ -914,6 +915,21 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintRegUnit &PR) {
914915
return OS;
915916
}
916917

918+
/// PrintVRegOrUnit - It is often convenient to track virtual registers and
919+
/// physical register units in the same list.
920+
class PrintVRegOrUnit : protected PrintRegUnit {
921+
public:
922+
PrintVRegOrUnit(unsigned VRegOrUnit, const TargetRegisterInfo *tri)
923+
: PrintRegUnit(VRegOrUnit, tri) {}
924+
void print(raw_ostream&) const;
925+
};
926+
927+
static inline raw_ostream &operator<<(raw_ostream &OS,
928+
const PrintVRegOrUnit &PR) {
929+
PR.print(OS);
930+
return OS;
931+
}
932+
917933
} // End llvm namespace
918934

919935
#endif

lib/CodeGen/TargetRegisterInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ void PrintRegUnit::print(raw_ostream &OS) const {
7373
OS << '~' << TRI->getName(*Roots);
7474
}
7575

76+
void PrintVRegOrUnit::print(raw_ostream &OS) const {
77+
if (TRI && TRI->isVirtualRegister(Unit)) {
78+
OS << "%vreg" << TargetRegisterInfo::virtReg2Index(Unit);
79+
return;
80+
}
81+
PrintRegUnit::print(OS);
82+
}
83+
7684
/// getAllocatableClass - Return the maximal subclass of the given register
7785
/// class that is alloctable, or NULL.
7886
const TargetRegisterClass *

0 commit comments

Comments
 (0)