[RISCV] Eliminate dead li after emitting VSETVLIs (#65934)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / SnippetRepetitor.h
blob2b3c416c9029f70257f3099578aa8ff033d516f9
1 //===-- 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 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
15 #define LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
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"
26 namespace llvm {
27 namespace exegesis {
29 class SnippetRepetitor {
30 public:
31 static std::unique_ptr<const SnippetRepetitor>
32 Create(Benchmark::RepetitionModeE Mode, const LLVMState &State);
34 virtual ~SnippetRepetitor();
36 // Returns the set of registers that are reserved by the repetitor.
37 virtual BitVector getReservedRegs() const = 0;
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, unsigned LoopBodySize,
43 bool CleanupMemory) const = 0;
45 explicit SnippetRepetitor(const LLVMState &State) : State(State) {}
47 protected:
48 const LLVMState &State;
51 } // namespace exegesis
52 } // namespace llvm
54 #endif