diff options
| author | Clement Courbet <courbet@google.com> | 2018-11-09 13:15:32 +0000 |
|---|---|---|
| committer | Clement Courbet <courbet@google.com> | 2018-11-09 13:15:32 +0000 |
| commit | eee2e06e2aa0fc13aae9db5d0149c21005c41961 (patch) | |
| tree | 87d95dcef8fc33dc000729fe1894b0f4d5e5de3f /llvm/utils | |
| parent | 72ccf00b1743f8c81f12b36156079e16f4c09893 (diff) | |
| download | bcm5719-llvm-eee2e06e2aa0fc13aae9db5d0149c21005c41961.tar.gz bcm5719-llvm-eee2e06e2aa0fc13aae9db5d0149c21005c41961.zip | |
[llvm-exegesis][NFC] Add a way to declare the default counter binding for unbound CPUs for a target.
Summary:
This simplifies the code and moves everything to tablegen for consistency. This
also prepares the ground for adding issue counters.
Reviewers: gchatelet, john.brawn, jsji
Subscribers: nemanjai, mgorny, javed.absar, kbarton, tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D54297
llvm-svn: 346489
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/TableGen/ExegesisEmitter.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/llvm/utils/TableGen/ExegesisEmitter.cpp b/llvm/utils/TableGen/ExegesisEmitter.cpp index 083d7439451..208237aca20 100644 --- a/llvm/utils/TableGen/ExegesisEmitter.cpp +++ b/llvm/utils/TableGen/ExegesisEmitter.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Debug.h" @@ -114,10 +115,6 @@ void ExegesisEmitter::emitPfmCountersInfo(const Record &Def, const size_t NumIssueCounters = Def.getValueAsListOfDefs("IssueCounters").size(); - // This is the default, do not emit. - if (CycleCounter.empty() && UopsCounter.empty() && NumIssueCounters == 0) - return; - OS << "\nstatic const PfmCountersInfo " << Target << Def.getName() << " = {\n"; @@ -157,28 +154,35 @@ void ExegesisEmitter::emitPfmCounters(raw_ostream &OS) const { // Emit the IssueCounters table. const auto PfmCounterDefs = Records.getAllDerivedDefinitions("ProcPfmCounters"); - OS << "static const PfmCountersInfo::IssueCounter " << Target - << "PfmIssueCounters[] = {\n"; - for (const Record *Def : PfmCounterDefs) { - for (const Record *ICDef : Def->getValueAsListOfDefs("IssueCounters")) - OS << " { " << Target << "PfmCounterNames[" - << getPfmCounterId(ICDef->getValueAsString("Counter")) << "], \"" - << ICDef->getValueAsString("ResourceName") << "\"},\n"; + // Only emit if non-empty. + const bool HasAtLeastOnePfmIssueCounter = + llvm::any_of(PfmCounterDefs, [](const Record *Def) { + return !Def->getValueAsListOfDefs("IssueCounters").empty(); + }); + if (HasAtLeastOnePfmIssueCounter) { + OS << "static const PfmCountersInfo::IssueCounter " << Target + << "PfmIssueCounters[] = {\n"; + for (const Record *Def : PfmCounterDefs) { + for (const Record *ICDef : Def->getValueAsListOfDefs("IssueCounters")) + OS << " { " << Target << "PfmCounterNames[" + << getPfmCounterId(ICDef->getValueAsString("Counter")) << "], \"" + << ICDef->getValueAsString("ResourceName") << "\"},\n"; + } + OS << "};\n"; } - OS << "};\n"; - // Now generate the PfmCountersInfo. unsigned IssueCountersTableOffset = 0; for (const Record *Def : PfmCounterDefs) emitPfmCountersInfo(*Def, IssueCountersTableOffset, OS); OS << "\n"; -} +} // namespace void ExegesisEmitter::emitPfmCountersLookupTable(raw_ostream &OS) const { std::vector<Record *> Bindings = Records.getAllDerivedDefinitions("PfmCountersBinding"); + assert(!Bindings.empty() && "there must be at least one binding"); llvm::sort(Bindings, [](const Record *L, const Record *R) { return L->getValueAsString("CpuName") < R->getValueAsString("CpuName"); }); |

