File indexing completed on 2026-05-10 08:44:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_MCA_STAGES_INORDERISSUESTAGE_H
0015 #define LLVM_MCA_STAGES_INORDERISSUESTAGE_H
0016
0017 #include "llvm/MCA/CustomBehaviour.h"
0018 #include "llvm/MCA/HardwareUnits/ResourceManager.h"
0019 #include "llvm/MCA/SourceMgr.h"
0020 #include "llvm/MCA/Stages/Stage.h"
0021
0022 namespace llvm {
0023 namespace mca {
0024 class LSUnitBase;
0025 class RegisterFile;
0026
0027 struct StallInfo {
0028 enum class StallKind {
0029 DEFAULT,
0030 REGISTER_DEPS,
0031 DISPATCH,
0032 DELAY,
0033 LOAD_STORE,
0034 CUSTOM_STALL
0035 };
0036
0037 InstRef IR;
0038 unsigned CyclesLeft = 0;
0039 StallKind Kind = StallKind::DEFAULT;
0040
0041 StallInfo() = default;
0042
0043 StallKind getStallKind() const { return Kind; }
0044 unsigned getCyclesLeft() const { return CyclesLeft; }
0045 const InstRef &getInstruction() const { return IR; }
0046 InstRef &getInstruction() { return IR; }
0047
0048 bool isValid() const { return (bool)IR; }
0049 void clear();
0050 void update(const InstRef &Inst, unsigned Cycles, StallKind SK);
0051 void cycleEnd();
0052 };
0053
0054 class InOrderIssueStage final : public Stage {
0055 const MCSubtargetInfo &STI;
0056 RegisterFile &PRF;
0057 ResourceManager RM;
0058 CustomBehaviour &CB;
0059 LSUnitBase &LSU;
0060
0061
0062 SmallVector<InstRef, 4> IssuedInst;
0063
0064
0065 unsigned NumIssued;
0066
0067 StallInfo SI;
0068
0069
0070 InstRef CarriedOver;
0071
0072 unsigned CarryOver;
0073
0074
0075 unsigned Bandwidth;
0076
0077
0078
0079
0080 unsigned LastWriteBackCycle;
0081
0082 InOrderIssueStage(const InOrderIssueStage &Other) = delete;
0083 InOrderIssueStage &operator=(const InOrderIssueStage &Other) = delete;
0084
0085
0086
0087
0088 bool canExecute(const InstRef &IR);
0089
0090
0091 Error tryIssue(InstRef &IR);
0092
0093
0094 void updateIssuedInst();
0095
0096
0097 void updateCarriedOver();
0098
0099
0100
0101 void notifyStallEvent();
0102
0103 void notifyInstructionIssued(const InstRef &IR,
0104 ArrayRef<ResourceUse> UsedRes);
0105 void notifyInstructionDispatched(const InstRef &IR, unsigned Ops,
0106 ArrayRef<unsigned> UsedRegs);
0107 void notifyInstructionExecuted(const InstRef &IR);
0108 void notifyInstructionRetired(const InstRef &IR,
0109 ArrayRef<unsigned> FreedRegs);
0110
0111
0112 void retireInstruction(InstRef &IR);
0113
0114 public:
0115 InOrderIssueStage(const MCSubtargetInfo &STI, RegisterFile &PRF,
0116 CustomBehaviour &CB, LSUnitBase &LSU);
0117
0118 unsigned getIssueWidth() const;
0119 bool isAvailable(const InstRef &) const override;
0120 bool hasWorkToComplete() const override;
0121 Error execute(InstRef &IR) override;
0122 Error cycleStart() override;
0123 Error cycleEnd() override;
0124 };
0125
0126 }
0127 }
0128
0129 #endif