[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/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h b/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h
index 52133b4..a0cfb1d 100644
--- a/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h
+++ b/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "Assembler.h"
+#include "Target.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
@@ -36,11 +37,11 @@
}
template <class... Bs> inline void Check(llvm::MCInst MCInst, Bs... Bytes) {
- CheckWithSetup(nullptr, {}, MCInst, Bytes...);
+ CheckWithSetup(ExegesisTarget::getDefault(), {}, MCInst, Bytes...);
}
template <class... Bs>
- inline void CheckWithSetup(const ExegesisTarget *ET,
+ inline void CheckWithSetup(const ExegesisTarget &ET,
llvm::ArrayRef<unsigned> RegsToDef,
llvm::MCInst MCInst, Bs... Bytes) {
ExecutableFunction Function =
@@ -67,7 +68,7 @@
}
ExecutableFunction
- assembleToFunction(const ExegesisTarget *ET,
+ assembleToFunction(const ExegesisTarget &ET,
llvm::ArrayRef<unsigned> RegsToDef,
llvm::ArrayRef<llvm::MCInst> Instructions) {
llvm::SmallString<256> Buffer;
diff --git a/llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
index 77de5e7..edacd7f 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
@@ -217,17 +217,14 @@
class FakeBenchmarkRunner : public BenchmarkRunner {
public:
- using BenchmarkRunner::BenchmarkRunner;
+ FakeBenchmarkRunner(const LLVMState &State)
+ : BenchmarkRunner(State, InstructionBenchmark::Unknown) {}
Instruction createInstruction(unsigned Opcode) {
return Instruction(State.getInstrInfo().get(Opcode), RATC);
}
private:
- InstructionBenchmark::ModeE getMode() const override {
- return InstructionBenchmark::Unknown;
- }
-
llvm::Expected<SnippetPrototype>
generatePrototype(unsigned Opcode) const override {
return llvm::make_error<llvm::StringError>("not implemented",