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