[llvm] r189124 - PrintVRegOrUnit
Andrew Trick
atrick at apple.com
Fri Aug 23 10:48:54 PDT 2013
Author: atrick
Date: Fri Aug 23 12:48:53 2013
New Revision: 189124
URL: http://llvm.org/viewvc/llvm-project?rev=189124&view=rev
Log:
PrintVRegOrUnit
Modified:
llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
llvm/trunk/lib/CodeGen/TargetRegisterInfo.cpp
Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=189124&r1=189123&r2=189124&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Fri Aug 23 12:48:53 2013
@@ -901,6 +901,7 @@ static inline raw_ostream &operator<<(ra
/// Usage: OS << PrintRegUnit(Unit, TRI) << '\n';
///
class PrintRegUnit {
+protected:
const TargetRegisterInfo *TRI;
unsigned Unit;
public:
@@ -913,6 +914,21 @@ static inline raw_ostream &operator<<(ra
PR.print(OS);
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
Modified: llvm/trunk/lib/CodeGen/TargetRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetRegisterInfo.cpp?rev=189124&r1=189123&r2=189124&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetRegisterInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetRegisterInfo.cpp Fri Aug 23 12:48:53 2013
@@ -73,6 +73,14 @@ void PrintRegUnit::print(raw_ostream &OS
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 *
More information about the llvm-commits
mailing list