[llvm] [AMDGPU][SIInsertWaitcnts][NFC] Introduce Counter class (PR #190271)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 15:15:43 PDT 2026
================
@@ -733,14 +734,65 @@ class WaitcntBrackets {
bool empty(InstCounterType T) const { return getScoreRange(T) == 0; }
private:
+ /// A container that holds all counters.
+ class AllCounters {
+ /// A counter of a specific InstCounterType. Whenever this pass visits an
+ /// instruction that affects this counter type we "increment" the counter.
+ /// Conceptually the counter implements the value of the corresponding
+ /// AMDGPU hardware counter if none of the outstanding instructions that
+ /// affect this counter had completed. When a wait for this counter is
+ /// emitted then we "decrement" (or zero) the counter.
+ class Counter {
+ InstCounterType CntT;
+ const AMDGPU::HardwareLimits *Limits = nullptr;
+ unsigned LB = 0;
+ unsigned UB = 0;
+
+ public:
+ Counter() = default;
+ Counter(InstCounterType CntT, const AMDGPU::HardwareLimits &Limits)
+ : CntT(CntT), Limits(&Limits) {}
+ /// \returns the count of outstanding instrs tracked by this counter.
+ unsigned getValue() const { return UB - LB; }
+ // TODO: Make private: we should not provide raw access to the internals.
+ void setLB(unsigned NewLB) { LB = NewLB; }
+ // TODO: Make private: we should not provide raw access to the internals.
----------------
shiltian wrote:
+1
https://github.com/llvm/llvm-project/pull/190271
More information about the llvm-commits
mailing list