diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-08 23:27:30 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-08 23:27:30 +0000 |
commit | 10191fd44f696910915586fdc1d3b16a2b01c485 (patch) | |
tree | db36b096cbbb219ae2834d5c9d23ad74eb20f8f4 /llvm/lib/Target/TargetRegisterInfo.cpp | |
parent | 8499e1a4cb1b8d3c1229f51e0d604f03c0285037 (diff) | |
download | bcm5719-llvm-10191fd44f696910915586fdc1d3b16a2b01c485.tar.gz bcm5719-llvm-10191fd44f696910915586fdc1d3b16a2b01c485.zip |
Use a shared function for a common operation.
llvm-svn: 156441
Diffstat (limited to 'llvm/lib/Target/TargetRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/Target/TargetRegisterInfo.cpp | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp index 4acbe729d74..50ba91e5b16 100644 --- a/llvm/lib/Target/TargetRegisterInfo.cpp +++ b/llvm/lib/Target/TargetRegisterInfo.cpp @@ -143,17 +143,7 @@ TargetRegisterInfo::getCommonSubClass(const TargetRegisterClass *A, // Register classes are ordered topologically, so the largest common // sub-class it the common sub-class with the smallest ID. - const unsigned *SubA = A->getSubClassMask(); - const unsigned *SubB = B->getSubClassMask(); - - // We could start the search from max(A.ID, B.ID), but we are only going to - // execute 2-3 iterations anyway. - for (unsigned Base = 0, BaseE = getNumRegClasses(); Base < BaseE; Base += 32) - if (unsigned Common = *SubA++ & *SubB++) - return getRegClass(Base + CountTrailingZeros_32(Common)); - - // No common sub-class exists. - return NULL; + return firstCommonClass(A->getSubClassMask(), B->getSubClassMask(), this); } const TargetRegisterClass * @@ -166,21 +156,10 @@ TargetRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, // Find Idx in the list of super-register indices. 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 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 Base = 0, BaseE = getNumRegClasses(); Base < BaseE; Base += 32) - if (unsigned Common = *Mask++ & *SC++) - return getRegClass(Base + CountTrailingZeros_32(Common)); + if (RCI.getSubReg() == Idx) + // 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. + return firstCommonClass(RCI.getMask(), A->getSubClassMask(), this); return 0; } |