diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2016-04-07 22:16:56 +0000 |
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2016-04-07 22:16:56 +0000 |
| commit | 2445dc19168a4f188bc48746841d1a0105cc258e (patch) | |
| tree | 398e6e335f62750881e74180ce433b54e1a97750 /llvm/lib | |
| parent | cf477ffc58bbd4521fd4183b2321067a5da69e16 (diff) | |
| download | bcm5719-llvm-2445dc19168a4f188bc48746841d1a0105cc258e.tar.gz bcm5719-llvm-2445dc19168a4f188bc48746841d1a0105cc258e.zip | |
[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.
llvm-svn: 265734
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/TargetRegisterInfo.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index fc88629b5c8..e1d90cb913e 100644 --- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp +++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp @@ -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; } |

