[llvm-exegesis] Get the BenchmarkRunner from the ExegesisTarget.
Summary:
This allows targets to override code generation for some instructions.
As an example of override, this also moves ad-hoc instruction filtering
for X86 into the X86 ExegesisTarget.
Reviewers: gchatelet
Subscribers: mgorny, tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D48587
llvm-svn: 335582
diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index 1d35824..cb87e3a 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -17,6 +17,9 @@
#ifndef LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H
#define LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H
+#include "BenchmarkResult.h"
+#include "BenchmarkRunner.h"
+#include "LlvmState.h"
#include "llvm/ADT/Triple.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/LegacyPassManager.h"
@@ -35,9 +38,16 @@
return {};
}
+ // Creates a benchmark runner for the given mode.
+ std::unique_ptr<BenchmarkRunner>
+ createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
+ const LLVMState &State) const;
+
// Returns the ExegesisTarget for the given triple or nullptr if the target
// does not exist.
static const ExegesisTarget *lookup(llvm::Triple TT);
+ // Returns the default (unspecialized) ExegesisTarget.
+ static const ExegesisTarget &getDefault();
// Registers a target. Not thread safe.
static void registerTarget(ExegesisTarget *T);
@@ -45,6 +55,14 @@
private:
virtual bool matchesArch(llvm::Triple::ArchType Arch) const = 0;
+
+ // Targets can implement their own Latency/Uops benchmarks runners by
+ // implementing these.
+ std::unique_ptr<BenchmarkRunner> virtual createLatencyBenchmarkRunner(
+ const LLVMState &State) const;
+ std::unique_ptr<BenchmarkRunner> virtual createUopsBenchmarkRunner(
+ const LLVMState &State) const;
+
const ExegesisTarget *Next = nullptr;
};