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 }
48 "printTcgen05MMAKind called with invalid value for immediate argument");
49}
50
52 const Constant *ImmArgVal) {
53 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
54 uint64_t Val = CI->getZExtValue();
55 switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
57 OS << "discard";
58 return;
60 OS << "lastuse";
61 return;
63 OS << "fill";
64 return;
66 OS << "use";
67 return;
68 }
69 }
70 llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
71 "immediate argument");
72}
73
75 static constexpr StringRef TensormapElemTypes[] = {
76 "u8", "u16", "u32", "s32", "u64", "s64",
77 "f16", "f32", "f32.ftz", "f64", "bf16", "tf32",
78 "tf32.ftz", "b4x16", "b4x16_p64", "b6x16_p32"};
79 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
80 uint64_t Val = CI->getZExtValue();
81 if (Val <= static_cast<uint64_t>(nvvm::TensormapElemType::B6x16_p32)) {
82 OS << TensormapElemTypes[Val];
83 return;
84 }
85 }
86}
87
89 const Constant *ImmArgVal) {
90 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
91 uint64_t Val = CI->getZExtValue();
92 switch (static_cast<TensormapInterleaveLayout>(Val)) {
94 OS << "No interleave";
95 return;
97 OS << "16B interleave";
98 return;
100 OS << "32B interleave";
101 return;
102 }
103 }
104}
105
107 const Constant *ImmArgVal) {
108 static constexpr StringRef TensormapSwizzleModes[] = {
109 "No swizzling", "32B swizzling", "64B swizzling", "128B swizzling",
110 "96B swizzling"};
111 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
112 uint64_t Val = CI->getZExtValue();
113 if (Val <= static_cast<uint64_t>(nvvm::TensormapSwizzleMode::SWIZZLE_96B)) {
114 OS << TensormapSwizzleModes[Val];
115 return;
116 }
117 }
118}
119
121 const Constant *ImmArgVal) {
122 static constexpr StringRef TensormapSwizzleAtomicities[] = {
123 "16B", "32B", "32B + 8B flip", "64B"};
124 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
125 uint64_t Val = CI->getZExtValue();
126 if (Val <= static_cast<uint64_t>(
128 OS << TensormapSwizzleAtomicities[Val];
129 return;
130 }
131 }
132}
133
135 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
136 uint64_t Val = CI->getZExtValue();
137 OS << (Val == static_cast<uint64_t>(TensormapFillMode::ZERO_FILL)
138 ? "Zero fill"
139 : "OOB-NaN fill");
140 return;
141 }
142}
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