SchedClassResolution.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===-- SchedClassResolution.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. /// Resolution of MCInst sched class into expanded form for further analysis.
  11. ///
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H
  14. #define LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H
  15. #include "BenchmarkResult.h"
  16. #include "llvm/MC/MCContext.h"
  17. #include "llvm/MC/MCDisassembler/MCDisassembler.h"
  18. #include "llvm/MC/MCInstPrinter.h"
  19. #include "llvm/MC/MCInstrInfo.h"
  20. #include "llvm/MC/MCObjectFileInfo.h"
  21. #include "llvm/MC/MCSubtargetInfo.h"
  22. #include "llvm/MC/TargetRegistry.h"
  23. #include "llvm/Support/Error.h"
  24. #include "llvm/Support/raw_ostream.h"
  25. namespace llvm {
  26. namespace exegesis {
  27. // Computes the idealized ProcRes Unit pressure. This is the expected
  28. // distribution if the CPU scheduler can distribute the load as evenly as
  29. // possible.
  30. std::vector<std::pair<uint16_t, float>>
  31. computeIdealizedProcResPressure(const MCSchedModel &SM,
  32. SmallVector<MCWriteProcResEntry, 8> WPRS);
  33. // An MCSchedClassDesc augmented with some additional data.
  34. struct ResolvedSchedClass {
  35. ResolvedSchedClass(const MCSubtargetInfo &STI, unsigned ResolvedSchedClassId,
  36. bool WasVariant);
  37. static std::pair<unsigned /*SchedClassId*/, bool /*WasVariant*/>
  38. resolveSchedClassId(const MCSubtargetInfo &SubtargetInfo,
  39. const MCInstrInfo &InstrInfo, const MCInst &MCI);
  40. std::vector<BenchmarkMeasure>
  41. getAsPoint(InstructionBenchmark::ModeE Mode, const MCSubtargetInfo &STI,
  42. ArrayRef<PerInstructionStats> Representative) const;
  43. const unsigned SchedClassId;
  44. const MCSchedClassDesc *const SCDesc;
  45. const bool WasVariant; // Whether the original class was variant.
  46. const SmallVector<MCWriteProcResEntry, 8> NonRedundantWriteProcRes;
  47. const std::vector<std::pair<uint16_t, float>> IdealizedProcResPressure;
  48. };
  49. } // namespace exegesis
  50. } // namespace llvm
  51. #endif // LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H