Bug Summary

File:build/source/build-llvm/tools/clang/stage2-bins/tools/mlir/test/lib/Dialect/Test/TestTypeDefs.cpp.inc
Warning:line 1421, column 9
Value stored to '_firstPrinted' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

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