mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
[llvm-mca] Track cycles contributed by resources that are in a 'Super' relationship.
This is required if we want to correctly match the behavior of method SubtargetEmitter::ExpandProcResource() in Tablegen. When computing the set of "consumed" processor resources and resource cycles, the logic in ExpandProcResource() doesn't update the number of resource cycles contributed by a "Super" resource to a group. We need to take this into account when a model declares a processor resource which is part of a 'processor resource group', and it is also used as the "Super" of other resources. llvm-svn: 333892
This commit is contained in:
parent
98a53476a7
commit
9cf08c77bf
@ -13,6 +13,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "InstrBuilder.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
@ -33,6 +34,19 @@ static void initializeUsedResources(InstrDesc &ID,
|
||||
// Populate resources consumed.
|
||||
using ResourcePlusCycles = std::pair<uint64_t, ResourceUsage>;
|
||||
std::vector<ResourcePlusCycles> Worklist;
|
||||
|
||||
// Track cycles contributed by resources that are in a "Super" relationship.
|
||||
// This is required if we want to correctly match the behavior of method
|
||||
// SubtargetEmitter::ExpandProcResource() in Tablegen. When computing the set
|
||||
// of "consumed" processor resources and resource cycles, the logic in
|
||||
// ExpandProcResource() doesn't update the number of resource cycles
|
||||
// contributed by a "Super" resource to a group.
|
||||
// We need to take this into account when we find that a processor resource is
|
||||
// part of a group, and it is also used as the "Super" of other resources.
|
||||
// This map stores the number of cycles contributed by sub-resources that are
|
||||
// part of a "Super" resource. The key value is the "Super" resource mask ID.
|
||||
DenseMap<uint64_t, unsigned> SuperResources;
|
||||
|
||||
for (unsigned I = 0, E = SCDesc.NumWriteProcResEntries; I < E; ++I) {
|
||||
const MCWriteProcResEntry *PRE = STI.getWriteProcResBegin(&SCDesc) + I;
|
||||
const MCProcResourceDesc &PR = *SM.getProcResource(PRE->ProcResourceIdx);
|
||||
@ -41,6 +55,10 @@ static void initializeUsedResources(InstrDesc &ID,
|
||||
ID.Buffers.push_back(Mask);
|
||||
CycleSegment RCy(0, PRE->Cycles, false);
|
||||
Worklist.emplace_back(ResourcePlusCycles(Mask, ResourceUsage(RCy)));
|
||||
if (PR.SuperIdx) {
|
||||
uint64_t Super = ProcResourceMasks[PR.SuperIdx];
|
||||
SuperResources[Super] += PRE->Cycles;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort elements by mask popcount, so that we prioritize resource units over
|
||||
@ -80,7 +98,7 @@ static void initializeUsedResources(InstrDesc &ID,
|
||||
for (unsigned J = I + 1; J < E; ++J) {
|
||||
ResourcePlusCycles &B = Worklist[J];
|
||||
if ((NormalizedMask & B.first) == NormalizedMask) {
|
||||
B.second.CS.Subtract(A.second.size());
|
||||
B.second.CS.Subtract(A.second.size() - SuperResources[A.first]);
|
||||
if (countPopulation(B.first) > 1)
|
||||
B.second.NumUnits++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user