1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* AttrDef Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_ATTRDEF_LIST
10#undef GET_ATTRDEF_LIST
11
12::mlir::amdgpu::AddressSpaceAttr,
13::mlir::amdgpu::DPPPermAttr,
14::mlir::amdgpu::LoadTemporalHintAttr,
15::mlir::amdgpu::ScopeAttr
16
17#endif // GET_ATTRDEF_LIST
18
19#ifdef GET_ATTRDEF_CLASSES
20#undef GET_ATTRDEF_CLASSES
21
22#include "llvm/ADT/TypeSwitch.h"
23#include "mlir/IR/Builders.h"
24#include "mlir/IR/DialectImplementation.h"
25#include "mlir/IR/OpImplementation.h"
26
27static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
28 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser, mnemonic)
29 .Case(str: ::mlir::amdgpu::AddressSpaceAttr::getMnemonic(), fn: [&](llvm::StringRef, llvm::SMLoc) {
30 value = ::mlir::amdgpu::AddressSpaceAttr::parse(odsParser&: parser, odsType: type);
31 return ::mlir::success(IsSuccess: !!value);
32 })
33 .Case(str: ::mlir::amdgpu::DPPPermAttr::getMnemonic(), fn: [&](llvm::StringRef, llvm::SMLoc) {
34 value = ::mlir::amdgpu::DPPPermAttr::parse(odsParser&: parser, odsType: type);
35 return ::mlir::success(IsSuccess: !!value);
36 })
37 .Case(str: ::mlir::amdgpu::LoadTemporalHintAttr::getMnemonic(), fn: [&](llvm::StringRef, llvm::SMLoc) {
38 value = ::mlir::amdgpu::LoadTemporalHintAttr::parse(odsParser&: parser, odsType: type);
39 return ::mlir::success(IsSuccess: !!value);
40 })
41 .Case(str: ::mlir::amdgpu::ScopeAttr::getMnemonic(), fn: [&](llvm::StringRef, llvm::SMLoc) {
42 value = ::mlir::amdgpu::ScopeAttr::parse(odsParser&: parser, odsType: type);
43 return ::mlir::success(IsSuccess: !!value);
44 })
45 .Default(fn: [&](llvm::StringRef keyword, llvm::SMLoc) {
46 *mnemonic = keyword;
47 return std::nullopt;
48 });
49}
50
51static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
52 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::amdgpu::AddressSpaceAttr>(caseFn: [&](auto t) {
53 printer << ::mlir::amdgpu::AddressSpaceAttr::getMnemonic();
54t.print(printer);
55 return ::mlir::success();
56 })
57 .Case<::mlir::amdgpu::DPPPermAttr>(caseFn: [&](auto t) {
58 printer << ::mlir::amdgpu::DPPPermAttr::getMnemonic();
59t.print(printer);
60 return ::mlir::success();
61 })
62 .Case<::mlir::amdgpu::LoadTemporalHintAttr>(caseFn: [&](auto t) {
63 printer << ::mlir::amdgpu::LoadTemporalHintAttr::getMnemonic();
64t.print(printer);
65 return ::mlir::success();
66 })
67 .Case<::mlir::amdgpu::ScopeAttr>(caseFn: [&](auto t) {
68 printer << ::mlir::amdgpu::ScopeAttr::getMnemonic();
69t.print(printer);
70 return ::mlir::success();
71 })
72 .Default(defaultFn: [](auto) { return ::mlir::failure(); });
73}
74
75namespace mlir::amdgpu {
76
77namespace detail {
78
79struct AddressSpaceAttrStorage : public ::mlir::AttributeStorage {
80 using KeyTy = std::tuple<::mlir::amdgpu::AddressSpace>;
81 AddressSpaceAttrStorage(::mlir::amdgpu::AddressSpace value) : value(std::move(value)) {}
82
83 KeyTy getAsKey() const {
84 return KeyTy(value);
85 }
86
87 bool operator==(const KeyTy &tblgenKey) const {
88 return (value == std::get<0>(t: tblgenKey));
89 }
90
91 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
92 return ::llvm::hash_combine(args: std::get<0>(t: tblgenKey));
93 }
94
95 static AddressSpaceAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
96 auto value = std::move(std::get<0>(t&: tblgenKey));
97 return new (allocator.allocate<AddressSpaceAttrStorage>()) AddressSpaceAttrStorage(std::move(value));
98 }
99
100 ::mlir::amdgpu::AddressSpace value;
101};
102
103} // namespace detail
104AddressSpaceAttr AddressSpaceAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::AddressSpace value) {
105 return Base::get(ctx: context, args: std::move(value));
106}
107
108::mlir::Attribute AddressSpaceAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
109 ::mlir::Builder odsBuilder(odsParser.getContext());
110 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
111 (void) odsLoc;
112 ::mlir::FailureOr<::mlir::amdgpu::AddressSpace> _result_value;
113 // Parse literal '<'
114 if (odsParser.parseLess()) return {};
115
116 // Parse variable 'value'
117 _result_value = ::mlir::FieldParser<::mlir::amdgpu::AddressSpace>::parse(parser&: odsParser);
118 if (::mlir::failed(Result: _result_value)) {
119 odsParser.emitError(loc: odsParser.getCurrentLocation(), message: "failed to parse AMDGPU_AddressSpaceAttr parameter 'value' which is to be a `::mlir::amdgpu::AddressSpace`");
120 return {};
121 }
122 // Parse literal '>'
123 if (odsParser.parseGreater()) return {};
124 assert(::mlir::succeeded(_result_value));
125 return AddressSpaceAttr::get(context: odsParser.getContext(),
126 value: ::mlir::amdgpu::AddressSpace((*_result_value)));
127}
128
129void AddressSpaceAttr::print(::mlir::AsmPrinter &odsPrinter) const {
130 ::mlir::Builder odsBuilder(getContext());
131 odsPrinter << "<";
132 odsPrinter.printStrippedAttrOrType(attrOrType: getValue());
133 odsPrinter << ">";
134}
135
136::mlir::amdgpu::AddressSpace AddressSpaceAttr::getValue() const {
137 return getImpl()->value;
138}
139
140
141} // namespace mlir::amdgpu
142MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::AddressSpaceAttr)
143namespace mlir::amdgpu {
144
145namespace detail {
146
147struct DPPPermAttrStorage : public ::mlir::AttributeStorage {
148 using KeyTy = std::tuple<::mlir::amdgpu::DPPPerm>;
149 DPPPermAttrStorage(::mlir::amdgpu::DPPPerm value) : value(std::move(value)) {}
150
151 KeyTy getAsKey() const {
152 return KeyTy(value);
153 }
154
155 bool operator==(const KeyTy &tblgenKey) const {
156 return (value == std::get<0>(t: tblgenKey));
157 }
158
159 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
160 return ::llvm::hash_combine(args: std::get<0>(t: tblgenKey));
161 }
162
163 static DPPPermAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
164 auto value = std::move(std::get<0>(t&: tblgenKey));
165 return new (allocator.allocate<DPPPermAttrStorage>()) DPPPermAttrStorage(std::move(value));
166 }
167
168 ::mlir::amdgpu::DPPPerm value;
169};
170
171} // namespace detail
172DPPPermAttr DPPPermAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::DPPPerm value) {
173 return Base::get(ctx: context, args: std::move(value));
174}
175
176::mlir::Attribute DPPPermAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
177 ::mlir::Builder odsBuilder(odsParser.getContext());
178 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
179 (void) odsLoc;
180 ::mlir::FailureOr<::mlir::amdgpu::DPPPerm> _result_value;
181 // Parse literal '<'
182 if (odsParser.parseLess()) return {};
183
184 // Parse variable 'value'
185 _result_value = ::mlir::FieldParser<::mlir::amdgpu::DPPPerm>::parse(parser&: odsParser);
186 if (::mlir::failed(Result: _result_value)) {
187 odsParser.emitError(loc: odsParser.getCurrentLocation(), message: "failed to parse AMDGPU_DPPPermAttr parameter 'value' which is to be a `::mlir::amdgpu::DPPPerm`");
188 return {};
189 }
190 // Parse literal '>'
191 if (odsParser.parseGreater()) return {};
192 assert(::mlir::succeeded(_result_value));
193 return DPPPermAttr::get(context: odsParser.getContext(),
194 value: ::mlir::amdgpu::DPPPerm((*_result_value)));
195}
196
197void DPPPermAttr::print(::mlir::AsmPrinter &odsPrinter) const {
198 ::mlir::Builder odsBuilder(getContext());
199 odsPrinter << "<";
200 odsPrinter.printStrippedAttrOrType(attrOrType: getValue());
201 odsPrinter << ">";
202}
203
204::mlir::amdgpu::DPPPerm DPPPermAttr::getValue() const {
205 return getImpl()->value;
206}
207
208
209} // namespace mlir::amdgpu
210MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::DPPPermAttr)
211namespace mlir::amdgpu {
212
213namespace detail {
214
215struct LoadTemporalHintAttrStorage : public ::mlir::AttributeStorage {
216 using KeyTy = std::tuple<::mlir::amdgpu::LoadTemporalHint>;
217 LoadTemporalHintAttrStorage(::mlir::amdgpu::LoadTemporalHint value) : value(std::move(value)) {}
218
219 KeyTy getAsKey() const {
220 return KeyTy(value);
221 }
222
223 bool operator==(const KeyTy &tblgenKey) const {
224 return (value == std::get<0>(t: tblgenKey));
225 }
226
227 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
228 return ::llvm::hash_combine(args: std::get<0>(t: tblgenKey));
229 }
230
231 static LoadTemporalHintAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
232 auto value = std::move(std::get<0>(t&: tblgenKey));
233 return new (allocator.allocate<LoadTemporalHintAttrStorage>()) LoadTemporalHintAttrStorage(std::move(value));
234 }
235
236 ::mlir::amdgpu::LoadTemporalHint value;
237};
238
239} // namespace detail
240LoadTemporalHintAttr LoadTemporalHintAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::LoadTemporalHint value) {
241 return Base::get(ctx: context, args: std::move(value));
242}
243
244::mlir::Attribute LoadTemporalHintAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
245 ::mlir::Builder odsBuilder(odsParser.getContext());
246 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
247 (void) odsLoc;
248 ::mlir::FailureOr<::mlir::amdgpu::LoadTemporalHint> _result_value;
249 // Parse literal '<'
250 if (odsParser.parseLess()) return {};
251
252 // Parse variable 'value'
253 _result_value = ::mlir::FieldParser<::mlir::amdgpu::LoadTemporalHint>::parse(parser&: odsParser);
254 if (::mlir::failed(Result: _result_value)) {
255 odsParser.emitError(loc: odsParser.getCurrentLocation(), message: "failed to parse AMDGPU_LoadTemporalHintAttr parameter 'value' which is to be a `::mlir::amdgpu::LoadTemporalHint`");
256 return {};
257 }
258 // Parse literal '>'
259 if (odsParser.parseGreater()) return {};
260 assert(::mlir::succeeded(_result_value));
261 return LoadTemporalHintAttr::get(context: odsParser.getContext(),
262 value: ::mlir::amdgpu::LoadTemporalHint((*_result_value)));
263}
264
265void LoadTemporalHintAttr::print(::mlir::AsmPrinter &odsPrinter) const {
266 ::mlir::Builder odsBuilder(getContext());
267 odsPrinter << "<";
268 odsPrinter.printStrippedAttrOrType(attrOrType: getValue());
269 odsPrinter << ">";
270}
271
272::mlir::amdgpu::LoadTemporalHint LoadTemporalHintAttr::getValue() const {
273 return getImpl()->value;
274}
275
276
277} // namespace mlir::amdgpu
278MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::LoadTemporalHintAttr)
279namespace mlir::amdgpu {
280
281namespace detail {
282
283struct ScopeAttrStorage : public ::mlir::AttributeStorage {
284 using KeyTy = std::tuple<::mlir::amdgpu::Scope>;
285 ScopeAttrStorage(::mlir::amdgpu::Scope value) : value(std::move(value)) {}
286
287 KeyTy getAsKey() const {
288 return KeyTy(value);
289 }
290
291 bool operator==(const KeyTy &tblgenKey) const {
292 return (value == std::get<0>(t: tblgenKey));
293 }
294
295 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
296 return ::llvm::hash_combine(args: std::get<0>(t: tblgenKey));
297 }
298
299 static ScopeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
300 auto value = std::move(std::get<0>(t&: tblgenKey));
301 return new (allocator.allocate<ScopeAttrStorage>()) ScopeAttrStorage(std::move(value));
302 }
303
304 ::mlir::amdgpu::Scope value;
305};
306
307} // namespace detail
308ScopeAttr ScopeAttr::get(::mlir::MLIRContext *context, ::mlir::amdgpu::Scope value) {
309 return Base::get(ctx: context, args: std::move(value));
310}
311
312::mlir::Attribute ScopeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
313 ::mlir::Builder odsBuilder(odsParser.getContext());
314 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
315 (void) odsLoc;
316 ::mlir::FailureOr<::mlir::amdgpu::Scope> _result_value;
317 // Parse literal '<'
318 if (odsParser.parseLess()) return {};
319
320 // Parse variable 'value'
321 _result_value = ::mlir::FieldParser<::mlir::amdgpu::Scope>::parse(parser&: odsParser);
322 if (::mlir::failed(Result: _result_value)) {
323 odsParser.emitError(loc: odsParser.getCurrentLocation(), message: "failed to parse AMDGPU_CacheScopeAttr parameter 'value' which is to be a `::mlir::amdgpu::Scope`");
324 return {};
325 }
326 // Parse literal '>'
327 if (odsParser.parseGreater()) return {};
328 assert(::mlir::succeeded(_result_value));
329 return ScopeAttr::get(context: odsParser.getContext(),
330 value: ::mlir::amdgpu::Scope((*_result_value)));
331}
332
333void ScopeAttr::print(::mlir::AsmPrinter &odsPrinter) const {
334 ::mlir::Builder odsBuilder(getContext());
335 odsPrinter << "<";
336 odsPrinter.printStrippedAttrOrType(attrOrType: getValue());
337 odsPrinter << ">";
338}
339
340::mlir::amdgpu::Scope ScopeAttr::getValue() const {
341 return getImpl()->value;
342}
343
344
345} // namespace mlir::amdgpu
346MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::amdgpu::ScopeAttr)
347namespace mlir::amdgpu {
348
349
350/// Parse an attribute registered to this dialect.
351::mlir::Attribute AMDGPUDialect::parseAttribute(::mlir::DialectAsmParser &parser,
352 ::mlir::Type type) const {
353 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
354 ::llvm::StringRef attrTag;
355 {
356 ::mlir::Attribute attr;
357 auto parseResult = generatedAttributeParser(parser, mnemonic: &attrTag, type, value&: attr);
358 if (parseResult.has_value())
359 return attr;
360 }
361
362 parser.emitError(loc: typeLoc) << "unknown attribute `"
363 << attrTag << "` in dialect `" << getNamespace() << "`";
364 return {};
365}
366/// Print an attribute registered to this dialect.
367void AMDGPUDialect::printAttribute(::mlir::Attribute attr,
368 ::mlir::DialectAsmPrinter &printer) const {
369 if (::mlir::succeeded(Result: generatedAttributePrinter(def: attr, printer)))
370 return;
371
372}
373
374} // namespace mlir::amdgpu
375
376#endif // GET_ATTRDEF_CLASSES
377
378