summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetRegisterInfo.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-03 22:49:04 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-03 22:49:04 +0000
commit2f460ae3b44d5163f2d7ce686d3def72afd332db (patch)
treec0854b92d79bc721c69ca9187c996d379272fb55 /llvm/lib/Target/TargetRegisterInfo.cpp
parent67dd612cddb0fd9b292d70fd0e64822a2a8c5d1f (diff)
downloadbcm5719-llvm-2f460ae3b44d5163f2d7ce686d3def72afd332db.tar.gz
bcm5719-llvm-2f460ae3b44d5163f2d7ce686d3def72afd332db.zip
Use a shared implementation of getMatchingSuperRegClass().
TargetRegisterClass now gives access to the necessary tables. llvm-svn: 156122
Diffstat (limited to 'llvm/lib/Target/TargetRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/TargetRegisterInfo.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp
index 10970f0c596..3ae3fed5d59 100644
--- a/llvm/lib/Target/TargetRegisterInfo.cpp
+++ b/llvm/lib/Target/TargetRegisterInfo.cpp
@@ -145,3 +145,33 @@ TargetRegisterInfo::getCommonSubClass(const TargetRegisterClass *A,
// No common sub-class exists.
return NULL;
}
+
+const TargetRegisterClass *
+TargetRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A,
+ const TargetRegisterClass *B,
+ unsigned Idx) const {
+ assert(A && B && "Missing register class");
+ assert(Idx && "Bad sub-register index");
+
+ // Find Idx in the list of super-register indices.
+ const uint16_t *SRI = B->getSuperRegIndices();
+ unsigned Offset = 0;
+ while (SRI[Offset] != Idx) {
+ if (!SRI[Offset])
+ return 0;
+ ++Offset;
+ }
+
+ // The register class bit mask corresponding to SRI[Offset]. The bit mask
+ // contains all register classes that are projected into B by Idx. Find a
+ // class that is also a sub-class of A.
+ const unsigned RCMaskWords = (getNumRegClasses()+31)/32;
+ const uint32_t *TV = B->getSubClassMask() + (Offset + 1) * RCMaskWords;
+ const uint32_t *SC = A->getSubClassMask();
+
+ // Find the first common register class in TV and SC.
+ for (unsigned i = 0; i != RCMaskWords ; ++i)
+ if (unsigned Common = TV[i] & SC[i])
+ return getRegClass(32*i + CountTrailingZeros_32(Common));
+ return 0;
+}
OpenPOWER on IntegriCloud