mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.
llvm-svn: 265734
This commit is contained in:
parent
d9674601e1
commit
78377d114f
@ -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
Block a user