forked from OSchip/llvm-project
[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.
llvm-svn: 265734
This commit is contained in:
parent
cf477ffc58
commit
2445dc1916
|
@ -112,18 +112,11 @@ TargetRegisterInfo::getAllocatableClass(const TargetRegisterClass *RC) const {
|
|||
if (!RC || RC->isAllocatable())
|
||||
return RC;
|
||||
|
||||
const unsigned *SubClass = RC->getSubClassMask();
|
||||
for (unsigned Base = 0, BaseE = getNumRegClasses();
|
||||
Base < BaseE; Base += 32) {
|
||||
unsigned Idx = Base;
|
||||
for (unsigned Mask = *SubClass++; Mask; Mask >>= 1) {
|
||||
unsigned Offset = countTrailingZeros(Mask);
|
||||
const TargetRegisterClass *SubRC = getRegClass(Idx + Offset);
|
||||
if (SubRC->isAllocatable())
|
||||
return SubRC;
|
||||
Mask >>= Offset;
|
||||
Idx += Offset + 1;
|
||||
}
|
||||
for (BitMaskClassIterator It(RC->getSubClassMask(), *this); It.isValid();
|
||||
++It) {
|
||||
const TargetRegisterClass *SubRC = getRegClass(It.getID());
|
||||
if (SubRC->isAllocatable())
|
||||
return SubRC;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue