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 VA_VDST:
39 return "VA_VDST";
40 case VM_VSRC:
41 return "VM_VSRC";
42 case NUM_INST_CNTS:
43 return "NUM_INST_CNTS";
44 }
45 llvm_unreachable("Unhandled InstCounterType");
46}
47
48#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
49void Waitcnt::dump() const { dbgs() << *this << '\n'; }
50#endif
51
52Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded) {
53 Waitcnt Decoded;
54 Decoded.set(LOAD_CNT, decodeVmcnt(Version, Encoded));
55 Decoded.set(EXP_CNT, decodeExpcnt(Version, Encoded));
56 Decoded.set(DS_CNT, decodeLgkmcnt(Version, Encoded));
57 return Decoded;
58}
59
60unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded) {
61 return encodeWaitcnt(Version, Decoded.get(LOAD_CNT), Decoded.get(EXP_CNT),
62 Decoded.get(DS_CNT));
63}
64
65Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt) {
66 Waitcnt Decoded;
67 Decoded.set(LOAD_CNT, decodeLoadcnt(Version, LoadcntDscnt));
68 Decoded.set(DS_CNT, decodeDscnt(Version, LoadcntDscnt));
69 return Decoded;
70}
71
72Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt) {
73 Waitcnt Decoded;
74 Decoded.set(STORE_CNT, decodeStorecnt(Version, StorecntDscnt));
75 Decoded.set(DS_CNT, decodeDscnt(Version, StorecntDscnt));
76 return Decoded;
77}
78
79unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded) {
80 return encodeLoadcntDscnt(Version, Decoded.get(LOAD_CNT),
81 Decoded.get(DS_CNT));
82}
83
85 const Waitcnt &Decoded) {
87 Decoded.get(DS_CNT));
88}
89
90} // 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:207
Instruction set architecture version.