blob: 038dcac1e16db2577f2df9991340506847bf99bd [file] [log] [blame]
Clement Courbet9431b722019-09-27 12:56:24 +00001//===-- SnippetRepetitor.h --------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// Defines helpers to fill functions with repetitions of a snippet.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
15#define LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
16
17#include "Assembler.h"
18#include "BenchmarkResult.h"
19#include "LlvmState.h"
20#include "llvm/ADT/BitVector.h"
21#include "llvm/CodeGen/MachineFunction.h"
22#include "llvm/MC/MCInst.h"
23#include "llvm/MC/MCInstrInfo.h"
24#include "llvm/Object/Binary.h"
25
26namespace llvm {
27namespace exegesis {
28
29class SnippetRepetitor {
30public:
31 static std::unique_ptr<const SnippetRepetitor>
32 Create(InstructionBenchmark::RepetitionModeE Mode, const LLVMState &State);
33
34 virtual ~SnippetRepetitor();
35
36 // Returns the set of registers that are reserved by the repetitor.
37 virtual BitVector getReservedRegs() const = 0;
38
39 // Returns a functor that repeats `Instructions` so that the function executes
40 // at least `MinInstructions` instructions.
41 virtual FillFunction Repeat(ArrayRef<MCInst> Instructions,
42 unsigned MinInstructions) const = 0;
43
44 explicit SnippetRepetitor(const LLVMState &State) : State(State) {}
45
46protected:
47 const LLVMState &State;
48};
49
50} // namespace exegesis
51} // namespace llvm
52
53#endif