summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-07-20 19:43:19 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2017-07-20 19:43:19 +0000
commitf3a778d75759ebb5c388ae93522a4cfabaebbd13 (patch)
tree31199e9b98a3e813615d86824dfa3e1251dff1b9
parent27c12e088ee520c2416d30fcb292d6666377c01f (diff)
downloadbcm5719-llvm-f3a778d75759ebb5c388ae93522a4cfabaebbd13.tar.gz
bcm5719-llvm-f3a778d75759ebb5c388ae93522a4cfabaebbd13.zip
Implement LaneBitmask::getNumLanes and LaneBitmask::getHighestLane
This should eliminate most uses of countPopulation and Log2_32 on the lane mask values. llvm-svn: 308658
-rw-r--r--llvm/include/llvm/MC/LaneBitmask.h7
-rw-r--r--llvm/lib/CodeGen/SplitKit.cpp6
-rw-r--r--llvm/lib/Target/AMDGPU/GCNRegPressure.cpp2
-rw-r--r--llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp3
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp8
5 files changed, 14 insertions, 12 deletions
diff --git a/llvm/include/llvm/MC/LaneBitmask.h b/llvm/include/llvm/MC/LaneBitmask.h
index 73b987b074d..35f472d817a 100644
--- a/llvm/include/llvm/MC/LaneBitmask.h
+++ b/llvm/include/llvm/MC/LaneBitmask.h
@@ -73,6 +73,13 @@ namespace llvm {
constexpr Type getAsInteger() const { return Mask; }
+ unsigned getNumLanes() const {
+ return countPopulation(Mask);
+ }
+ unsigned getHighestLane() const {
+ return Log2_32(Mask);
+ }
+
static LaneBitmask getNone() { return LaneBitmask(0); }
static LaneBitmask getAll() { return ~LaneBitmask(0); }
static LaneBitmask getLane(unsigned Lane) {
diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp
index 323045fd2aa..aaaa342b520 100644
--- a/llvm/lib/CodeGen/SplitKit.cpp
+++ b/llvm/lib/CodeGen/SplitKit.cpp
@@ -552,7 +552,7 @@ SlotIndex SplitEditor::buildCopy(unsigned FromReg, unsigned ToReg,
if ((SubRegMask & ~LaneMask).any())
continue;
- unsigned PopCount = countPopulation(SubRegMask.getAsInteger());
+ unsigned PopCount = SubRegMask.getNumLanes();
PossibleIndexes.push_back(Idx);
if (PopCount > BestCover) {
BestCover = PopCount;
@@ -583,8 +583,8 @@ SlotIndex SplitEditor::buildCopy(unsigned FromReg, unsigned ToReg,
// Try to cover as much of the remaining lanes as possible but
// as few of the already covered lanes as possible.
- int Cover = countPopulation((SubRegMask & LanesLeft).getAsInteger())
- - countPopulation((SubRegMask & ~LanesLeft).getAsInteger());
+ int Cover = (SubRegMask & LanesLeft).getNumLanes()
+ - (SubRegMask & ~LanesLeft).getNumLanes();
if (Cover > BestCover) {
BestCover = Cover;
BestIdx = Idx;
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
index 09cac8c2c8f..0384340174f 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -107,7 +107,7 @@ void GCNRegPressure::inc(unsigned Reg,
assert(PrevMask < NewMask);
Value[Kind == SGPR_TUPLE ? SGPR32 : VGPR32] +=
- Sign * countPopulation((~PrevMask & NewMask).getAsInteger());
+ Sign * (~PrevMask & NewMask).getNumLanes();
if (PrevMask.none()) {
assert(NewMask.any());
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 4a3fbb4593b..d9a5ce338bf 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -1275,8 +1275,7 @@ const TargetRegisterClass *SIRegisterInfo::getSubRegClass(
return RC;
// We can assume that each lane corresponds to one 32-bit register.
- LaneBitmask::Type Mask = getSubRegIndexLaneMask(SubIdx).getAsInteger();
- unsigned Count = countPopulation(Mask);
+ unsigned Count = getSubRegIndexLaneMask(SubIdx).getNumLanes();
if (isSGPRClass(RC)) {
switch (Count) {
case 1:
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 6399fb5ec1d..77450aef9a5 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -1295,9 +1295,7 @@ void CodeGenRegBank::computeSubRegLaneMasks() {
// Moving from a class with no subregisters we just had a single lane:
// The subregister must be a leaf subregister and only occupies 1 bit.
// Move the bit from the class without subregisters into that position.
- static_assert(sizeof(Idx.LaneMask.getAsInteger()) == 4,
- "Change Log2_32 to a proper one");
- unsigned DstBit = Log2_32(Idx.LaneMask.getAsInteger());
+ unsigned DstBit = Idx.LaneMask.getHighestLane();
assert(Idx.LaneMask == LaneBitmask::getLane(DstBit) &&
"Must be a leaf subregister");
MaskRolPair MaskRol = { LaneBitmask::getLane(0), (uint8_t)DstBit };
@@ -1328,9 +1326,7 @@ void CodeGenRegBank::computeSubRegLaneMasks() {
assert(Composite->getComposites().empty());
// Create Mask+Rotate operation and merge with existing ops if possible.
- static_assert(sizeof(Composite->LaneMask.getAsInteger()) == 4,
- "Change Log2_32 to a proper one");
- unsigned DstBit = Log2_32(Composite->LaneMask.getAsInteger());
+ unsigned DstBit = Composite->LaneMask.getHighestLane();
int Shift = DstBit - SrcBit;
uint8_t RotateLeft = Shift >= 0 ? (uint8_t)Shift
: LaneBitmask::BitWidth + Shift;
OpenPOWER on IntegriCloud