File indexing completed on 2026-05-10 08:44:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef LLVM_MCA_STAGES_MICROOPQUEUESTAGE_H
0017 #define LLVM_MCA_STAGES_MICROOPQUEUESTAGE_H
0018
0019 #include "llvm/ADT/SmallVector.h"
0020 #include "llvm/MCA/Stages/Stage.h"
0021
0022 namespace llvm {
0023 namespace mca {
0024
0025
0026 class MicroOpQueueStage : public Stage {
0027 SmallVector<InstRef, 8> Buffer;
0028 unsigned NextAvailableSlotIdx;
0029 unsigned CurrentInstructionSlotIdx;
0030
0031
0032
0033
0034 const unsigned MaxIPC;
0035 unsigned CurrentIPC;
0036
0037
0038 unsigned AvailableEntries;
0039
0040
0041
0042
0043 bool IsZeroLatencyStage;
0044
0045 MicroOpQueueStage(const MicroOpQueueStage &Other) = delete;
0046 MicroOpQueueStage &operator=(const MicroOpQueueStage &Other) = delete;
0047
0048
0049
0050
0051
0052
0053
0054 unsigned getNormalizedOpcodes(const InstRef &IR) const {
0055 unsigned NormalizedOpcodes =
0056 std::min(static_cast<unsigned>(Buffer.size()),
0057 IR.getInstruction()->getDesc().NumMicroOps);
0058 return NormalizedOpcodes ? NormalizedOpcodes : 1U;
0059 }
0060
0061 Error moveInstructions();
0062
0063 public:
0064 MicroOpQueueStage(unsigned Size, unsigned IPC = 0,
0065 bool ZeroLatencyStage = true);
0066
0067 bool isAvailable(const InstRef &IR) const override {
0068 if (MaxIPC && CurrentIPC == MaxIPC)
0069 return false;
0070 unsigned NormalizedOpcodes = getNormalizedOpcodes(IR);
0071 if (NormalizedOpcodes > AvailableEntries)
0072 return false;
0073 return true;
0074 }
0075
0076 bool hasWorkToComplete() const override {
0077 return AvailableEntries != Buffer.size();
0078 }
0079
0080 Error execute(InstRef &IR) override;
0081 Error cycleStart() override;
0082 Error cycleEnd() override;
0083 };
0084
0085 }
0086 }
0087
0088 #endif