LLVM 23.0.0git
AMDGPUWaitcntUtils.cpp
Go to the documentation of this file.
1//===- AMDGPUWaitcntUtils.cpp ---------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12namespace llvm::AMDGPU {
13
17
19 switch (T) {
20 case LOAD_CNT:
21 return "LOAD_CNT";
22 case DS_CNT:
23 return "DS_CNT";
24 case EXP_CNT:
25 return "EXP_CNT";
26 case STORE_CNT:
27 return "STORE_CNT";
28 case SAMPLE_CNT:
29 return "SAMPLE_CNT";
30 case BVH_CNT:
31 return "BVH_CNT";
32 case KM_CNT:
33 return "KM_CNT";
34 case X_CNT:
35 return "X_CNT";
36 case ASYNC_CNT:
37 return "ASYNC_CNT";
38 case TENSOR_CNT:
39 return "TENSOR_CNT";
40 case VA_VDST:
41 return "VA_VDST";
42 case VM_VSRC:
43 return "VM_VSRC";
44 case NUM_INST_CNTS:
45 return "NUM_INST_CNTS";
46 }
47 llvm_unreachable("Unhandled InstCounterType");
48}
49
50#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
51void Waitcnt::dump() const { dbgs() << *this << '\n'; }
52#endif
53
54Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded) {
55 Waitcnt Decoded;
56 Decoded.set(LOAD_CNT, decodeVmcnt(Version, Encoded));
57 Decoded.set(EXP_CNT, decodeExpcnt(Version, Encoded));
58 Decoded.set(DS_CNT, decodeLgkmcnt(Version, Encoded));
59 return Decoded;
60}
61
62unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded) {
63 return encodeWaitcnt(Version, Decoded.get(LOAD_CNT), Decoded.get(EXP_CNT),
64 Decoded.get(DS_CNT));
65}
66
67Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt) {
68 Waitcnt Decoded;
69 Decoded.set(LOAD_CNT, decodeLoadcnt(Version, LoadcntDscnt));
70 Decoded.set(DS_CNT, decodeDscnt(Version, LoadcntDscnt));
71 return Decoded;
72}
73
74Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt) {
75 Waitcnt Decoded;
76 Decoded.set(STORE_CNT, decodeStorecnt(Version, StorecntDscnt));
77 Decoded.set(DS_CNT, decodeDscnt(Version, StorecntDscnt));
78 return Decoded;
79}
80
81unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded) {
82 return encodeLoadcntDscnt(Version, Decoded.get(LOAD_CNT),
83 Decoded.get(DS_CNT));
84}
85
87 const Waitcnt &Decoded) {
89 Decoded.get(DS_CNT));
90}
91
92} // namespace llvm::AMDGPU
#define T
Represents the counter values to wait for in an s_waitcnt instruction.
LLVM_DUMP_METHOD void dump() const
unsigned get(InstCounterType T) const
void set(InstCounterType T, unsigned Val)
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:882
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
iota_range< InstCounterType > inst_counter_types(InstCounterType MaxCounter)
unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded)
unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded)
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt)
Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt)
unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt)
StringLiteral getInstCounterName(InstCounterType T)
unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt)
Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt)
unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt)
auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition Sequence.h:337
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:334
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
Instruction set architecture version.