diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-01-03 14:47:46 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-01-03 14:47:46 +0000 |
| commit | b284054b2620c95115b938a3213a0aa4ca49090a (patch) | |
| tree | fafe0fddffbabf0215181be27bb997723267e5d4 /llvm/lib/MCA/HardwareUnits/ResourceManager.cpp | |
| parent | 2ba76be8823795ae34e9ee9eccf13964cab854a3 (diff) | |
| download | bcm5719-llvm-b284054b2620c95115b938a3213a0aa4ca49090a.tar.gz bcm5719-llvm-b284054b2620c95115b938a3213a0aa4ca49090a.zip | |
[MCA] Improve code comment and reuse an helper function in ResourceManager. NFCI
llvm-svn: 350322
Diffstat (limited to 'llvm/lib/MCA/HardwareUnits/ResourceManager.cpp')
| -rw-r--r-- | llvm/lib/MCA/HardwareUnits/ResourceManager.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp b/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp index 9fc92cd8185..6c21b771330 100644 --- a/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp +++ b/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp @@ -24,11 +24,17 @@ namespace mca { #define DEBUG_TYPE "llvm-mca" ResourceStrategy::~ResourceStrategy() = default; +// Returns the index of the highest bit set. For resource masks, the position of +// the highest bit set can be used to construct a resource mask identifier. +static unsigned getResourceStateIndex(uint64_t Mask) { + return std::numeric_limits<uint64_t>::digits - countLeadingZeros(Mask); +} + static uint64_t selectImpl(uint64_t CandidateMask, uint64_t &NextInSequenceMask) { - CandidateMask = 1ULL << (countLeadingZeros(CandidateMask) ^ - (std::numeric_limits<uint64_t>::digits - 1)); - NextInSequenceMask &= (CandidateMask ^ (CandidateMask - 1)); + // The upper bit set in CandidateMask identifies our next candidate resource. + CandidateMask = 1ULL << (getResourceStateIndex(CandidateMask) - 1); + NextInSequenceMask &= (CandidateMask | (CandidateMask - 1)); return CandidateMask; } @@ -69,8 +75,7 @@ ResourceState::ResourceState(const MCProcResourceDesc &Desc, unsigned Index, BufferSize(Desc.BufferSize), IsAGroup(countPopulation(ResourceMask) > 1) { if (IsAGroup) { ResourceSizeMask = - ResourceMask ^ (1ULL << (countLeadingZeros(ResourceMask) ^ - (std::numeric_limits<uint64_t>::digits - 1))); + ResourceMask ^ 1ULL << (getResourceStateIndex(ResourceMask) - 1); } else { ResourceSizeMask = (1ULL << Desc.NumUnits) - 1; } @@ -103,10 +108,6 @@ void ResourceState::dump() const { } #endif -static unsigned getResourceStateIndex(uint64_t Mask) { - return std::numeric_limits<uint64_t>::digits - countLeadingZeros(Mask); -} - static std::unique_ptr<ResourceStrategy> getStrategyFor(const ResourceState &RS) { if (RS.isAResourceGroup() || RS.getNumUnits() > 1) |

