LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#ifdef GET_OP_LIST
11#undef GET_OP_LIST
12
16#endif // GET_OP_LIST
17
18#ifdef GET_OP_CLASSES
19#undef GET_OP_CLASSES
20
21
22//===----------------------------------------------------------------------===//
23// Local Utility Method Definitions
24//===----------------------------------------------------------------------===//
25
26
27static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
28 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
29 unsigned valueIndex) {
30 if (!((::llzk::isValidType(type)))) {
31 return op->emitOpError(valueKind) << " #" << valueIndex
32 << " must be variadic of a valid LLZK type, but got " << type;
33 }
34 return ::mlir::success();
35}
36
37static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops2(
38 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
39 unsigned valueIndex) {
40 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
41 return op->emitOpError(valueKind) << " #" << valueIndex
42 << " must be variadic of index, but got " << type;
43 }
44 return ::mlir::success();
45}
46
47static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
48 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
49 if (attr && !((::llvm::isa<::mlir::SymbolRefAttr>(attr))))
50 return emitError() << "attribute '" << attrName
51 << "' failed to satisfy constraint: symbol reference attribute";
52 return ::mlir::success();
53}
54static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
55 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
56 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
57 return op->emitOpError();
58 });
59}
60
61static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
62 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
63 if (attr && !((::llvm::isa<::mlir::ArrayAttr>(attr))))
64 return emitError() << "attribute '" << attrName
65 << "' failed to satisfy constraint: array attribute";
66 return ::mlir::success();
67}
68static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
69 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
70 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
71 return op->emitOpError();
72 });
73}
74
75static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
76 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
77 if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
78 return emitError() << "attribute '" << attrName
79 << "' failed to satisfy constraint: i32 dense array attribute";
80 return ::mlir::success();
81}
82static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
83 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
84 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
85 return op->emitOpError();
86 });
87}
88
89static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
90 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
91 if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); }))))
92 return emitError() << "attribute '" << attrName
93 << "' failed to satisfy constraint: Array of dictionary attributes";
94 return ::mlir::success();
95}
96static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
97 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
98 return __mlir_ods_local_attr_constraint_Ops4(attr, attrName, [op]() {
99 return op->emitOpError();
100 });
101}
102
103static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
104 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
105 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
106 return emitError() << "attribute '" << attrName
107 << "' failed to satisfy constraint: string attribute";
108 return ::mlir::success();
109}
110static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
111 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
112 return __mlir_ods_local_attr_constraint_Ops5(attr, attrName, [op]() {
113 return op->emitOpError();
114 });
115}
116
117static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops6(
118 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
119 if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue())))))
120 return emitError() << "attribute '" << attrName
121 << "' failed to satisfy constraint: type attribute of function type";
122 return ::mlir::success();
123}
124static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops6(
125 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
126 return __mlir_ods_local_attr_constraint_Ops6(attr, attrName, [op]() {
127 return op->emitOpError();
128 });
129}
130
131static ::llvm::LogicalResult __mlir_ods_local_region_constraint_Ops1(
132 ::mlir::Operation *op, ::mlir::Region &region, ::llvm::StringRef regionName,
133 unsigned regionIndex) {
134 if (!((true))) {
135 return op->emitOpError("region #") << regionIndex
136 << (regionName.empty() ? " " : " ('" + regionName + "') ")
137 << "failed to verify constraint: any region";
138 }
139 return ::mlir::success();
140}
141namespace llzk::function {
142
143
144//===----------------------------------------------------------------------===//
145// ::llzk::function::CallOp definitions
146//===----------------------------------------------------------------------===//
147
148namespace detail {
149
150CallOpGenericAdaptorBase::CallOpGenericAdaptorBase(CallOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
151
152std::pair<unsigned, unsigned> CallOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
153 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
154
155 unsigned start = 0;
156 for (unsigned i = 0; i < index; ++i)
157 start += sizeAttr[i];
158 return {start, sizeAttr[index]};
159}
160
161::mlir::SymbolRefAttr CallOpGenericAdaptorBase::getCallee() {
162 auto attr = getCalleeAttr();
163 return attr;
164}
165
166::std::optional< ::mlir::ArrayAttr > CallOpGenericAdaptorBase::getTemplateParams() {
167 auto attr = getTemplateParamsAttr();
168 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
169}
170
172 auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
173 return attr;
174}
175
177 auto attr = getNumDimsPerMapAttr();
178 return attr;
179}
180
182 auto attr = getMapOpGroupSizesAttr();
183 return attr;
184}
185
186::std::optional< ::mlir::ArrayAttr > CallOpGenericAdaptorBase::getArgAttrs() {
187 auto attr = getArgAttrsAttr();
188 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
189}
190
191::std::optional< ::mlir::ArrayAttr > CallOpGenericAdaptorBase::getResAttrs() {
192 auto attr = getResAttrsAttr();
193 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
194}
195
196
197} // namespace detail
199
200::llvm::LogicalResult CallOpAdaptor::verify(::mlir::Location loc) {
201 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
202 auto tblgen_callee = getProperties().callee; (void)tblgen_callee;
203 if (!tblgen_callee) return emitError(loc, "'function.call' op requires attribute 'callee'");
204 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
205 if (!tblgen_mapOpGroupSizes) return emitError(loc, "'function.call' op requires attribute 'mapOpGroupSizes'");
206 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
207 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
208 auto tblgen_templateParams = getProperties().templateParams; (void)tblgen_templateParams;
209
210 if (tblgen_callee && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_callee))))
211 return emitError(loc, "'function.call' op attribute 'callee' failed to satisfy constraint: symbol reference attribute");
212
213 if (tblgen_templateParams && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_templateParams))))
214 return emitError(loc, "'function.call' op attribute 'templateParams' failed to satisfy constraint: array attribute");
215
216 if (tblgen_numDimsPerMap && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numDimsPerMap))))
217 return emitError(loc, "'function.call' op attribute 'numDimsPerMap' failed to satisfy constraint: i32 dense array attribute");
218
219 if (tblgen_mapOpGroupSizes && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_mapOpGroupSizes))))
220 return emitError(loc, "'function.call' op attribute 'mapOpGroupSizes' failed to satisfy constraint: i32 dense array attribute");
221
222 if (tblgen_arg_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_arg_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_arg_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); }))))
223 return emitError(loc, "'function.call' op attribute 'arg_attrs' failed to satisfy constraint: Array of dictionary attributes");
224
225 if (tblgen_res_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_res_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_res_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); }))))
226 return emitError(loc, "'function.call' op attribute 'res_attrs' failed to satisfy constraint: Array of dictionary attributes");
227 return ::mlir::success();
228}
229
230std::pair<unsigned, unsigned> CallOp::getODSOperandIndexAndLength(unsigned index) {
231 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
232
233 unsigned start = 0;
234 for (unsigned i = 0; i < index; ++i)
235 start += sizeAttr[i];
236 return {start, sizeAttr[index]};
237}
238
239::mlir::MutableOperandRange CallOp::getArgOperandsMutable() {
240 auto range = getODSOperandIndexAndLength(0);
241 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
242 return mutableRange;
243}
244
245::mlir::MutableOperandRangeRange CallOp::getMapOperandsMutable() {
246 auto range = getODSOperandIndexAndLength(1);
247 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
248 return mutableRange.split(*(*this)->getAttrDictionary().getNamed(getMapOpGroupSizesAttrName()));
249}
250
251std::pair<unsigned, unsigned> CallOp::getODSResultIndexAndLength(unsigned index) {
252 bool isVariadic[] = {true};
253 int prevVariadicCount = 0;
254 for (unsigned i = 0; i < index; ++i)
255 if (isVariadic[i]) ++prevVariadicCount;
256
257 // Calculate how many dynamic values a static variadic operand corresponds to.
258 // This assumes all static variadic operands have the same dynamic value count.
259 int variadicSize = (getOperation()->getNumResults() - 0) / 1;
260 // `index` passed in as the parameter is the static index which counts each
261 // operand (variadic or not) as size 1. So here for each previous static variadic
262 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
263 // value pack for this static operand starts.
264 int start = index + (variadicSize - 1) * prevVariadicCount;
265 int size = isVariadic[index] ? variadicSize : 1;
266 return {start, size};
267}
268
269::llvm::LogicalResult CallOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
270 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
271 if (!dict) {
272 emitError() << "expected DictionaryAttr to set properties";
273 return ::mlir::failure();
274 }
275
276 {
277 auto &propStorage = prop.arg_attrs;
278 auto attr = dict.get("arg_attrs");
279 if (attr) {
280 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
281 if (convertedAttr) {
282 propStorage = convertedAttr;
283 } else {
284 emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr;
285 return ::mlir::failure();
286 }
287 }
288 }
289
290 {
291 auto &propStorage = prop.callee;
292 auto attr = dict.get("callee");
293 if (attr) {
294 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
295 if (convertedAttr) {
296 propStorage = convertedAttr;
297 } else {
298 emitError() << "Invalid attribute `callee` in property conversion: " << attr;
299 return ::mlir::failure();
300 }
301 }
302 }
303
304 {
305 auto &propStorage = prop.mapOpGroupSizes;
306 auto attr = dict.get("mapOpGroupSizes");
307 if (attr) {
308 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
309 if (convertedAttr) {
310 propStorage = convertedAttr;
311 } else {
312 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
313 return ::mlir::failure();
314 }
315 }
316 }
317
318 {
319 auto &propStorage = prop.numDimsPerMap;
320 auto attr = dict.get("numDimsPerMap");
321 if (attr) {
322 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
323 if (convertedAttr) {
324 propStorage = convertedAttr;
325 } else {
326 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
327 return ::mlir::failure();
328 }
329 }
330 }
331
332 {
333 auto &propStorage = prop.res_attrs;
334 auto attr = dict.get("res_attrs");
335 if (attr) {
336 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
337 if (convertedAttr) {
338 propStorage = convertedAttr;
339 } else {
340 emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr;
341 return ::mlir::failure();
342 }
343 }
344 }
345
346 {
347 auto &propStorage = prop.templateParams;
348 auto attr = dict.get("templateParams");
349 if (attr) {
350 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
351 if (convertedAttr) {
352 propStorage = convertedAttr;
353 } else {
354 emitError() << "Invalid attribute `templateParams` in property conversion: " << attr;
355 return ::mlir::failure();
356 }
357 }
358 }
359{
360
361 auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
362 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {
363 return convertFromAttribute(propStorage, propAttr, emitError);
364 };
365 auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
366;
367 if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() {
368 return emitError() << "for `operandSegmentSizes`: ";
369 })))
370 return ::mlir::failure();
371 }
372 return ::mlir::success();
373}
374
375::mlir::Attribute CallOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
376 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
377 ::mlir::Builder odsBuilder{ctx};
378
379 {
380 const auto &propStorage = prop.arg_attrs;
381 if (propStorage)
382 attrs.push_back(odsBuilder.getNamedAttr("arg_attrs",
383 propStorage));
384 }
385
386 {
387 const auto &propStorage = prop.callee;
388 if (propStorage)
389 attrs.push_back(odsBuilder.getNamedAttr("callee",
390 propStorage));
391 }
392
393 {
394 const auto &propStorage = prop.mapOpGroupSizes;
395 if (propStorage)
396 attrs.push_back(odsBuilder.getNamedAttr("mapOpGroupSizes",
397 propStorage));
398 }
399
400 {
401 const auto &propStorage = prop.numDimsPerMap;
402 if (propStorage)
403 attrs.push_back(odsBuilder.getNamedAttr("numDimsPerMap",
404 propStorage));
405 }
406
407 {
408 const auto &propStorage = prop.res_attrs;
409 if (propStorage)
410 attrs.push_back(odsBuilder.getNamedAttr("res_attrs",
411 propStorage));
412 }
413
414 {
415 const auto &propStorage = prop.templateParams;
416 if (propStorage)
417 attrs.push_back(odsBuilder.getNamedAttr("templateParams",
418 propStorage));
419 }
420
421 {
422 const auto &propStorage = prop.operandSegmentSizes;
423 auto attr = [&]() -> ::mlir::Attribute {
424 return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
425 }();
426 attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
427 }
428
429 if (!attrs.empty())
430 return odsBuilder.getDictionaryAttr(attrs);
431 return {};
432}
433
434llvm::hash_code CallOp::computePropertiesHash(const Properties &prop) {
435 auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code {
436 using ::llvm::hash_value;
437 return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
438 };
439 using llvm::hash_value;
440 return llvm::hash_combine(
441 llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()),
442 llvm::hash_value(prop.callee.getAsOpaquePointer()),
443 llvm::hash_value(prop.mapOpGroupSizes.getAsOpaquePointer()),
444 llvm::hash_value(prop.numDimsPerMap.getAsOpaquePointer()),
445 llvm::hash_value(prop.res_attrs.getAsOpaquePointer()),
446 llvm::hash_value(prop.templateParams.getAsOpaquePointer()),
447 hash_operandSegmentSizes_(prop.operandSegmentSizes));
448}
449
450std::optional<mlir::Attribute> CallOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
451 if (name == "arg_attrs")
452 return prop.arg_attrs;
453
454 if (name == "callee")
455 return prop.callee;
456
457 if (name == "mapOpGroupSizes")
458 return prop.mapOpGroupSizes;
459
460 if (name == "numDimsPerMap")
461 return prop.numDimsPerMap;
462
463 if (name == "res_attrs")
464 return prop.res_attrs;
465
466 if (name == "templateParams")
467 return prop.templateParams;
468 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
469 return std::nullopt;
470}
471
472void CallOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
473 if (name == "arg_attrs") {
474 prop.arg_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.arg_attrs)>>(value);
475 return;
476 }
477
478 if (name == "callee") {
479 prop.callee = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.callee)>>(value);
480 return;
481 }
482
483 if (name == "mapOpGroupSizes") {
484 prop.mapOpGroupSizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapOpGroupSizes)>>(value);
485 return;
486 }
487
488 if (name == "numDimsPerMap") {
489 prop.numDimsPerMap = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDimsPerMap)>>(value);
490 return;
491 }
492
493 if (name == "res_attrs") {
494 prop.res_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.res_attrs)>>(value);
495 return;
496 }
497
498 if (name == "templateParams") {
499 prop.templateParams = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.templateParams)>>(value);
500 return;
501 }
502 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") {
503 auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value);
504 if (!arrAttr) return;
505 if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t))
506 return;
507 llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin());
508 return;
509 }
510}
511
512void CallOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
513 if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs);
514
515 if (prop.callee) attrs.append("callee", prop.callee);
516
517 if (prop.mapOpGroupSizes) attrs.append("mapOpGroupSizes", prop.mapOpGroupSizes);
518
519 if (prop.numDimsPerMap) attrs.append("numDimsPerMap", prop.numDimsPerMap);
520
521 if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs);
522
523 if (prop.templateParams) attrs.append("templateParams", prop.templateParams);
524 attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
525}
526
527::llvm::LogicalResult CallOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
528 {
529 ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName));
530 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "arg_attrs", emitError)))
531 return ::mlir::failure();
532 }
533
534 {
535 ::mlir::Attribute attr = attrs.get(getCalleeAttrName(opName));
536 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "callee", emitError)))
537 return ::mlir::failure();
538 }
539
540 {
541 ::mlir::Attribute attr = attrs.get(getMapOpGroupSizesAttrName(opName));
542 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "mapOpGroupSizes", emitError)))
543 return ::mlir::failure();
544 }
545
546 {
547 ::mlir::Attribute attr = attrs.get(getNumDimsPerMapAttrName(opName));
548 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "numDimsPerMap", emitError)))
549 return ::mlir::failure();
550 }
551
552 {
553 ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName));
554 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "res_attrs", emitError)))
555 return ::mlir::failure();
556 }
557
558 {
559 ::mlir::Attribute attr = attrs.get(getTemplateParamsAttrName(opName));
560 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "templateParams", emitError)))
561 return ::mlir::failure();
562 }
563 return ::mlir::success();
564}
565
566::mlir::SymbolRefAttr CallOp::getCallee() {
567 auto attr = getCalleeAttr();
568 return attr;
569}
570
571::std::optional< ::mlir::ArrayAttr > CallOp::getTemplateParams() {
572 auto attr = getTemplateParamsAttr();
573 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
574}
575
576::llvm::ArrayRef<int32_t> CallOp::getNumDimsPerMap() {
577 auto attr = getNumDimsPerMapAttr();
578 return attr;
579}
580
581::llvm::ArrayRef<int32_t> CallOp::getMapOpGroupSizes() {
582 auto attr = getMapOpGroupSizesAttr();
583 return attr;
584}
585
586::std::optional< ::mlir::ArrayAttr > CallOp::getArgAttrs() {
587 auto attr = getArgAttrsAttr();
588 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
589}
590
591::std::optional< ::mlir::ArrayAttr > CallOp::getResAttrs() {
592 auto attr = getResAttrsAttr();
593 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
594}
595
596void CallOp::setNumDimsPerMap(::llvm::ArrayRef<int32_t> attrValue) {
597 getProperties().numDimsPerMap = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
598}
599
600void CallOp::setMapOpGroupSizes(::llvm::ArrayRef<int32_t> attrValue) {
601 getProperties().mapOpGroupSizes = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
602}
603
604CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
605 ::mlir::OperationState __state__(location, getOperationName());
606 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
607 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
608 assert(__res__ && "builder didn't return the right type");
609 return __res__;
610}
611
612CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
613 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
614}
615
616CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
617 ::mlir::OperationState __state__(location, getOperationName());
618 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
619 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
620 assert(__res__ && "builder didn't return the right type");
621 return __res__;
622}
623
624CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
625 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
626}
627
628void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
629 build(odsBuilder, odsState, resultTypes, callee, mapOperands,
630 odsBuilder.getDenseI32ArrayAttr(numDimsPerMap),
631 argOperands, templateParams);
632
633}
634
635CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
636 ::mlir::OperationState __state__(location, getOperationName());
637 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
638 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
639 assert(__res__ && "builder didn't return the right type");
640 return __res__;
641}
642
643CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
644 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
645}
646
647void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::function::FuncDefOp callee, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
648 build(odsBuilder, odsState, callee.getResultTypes(),
649 callee.getFullyQualifiedName(false),
650 argOperands, templateParams);
651
652}
653
654CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::function::FuncDefOp callee, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
655 ::mlir::OperationState __state__(location, getOperationName());
656 build(builder, __state__, std::forward<decltype(callee)>(callee), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
657 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
658 assert(__res__ && "builder didn't return the right type");
659 return __res__;
660}
661
662CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::function::FuncDefOp callee, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
663 return create(builder, builder.getLoc(), std::forward<decltype(callee)>(callee), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
664}
665
666void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
667 build(odsBuilder, odsState, callee.getResultTypes(),
668 callee.getFullyQualifiedName(false), mapOperands, numDimsPerMap,
669 argOperands, templateParams);
670
671}
672
673CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
674 ::mlir::OperationState __state__(location, getOperationName());
675 build(builder, __state__, std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
676 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
677 assert(__res__ && "builder didn't return the right type");
678 return __res__;
679}
680
681CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
682 return create(builder, builder.getLoc(), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
683}
684
685void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
686 build(odsBuilder, odsState, callee, mapOperands,
687 odsBuilder.getDenseI32ArrayAttr(numDimsPerMap),
688 argOperands, templateParams);
689
690}
691
692CallOp CallOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
693 ::mlir::OperationState __state__(location, getOperationName());
694 build(builder, __state__, std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
695 auto __res__ = ::llvm::dyn_cast<CallOp>(builder.create(__state__));
696 assert(__res__ && "builder didn't return the right type");
697 return __res__;
698}
699
700CallOp CallOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::mlir::ValueRange argOperands, ::llvm::ArrayRef<::mlir::Attribute> templateParams) {
701 return create(builder, builder.getLoc(), std::forward<decltype(callee)>(callee), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(argOperands)>(argOperands), std::forward<decltype(templateParams)>(templateParams));
702}
703
704void CallOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
705 ::mlir::Builder odsBuilder(opName.getContext());
706 if (!properties.numDimsPerMap)
707 properties.numDimsPerMap = odsBuilder.getDenseI32ArrayAttr({});
708}
709
710::llvm::LogicalResult CallOp::verifyInvariantsImpl() {
711 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
712 auto tblgen_callee = getProperties().callee; (void)tblgen_callee;
713 if (!tblgen_callee) return emitOpError("requires attribute 'callee'");
714 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
715 if (!tblgen_mapOpGroupSizes) return emitOpError("requires attribute 'mapOpGroupSizes'");
716 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
717 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
718 auto tblgen_templateParams = getProperties().templateParams; (void)tblgen_templateParams;
719
720 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_callee, "callee")))
721 return ::mlir::failure();
722
723 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_templateParams, "templateParams")))
724 return ::mlir::failure();
725
726 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_numDimsPerMap, "numDimsPerMap")))
727 return ::mlir::failure();
728
729 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_mapOpGroupSizes, "mapOpGroupSizes")))
730 return ::mlir::failure();
731
732 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_arg_attrs, "arg_attrs")))
733 return ::mlir::failure();
734
735 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_res_attrs, "res_attrs")))
736 return ::mlir::failure();
737 {
738 unsigned index = 0; (void)index;
739 auto valueGroup0 = getODSOperands(0);
740
741 for (auto v : valueGroup0) {
742 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
743 return ::mlir::failure();
744 }
745 auto valueGroup1 = getODSOperands(1);
746 if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr(*this, "mapOpGroupSizes", "mapOperands", valueGroup1.size())))
747 return ::mlir::failure();
748
749 for (auto v : valueGroup1) {
750 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
751 return ::mlir::failure();
752 }
753 }
754 {
755 unsigned index = 0; (void)index;
756 auto valueGroup0 = getODSResults(0);
757
758 for (auto v : valueGroup0) {
759 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
760 return ::mlir::failure();
761 }
762 }
763 return ::mlir::success();
764}
765
766::llvm::LogicalResult CallOp::verifyInvariants() {
767 return verifyInvariantsImpl();
768}
769
770::mlir::ParseResult CallOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
771 ::mlir::SymbolRefAttr calleeAttr;
772 ::mlir::ArrayAttr templateParamsAttr;
773 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> argOperandsOperands;
774 ::llvm::SMLoc argOperandsOperandsLoc;
775 (void)argOperandsOperandsLoc;
776 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> mapOperandsOperands;
777 llvm::SmallVector<int32_t> mapOperandsOperandGroupSizes;
778 ::llvm::SMLoc mapOperandsOperandsLoc;
779 (void)mapOperandsOperandsLoc;
780 ::mlir::DenseI32ArrayAttr numDimsPerMapAttr;
781 ::llvm::ArrayRef<::mlir::Type> argOperandsTypes;
782 ::llvm::ArrayRef<::mlir::Type> allResultTypes;
783
784 if (parser.parseCustomAttributeWithFallback(calleeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
785 return ::mlir::failure();
786 }
787 if (calleeAttr) result.getOrAddProperties<CallOp::Properties>().callee = calleeAttr;
788 if (::mlir::succeeded(parser.parseOptionalLess())) {
789 {
790 auto odsResult = parseTemplateParams(parser, templateParamsAttr);
791 if (odsResult) return ::mlir::failure();
792 if (templateParamsAttr)
793 result.getOrAddProperties<CallOp::Properties>().templateParams = templateParamsAttr;
794 }
795 if (parser.parseGreater())
796 return ::mlir::failure();
797 }
798 if (parser.parseLParen())
799 return ::mlir::failure();
800
801 argOperandsOperandsLoc = parser.getCurrentLocation();
802 if (parser.parseOperandList(argOperandsOperands))
803 return ::mlir::failure();
804 if (parser.parseRParen())
805 return ::mlir::failure();
806 if (::mlir::succeeded(parser.parseOptionalLBrace())) {
807 {
808 mapOperandsOperandsLoc = parser.getCurrentLocation();
809 ::llvm::SmallVector<::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand>> mapOperandsOperandGroups;
810 auto odsResult = parseMultiDimAndSymbolList(parser, mapOperandsOperandGroups, numDimsPerMapAttr);
811 if (odsResult) return ::mlir::failure();
812 for (const auto &subRange : mapOperandsOperandGroups) {
813 mapOperandsOperands.append(subRange.begin(), subRange.end());
814 mapOperandsOperandGroupSizes.push_back(subRange.size());
815 }
816 if (numDimsPerMapAttr)
817 result.getOrAddProperties<CallOp::Properties>().numDimsPerMap = numDimsPerMapAttr;
818 }
819 if (parser.parseRBrace())
820 return ::mlir::failure();
821 }
822 if (parser.parseColon())
823 return ::mlir::failure();
824
825 ::mlir::FunctionType argOperands__allResult_functionType;
826 if (parser.parseType(argOperands__allResult_functionType))
827 return ::mlir::failure();
828 argOperandsTypes = argOperands__allResult_functionType.getInputs();
829 allResultTypes = argOperands__allResult_functionType.getResults();
830 {
831 auto odsResult = parseAttrDictWithWarnings(parser, result.attributes, result);
832 if (odsResult) return ::mlir::failure();
833 }
834::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(argOperandsOperands.size()), static_cast<int32_t>(mapOperandsOperands.size())}), result.getOrAddProperties<CallOp::Properties>().operandSegmentSizes.begin());
835 result.getOrAddProperties<CallOp::Properties>().mapOpGroupSizes = parser.getBuilder().getDenseI32ArrayAttr(mapOperandsOperandGroupSizes);
836 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
837 result.addTypes(allResultTypes);
838 if (parser.resolveOperands(argOperandsOperands, argOperandsTypes, argOperandsOperandsLoc, result.operands))
839 return ::mlir::failure();
840 if (parser.resolveOperands(mapOperandsOperands, odsBuildableType0, mapOperandsOperandsLoc, result.operands))
841 return ::mlir::failure();
842 return ::mlir::success();
843}
844
845::llvm::LogicalResult CallOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
846 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
847 if (!dict) {
848 emitError() << "expected DictionaryAttr to set properties";
849 return ::mlir::failure();
850 }
851 // keep track of used keys in the input dictionary to be able to error out
852 // if there are some unknown ones.
853 ::mlir::DenseSet<::mlir::StringAttr> usedKeys;
854 ::mlir::MLIRContext *ctx = dict.getContext();
855 (void)ctx;
856 {
857
858 auto &propStorage = prop.mapOpGroupSizes;
859 auto mapOpGroupSizesAttrName = ::mlir::StringAttr::get(ctx, "mapOpGroupSizes");
860 auto attr = dict.get(mapOpGroupSizesAttrName);
861 usedKeys.insert(mapOpGroupSizesAttrName);
862 if (attr || /*isRequired=*/true) {
863 if (!attr) {
864 emitError() << "expected key entry for mapOpGroupSizes in DictionaryAttr to set "
865 "Properties.";
866 return ::mlir::failure();
867 }
868 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
869 if (convertedAttr) {
870 propStorage = convertedAttr;
871 } else {
872 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
873 return ::mlir::failure();
874 }
875 }
876 }
877 {
878
879 auto &propStorage = prop.arg_attrs;
880 auto arg_attrsAttrName = ::mlir::StringAttr::get(ctx, "arg_attrs");
881 auto attr = dict.get(arg_attrsAttrName);
882 usedKeys.insert(arg_attrsAttrName);
883 if (attr || /*isRequired=*/false) {
884 if (!attr) {
885 emitError() << "expected key entry for arg_attrs in DictionaryAttr to set "
886 "Properties.";
887 return ::mlir::failure();
888 }
889 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
890 if (convertedAttr) {
891 propStorage = convertedAttr;
892 } else {
893 emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr;
894 return ::mlir::failure();
895 }
896 }
897 }
898 {
899
900 auto &propStorage = prop.res_attrs;
901 auto res_attrsAttrName = ::mlir::StringAttr::get(ctx, "res_attrs");
902 auto attr = dict.get(res_attrsAttrName);
903 usedKeys.insert(res_attrsAttrName);
904 if (attr || /*isRequired=*/false) {
905 if (!attr) {
906 emitError() << "expected key entry for res_attrs in DictionaryAttr to set "
907 "Properties.";
908 return ::mlir::failure();
909 }
910 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
911 if (convertedAttr) {
912 propStorage = convertedAttr;
913 } else {
914 emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr;
915 return ::mlir::failure();
916 }
917 }
918 }
919
920 for (::mlir::NamedAttribute attr : dict) {
921 if (!usedKeys.contains(attr.getName()))
922 return emitError() << "unknown key '" << attr.getName() <<
923 "' when parsing properties dictionary";
924 }
925 return ::mlir::success();
926}
927
928void CallOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
929 _odsPrinter << ' ';
930 _odsPrinter.printAttributeWithoutType(getCalleeAttr());
931 if (((getTemplateParamsAttr()))) {
932 _odsPrinter << "<";
933 printTemplateParams(_odsPrinter, *this, getTemplateParamsAttr());
934 _odsPrinter << ">";
935 }
936 _odsPrinter << "(";
937 _odsPrinter << getArgOperands();
938 _odsPrinter << ")";
939 if (((!getMapOperands().empty()) || (getNumDimsPerMapAttr() != ::mlir::OpBuilder((*this)->getContext()).getDenseI32ArrayAttr({})))) {
940 _odsPrinter << ' ' << "{";
942 _odsPrinter << "}";
943 }
944 _odsPrinter << ' ' << ":";
945 _odsPrinter << ' ';
946 _odsPrinter.printFunctionalType(getArgOperands().getTypes(), getOperation()->getResultTypes());
947 _odsPrinter << ' ';
948 printAttrDictWithWarnings(_odsPrinter, *this, getOperation()->getAttrDictionary(), getProperties());
949}
950
951
952} // namespace llzk::function
953MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::CallOp)
955
956namespace llzk::function {
957
958
959//===----------------------------------------------------------------------===//
960// ::llzk::function::FuncDefOp definitions
961//===----------------------------------------------------------------------===//
962
963namespace detail {
964
966
968 auto attr = getSymNameAttr();
969 return attr.getValue();
970}
971
973 auto attr = getFunctionTypeAttr();
974 return ::llvm::cast<::mlir::FunctionType>(attr.getValue());
975}
976
977::std::optional< ::mlir::ArrayAttr > FuncDefOpGenericAdaptorBase::getArgAttrs() {
978 auto attr = getArgAttrsAttr();
979 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
980}
981
982::std::optional< ::mlir::ArrayAttr > FuncDefOpGenericAdaptorBase::getResAttrs() {
983 auto attr = getResAttrsAttr();
984 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
985}
986
987
988} // namespace detail
990
991::llvm::LogicalResult FuncDefOpAdaptor::verify(::mlir::Location loc) {
992 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
993 auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type;
994 if (!tblgen_function_type) return emitError(loc, "'function.def' op requires attribute 'function_type'");
995 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
996 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
997 if (!tblgen_sym_name) return emitError(loc, "'function.def' op requires attribute 'sym_name'");
998
999 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
1000 return emitError(loc, "'function.def' op attribute 'sym_name' failed to satisfy constraint: string attribute");
1001
1002 if (tblgen_function_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_function_type))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(tblgen_function_type).getValue()))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(tblgen_function_type).getValue())))))
1003 return emitError(loc, "'function.def' op attribute 'function_type' failed to satisfy constraint: type attribute of function type");
1004
1005 if (tblgen_arg_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_arg_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_arg_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); }))))
1006 return emitError(loc, "'function.def' op attribute 'arg_attrs' failed to satisfy constraint: Array of dictionary attributes");
1007
1008 if (tblgen_res_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_res_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_res_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); }))))
1009 return emitError(loc, "'function.def' op attribute 'res_attrs' failed to satisfy constraint: Array of dictionary attributes");
1010 return ::mlir::success();
1011}
1012
1013::llvm::LogicalResult FuncDefOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1014 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1015 if (!dict) {
1016 emitError() << "expected DictionaryAttr to set properties";
1017 return ::mlir::failure();
1018 }
1019
1020 {
1021 auto &propStorage = prop.arg_attrs;
1022 auto attr = dict.get("arg_attrs");
1023 if (attr) {
1024 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1025 if (convertedAttr) {
1026 propStorage = convertedAttr;
1027 } else {
1028 emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr;
1029 return ::mlir::failure();
1030 }
1031 }
1032 }
1033
1034 {
1035 auto &propStorage = prop.function_type;
1036 auto attr = dict.get("function_type");
1037 if (attr) {
1038 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1039 if (convertedAttr) {
1040 propStorage = convertedAttr;
1041 } else {
1042 emitError() << "Invalid attribute `function_type` in property conversion: " << attr;
1043 return ::mlir::failure();
1044 }
1045 }
1046 }
1047
1048 {
1049 auto &propStorage = prop.res_attrs;
1050 auto attr = dict.get("res_attrs");
1051 if (attr) {
1052 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1053 if (convertedAttr) {
1054 propStorage = convertedAttr;
1055 } else {
1056 emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr;
1057 return ::mlir::failure();
1058 }
1059 }
1060 }
1061
1062 {
1063 auto &propStorage = prop.sym_name;
1064 auto attr = dict.get("sym_name");
1065 if (attr) {
1066 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1067 if (convertedAttr) {
1068 propStorage = convertedAttr;
1069 } else {
1070 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
1071 return ::mlir::failure();
1072 }
1073 }
1074 }
1075 return ::mlir::success();
1076}
1077
1078::mlir::Attribute FuncDefOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1079 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1080 ::mlir::Builder odsBuilder{ctx};
1081
1082 {
1083 const auto &propStorage = prop.arg_attrs;
1084 if (propStorage)
1085 attrs.push_back(odsBuilder.getNamedAttr("arg_attrs",
1086 propStorage));
1087 }
1088
1089 {
1090 const auto &propStorage = prop.function_type;
1091 if (propStorage)
1092 attrs.push_back(odsBuilder.getNamedAttr("function_type",
1093 propStorage));
1094 }
1095
1096 {
1097 const auto &propStorage = prop.res_attrs;
1098 if (propStorage)
1099 attrs.push_back(odsBuilder.getNamedAttr("res_attrs",
1100 propStorage));
1101 }
1102
1103 {
1104 const auto &propStorage = prop.sym_name;
1105 if (propStorage)
1106 attrs.push_back(odsBuilder.getNamedAttr("sym_name",
1107 propStorage));
1108 }
1109
1110 if (!attrs.empty())
1111 return odsBuilder.getDictionaryAttr(attrs);
1112 return {};
1113}
1114
1115llvm::hash_code FuncDefOp::computePropertiesHash(const Properties &prop) {
1116 using llvm::hash_value;
1117 return llvm::hash_combine(
1118 llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()),
1119 llvm::hash_value(prop.function_type.getAsOpaquePointer()),
1120 llvm::hash_value(prop.res_attrs.getAsOpaquePointer()),
1121 llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
1122}
1123
1124std::optional<mlir::Attribute> FuncDefOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1125 if (name == "arg_attrs")
1126 return prop.arg_attrs;
1127
1128 if (name == "function_type")
1129 return prop.function_type;
1130
1131 if (name == "res_attrs")
1132 return prop.res_attrs;
1133
1134 if (name == "sym_name")
1135 return prop.sym_name;
1136 return std::nullopt;
1137}
1138
1139void FuncDefOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1140 if (name == "arg_attrs") {
1141 prop.arg_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.arg_attrs)>>(value);
1142 return;
1143 }
1144
1145 if (name == "function_type") {
1146 prop.function_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.function_type)>>(value);
1147 return;
1148 }
1149
1150 if (name == "res_attrs") {
1151 prop.res_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.res_attrs)>>(value);
1152 return;
1153 }
1154
1155 if (name == "sym_name") {
1156 prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
1157 return;
1158 }
1159}
1160
1161void FuncDefOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1162 if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs);
1163
1164 if (prop.function_type) attrs.append("function_type", prop.function_type);
1165
1166 if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs);
1167
1168 if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
1169}
1170
1171::llvm::LogicalResult FuncDefOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1172 {
1173 ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName));
1174 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "arg_attrs", emitError)))
1175 return ::mlir::failure();
1176 }
1177
1178 {
1179 ::mlir::Attribute attr = attrs.get(getFunctionTypeAttrName(opName));
1180 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops6(attr, "function_type", emitError)))
1181 return ::mlir::failure();
1182 }
1183
1184 {
1185 ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName));
1186 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "res_attrs", emitError)))
1187 return ::mlir::failure();
1188 }
1189
1190 {
1191 ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
1192 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(attr, "sym_name", emitError)))
1193 return ::mlir::failure();
1194 }
1195 return ::mlir::success();
1196}
1197
1198::llvm::LogicalResult FuncDefOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
1199 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
1200 if (::mlir::failed(reader.readOptionalAttribute(prop.arg_attrs)))
1201 return ::mlir::failure();
1202
1203 if (::mlir::failed(reader.readAttribute(prop.function_type)))
1204 return ::mlir::failure();
1205
1206 if (::mlir::failed(reader.readOptionalAttribute(prop.res_attrs)))
1207 return ::mlir::failure();
1208
1209 if (::mlir::failed(reader.readAttribute(prop.sym_name)))
1210 return ::mlir::failure();
1211 return ::mlir::success();
1212}
1213
1214void FuncDefOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
1215 auto &prop = getProperties(); (void)prop;
1216
1217 writer.writeOptionalAttribute(prop.arg_attrs);
1218 writer.writeAttribute(prop.function_type);
1219
1220 writer.writeOptionalAttribute(prop.res_attrs);
1221 writer.writeAttribute(prop.sym_name);
1222}
1223
1224::llvm::StringRef FuncDefOp::getSymName() {
1225 auto attr = getSymNameAttr();
1226 return attr.getValue();
1227}
1228
1229::mlir::FunctionType FuncDefOp::getFunctionType() {
1230 auto attr = getFunctionTypeAttr();
1231 return ::llvm::cast<::mlir::FunctionType>(attr.getValue());
1232}
1233
1234::std::optional< ::mlir::ArrayAttr > FuncDefOp::getArgAttrs() {
1235 auto attr = getArgAttrsAttr();
1236 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
1237}
1238
1239::std::optional< ::mlir::ArrayAttr > FuncDefOp::getResAttrs() {
1240 auto attr = getResAttrsAttr();
1241 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
1242}
1243
1244void FuncDefOp::setSymName(::llvm::StringRef attrValue) {
1245 getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
1246}
1247
1248void FuncDefOp::setFunctionType(::mlir::FunctionType attrValue) {
1249 getProperties().function_type = ::mlir::TypeAttr::get(attrValue);
1250}
1251
1252FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef name, ::mlir::FunctionType type, ::llvm::ArrayRef<::mlir::NamedAttribute> attrs, ::llvm::ArrayRef<::mlir::DictionaryAttr> argAttrs) {
1253 ::mlir::OperationState __state__(location, getOperationName());
1254 build(builder, __state__, std::forward<decltype(name)>(name), std::forward<decltype(type)>(type), std::forward<decltype(attrs)>(attrs), std::forward<decltype(argAttrs)>(argAttrs));
1255 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1256 assert(__res__ && "builder didn't return the right type");
1257 return __res__;
1258}
1259
1260FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef name, ::mlir::FunctionType type, ::llvm::ArrayRef<::mlir::NamedAttribute> attrs, ::llvm::ArrayRef<::mlir::DictionaryAttr> argAttrs) {
1261 return create(builder, builder.getLoc(), std::forward<decltype(name)>(name), std::forward<decltype(type)>(type), std::forward<decltype(attrs)>(attrs), std::forward<decltype(argAttrs)>(argAttrs));
1262}
1263
1264void FuncDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1265 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
1266 odsState.getOrAddProperties<Properties>().function_type = function_type;
1267 if (arg_attrs) {
1268 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1269 }
1270 if (res_attrs) {
1271 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1272 }
1273 (void)odsState.addRegion();
1274}
1275
1276FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1277 ::mlir::OperationState __state__(location, getOperationName());
1278 build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1279 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1280 assert(__res__ && "builder didn't return the right type");
1281 return __res__;
1282}
1283
1284FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1285 return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1286}
1287
1288void FuncDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1289 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
1290 odsState.getOrAddProperties<Properties>().function_type = function_type;
1291 if (arg_attrs) {
1292 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1293 }
1294 if (res_attrs) {
1295 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1296 }
1297 (void)odsState.addRegion();
1298 assert(resultTypes.size() == 0u && "mismatched number of results");
1299 odsState.addTypes(resultTypes);
1300}
1301
1302FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1303 ::mlir::OperationState __state__(location, getOperationName());
1304 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1305 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1306 assert(__res__ && "builder didn't return the right type");
1307 return __res__;
1308}
1309
1310FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1311 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1312}
1313
1314void FuncDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1315 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
1316 odsState.getOrAddProperties<Properties>().function_type = ::mlir::TypeAttr::get(function_type);
1317 if (arg_attrs) {
1318 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1319 }
1320 if (res_attrs) {
1321 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1322 }
1323 (void)odsState.addRegion();
1324}
1325
1326FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1327 ::mlir::OperationState __state__(location, getOperationName());
1328 build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1329 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1330 assert(__res__ && "builder didn't return the right type");
1331 return __res__;
1332}
1333
1334FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1335 return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1336}
1337
1338void FuncDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1339 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
1340 odsState.getOrAddProperties<Properties>().function_type = ::mlir::TypeAttr::get(function_type);
1341 if (arg_attrs) {
1342 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1343 }
1344 if (res_attrs) {
1345 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1346 }
1347 (void)odsState.addRegion();
1348 assert(resultTypes.size() == 0u && "mismatched number of results");
1349 odsState.addTypes(resultTypes);
1350}
1351
1352FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1353 ::mlir::OperationState __state__(location, getOperationName());
1354 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1355 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1356 assert(__res__ && "builder didn't return the right type");
1357 return __res__;
1358}
1359
1360FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) {
1361 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(function_type)>(function_type), std::forward<decltype(arg_attrs)>(arg_attrs), std::forward<decltype(res_attrs)>(res_attrs));
1362}
1363
1364void FuncDefOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1365 assert(operands.size() == 0u && "mismatched number of parameters");
1366 odsState.addOperands(operands);
1367 odsState.addAttributes(attributes);
1368 for (unsigned i = 0; i != 1; ++i)
1369 (void)odsState.addRegion();
1370 assert(resultTypes.size() == 0u && "mismatched number of return types");
1371 odsState.addTypes(resultTypes);
1372
1373 if (!attributes.empty()) {
1374 (void)odsState.getOrAddProperties<FuncDefOp::Properties>();
1375 ::mlir::PropertyRef properties = odsState.getRawProperties();
1376 std::optional<::mlir::RegisteredOperationName> info =
1377 odsState.name.getRegisteredInfo();
1378 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
1379 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
1380 ::llvm::report_fatal_error("Property conversion failed.");
1381 }
1382}
1383
1384FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1385 ::mlir::OperationState __state__(location, getOperationName());
1386 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1387 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1388 assert(__res__ && "builder didn't return the right type");
1389 return __res__;
1390}
1391
1392FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1393 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1394}
1395
1396void FuncDefOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1397 assert(operands.size() == 0u && "mismatched number of parameters");
1398 odsState.addOperands(operands);
1399 odsState.useProperties(const_cast<Properties&>(properties));
1400 odsState.addAttributes(discardableAttributes);
1401 for (unsigned i = 0; i != 1; ++i)
1402 (void)odsState.addRegion();
1403 assert(resultTypes.size() == 0u && "mismatched number of return types");
1404 odsState.addTypes(resultTypes);
1405}
1406
1407FuncDefOp FuncDefOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1408 ::mlir::OperationState __state__(location, getOperationName());
1409 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1410 auto __res__ = ::llvm::dyn_cast<FuncDefOp>(builder.create(__state__));
1411 assert(__res__ && "builder didn't return the right type");
1412 return __res__;
1413}
1414
1415FuncDefOp FuncDefOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1416 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1417}
1418
1419::llvm::LogicalResult FuncDefOp::verifyInvariantsImpl() {
1420 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
1421 auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type;
1422 if (!tblgen_function_type) return emitOpError("requires attribute 'function_type'");
1423 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
1424 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
1425 if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
1426
1427 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(*this, tblgen_sym_name, "sym_name")))
1428 return ::mlir::failure();
1429
1430 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops6(*this, tblgen_function_type, "function_type")))
1431 return ::mlir::failure();
1432
1433 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_arg_attrs, "arg_attrs")))
1434 return ::mlir::failure();
1435
1436 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_res_attrs, "res_attrs")))
1437 return ::mlir::failure();
1438 {
1439 unsigned index = 0; (void)index;
1440
1441 for (auto &region : ::llvm::MutableArrayRef((*this)->getRegion(0)))
1442 if (::mlir::failed(__mlir_ods_local_region_constraint_Ops1(*this, region, "body", index++)))
1443 return ::mlir::failure();
1444 }
1445 return ::mlir::success();
1446}
1447
1448::llvm::LogicalResult FuncDefOp::verifyInvariants() {
1449 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1450 return ::mlir::success();
1451 return ::mlir::failure();
1452}
1453
1454::llvm::LogicalResult FuncDefOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1455 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1456 if (!dict) {
1457 emitError() << "expected DictionaryAttr to set properties";
1458 return ::mlir::failure();
1459 }
1460 // keep track of used keys in the input dictionary to be able to error out
1461 // if there are some unknown ones.
1462 ::mlir::DenseSet<::mlir::StringAttr> usedKeys;
1463 ::mlir::MLIRContext *ctx = dict.getContext();
1464 (void)ctx;
1465 {
1466
1467 auto &propStorage = prop.sym_name;
1468 auto sym_nameAttrName = ::mlir::StringAttr::get(ctx, "sym_name");
1469 auto attr = dict.get(sym_nameAttrName);
1470 usedKeys.insert(sym_nameAttrName);
1471 if (attr || /*isRequired=*/true) {
1472 if (!attr) {
1473 emitError() << "expected key entry for sym_name in DictionaryAttr to set "
1474 "Properties.";
1475 return ::mlir::failure();
1476 }
1477 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1478 if (convertedAttr) {
1479 propStorage = convertedAttr;
1480 } else {
1481 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
1482 return ::mlir::failure();
1483 }
1484 }
1485 }
1486 {
1487
1488 auto &propStorage = prop.function_type;
1489 auto function_typeAttrName = ::mlir::StringAttr::get(ctx, "function_type");
1490 auto attr = dict.get(function_typeAttrName);
1491 usedKeys.insert(function_typeAttrName);
1492 if (attr || /*isRequired=*/true) {
1493 if (!attr) {
1494 emitError() << "expected key entry for function_type in DictionaryAttr to set "
1495 "Properties.";
1496 return ::mlir::failure();
1497 }
1498 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1499 if (convertedAttr) {
1500 propStorage = convertedAttr;
1501 } else {
1502 emitError() << "Invalid attribute `function_type` in property conversion: " << attr;
1503 return ::mlir::failure();
1504 }
1505 }
1506 }
1507 {
1508
1509 auto &propStorage = prop.arg_attrs;
1510 auto arg_attrsAttrName = ::mlir::StringAttr::get(ctx, "arg_attrs");
1511 auto attr = dict.get(arg_attrsAttrName);
1512 usedKeys.insert(arg_attrsAttrName);
1513 if (attr || /*isRequired=*/false) {
1514 if (!attr) {
1515 emitError() << "expected key entry for arg_attrs in DictionaryAttr to set "
1516 "Properties.";
1517 return ::mlir::failure();
1518 }
1519 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1520 if (convertedAttr) {
1521 propStorage = convertedAttr;
1522 } else {
1523 emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr;
1524 return ::mlir::failure();
1525 }
1526 }
1527 }
1528 {
1529
1530 auto &propStorage = prop.res_attrs;
1531 auto res_attrsAttrName = ::mlir::StringAttr::get(ctx, "res_attrs");
1532 auto attr = dict.get(res_attrsAttrName);
1533 usedKeys.insert(res_attrsAttrName);
1534 if (attr || /*isRequired=*/false) {
1535 if (!attr) {
1536 emitError() << "expected key entry for res_attrs in DictionaryAttr to set "
1537 "Properties.";
1538 return ::mlir::failure();
1539 }
1540 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1541 if (convertedAttr) {
1542 propStorage = convertedAttr;
1543 } else {
1544 emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr;
1545 return ::mlir::failure();
1546 }
1547 }
1548 }
1549
1550 for (::mlir::NamedAttribute attr : dict) {
1551 if (!usedKeys.contains(attr.getName()))
1552 return emitError() << "unknown key '" << attr.getName() <<
1553 "' when parsing properties dictionary";
1554 }
1555 return ::mlir::success();
1556}
1557
1558
1559} // namespace llzk::function
1560MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::FuncDefOp)
1562
1563namespace llzk::function {
1564
1565
1566//===----------------------------------------------------------------------===//
1567// ::llzk::function::ReturnOp definitions
1568//===----------------------------------------------------------------------===//
1569
1570namespace detail {
1571
1572ReturnOpGenericAdaptorBase::ReturnOpGenericAdaptorBase(ReturnOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
1573
1574std::pair<unsigned, unsigned> ReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1575 bool isVariadic[] = {true};
1576 int prevVariadicCount = 0;
1577 for (unsigned i = 0; i < index; ++i)
1578 if (isVariadic[i]) ++prevVariadicCount;
1579
1580 // Calculate how many dynamic values a static variadic operand corresponds to.
1581 // This assumes all static variadic operands have the same dynamic value count.
1582 int variadicSize = (odsOperandsSize - 0) / 1;
1583 // `index` passed in as the parameter is the static index which counts each
1584 // operand (variadic or not) as size 1. So here for each previous static variadic
1585 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1586 // value pack for this static operand starts.
1587 int start = index + (variadicSize - 1) * prevVariadicCount;
1588 int size = isVariadic[index] ? variadicSize : 1;
1589 return {start, size};
1590}
1591
1592
1593} // namespace detail
1595
1596::llvm::LogicalResult ReturnOpAdaptor::verify(::mlir::Location loc) {
1597 return ::mlir::success();
1598}
1599
1600std::pair<unsigned, unsigned> ReturnOp::getODSOperandIndexAndLength(unsigned index) {
1601 bool isVariadic[] = {true};
1602 int prevVariadicCount = 0;
1603 for (unsigned i = 0; i < index; ++i)
1604 if (isVariadic[i]) ++prevVariadicCount;
1605
1606 // Calculate how many dynamic values a static variadic operand corresponds to.
1607 // This assumes all static variadic operands have the same dynamic value count.
1608 int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
1609 // `index` passed in as the parameter is the static index which counts each
1610 // operand (variadic or not) as size 1. So here for each previous static variadic
1611 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1612 // value pack for this static operand starts.
1613 int start = index + (variadicSize - 1) * prevVariadicCount;
1614 int size = isVariadic[index] ? variadicSize : 1;
1615 return {start, size};
1616}
1617
1618::mlir::MutableOperandRange ReturnOp::getOperandsMutable() {
1619 auto range = getODSOperandIndexAndLength(0);
1620 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1621 return mutableRange;
1622}
1623
1624::llvm::LogicalResult ReturnOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1625 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1626 if (!dict) {
1627 emitError() << "expected DictionaryAttr to set properties";
1628 return ::mlir::failure();
1629 }
1630 return ::mlir::success();
1631}
1632
1633::mlir::Attribute ReturnOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1634 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1635 ::mlir::Builder odsBuilder{ctx};
1636
1637 if (!attrs.empty())
1638 return odsBuilder.getDictionaryAttr(attrs);
1639 return {};
1640}
1641
1642llvm::hash_code ReturnOp::computePropertiesHash(const Properties &prop) {
1643 using llvm::hash_value;
1644 return llvm::hash_combine();
1645}
1646
1647std::optional<mlir::Attribute> ReturnOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1648 return std::nullopt;
1649}
1650
1651void ReturnOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1652}
1653
1654void ReturnOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1655}
1656
1657::llvm::LogicalResult ReturnOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1658 return ::mlir::success();
1659}
1660
1661void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
1662 build(odsBuilder, odsState, ::mlir::ValueRange {});
1663
1664}
1665
1666ReturnOp ReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location) {
1667 ::mlir::OperationState __state__(location, getOperationName());
1668 build(builder, __state__);
1669 auto __res__ = ::llvm::dyn_cast<ReturnOp>(builder.create(__state__));
1670 assert(__res__ && "builder didn't return the right type");
1671 return __res__;
1672}
1673
1674ReturnOp ReturnOp::create(::mlir::ImplicitLocOpBuilder &builder) {
1675 return create(builder, builder.getLoc());
1676}
1677
1678void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) {
1679 odsState.addOperands(operands);
1680}
1681
1682ReturnOp ReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands) {
1683 ::mlir::OperationState __state__(location, getOperationName());
1684 build(builder, __state__, std::forward<decltype(operands)>(operands));
1685 auto __res__ = ::llvm::dyn_cast<ReturnOp>(builder.create(__state__));
1686 assert(__res__ && "builder didn't return the right type");
1687 return __res__;
1688}
1689
1690ReturnOp ReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands) {
1691 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands));
1692}
1693
1694void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1695 odsState.addOperands(operands);
1696 odsState.addAttributes(attributes);
1697 assert(resultTypes.size() == 0u && "mismatched number of return types");
1698 odsState.addTypes(resultTypes);
1699}
1700
1701ReturnOp ReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1702 ::mlir::OperationState __state__(location, getOperationName());
1703 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1704 auto __res__ = ::llvm::dyn_cast<ReturnOp>(builder.create(__state__));
1705 assert(__res__ && "builder didn't return the right type");
1706 return __res__;
1707}
1708
1709ReturnOp ReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1710 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1711}
1712
1713void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1714 odsState.addOperands(operands);
1715 odsState.useProperties(const_cast<Properties&>(properties));
1716 odsState.addAttributes(discardableAttributes);
1717 assert(resultTypes.size() == 0u && "mismatched number of return types");
1718 odsState.addTypes(resultTypes);
1719}
1720
1721ReturnOp ReturnOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1722 ::mlir::OperationState __state__(location, getOperationName());
1723 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1724 auto __res__ = ::llvm::dyn_cast<ReturnOp>(builder.create(__state__));
1725 assert(__res__ && "builder didn't return the right type");
1726 return __res__;
1727}
1728
1729ReturnOp ReturnOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1730 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1731}
1732
1733::llvm::LogicalResult ReturnOp::verifyInvariantsImpl() {
1734 {
1735 unsigned index = 0; (void)index;
1736 auto valueGroup0 = getODSOperands(0);
1737
1738 for (auto v : valueGroup0) {
1739 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1740 return ::mlir::failure();
1741 }
1742 }
1743 return ::mlir::success();
1744}
1745
1746::llvm::LogicalResult ReturnOp::verifyInvariants() {
1747 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1748 return ::mlir::success();
1749 return ::mlir::failure();
1750}
1751
1752::mlir::ParseResult ReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1753 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands;
1754 ::llvm::SMLoc operandsOperandsLoc;
1755 (void)operandsOperandsLoc;
1756 ::llvm::SmallVector<::mlir::Type, 1> operandsTypes;
1757 {
1758 auto loc = parser.getCurrentLocation();(void)loc;
1759 if (parser.parseOptionalAttrDict(result.attributes))
1760 return ::mlir::failure();
1761 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
1762 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
1763 })))
1764 return ::mlir::failure();
1765 }
1766
1767 operandsOperandsLoc = parser.getCurrentLocation();
1768 if (parser.parseOperandList(operandsOperands))
1769 return ::mlir::failure();
1770 if (!operandsOperands.empty()) {
1771 if (parser.parseColon())
1772 return ::mlir::failure();
1773
1774 if (parser.parseTypeList(operandsTypes))
1775 return ::mlir::failure();
1776 }
1777 if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands))
1778 return ::mlir::failure();
1779 return ::mlir::success();
1780}
1781
1782void ReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1783 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1784 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1785 if (!getOperands().empty()) {
1786 _odsPrinter << ' ';
1787 _odsPrinter << getOperands();
1788 _odsPrinter << ' ' << ":";
1789 _odsPrinter << ' ';
1790 _odsPrinter << getOperands().getTypes();
1791 }
1792}
1793
1794void ReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
1795}
1796
1797
1798} // namespace llzk::function
1799MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::ReturnOp)
1800
1801
1802#endif // GET_OP_CLASSES
1803
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:200
CallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:289
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::mlir::ValueRange argOperands={}, ::llvm::ArrayRef<::mlir::Attribute > templateParams={})
void setNumDimsPerMap(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:596
::mlir::SymbolRefAttr getCalleeAttr()
Definition Ops.h.inc:456
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:512
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:527
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:434
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:704
::mlir::StringAttr getResAttrsAttrName()
Definition Ops.h.inc:395
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:586
::mlir::SymbolRefAttr getCallee()
Definition Ops.cpp.inc:566
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:251
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:450
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:845
::mlir::ArrayAttr getArgAttrsAttr()
Definition Ops.h.inc:476
::mlir::StringAttr getArgAttrsAttrName()
Definition Ops.h.inc:363
void setMapOpGroupSizes(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:600
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:269
::mlir::StringAttr getTemplateParamsAttrName()
Definition Ops.h.inc:403
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:472
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:581
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:230
::mlir::MutableOperandRange getArgOperandsMutable()
Definition Ops.cpp.inc:239
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:576
::mlir::Operation::operand_range getArgOperands()
Definition Ops.h.inc:430
static CallOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::mlir::ValueRange argOperands={}, ::llvm::ArrayRef<::mlir::Attribute > templateParams={})
Definition Ops.cpp.inc:604
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:766
::mlir::StringAttr getMapOpGroupSizesAttrName()
Definition Ops.h.inc:379
::mlir::ArrayAttr getTemplateParamsAttr()
Definition Ops.h.inc:461
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:770
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:928
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:419
::mlir::OperandRangeRange getMapOperands()
Definition Ops.h.inc:434
::mlir::ArrayAttr getResAttrsAttr()
Definition Ops.h.inc:481
FoldAdaptor::Properties Properties
Definition Ops.h.inc:350
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:471
::std::optional< ::mlir::ArrayAttr > getTemplateParams()
Definition Ops.cpp.inc:571
::mlir::StringAttr getNumDimsPerMapAttrName()
Definition Ops.h.inc:387
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:375
::mlir::MutableOperandRangeRange getMapOperandsMutable()
Definition Ops.cpp.inc:245
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:710
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:441
::mlir::StringAttr getCalleeAttrName()
Definition Ops.h.inc:371
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:591
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.h.inc:466
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:424
FuncDefOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:766
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:991
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1139
static FuncDefOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef name, ::mlir::FunctionType type, ::llvm::ArrayRef<::mlir::NamedAttribute > attrs={}, ::llvm::ArrayRef<::mlir::DictionaryAttr > argAttrs={})
Definition Ops.cpp.inc:1252
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1115
FoldAdaptor::Properties Properties
Definition Ops.h.inc:809
::mlir::FunctionType getFunctionType()
Definition Ops.cpp.inc:1229
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef name, ::mlir::FunctionType type, ::llvm::ArrayRef<::mlir::NamedAttribute > attrs={}, ::llvm::ArrayRef<::mlir::DictionaryAttr > argAttrs={})
::mlir::StringAttr getSymNameAttrName()
Definition Ops.h.inc:839
::mlir::StringAttr getFunctionTypeAttrName()
Definition Ops.h.inc:823
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1448
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1124
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:1198
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1454
::mlir::StringAttr getResAttrsAttrName()
Definition Ops.h.inc:831
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:1239
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:1234
::mlir::ArrayAttr getArgAttrsAttr()
Definition Ops.h.inc:894
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1078
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1161
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:1214
::llvm::StringRef getSymName()
Definition Ops.cpp.inc:1224
void setFunctionType(::mlir::FunctionType attrValue)
Definition Ops.cpp.inc:1248
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1013
::llvm::ArrayRef<::mlir::Type > getResultTypes()
Required by FunctionOpInterface.
Definition Ops.h.inc:1071
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:847
void setSymName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:1244
::mlir::SymbolRefAttr getFullyQualifiedName(bool requireParent=true)
Return the full name for this function from the root module, including all surrounding symbol table n...
Definition Ops.cpp:477
::mlir::TypeAttr getFunctionTypeAttr()
Definition Ops.h.inc:889
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1171
::llvm::LogicalResult verify()
Definition Ops.cpp:346
::mlir::StringAttr getSymNameAttr()
Definition Ops.h.inc:884
::mlir::ArrayAttr getResAttrsAttr()
Definition Ops.h.inc:899
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1419
::mlir::StringAttr getArgAttrsAttrName()
Definition Ops.h.inc:815
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1596
ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1166
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1782
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1654
FoldAdaptor::Properties Properties
Definition Ops.h.inc:1210
static ReturnOp create(::mlir::OpBuilder &builder, ::mlir::Location location)
Definition Ops.cpp.inc:1666
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1657
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1600
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1733
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState)
Definition Ops.cpp.inc:1661
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1642
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:1222
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1624
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:1794
::llvm::LogicalResult verify()
Definition Ops.cpp:526
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:1217
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1651
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1647
::mlir::MutableOperandRange getOperandsMutable()
Definition Ops.cpp.inc:1618
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1633
::mlir::Operation::operand_range getOperands()
Definition Ops.h.inc:1228
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1746
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1752
CallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:232
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:261
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:186
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:181
::std::optional< ::mlir::ArrayAttr > getTemplateParams()
Definition Ops.cpp.inc:166
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.cpp.inc:171
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:228
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:152
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:176
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:191
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:982
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:977
FuncDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:708
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:704
ReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1142
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:1138
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1574
Common interface for constant parameter-like symbol operations that can be defined within a TemplateO...
void printTemplateParams(mlir::AsmPrinter &printer, mlir::ArrayAttr value)
Definition OpHelpers.h:198
mlir::ParseResult parseAttrDictWithWarnings(mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state)
Definition OpHelpers.h:151
bool isValidType(Type type)
void printMultiDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
Definition OpHelpers.h:144
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename mlir::PropertiesSelector< ConcreteOp >::type state)
Definition OpHelpers.h:158
mlir::ParseResult parseTemplateParams(mlir::AsmParser &parser, mlir::ArrayAttr &value)
Definition OpHelpers.h:165
mlir::ParseResult parseMultiDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &multiMapOperands, mlir::DenseI32ArrayAttr &numDimsPerMap)
Definition OpHelpers.h:136