summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-31 17:18:29 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-31 17:18:29 +0000
commitfa9d7db17b76a6c139e28613a743950c719a1d36 (patch)
tree0da8f96469c0a65a463f2047773c500460584b3d /llvm/lib
parent2be0a77adeb603afbb4b3557d754b967e9d4bf4a (diff)
downloadbcm5719-llvm-fa9d7db17b76a6c139e28613a743950c719a1d36.tar.gz
bcm5719-llvm-fa9d7db17b76a6c139e28613a743950c719a1d36.zip
Add a PrintRegUnit helper similar to PrintReg.
Reg-units are named after their root registers, and most units have a single root, so they simply print as 'AL', 'XMM0', etc. The rare dual root reg-units print as FPSCR~FPSCR_NZCV, FP0~ST7, ... The printing piggybacks on the existing register name tables, so no extra const data space is required. llvm-svn: 157754
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/TargetRegisterInfo.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp
index a989cf4a7af..2395f2ba12a 100644
--- a/llvm/lib/Target/TargetRegisterInfo.cpp
+++ b/llvm/lib/Target/TargetRegisterInfo.cpp
@@ -46,6 +46,27 @@ void PrintReg::print(raw_ostream &OS) const {
}
}
+void PrintRegUnit::print(raw_ostream &OS) const {
+ // Generic printout when TRI is missing.
+ if (!TRI) {
+ OS << "Unit~" << Unit;
+ return;
+ }
+
+ // Check for invalid register units.
+ if (Unit >= TRI->getNumRegUnits()) {
+ OS << "BadUnit~" << Unit;
+ return;
+ }
+
+ // Normal units have at least one root.
+ MCRegUnitRootIterator Roots(Unit, TRI);
+ assert(Roots.isValid() && "Unit has no roots.");
+ OS << TRI->getName(*Roots);
+ for (++Roots; Roots.isValid(); ++Roots)
+ OS << '~' << TRI->getName(*Roots);
+}
+
/// getAllocatableClass - Return the maximal subclass of the given register
/// class that is alloctable, or NULL.
const TargetRegisterClass *
OpenPOWER on IntegriCloud