Skip to content

Commit 130fa98

Browse files
authored
[AMDGPU][NFC] dump Waitcnt using an ostream operator (#171251)
1 parent fec0a64 commit 130fa98

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

llvm/include/llvm/ADT/StringExtras.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ class ListSeparator {
541541
}
542542
return Separator;
543543
}
544+
bool unused() { return First; }
544545
};
545546

546547
/// A forward iterator over partitions of string over a separator.

llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,9 +1451,9 @@ bool WaitcntGeneratorPreGFX12::applyPreexistingWaitcnt(
14511451
} else if (Opcode == AMDGPU::S_WAITCNT_lds_direct) {
14521452
assert(ST->hasVMemToLDSLoad());
14531453
LLVM_DEBUG(dbgs() << "Processing S_WAITCNT_lds_direct: " << II
1454-
<< "Before: " << Wait.LoadCnt << '\n';);
1454+
<< "Before: " << Wait;);
14551455
ScoreBrackets.determineWait(LOAD_CNT, FIRST_LDS_VGPR, Wait);
1456-
LLVM_DEBUG(dbgs() << "After: " << Wait.LoadCnt << '\n';);
1456+
LLVM_DEBUG(dbgs() << "After: " << Wait;);
14571457

14581458
// It is possible (but unlikely) that this is the only wait instruction,
14591459
// in which case, we exit this loop without a WaitcntInstr to consume

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,30 @@ bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val) {
17121712
return false;
17131713
}
17141714

1715+
raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait) {
1716+
ListSeparator LS;
1717+
if (Wait.LoadCnt != ~0u)
1718+
OS << LS << "LoadCnt: " << Wait.LoadCnt;
1719+
if (Wait.ExpCnt != ~0u)
1720+
OS << LS << "ExpCnt: " << Wait.ExpCnt;
1721+
if (Wait.DsCnt != ~0u)
1722+
OS << LS << "DsCnt: " << Wait.DsCnt;
1723+
if (Wait.StoreCnt != ~0u)
1724+
OS << LS << "StoreCnt: " << Wait.StoreCnt;
1725+
if (Wait.SampleCnt != ~0u)
1726+
OS << LS << "SampleCnt: " << Wait.SampleCnt;
1727+
if (Wait.BvhCnt != ~0u)
1728+
OS << LS << "BvhCnt: " << Wait.BvhCnt;
1729+
if (Wait.KmCnt != ~0u)
1730+
OS << LS << "KmCnt: " << Wait.KmCnt;
1731+
if (Wait.XCnt != ~0u)
1732+
OS << LS << "XCnt: " << Wait.XCnt;
1733+
if (LS.unused())
1734+
OS << "none";
1735+
OS << '\n';
1736+
return OS;
1737+
}
1738+
17151739
unsigned getVmcntBitMask(const IsaVersion &Version) {
17161740
return (1 << (getVmcntBitWidthLo(Version.Major) +
17171741
getVmcntBitWidthHi(Version.Major))) -

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ struct Waitcnt {
11191119
std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
11201120
std::min(KmCnt, Other.KmCnt), std::min(XCnt, Other.XCnt));
11211121
}
1122+
1123+
friend raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait);
11221124
};
11231125

11241126
// The following methods are only meaningful on targets that support

0 commit comments

Comments
 (0)