diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-20 12:25:54 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-20 12:25:54 +0000 |
commit | 4704f0386bb8a29edb5d014ef7c00ef1b82fe78d (patch) | |
tree | 0259e9d0987c641812784514b3e69858e3ab902f /llvm/tools/llvm-mca/Scheduler.cpp | |
parent | a713ebea2456be61281e7570106a842357ce43a1 (diff) | |
download | bcm5719-llvm-4704f0386bb8a29edb5d014ef7c00ef1b82fe78d.tar.gz bcm5719-llvm-4704f0386bb8a29edb5d014ef7c00ef1b82fe78d.zip |
[llvm-mca] Move the routine that computes processor resource masks to its own file.
Function computeProcResourceMasks is used by the ResourceManager (owned by the
Scheduler) to compute resource masks for processor resources. Before this
refactoring, there was an implicit dependency between the Scheduler and the
InstrBuilder. That is because InstrBuilder has to know about resource masks when
computing the set of processor resources consumed by a new instruction.
With this patch, the functionality that computes resource masks has been
extracted from the ResourceManager, and moved to a separate file (Support.h).
This helps removing the dependency between the Scheduler and the InstrBuilder.
No functional change intended.
llvm-svn: 327973
Diffstat (limited to 'llvm/tools/llvm-mca/Scheduler.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/Scheduler.cpp | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/llvm/tools/llvm-mca/Scheduler.cpp b/llvm/tools/llvm-mca/Scheduler.cpp index 0a8c73665e4..4d7f1a222ca 100644 --- a/llvm/tools/llvm-mca/Scheduler.cpp +++ b/llvm/tools/llvm-mca/Scheduler.cpp @@ -11,9 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "Scheduler.h" #include "Backend.h" #include "HWEventListener.h" +#include "Scheduler.h" +#include "Support.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -43,6 +44,12 @@ void ResourceState::dump() const { } #endif +void ResourceManager::initialize(const llvm::MCSchedModel &SM) { + computeProcResourceMasks(SM, ProcResID2Mask); + for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) + addResource(*SM.getProcResource(I), I, ProcResID2Mask[I]); +} + // Adds a new resource state in Resources, as well as a new descriptor in // ResourceDescriptor. Map 'Resources' allows to quickly obtain ResourceState // objects from resource mask identifiers. @@ -52,36 +59,6 @@ void ResourceManager::addResource(const MCProcResourceDesc &Desc, Resources[Mask] = llvm::make_unique<ResourceState>(Desc, Index, Mask); } -// Populate vector ProcResID2Mask with resource masks. One per each processor -// resource declared by the scheduling model. -void ResourceManager::computeProcResourceMasks(const MCSchedModel &SM) { - unsigned ProcResourceID = 0; - - // Create a unique bitmask for every processor resource unit. - // Skip resource at index 0, since it always references 'InvalidUnit'. - ProcResID2Mask.resize(SM.getNumProcResourceKinds()); - for (unsigned I = 1, E = SM.getNumProcResourceKinds(); I < E; ++I) { - const MCProcResourceDesc &Desc = *SM.getProcResource(I); - if (Desc.SubUnitsIdxBegin) - continue; - ProcResID2Mask[I] = 1ULL << ProcResourceID; - ProcResourceID++; - } - - // Create a unique bitmask for every processor resource group. - for (unsigned I = 1, E = SM.getNumProcResourceKinds(); I < E; ++I) { - const MCProcResourceDesc &Desc = *SM.getProcResource(I); - if (!Desc.SubUnitsIdxBegin) - continue; - ProcResID2Mask[I] |= 1ULL << ProcResourceID; - for (unsigned U = 0; U < Desc.NumUnits; ++U) { - uint64_t OtherMask = ProcResID2Mask[Desc.SubUnitsIdxBegin[U]]; - ProcResID2Mask[I] |= OtherMask; - } - ProcResourceID++; - } -} - // Returns the actual resource consumed by this Use. // First, is the primary resource ID. // Second, is the specific sub-resource ID. |