[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
diff --git a/llvm/tools/llvm-exegesis/lib/Uops.h b/llvm/tools/llvm-exegesis/lib/Uops.h
index 0236cd9..160397a 100644
--- a/llvm/tools/llvm-exegesis/lib/Uops.h
+++ b/llvm/tools/llvm-exegesis/lib/Uops.h
@@ -16,14 +16,14 @@
#define LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H
#include "BenchmarkRunner.h"
+#include "SnippetGenerator.h"
namespace exegesis {
-class UopsBenchmarkRunner : public BenchmarkRunner {
+class UopsSnippetGenerator : public SnippetGenerator {
public:
- UopsBenchmarkRunner(const LLVMState &State)
- : BenchmarkRunner(State, InstructionBenchmark::Uops) {}
- ~UopsBenchmarkRunner() override;
+ UopsSnippetGenerator(const LLVMState &State) : SnippetGenerator(State) {}
+ ~UopsSnippetGenerator() override;
llvm::Expected<CodeTemplate>
generateCodeTemplate(unsigned Opcode) const override;
@@ -33,10 +33,6 @@
private:
llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
- std::vector<BenchmarkMeasure>
- runMeasurements(const ExecutableFunction &EF, ScratchSpace &Scratch,
- const unsigned NumRepetitions) const override;
-
// Instantiates memory operands within a snippet.
// To make computations as parallel as possible, we generate independant
// memory locations for instructions that load and store. If there are less
@@ -65,6 +61,20 @@
std::vector<InstructionBuilder> &Snippet) const;
};
+class UopsBenchmarkRunner : public BenchmarkRunner {
+public:
+ UopsBenchmarkRunner(const LLVMState &State)
+ : BenchmarkRunner(State, InstructionBenchmark::Uops) {}
+ ~UopsBenchmarkRunner() override;
+
+ static constexpr const size_t kMinNumDifferentAddresses = 6;
+
+private:
+ std::vector<BenchmarkMeasure>
+ runMeasurements(const ExecutableFunction &EF, ScratchSpace &Scratch,
+ const unsigned NumRepetitions) const override;
+};
+
} // namespace exegesis
#endif // LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H