summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/Target.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-09-13 07:40:53 +0000
committerClement Courbet <courbet@google.com>2018-09-13 07:40:53 +0000
commitd939f6d01396201d1b8fb5dba652e9528276e79e (patch)
treea6a1ce6223ee509273ef8b3f6d7c9a080ee6034a /llvm/tools/llvm-exegesis/lib/Target.cpp
parent58c3dee3b3cdf103680d80b61167dda9612d3e0d (diff)
downloadbcm5719-llvm-d939f6d01396201d1b8fb5dba652e9528276e79e.tar.gz
bcm5719-llvm-d939f6d01396201d1b8fb5dba652e9528276e79e.zip
[llvm-exegesis][NFC] Split BenchmarkRunner class
Summary: The snippet-generation part goes to the SnippetGenerator class. This will allow benchmarking arbitrary code (see PR38437). Reviewers: gchatelet Subscribers: mgorny, tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D51979 llvm-svn: 342117
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Target.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/Target.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 67a9ea65195..a8b34878475 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -36,6 +36,20 @@ void ExegesisTarget::registerTarget(ExegesisTarget *Target) {
FirstTarget = Target;
}
+std::unique_ptr<SnippetGenerator>
+ExegesisTarget::createSnippetGenerator(InstructionBenchmark::ModeE Mode,
+ const LLVMState &State) const {
+ switch (Mode) {
+ case InstructionBenchmark::Unknown:
+ return nullptr;
+ case InstructionBenchmark::Latency:
+ return createLatencySnippetGenerator(State);
+ case InstructionBenchmark::Uops:
+ return createUopsSnippetGenerator(State);
+ }
+ return nullptr;
+}
+
std::unique_ptr<BenchmarkRunner>
ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
const LLVMState &State) const {
@@ -50,6 +64,16 @@ ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
return nullptr;
}
+std::unique_ptr<SnippetGenerator>
+ExegesisTarget::createLatencySnippetGenerator(const LLVMState &State) const {
+ return llvm::make_unique<LatencySnippetGenerator>(State);
+}
+
+std::unique_ptr<SnippetGenerator>
+ExegesisTarget::createUopsSnippetGenerator(const LLVMState &State) const {
+ return llvm::make_unique<UopsSnippetGenerator>(State);
+}
+
std::unique_ptr<BenchmarkRunner>
ExegesisTarget::createLatencyBenchmarkRunner(const LLVMState &State) const {
return llvm::make_unique<LatencyBenchmarkRunner>(State);
OpenPOWER on IntegriCloud