[llvm] 130fa98 - [AMDGPU][NFC] dump Waitcnt using an ostream operator (#171251)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 07:15:58 PST 2025
Author: Sameer Sahasrabuddhe
Date: 2025-12-10T20:45:49+05:30
New Revision: 130fa98a29291e559a1061f0684a71e4a150c0dc
URL: https://github.com/llvm/llvm-project/commit/130fa98a29291e559a1061f0684a71e4a150c0dc
DIFF: https://github.com/llvm/llvm-project/commit/130fa98a29291e559a1061f0684a71e4a150c0dc.diff
LOG: [AMDGPU][NFC] dump Waitcnt using an ostream operator (#171251)
Added:
Modified:
llvm/include/llvm/ADT/StringExtras.h
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index 2440e7678a831..abdf5337d68b2 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -541,6 +541,7 @@ class ListSeparator {
}
return Separator;
}
+ bool unused() { return First; }
};
/// A forward iterator over partitions of string over a separator.
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 146f3604d9f8f..3d6fc309c7cf4 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1451,9 +1451,9 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
} else if (Opcode == AMDGPU::S_WAITCNT_lds_direct) {
assert(ST->hasVMemToLDSLoad());
LLVM_DEBUG(dbgs() << "Processing S_WAITCNT_lds_direct: " << II
- << "Before: " << Wait.LoadCnt << '\n';);
+ << "Before: " << Wait;);
ScoreBrackets.determineWait(LOAD_CNT, FIRST_LDS_VGPR, Wait);
- LLVM_DEBUG(dbgs() << "After: " << Wait.LoadCnt << '\n';);
+ LLVM_DEBUG(dbgs() << "After: " << Wait;);
// It is possible (but unlikely) that this is the only wait instruction,
// in which case, we exit this loop without a WaitcntInstr to consume
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index c6e061f368aef..78d2370f5bfa8 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -1712,6 +1712,30 @@ bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val) {
return false;
}
+raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait) {
+ ListSeparator LS;
+ if (Wait.LoadCnt != ~0u)
+ OS << LS << "LoadCnt: " << Wait.LoadCnt;
+ if (Wait.ExpCnt != ~0u)
+ OS << LS << "ExpCnt: " << Wait.ExpCnt;
+ if (Wait.DsCnt != ~0u)
+ OS << LS << "DsCnt: " << Wait.DsCnt;
+ if (Wait.StoreCnt != ~0u)
+ OS << LS << "StoreCnt: " << Wait.StoreCnt;
+ if (Wait.SampleCnt != ~0u)
+ OS << LS << "SampleCnt: " << Wait.SampleCnt;
+ if (Wait.BvhCnt != ~0u)
+ OS << LS << "BvhCnt: " << Wait.BvhCnt;
+ if (Wait.KmCnt != ~0u)
+ OS << LS << "KmCnt: " << Wait.KmCnt;
+ if (Wait.XCnt != ~0u)
+ OS << LS << "XCnt: " << Wait.XCnt;
+ if (LS.unused())
+ OS << "none";
+ OS << '\n';
+ return OS;
+}
+
unsigned getVmcntBitMask(const IsaVersion &Version) {
return (1 << (getVmcntBitWidthLo(Version.Major) +
getVmcntBitWidthHi(Version.Major))) -
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index 3a352006e006c..75db58a292c13 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -1119,6 +1119,8 @@ struct Waitcnt {
std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
std::min(KmCnt, Other.KmCnt), std::min(XCnt, Other.XCnt));
}
+
+ friend raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait);
};
// The following methods are only meaningful on targets that support
More information about the llvm-commits
mailing list