summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetRegisterInfo.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-04 01:48:29 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-04 01:48:29 +0000
commit57c70506759429ddcbe9d3b8f3eab0f804829987 (patch)
tree5e3c1dde687afddbcfc0d19902476b2cac0a3bb1 /llvm/lib/Target/TargetRegisterInfo.cpp
parenta3c24f447fa1af4bcf0ccf242729825253e61432 (diff)
downloadbcm5719-llvm-57c70506759429ddcbe9d3b8f3eab0f804829987.tar.gz
bcm5719-llvm-57c70506759429ddcbe9d3b8f3eab0f804829987.zip
Add a SuperRegClassIterator class.
This iterator class provides a more abstract interface to the (Idx, Mask) lists of super-registers for a register class. The layout of the tables shouldn't be exposed to clients. llvm-svn: 156144
Diffstat (limited to 'llvm/lib/Target/TargetRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/TargetRegisterInfo.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp
index 3ae3fed5d59..d5518ea2c19 100644
--- a/llvm/lib/Target/TargetRegisterInfo.cpp
+++ b/llvm/lib/Target/TargetRegisterInfo.cpp
@@ -154,24 +154,22 @@ TargetRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A,
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;
- }
+ const uint32_t *Mask = 0;
+ for (SuperRegClassIterator RCI(B, this); RCI.isValid(); ++RCI)
+ if (RCI.getSubReg() == Idx) {
+ Mask = RCI.getMask();
+ break;
+ }
+ if (!Mask)
+ return 0;
- // 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;
+ // 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 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));
+ for (unsigned Base = 0, BaseE = getNumRegClasses(); Base < BaseE; Base += 32)
+ if (unsigned Common = *Mask++ & *SC++)
+ return getRegClass(Base + CountTrailingZeros_32(Common));
return 0;
}
OpenPOWER on IntegriCloud