SnippetRepetitor.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
  14. #define LLVM_TOOLS_LLVM_EXEGESIS_FUNCTIONFILLER_H
  15. #include "Assembler.h"
  16. #include "BenchmarkResult.h"
  17. #include "LlvmState.h"
  18. #include "llvm/ADT/BitVector.h"
  19. #include "llvm/CodeGen/MachineFunction.h"
  20. #include "llvm/MC/MCInst.h"
  21. #include "llvm/MC/MCInstrInfo.h"
  22. #include "llvm/Object/Binary.h"
  23. namespace llvm {
  24. namespace exegesis {
  25. class SnippetRepetitor {
  26. public:
  27. static std::unique_ptr<const SnippetRepetitor>
  28. Create(InstructionBenchmark::RepetitionModeE Mode, const LLVMState &State);
  29. virtual ~SnippetRepetitor();
  30. // Returns the set of registers that are reserved by the repetitor.
  31. virtual BitVector getReservedRegs() const = 0;
  32. // Returns a functor that repeats `Instructions` so that the function executes
  33. // at least `MinInstructions` instructions.
  34. virtual FillFunction Repeat(ArrayRef<MCInst> Instructions,
  35. unsigned MinInstructions) const = 0;
  36. explicit SnippetRepetitor(const LLVMState &State) : State(State) {}
  37. protected:
  38. const LLVMState &State;
  39. };
  40. } // namespace exegesis
  41. } // namespace llvm
  42. #endif