summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-14 18:53:39 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-14 18:53:39 +0000
commit2dd1ee5fd5486bb4b6438177d5afee319f4fab09 (patch)
tree907ce769375e9ec1002934aa801ab0df1bfeff48 /llvm
parent472362e6ed6866bc6518aea7c69e52c8d1d3eb47 (diff)
downloadbcm5719-llvm-2dd1ee5fd5486bb4b6438177d5afee319f4fab09.tar.gz
bcm5719-llvm-2dd1ee5fd5486bb4b6438177d5afee319f4fab09.zip
Add TargetRegisterInfo::printReg() to pretty-print registers.
llvm-svn: 121780
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Target/TargetRegisterInfo.h4
-rw-r--r--llvm/lib/Target/TargetRegisterInfo.cpp8
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/include/llvm/Target/TargetRegisterInfo.h b/llvm/include/llvm/Target/TargetRegisterInfo.h
index 9caedcb5064..5af90fbf8cd 100644
--- a/llvm/include/llvm/Target/TargetRegisterInfo.h
+++ b/llvm/include/llvm/Target/TargetRegisterInfo.h
@@ -29,6 +29,7 @@ class MachineFunction;
class MachineMove;
class RegScavenger;
template<class T> class SmallVectorImpl;
+class raw_ostream;
/// TargetRegisterDesc - This record contains all of the information known about
/// a particular register. The AliasSet field (if not null) contains a pointer
@@ -321,6 +322,9 @@ public:
return Reg >= FirstVirtualRegister;
}
+ /// printReg - Print a virtual or physical register on OS.
+ void printReg(unsigned Reg, raw_ostream &OS) const;
+
/// getMinimalPhysRegClass - Returns the Register Class of a physical
/// register of the given type, picking the most sub register class of
/// the right type that contains this physreg.
diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp
index 3beddf5fc77..078320d42f2 100644
--- a/llvm/lib/Target/TargetRegisterInfo.cpp
+++ b/llvm/lib/Target/TargetRegisterInfo.cpp
@@ -17,6 +17,7 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/ADT/BitVector.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -39,6 +40,13 @@ TargetRegisterInfo::TargetRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
TargetRegisterInfo::~TargetRegisterInfo() {}
+void TargetRegisterInfo::printReg(unsigned Reg, raw_ostream &OS) const {
+ if (Reg && isVirtualRegister(Reg))
+ OS << "%reg" << Reg;
+ else
+ OS << '%' << getName(Reg);
+}
+
/// getMinimalPhysRegClass - Returns the Register Class of a physical
/// register of the given type, picking the most sub register class of
/// the right type that contains this physreg.
OpenPOWER on IntegriCloud