LLVM 24.0.0git
NVVMIntrinsicUtils.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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//
9// This file implements functions associated with NVVM Intrinsics.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/StringRef.h"
15
16using namespace llvm;
17using namespace nvvm;
18
19void nvvm::printTMAReductionOp(raw_ostream &OS, const Constant *ImmArgVal) {
20 const auto *CI = dyn_cast<ConstantInt>(ImmArgVal);
21 if (!CI || CI->getZExtValue() > static_cast<uint64_t>(TMAReductionOp::XOR))
23 "printTMAReductionOp called with invalid value for immediate argument");
24
26 static_cast<TMAReductionOp>(CI->getZExtValue()));
27}
28
29void nvvm::printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
30 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
31 uint64_t Val = CI->getZExtValue();
32 switch (static_cast<Tcgen05MMAKind>(Val)) {
34 OS << "f16";
35 return;
37 OS << "tf32";
38 return;
40 OS << "f8f6f4";
41 return;
43 OS << "i8";
44 return;
45 }
46 }
47}
48
50 const Constant *ImmArgVal) {
51 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
52 uint64_t Val = CI->getZExtValue();
53 switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
55 OS << "discard";
56 return;
58 OS << "lastuse";
59 return;
61 OS << "fill";
62 return;
64 OS << "use";
65 return;
66 }
67 }
68}
69
71 static constexpr StringRef TensormapElemTypes[] = {
72 "u8", "u16", "u32", "s32", "u64", "s64",
73 "f16", "f32", "f32.ftz", "f64", "bf16", "tf32",
74 "tf32.ftz", "b4x16", "b4x16_p64", "b6x16_p32"};
75 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
76 uint64_t Val = CI->getZExtValue();
77 if (Val <= static_cast<uint64_t>(nvvm::TensormapElemType::B6x16_p32)) {
78 OS << TensormapElemTypes[Val];
79 return;
80 }
81 }
82}
83
85 const Constant *ImmArgVal) {
86 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
87 uint64_t Val = CI->getZExtValue();
88 switch (static_cast<TensormapInterleaveLayout>(Val)) {
90 OS << "No interleave";
91 return;
93 OS << "16B interleave";
94 return;
96 OS << "32B interleave";
97 return;
98 }
99 }
100}
101
103 const Constant *ImmArgVal) {
104 static constexpr StringRef TensormapSwizzleModes[] = {
105 "No swizzling", "32B swizzling", "64B swizzling", "128B swizzling",
106 "96B swizzling"};
107 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
108 uint64_t Val = CI->getZExtValue();
109 if (Val <= static_cast<uint64_t>(nvvm::TensormapSwizzleMode::SWIZZLE_96B)) {
110 OS << TensormapSwizzleModes[Val];
111 return;
112 }
113 }
114}
115
117 const Constant *ImmArgVal) {
118 static constexpr StringRef TensormapSwizzleAtomicities[] = {
119 "16B", "32B", "32B + 8B flip", "64B"};
120 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
121 uint64_t Val = CI->getZExtValue();
122 if (Val <= static_cast<uint64_t>(
124 OS << TensormapSwizzleAtomicities[Val];
125 return;
126 }
127 }
128}
129
131 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
132 uint64_t Val = CI->getZExtValue();
133 OS << (Val == static_cast<uint64_t>(TensormapFillMode::ZERO_FILL)
134 ? "Zero fill"
135 : "OOB-NaN fill");
136 return;
137 }
138}
This file contains the definitions of the enumerations and flags associated with NVVM Intrinsics,...
This is an important base class in LLVM.
Definition Constant.h:43
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI void printTensormapSwizzleMode(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTMAReductionOp(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTensormapInterleaveLayout(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTensormapSwizzleAtomicity(raw_ostream &OS, const Constant *ImmArgVal)
StringRef getTMATensorReductionOpName(TMAReductionOp Op)
LLVM_ABI void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTensormapFillMode(raw_ostream &OS, const Constant *ImmArgVal)
LLVM_ABI void printTensormapElemType(raw_ostream &OS, const Constant *ImmArgVal)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643