1 //===-- SchedClassResolution.h ----------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// Resolution of MCInst sched class into expanded form for further analysis.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H
15 #define LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H
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/Support/Error.h"
25 #include "llvm/Support/TargetRegistry.h"
26 #include "llvm/Support/raw_ostream.h"
31 // Computes the idealized ProcRes Unit pressure. This is the expected
32 // distribution if the CPU scheduler can distribute the load as evenly as
34 std::vector
<std::pair
<uint16_t, float>> computeIdealizedProcResPressure(
35 const llvm::MCSchedModel
&SM
,
36 llvm::SmallVector
<llvm::MCWriteProcResEntry
, 8> WPRS
);
38 // An llvm::MCSchedClassDesc augmented with some additional data.
39 struct ResolvedSchedClass
{
40 ResolvedSchedClass(const llvm::MCSubtargetInfo
&STI
,
41 unsigned ResolvedSchedClassId
, bool WasVariant
);
43 static std::pair
<unsigned /*SchedClassId*/, bool /*WasVariant*/>
44 resolveSchedClassId(const llvm::MCSubtargetInfo
&SubtargetInfo
,
45 const llvm::MCInstrInfo
&InstrInfo
,
46 const llvm::MCInst
&MCI
);
48 std::vector
<BenchmarkMeasure
>
49 getAsPoint(InstructionBenchmark::ModeE Mode
, const llvm::MCSubtargetInfo
&STI
,
50 ArrayRef
<PerInstructionStats
> Representative
) const;
52 const unsigned SchedClassId
;
53 const llvm::MCSchedClassDesc
*const SCDesc
;
54 const bool WasVariant
; // Whether the original class was variant.
55 const llvm::SmallVector
<llvm::MCWriteProcResEntry
, 8>
56 NonRedundantWriteProcRes
;
57 const std::vector
<std::pair
<uint16_t, float>> IdealizedProcResPressure
;
60 } // namespace exegesis
63 #endif // LLVM_TOOLS_LLVM_EXEGESIS_SCHEDCLASSRESOLUTION_H