summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis')
-rw-r--r--llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp27
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.cpp11
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.h2
-rw-r--r--llvm/tools/llvm-exegesis/lib/PowerPC/Target.cpp20
-rw-r--r--llvm/tools/llvm-exegesis/lib/Target.cpp11
5 files changed, 17 insertions, 54 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
index 0197420f433..d6b6cff5472 100644
--- a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
@@ -14,22 +14,6 @@
namespace llvm {
namespace exegesis {
-namespace {
-
-class AArch64LatencyBenchmarkRunner : public LatencyBenchmarkRunner {
-public:
- AArch64LatencyBenchmarkRunner(const LLVMState &State)
- : LatencyBenchmarkRunner(State) {}
-
-private:
- const char *getCounterName() const override {
- // All AArch64 subtargets have CPU_CYCLES as the cycle counter name
- return "CPU_CYCLES";
- }
-};
-
-namespace {
-
static unsigned getLoadImmediateOpcode(unsigned RegBitWidth) {
switch (RegBitWidth) {
case 32:
@@ -50,11 +34,13 @@ static llvm::MCInst loadImmediate(unsigned Reg, unsigned RegBitWidth,
.addImm(Value.getZExtValue());
}
-} // namespace
+#include "AArch64GenExegesis.inc"
+
+namespace {
class ExegesisAArch64Target : public ExegesisTarget {
public:
- ExegesisAArch64Target() : ExegesisTarget({}) {}
+ ExegesisAArch64Target() : ExegesisTarget(AArch64CpuPfmCounters) {}
private:
std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
@@ -76,11 +62,6 @@ private:
// Function return is a pseudo-instruction that needs to be expanded
PM.add(llvm::createAArch64ExpandPseudoPass());
}
-
- std::unique_ptr<BenchmarkRunner>
- createLatencyBenchmarkRunner(const LLVMState &State) const override {
- return llvm::make_unique<AArch64LatencyBenchmarkRunner>(State);
- }
};
} // namespace
diff --git a/llvm/tools/llvm-exegesis/lib/Latency.cpp b/llvm/tools/llvm-exegesis/lib/Latency.cpp
index 3d18e37f4c3..9a56b275088 100644
--- a/llvm/tools/llvm-exegesis/lib/Latency.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Latency.cpp
@@ -166,13 +166,6 @@ LatencySnippetGenerator::generateCodeTemplates(const Instruction &Instr) const {
return std::move(Results);
}
-const char *LatencyBenchmarkRunner::getCounterName() const {
- const char *CounterName = State.getPfmCounters().CycleCounter;
- if (!CounterName)
- llvm::report_fatal_error("sched model does not define a cycle counter");
- return CounterName;
-}
-
LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default;
llvm::Expected<std::vector<BenchmarkMeasure>>
@@ -182,9 +175,9 @@ LatencyBenchmarkRunner::runMeasurements(
// measure several times and take the minimum value.
constexpr const int NumMeasurements = 30;
int64_t MinValue = std::numeric_limits<int64_t>::max();
- const char *CounterName = getCounterName();
+ const char *CounterName = State.getPfmCounters().CycleCounter;
if (!CounterName)
- llvm::report_fatal_error("could not determine cycle counter name");
+ llvm::report_fatal_error("sched model does not define a cycle counter");
for (size_t I = 0; I < NumMeasurements; ++I) {
auto ExpectedCounterValue = Executor.runAndMeasure(CounterName);
if (!ExpectedCounterValue)
diff --git a/llvm/tools/llvm-exegesis/lib/Latency.h b/llvm/tools/llvm-exegesis/lib/Latency.h
index fef72cde5a6..513c5f3ce78 100644
--- a/llvm/tools/llvm-exegesis/lib/Latency.h
+++ b/llvm/tools/llvm-exegesis/lib/Latency.h
@@ -40,8 +40,6 @@ public:
private:
llvm::Expected<std::vector<BenchmarkMeasure>>
runMeasurements(const FunctionExecutor &Executor) const override;
-
- virtual const char *getCounterName() const;
};
} // namespace exegesis
} // namespace llvm
diff --git a/llvm/tools/llvm-exegesis/lib/PowerPC/Target.cpp b/llvm/tools/llvm-exegesis/lib/PowerPC/Target.cpp
index b4c7ce64a50..b4bdb5dc4ad 100644
--- a/llvm/tools/llvm-exegesis/lib/PowerPC/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/PowerPC/Target.cpp
@@ -15,24 +15,12 @@
namespace llvm {
namespace exegesis {
-namespace {
-class PowerPCLatencyBenchmarkRunner : public LatencyBenchmarkRunner {
-public:
- PowerPCLatencyBenchmarkRunner(const LLVMState &State)
- : LatencyBenchmarkRunner(State) {}
-
-private:
- const char *getCounterName() const override {
- // All PowerPC subtargets have CYCLES as the cycle counter name
- return "CYCLES";
- }
-};
-} // end anonymous namespace
+#include "PPCGenExegesis.inc"
namespace {
class ExegesisPowerPCTarget : public ExegesisTarget {
public:
- ExegesisPowerPCTarget() : ExegesisTarget({}) {}
+ ExegesisPowerPCTarget() : ExegesisTarget(PPCCpuPfmCounters) {}
private:
std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
@@ -41,10 +29,6 @@ private:
bool matchesArch(llvm::Triple::ArchType Arch) const override {
return Arch == llvm::Triple::ppc64le;
}
- std::unique_ptr<BenchmarkRunner>
- createLatencyBenchmarkRunner(const LLVMState &State) const override {
- return llvm::make_unique<PowerPCLatencyBenchmarkRunner>(State);
- }
};
} // end anonymous namespace
diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 06557770418..2c89d27b4ab 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -87,7 +87,8 @@ ExegesisTarget::createUopsBenchmarkRunner(const LLVMState &State) const {
static_assert(std::is_pod<PfmCountersInfo>::value,
"We shouldn't have dynamic initialization here");
-const PfmCountersInfo PfmCountersInfo::Default = {nullptr, nullptr, nullptr, 0u};
+const PfmCountersInfo PfmCountersInfo::Default = {nullptr, nullptr, nullptr,
+ 0u};
const PfmCountersInfo &
ExegesisTarget::getPfmCounters(llvm::StringRef CpuName) const {
@@ -103,7 +104,13 @@ ExegesisTarget::getPfmCounters(llvm::StringRef CpuName) const {
std::lower_bound(CpuPfmCounters.begin(), CpuPfmCounters.end(), CpuName);
if (Found == CpuPfmCounters.end() ||
llvm::StringRef(Found->CpuName) != CpuName) {
- return PfmCountersInfo::Default;
+ // Use the default.
+ if (CpuPfmCounters.begin() != CpuPfmCounters.end() &&
+ CpuPfmCounters.begin()->CpuName[0] == '\0') {
+ Found = CpuPfmCounters.begin(); // The target specifies a default.
+ } else {
+ return PfmCountersInfo::Default; // No default for the target.
+ }
}
assert(Found->PCI && "Missing counters");
return *Found->PCI;
OpenPOWER on IntegriCloud