[llvm-mca] Let the Scheduler notify dispatch stall events caused by the lack of scheduling resources.
This patch moves part of the logic that notifies dispatch stall events from the
DispatchUnit to the Scheduler.
The main goal of this patch is to remove (yet another) dependency between the
DispatchUnit and the Scheduler. Before this patch, the DispatchUnit had to know
about `Scheduler::Event` and how to classify stalls due to the lack of scheduling
resources. This patch removes that knowledge and simplifies the logic in
DispatchUnit::checkScheduler.
This is another change done in preparation for the work to fix PR36663.
No functional change intended.
llvm-svn: 329835
diff --git a/llvm/tools/llvm-mca/Scheduler.h b/llvm/tools/llvm-mca/Scheduler.h
index ad73fc7..9f9422c 100644
--- a/llvm/tools/llvm-mca/Scheduler.h
+++ b/llvm/tools/llvm-mca/Scheduler.h
@@ -454,42 +454,14 @@
void setDispatchUnit(DispatchUnit *DispUnit) { DU = DispUnit; }
- /// Scheduling events.
+ /// Check if instruction at index Idx can be dispatched.
///
/// The DispatchUnit is responsible for querying the Scheduler before
/// dispatching new instructions. Queries are performed through method
- /// `Scheduler::CanBeDispatched`, which returns an instance of this enum to
- /// tell if the dispatch would fail or not. If scheduling resources are
- /// available, and the instruction can be dispatched, then the query returns
- /// HWS_AVAILABLE. A values different than HWS_AVAILABLE means that the
- /// instruction cannot be dispatched during this cycle.
- ///
- /// Each event name starts with prefix "HWS_", and it is followed by
- /// a substring which describes the reason why the Scheduler was unavailable
- /// (or "AVAILABLE" if the instruction is allowed to be dispatched).
- ///
- /// HWS_QUEUE_UNAVAILABLE is returned if there are not enough available slots
- /// in the scheduler's queue. That means, one (or more) buffered resources
- /// consumed by the instruction were full.
- ///
- /// HWS_LD_QUEUE_UNAVAILABLE is returned when an instruction 'mayLoad', and
- /// the load queue in the load/store unit (implemented by class LSUnit) is
- /// full. Similarly, HWS_ST_QUEUE_UNAVAILABLE is returned when the store
- /// queue is full, and the instruction to be dispatched 'mayStore'.
- ///
- /// HWS_DISPATCH_GROUP_RESTRICTION is only returned in special cases where the
- /// instruction consumes an in-order issue/dispatch resource (i.e. a resource
- /// with `BufferSize=0`), and the pipeline resource is not immediately
- /// available.
- enum Event {
- HWS_AVAILABLE,
- HWS_QUEUE_UNAVAILABLE,
- HWS_DISPATCH_GROUP_RESTRICTION,
- HWS_LD_QUEUE_UNAVAILABLE,
- HWS_ST_QUEUE_UNAVAILABLE
- };
-
- Event canBeDispatched(const InstrDesc &Desc) const;
+ /// `Scheduler::CanBeDispatched`. If scheduling resources are available,
+ /// and the instruction can be dispatched, then this method returns true.
+ /// Otherwise, a generic HWStallEvent is notified to the listeners.
+ bool canBeDispatched(unsigned Idx, const InstrDesc &Desc) const;
void scheduleInstruction(unsigned Idx, Instruction &MCIS);
void cycleEvent(unsigned Cycle);