LLVM 22.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::printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal) {
20 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
21 uint64_t Val = CI->getZExtValue();
22 switch (static_cast<Tcgen05MMAKind>(Val)) {
24 OS << "f16";
25 return;
27 OS << "tf32";
28 return;
30 OS << "f8f6f4";
31 return;
33 OS << "i8";
34 return;
35 }
36 }
38 "printTcgen05MMAKind called with invalid value for immediate argument");
39}
40
42 const Constant *ImmArgVal) {
43 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
44 uint64_t Val = CI->getZExtValue();
45 switch (static_cast<Tcgen05CollectorUsageOp>(Val)) {
47 OS << "discard";
48 return;
50 OS << "lastuse";
51 return;
53 OS << "fill";
54 return;
56 OS << "use";
57 return;
58 }
59 }
60 llvm_unreachable("printTcgen05CollectorUsageOp called with invalid value for "
61 "immediate argument");
62}
63
65 static constexpr StringRef TensormapElemTypes[] = {
66 "u8", "u16", "u32", "s32", "u64", "s64",
67 "f16", "f32", "f32.ftz", "f64", "bf16", "tf32",
68 "tf32.ftz", "b4x16", "b4x16_p64", "b6x16_p32"};
69 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
70 uint64_t Val = CI->getZExtValue();
71 if (Val <= static_cast<uint64_t>(nvvm::TensormapElemType::B6x16_p32)) {
72 OS << TensormapElemTypes[Val];
73 return;
74 }
75 }
76}
77
79 const Constant *ImmArgVal) {
80 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
81 uint64_t Val = CI->getZExtValue();
82 switch (static_cast<TensormapInterleaveLayout>(Val)) {
84 OS << "No interleave";
85 return;
87 OS << "16B interleave";
88 return;
90 OS << "32B interleave";
91 return;
92 }
93 }
94}
95
97 const Constant *ImmArgVal) {
98 static constexpr StringRef TensormapSwizzleModes[] = {
99 "No swizzling", "32B swizzling", "64B swizzling", "128B swizzling",
100 "96B swizzling"};
101 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
102 uint64_t Val = CI->getZExtValue();
103 if (Val <= static_cast<uint64_t>(nvvm::TensormapSwizzleMode::SWIZZLE_96B)) {
104 OS << TensormapSwizzleModes[Val];
105 return;
106 }
107 }
108}
109
111 const Constant *ImmArgVal) {
112 static constexpr StringRef TensormapSwizzleAtomicities[] = {
113 "16B", "32B", "32B + 8B flip", "64B"};
114 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
115 uint64_t Val = CI->getZExtValue();
116 if (Val <= static_cast<uint64_t>(
118 OS << TensormapSwizzleAtomicities[Val];
119 return;
120 }
121 }
122}
123
125 if (const auto *CI = dyn_cast<ConstantInt>(ImmArgVal)) {
126 uint64_t Val = CI->getZExtValue();
127 OS << (Val == static_cast<uint64_t>(TensormapFillMode::ZERO_FILL)
128 ? "Zero fill"
129 : "OOB-NaN fill");
130 return;
131 }
132}
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
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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.
void printTensormapSwizzleMode(raw_ostream &OS, const Constant *ImmArgVal)
void printTensormapInterleaveLayout(raw_ostream &OS, const Constant *ImmArgVal)
void printTensormapSwizzleAtomicity(raw_ostream &OS, const Constant *ImmArgVal)
void printTcgen05MMAKind(raw_ostream &OS, const Constant *ImmArgVal)
void printTcgen05CollectorUsageOp(raw_ostream &OS, const Constant *ImmArgVal)
void printTensormapFillMode(raw_ostream &OS, const Constant *ImmArgVal)
void printTensormapElemType(raw_ostream &OS, const Constant *ImmArgVal)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643