14#ifndef LLVM_MCA_HARDWAREUNITS_SCHEDULER_H
15#define LLVM_MCA_HARDWAREUNITS_SCHEDULER_H
44 int computeRank(
const InstRef &Lhs)
const {
53 int LhsRank = computeRank(Lhs);
54 int RhsRank = computeRank(Rhs);
58 if (LhsRank == RhsRank)
60 return LhsRank < RhsRank;
75 std::unique_ptr<SchedulerStrategy> Strategy;
78 std::unique_ptr<ResourceManager> Resources;
112 std::vector<InstRef> WaitSet;
113 std::vector<InstRef> PendingSet;
114 std::vector<InstRef> ReadySet;
115 std::vector<InstRef> IssuedSet;
126 unsigned NumDispatchedToThePendingSet;
135 LLVM_ABI void initializeStrategy(std::unique_ptr<SchedulerStrategy> S);
138 void issueInstructionImpl(
162 std::unique_ptr<SchedulerStrategy> SelectStrategy)
167 std::unique_ptr<SchedulerStrategy> SelectStrategy)
168 : LSU(Lsu), Resources(
std::
move(RM)), BusyResourceUnits(0),
169 NumDispatchedToThePendingSet(0), HadTokenStall(
false) {
170 initializeStrategy(std::move(SelectStrategy));
235 return Resources->resolveResourceMask(Mask);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines a base class for describing a simulated hardware unit.
A Load/Store unit class that models load/store queues and that implements a simple weak memory consis...
Legalize the Machine IR a function s Machine IR
The classes here represent processor resource units and their management strategy.
This file defines the SmallVector class.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Default instruction selection strategy used by class Scheduler.
virtual ~DefaultSchedulerStrategy()
DefaultSchedulerStrategy()=default
bool compare(const InstRef &Lhs, const InstRef &Rhs) const override
Returns true if Lhs should take priority over Rhs.
An InstRef contains both a SourceMgr index and Instruction pair.
Instruction * getInstruction()
unsigned getSourceIndex() const
unsigned getNumUsers() const
Abstract base interface for LS (load/store) units in llvm-mca.
A resource manager for processor resource units and groups.
SchedulerStrategy()=default
virtual ~SchedulerStrategy()
virtual bool compare(const InstRef &Lhs, const InstRef &Rhs) const =0
Returns true if Lhs should take priority over Rhs.
Class Scheduler is responsible for issuing instructions to pipeline resources.
@ SC_DISPATCH_GROUP_STALL
LLVM_ABI InstRef select()
Select the next instruction to issue from the ReadySet.
unsigned getResourceID(uint64_t Mask) const
Convert a resource mask into a valid llvm processor resource identifier.
LLVM_ABI void issueInstruction(InstRef &IR, SmallVectorImpl< std::pair< ResourceRef, ReleaseAtCycles > > &Used, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)
Issue an instruction and populates a vector of used pipeline resources, and a vector of instructions ...
Scheduler(std::unique_ptr< ResourceManager > RM, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)
LLVM_ABI Status isAvailable(const InstRef &IR)
Check if the instruction in 'IR' can be dispatched during this cycle.
LLVM_ABI void analyzeDataDependencies(SmallVectorImpl< InstRef > &RegDeps, SmallVectorImpl< InstRef > &MemDeps)
This method is called by the ExecuteStage at the end of each cycle to identify bottlenecks caused by ...
Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)
LLVM_ABI bool dispatch(InstRef &IR)
Reserves buffer and LSUnit queue resources that are necessary to issue this instruction.
LLVM_ABI void cycleEvent(SmallVectorImpl< ResourceRef > &Freed, SmallVectorImpl< InstRef > &Executed, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)
This routine notifies the Scheduler that a new cycle just started.
LLVM_ABI bool mustIssueImmediately(const InstRef &IR) const
Returns true if IR has to be issued immediately, or if IR is a zero latency instruction.
LLVM_ABI uint64_t analyzeResourcePressure(SmallVectorImpl< InstRef > &Insts)
Returns a mask of busy resources, and populates vector Insts with instructions that could not be issu...
bool isReadySetEmpty() const
void instructionCheck(const InstRef &IR) const
Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu)
bool hadTokenStall() const
bool isWaitSetEmpty() const
Helper functions used by various pipeline components.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Implement std::hash so that hash_code can be used in STL containers.
Machine model for scheduling, bundling, and heuristics.