[llvm-exegesis] Implements a cache of Instruction objects.
[llvm-core.git] / tools / llvm-exegesis / lib / Latency.h
blobfef72cde5a6a224c5fdb56a4581dea03299ade07
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 llvm {
23 namespace exegesis {
25 class LatencySnippetGenerator : public SnippetGenerator {
26 public:
27 LatencySnippetGenerator(const LLVMState &State) : SnippetGenerator(State) {}
28 ~LatencySnippetGenerator() override;
30 llvm::Expected<std::vector<CodeTemplate>>
31 generateCodeTemplates(const Instruction &Instr) const override;
34 class LatencyBenchmarkRunner : public BenchmarkRunner {
35 public:
36 LatencyBenchmarkRunner(const LLVMState &State)
37 : BenchmarkRunner(State, InstructionBenchmark::Latency) {}
38 ~LatencyBenchmarkRunner() override;
40 private:
41 llvm::Expected<std::vector<BenchmarkMeasure>>
42 runMeasurements(const FunctionExecutor &Executor) const override;
44 virtual const char *getCounterName() const;
46 } // namespace exegesis
47 } // namespace llvm
49 #endif // LLVM_TOOLS_LLVM_EXEGESIS_LATENCY_H