LLZK 0.1.0
Veridise's ZK Language IR
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
26namespace llzk {
27namespace function {
28
29static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
30 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
31 unsigned valueIndex) {
32 if (!((::llzk::isValidType(type)))) {
33 return op->emitOpError(valueKind) << " #" << valueIndex
34 << " must be variadic of a valid LLZK type, but got " << type;
35 }
36 return ::mlir::success();
37}
38
39static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops2(
40 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
41 unsigned valueIndex) {
42 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
43 return op->emitOpError(valueKind) << " #" << valueIndex
44 << " must be variadic of index, but got " << type;
45 }
46 return ::mlir::success();
47}
48
49static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
50 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
51 if (attr && !((::llvm::isa<::mlir::SymbolRefAttr>(attr))))
52 return emitError() << "attribute '" << attrName
53 << "' failed to satisfy constraint: symbol reference attribute";
54 return ::mlir::success();
55}
56static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
57 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
58 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
59 return op->emitOpError();
60 });
61}
62
63static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
64 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
65 if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
66 return emitError() << "attribute '" << attrName
67 << "' failed to satisfy constraint: i32 dense array attribute";
68 return ::mlir::success();
69}
70static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
71 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
72 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
73 return op->emitOpError();
74 });
75}
76
77static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
78 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
79 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
80 return emitError() << "attribute '" << attrName
81 << "' failed to satisfy constraint: string attribute";
82 return ::mlir::success();
83}
84static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
85 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
86 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
87 return op->emitOpError();
88 });
89}
90
91static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
92 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
93 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())))))
94 return emitError() << "attribute '" << attrName
95 << "' failed to satisfy constraint: type attribute of function type";
96 return ::mlir::success();
97}
98static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
99 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
100 return __mlir_ods_local_attr_constraint_Ops4(attr, attrName, [op]() {
101 return op->emitOpError();
102 });
103}
104
105static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
106 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
107 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))); }))))
108 return emitError() << "attribute '" << attrName
109 << "' failed to satisfy constraint: Array of dictionary attributes";
110 return ::mlir::success();
111}
112static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
113 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
114 return __mlir_ods_local_attr_constraint_Ops5(attr, attrName, [op]() {
115 return op->emitOpError();
116 });
117}
118
119static ::llvm::LogicalResult __mlir_ods_local_region_constraint_Ops1(
120 ::mlir::Operation *op, ::mlir::Region &region, ::llvm::StringRef regionName,
121 unsigned regionIndex) {
122 if (!((true))) {
123 return op->emitOpError("region #") << regionIndex
124 << (regionName.empty() ? " " : " ('" + regionName + "') ")
125 << "failed to verify constraint: any region";
126 }
127 return ::mlir::success();
128}
129} // namespace function
130} // namespace llzk
131namespace llzk {
132namespace function {
133
134//===----------------------------------------------------------------------===//
135// ::llzk::function::CallOp definitions
136//===----------------------------------------------------------------------===//
137
138namespace detail {
139CallOpGenericAdaptorBase::CallOpGenericAdaptorBase(CallOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
140
141std::pair<unsigned, unsigned> CallOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
142 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
143
144 unsigned start = 0;
145 for (unsigned i = 0; i < index; ++i)
146 start += sizeAttr[i];
147 return {start, sizeAttr[index]};
148}
149
150::mlir::SymbolRefAttr CallOpGenericAdaptorBase::getCallee() {
151 auto attr = getCalleeAttr();
152 return attr;
153}
154
156 auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
157 return attr;
158}
159
161 auto attr = getNumDimsPerMapAttr();
162 return attr;
163}
164
166 auto attr = getMapOpGroupSizesAttr();
167 return attr;
168}
169
170} // namespace detail
172
173::llvm::LogicalResult CallOpAdaptor::verify(::mlir::Location loc) {
174 auto tblgen_callee = getProperties().callee; (void)tblgen_callee;
175 if (!tblgen_callee) return emitError(loc, "'function.call' op ""requires attribute 'callee'");
176 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
177 if (!tblgen_mapOpGroupSizes) return emitError(loc, "'function.call' op ""requires attribute 'mapOpGroupSizes'");
178 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
179
180 if (tblgen_callee && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_callee))))
181 return emitError(loc, "'function.call' op ""attribute 'callee' failed to satisfy constraint: symbol reference attribute");
182
183 if (tblgen_numDimsPerMap && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numDimsPerMap))))
184 return emitError(loc, "'function.call' op ""attribute 'numDimsPerMap' failed to satisfy constraint: i32 dense array attribute");
185
186 if (tblgen_mapOpGroupSizes && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_mapOpGroupSizes))))
187 return emitError(loc, "'function.call' op ""attribute 'mapOpGroupSizes' failed to satisfy constraint: i32 dense array attribute");
188 return ::mlir::success();
189}
190
191std::pair<unsigned, unsigned> CallOp::getODSOperandIndexAndLength(unsigned index) {
192 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
193
194 unsigned start = 0;
195 for (unsigned i = 0; i < index; ++i)
196 start += sizeAttr[i];
197 return {start, sizeAttr[index]};
198}
199
200::mlir::MutableOperandRange CallOp::getArgOperandsMutable() {
201 auto range = getODSOperandIndexAndLength(0);
202 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
203 return mutableRange;
204}
205
206::mlir::MutableOperandRangeRange CallOp::getMapOperandsMutable() {
207 auto range = getODSOperandIndexAndLength(1);
208 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
209 return mutableRange.split(*(*this)->getAttrDictionary().getNamed(getMapOpGroupSizesAttrName()));
210}
211
212std::pair<unsigned, unsigned> CallOp::getODSResultIndexAndLength(unsigned index) {
213 bool isVariadic[] = {true};
214 int prevVariadicCount = 0;
215 for (unsigned i = 0; i < index; ++i)
216 if (isVariadic[i]) ++prevVariadicCount;
217
218 // Calculate how many dynamic values a static variadic operand corresponds to.
219 // This assumes all static variadic operands have the same dynamic value count.
220 int variadicSize = (getOperation()->getNumResults() - 0) / 1;
221 // `index` passed in as the parameter is the static index which counts each
222 // operand (variadic or not) as size 1. So here for each previous static variadic
223 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
224 // value pack for this static operand starts.
225 int start = index + (variadicSize - 1) * prevVariadicCount;
226 int size = isVariadic[index] ? variadicSize : 1;
227 return {start, size};
228}
229
230::llvm::LogicalResult CallOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
231 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
232 if (!dict) {
233 emitError() << "expected DictionaryAttr to set properties";
234 return ::mlir::failure();
235 }
236
237 {
238 auto &propStorage = prop.callee;
239 auto attr = dict.get("callee");
240 if (attr) {
241 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
242 if (convertedAttr) {
243 propStorage = convertedAttr;
244 } else {
245 emitError() << "Invalid attribute `callee` in property conversion: " << attr;
246 return ::mlir::failure();
247 }
248 }
249 }
250
251 {
252 auto &propStorage = prop.mapOpGroupSizes;
253 auto attr = dict.get("mapOpGroupSizes");
254 if (attr) {
255 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
256 if (convertedAttr) {
257 propStorage = convertedAttr;
258 } else {
259 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
260 return ::mlir::failure();
261 }
262 }
263 }
264
265 {
266 auto &propStorage = prop.numDimsPerMap;
267 auto attr = dict.get("numDimsPerMap");
268 if (attr) {
269 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
270 if (convertedAttr) {
271 propStorage = convertedAttr;
272 } else {
273 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
274 return ::mlir::failure();
275 }
276 }
277 }
278{
279
280 auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
281 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {
282 return convertFromAttribute(propStorage, propAttr, emitError);
283 };
284 auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
285;
286 if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError)))
287 return ::mlir::failure();
288 }
289 return ::mlir::success();
290}
291
292::mlir::Attribute CallOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
293 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
294 ::mlir::Builder odsBuilder{ctx};
295
296 {
297 const auto &propStorage = prop.callee;
298 if (propStorage)
299 attrs.push_back(odsBuilder.getNamedAttr("callee",
300 propStorage));
301 }
302
303 {
304 const auto &propStorage = prop.mapOpGroupSizes;
305 if (propStorage)
306 attrs.push_back(odsBuilder.getNamedAttr("mapOpGroupSizes",
307 propStorage));
308 }
309
310 {
311 const auto &propStorage = prop.numDimsPerMap;
312 if (propStorage)
313 attrs.push_back(odsBuilder.getNamedAttr("numDimsPerMap",
314 propStorage));
315 }
316
317 {
318 const auto &propStorage = prop.operandSegmentSizes;
319 auto attr = [&]() -> ::mlir::Attribute {
320 return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
321 }();
322 attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
323 }
324
325 if (!attrs.empty())
326 return odsBuilder.getDictionaryAttr(attrs);
327 return {};
328}
329
330llvm::hash_code CallOp::computePropertiesHash(const Properties &prop) {
331 auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code {
332 return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
333 };
334 return llvm::hash_combine(
335 llvm::hash_value(prop.callee.getAsOpaquePointer()),
336 llvm::hash_value(prop.mapOpGroupSizes.getAsOpaquePointer()),
337 llvm::hash_value(prop.numDimsPerMap.getAsOpaquePointer()),
338 hash_operandSegmentSizes(prop.operandSegmentSizes));
339}
340
341std::optional<mlir::Attribute> CallOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
342 if (name == "callee")
343 return prop.callee;
344
345 if (name == "mapOpGroupSizes")
346 return prop.mapOpGroupSizes;
347
348 if (name == "numDimsPerMap")
349 return prop.numDimsPerMap;
350 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
351 return std::nullopt;
352}
353
354void CallOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
355 if (name == "callee") {
356 prop.callee = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.callee)>>(value);
357 return;
358 }
359
360 if (name == "mapOpGroupSizes") {
361 prop.mapOpGroupSizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapOpGroupSizes)>>(value);
362 return;
363 }
364
365 if (name == "numDimsPerMap") {
366 prop.numDimsPerMap = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDimsPerMap)>>(value);
367 return;
368 }
369 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") {
370 auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value);
371 if (!arrAttr) return;
372 if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t))
373 return;
374 llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin());
375 return;
376 }
377}
378
379void CallOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
380 if (prop.callee) attrs.append("callee", prop.callee);
381
382 if (prop.mapOpGroupSizes) attrs.append("mapOpGroupSizes", prop.mapOpGroupSizes);
383
384 if (prop.numDimsPerMap) attrs.append("numDimsPerMap", prop.numDimsPerMap);
385 attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
386}
387
388::llvm::LogicalResult CallOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
389 {
390 ::mlir::Attribute attr = attrs.get(getCalleeAttrName(opName));
391 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "callee", emitError)))
392 return ::mlir::failure();
393 }
394
395 {
396 ::mlir::Attribute attr = attrs.get(getMapOpGroupSizesAttrName(opName));
397 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "mapOpGroupSizes", emitError)))
398 return ::mlir::failure();
399 }
400
401 {
402 ::mlir::Attribute attr = attrs.get(getNumDimsPerMapAttrName(opName));
403 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "numDimsPerMap", emitError)))
404 return ::mlir::failure();
405 }
406 return ::mlir::success();
407}
408
409::llvm::LogicalResult CallOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
410 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
411 if (::mlir::failed(reader.readAttribute(prop.callee)))
412 return ::mlir::failure();
413
414 if (::mlir::failed(reader.readAttribute(prop.mapOpGroupSizes)))
415 return ::mlir::failure();
416
417 if (::mlir::failed(reader.readOptionalAttribute(prop.numDimsPerMap)))
418 return ::mlir::failure();
419
420 if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
421 auto &propStorage = prop.operandSegmentSizes;
422 ::mlir::DenseI32ArrayAttr attr;
423 if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
424 if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
425 reader.emitError("size mismatch for operand/result_segment_size");
426 return ::mlir::failure();
427 }
428 ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
429 }
430
431 {
432 auto &propStorage = prop.operandSegmentSizes;
433 auto readProp = [&]() {
434
435 if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
436 return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
437;
438 return ::mlir::success();
439 };
440 if (::mlir::failed(readProp()))
441 return ::mlir::failure();
442 }
443 return ::mlir::success();
444}
445
446void CallOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
447 auto &prop = getProperties(); (void)prop;
448 writer.writeAttribute(prop.callee);
449 writer.writeAttribute(prop.mapOpGroupSizes);
450
451 writer.writeOptionalAttribute(prop.numDimsPerMap);
452
453if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
454 auto &propStorage = prop.operandSegmentSizes;
455 writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
456}
457
458 {
459 auto &propStorage = prop.operandSegmentSizes;
460
461 if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
462 writer.writeSparseArray(::llvm::ArrayRef(propStorage));
463;
464 }
465}
466
467::mlir::SymbolRefAttr CallOp::getCallee() {
468 auto attr = getCalleeAttr();
469 return attr;
470}
471
472::llvm::ArrayRef<int32_t> CallOp::getNumDimsPerMap() {
473 auto attr = getNumDimsPerMapAttr();
474 return attr;
475}
476
477::llvm::ArrayRef<int32_t> CallOp::getMapOpGroupSizes() {
478 auto attr = getMapOpGroupSizesAttr();
479 return attr;
480}
481
482void CallOp::setNumDimsPerMap(::llvm::ArrayRef<int32_t> attrValue) {
483 getProperties().numDimsPerMap = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
484}
485
486void CallOp::setMapOpGroupSizes(::llvm::ArrayRef<int32_t> attrValue) {
487 getProperties().mapOpGroupSizes = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
488}
489
490void 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) {
491 build(odsBuilder, odsState, resultTypes, callee, mapOperands,
492 odsBuilder.getDenseI32ArrayAttr(numDimsPerMap), argOperands);
493
494}
495
496void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::function::FuncDefOp callee, ::mlir::ValueRange argOperands) {
497 build(odsBuilder, odsState, callee.getResultTypes(),
498 callee.getFullyQualifiedName(false), argOperands);
499
500}
501
502void CallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::function::FuncDefOp callee, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::mlir::ValueRange argOperands) {
503 build(odsBuilder, odsState, callee.getResultTypes(),
504 callee.getFullyQualifiedName(false), mapOperands, numDimsPerMap, argOperands);
505
506}
507
508void 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) {
509 build(odsBuilder, odsState, callee, mapOperands,
510 odsBuilder.getDenseI32ArrayAttr(numDimsPerMap), argOperands);
511
512}
513
514void CallOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
515 ::mlir::Builder odsBuilder(opName.getContext());
516 if (!properties.numDimsPerMap)
517 properties.numDimsPerMap = odsBuilder.getDenseI32ArrayAttr({});
518}
519
520::llvm::LogicalResult CallOp::verifyInvariantsImpl() {
521 auto tblgen_callee = getProperties().callee; (void)tblgen_callee;
522 if (!tblgen_callee) return emitOpError("requires attribute 'callee'");
523 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
524 if (!tblgen_mapOpGroupSizes) return emitOpError("requires attribute 'mapOpGroupSizes'");
525 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
526
527 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_callee, "callee")))
528 return ::mlir::failure();
529
530 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_numDimsPerMap, "numDimsPerMap")))
531 return ::mlir::failure();
532
533 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_mapOpGroupSizes, "mapOpGroupSizes")))
534 return ::mlir::failure();
535 {
536 unsigned index = 0; (void)index;
537 auto valueGroup0 = getODSOperands(0);
538
539 for (auto v : valueGroup0) {
540 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
541 return ::mlir::failure();
542 }
543 auto valueGroup1 = getODSOperands(1);
544 if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr(*this, "mapOpGroupSizes", "mapOperands", valueGroup1.size())))
545 return ::mlir::failure();
546
547 for (auto v : valueGroup1) {
548 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
549 return ::mlir::failure();
550 }
551 }
552 {
553 unsigned index = 0; (void)index;
554 auto valueGroup0 = getODSResults(0);
555
556 for (auto v : valueGroup0) {
557 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
558 return ::mlir::failure();
559 }
560 }
561 return ::mlir::success();
562}
563
564::llvm::LogicalResult CallOp::verifyInvariants() {
565 return verifyInvariantsImpl();
566}
567
568::mlir::ParseResult CallOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
569 ::mlir::SymbolRefAttr calleeAttr;
570 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> argOperandsOperands;
571 ::llvm::SMLoc argOperandsOperandsLoc;
572 (void)argOperandsOperandsLoc;
573 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> mapOperandsOperands;
574 llvm::SmallVector<int32_t> mapOperandsOperandGroupSizes;
575 ::llvm::SMLoc mapOperandsOperandsLoc;
576 (void)mapOperandsOperandsLoc;
577 ::mlir::DenseI32ArrayAttr numDimsPerMapAttr;
578 ::llvm::ArrayRef<::mlir::Type> argOperandsTypes;
579 ::llvm::ArrayRef<::mlir::Type> allResultTypes;
580
581 if (parser.parseCustomAttributeWithFallback(calleeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
582 return ::mlir::failure();
583 }
584 if (calleeAttr) result.getOrAddProperties<CallOp::Properties>().callee = calleeAttr;
585 if (parser.parseLParen())
586 return ::mlir::failure();
587
588 argOperandsOperandsLoc = parser.getCurrentLocation();
589 if (parser.parseOperandList(argOperandsOperands))
590 return ::mlir::failure();
591 if (parser.parseRParen())
592 return ::mlir::failure();
593 if (::mlir::succeeded(parser.parseOptionalLBrace())) {
594 {
595 mapOperandsOperandsLoc = parser.getCurrentLocation();
596 ::llvm::SmallVector<::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand>> mapOperandsOperandGroups;
597 auto odsResult = parseMultiDimAndSymbolList(parser, mapOperandsOperandGroups, numDimsPerMapAttr);
598 if (odsResult) return ::mlir::failure();
599 for (const auto &subRange : mapOperandsOperandGroups) {
600 mapOperandsOperands.append(subRange.begin(), subRange.end());
601 mapOperandsOperandGroupSizes.push_back(subRange.size());
602 }
603 if (numDimsPerMapAttr)
604 result.getOrAddProperties<CallOp::Properties>().numDimsPerMap = numDimsPerMapAttr;
605 }
606 if (parser.parseRBrace())
607 return ::mlir::failure();
608 }
609 if (parser.parseColon())
610 return ::mlir::failure();
611
612 ::mlir::FunctionType argOperands__allResult_functionType;
613 if (parser.parseType(argOperands__allResult_functionType))
614 return ::mlir::failure();
615 argOperandsTypes = argOperands__allResult_functionType.getInputs();
616 allResultTypes = argOperands__allResult_functionType.getResults();
617 {
618 auto odsResult = parseAttrDictWithWarnings(parser, result.attributes, result);
619 if (odsResult) return ::mlir::failure();
620 }
621::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(argOperandsOperands.size()), static_cast<int32_t>(mapOperandsOperands.size())}), result.getOrAddProperties<CallOp::Properties>().operandSegmentSizes.begin());
622 result.getOrAddProperties<CallOp::Properties>().mapOpGroupSizes = parser.getBuilder().getDenseI32ArrayAttr(mapOperandsOperandGroupSizes);
623 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
624 result.addTypes(allResultTypes);
625 if (parser.resolveOperands(argOperandsOperands, argOperandsTypes, argOperandsOperandsLoc, result.operands))
626 return ::mlir::failure();
627 if (parser.resolveOperands(mapOperandsOperands, odsBuildableType0, mapOperandsOperandsLoc, result.operands))
628 return ::mlir::failure();
629 return ::mlir::success();
630}
631
632::llvm::LogicalResult CallOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
633 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
634 if (!dict) {
635 emitError() << "expected DictionaryAttr to set properties";
636 return ::mlir::failure();
637 }
638 {
639
640 auto &propStorage = prop.mapOpGroupSizes;
641 auto attr = dict.get("mapOpGroupSizes");
642 if (attr || /*isRequired=*/true) {
643 if (!attr) {
644 emitError() << "expected key entry for mapOpGroupSizes in DictionaryAttr to set "
645 "Properties.";
646 return ::mlir::failure();
647 }
648 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
649 if (convertedAttr) {
650 propStorage = convertedAttr;
651 } else {
652 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
653 return ::mlir::failure();
654 }
655 }
656 }
657 return ::mlir::success();
658}
659
660void CallOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
661 _odsPrinter << ' ';
662 _odsPrinter.printAttributeWithoutType(getCalleeAttr());
663 _odsPrinter << "(";
664 _odsPrinter << getArgOperands();
665 _odsPrinter << ")";
666 if (((!getMapOperands().empty()) || (getNumDimsPerMapAttr() != ::mlir::OpBuilder((*this)->getContext()).getDenseI32ArrayAttr({})))) {
667 _odsPrinter << ' ' << "{";
669 _odsPrinter << "}";
670 }
671 _odsPrinter << ' ' << ":";
672 _odsPrinter << ' ';
673 _odsPrinter.printFunctionalType(getArgOperands().getTypes(), getOperation()->getResultTypes());
674 _odsPrinter << ' ';
675 printAttrDictWithWarnings(_odsPrinter, *this, getOperation()->getAttrDictionary(), getProperties());
676}
677
678} // namespace function
679} // namespace llzk
680MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::CallOp)
681
682namespace llzk {
683namespace function {
684
685//===----------------------------------------------------------------------===//
686// ::llzk::function::FuncDefOp definitions
687//===----------------------------------------------------------------------===//
688
689namespace detail {
691
693 auto attr = getSymNameAttr();
694 return attr.getValue();
695}
696
698 auto attr = getFunctionTypeAttr();
699 return ::llvm::cast<::mlir::FunctionType>(attr.getValue());
700}
701
702::std::optional< ::mlir::ArrayAttr > FuncDefOpGenericAdaptorBase::getArgAttrs() {
703 auto attr = getArgAttrsAttr();
704 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
705}
706
707::std::optional< ::mlir::ArrayAttr > FuncDefOpGenericAdaptorBase::getResAttrs() {
708 auto attr = getResAttrsAttr();
709 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
710}
711
712} // namespace detail
714
715::llvm::LogicalResult FuncDefOpAdaptor::verify(::mlir::Location loc) {
716 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
717 auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type;
718 if (!tblgen_function_type) return emitError(loc, "'function.def' op ""requires attribute 'function_type'");
719 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
720 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
721 if (!tblgen_sym_name) return emitError(loc, "'function.def' op ""requires attribute 'sym_name'");
722
723 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
724 return emitError(loc, "'function.def' op ""attribute 'sym_name' failed to satisfy constraint: string attribute");
725
726 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())))))
727 return emitError(loc, "'function.def' op ""attribute 'function_type' failed to satisfy constraint: type attribute of function type");
728
729 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))); }))))
730 return emitError(loc, "'function.def' op ""attribute 'arg_attrs' failed to satisfy constraint: Array of dictionary attributes");
731
732 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))); }))))
733 return emitError(loc, "'function.def' op ""attribute 'res_attrs' failed to satisfy constraint: Array of dictionary attributes");
734 return ::mlir::success();
735}
736
737::llvm::LogicalResult FuncDefOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
738 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
739 if (!dict) {
740 emitError() << "expected DictionaryAttr to set properties";
741 return ::mlir::failure();
742 }
743
744 {
745 auto &propStorage = prop.arg_attrs;
746 auto attr = dict.get("arg_attrs");
747 if (attr) {
748 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
749 if (convertedAttr) {
750 propStorage = convertedAttr;
751 } else {
752 emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr;
753 return ::mlir::failure();
754 }
755 }
756 }
757
758 {
759 auto &propStorage = prop.function_type;
760 auto attr = dict.get("function_type");
761 if (attr) {
762 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
763 if (convertedAttr) {
764 propStorage = convertedAttr;
765 } else {
766 emitError() << "Invalid attribute `function_type` in property conversion: " << attr;
767 return ::mlir::failure();
768 }
769 }
770 }
771
772 {
773 auto &propStorage = prop.res_attrs;
774 auto attr = dict.get("res_attrs");
775 if (attr) {
776 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
777 if (convertedAttr) {
778 propStorage = convertedAttr;
779 } else {
780 emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr;
781 return ::mlir::failure();
782 }
783 }
784 }
785
786 {
787 auto &propStorage = prop.sym_name;
788 auto attr = dict.get("sym_name");
789 if (attr) {
790 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
791 if (convertedAttr) {
792 propStorage = convertedAttr;
793 } else {
794 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
795 return ::mlir::failure();
796 }
797 }
798 }
799 return ::mlir::success();
800}
801
802::mlir::Attribute FuncDefOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
803 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
804 ::mlir::Builder odsBuilder{ctx};
805
806 {
807 const auto &propStorage = prop.arg_attrs;
808 if (propStorage)
809 attrs.push_back(odsBuilder.getNamedAttr("arg_attrs",
810 propStorage));
811 }
812
813 {
814 const auto &propStorage = prop.function_type;
815 if (propStorage)
816 attrs.push_back(odsBuilder.getNamedAttr("function_type",
817 propStorage));
818 }
819
820 {
821 const auto &propStorage = prop.res_attrs;
822 if (propStorage)
823 attrs.push_back(odsBuilder.getNamedAttr("res_attrs",
824 propStorage));
825 }
826
827 {
828 const auto &propStorage = prop.sym_name;
829 if (propStorage)
830 attrs.push_back(odsBuilder.getNamedAttr("sym_name",
831 propStorage));
832 }
833
834 if (!attrs.empty())
835 return odsBuilder.getDictionaryAttr(attrs);
836 return {};
837}
838
839llvm::hash_code FuncDefOp::computePropertiesHash(const Properties &prop) {
840 return llvm::hash_combine(
841 llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()),
842 llvm::hash_value(prop.function_type.getAsOpaquePointer()),
843 llvm::hash_value(prop.res_attrs.getAsOpaquePointer()),
844 llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
845}
846
847std::optional<mlir::Attribute> FuncDefOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
848 if (name == "arg_attrs")
849 return prop.arg_attrs;
850
851 if (name == "function_type")
852 return prop.function_type;
853
854 if (name == "res_attrs")
855 return prop.res_attrs;
856
857 if (name == "sym_name")
858 return prop.sym_name;
859 return std::nullopt;
860}
861
862void FuncDefOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
863 if (name == "arg_attrs") {
864 prop.arg_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.arg_attrs)>>(value);
865 return;
866 }
867
868 if (name == "function_type") {
869 prop.function_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.function_type)>>(value);
870 return;
871 }
872
873 if (name == "res_attrs") {
874 prop.res_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.res_attrs)>>(value);
875 return;
876 }
877
878 if (name == "sym_name") {
879 prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
880 return;
881 }
882}
883
884void FuncDefOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
885 if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs);
886
887 if (prop.function_type) attrs.append("function_type", prop.function_type);
888
889 if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs);
890
891 if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
892}
893
894::llvm::LogicalResult FuncDefOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
895 {
896 ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName));
897 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(attr, "arg_attrs", emitError)))
898 return ::mlir::failure();
899 }
900
901 {
902 ::mlir::Attribute attr = attrs.get(getFunctionTypeAttrName(opName));
903 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "function_type", emitError)))
904 return ::mlir::failure();
905 }
906
907 {
908 ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName));
909 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(attr, "res_attrs", emitError)))
910 return ::mlir::failure();
911 }
912
913 {
914 ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
915 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "sym_name", emitError)))
916 return ::mlir::failure();
917 }
918 return ::mlir::success();
919}
920
921::llvm::LogicalResult FuncDefOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
922 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
923 if (::mlir::failed(reader.readOptionalAttribute(prop.arg_attrs)))
924 return ::mlir::failure();
925
926 if (::mlir::failed(reader.readAttribute(prop.function_type)))
927 return ::mlir::failure();
928
929 if (::mlir::failed(reader.readOptionalAttribute(prop.res_attrs)))
930 return ::mlir::failure();
931
932 if (::mlir::failed(reader.readAttribute(prop.sym_name)))
933 return ::mlir::failure();
934 return ::mlir::success();
935}
936
937void FuncDefOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
938 auto &prop = getProperties(); (void)prop;
939
940 writer.writeOptionalAttribute(prop.arg_attrs);
941 writer.writeAttribute(prop.function_type);
942
943 writer.writeOptionalAttribute(prop.res_attrs);
944 writer.writeAttribute(prop.sym_name);
945}
946
947::llvm::StringRef FuncDefOp::getSymName() {
948 auto attr = getSymNameAttr();
949 return attr.getValue();
950}
951
952::mlir::FunctionType FuncDefOp::getFunctionType() {
953 auto attr = getFunctionTypeAttr();
954 return ::llvm::cast<::mlir::FunctionType>(attr.getValue());
955}
956
957::std::optional< ::mlir::ArrayAttr > FuncDefOp::getArgAttrs() {
958 auto attr = getArgAttrsAttr();
959 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
960}
961
962::std::optional< ::mlir::ArrayAttr > FuncDefOp::getResAttrs() {
963 auto attr = getResAttrsAttr();
964 return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt);
965}
966
967void FuncDefOp::setSymName(::llvm::StringRef attrValue) {
968 getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
969}
970
971void FuncDefOp::setFunctionType(::mlir::FunctionType attrValue) {
972 getProperties().function_type = ::mlir::TypeAttr::get(attrValue);
973}
974
975void 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) {
976 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
977 odsState.getOrAddProperties<Properties>().function_type = function_type;
978 if (arg_attrs) {
979 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
980 }
981 if (res_attrs) {
982 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
983 }
984 (void)odsState.addRegion();
985}
986
987void 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) {
988 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
989 odsState.getOrAddProperties<Properties>().function_type = function_type;
990 if (arg_attrs) {
991 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
992 }
993 if (res_attrs) {
994 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
995 }
996 (void)odsState.addRegion();
997 assert(resultTypes.size() == 0u && "mismatched number of results");
998 odsState.addTypes(resultTypes);
999}
1000
1001void 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) {
1002 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
1003 odsState.getOrAddProperties<Properties>().function_type = ::mlir::TypeAttr::get(function_type);
1004 if (arg_attrs) {
1005 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1006 }
1007 if (res_attrs) {
1008 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1009 }
1010 (void)odsState.addRegion();
1011}
1012
1013void 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) {
1014 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
1015 odsState.getOrAddProperties<Properties>().function_type = ::mlir::TypeAttr::get(function_type);
1016 if (arg_attrs) {
1017 odsState.getOrAddProperties<Properties>().arg_attrs = arg_attrs;
1018 }
1019 if (res_attrs) {
1020 odsState.getOrAddProperties<Properties>().res_attrs = res_attrs;
1021 }
1022 (void)odsState.addRegion();
1023 assert(resultTypes.size() == 0u && "mismatched number of results");
1024 odsState.addTypes(resultTypes);
1025}
1026
1027void FuncDefOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1028 assert(operands.size() == 0u && "mismatched number of parameters");
1029 odsState.addOperands(operands);
1030 odsState.addAttributes(attributes);
1031 for (unsigned i = 0; i != 1; ++i)
1032 (void)odsState.addRegion();
1033 assert(resultTypes.size() == 0u && "mismatched number of return types");
1034 odsState.addTypes(resultTypes);
1035
1036 if (!attributes.empty()) {
1037 ::mlir::OpaqueProperties properties =
1038 &odsState.getOrAddProperties<FuncDefOp::Properties>();
1039 std::optional<::mlir::RegisteredOperationName> info =
1040 odsState.name.getRegisteredInfo();
1041 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
1042 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
1043 ::llvm::report_fatal_error("Property conversion failed.");
1044 }
1045}
1046
1047::llvm::LogicalResult FuncDefOp::verifyInvariantsImpl() {
1048 auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs;
1049 auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type;
1050 if (!tblgen_function_type) return emitOpError("requires attribute 'function_type'");
1051 auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs;
1052 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
1053 if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
1054
1055 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_sym_name, "sym_name")))
1056 return ::mlir::failure();
1057
1058 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_function_type, "function_type")))
1059 return ::mlir::failure();
1060
1061 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(*this, tblgen_arg_attrs, "arg_attrs")))
1062 return ::mlir::failure();
1063
1064 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(*this, tblgen_res_attrs, "res_attrs")))
1065 return ::mlir::failure();
1066 {
1067 unsigned index = 0; (void)index;
1068
1069 for (auto &region : ::llvm::MutableArrayRef((*this)->getRegion(0)))
1070 if (::mlir::failed(__mlir_ods_local_region_constraint_Ops1(*this, region, "body", index++)))
1071 return ::mlir::failure();
1072 }
1073 return ::mlir::success();
1074}
1075
1076::llvm::LogicalResult FuncDefOp::verifyInvariants() {
1077 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1078 return ::mlir::success();
1079 return ::mlir::failure();
1080}
1081
1082} // namespace function
1083} // namespace llzk
1084MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::FuncDefOp)
1085
1086namespace llzk {
1087namespace function {
1088
1089//===----------------------------------------------------------------------===//
1090// ::llzk::function::ReturnOp definitions
1091//===----------------------------------------------------------------------===//
1092
1093namespace detail {
1094std::pair<unsigned, unsigned> ReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1095 bool isVariadic[] = {true};
1096 int prevVariadicCount = 0;
1097 for (unsigned i = 0; i < index; ++i)
1098 if (isVariadic[i]) ++prevVariadicCount;
1099
1100 // Calculate how many dynamic values a static variadic operand corresponds to.
1101 // This assumes all static variadic operands have the same dynamic value count.
1102 int variadicSize = (odsOperandsSize - 0) / 1;
1103 // `index` passed in as the parameter is the static index which counts each
1104 // operand (variadic or not) as size 1. So here for each previous static variadic
1105 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1106 // value pack for this static operand starts.
1107 int start = index + (variadicSize - 1) * prevVariadicCount;
1108 int size = isVariadic[index] ? variadicSize : 1;
1109 return {start, size};
1110}
1111
1112} // namespace detail
1114
1115::llvm::LogicalResult ReturnOpAdaptor::verify(::mlir::Location loc) {
1116 return ::mlir::success();
1117}
1118
1119std::pair<unsigned, unsigned> ReturnOp::getODSOperandIndexAndLength(unsigned index) {
1120 bool isVariadic[] = {true};
1121 int prevVariadicCount = 0;
1122 for (unsigned i = 0; i < index; ++i)
1123 if (isVariadic[i]) ++prevVariadicCount;
1124
1125 // Calculate how many dynamic values a static variadic operand corresponds to.
1126 // This assumes all static variadic operands have the same dynamic value count.
1127 int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
1128 // `index` passed in as the parameter is the static index which counts each
1129 // operand (variadic or not) as size 1. So here for each previous static variadic
1130 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1131 // value pack for this static operand starts.
1132 int start = index + (variadicSize - 1) * prevVariadicCount;
1133 int size = isVariadic[index] ? variadicSize : 1;
1134 return {start, size};
1135}
1136
1137::mlir::MutableOperandRange ReturnOp::getOperandsMutable() {
1138 auto range = getODSOperandIndexAndLength(0);
1139 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1140 return mutableRange;
1141}
1142
1143void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {
1144 build(odsBuilder, odsState, std::nullopt);
1145
1146}
1147
1148void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) {
1149 odsState.addOperands(operands);
1150}
1151
1152void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1153 odsState.addOperands(operands);
1154 odsState.addAttributes(attributes);
1155 assert(resultTypes.size() == 0u && "mismatched number of return types");
1156 odsState.addTypes(resultTypes);
1157}
1158
1159::llvm::LogicalResult ReturnOp::verifyInvariantsImpl() {
1160 {
1161 unsigned index = 0; (void)index;
1162 auto valueGroup0 = getODSOperands(0);
1163
1164 for (auto v : valueGroup0) {
1165 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1166 return ::mlir::failure();
1167 }
1168 }
1169 return ::mlir::success();
1170}
1171
1172::llvm::LogicalResult ReturnOp::verifyInvariants() {
1173 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1174 return ::mlir::success();
1175 return ::mlir::failure();
1176}
1177
1178::mlir::ParseResult ReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1179 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands;
1180 ::llvm::SMLoc operandsOperandsLoc;
1181 (void)operandsOperandsLoc;
1182 ::llvm::SmallVector<::mlir::Type, 1> operandsTypes;
1183 {
1184 auto loc = parser.getCurrentLocation();(void)loc;
1185 if (parser.parseOptionalAttrDict(result.attributes))
1186 return ::mlir::failure();
1187 }
1188
1189 operandsOperandsLoc = parser.getCurrentLocation();
1190 if (parser.parseOperandList(operandsOperands))
1191 return ::mlir::failure();
1192 if (!operandsOperands.empty()) {
1193 if (parser.parseColon())
1194 return ::mlir::failure();
1195
1196 if (parser.parseTypeList(operandsTypes))
1197 return ::mlir::failure();
1198 }
1199 if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands))
1200 return ::mlir::failure();
1201 return ::mlir::success();
1202}
1203
1204void ReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1205 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1206 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1207 if (!getOperands().empty()) {
1208 _odsPrinter << ' ';
1209 _odsPrinter << getOperands();
1210 _odsPrinter << ' ' << ":";
1211 _odsPrinter << ' ';
1212 _odsPrinter << getOperands().getTypes();
1213 }
1214}
1215
1216void ReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
1217}
1218
1219::mlir::MutableOperandRange ReturnOp::getMutableSuccessorOperands(
1220 ::mlir::RegionBranchPoint point) {
1221 return ::mlir::MutableOperandRange(*this);
1222}
1223
1224} // namespace function
1225} // namespace llzk
1226MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::function::ReturnOp)
1227
1228
1229#endif // GET_OP_CLASSES
1230
MlirStringRef name
Definition Poly.cpp:48
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:173
CallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:133
void setNumDimsPerMap(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:482
::mlir::SymbolRefAttr getCalleeAttr()
Definition Ops.h.inc:267
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:379
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:388
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:330
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:514
::mlir::SymbolRefAttr getCallee()
Definition Ops.cpp.inc:467
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:212
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:341
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:632
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:446
void setMapOpGroupSizes(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:486
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:230
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:354
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr callee, ::mlir::ValueRange argOperands={})
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:477
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:191
::mlir::MutableOperandRange getArgOperandsMutable()
Definition Ops.cpp.inc:200
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:472
::mlir::Operation::operand_range getArgOperands()
Definition Ops.h.inc:241
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:564
::mlir::StringAttr getMapOpGroupSizesAttrName()
Definition Ops.h.inc:206
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:568
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:660
::mlir::OperandRangeRange getMapOperands()
Definition Ops.h.inc:245
FoldAdaptor::Properties Properties
Definition Ops.h.inc:192
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:277
::mlir::StringAttr getNumDimsPerMapAttrName()
Definition Ops.h.inc:214
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:292
::mlir::MutableOperandRangeRange getMapOperandsMutable()
Definition Ops.cpp.inc:206
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:409
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:520
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:252
::mlir::StringAttr getCalleeAttrName()
Definition Ops.h.inc:198
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.h.inc:272
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:235
FuncDefOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:490
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:715
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:862
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:839
FoldAdaptor::Properties Properties
Definition Ops.h.inc:533
::mlir::FunctionType getFunctionType()
Definition Ops.cpp.inc:952
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:563
::mlir::StringAttr getFunctionTypeAttrName()
Definition Ops.h.inc:547
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1076
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:847
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:921
::mlir::StringAttr getResAttrsAttrName()
Definition Ops.h.inc:555
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:962
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:957
::mlir::ArrayAttr getArgAttrsAttr()
Definition Ops.h.inc:618
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:802
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:884
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:937
::llvm::StringRef getSymName()
Definition Ops.cpp.inc:947
void setFunctionType(::mlir::FunctionType attrValue)
Definition Ops.cpp.inc:971
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:737
::llvm::ArrayRef<::mlir::Type > getResultTypes()
Returns the result types of this function.
Definition Ops.h.inc:740
void setSymName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:967
::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:323
::mlir::TypeAttr getFunctionTypeAttr()
Definition Ops.h.inc:613
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:894
::llvm::LogicalResult verify()
Definition Ops.cpp:213
::mlir::StringAttr getSymNameAttr()
Definition Ops.h.inc:608
::mlir::ArrayAttr getResAttrsAttr()
Definition Ops.h.inc:623
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1047
::mlir::StringAttr getArgAttrsAttrName()
Definition Ops.h.inc:539
ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs={}, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:828
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1115
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1204
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1119
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1159
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState)
Definition Ops.cpp.inc:1143
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:878
::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point)
Definition Ops.cpp.inc:1219
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:1216
::llvm::LogicalResult verify()
Definition Ops.cpp:366
::mlir::MutableOperandRange getOperandsMutable()
Definition Ops.cpp.inc:1137
::mlir::Operation::operand_range getOperands()
Definition Ops.h.inc:884
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1172
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1178
CallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:97
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:120
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:165
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.cpp.inc:155
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:93
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:141
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:160
::std::optional< ::mlir::ArrayAttr > getResAttrs()
Definition Ops.cpp.inc:707
::std::optional< ::mlir::ArrayAttr > getArgAttrs()
Definition Ops.cpp.inc:702
FuncDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:433
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:429
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1094
mlir::ParseResult parseAttrDictWithWarnings(mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state)
Definition OpHelpers.h:122
bool isValidType(Type type)
void printMultiDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
Definition OpHelpers.h:115
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename mlir::PropertiesSelector< ConcreteOp >::type state)
Definition OpHelpers.h:129
mlir::ParseResult parseMultiDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &multiMapOperands, mlir::DenseI32ArrayAttr &numDimsPerMap)
Definition OpHelpers.h:107