summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-06-04 12:23:07 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-06-04 12:23:07 +0000
commit2008c7c8fdc27ca1ac25cf9758abea066047e67d (patch)
tree99cad6550d1675fe8b0898051c9bdbcb9adf1231 /llvm/tools/llvm-mca
parent9cb8e391839bc6f1ed0457ebde5a40fb86435772 (diff)
downloadbcm5719-llvm-2008c7c8fdc27ca1ac25cf9758abea066047e67d.tar.gz
bcm5719-llvm-2008c7c8fdc27ca1ac25cf9758abea066047e67d.zip
[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
Diffstat (limited to 'llvm/tools/llvm-mca')
-rw-r--r--llvm/tools/llvm-mca/InstrBuilder.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/tools/llvm-mca/InstrBuilder.cpp b/llvm/tools/llvm-mca/InstrBuilder.cpp
index bca3e4bc0d7..a745e1a6150 100644
--- a/llvm/tools/llvm-mca/InstrBuilder.cpp
+++ b/llvm/tools/llvm-mca/InstrBuilder.cpp
@@ -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++;
}
OpenPOWER on IntegriCloud