[llvm-exegesis] Provide a way to handle memory instructions.
[llvm-core.git] / tools / llvm-exegesis / lib / Latency.h
blobfdaeb786fa554842034f43732698babc4dc2c087
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"
21 namespace exegesis {
23 class LatencyBenchmarkRunner : public BenchmarkRunner {
24 public:
25 LatencyBenchmarkRunner(const LLVMState &State)
26 : BenchmarkRunner(State, InstructionBenchmark::Latency) {}
27 ~LatencyBenchmarkRunner() override;
29 llvm::Expected<SnippetPrototype>
30 generatePrototype(unsigned Opcode) const override;
32 private:
33 llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
35 llvm::Expected<SnippetPrototype> generateTwoInstructionPrototype(
36 const Instruction &Instr) const;
38 std::vector<BenchmarkMeasure>
39 runMeasurements(const ExecutableFunction &EF, ScratchSpace &Scratch,
40 const unsigned NumRepetitions) const override;
42 virtual const char *getCounterName() const;
45 } // namespace exegesis
47 #endif // LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H