[llvm-exegesis][NFC] moving code around.
[llvm-complete.git] / tools / llvm-exegesis / lib / Latency.h
blob3a72d026d9fdda9ad033db692faefd49b5df4dec
1 //===-- Latency.h -----------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// A BenchmarkRunner implementation to measure instruction latencies.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H
16 #define LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H
18 #include "BenchmarkRunner.h"
19 #include "MCInstrDescView.h"
20 #include "SnippetGenerator.h"
22 namespace exegesis {
24 class LatencySnippetGenerator : public SnippetGenerator {
25 public:
26 LatencySnippetGenerator(const LLVMState &State) : SnippetGenerator(State) {}
27 ~LatencySnippetGenerator() override;
29 llvm::Expected<CodeTemplate>
30 generateCodeTemplate(unsigned Opcode) const override;
32 private:
33 llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
35 llvm::Expected<CodeTemplate>
36 generateTwoInstructionPrototype(const Instruction &Instr) const;
39 class LatencyBenchmarkRunner : public BenchmarkRunner {
40 public:
41 LatencyBenchmarkRunner(const LLVMState &State)
42 : BenchmarkRunner(State, InstructionBenchmark::Latency) {}
43 ~LatencyBenchmarkRunner() override;
45 private:
46 std::vector<BenchmarkMeasure>
47 runMeasurements(const ExecutableFunction &EF,
48 ScratchSpace &Scratch) const override;
50 virtual const char *getCounterName() const;
52 } // namespace exegesis
54 #endif // LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H