From 2445dc19168a4f188bc48746841d1a0105cc258e Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Thu, 7 Apr 2016 22:16:56 +0000 Subject: [PATCH] [TargetRegisterInfo] Refactor the code to use BitMaskClassIterator. llvm-svn: 265734 --- llvm/lib/CodeGen/TargetRegisterInfo.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index fc88629b5c8f..e1d90cb913e5 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; }