File: | build/source/build-llvm/tools/clang/stage2-bins/tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc |
Warning: | line 2782, column 5 Value stored to '_firstPrinted' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
2 | |* *| |
3 | |* TypeDef Definitions *| |
4 | |* *| |
5 | |* Automatically generated file, do not edit! *| |
6 | |* *| |
7 | \*===----------------------------------------------------------------------===*/ |
8 | |
9 | #ifdef GET_TYPEDEF_LIST |
10 | #undef GET_TYPEDEF_LIST |
11 | |
12 | ::test::CompoundNestedInnerType, |
13 | ::test::CompoundNestedOuterType, |
14 | ::test::CompoundNestedOuterQualType, |
15 | ::test::CompoundAType, |
16 | ::test::TestIntegerType, |
17 | ::test::SimpleAType, |
18 | ::test::StructType, |
19 | ::test::TestMemRefElementTypeType, |
20 | ::test::TestType, |
21 | ::test::TestTypeAPFloatType, |
22 | ::test::TestTypeAllOptionalParamsType, |
23 | ::test::TestTypeAllOptionalStructType, |
24 | ::test::TestTypeCustomType, |
25 | ::test::TestTypeCustomSpacingType, |
26 | ::test::TestTypeCustomStringType, |
27 | ::test::TestTypeDefaultValuedTypeType, |
28 | ::test::TestTypeElseAnchorType, |
29 | ::test::TestTypeElseAnchorStructType, |
30 | ::test::TestTypeNoParserType, |
31 | ::test::TestTypeOptionalGroupType, |
32 | ::test::TestTypeOptionalGroupParamsType, |
33 | ::test::TestTypeOptionalGroupStructType, |
34 | ::test::TestTypeOptionalParamType, |
35 | ::test::TestTypeOptionalParamsType, |
36 | ::test::TestTypeOptionalParamsAfterRequiredType, |
37 | ::test::TestTypeOptionalStructType, |
38 | ::test::TestTypeOptionalValueTypeType, |
39 | ::test::TestTypeSpaceSType, |
40 | ::test::TestStructTypeCaptureAllType, |
41 | ::test::TestTypeWithFormatType, |
42 | ::test::TestTypeWithLayoutType, |
43 | ::test::TestTypeWithTraitType |
44 | |
45 | #endif // GET_TYPEDEF_LIST |
46 | |
47 | #ifdef GET_TYPEDEF_CLASSES |
48 | #undef GET_TYPEDEF_CLASSES |
49 | |
50 | static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { |
51 | return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) |
52 | .Case(::test::CompoundNestedInnerType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
53 | value = ::test::CompoundNestedInnerType::parse(parser); |
54 | return ::mlir::success(!!value); |
55 | }) |
56 | .Case(::test::CompoundNestedOuterType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
57 | value = ::test::CompoundNestedOuterType::parse(parser); |
58 | return ::mlir::success(!!value); |
59 | }) |
60 | .Case(::test::CompoundNestedOuterQualType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
61 | value = ::test::CompoundNestedOuterQualType::parse(parser); |
62 | return ::mlir::success(!!value); |
63 | }) |
64 | .Case(::test::CompoundAType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
65 | value = ::test::CompoundAType::parse(parser); |
66 | return ::mlir::success(!!value); |
67 | }) |
68 | .Case(::test::TestIntegerType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
69 | value = ::test::TestIntegerType::parse(parser); |
70 | return ::mlir::success(!!value); |
71 | }) |
72 | .Case(::test::SimpleAType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
73 | value = ::test::SimpleAType::get(parser.getContext()); |
74 | return ::mlir::success(!!value); |
75 | }) |
76 | .Case(::test::StructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
77 | value = ::test::StructType::parse(parser); |
78 | return ::mlir::success(!!value); |
79 | }) |
80 | .Case(::test::TestMemRefElementTypeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
81 | value = ::test::TestMemRefElementTypeType::get(parser.getContext()); |
82 | return ::mlir::success(!!value); |
83 | }) |
84 | .Case(::test::TestType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
85 | value = ::test::TestType::get(parser.getContext()); |
86 | return ::mlir::success(!!value); |
87 | }) |
88 | .Case(::test::TestTypeAPFloatType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
89 | value = ::test::TestTypeAPFloatType::parse(parser); |
90 | return ::mlir::success(!!value); |
91 | }) |
92 | .Case(::test::TestTypeAllOptionalParamsType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
93 | value = ::test::TestTypeAllOptionalParamsType::parse(parser); |
94 | return ::mlir::success(!!value); |
95 | }) |
96 | .Case(::test::TestTypeAllOptionalStructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
97 | value = ::test::TestTypeAllOptionalStructType::parse(parser); |
98 | return ::mlir::success(!!value); |
99 | }) |
100 | .Case(::test::TestTypeCustomType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
101 | value = ::test::TestTypeCustomType::parse(parser); |
102 | return ::mlir::success(!!value); |
103 | }) |
104 | .Case(::test::TestTypeCustomSpacingType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
105 | value = ::test::TestTypeCustomSpacingType::parse(parser); |
106 | return ::mlir::success(!!value); |
107 | }) |
108 | .Case(::test::TestTypeCustomStringType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
109 | value = ::test::TestTypeCustomStringType::parse(parser); |
110 | return ::mlir::success(!!value); |
111 | }) |
112 | .Case(::test::TestTypeDefaultValuedTypeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
113 | value = ::test::TestTypeDefaultValuedTypeType::parse(parser); |
114 | return ::mlir::success(!!value); |
115 | }) |
116 | .Case(::test::TestTypeElseAnchorType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
117 | value = ::test::TestTypeElseAnchorType::parse(parser); |
118 | return ::mlir::success(!!value); |
119 | }) |
120 | .Case(::test::TestTypeElseAnchorStructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
121 | value = ::test::TestTypeElseAnchorStructType::parse(parser); |
122 | return ::mlir::success(!!value); |
123 | }) |
124 | .Case(::test::TestTypeNoParserType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
125 | value = ::test::TestTypeNoParserType::parse(parser); |
126 | return ::mlir::success(!!value); |
127 | }) |
128 | .Case(::test::TestTypeOptionalGroupType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
129 | value = ::test::TestTypeOptionalGroupType::parse(parser); |
130 | return ::mlir::success(!!value); |
131 | }) |
132 | .Case(::test::TestTypeOptionalGroupParamsType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
133 | value = ::test::TestTypeOptionalGroupParamsType::parse(parser); |
134 | return ::mlir::success(!!value); |
135 | }) |
136 | .Case(::test::TestTypeOptionalGroupStructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
137 | value = ::test::TestTypeOptionalGroupStructType::parse(parser); |
138 | return ::mlir::success(!!value); |
139 | }) |
140 | .Case(::test::TestTypeOptionalParamType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
141 | value = ::test::TestTypeOptionalParamType::parse(parser); |
142 | return ::mlir::success(!!value); |
143 | }) |
144 | .Case(::test::TestTypeOptionalParamsType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
145 | value = ::test::TestTypeOptionalParamsType::parse(parser); |
146 | return ::mlir::success(!!value); |
147 | }) |
148 | .Case(::test::TestTypeOptionalParamsAfterRequiredType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
149 | value = ::test::TestTypeOptionalParamsAfterRequiredType::parse(parser); |
150 | return ::mlir::success(!!value); |
151 | }) |
152 | .Case(::test::TestTypeOptionalStructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
153 | value = ::test::TestTypeOptionalStructType::parse(parser); |
154 | return ::mlir::success(!!value); |
155 | }) |
156 | .Case(::test::TestTypeOptionalValueTypeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
157 | value = ::test::TestTypeOptionalValueTypeType::parse(parser); |
158 | return ::mlir::success(!!value); |
159 | }) |
160 | .Case(::test::TestTypeSpaceSType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
161 | value = ::test::TestTypeSpaceSType::parse(parser); |
162 | return ::mlir::success(!!value); |
163 | }) |
164 | .Case(::test::TestStructTypeCaptureAllType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
165 | value = ::test::TestStructTypeCaptureAllType::parse(parser); |
166 | return ::mlir::success(!!value); |
167 | }) |
168 | .Case(::test::TestTypeWithFormatType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
169 | value = ::test::TestTypeWithFormatType::parse(parser); |
170 | return ::mlir::success(!!value); |
171 | }) |
172 | .Case(::test::TestTypeWithLayoutType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
173 | value = ::test::TestTypeWithLayoutType::parse(parser); |
174 | return ::mlir::success(!!value); |
175 | }) |
176 | .Case(::test::TestTypeWithTraitType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { |
177 | value = ::test::TestTypeWithTraitType::get(parser.getContext()); |
178 | return ::mlir::success(!!value); |
179 | }) |
180 | .Default([&](llvm::StringRef keyword, llvm::SMLoc) { |
181 | *mnemonic = keyword; |
182 | return std::nullopt; |
183 | }); |
184 | } |
185 | |
186 | static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { |
187 | return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::test::CompoundNestedInnerType>([&](auto t) { |
188 | printer << ::test::CompoundNestedInnerType::getMnemonic(); |
189 | t.print(printer); |
190 | return ::mlir::success(); |
191 | }) |
192 | .Case<::test::CompoundNestedOuterType>([&](auto t) { |
193 | printer << ::test::CompoundNestedOuterType::getMnemonic(); |
194 | t.print(printer); |
195 | return ::mlir::success(); |
196 | }) |
197 | .Case<::test::CompoundNestedOuterQualType>([&](auto t) { |
198 | printer << ::test::CompoundNestedOuterQualType::getMnemonic(); |
199 | t.print(printer); |
200 | return ::mlir::success(); |
201 | }) |
202 | .Case<::test::CompoundAType>([&](auto t) { |
203 | printer << ::test::CompoundAType::getMnemonic(); |
204 | t.print(printer); |
205 | return ::mlir::success(); |
206 | }) |
207 | .Case<::test::TestIntegerType>([&](auto t) { |
208 | printer << ::test::TestIntegerType::getMnemonic(); |
209 | t.print(printer); |
210 | return ::mlir::success(); |
211 | }) |
212 | .Case<::test::SimpleAType>([&](auto t) { |
213 | printer << ::test::SimpleAType::getMnemonic(); |
214 | return ::mlir::success(); |
215 | }) |
216 | .Case<::test::StructType>([&](auto t) { |
217 | printer << ::test::StructType::getMnemonic(); |
218 | t.print(printer); |
219 | return ::mlir::success(); |
220 | }) |
221 | .Case<::test::TestMemRefElementTypeType>([&](auto t) { |
222 | printer << ::test::TestMemRefElementTypeType::getMnemonic(); |
223 | return ::mlir::success(); |
224 | }) |
225 | .Case<::test::TestType>([&](auto t) { |
226 | printer << ::test::TestType::getMnemonic(); |
227 | return ::mlir::success(); |
228 | }) |
229 | .Case<::test::TestTypeAPFloatType>([&](auto t) { |
230 | printer << ::test::TestTypeAPFloatType::getMnemonic(); |
231 | t.print(printer); |
232 | return ::mlir::success(); |
233 | }) |
234 | .Case<::test::TestTypeAllOptionalParamsType>([&](auto t) { |
235 | printer << ::test::TestTypeAllOptionalParamsType::getMnemonic(); |
236 | t.print(printer); |
237 | return ::mlir::success(); |
238 | }) |
239 | .Case<::test::TestTypeAllOptionalStructType>([&](auto t) { |
240 | printer << ::test::TestTypeAllOptionalStructType::getMnemonic(); |
241 | t.print(printer); |
242 | return ::mlir::success(); |
243 | }) |
244 | .Case<::test::TestTypeCustomType>([&](auto t) { |
245 | printer << ::test::TestTypeCustomType::getMnemonic(); |
246 | t.print(printer); |
247 | return ::mlir::success(); |
248 | }) |
249 | .Case<::test::TestTypeCustomSpacingType>([&](auto t) { |
250 | printer << ::test::TestTypeCustomSpacingType::getMnemonic(); |
251 | t.print(printer); |
252 | return ::mlir::success(); |
253 | }) |
254 | .Case<::test::TestTypeCustomStringType>([&](auto t) { |
255 | printer << ::test::TestTypeCustomStringType::getMnemonic(); |
256 | t.print(printer); |
257 | return ::mlir::success(); |
258 | }) |
259 | .Case<::test::TestTypeDefaultValuedTypeType>([&](auto t) { |
260 | printer << ::test::TestTypeDefaultValuedTypeType::getMnemonic(); |
261 | t.print(printer); |
262 | return ::mlir::success(); |
263 | }) |
264 | .Case<::test::TestTypeElseAnchorType>([&](auto t) { |
265 | printer << ::test::TestTypeElseAnchorType::getMnemonic(); |
266 | t.print(printer); |
267 | return ::mlir::success(); |
268 | }) |
269 | .Case<::test::TestTypeElseAnchorStructType>([&](auto t) { |
270 | printer << ::test::TestTypeElseAnchorStructType::getMnemonic(); |
271 | t.print(printer); |
272 | return ::mlir::success(); |
273 | }) |
274 | .Case<::test::TestTypeNoParserType>([&](auto t) { |
275 | printer << ::test::TestTypeNoParserType::getMnemonic(); |
276 | t.print(printer); |
277 | return ::mlir::success(); |
278 | }) |
279 | .Case<::test::TestTypeOptionalGroupType>([&](auto t) { |
280 | printer << ::test::TestTypeOptionalGroupType::getMnemonic(); |
281 | t.print(printer); |
282 | return ::mlir::success(); |
283 | }) |
284 | .Case<::test::TestTypeOptionalGroupParamsType>([&](auto t) { |
285 | printer << ::test::TestTypeOptionalGroupParamsType::getMnemonic(); |
286 | t.print(printer); |
287 | return ::mlir::success(); |
288 | }) |
289 | .Case<::test::TestTypeOptionalGroupStructType>([&](auto t) { |
290 | printer << ::test::TestTypeOptionalGroupStructType::getMnemonic(); |
291 | t.print(printer); |
292 | return ::mlir::success(); |
293 | }) |
294 | .Case<::test::TestTypeOptionalParamType>([&](auto t) { |
295 | printer << ::test::TestTypeOptionalParamType::getMnemonic(); |
296 | t.print(printer); |
297 | return ::mlir::success(); |
298 | }) |
299 | .Case<::test::TestTypeOptionalParamsType>([&](auto t) { |
300 | printer << ::test::TestTypeOptionalParamsType::getMnemonic(); |
301 | t.print(printer); |
302 | return ::mlir::success(); |
303 | }) |
304 | .Case<::test::TestTypeOptionalParamsAfterRequiredType>([&](auto t) { |
305 | printer << ::test::TestTypeOptionalParamsAfterRequiredType::getMnemonic(); |
306 | t.print(printer); |
307 | return ::mlir::success(); |
308 | }) |
309 | .Case<::test::TestTypeOptionalStructType>([&](auto t) { |
310 | printer << ::test::TestTypeOptionalStructType::getMnemonic(); |
311 | t.print(printer); |
312 | return ::mlir::success(); |
313 | }) |
314 | .Case<::test::TestTypeOptionalValueTypeType>([&](auto t) { |
315 | printer << ::test::TestTypeOptionalValueTypeType::getMnemonic(); |
316 | t.print(printer); |
317 | return ::mlir::success(); |
318 | }) |
319 | .Case<::test::TestTypeSpaceSType>([&](auto t) { |
320 | printer << ::test::TestTypeSpaceSType::getMnemonic(); |
321 | t.print(printer); |
322 | return ::mlir::success(); |
323 | }) |
324 | .Case<::test::TestStructTypeCaptureAllType>([&](auto t) { |
325 | printer << ::test::TestStructTypeCaptureAllType::getMnemonic(); |
326 | t.print(printer); |
327 | return ::mlir::success(); |
328 | }) |
329 | .Case<::test::TestTypeWithFormatType>([&](auto t) { |
330 | printer << ::test::TestTypeWithFormatType::getMnemonic(); |
331 | t.print(printer); |
332 | return ::mlir::success(); |
333 | }) |
334 | .Case<::test::TestTypeWithLayoutType>([&](auto t) { |
335 | printer << ::test::TestTypeWithLayoutType::getMnemonic(); |
336 | t.print(printer); |
337 | return ::mlir::success(); |
338 | }) |
339 | .Case<::test::TestTypeWithTraitType>([&](auto t) { |
340 | printer << ::test::TestTypeWithTraitType::getMnemonic(); |
341 | return ::mlir::success(); |
342 | }) |
343 | .Default([](auto) { return ::mlir::failure(); }); |
344 | } |
345 | |
346 | namespace test { |
347 | namespace detail { |
348 | struct CompoundNestedInnerTypeStorage : public ::mlir::TypeStorage { |
349 | using KeyTy = std::tuple<int, ::test::CompoundAType>; |
350 | CompoundNestedInnerTypeStorage(int some_int, ::test::CompoundAType cmpdA) : some_int(some_int), cmpdA(cmpdA) {} |
351 | |
352 | KeyTy getAsKey() const { |
353 | return KeyTy(some_int, cmpdA); |
354 | } |
355 | |
356 | bool operator==(const KeyTy &tblgenKey) const { |
357 | return (some_int == std::get<0>(tblgenKey)) && (cmpdA == std::get<1>(tblgenKey)); |
358 | } |
359 | |
360 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
361 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
362 | } |
363 | |
364 | static CompoundNestedInnerTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
365 | auto some_int = std::get<0>(tblgenKey); |
366 | auto cmpdA = std::get<1>(tblgenKey); |
367 | return new (allocator.allocate<CompoundNestedInnerTypeStorage>()) CompoundNestedInnerTypeStorage(some_int, cmpdA); |
368 | } |
369 | |
370 | int some_int; |
371 | ::test::CompoundAType cmpdA; |
372 | }; |
373 | } // namespace detail |
374 | CompoundNestedInnerType CompoundNestedInnerType::get(::mlir::MLIRContext *context, int some_int, ::test::CompoundAType cmpdA) { |
375 | return Base::get(context, some_int, cmpdA); |
376 | } |
377 | |
378 | ::mlir::Type CompoundNestedInnerType::parse(::mlir::AsmParser &odsParser) { |
379 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
380 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
381 | (void) odsLoc; |
382 | ::mlir::FailureOr<int> _result_some_int; |
383 | ::mlir::FailureOr<::test::CompoundAType> _result_cmpdA; |
384 | // Parse literal '<' |
385 | if (odsParser.parseLess()) return {}; |
386 | |
387 | // Parse variable 'some_int' |
388 | _result_some_int = ::mlir::FieldParser<int>::parse(odsParser); |
389 | if (::mlir::failed(_result_some_int)) { |
390 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CompoundNestedInnerType parameter 'some_int' which is to be a `int`"); |
391 | return {}; |
392 | } |
393 | |
394 | // Parse variable 'cmpdA' |
395 | _result_cmpdA = ::mlir::FieldParser<::test::CompoundAType>::parse(odsParser); |
396 | if (::mlir::failed(_result_cmpdA)) { |
397 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CompoundNestedInnerType parameter 'cmpdA' which is to be a `::test::CompoundAType`"); |
398 | return {}; |
399 | } |
400 | // Parse literal '>' |
401 | if (odsParser.parseGreater()) return {}; |
402 | assert(::mlir::succeeded(_result_some_int))(static_cast <bool> (::mlir::succeeded(_result_some_int )) ? void (0) : __assert_fail ("::mlir::succeeded(_result_some_int)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 402 , __extension__ __PRETTY_FUNCTION__)); |
403 | assert(::mlir::succeeded(_result_cmpdA))(static_cast <bool> (::mlir::succeeded(_result_cmpdA)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_cmpdA)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 403 , __extension__ __PRETTY_FUNCTION__)); |
404 | return CompoundNestedInnerType::get(odsParser.getContext(), |
405 | int((*_result_some_int)), |
406 | ::test::CompoundAType((*_result_cmpdA))); |
407 | } |
408 | |
409 | void CompoundNestedInnerType::print(::mlir::AsmPrinter &odsPrinter) const { |
410 | ::mlir::Builder odsBuilder(getContext()); |
411 | odsPrinter << "<"; |
412 | odsPrinter.printStrippedAttrOrType(getSomeInt()); |
413 | odsPrinter << ' '; |
414 | odsPrinter.printStrippedAttrOrType(getCmpdA()); |
415 | odsPrinter << ">"; |
416 | } |
417 | |
418 | int CompoundNestedInnerType::getSomeInt() const { |
419 | return getImpl()->some_int; |
420 | } |
421 | |
422 | ::test::CompoundAType CompoundNestedInnerType::getCmpdA() const { |
423 | return getImpl()->cmpdA; |
424 | } |
425 | |
426 | } // namespace test |
427 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::CompoundNestedInnerType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::CompoundNestedInnerType>::id = {}; } } |
428 | namespace test { |
429 | namespace detail { |
430 | struct CompoundNestedOuterTypeStorage : public ::mlir::TypeStorage { |
431 | using KeyTy = std::tuple<::test::CompoundNestedInnerType>; |
432 | CompoundNestedOuterTypeStorage(::test::CompoundNestedInnerType inner) : inner(inner) {} |
433 | |
434 | KeyTy getAsKey() const { |
435 | return KeyTy(inner); |
436 | } |
437 | |
438 | bool operator==(const KeyTy &tblgenKey) const { |
439 | return (inner == std::get<0>(tblgenKey)); |
440 | } |
441 | |
442 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
443 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
444 | } |
445 | |
446 | static CompoundNestedOuterTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
447 | auto inner = std::get<0>(tblgenKey); |
448 | return new (allocator.allocate<CompoundNestedOuterTypeStorage>()) CompoundNestedOuterTypeStorage(inner); |
449 | } |
450 | |
451 | ::test::CompoundNestedInnerType inner; |
452 | }; |
453 | } // namespace detail |
454 | CompoundNestedOuterType CompoundNestedOuterType::get(::mlir::MLIRContext *context, ::test::CompoundNestedInnerType inner) { |
455 | return Base::get(context, inner); |
456 | } |
457 | |
458 | ::mlir::Type CompoundNestedOuterType::parse(::mlir::AsmParser &odsParser) { |
459 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
460 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
461 | (void) odsLoc; |
462 | ::mlir::FailureOr<::test::CompoundNestedInnerType> _result_inner; |
463 | // Parse literal '<' |
464 | if (odsParser.parseLess()) return {}; |
465 | // Parse literal 'i' |
466 | if (odsParser.parseKeyword("i")) return {}; |
467 | |
468 | // Parse variable 'inner' |
469 | _result_inner = ::mlir::FieldParser<::test::CompoundNestedInnerType>::parse(odsParser); |
470 | if (::mlir::failed(_result_inner)) { |
471 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CompoundNestedOuterType parameter 'inner' which is to be a `::test::CompoundNestedInnerType`"); |
472 | return {}; |
473 | } |
474 | // Parse literal '>' |
475 | if (odsParser.parseGreater()) return {}; |
476 | assert(::mlir::succeeded(_result_inner))(static_cast <bool> (::mlir::succeeded(_result_inner)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_inner)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 476 , __extension__ __PRETTY_FUNCTION__)); |
477 | return CompoundNestedOuterType::get(odsParser.getContext(), |
478 | ::test::CompoundNestedInnerType((*_result_inner))); |
479 | } |
480 | |
481 | void CompoundNestedOuterType::print(::mlir::AsmPrinter &odsPrinter) const { |
482 | ::mlir::Builder odsBuilder(getContext()); |
483 | odsPrinter << "<"; |
484 | odsPrinter << "i"; |
485 | odsPrinter << ' '; |
486 | odsPrinter.printStrippedAttrOrType(getInner()); |
487 | odsPrinter << ">"; |
488 | } |
489 | |
490 | ::test::CompoundNestedInnerType CompoundNestedOuterType::getInner() const { |
491 | return getImpl()->inner; |
492 | } |
493 | |
494 | } // namespace test |
495 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::CompoundNestedOuterType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::CompoundNestedOuterType>::id = {}; } } |
496 | namespace test { |
497 | namespace detail { |
498 | struct CompoundNestedOuterQualTypeStorage : public ::mlir::TypeStorage { |
499 | using KeyTy = std::tuple<::test::CompoundNestedInnerType>; |
500 | CompoundNestedOuterQualTypeStorage(::test::CompoundNestedInnerType inner) : inner(inner) {} |
501 | |
502 | KeyTy getAsKey() const { |
503 | return KeyTy(inner); |
504 | } |
505 | |
506 | bool operator==(const KeyTy &tblgenKey) const { |
507 | return (inner == std::get<0>(tblgenKey)); |
508 | } |
509 | |
510 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
511 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
512 | } |
513 | |
514 | static CompoundNestedOuterQualTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
515 | auto inner = std::get<0>(tblgenKey); |
516 | return new (allocator.allocate<CompoundNestedOuterQualTypeStorage>()) CompoundNestedOuterQualTypeStorage(inner); |
517 | } |
518 | |
519 | ::test::CompoundNestedInnerType inner; |
520 | }; |
521 | } // namespace detail |
522 | CompoundNestedOuterQualType CompoundNestedOuterQualType::get(::mlir::MLIRContext *context, ::test::CompoundNestedInnerType inner) { |
523 | return Base::get(context, inner); |
524 | } |
525 | |
526 | ::mlir::Type CompoundNestedOuterQualType::parse(::mlir::AsmParser &odsParser) { |
527 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
528 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
529 | (void) odsLoc; |
530 | ::mlir::FailureOr<::test::CompoundNestedInnerType> _result_inner; |
531 | // Parse literal '<' |
532 | if (odsParser.parseLess()) return {}; |
533 | // Parse literal 'i' |
534 | if (odsParser.parseKeyword("i")) return {}; |
535 | |
536 | // Parse variable 'inner' |
537 | _result_inner = ::mlir::FieldParser<::test::CompoundNestedInnerType>::parse(odsParser); |
538 | if (::mlir::failed(_result_inner)) { |
539 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CompoundNestedOuterTypeQual parameter 'inner' which is to be a `::test::CompoundNestedInnerType`"); |
540 | return {}; |
541 | } |
542 | // Parse literal '>' |
543 | if (odsParser.parseGreater()) return {}; |
544 | assert(::mlir::succeeded(_result_inner))(static_cast <bool> (::mlir::succeeded(_result_inner)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_inner)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 544 , __extension__ __PRETTY_FUNCTION__)); |
545 | return CompoundNestedOuterQualType::get(odsParser.getContext(), |
546 | ::test::CompoundNestedInnerType((*_result_inner))); |
547 | } |
548 | |
549 | void CompoundNestedOuterQualType::print(::mlir::AsmPrinter &odsPrinter) const { |
550 | ::mlir::Builder odsBuilder(getContext()); |
551 | odsPrinter << "<"; |
552 | odsPrinter << "i"; |
553 | odsPrinter << ' '; |
554 | odsPrinter << getInner(); |
555 | odsPrinter << ">"; |
556 | } |
557 | |
558 | ::test::CompoundNestedInnerType CompoundNestedOuterQualType::getInner() const { |
559 | return getImpl()->inner; |
560 | } |
561 | |
562 | } // namespace test |
563 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::CompoundNestedOuterQualType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::CompoundNestedOuterQualType>::id = {}; } } |
564 | namespace test { |
565 | namespace detail { |
566 | struct CompoundATypeStorage : public ::mlir::TypeStorage { |
567 | using KeyTy = std::tuple<int, ::mlir::Type, ::llvm::ArrayRef<int>>; |
568 | CompoundATypeStorage(int widthOfSomething, ::mlir::Type oneType, ::llvm::ArrayRef<int> arrayOfInts) : widthOfSomething(widthOfSomething), oneType(oneType), arrayOfInts(arrayOfInts) {} |
569 | |
570 | KeyTy getAsKey() const { |
571 | return KeyTy(widthOfSomething, oneType, arrayOfInts); |
572 | } |
573 | |
574 | bool operator==(const KeyTy &tblgenKey) const { |
575 | return (widthOfSomething == std::get<0>(tblgenKey)) && (oneType == std::get<1>(tblgenKey)) && (arrayOfInts == std::get<2>(tblgenKey)); |
576 | } |
577 | |
578 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
579 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); |
580 | } |
581 | |
582 | static CompoundATypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
583 | auto widthOfSomething = std::get<0>(tblgenKey); |
584 | auto oneType = std::get<1>(tblgenKey); |
585 | auto arrayOfInts = std::get<2>(tblgenKey); |
586 | arrayOfInts = allocator.copyInto(arrayOfInts); |
587 | return new (allocator.allocate<CompoundATypeStorage>()) CompoundATypeStorage(widthOfSomething, oneType, arrayOfInts); |
588 | } |
589 | |
590 | int widthOfSomething; |
591 | ::mlir::Type oneType; |
592 | ::llvm::ArrayRef<int> arrayOfInts; |
593 | }; |
594 | } // namespace detail |
595 | CompoundAType CompoundAType::get(::mlir::MLIRContext *context, int widthOfSomething, ::mlir::Type oneType, ::llvm::ArrayRef<int> arrayOfInts) { |
596 | return Base::get(context, widthOfSomething, oneType, arrayOfInts); |
597 | } |
598 | |
599 | int CompoundAType::getWidthOfSomething() const { |
600 | return getImpl()->widthOfSomething; |
601 | } |
602 | |
603 | ::mlir::Type CompoundAType::getOneType() const { |
604 | return getImpl()->oneType; |
605 | } |
606 | |
607 | ::llvm::ArrayRef<int> CompoundAType::getArrayOfInts() const { |
608 | return getImpl()->arrayOfInts; |
609 | } |
610 | |
611 | } // namespace test |
612 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::CompoundAType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::CompoundAType>::id = {}; } } |
613 | namespace test { |
614 | namespace detail { |
615 | struct TestIntegerTypeStorage : public ::mlir::TypeStorage { |
616 | using KeyTy = std::tuple<unsigned, ::test::TestIntegerType::SignednessSemantics>; |
617 | TestIntegerTypeStorage(unsigned width, ::test::TestIntegerType::SignednessSemantics signedness) : width(width), signedness(signedness) {} |
618 | |
619 | KeyTy getAsKey() const { |
620 | return KeyTy(width, signedness); |
621 | } |
622 | |
623 | bool operator==(const KeyTy &tblgenKey) const { |
624 | return (width == std::get<0>(tblgenKey)) && (signedness == std::get<1>(tblgenKey)); |
625 | } |
626 | |
627 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
628 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
629 | } |
630 | |
631 | static TestIntegerTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
632 | auto width = std::get<0>(tblgenKey); |
633 | auto signedness = std::get<1>(tblgenKey); |
634 | return new (allocator.allocate<TestIntegerTypeStorage>()) TestIntegerTypeStorage(width, signedness); |
635 | } |
636 | |
637 | unsigned width; |
638 | ::test::TestIntegerType::SignednessSemantics signedness; |
639 | }; |
640 | } // namespace detail |
641 | TestIntegerType TestIntegerType::get(::mlir::MLIRContext *context, unsigned width, SignednessSemantics signedness) { |
642 | return Base::get(context, width, signedness); |
643 | } |
644 | |
645 | TestIntegerType TestIntegerType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, unsigned width, SignednessSemantics signedness) { |
646 | return Base::getChecked(emitError, context, width, signedness); |
647 | } |
648 | |
649 | unsigned TestIntegerType::getWidth() const { |
650 | return getImpl()->width; |
651 | } |
652 | |
653 | ::test::TestIntegerType::SignednessSemantics TestIntegerType::getSignedness() const { |
654 | return getImpl()->signedness; |
655 | } |
656 | |
657 | } // namespace test |
658 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestIntegerType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestIntegerType>::id = {}; } } |
659 | namespace test { |
660 | } // namespace test |
661 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::SimpleAType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::SimpleAType>::id = {}; } } |
662 | namespace test { |
663 | namespace detail { |
664 | struct StructTypeStorage : public ::mlir::TypeStorage { |
665 | using KeyTy = std::tuple<::llvm::ArrayRef<::test::FieldInfo>>; |
666 | StructTypeStorage(::llvm::ArrayRef<::test::FieldInfo> fields) : fields(fields) {} |
667 | |
668 | KeyTy getAsKey() const { |
669 | return KeyTy(fields); |
670 | } |
671 | |
672 | bool operator==(const KeyTy &tblgenKey) const { |
673 | return (fields == std::get<0>(tblgenKey)); |
674 | } |
675 | |
676 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
677 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
678 | } |
679 | |
680 | static StructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
681 | auto fields = std::get<0>(tblgenKey); |
682 | |
683 | llvm::SmallVector<::test::FieldInfo, 4> tmpFields; |
684 | for (size_t i = 0, e = fields.size(); i < e; ++i) |
685 | tmpFields.push_back(fields[i].allocateInto(allocator)); |
686 | fields = allocator.copyInto(ArrayRef<::test::FieldInfo>(tmpFields)); |
687 | |
688 | return new (allocator.allocate<StructTypeStorage>()) StructTypeStorage(fields); |
689 | } |
690 | |
691 | ::llvm::ArrayRef<::test::FieldInfo> fields; |
692 | }; |
693 | } // namespace detail |
694 | StructType StructType::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::test::FieldInfo> fields) { |
695 | return Base::get(context, fields); |
696 | } |
697 | |
698 | ::llvm::ArrayRef<::test::FieldInfo> StructType::getFields() const { |
699 | return getImpl()->fields; |
700 | } |
701 | |
702 | } // namespace test |
703 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::StructType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::StructType>::id = {}; } } |
704 | namespace test { |
705 | } // namespace test |
706 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestMemRefElementTypeType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestMemRefElementTypeType>::id = {}; } } |
707 | namespace test { |
708 | } // namespace test |
709 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestType>::id = {}; } } |
710 | namespace test { |
711 | namespace detail { |
712 | struct TestTypeAPFloatTypeStorage : public ::mlir::TypeStorage { |
713 | using KeyTy = std::tuple<llvm::APFloat>; |
714 | TestTypeAPFloatTypeStorage(llvm::APFloat a) : a(a) {} |
715 | |
716 | KeyTy getAsKey() const { |
717 | return KeyTy(a); |
718 | } |
719 | |
720 | bool operator==(const KeyTy &tblgenKey) const { |
721 | return (a.bitwiseIsEqual(std::get<0>(tblgenKey))); |
722 | } |
723 | |
724 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
725 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
726 | } |
727 | |
728 | static TestTypeAPFloatTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
729 | auto a = std::get<0>(tblgenKey); |
730 | return new (allocator.allocate<TestTypeAPFloatTypeStorage>()) TestTypeAPFloatTypeStorage(a); |
731 | } |
732 | |
733 | llvm::APFloat a; |
734 | }; |
735 | } // namespace detail |
736 | TestTypeAPFloatType TestTypeAPFloatType::get(::mlir::MLIRContext *context, llvm::APFloat a) { |
737 | return Base::get(context, a); |
738 | } |
739 | |
740 | ::mlir::Type TestTypeAPFloatType::parse(::mlir::AsmParser &odsParser) { |
741 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
742 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
743 | (void) odsLoc; |
744 | ::mlir::FailureOr<llvm::APFloat> _result_a; |
745 | // Parse literal '<' |
746 | if (odsParser.parseLess()) return {}; |
747 | |
748 | // Parse variable 'a' |
749 | _result_a = [&]() -> mlir::FailureOr<llvm::APFloat> { |
750 | mlir::FloatAttr attr; |
751 | auto result = odsParser.parseOptionalAttribute(attr); |
752 | if (result.has_value() && mlir::succeeded(*result)) |
753 | return attr.getValue(); |
754 | if (!result.has_value()) |
755 | return llvm::APFloat(APFloat::getZero(APFloat::IEEEdouble())); |
756 | return mlir::failure(); |
757 | }() ; |
758 | if (::mlir::failed(_result_a)) { |
759 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeAPFloat parameter 'a' which is to be a `llvm::APFloat`"); |
760 | return {}; |
761 | } |
762 | // Parse literal '>' |
763 | if (odsParser.parseGreater()) return {}; |
764 | return TestTypeAPFloatType::get(odsParser.getContext(), |
765 | llvm::APFloat((_result_a.value_or(llvm::APFloat(APFloat::getZero(APFloat::IEEEdouble())))))); |
766 | } |
767 | |
768 | void TestTypeAPFloatType::print(::mlir::AsmPrinter &odsPrinter) const { |
769 | ::mlir::Builder odsBuilder(getContext()); |
770 | odsPrinter << "<"; |
771 | if (!(getA().bitwiseIsEqual(llvm::APFloat(APFloat::getZero(APFloat::IEEEdouble()))))) { |
772 | odsPrinter.printStrippedAttrOrType(getA()); |
773 | } |
774 | odsPrinter << ">"; |
775 | } |
776 | |
777 | llvm::APFloat TestTypeAPFloatType::getA() const { |
778 | return getImpl()->a; |
779 | } |
780 | |
781 | } // namespace test |
782 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeAPFloatType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeAPFloatType>::id = {}; } } |
783 | namespace test { |
784 | namespace detail { |
785 | struct TestTypeAllOptionalParamsTypeStorage : public ::mlir::TypeStorage { |
786 | using KeyTy = std::tuple<std::optional<int>, std::optional<int>>; |
787 | TestTypeAllOptionalParamsTypeStorage(std::optional<int> a, std::optional<int> b) : a(a), b(b) {} |
788 | |
789 | KeyTy getAsKey() const { |
790 | return KeyTy(a, b); |
791 | } |
792 | |
793 | bool operator==(const KeyTy &tblgenKey) const { |
794 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
795 | } |
796 | |
797 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
798 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
799 | } |
800 | |
801 | static TestTypeAllOptionalParamsTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
802 | auto a = std::get<0>(tblgenKey); |
803 | auto b = std::get<1>(tblgenKey); |
804 | return new (allocator.allocate<TestTypeAllOptionalParamsTypeStorage>()) TestTypeAllOptionalParamsTypeStorage(a, b); |
805 | } |
806 | |
807 | std::optional<int> a; |
808 | std::optional<int> b; |
809 | }; |
810 | } // namespace detail |
811 | TestTypeAllOptionalParamsType TestTypeAllOptionalParamsType::get(::mlir::MLIRContext *context, std::optional<int> a, std::optional<int> b) { |
812 | return Base::get(context, a, b); |
813 | } |
814 | |
815 | ::mlir::Type TestTypeAllOptionalParamsType::parse(::mlir::AsmParser &odsParser) { |
816 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
817 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
818 | (void) odsLoc; |
819 | ::mlir::FailureOr<std::optional<int>> _result_a; |
820 | ::mlir::FailureOr<std::optional<int>> _result_b; |
821 | // Parse literal '<' |
822 | if (odsParser.parseLess()) return {}; |
823 | // Parse parameter list |
824 | do { |
825 | |
826 | // Parse variable 'a' |
827 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
828 | if (::mlir::failed(_result_a)) { |
829 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeAllOptionalParams parameter 'a' which is to be a `std::optional<int>`"); |
830 | return {}; |
831 | } |
832 | if (::mlir::succeeded(_result_a) && !((*_result_a) == std::optional<int>())) { |
833 | // Parse literal ',' |
834 | if (odsParser.parseOptionalComma()) break; |
835 | } |
836 | |
837 | // Parse variable 'b' |
838 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
839 | if (::mlir::failed(_result_b)) { |
840 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeAllOptionalParams parameter 'b' which is to be a `std::optional<int>`"); |
841 | return {}; |
842 | } |
843 | } while(false); |
844 | // Parse literal '>' |
845 | if (odsParser.parseGreater()) return {}; |
846 | return TestTypeAllOptionalParamsType::get(odsParser.getContext(), |
847 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
848 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
849 | } |
850 | |
851 | void TestTypeAllOptionalParamsType::print(::mlir::AsmPrinter &odsPrinter) const { |
852 | ::mlir::Builder odsBuilder(getContext()); |
853 | odsPrinter << "<"; |
854 | { |
855 | bool _firstPrinted = true; |
856 | if (!(getA() == std::optional<int>())) { |
857 | if (!_firstPrinted) odsPrinter << ", "; |
858 | _firstPrinted = false; |
859 | if (!(getA() == std::optional<int>())) { |
860 | odsPrinter.printStrippedAttrOrType(getA()); |
861 | } |
862 | } |
863 | if (!(getB() == std::optional<int>())) { |
864 | if (!_firstPrinted) odsPrinter << ", "; |
865 | _firstPrinted = false; |
866 | if (!(getB() == std::optional<int>())) { |
867 | odsPrinter.printStrippedAttrOrType(getB()); |
868 | } |
869 | } |
870 | } |
871 | odsPrinter << ">"; |
872 | } |
873 | |
874 | std::optional<int> TestTypeAllOptionalParamsType::getA() const { |
875 | return getImpl()->a; |
876 | } |
877 | |
878 | std::optional<int> TestTypeAllOptionalParamsType::getB() const { |
879 | return getImpl()->b; |
880 | } |
881 | |
882 | } // namespace test |
883 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeAllOptionalParamsType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeAllOptionalParamsType>::id = {}; } } |
884 | namespace test { |
885 | namespace detail { |
886 | struct TestTypeAllOptionalStructTypeStorage : public ::mlir::TypeStorage { |
887 | using KeyTy = std::tuple<std::optional<int>, std::optional<int>>; |
888 | TestTypeAllOptionalStructTypeStorage(std::optional<int> a, std::optional<int> b) : a(a), b(b) {} |
889 | |
890 | KeyTy getAsKey() const { |
891 | return KeyTy(a, b); |
892 | } |
893 | |
894 | bool operator==(const KeyTy &tblgenKey) const { |
895 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
896 | } |
897 | |
898 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
899 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
900 | } |
901 | |
902 | static TestTypeAllOptionalStructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
903 | auto a = std::get<0>(tblgenKey); |
904 | auto b = std::get<1>(tblgenKey); |
905 | return new (allocator.allocate<TestTypeAllOptionalStructTypeStorage>()) TestTypeAllOptionalStructTypeStorage(a, b); |
906 | } |
907 | |
908 | std::optional<int> a; |
909 | std::optional<int> b; |
910 | }; |
911 | } // namespace detail |
912 | TestTypeAllOptionalStructType TestTypeAllOptionalStructType::get(::mlir::MLIRContext *context, std::optional<int> a, std::optional<int> b) { |
913 | return Base::get(context, a, b); |
914 | } |
915 | |
916 | ::mlir::Type TestTypeAllOptionalStructType::parse(::mlir::AsmParser &odsParser) { |
917 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
918 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
919 | (void) odsLoc; |
920 | ::mlir::FailureOr<std::optional<int>> _result_a; |
921 | ::mlir::FailureOr<std::optional<int>> _result_b; |
922 | // Parse literal '<' |
923 | if (odsParser.parseLess()) return {}; |
924 | // Parse parameter struct |
925 | bool _seen_a = false; |
926 | bool _seen_b = false; |
927 | { |
928 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
929 | // Parse literal '=' |
930 | if (odsParser.parseEqual()) return {}; |
931 | if (!_seen_a && _paramKey == "a") { |
932 | _seen_a = true; |
933 | |
934 | // Parse variable 'a' |
935 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
936 | if (::mlir::failed(_result_a)) { |
937 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeAllOptionalStruct parameter 'a' which is to be a `std::optional<int>`"); |
938 | return {}; |
939 | } |
940 | } else if (!_seen_b && _paramKey == "b") { |
941 | _seen_b = true; |
942 | |
943 | // Parse variable 'b' |
944 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
945 | if (::mlir::failed(_result_b)) { |
946 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeAllOptionalStruct parameter 'b' which is to be a `std::optional<int>`"); |
947 | return {}; |
948 | } |
949 | } else { |
950 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
951 | return {}; |
952 | } |
953 | return true; |
954 | }; |
955 | ::llvm::StringRef _paramKey; |
956 | if (!odsParser.parseOptionalKeyword(&_paramKey)) { |
957 | if (!_loop_body(_paramKey)) return {}; |
958 | while (!odsParser.parseOptionalComma()) { |
959 | ::llvm::StringRef _paramKey; |
960 | if (odsParser.parseKeyword(&_paramKey)) { |
961 | odsParser.emitError(odsParser.getCurrentLocation(), |
962 | "expected a parameter name in struct"); |
963 | return {}; |
964 | } |
965 | if (!_loop_body(_paramKey)) return {}; |
966 | } |
967 | } |
968 | } |
969 | // Parse literal '>' |
970 | if (odsParser.parseGreater()) return {}; |
971 | return TestTypeAllOptionalStructType::get(odsParser.getContext(), |
972 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
973 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
974 | } |
975 | |
976 | void TestTypeAllOptionalStructType::print(::mlir::AsmPrinter &odsPrinter) const { |
977 | ::mlir::Builder odsBuilder(getContext()); |
978 | odsPrinter << "<"; |
979 | { |
980 | bool _firstPrinted = true; |
981 | if (!(getA() == std::optional<int>())) { |
982 | if (!_firstPrinted) odsPrinter << ", "; |
983 | _firstPrinted = false; |
984 | odsPrinter << "a = "; |
985 | if (!(getA() == std::optional<int>())) { |
986 | odsPrinter.printStrippedAttrOrType(getA()); |
987 | } |
988 | } |
989 | if (!(getB() == std::optional<int>())) { |
990 | if (!_firstPrinted) odsPrinter << ", "; |
991 | _firstPrinted = false; |
992 | odsPrinter << "b = "; |
993 | if (!(getB() == std::optional<int>())) { |
994 | odsPrinter.printStrippedAttrOrType(getB()); |
995 | } |
996 | } |
997 | } |
998 | odsPrinter << ">"; |
999 | } |
1000 | |
1001 | std::optional<int> TestTypeAllOptionalStructType::getA() const { |
1002 | return getImpl()->a; |
1003 | } |
1004 | |
1005 | std::optional<int> TestTypeAllOptionalStructType::getB() const { |
1006 | return getImpl()->b; |
1007 | } |
1008 | |
1009 | } // namespace test |
1010 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeAllOptionalStructType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeAllOptionalStructType>::id = {}; } } |
1011 | namespace test { |
1012 | namespace detail { |
1013 | struct TestTypeCustomTypeStorage : public ::mlir::TypeStorage { |
1014 | using KeyTy = std::tuple<int, std::optional<int>>; |
1015 | TestTypeCustomTypeStorage(int a, std::optional<int> b) : a(a), b(b) {} |
1016 | |
1017 | KeyTy getAsKey() const { |
1018 | return KeyTy(a, b); |
1019 | } |
1020 | |
1021 | bool operator==(const KeyTy &tblgenKey) const { |
1022 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1023 | } |
1024 | |
1025 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1026 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1027 | } |
1028 | |
1029 | static TestTypeCustomTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1030 | auto a = std::get<0>(tblgenKey); |
1031 | auto b = std::get<1>(tblgenKey); |
1032 | return new (allocator.allocate<TestTypeCustomTypeStorage>()) TestTypeCustomTypeStorage(a, b); |
1033 | } |
1034 | |
1035 | int a; |
1036 | std::optional<int> b; |
1037 | }; |
1038 | } // namespace detail |
1039 | TestTypeCustomType TestTypeCustomType::get(::mlir::MLIRContext *context, int a, std::optional<int> b) { |
1040 | return Base::get(context, a, b); |
1041 | } |
1042 | |
1043 | ::mlir::Type TestTypeCustomType::parse(::mlir::AsmParser &odsParser) { |
1044 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1045 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1046 | (void) odsLoc; |
1047 | ::mlir::FailureOr<int> _result_a; |
1048 | ::mlir::FailureOr<std::optional<int>> _result_b; |
1049 | // Parse literal '<' |
1050 | if (odsParser.parseLess()) return {}; |
1051 | { |
1052 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1053 | (void)odsCustomLoc; |
1054 | auto odsCustomResult = parseCustomTypeA(odsParser, |
1055 | ::mlir::detail::unwrapForCustomParse(_result_a)); |
1056 | if (::mlir::failed(odsCustomResult)) return {}; |
1057 | if (::mlir::failed(_result_a)) { |
1058 | odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'a'"); |
1059 | return {}; |
1060 | } |
1061 | } |
1062 | { |
1063 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1064 | (void)odsCustomLoc; |
1065 | auto odsCustomResult = parseCustomTypeB(odsParser, |
1066 | *_result_a, |
1067 | ::mlir::detail::unwrapForCustomParse(_result_b)); |
1068 | if (::mlir::failed(odsCustomResult)) return {}; |
1069 | } |
1070 | // Parse literal '>' |
1071 | if (odsParser.parseGreater()) return {}; |
1072 | assert(::mlir::succeeded(_result_a))(static_cast <bool> (::mlir::succeeded(_result_a)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_a)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1072, __extension__ __PRETTY_FUNCTION__)); |
1073 | return TestTypeCustomType::get(odsParser.getContext(), |
1074 | int((*_result_a)), |
1075 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
1076 | } |
1077 | |
1078 | void TestTypeCustomType::print(::mlir::AsmPrinter &odsPrinter) const { |
1079 | ::mlir::Builder odsBuilder(getContext()); |
1080 | odsPrinter << "<"; |
1081 | printCustomTypeA(odsPrinter, |
1082 | getA()); |
1083 | printCustomTypeB(odsPrinter, |
1084 | getA(), |
1085 | getB()); |
1086 | odsPrinter << ">"; |
1087 | } |
1088 | |
1089 | int TestTypeCustomType::getA() const { |
1090 | return getImpl()->a; |
1091 | } |
1092 | |
1093 | std::optional<int> TestTypeCustomType::getB() const { |
1094 | return getImpl()->b; |
1095 | } |
1096 | |
1097 | } // namespace test |
1098 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeCustomType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeCustomType>::id = {}; } } |
1099 | namespace test { |
1100 | namespace detail { |
1101 | struct TestTypeCustomSpacingTypeStorage : public ::mlir::TypeStorage { |
1102 | using KeyTy = std::tuple<int, int>; |
1103 | TestTypeCustomSpacingTypeStorage(int a, int b) : a(a), b(b) {} |
1104 | |
1105 | KeyTy getAsKey() const { |
1106 | return KeyTy(a, b); |
1107 | } |
1108 | |
1109 | bool operator==(const KeyTy &tblgenKey) const { |
1110 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1111 | } |
1112 | |
1113 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1114 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1115 | } |
1116 | |
1117 | static TestTypeCustomSpacingTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1118 | auto a = std::get<0>(tblgenKey); |
1119 | auto b = std::get<1>(tblgenKey); |
1120 | return new (allocator.allocate<TestTypeCustomSpacingTypeStorage>()) TestTypeCustomSpacingTypeStorage(a, b); |
1121 | } |
1122 | |
1123 | int a; |
1124 | int b; |
1125 | }; |
1126 | } // namespace detail |
1127 | TestTypeCustomSpacingType TestTypeCustomSpacingType::get(::mlir::MLIRContext *context, int a, int b) { |
1128 | return Base::get(context, a, b); |
1129 | } |
1130 | |
1131 | ::mlir::Type TestTypeCustomSpacingType::parse(::mlir::AsmParser &odsParser) { |
1132 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1133 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1134 | (void) odsLoc; |
1135 | ::mlir::FailureOr<int> _result_a; |
1136 | ::mlir::FailureOr<int> _result_b; |
1137 | // Parse literal '<' |
1138 | if (odsParser.parseLess()) return {}; |
1139 | { |
1140 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1141 | (void)odsCustomLoc; |
1142 | auto odsCustomResult = parseCustomTypeA(odsParser, |
1143 | ::mlir::detail::unwrapForCustomParse(_result_a)); |
1144 | if (::mlir::failed(odsCustomResult)) return {}; |
1145 | if (::mlir::failed(_result_a)) { |
1146 | odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'a'"); |
1147 | return {}; |
1148 | } |
1149 | } |
1150 | { |
1151 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1152 | (void)odsCustomLoc; |
1153 | auto odsCustomResult = parseCustomTypeA(odsParser, |
1154 | ::mlir::detail::unwrapForCustomParse(_result_b)); |
1155 | if (::mlir::failed(odsCustomResult)) return {}; |
1156 | if (::mlir::failed(_result_b)) { |
1157 | odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'b'"); |
1158 | return {}; |
1159 | } |
1160 | } |
1161 | // Parse literal '>' |
1162 | if (odsParser.parseGreater()) return {}; |
1163 | assert(::mlir::succeeded(_result_a))(static_cast <bool> (::mlir::succeeded(_result_a)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_a)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1163, __extension__ __PRETTY_FUNCTION__)); |
1164 | assert(::mlir::succeeded(_result_b))(static_cast <bool> (::mlir::succeeded(_result_b)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_b)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1164, __extension__ __PRETTY_FUNCTION__)); |
1165 | return TestTypeCustomSpacingType::get(odsParser.getContext(), |
1166 | int((*_result_a)), |
1167 | int((*_result_b))); |
1168 | } |
1169 | |
1170 | void TestTypeCustomSpacingType::print(::mlir::AsmPrinter &odsPrinter) const { |
1171 | ::mlir::Builder odsBuilder(getContext()); |
1172 | odsPrinter << "<"; |
1173 | printCustomTypeA(odsPrinter, |
1174 | getA()); |
1175 | odsPrinter << ' '; |
1176 | printCustomTypeA(odsPrinter, |
1177 | getB()); |
1178 | odsPrinter << ">"; |
1179 | } |
1180 | |
1181 | int TestTypeCustomSpacingType::getA() const { |
1182 | return getImpl()->a; |
1183 | } |
1184 | |
1185 | int TestTypeCustomSpacingType::getB() const { |
1186 | return getImpl()->b; |
1187 | } |
1188 | |
1189 | } // namespace test |
1190 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeCustomSpacingType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeCustomSpacingType>::id = {}; } } |
1191 | namespace test { |
1192 | namespace detail { |
1193 | struct TestTypeCustomStringTypeStorage : public ::mlir::TypeStorage { |
1194 | using KeyTy = std::tuple<::llvm::StringRef>; |
1195 | TestTypeCustomStringTypeStorage(::llvm::StringRef foo) : foo(foo) {} |
1196 | |
1197 | KeyTy getAsKey() const { |
1198 | return KeyTy(foo); |
1199 | } |
1200 | |
1201 | bool operator==(const KeyTy &tblgenKey) const { |
1202 | return (foo == std::get<0>(tblgenKey)); |
1203 | } |
1204 | |
1205 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1206 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
1207 | } |
1208 | |
1209 | static TestTypeCustomStringTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1210 | auto foo = std::get<0>(tblgenKey); |
1211 | foo = allocator.copyInto(foo); |
1212 | return new (allocator.allocate<TestTypeCustomStringTypeStorage>()) TestTypeCustomStringTypeStorage(foo); |
1213 | } |
1214 | |
1215 | ::llvm::StringRef foo; |
1216 | }; |
1217 | } // namespace detail |
1218 | TestTypeCustomStringType TestTypeCustomStringType::get(::mlir::MLIRContext *context, ::llvm::StringRef foo) { |
1219 | return Base::get(context, foo); |
1220 | } |
1221 | |
1222 | ::mlir::Type TestTypeCustomStringType::parse(::mlir::AsmParser &odsParser) { |
1223 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1224 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1225 | (void) odsLoc; |
1226 | ::mlir::FailureOr<std::string> _result_foo; |
1227 | // Parse literal '<' |
1228 | if (odsParser.parseLess()) return {}; |
1229 | { |
1230 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1231 | (void)odsCustomLoc; |
1232 | auto odsCustomResult = parseFooString(odsParser, |
1233 | ::mlir::detail::unwrapForCustomParse(_result_foo)); |
1234 | if (::mlir::failed(odsCustomResult)) return {}; |
1235 | if (::mlir::failed(_result_foo)) { |
1236 | odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'foo'"); |
1237 | return {}; |
1238 | } |
1239 | } |
1240 | { |
1241 | auto odsCustomLoc = odsParser.getCurrentLocation(); |
1242 | (void)odsCustomLoc; |
1243 | auto odsCustomResult = parseBarString(odsParser, |
1244 | *_result_foo); |
1245 | if (::mlir::failed(odsCustomResult)) return {}; |
1246 | } |
1247 | // Parse literal '>' |
1248 | if (odsParser.parseGreater()) return {}; |
1249 | assert(::mlir::succeeded(_result_foo))(static_cast <bool> (::mlir::succeeded(_result_foo)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_foo)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1249, __extension__ __PRETTY_FUNCTION__)); |
1250 | return TestTypeCustomStringType::get(odsParser.getContext(), |
1251 | ::llvm::StringRef((*_result_foo))); |
1252 | } |
1253 | |
1254 | void TestTypeCustomStringType::print(::mlir::AsmPrinter &odsPrinter) const { |
1255 | ::mlir::Builder odsBuilder(getContext()); |
1256 | odsPrinter << "<"; |
1257 | printFooString(odsPrinter, |
1258 | getFoo()); |
1259 | odsPrinter << ' '; |
1260 | printBarString(odsPrinter, |
1261 | getFoo()); |
1262 | odsPrinter << ">"; |
1263 | } |
1264 | |
1265 | ::llvm::StringRef TestTypeCustomStringType::getFoo() const { |
1266 | return getImpl()->foo; |
1267 | } |
1268 | |
1269 | } // namespace test |
1270 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeCustomStringType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeCustomStringType>::id = {}; } } |
1271 | namespace test { |
1272 | namespace detail { |
1273 | struct TestTypeDefaultValuedTypeTypeStorage : public ::mlir::TypeStorage { |
1274 | using KeyTy = std::tuple<mlir::IntegerType>; |
1275 | TestTypeDefaultValuedTypeTypeStorage(mlir::IntegerType type) : type(type) {} |
1276 | |
1277 | KeyTy getAsKey() const { |
1278 | return KeyTy(type); |
1279 | } |
1280 | |
1281 | bool operator==(const KeyTy &tblgenKey) const { |
1282 | return (type == std::get<0>(tblgenKey)); |
1283 | } |
1284 | |
1285 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1286 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
1287 | } |
1288 | |
1289 | static TestTypeDefaultValuedTypeTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1290 | auto type = std::get<0>(tblgenKey); |
1291 | return new (allocator.allocate<TestTypeDefaultValuedTypeTypeStorage>()) TestTypeDefaultValuedTypeTypeStorage(type); |
1292 | } |
1293 | |
1294 | mlir::IntegerType type; |
1295 | }; |
1296 | } // namespace detail |
1297 | TestTypeDefaultValuedTypeType TestTypeDefaultValuedTypeType::get(::mlir::MLIRContext *context, mlir::IntegerType type) { |
1298 | return Base::get(context, type); |
1299 | } |
1300 | |
1301 | ::mlir::Type TestTypeDefaultValuedTypeType::parse(::mlir::AsmParser &odsParser) { |
1302 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1303 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1304 | (void) odsLoc; |
1305 | ::mlir::FailureOr<mlir::IntegerType> _result_type; |
1306 | // Parse literal '<' |
1307 | if (odsParser.parseLess()) return {}; |
1308 | // Parse literal '(' |
1309 | if (odsParser.parseOptionalLParen()) { |
1310 | } else { |
1311 | |
1312 | // Parse variable 'type' |
1313 | _result_type = ::mlir::FieldParser<mlir::IntegerType>::parse(odsParser); |
1314 | if (::mlir::failed(_result_type)) { |
1315 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeDefaultValuedType parameter 'type' which is to be a `mlir::IntegerType`"); |
1316 | return {}; |
1317 | } |
1318 | // Parse literal ')' |
1319 | if (odsParser.parseRParen()) return {}; |
1320 | } |
1321 | // Parse literal '>' |
1322 | if (odsParser.parseGreater()) return {}; |
1323 | return TestTypeDefaultValuedTypeType::get(odsParser.getContext(), |
1324 | mlir::IntegerType((_result_type.value_or(mlir::IntegerType::get(odsParser.getContext(), 32))))); |
1325 | } |
1326 | |
1327 | void TestTypeDefaultValuedTypeType::print(::mlir::AsmPrinter &odsPrinter) const { |
1328 | ::mlir::Builder odsBuilder(getContext()); |
1329 | odsPrinter << "<"; |
1330 | if (!(getType() == mlir::IntegerType::get(getContext(), 32))) { |
1331 | odsPrinter << "("; |
1332 | if (!(getType() == mlir::IntegerType::get(getContext(), 32))) { |
1333 | odsPrinter.printStrippedAttrOrType(getType()); |
1334 | } |
1335 | odsPrinter << ")"; |
1336 | } else { |
1337 | } |
1338 | odsPrinter << ">"; |
1339 | } |
1340 | |
1341 | mlir::IntegerType TestTypeDefaultValuedTypeType::getType() const { |
1342 | return getImpl()->type; |
1343 | } |
1344 | |
1345 | } // namespace test |
1346 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeDefaultValuedTypeType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeDefaultValuedTypeType>::id = {}; } } |
1347 | namespace test { |
1348 | namespace detail { |
1349 | struct TestTypeElseAnchorTypeStorage : public ::mlir::TypeStorage { |
1350 | using KeyTy = std::tuple<std::optional<int>>; |
1351 | TestTypeElseAnchorTypeStorage(std::optional<int> a) : a(a) {} |
1352 | |
1353 | KeyTy getAsKey() const { |
1354 | return KeyTy(a); |
1355 | } |
1356 | |
1357 | bool operator==(const KeyTy &tblgenKey) const { |
1358 | return (a == std::get<0>(tblgenKey)); |
1359 | } |
1360 | |
1361 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1362 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
1363 | } |
1364 | |
1365 | static TestTypeElseAnchorTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1366 | auto a = std::get<0>(tblgenKey); |
1367 | return new (allocator.allocate<TestTypeElseAnchorTypeStorage>()) TestTypeElseAnchorTypeStorage(a); |
1368 | } |
1369 | |
1370 | std::optional<int> a; |
1371 | }; |
1372 | } // namespace detail |
1373 | TestTypeElseAnchorType TestTypeElseAnchorType::get(::mlir::MLIRContext *context, std::optional<int> a) { |
1374 | return Base::get(context, a); |
1375 | } |
1376 | |
1377 | ::mlir::Type TestTypeElseAnchorType::parse(::mlir::AsmParser &odsParser) { |
1378 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1379 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1380 | (void) odsLoc; |
1381 | ::mlir::FailureOr<std::optional<int>> _result_a; |
1382 | // Parse literal '<' |
1383 | if (odsParser.parseLess()) return {}; |
1384 | // Parse literal '?' |
1385 | if (odsParser.parseOptionalQuestion()) { |
1386 | |
1387 | // Parse variable 'a' |
1388 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1389 | if (::mlir::failed(_result_a)) { |
1390 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeElseAnchor parameter 'a' which is to be a `std::optional<int>`"); |
1391 | return {}; |
1392 | } |
1393 | } else { |
1394 | } |
1395 | // Parse literal '>' |
1396 | if (odsParser.parseGreater()) return {}; |
1397 | return TestTypeElseAnchorType::get(odsParser.getContext(), |
1398 | std::optional<int>((_result_a.value_or(std::optional<int>())))); |
1399 | } |
1400 | |
1401 | void TestTypeElseAnchorType::print(::mlir::AsmPrinter &odsPrinter) const { |
1402 | ::mlir::Builder odsBuilder(getContext()); |
1403 | odsPrinter << "<"; |
1404 | if (!(!(getA() == std::optional<int>()))) { |
1405 | odsPrinter << "?"; |
1406 | } else { |
1407 | if (!(getA() == std::optional<int>())) { |
1408 | odsPrinter.printStrippedAttrOrType(getA()); |
1409 | } |
1410 | } |
1411 | odsPrinter << ">"; |
1412 | } |
1413 | |
1414 | std::optional<int> TestTypeElseAnchorType::getA() const { |
1415 | return getImpl()->a; |
1416 | } |
1417 | |
1418 | } // namespace test |
1419 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeElseAnchorType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeElseAnchorType>::id = {}; } } |
1420 | namespace test { |
1421 | namespace detail { |
1422 | struct TestTypeElseAnchorStructTypeStorage : public ::mlir::TypeStorage { |
1423 | using KeyTy = std::tuple<std::optional<int>, std::optional<int>>; |
1424 | TestTypeElseAnchorStructTypeStorage(std::optional<int> a, std::optional<int> b) : a(a), b(b) {} |
1425 | |
1426 | KeyTy getAsKey() const { |
1427 | return KeyTy(a, b); |
1428 | } |
1429 | |
1430 | bool operator==(const KeyTy &tblgenKey) const { |
1431 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1432 | } |
1433 | |
1434 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1435 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1436 | } |
1437 | |
1438 | static TestTypeElseAnchorStructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1439 | auto a = std::get<0>(tblgenKey); |
1440 | auto b = std::get<1>(tblgenKey); |
1441 | return new (allocator.allocate<TestTypeElseAnchorStructTypeStorage>()) TestTypeElseAnchorStructTypeStorage(a, b); |
1442 | } |
1443 | |
1444 | std::optional<int> a; |
1445 | std::optional<int> b; |
1446 | }; |
1447 | } // namespace detail |
1448 | TestTypeElseAnchorStructType TestTypeElseAnchorStructType::get(::mlir::MLIRContext *context, std::optional<int> a, std::optional<int> b) { |
1449 | return Base::get(context, a, b); |
1450 | } |
1451 | |
1452 | ::mlir::Type TestTypeElseAnchorStructType::parse(::mlir::AsmParser &odsParser) { |
1453 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1454 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1455 | (void) odsLoc; |
1456 | ::mlir::FailureOr<std::optional<int>> _result_a; |
1457 | ::mlir::FailureOr<std::optional<int>> _result_b; |
1458 | // Parse literal '<' |
1459 | if (odsParser.parseLess()) return {}; |
1460 | // Parse literal '?' |
1461 | if (odsParser.parseOptionalQuestion()) { |
1462 | // Parse parameter struct |
1463 | bool _seen_a = false; |
1464 | bool _seen_b = false; |
1465 | { |
1466 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
1467 | // Parse literal '=' |
1468 | if (odsParser.parseEqual()) return {}; |
1469 | if (!_seen_a && _paramKey == "a") { |
1470 | _seen_a = true; |
1471 | |
1472 | // Parse variable 'a' |
1473 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1474 | if (::mlir::failed(_result_a)) { |
1475 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeElseAnchorStruct parameter 'a' which is to be a `std::optional<int>`"); |
1476 | return {}; |
1477 | } |
1478 | } else if (!_seen_b && _paramKey == "b") { |
1479 | _seen_b = true; |
1480 | |
1481 | // Parse variable 'b' |
1482 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1483 | if (::mlir::failed(_result_b)) { |
1484 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeElseAnchorStruct parameter 'b' which is to be a `std::optional<int>`"); |
1485 | return {}; |
1486 | } |
1487 | } else { |
1488 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
1489 | return {}; |
1490 | } |
1491 | return true; |
1492 | }; |
1493 | ::llvm::StringRef _paramKey; |
1494 | if (!odsParser.parseOptionalKeyword(&_paramKey)) { |
1495 | if (!_loop_body(_paramKey)) return {}; |
1496 | while (!odsParser.parseOptionalComma()) { |
1497 | ::llvm::StringRef _paramKey; |
1498 | if (odsParser.parseKeyword(&_paramKey)) { |
1499 | odsParser.emitError(odsParser.getCurrentLocation(), |
1500 | "expected a parameter name in struct"); |
1501 | return {}; |
1502 | } |
1503 | if (!_loop_body(_paramKey)) return {}; |
1504 | } |
1505 | } |
1506 | } |
1507 | } else { |
1508 | } |
1509 | // Parse literal '>' |
1510 | if (odsParser.parseGreater()) return {}; |
1511 | return TestTypeElseAnchorStructType::get(odsParser.getContext(), |
1512 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
1513 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
1514 | } |
1515 | |
1516 | void TestTypeElseAnchorStructType::print(::mlir::AsmPrinter &odsPrinter) const { |
1517 | ::mlir::Builder odsBuilder(getContext()); |
1518 | odsPrinter << "<"; |
1519 | if (!(!(getA() == std::optional<int>()) || !(getB() == std::optional<int>()))) { |
1520 | odsPrinter << "?"; |
1521 | } else { |
1522 | { |
1523 | bool _firstPrinted = true; |
1524 | if (!(getA() == std::optional<int>())) { |
1525 | if (!_firstPrinted) odsPrinter << ", "; |
1526 | _firstPrinted = false; |
1527 | odsPrinter << "a = "; |
1528 | if (!(getA() == std::optional<int>())) { |
1529 | odsPrinter.printStrippedAttrOrType(getA()); |
1530 | } |
1531 | } |
1532 | if (!(getB() == std::optional<int>())) { |
1533 | if (!_firstPrinted) odsPrinter << ", "; |
1534 | _firstPrinted = false; |
1535 | odsPrinter << "b = "; |
1536 | if (!(getB() == std::optional<int>())) { |
1537 | odsPrinter.printStrippedAttrOrType(getB()); |
1538 | } |
1539 | } |
1540 | } |
1541 | } |
1542 | odsPrinter << ">"; |
1543 | } |
1544 | |
1545 | std::optional<int> TestTypeElseAnchorStructType::getA() const { |
1546 | return getImpl()->a; |
1547 | } |
1548 | |
1549 | std::optional<int> TestTypeElseAnchorStructType::getB() const { |
1550 | return getImpl()->b; |
1551 | } |
1552 | |
1553 | } // namespace test |
1554 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeElseAnchorStructType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeElseAnchorStructType>::id = {}; } } |
1555 | namespace test { |
1556 | namespace detail { |
1557 | struct TestTypeNoParserTypeStorage : public ::mlir::TypeStorage { |
1558 | using KeyTy = std::tuple<uint32_t, ::llvm::ArrayRef<int64_t>, ::llvm::StringRef, ::test::CustomParam>; |
1559 | TestTypeNoParserTypeStorage(uint32_t one, ::llvm::ArrayRef<int64_t> two, ::llvm::StringRef three, ::test::CustomParam four) : one(one), two(two), three(three), four(four) {} |
1560 | |
1561 | KeyTy getAsKey() const { |
1562 | return KeyTy(one, two, three, four); |
1563 | } |
1564 | |
1565 | bool operator==(const KeyTy &tblgenKey) const { |
1566 | return (one == std::get<0>(tblgenKey)) && (two == std::get<1>(tblgenKey)) && (three == std::get<2>(tblgenKey)) && (four == std::get<3>(tblgenKey)); |
1567 | } |
1568 | |
1569 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1570 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey)); |
1571 | } |
1572 | |
1573 | static TestTypeNoParserTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1574 | auto one = std::get<0>(tblgenKey); |
1575 | auto two = std::get<1>(tblgenKey); |
1576 | auto three = std::get<2>(tblgenKey); |
1577 | auto four = std::get<3>(tblgenKey); |
1578 | two = allocator.copyInto(two); |
1579 | three = allocator.copyInto(three); |
1580 | return new (allocator.allocate<TestTypeNoParserTypeStorage>()) TestTypeNoParserTypeStorage(one, two, three, four); |
1581 | } |
1582 | |
1583 | uint32_t one; |
1584 | ::llvm::ArrayRef<int64_t> two; |
1585 | ::llvm::StringRef three; |
1586 | ::test::CustomParam four; |
1587 | }; |
1588 | } // namespace detail |
1589 | TestTypeNoParserType TestTypeNoParserType::get(::mlir::MLIRContext *context, uint32_t one, ::llvm::ArrayRef<int64_t> two, ::llvm::StringRef three, ::test::CustomParam four) { |
1590 | return Base::get(context, one, two, three, four); |
1591 | } |
1592 | |
1593 | ::mlir::Type TestTypeNoParserType::parse(::mlir::AsmParser &odsParser) { |
1594 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1595 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1596 | (void) odsLoc; |
1597 | ::mlir::FailureOr<uint32_t> _result_one; |
1598 | ::mlir::FailureOr<::llvm::SmallVector<int64_t>> _result_two; |
1599 | ::mlir::FailureOr<std::string> _result_three; |
1600 | ::mlir::FailureOr<::test::CustomParam> _result_four; |
1601 | // Parse literal '<' |
1602 | if (odsParser.parseLess()) return {}; |
1603 | |
1604 | // Parse variable 'one' |
1605 | _result_one = ::mlir::FieldParser<uint32_t>::parse(odsParser); |
1606 | if (::mlir::failed(_result_one)) { |
1607 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeNoParser parameter 'one' which is to be a `uint32_t`"); |
1608 | return {}; |
1609 | } |
1610 | // Parse literal ',' |
1611 | if (odsParser.parseComma()) return {}; |
1612 | // Parse literal '[' |
1613 | if (odsParser.parseLSquare()) return {}; |
1614 | |
1615 | // Parse variable 'two' |
1616 | _result_two = ::mlir::FieldParser<::llvm::SmallVector<int64_t>>::parse(odsParser); |
1617 | if (::mlir::failed(_result_two)) { |
1618 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeNoParser parameter 'two' which is to be a `::llvm::ArrayRef<int64_t>`"); |
1619 | return {}; |
1620 | } |
1621 | // Parse literal ']' |
1622 | if (odsParser.parseRSquare()) return {}; |
1623 | // Parse literal ',' |
1624 | if (odsParser.parseComma()) return {}; |
1625 | |
1626 | // Parse variable 'three' |
1627 | _result_three = ::mlir::FieldParser<std::string>::parse(odsParser); |
1628 | if (::mlir::failed(_result_three)) { |
1629 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeNoParser parameter 'three' which is to be a `::llvm::StringRef`"); |
1630 | return {}; |
1631 | } |
1632 | // Parse literal ',' |
1633 | if (odsParser.parseComma()) return {}; |
1634 | |
1635 | // Parse variable 'four' |
1636 | _result_four = ::mlir::FieldParser<::test::CustomParam>::parse(odsParser); |
1637 | if (::mlir::failed(_result_four)) { |
1638 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeNoParser parameter 'four' which is to be a `::test::CustomParam`"); |
1639 | return {}; |
1640 | } |
1641 | // Parse literal '>' |
1642 | if (odsParser.parseGreater()) return {}; |
1643 | assert(::mlir::succeeded(_result_one))(static_cast <bool> (::mlir::succeeded(_result_one)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_one)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1643, __extension__ __PRETTY_FUNCTION__)); |
1644 | assert(::mlir::succeeded(_result_two))(static_cast <bool> (::mlir::succeeded(_result_two)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_two)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1644, __extension__ __PRETTY_FUNCTION__)); |
1645 | assert(::mlir::succeeded(_result_three))(static_cast <bool> (::mlir::succeeded(_result_three)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_three)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 1645 , __extension__ __PRETTY_FUNCTION__)); |
1646 | assert(::mlir::succeeded(_result_four))(static_cast <bool> (::mlir::succeeded(_result_four)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_four)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 1646 , __extension__ __PRETTY_FUNCTION__)); |
1647 | return TestTypeNoParserType::get(odsParser.getContext(), |
1648 | uint32_t((*_result_one)), |
1649 | ::llvm::ArrayRef<int64_t>((*_result_two)), |
1650 | ::llvm::StringRef((*_result_three)), |
1651 | ::test::CustomParam((*_result_four))); |
1652 | } |
1653 | |
1654 | void TestTypeNoParserType::print(::mlir::AsmPrinter &odsPrinter) const { |
1655 | ::mlir::Builder odsBuilder(getContext()); |
1656 | odsPrinter << "<"; |
1657 | odsPrinter.printStrippedAttrOrType(getOne()); |
1658 | odsPrinter << ","; |
1659 | odsPrinter << ' ' << "["; |
1660 | odsPrinter.printStrippedAttrOrType(getTwo()); |
1661 | odsPrinter << "]"; |
1662 | odsPrinter << ","; |
1663 | odsPrinter << ' '; |
1664 | odsPrinter << '"' << getThree() << '"';; |
1665 | odsPrinter << ","; |
1666 | odsPrinter << ' '; |
1667 | odsPrinter.printStrippedAttrOrType(getFour()); |
1668 | odsPrinter << ">"; |
1669 | } |
1670 | |
1671 | uint32_t TestTypeNoParserType::getOne() const { |
1672 | return getImpl()->one; |
1673 | } |
1674 | |
1675 | ::llvm::ArrayRef<int64_t> TestTypeNoParserType::getTwo() const { |
1676 | return getImpl()->two; |
1677 | } |
1678 | |
1679 | ::llvm::StringRef TestTypeNoParserType::getThree() const { |
1680 | return getImpl()->three; |
1681 | } |
1682 | |
1683 | ::test::CustomParam TestTypeNoParserType::getFour() const { |
1684 | return getImpl()->four; |
1685 | } |
1686 | |
1687 | } // namespace test |
1688 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeNoParserType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeNoParserType>::id = {}; } } |
1689 | namespace test { |
1690 | namespace detail { |
1691 | struct TestTypeOptionalGroupTypeStorage : public ::mlir::TypeStorage { |
1692 | using KeyTy = std::tuple<int, std::optional<int>>; |
1693 | TestTypeOptionalGroupTypeStorage(int a, std::optional<int> b) : a(a), b(b) {} |
1694 | |
1695 | KeyTy getAsKey() const { |
1696 | return KeyTy(a, b); |
1697 | } |
1698 | |
1699 | bool operator==(const KeyTy &tblgenKey) const { |
1700 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1701 | } |
1702 | |
1703 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1704 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1705 | } |
1706 | |
1707 | static TestTypeOptionalGroupTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1708 | auto a = std::get<0>(tblgenKey); |
1709 | auto b = std::get<1>(tblgenKey); |
1710 | return new (allocator.allocate<TestTypeOptionalGroupTypeStorage>()) TestTypeOptionalGroupTypeStorage(a, b); |
1711 | } |
1712 | |
1713 | int a; |
1714 | std::optional<int> b; |
1715 | }; |
1716 | } // namespace detail |
1717 | TestTypeOptionalGroupType TestTypeOptionalGroupType::get(::mlir::MLIRContext *context, int a, std::optional<int> b) { |
1718 | return Base::get(context, a, b); |
1719 | } |
1720 | |
1721 | ::mlir::Type TestTypeOptionalGroupType::parse(::mlir::AsmParser &odsParser) { |
1722 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1723 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1724 | (void) odsLoc; |
1725 | ::mlir::FailureOr<int> _result_a; |
1726 | ::mlir::FailureOr<std::optional<int>> _result_b; |
1727 | // Parse literal '<' |
1728 | if (odsParser.parseLess()) return {}; |
1729 | // Parse literal '(' |
1730 | if (odsParser.parseOptionalLParen()) { |
1731 | // Parse literal 'x' |
1732 | if (odsParser.parseKeyword("x")) return {}; |
1733 | } else { |
1734 | |
1735 | // Parse variable 'b' |
1736 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1737 | if (::mlir::failed(_result_b)) { |
1738 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroup parameter 'b' which is to be a `std::optional<int>`"); |
1739 | return {}; |
1740 | } |
1741 | // Parse literal ')' |
1742 | if (odsParser.parseRParen()) return {}; |
1743 | } |
1744 | |
1745 | // Parse variable 'a' |
1746 | _result_a = ::mlir::FieldParser<int>::parse(odsParser); |
1747 | if (::mlir::failed(_result_a)) { |
1748 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroup parameter 'a' which is to be a `int`"); |
1749 | return {}; |
1750 | } |
1751 | // Parse literal '>' |
1752 | if (odsParser.parseGreater()) return {}; |
1753 | assert(::mlir::succeeded(_result_a))(static_cast <bool> (::mlir::succeeded(_result_a)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_a)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 1753, __extension__ __PRETTY_FUNCTION__)); |
1754 | return TestTypeOptionalGroupType::get(odsParser.getContext(), |
1755 | int((*_result_a)), |
1756 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
1757 | } |
1758 | |
1759 | void TestTypeOptionalGroupType::print(::mlir::AsmPrinter &odsPrinter) const { |
1760 | ::mlir::Builder odsBuilder(getContext()); |
1761 | odsPrinter << "<"; |
1762 | if (!(getB() == std::optional<int>())) { |
1763 | odsPrinter << "("; |
1764 | if (!(getB() == std::optional<int>())) { |
1765 | odsPrinter.printStrippedAttrOrType(getB()); |
1766 | } |
1767 | odsPrinter << ")"; |
1768 | } else { |
1769 | odsPrinter << "x"; |
1770 | } |
1771 | odsPrinter << ' '; |
1772 | odsPrinter.printStrippedAttrOrType(getA()); |
1773 | odsPrinter << ">"; |
1774 | } |
1775 | |
1776 | int TestTypeOptionalGroupType::getA() const { |
1777 | return getImpl()->a; |
1778 | } |
1779 | |
1780 | std::optional<int> TestTypeOptionalGroupType::getB() const { |
1781 | return getImpl()->b; |
1782 | } |
1783 | |
1784 | } // namespace test |
1785 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalGroupType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalGroupType>::id = {}; } } |
1786 | namespace test { |
1787 | namespace detail { |
1788 | struct TestTypeOptionalGroupParamsTypeStorage : public ::mlir::TypeStorage { |
1789 | using KeyTy = std::tuple<std::optional<int>, std::optional<int>>; |
1790 | TestTypeOptionalGroupParamsTypeStorage(std::optional<int> a, std::optional<int> b) : a(a), b(b) {} |
1791 | |
1792 | KeyTy getAsKey() const { |
1793 | return KeyTy(a, b); |
1794 | } |
1795 | |
1796 | bool operator==(const KeyTy &tblgenKey) const { |
1797 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1798 | } |
1799 | |
1800 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1801 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1802 | } |
1803 | |
1804 | static TestTypeOptionalGroupParamsTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1805 | auto a = std::get<0>(tblgenKey); |
1806 | auto b = std::get<1>(tblgenKey); |
1807 | return new (allocator.allocate<TestTypeOptionalGroupParamsTypeStorage>()) TestTypeOptionalGroupParamsTypeStorage(a, b); |
1808 | } |
1809 | |
1810 | std::optional<int> a; |
1811 | std::optional<int> b; |
1812 | }; |
1813 | } // namespace detail |
1814 | TestTypeOptionalGroupParamsType TestTypeOptionalGroupParamsType::get(::mlir::MLIRContext *context, std::optional<int> a, std::optional<int> b) { |
1815 | return Base::get(context, a, b); |
1816 | } |
1817 | |
1818 | ::mlir::Type TestTypeOptionalGroupParamsType::parse(::mlir::AsmParser &odsParser) { |
1819 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1820 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1821 | (void) odsLoc; |
1822 | ::mlir::FailureOr<std::optional<int>> _result_a; |
1823 | ::mlir::FailureOr<std::optional<int>> _result_b; |
1824 | // Parse literal '<' |
1825 | if (odsParser.parseLess()) return {}; |
1826 | // Parse literal '(' |
1827 | if (odsParser.parseOptionalLParen()) { |
1828 | // Parse literal 'x' |
1829 | if (odsParser.parseKeyword("x")) return {}; |
1830 | } else { |
1831 | // Parse parameter list |
1832 | do { |
1833 | |
1834 | // Parse variable 'a' |
1835 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1836 | if (::mlir::failed(_result_a)) { |
1837 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroupParams parameter 'a' which is to be a `std::optional<int>`"); |
1838 | return {}; |
1839 | } |
1840 | if (::mlir::succeeded(_result_a) && !((*_result_a) == 10)) { |
1841 | // Parse literal ',' |
1842 | if (odsParser.parseOptionalComma()) break; |
1843 | } |
1844 | |
1845 | // Parse variable 'b' |
1846 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1847 | if (::mlir::failed(_result_b)) { |
1848 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroupParams parameter 'b' which is to be a `std::optional<int>`"); |
1849 | return {}; |
1850 | } |
1851 | } while(false); |
1852 | // Parse literal ')' |
1853 | if (odsParser.parseRParen()) return {}; |
1854 | } |
1855 | // Parse literal '>' |
1856 | if (odsParser.parseGreater()) return {}; |
1857 | return TestTypeOptionalGroupParamsType::get(odsParser.getContext(), |
1858 | std::optional<int>((_result_a.value_or(10))), |
1859 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
1860 | } |
1861 | |
1862 | void TestTypeOptionalGroupParamsType::print(::mlir::AsmPrinter &odsPrinter) const { |
1863 | ::mlir::Builder odsBuilder(getContext()); |
1864 | odsPrinter << "<"; |
1865 | if (!(getA() == 10) || !(getB() == std::optional<int>())) { |
1866 | odsPrinter << "("; |
1867 | { |
1868 | bool _firstPrinted = true; |
1869 | if (!(getA() == 10)) { |
1870 | if (!_firstPrinted) odsPrinter << ", "; |
1871 | _firstPrinted = false; |
1872 | if (!(getA() == 10)) { |
1873 | odsPrinter.printStrippedAttrOrType(getA()); |
1874 | } |
1875 | } |
1876 | if (!(getB() == std::optional<int>())) { |
1877 | if (!_firstPrinted) odsPrinter << ", "; |
1878 | _firstPrinted = false; |
1879 | if (!(getB() == std::optional<int>())) { |
1880 | odsPrinter.printStrippedAttrOrType(getB()); |
1881 | } |
1882 | } |
1883 | } |
1884 | odsPrinter << ")"; |
1885 | } else { |
1886 | odsPrinter << "x"; |
1887 | } |
1888 | odsPrinter << ">"; |
1889 | } |
1890 | |
1891 | std::optional<int> TestTypeOptionalGroupParamsType::getA() const { |
1892 | return getImpl()->a; |
1893 | } |
1894 | |
1895 | std::optional<int> TestTypeOptionalGroupParamsType::getB() const { |
1896 | return getImpl()->b; |
1897 | } |
1898 | |
1899 | } // namespace test |
1900 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalGroupParamsType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalGroupParamsType>::id = {}; } } |
1901 | namespace test { |
1902 | namespace detail { |
1903 | struct TestTypeOptionalGroupStructTypeStorage : public ::mlir::TypeStorage { |
1904 | using KeyTy = std::tuple<std::optional<int>, std::optional<int>>; |
1905 | TestTypeOptionalGroupStructTypeStorage(std::optional<int> a, std::optional<int> b) : a(a), b(b) {} |
1906 | |
1907 | KeyTy getAsKey() const { |
1908 | return KeyTy(a, b); |
1909 | } |
1910 | |
1911 | bool operator==(const KeyTy &tblgenKey) const { |
1912 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
1913 | } |
1914 | |
1915 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
1916 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
1917 | } |
1918 | |
1919 | static TestTypeOptionalGroupStructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
1920 | auto a = std::get<0>(tblgenKey); |
1921 | auto b = std::get<1>(tblgenKey); |
1922 | return new (allocator.allocate<TestTypeOptionalGroupStructTypeStorage>()) TestTypeOptionalGroupStructTypeStorage(a, b); |
1923 | } |
1924 | |
1925 | std::optional<int> a; |
1926 | std::optional<int> b; |
1927 | }; |
1928 | } // namespace detail |
1929 | TestTypeOptionalGroupStructType TestTypeOptionalGroupStructType::get(::mlir::MLIRContext *context, std::optional<int> a, std::optional<int> b) { |
1930 | return Base::get(context, a, b); |
1931 | } |
1932 | |
1933 | ::mlir::Type TestTypeOptionalGroupStructType::parse(::mlir::AsmParser &odsParser) { |
1934 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
1935 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
1936 | (void) odsLoc; |
1937 | ::mlir::FailureOr<std::optional<int>> _result_a; |
1938 | ::mlir::FailureOr<std::optional<int>> _result_b; |
1939 | // Parse literal '<' |
1940 | if (odsParser.parseLess()) return {}; |
1941 | // Parse literal '(' |
1942 | if (odsParser.parseOptionalLParen()) { |
1943 | // Parse literal 'x' |
1944 | if (odsParser.parseKeyword("x")) return {}; |
1945 | } else { |
1946 | // Parse parameter struct |
1947 | bool _seen_a = false; |
1948 | bool _seen_b = false; |
1949 | { |
1950 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
1951 | // Parse literal '=' |
1952 | if (odsParser.parseEqual()) return {}; |
1953 | if (!_seen_a && _paramKey == "a") { |
1954 | _seen_a = true; |
1955 | |
1956 | // Parse variable 'a' |
1957 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1958 | if (::mlir::failed(_result_a)) { |
1959 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroupStruct parameter 'a' which is to be a `std::optional<int>`"); |
1960 | return {}; |
1961 | } |
1962 | } else if (!_seen_b && _paramKey == "b") { |
1963 | _seen_b = true; |
1964 | |
1965 | // Parse variable 'b' |
1966 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
1967 | if (::mlir::failed(_result_b)) { |
1968 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalGroupStruct parameter 'b' which is to be a `std::optional<int>`"); |
1969 | return {}; |
1970 | } |
1971 | } else { |
1972 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
1973 | return {}; |
1974 | } |
1975 | return true; |
1976 | }; |
1977 | ::llvm::StringRef _paramKey; |
1978 | if (!odsParser.parseOptionalKeyword(&_paramKey)) { |
1979 | if (!_loop_body(_paramKey)) return {}; |
1980 | while (!odsParser.parseOptionalComma()) { |
1981 | ::llvm::StringRef _paramKey; |
1982 | if (odsParser.parseKeyword(&_paramKey)) { |
1983 | odsParser.emitError(odsParser.getCurrentLocation(), |
1984 | "expected a parameter name in struct"); |
1985 | return {}; |
1986 | } |
1987 | if (!_loop_body(_paramKey)) return {}; |
1988 | } |
1989 | } |
1990 | } |
1991 | // Parse literal ')' |
1992 | if (odsParser.parseRParen()) return {}; |
1993 | } |
1994 | // Parse literal '>' |
1995 | if (odsParser.parseGreater()) return {}; |
1996 | return TestTypeOptionalGroupStructType::get(odsParser.getContext(), |
1997 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
1998 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
1999 | } |
2000 | |
2001 | void TestTypeOptionalGroupStructType::print(::mlir::AsmPrinter &odsPrinter) const { |
2002 | ::mlir::Builder odsBuilder(getContext()); |
2003 | odsPrinter << "<"; |
2004 | if (!(getA() == std::optional<int>()) || !(getB() == std::optional<int>())) { |
2005 | odsPrinter << "("; |
2006 | { |
2007 | bool _firstPrinted = true; |
2008 | if (!(getA() == std::optional<int>())) { |
2009 | if (!_firstPrinted) odsPrinter << ", "; |
2010 | _firstPrinted = false; |
2011 | odsPrinter << "a = "; |
2012 | if (!(getA() == std::optional<int>())) { |
2013 | odsPrinter.printStrippedAttrOrType(getA()); |
2014 | } |
2015 | } |
2016 | if (!(getB() == std::optional<int>())) { |
2017 | if (!_firstPrinted) odsPrinter << ", "; |
2018 | _firstPrinted = false; |
2019 | odsPrinter << "b = "; |
2020 | if (!(getB() == std::optional<int>())) { |
2021 | odsPrinter.printStrippedAttrOrType(getB()); |
2022 | } |
2023 | } |
2024 | } |
2025 | odsPrinter << ")"; |
2026 | } else { |
2027 | odsPrinter << "x"; |
2028 | } |
2029 | odsPrinter << ">"; |
2030 | } |
2031 | |
2032 | std::optional<int> TestTypeOptionalGroupStructType::getA() const { |
2033 | return getImpl()->a; |
2034 | } |
2035 | |
2036 | std::optional<int> TestTypeOptionalGroupStructType::getB() const { |
2037 | return getImpl()->b; |
2038 | } |
2039 | |
2040 | } // namespace test |
2041 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalGroupStructType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalGroupStructType>::id = {}; } } |
2042 | namespace test { |
2043 | namespace detail { |
2044 | struct TestTypeOptionalParamTypeStorage : public ::mlir::TypeStorage { |
2045 | using KeyTy = std::tuple<std::optional<int>, int, std::optional<::mlir::Attribute>>; |
2046 | TestTypeOptionalParamTypeStorage(std::optional<int> a, int b, std::optional<::mlir::Attribute> c) : a(a), b(b), c(c) {} |
2047 | |
2048 | KeyTy getAsKey() const { |
2049 | return KeyTy(a, b, c); |
2050 | } |
2051 | |
2052 | bool operator==(const KeyTy &tblgenKey) const { |
2053 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)) && (c == std::get<2>(tblgenKey)); |
2054 | } |
2055 | |
2056 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2057 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); |
2058 | } |
2059 | |
2060 | static TestTypeOptionalParamTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2061 | auto a = std::get<0>(tblgenKey); |
2062 | auto b = std::get<1>(tblgenKey); |
2063 | auto c = std::get<2>(tblgenKey); |
2064 | return new (allocator.allocate<TestTypeOptionalParamTypeStorage>()) TestTypeOptionalParamTypeStorage(a, b, c); |
2065 | } |
2066 | |
2067 | std::optional<int> a; |
2068 | int b; |
2069 | std::optional<::mlir::Attribute> c; |
2070 | }; |
2071 | } // namespace detail |
2072 | TestTypeOptionalParamType TestTypeOptionalParamType::get(::mlir::MLIRContext *context, std::optional<int> a, int b, std::optional<::mlir::Attribute> c) { |
2073 | return Base::get(context, a, b, c); |
2074 | } |
2075 | |
2076 | ::mlir::Type TestTypeOptionalParamType::parse(::mlir::AsmParser &odsParser) { |
2077 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2078 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2079 | (void) odsLoc; |
2080 | ::mlir::FailureOr<std::optional<int>> _result_a; |
2081 | ::mlir::FailureOr<int> _result_b; |
2082 | ::mlir::FailureOr<std::optional<::mlir::Attribute>> _result_c; |
2083 | // Parse literal '<' |
2084 | if (odsParser.parseLess()) return {}; |
2085 | |
2086 | // Parse variable 'a' |
2087 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
2088 | if (::mlir::failed(_result_a)) { |
2089 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParam parameter 'a' which is to be a `std::optional<int>`"); |
2090 | return {}; |
2091 | } |
2092 | // Parse literal ',' |
2093 | if (odsParser.parseComma()) return {}; |
2094 | |
2095 | // Parse variable 'b' |
2096 | _result_b = ::mlir::FieldParser<int>::parse(odsParser); |
2097 | if (::mlir::failed(_result_b)) { |
2098 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParam parameter 'b' which is to be a `int`"); |
2099 | return {}; |
2100 | } |
2101 | // Parse literal ',' |
2102 | if (odsParser.parseOptionalComma()) { |
2103 | } else { |
2104 | |
2105 | // Parse variable 'c' |
2106 | _result_c = ::mlir::FieldParser<std::optional<::mlir::Attribute>>::parse(odsParser); |
2107 | if (::mlir::failed(_result_c)) { |
2108 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParam parameter 'c' which is to be a `std::optional<::mlir::Attribute>`"); |
2109 | return {}; |
2110 | } |
2111 | } |
2112 | // Parse literal '>' |
2113 | if (odsParser.parseGreater()) return {}; |
2114 | assert(::mlir::succeeded(_result_b))(static_cast <bool> (::mlir::succeeded(_result_b)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_b)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2114, __extension__ __PRETTY_FUNCTION__)); |
2115 | return TestTypeOptionalParamType::get(odsParser.getContext(), |
2116 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
2117 | int((*_result_b)), |
2118 | std::optional<::mlir::Attribute>((_result_c.value_or(std::nullopt)))); |
2119 | } |
2120 | |
2121 | void TestTypeOptionalParamType::print(::mlir::AsmPrinter &odsPrinter) const { |
2122 | ::mlir::Builder odsBuilder(getContext()); |
2123 | odsPrinter << "<"; |
2124 | if (!(getA() == std::optional<int>())) { |
2125 | odsPrinter.printStrippedAttrOrType(getA()); |
2126 | } |
2127 | odsPrinter << ","; |
2128 | odsPrinter << ' '; |
2129 | odsPrinter.printStrippedAttrOrType(getB()); |
2130 | if (!(getC() == std::nullopt)) { |
2131 | odsPrinter << ","; |
2132 | if (!(getC() == std::nullopt)) { |
2133 | odsPrinter << ' '; |
2134 | odsPrinter.printStrippedAttrOrType(getC()); |
2135 | } |
2136 | } else { |
2137 | } |
2138 | odsPrinter << ">"; |
2139 | } |
2140 | |
2141 | std::optional<int> TestTypeOptionalParamType::getA() const { |
2142 | return getImpl()->a; |
2143 | } |
2144 | |
2145 | int TestTypeOptionalParamType::getB() const { |
2146 | return getImpl()->b; |
2147 | } |
2148 | |
2149 | std::optional<::mlir::Attribute> TestTypeOptionalParamType::getC() const { |
2150 | return getImpl()->c; |
2151 | } |
2152 | |
2153 | } // namespace test |
2154 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalParamType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalParamType>::id = {}; } } |
2155 | namespace test { |
2156 | namespace detail { |
2157 | struct TestTypeOptionalParamsTypeStorage : public ::mlir::TypeStorage { |
2158 | using KeyTy = std::tuple<std::optional<int>, ::llvm::StringRef>; |
2159 | TestTypeOptionalParamsTypeStorage(std::optional<int> a, ::llvm::StringRef b) : a(a), b(b) {} |
2160 | |
2161 | KeyTy getAsKey() const { |
2162 | return KeyTy(a, b); |
2163 | } |
2164 | |
2165 | bool operator==(const KeyTy &tblgenKey) const { |
2166 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
2167 | } |
2168 | |
2169 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2170 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
2171 | } |
2172 | |
2173 | static TestTypeOptionalParamsTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2174 | auto a = std::get<0>(tblgenKey); |
2175 | auto b = std::get<1>(tblgenKey); |
2176 | b = allocator.copyInto(b); |
2177 | return new (allocator.allocate<TestTypeOptionalParamsTypeStorage>()) TestTypeOptionalParamsTypeStorage(a, b); |
2178 | } |
2179 | |
2180 | std::optional<int> a; |
2181 | ::llvm::StringRef b; |
2182 | }; |
2183 | } // namespace detail |
2184 | TestTypeOptionalParamsType TestTypeOptionalParamsType::get(::mlir::MLIRContext *context, std::optional<int> a, ::llvm::StringRef b) { |
2185 | return Base::get(context, a, b); |
2186 | } |
2187 | |
2188 | ::mlir::Type TestTypeOptionalParamsType::parse(::mlir::AsmParser &odsParser) { |
2189 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2190 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2191 | (void) odsLoc; |
2192 | ::mlir::FailureOr<std::optional<int>> _result_a; |
2193 | ::mlir::FailureOr<std::string> _result_b; |
2194 | // Parse literal '<' |
2195 | if (odsParser.parseLess()) return {}; |
2196 | // Parse parameter list |
2197 | do { |
2198 | |
2199 | // Parse variable 'a' |
2200 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
2201 | if (::mlir::failed(_result_a)) { |
2202 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParams parameter 'a' which is to be a `std::optional<int>`"); |
2203 | return {}; |
2204 | } |
2205 | if (::mlir::succeeded(_result_a) && !((*_result_a) == std::optional<int>())) { |
2206 | // Parse literal ',' |
2207 | if (odsParser.parseComma()) return {}; |
2208 | } |
2209 | |
2210 | // Parse variable 'b' |
2211 | _result_b = ::mlir::FieldParser<std::string>::parse(odsParser); |
2212 | if (::mlir::failed(_result_b)) { |
2213 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParams parameter 'b' which is to be a `::llvm::StringRef`"); |
2214 | return {}; |
2215 | } |
2216 | } while(false); |
2217 | // Parse literal '>' |
2218 | if (odsParser.parseGreater()) return {}; |
2219 | assert(::mlir::succeeded(_result_b))(static_cast <bool> (::mlir::succeeded(_result_b)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_b)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2219, __extension__ __PRETTY_FUNCTION__)); |
2220 | return TestTypeOptionalParamsType::get(odsParser.getContext(), |
2221 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
2222 | ::llvm::StringRef((*_result_b))); |
2223 | } |
2224 | |
2225 | void TestTypeOptionalParamsType::print(::mlir::AsmPrinter &odsPrinter) const { |
2226 | ::mlir::Builder odsBuilder(getContext()); |
2227 | odsPrinter << "<"; |
2228 | { |
2229 | bool _firstPrinted = true; |
2230 | if (!(getA() == std::optional<int>())) { |
2231 | if (!_firstPrinted) odsPrinter << ", "; |
2232 | _firstPrinted = false; |
2233 | if (!(getA() == std::optional<int>())) { |
2234 | odsPrinter.printStrippedAttrOrType(getA()); |
2235 | } |
2236 | } |
2237 | if (!_firstPrinted) odsPrinter << ", "; |
2238 | _firstPrinted = false; |
2239 | odsPrinter << '"' << getB() << '"';; |
2240 | } |
2241 | odsPrinter << ">"; |
2242 | } |
2243 | |
2244 | std::optional<int> TestTypeOptionalParamsType::getA() const { |
2245 | return getImpl()->a; |
2246 | } |
2247 | |
2248 | ::llvm::StringRef TestTypeOptionalParamsType::getB() const { |
2249 | return getImpl()->b; |
2250 | } |
2251 | |
2252 | } // namespace test |
2253 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalParamsType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalParamsType>::id = {}; } } |
2254 | namespace test { |
2255 | namespace detail { |
2256 | struct TestTypeOptionalParamsAfterRequiredTypeStorage : public ::mlir::TypeStorage { |
2257 | using KeyTy = std::tuple<::llvm::StringRef, std::optional<int>>; |
2258 | TestTypeOptionalParamsAfterRequiredTypeStorage(::llvm::StringRef a, std::optional<int> b) : a(a), b(b) {} |
2259 | |
2260 | KeyTy getAsKey() const { |
2261 | return KeyTy(a, b); |
2262 | } |
2263 | |
2264 | bool operator==(const KeyTy &tblgenKey) const { |
2265 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
2266 | } |
2267 | |
2268 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2269 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
2270 | } |
2271 | |
2272 | static TestTypeOptionalParamsAfterRequiredTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2273 | auto a = std::get<0>(tblgenKey); |
2274 | auto b = std::get<1>(tblgenKey); |
2275 | a = allocator.copyInto(a); |
2276 | return new (allocator.allocate<TestTypeOptionalParamsAfterRequiredTypeStorage>()) TestTypeOptionalParamsAfterRequiredTypeStorage(a, b); |
2277 | } |
2278 | |
2279 | ::llvm::StringRef a; |
2280 | std::optional<int> b; |
2281 | }; |
2282 | } // namespace detail |
2283 | TestTypeOptionalParamsAfterRequiredType TestTypeOptionalParamsAfterRequiredType::get(::mlir::MLIRContext *context, ::llvm::StringRef a, std::optional<int> b) { |
2284 | return Base::get(context, a, b); |
2285 | } |
2286 | |
2287 | ::mlir::Type TestTypeOptionalParamsAfterRequiredType::parse(::mlir::AsmParser &odsParser) { |
2288 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2289 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2290 | (void) odsLoc; |
2291 | ::mlir::FailureOr<std::string> _result_a; |
2292 | ::mlir::FailureOr<std::optional<int>> _result_b; |
2293 | // Parse literal '<' |
2294 | if (odsParser.parseLess()) return {}; |
2295 | // Parse parameter list |
2296 | do { |
2297 | |
2298 | // Parse variable 'a' |
2299 | _result_a = ::mlir::FieldParser<std::string>::parse(odsParser); |
2300 | if (::mlir::failed(_result_a)) { |
2301 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParamsAfterRequired parameter 'a' which is to be a `::llvm::StringRef`"); |
2302 | return {}; |
2303 | } |
2304 | // Parse literal ',' |
2305 | if (odsParser.parseOptionalComma()) break; |
2306 | |
2307 | // Parse variable 'b' |
2308 | _result_b = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
2309 | if (::mlir::failed(_result_b)) { |
2310 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalParamsAfterRequired parameter 'b' which is to be a `std::optional<int>`"); |
2311 | return {}; |
2312 | } |
2313 | } while(false); |
2314 | // Parse literal '>' |
2315 | if (odsParser.parseGreater()) return {}; |
2316 | assert(::mlir::succeeded(_result_a))(static_cast <bool> (::mlir::succeeded(_result_a)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_a)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2316, __extension__ __PRETTY_FUNCTION__)); |
2317 | return TestTypeOptionalParamsAfterRequiredType::get(odsParser.getContext(), |
2318 | ::llvm::StringRef((*_result_a)), |
2319 | std::optional<int>((_result_b.value_or(std::optional<int>())))); |
2320 | } |
2321 | |
2322 | void TestTypeOptionalParamsAfterRequiredType::print(::mlir::AsmPrinter &odsPrinter) const { |
2323 | ::mlir::Builder odsBuilder(getContext()); |
2324 | odsPrinter << "<"; |
2325 | { |
2326 | bool _firstPrinted = true; |
2327 | if (!_firstPrinted) odsPrinter << ", "; |
2328 | _firstPrinted = false; |
2329 | odsPrinter << '"' << getA() << '"';; |
2330 | if (!(getB() == std::optional<int>())) { |
2331 | if (!_firstPrinted) odsPrinter << ", "; |
2332 | _firstPrinted = false; |
2333 | if (!(getB() == std::optional<int>())) { |
2334 | odsPrinter.printStrippedAttrOrType(getB()); |
2335 | } |
2336 | } |
2337 | } |
2338 | odsPrinter << ">"; |
2339 | } |
2340 | |
2341 | ::llvm::StringRef TestTypeOptionalParamsAfterRequiredType::getA() const { |
2342 | return getImpl()->a; |
2343 | } |
2344 | |
2345 | std::optional<int> TestTypeOptionalParamsAfterRequiredType::getB() const { |
2346 | return getImpl()->b; |
2347 | } |
2348 | |
2349 | } // namespace test |
2350 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalParamsAfterRequiredType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalParamsAfterRequiredType>::id = {}; } } |
2351 | namespace test { |
2352 | namespace detail { |
2353 | struct TestTypeOptionalStructTypeStorage : public ::mlir::TypeStorage { |
2354 | using KeyTy = std::tuple<std::optional<int>, ::llvm::StringRef>; |
2355 | TestTypeOptionalStructTypeStorage(std::optional<int> a, ::llvm::StringRef b) : a(a), b(b) {} |
2356 | |
2357 | KeyTy getAsKey() const { |
2358 | return KeyTy(a, b); |
2359 | } |
2360 | |
2361 | bool operator==(const KeyTy &tblgenKey) const { |
2362 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
2363 | } |
2364 | |
2365 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2366 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
2367 | } |
2368 | |
2369 | static TestTypeOptionalStructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2370 | auto a = std::get<0>(tblgenKey); |
2371 | auto b = std::get<1>(tblgenKey); |
2372 | b = allocator.copyInto(b); |
2373 | return new (allocator.allocate<TestTypeOptionalStructTypeStorage>()) TestTypeOptionalStructTypeStorage(a, b); |
2374 | } |
2375 | |
2376 | std::optional<int> a; |
2377 | ::llvm::StringRef b; |
2378 | }; |
2379 | } // namespace detail |
2380 | TestTypeOptionalStructType TestTypeOptionalStructType::get(::mlir::MLIRContext *context, std::optional<int> a, ::llvm::StringRef b) { |
2381 | return Base::get(context, a, b); |
2382 | } |
2383 | |
2384 | ::mlir::Type TestTypeOptionalStructType::parse(::mlir::AsmParser &odsParser) { |
2385 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2386 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2387 | (void) odsLoc; |
2388 | ::mlir::FailureOr<std::optional<int>> _result_a; |
2389 | ::mlir::FailureOr<std::string> _result_b; |
2390 | // Parse literal '<' |
2391 | if (odsParser.parseLess()) return {}; |
2392 | // Parse parameter struct |
2393 | bool _seen_a = false; |
2394 | bool _seen_b = false; |
2395 | { |
2396 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
2397 | // Parse literal '=' |
2398 | if (odsParser.parseEqual()) return {}; |
2399 | if (!_seen_a && _paramKey == "a") { |
2400 | _seen_a = true; |
2401 | |
2402 | // Parse variable 'a' |
2403 | _result_a = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
2404 | if (::mlir::failed(_result_a)) { |
2405 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalStruct parameter 'a' which is to be a `std::optional<int>`"); |
2406 | return {}; |
2407 | } |
2408 | } else if (!_seen_b && _paramKey == "b") { |
2409 | _seen_b = true; |
2410 | |
2411 | // Parse variable 'b' |
2412 | _result_b = ::mlir::FieldParser<std::string>::parse(odsParser); |
2413 | if (::mlir::failed(_result_b)) { |
2414 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalStruct parameter 'b' which is to be a `::llvm::StringRef`"); |
2415 | return {}; |
2416 | } |
2417 | } else { |
2418 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
2419 | return {}; |
2420 | } |
2421 | return true; |
2422 | }; |
2423 | do { |
2424 | ::llvm::StringRef _paramKey; |
2425 | if (odsParser.parseKeyword(&_paramKey)) { |
2426 | odsParser.emitError(odsParser.getCurrentLocation(), |
2427 | "expected a parameter name in struct"); |
2428 | return {}; |
2429 | } |
2430 | if (!_loop_body(_paramKey)) return {}; |
2431 | } while(!odsParser.parseOptionalComma()); |
2432 | if (!_seen_b) { |
2433 | odsParser.emitError(odsParser.getCurrentLocation(), "struct is missing required parameter: ") << "b"; |
2434 | return {}; |
2435 | } |
2436 | } |
2437 | // Parse literal '>' |
2438 | if (odsParser.parseGreater()) return {}; |
2439 | assert(::mlir::succeeded(_result_b))(static_cast <bool> (::mlir::succeeded(_result_b)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_b)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2439, __extension__ __PRETTY_FUNCTION__)); |
2440 | return TestTypeOptionalStructType::get(odsParser.getContext(), |
2441 | std::optional<int>((_result_a.value_or(std::optional<int>()))), |
2442 | ::llvm::StringRef((*_result_b))); |
2443 | } |
2444 | |
2445 | void TestTypeOptionalStructType::print(::mlir::AsmPrinter &odsPrinter) const { |
2446 | ::mlir::Builder odsBuilder(getContext()); |
2447 | odsPrinter << "<"; |
2448 | { |
2449 | bool _firstPrinted = true; |
2450 | if (!(getA() == std::optional<int>())) { |
2451 | if (!_firstPrinted) odsPrinter << ", "; |
2452 | _firstPrinted = false; |
2453 | odsPrinter << "a = "; |
2454 | if (!(getA() == std::optional<int>())) { |
2455 | odsPrinter.printStrippedAttrOrType(getA()); |
2456 | } |
2457 | } |
2458 | if (!_firstPrinted) odsPrinter << ", "; |
2459 | _firstPrinted = false; |
2460 | odsPrinter << "b = "; |
2461 | odsPrinter << '"' << getB() << '"';; |
2462 | } |
2463 | odsPrinter << ">"; |
2464 | } |
2465 | |
2466 | std::optional<int> TestTypeOptionalStructType::getA() const { |
2467 | return getImpl()->a; |
2468 | } |
2469 | |
2470 | ::llvm::StringRef TestTypeOptionalStructType::getB() const { |
2471 | return getImpl()->b; |
2472 | } |
2473 | |
2474 | } // namespace test |
2475 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalStructType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalStructType>::id = {}; } } |
2476 | namespace test { |
2477 | namespace detail { |
2478 | struct TestTypeOptionalValueTypeTypeStorage : public ::mlir::TypeStorage { |
2479 | using KeyTy = std::tuple<std::optional<int>>; |
2480 | TestTypeOptionalValueTypeTypeStorage(std::optional<int> value) : value(value) {} |
2481 | |
2482 | KeyTy getAsKey() const { |
2483 | return KeyTy(value); |
2484 | } |
2485 | |
2486 | bool operator==(const KeyTy &tblgenKey) const { |
2487 | return (value == std::get<0>(tblgenKey)); |
2488 | } |
2489 | |
2490 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2491 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
2492 | } |
2493 | |
2494 | static TestTypeOptionalValueTypeTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2495 | auto value = std::get<0>(tblgenKey); |
2496 | return new (allocator.allocate<TestTypeOptionalValueTypeTypeStorage>()) TestTypeOptionalValueTypeTypeStorage(value); |
2497 | } |
2498 | |
2499 | std::optional<int> value; |
2500 | }; |
2501 | } // namespace detail |
2502 | TestTypeOptionalValueTypeType TestTypeOptionalValueTypeType::get(::mlir::MLIRContext *context, std::optional<int> value) { |
2503 | return Base::get(context, value); |
2504 | } |
2505 | |
2506 | ::mlir::Type TestTypeOptionalValueTypeType::parse(::mlir::AsmParser &odsParser) { |
2507 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2508 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2509 | (void) odsLoc; |
2510 | ::mlir::FailureOr<std::optional<int>> _result_value; |
2511 | // Parse literal '<' |
2512 | if (odsParser.parseOptionalLess()) { |
2513 | } else { |
2514 | |
2515 | // Parse variable 'value' |
2516 | _result_value = ::mlir::FieldParser<std::optional<int>>::parse(odsParser); |
2517 | if (::mlir::failed(_result_value)) { |
2518 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeOptionalValueType parameter 'value' which is to be a `std::optional<int>`"); |
2519 | return {}; |
2520 | } |
2521 | // Parse literal '>' |
2522 | if (odsParser.parseGreater()) return {}; |
2523 | } |
2524 | return TestTypeOptionalValueTypeType::get(odsParser.getContext(), |
2525 | std::optional<int>((_result_value.value_or(std::optional<int>())))); |
2526 | } |
2527 | |
2528 | void TestTypeOptionalValueTypeType::print(::mlir::AsmPrinter &odsPrinter) const { |
2529 | ::mlir::Builder odsBuilder(getContext()); |
2530 | if (!(getValue() == std::optional<int>())) { |
2531 | odsPrinter << "<"; |
2532 | if (!(getValue() == std::optional<int>())) { |
2533 | odsPrinter.printStrippedAttrOrType(getValue()); |
2534 | } |
2535 | odsPrinter << ">"; |
2536 | } else { |
2537 | } |
2538 | } |
2539 | |
2540 | std::optional<int> TestTypeOptionalValueTypeType::getValue() const { |
2541 | return getImpl()->value; |
2542 | } |
2543 | |
2544 | } // namespace test |
2545 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeOptionalValueTypeType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeOptionalValueTypeType>::id = {}; } } |
2546 | namespace test { |
2547 | namespace detail { |
2548 | struct TestTypeSpaceSTypeStorage : public ::mlir::TypeStorage { |
2549 | using KeyTy = std::tuple<int, int>; |
2550 | TestTypeSpaceSTypeStorage(int a, int b) : a(a), b(b) {} |
2551 | |
2552 | KeyTy getAsKey() const { |
2553 | return KeyTy(a, b); |
2554 | } |
2555 | |
2556 | bool operator==(const KeyTy &tblgenKey) const { |
2557 | return (a == std::get<0>(tblgenKey)) && (b == std::get<1>(tblgenKey)); |
2558 | } |
2559 | |
2560 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2561 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); |
2562 | } |
2563 | |
2564 | static TestTypeSpaceSTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2565 | auto a = std::get<0>(tblgenKey); |
2566 | auto b = std::get<1>(tblgenKey); |
2567 | return new (allocator.allocate<TestTypeSpaceSTypeStorage>()) TestTypeSpaceSTypeStorage(a, b); |
2568 | } |
2569 | |
2570 | int a; |
2571 | int b; |
2572 | }; |
2573 | } // namespace detail |
2574 | TestTypeSpaceSType TestTypeSpaceSType::get(::mlir::MLIRContext *context, int a, int b) { |
2575 | return Base::get(context, a, b); |
2576 | } |
2577 | |
2578 | ::mlir::Type TestTypeSpaceSType::parse(::mlir::AsmParser &odsParser) { |
2579 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2580 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2581 | (void) odsLoc; |
2582 | ::mlir::FailureOr<int> _result_a; |
2583 | ::mlir::FailureOr<int> _result_b; |
2584 | // Parse literal '<' |
2585 | if (odsParser.parseLess()) return {}; |
2586 | |
2587 | // Parse variable 'a' |
2588 | _result_a = ::mlir::FieldParser<int>::parse(odsParser); |
2589 | if (::mlir::failed(_result_a)) { |
2590 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeSpaces parameter 'a' which is to be a `int`"); |
2591 | return {}; |
2592 | } |
2593 | // Parse literal '(' |
2594 | if (odsParser.parseLParen()) return {}; |
2595 | // Parse literal ')' |
2596 | if (odsParser.parseRParen()) return {}; |
2597 | // Parse literal '(' |
2598 | if (odsParser.parseLParen()) return {}; |
2599 | // Parse literal ')' |
2600 | if (odsParser.parseRParen()) return {}; |
2601 | |
2602 | // Parse variable 'b' |
2603 | _result_b = ::mlir::FieldParser<int>::parse(odsParser); |
2604 | if (::mlir::failed(_result_b)) { |
2605 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeSpaces parameter 'b' which is to be a `int`"); |
2606 | return {}; |
2607 | } |
2608 | // Parse literal '>' |
2609 | if (odsParser.parseGreater()) return {}; |
2610 | assert(::mlir::succeeded(_result_a))(static_cast <bool> (::mlir::succeeded(_result_a)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_a)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2610, __extension__ __PRETTY_FUNCTION__)); |
2611 | assert(::mlir::succeeded(_result_b))(static_cast <bool> (::mlir::succeeded(_result_b)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_b)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2611, __extension__ __PRETTY_FUNCTION__)); |
2612 | return TestTypeSpaceSType::get(odsParser.getContext(), |
2613 | int((*_result_a)), |
2614 | int((*_result_b))); |
2615 | } |
2616 | |
2617 | void TestTypeSpaceSType::print(::mlir::AsmPrinter &odsPrinter) const { |
2618 | ::mlir::Builder odsBuilder(getContext()); |
2619 | odsPrinter << "<"; |
2620 | odsPrinter << " "; |
2621 | odsPrinter.printStrippedAttrOrType(getA()); |
2622 | odsPrinter << '\n'; |
2623 | odsPrinter << "("; |
2624 | odsPrinter << ")"; |
2625 | odsPrinter << "("; |
2626 | odsPrinter << ")"; |
2627 | odsPrinter << ' '; |
2628 | odsPrinter.printStrippedAttrOrType(getB()); |
2629 | odsPrinter << ">"; |
2630 | } |
2631 | |
2632 | int TestTypeSpaceSType::getA() const { |
2633 | return getImpl()->a; |
2634 | } |
2635 | |
2636 | int TestTypeSpaceSType::getB() const { |
2637 | return getImpl()->b; |
2638 | } |
2639 | |
2640 | } // namespace test |
2641 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeSpaceSType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeSpaceSType>::id = {}; } } |
2642 | namespace test { |
2643 | namespace detail { |
2644 | struct TestStructTypeCaptureAllTypeStorage : public ::mlir::TypeStorage { |
2645 | using KeyTy = std::tuple<int, int, int, int>; |
2646 | TestStructTypeCaptureAllTypeStorage(int v0, int v1, int v2, int v3) : v0(v0), v1(v1), v2(v2), v3(v3) {} |
2647 | |
2648 | KeyTy getAsKey() const { |
2649 | return KeyTy(v0, v1, v2, v3); |
2650 | } |
2651 | |
2652 | bool operator==(const KeyTy &tblgenKey) const { |
2653 | return (v0 == std::get<0>(tblgenKey)) && (v1 == std::get<1>(tblgenKey)) && (v2 == std::get<2>(tblgenKey)) && (v3 == std::get<3>(tblgenKey)); |
2654 | } |
2655 | |
2656 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2657 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey)); |
2658 | } |
2659 | |
2660 | static TestStructTypeCaptureAllTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2661 | auto v0 = std::get<0>(tblgenKey); |
2662 | auto v1 = std::get<1>(tblgenKey); |
2663 | auto v2 = std::get<2>(tblgenKey); |
2664 | auto v3 = std::get<3>(tblgenKey); |
2665 | return new (allocator.allocate<TestStructTypeCaptureAllTypeStorage>()) TestStructTypeCaptureAllTypeStorage(v0, v1, v2, v3); |
2666 | } |
2667 | |
2668 | int v0; |
2669 | int v1; |
2670 | int v2; |
2671 | int v3; |
2672 | }; |
2673 | } // namespace detail |
2674 | TestStructTypeCaptureAllType TestStructTypeCaptureAllType::get(::mlir::MLIRContext *context, int v0, int v1, int v2, int v3) { |
2675 | return Base::get(context, v0, v1, v2, v3); |
2676 | } |
2677 | |
2678 | ::mlir::Type TestStructTypeCaptureAllType::parse(::mlir::AsmParser &odsParser) { |
2679 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2680 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2681 | (void) odsLoc; |
2682 | ::mlir::FailureOr<int> _result_v0; |
2683 | ::mlir::FailureOr<int> _result_v1; |
2684 | ::mlir::FailureOr<int> _result_v2; |
2685 | ::mlir::FailureOr<int> _result_v3; |
2686 | // Parse literal '<' |
2687 | if (odsParser.parseLess()) return {}; |
2688 | // Parse parameter struct |
2689 | bool _seen_v0 = false; |
2690 | bool _seen_v1 = false; |
2691 | bool _seen_v2 = false; |
2692 | bool _seen_v3 = false; |
2693 | { |
2694 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
2695 | // Parse literal '=' |
2696 | if (odsParser.parseEqual()) return {}; |
2697 | if (!_seen_v0 && _paramKey == "v0") { |
2698 | _seen_v0 = true; |
2699 | |
2700 | // Parse variable 'v0' |
2701 | _result_v0 = ::mlir::FieldParser<int>::parse(odsParser); |
2702 | if (::mlir::failed(_result_v0)) { |
2703 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeStructCaptureAll parameter 'v0' which is to be a `int`"); |
2704 | return {}; |
2705 | } |
2706 | } else if (!_seen_v1 && _paramKey == "v1") { |
2707 | _seen_v1 = true; |
2708 | |
2709 | // Parse variable 'v1' |
2710 | _result_v1 = ::mlir::FieldParser<int>::parse(odsParser); |
2711 | if (::mlir::failed(_result_v1)) { |
2712 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeStructCaptureAll parameter 'v1' which is to be a `int`"); |
2713 | return {}; |
2714 | } |
2715 | } else if (!_seen_v2 && _paramKey == "v2") { |
2716 | _seen_v2 = true; |
2717 | |
2718 | // Parse variable 'v2' |
2719 | _result_v2 = ::mlir::FieldParser<int>::parse(odsParser); |
2720 | if (::mlir::failed(_result_v2)) { |
2721 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeStructCaptureAll parameter 'v2' which is to be a `int`"); |
2722 | return {}; |
2723 | } |
2724 | } else if (!_seen_v3 && _paramKey == "v3") { |
2725 | _seen_v3 = true; |
2726 | |
2727 | // Parse variable 'v3' |
2728 | _result_v3 = ::mlir::FieldParser<int>::parse(odsParser); |
2729 | if (::mlir::failed(_result_v3)) { |
2730 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeStructCaptureAll parameter 'v3' which is to be a `int`"); |
2731 | return {}; |
2732 | } |
2733 | } else { |
2734 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
2735 | return {}; |
2736 | } |
2737 | return true; |
2738 | }; |
2739 | for (unsigned odsStructIndex = 0; odsStructIndex < 4; ++odsStructIndex) { |
2740 | ::llvm::StringRef _paramKey; |
2741 | if (odsParser.parseKeyword(&_paramKey)) { |
2742 | odsParser.emitError(odsParser.getCurrentLocation(), |
2743 | "expected a parameter name in struct"); |
2744 | return {}; |
2745 | } |
2746 | if (!_loop_body(_paramKey)) return {}; |
2747 | if ((odsStructIndex != 4 - 1) && odsParser.parseComma()) |
2748 | return {}; |
2749 | } |
2750 | } |
2751 | // Parse literal '>' |
2752 | if (odsParser.parseGreater()) return {}; |
2753 | assert(::mlir::succeeded(_result_v0))(static_cast <bool> (::mlir::succeeded(_result_v0)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_v0)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2753, __extension__ __PRETTY_FUNCTION__)); |
2754 | assert(::mlir::succeeded(_result_v1))(static_cast <bool> (::mlir::succeeded(_result_v1)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_v1)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2754, __extension__ __PRETTY_FUNCTION__)); |
2755 | assert(::mlir::succeeded(_result_v2))(static_cast <bool> (::mlir::succeeded(_result_v2)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_v2)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2755, __extension__ __PRETTY_FUNCTION__)); |
2756 | assert(::mlir::succeeded(_result_v3))(static_cast <bool> (::mlir::succeeded(_result_v3)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_v3)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2756, __extension__ __PRETTY_FUNCTION__)); |
2757 | return TestStructTypeCaptureAllType::get(odsParser.getContext(), |
2758 | int((*_result_v0)), |
2759 | int((*_result_v1)), |
2760 | int((*_result_v2)), |
2761 | int((*_result_v3))); |
2762 | } |
2763 | |
2764 | void TestStructTypeCaptureAllType::print(::mlir::AsmPrinter &odsPrinter) const { |
2765 | ::mlir::Builder odsBuilder(getContext()); |
2766 | odsPrinter << "<"; |
2767 | { |
2768 | bool _firstPrinted = true; |
2769 | if (!_firstPrinted) odsPrinter << ", "; |
2770 | _firstPrinted = false; |
2771 | odsPrinter << "v0 = "; |
2772 | odsPrinter.printStrippedAttrOrType(getV0()); |
2773 | if (!_firstPrinted) odsPrinter << ", "; |
2774 | _firstPrinted = false; |
2775 | odsPrinter << "v1 = "; |
2776 | odsPrinter.printStrippedAttrOrType(getV1()); |
2777 | if (!_firstPrinted) odsPrinter << ", "; |
2778 | _firstPrinted = false; |
2779 | odsPrinter << "v2 = "; |
2780 | odsPrinter.printStrippedAttrOrType(getV2()); |
2781 | if (!_firstPrinted) odsPrinter << ", "; |
2782 | _firstPrinted = false; |
Value stored to '_firstPrinted' is never read | |
2783 | odsPrinter << "v3 = "; |
2784 | odsPrinter.printStrippedAttrOrType(getV3()); |
2785 | } |
2786 | odsPrinter << ">"; |
2787 | } |
2788 | |
2789 | int TestStructTypeCaptureAllType::getV0() const { |
2790 | return getImpl()->v0; |
2791 | } |
2792 | |
2793 | int TestStructTypeCaptureAllType::getV1() const { |
2794 | return getImpl()->v1; |
2795 | } |
2796 | |
2797 | int TestStructTypeCaptureAllType::getV2() const { |
2798 | return getImpl()->v2; |
2799 | } |
2800 | |
2801 | int TestStructTypeCaptureAllType::getV3() const { |
2802 | return getImpl()->v3; |
2803 | } |
2804 | |
2805 | } // namespace test |
2806 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestStructTypeCaptureAllType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestStructTypeCaptureAllType>::id = {}; } } |
2807 | namespace test { |
2808 | namespace detail { |
2809 | struct TestTypeWithFormatTypeStorage : public ::mlir::TypeStorage { |
2810 | using KeyTy = std::tuple<int64_t, std::string, ::mlir::Attribute>; |
2811 | TestTypeWithFormatTypeStorage(int64_t one, std::string two, ::mlir::Attribute three) : one(one), two(two), three(three) {} |
2812 | |
2813 | KeyTy getAsKey() const { |
2814 | return KeyTy(one, two, three); |
2815 | } |
2816 | |
2817 | bool operator==(const KeyTy &tblgenKey) const { |
2818 | return (one == std::get<0>(tblgenKey)) && (two == std::get<1>(tblgenKey)) && (three == std::get<2>(tblgenKey)); |
2819 | } |
2820 | |
2821 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2822 | return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); |
2823 | } |
2824 | |
2825 | static TestTypeWithFormatTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2826 | auto one = std::get<0>(tblgenKey); |
2827 | auto two = std::get<1>(tblgenKey); |
2828 | auto three = std::get<2>(tblgenKey); |
2829 | return new (allocator.allocate<TestTypeWithFormatTypeStorage>()) TestTypeWithFormatTypeStorage(one, two, three); |
2830 | } |
2831 | |
2832 | int64_t one; |
2833 | std::string two; |
2834 | ::mlir::Attribute three; |
2835 | }; |
2836 | } // namespace detail |
2837 | TestTypeWithFormatType TestTypeWithFormatType::get(::mlir::MLIRContext *context, int64_t one, std::string two, ::mlir::Attribute three) { |
2838 | return Base::get(context, one, two, three); |
2839 | } |
2840 | |
2841 | ::mlir::Type TestTypeWithFormatType::parse(::mlir::AsmParser &odsParser) { |
2842 | ::mlir::Builder odsBuilder(odsParser.getContext()); |
2843 | ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); |
2844 | (void) odsLoc; |
2845 | ::mlir::FailureOr<int64_t> _result_one; |
2846 | ::mlir::FailureOr<std::string> _result_two; |
2847 | ::mlir::FailureOr<::mlir::Attribute> _result_three; |
2848 | // Parse literal '<' |
2849 | if (odsParser.parseLess()) return {}; |
2850 | |
2851 | // Parse variable 'one' |
2852 | _result_one = ::mlir::FieldParser<int64_t>::parse(odsParser); |
2853 | if (::mlir::failed(_result_one)) { |
2854 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeWithFormat parameter 'one' which is to be a `int64_t`"); |
2855 | return {}; |
2856 | } |
2857 | // Parse literal ',' |
2858 | if (odsParser.parseComma()) return {}; |
2859 | // Parse parameter struct |
2860 | bool _seen_three = false; |
2861 | bool _seen_two = false; |
2862 | { |
2863 | const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { |
2864 | // Parse literal '=' |
2865 | if (odsParser.parseEqual()) return {}; |
2866 | if (!_seen_three && _paramKey == "three") { |
2867 | _seen_three = true; |
2868 | |
2869 | // Parse variable 'three' |
2870 | _result_three = ::mlir::FieldParser<::mlir::Attribute>::parse(odsParser); |
2871 | if (::mlir::failed(_result_three)) { |
2872 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeWithFormat parameter 'three' which is to be a `::mlir::Attribute`"); |
2873 | return {}; |
2874 | } |
2875 | } else if (!_seen_two && _paramKey == "two") { |
2876 | _seen_two = true; |
2877 | |
2878 | // Parse variable 'two' |
2879 | _result_two = ::mlir::FieldParser<std::string>::parse(odsParser); |
2880 | if (::mlir::failed(_result_two)) { |
2881 | odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse TestTypeWithFormat parameter 'two' which is to be a `std::string`"); |
2882 | return {}; |
2883 | } |
2884 | } else { |
2885 | odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; |
2886 | return {}; |
2887 | } |
2888 | return true; |
2889 | }; |
2890 | for (unsigned odsStructIndex = 0; odsStructIndex < 2; ++odsStructIndex) { |
2891 | ::llvm::StringRef _paramKey; |
2892 | if (odsParser.parseKeyword(&_paramKey)) { |
2893 | odsParser.emitError(odsParser.getCurrentLocation(), |
2894 | "expected a parameter name in struct"); |
2895 | return {}; |
2896 | } |
2897 | if (!_loop_body(_paramKey)) return {}; |
2898 | if ((odsStructIndex != 2 - 1) && odsParser.parseComma()) |
2899 | return {}; |
2900 | } |
2901 | } |
2902 | // Parse literal '>' |
2903 | if (odsParser.parseGreater()) return {}; |
2904 | assert(::mlir::succeeded(_result_one))(static_cast <bool> (::mlir::succeeded(_result_one)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_one)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2904, __extension__ __PRETTY_FUNCTION__)); |
2905 | assert(::mlir::succeeded(_result_two))(static_cast <bool> (::mlir::succeeded(_result_two)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_two)", "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc" , 2905, __extension__ __PRETTY_FUNCTION__)); |
2906 | assert(::mlir::succeeded(_result_three))(static_cast <bool> (::mlir::succeeded(_result_three)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_three)" , "tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc", 2906 , __extension__ __PRETTY_FUNCTION__)); |
2907 | return TestTypeWithFormatType::get(odsParser.getContext(), |
2908 | int64_t((*_result_one)), |
2909 | std::string((*_result_two)), |
2910 | ::mlir::Attribute((*_result_three))); |
2911 | } |
2912 | |
2913 | void TestTypeWithFormatType::print(::mlir::AsmPrinter &odsPrinter) const { |
2914 | ::mlir::Builder odsBuilder(getContext()); |
2915 | odsPrinter << "<"; |
2916 | odsPrinter.printStrippedAttrOrType(getOne()); |
2917 | odsPrinter << ","; |
2918 | odsPrinter << ' '; |
2919 | { |
2920 | bool _firstPrinted = true; |
2921 | if (!_firstPrinted) odsPrinter << ", "; |
2922 | _firstPrinted = false; |
2923 | odsPrinter << "three = "; |
2924 | odsPrinter.printStrippedAttrOrType(getThree()); |
2925 | if (!_firstPrinted) odsPrinter << ", "; |
2926 | _firstPrinted = false; |
2927 | odsPrinter << "two = "; |
2928 | odsPrinter << '"' << getTwo() << '"'; |
2929 | } |
2930 | odsPrinter << ">"; |
2931 | } |
2932 | |
2933 | int64_t TestTypeWithFormatType::getOne() const { |
2934 | return getImpl()->one; |
2935 | } |
2936 | |
2937 | llvm::StringRef TestTypeWithFormatType::getTwo() const { |
2938 | return getImpl()->two; |
2939 | } |
2940 | |
2941 | ::mlir::Attribute TestTypeWithFormatType::getThree() const { |
2942 | return getImpl()->three; |
2943 | } |
2944 | |
2945 | } // namespace test |
2946 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeWithFormatType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeWithFormatType>::id = {}; } } |
2947 | namespace test { |
2948 | namespace detail { |
2949 | struct TestTypeWithLayoutTypeStorage : public ::mlir::TypeStorage { |
2950 | using KeyTy = std::tuple<unsigned>; |
2951 | TestTypeWithLayoutTypeStorage(unsigned key) : key(key) {} |
2952 | |
2953 | KeyTy getAsKey() const { |
2954 | return KeyTy(key); |
2955 | } |
2956 | |
2957 | bool operator==(const KeyTy &tblgenKey) const { |
2958 | return (key == std::get<0>(tblgenKey)); |
2959 | } |
2960 | |
2961 | static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { |
2962 | return ::llvm::hash_combine(std::get<0>(tblgenKey)); |
2963 | } |
2964 | |
2965 | static TestTypeWithLayoutTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, const KeyTy &tblgenKey) { |
2966 | auto key = std::get<0>(tblgenKey); |
2967 | return new (allocator.allocate<TestTypeWithLayoutTypeStorage>()) TestTypeWithLayoutTypeStorage(key); |
2968 | } |
2969 | |
2970 | unsigned key; |
2971 | }; |
2972 | } // namespace detail |
2973 | TestTypeWithLayoutType TestTypeWithLayoutType::get(::mlir::MLIRContext *context, unsigned key) { |
2974 | return Base::get(context, key); |
2975 | } |
2976 | |
2977 | unsigned TestTypeWithLayoutType::getKey() const { |
2978 | return getImpl()->key; |
2979 | } |
2980 | |
2981 | } // namespace test |
2982 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeWithLayoutType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeWithLayoutType>::id = {}; } } |
2983 | namespace test { |
2984 | } // namespace test |
2985 | MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::TestTypeWithTraitType)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver < ::test::TestTypeWithTraitType>::id = {}; } } |
2986 | |
2987 | #endif // GET_TYPEDEF_CLASSES |
2988 |