SnippetRepetitor.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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,
  36. unsigned LoopBodySize) const = 0;
  37. explicit SnippetRepetitor(const LLVMState &State) : State(State) {}
  38. protected:
  39. const LLVMState &State;
  40. };
  41. } // namespace exegesis
  42. } // namespace llvm
  43. #endif