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 polymorphic {
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 (!((::llvm::isa<::mlir::IndexType>(type)))) {
33 return op->emitOpError(valueKind) << " #" << valueIndex
34 << " must be variadic of index, 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 index, but got " << type;
45 }
46 return ::mlir::success();
47}
48
49static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops3(
50 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
51 unsigned valueIndex) {
52 if (!((::llzk::isValidConstReadType(type)))) {
53 return op->emitOpError(valueKind) << " #" << valueIndex
54 << " must be integral, felt, or typevar type, but got " << type;
55 }
56 return ::mlir::success();
57}
58
59static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops4(
60 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
61 unsigned valueIndex) {
62 if (!((::llzk::isValidType(type)))) {
63 return op->emitOpError(valueKind) << " #" << valueIndex
64 << " must be a valid LLZK type, but got " << type;
65 }
66 return ::mlir::success();
67}
68
69static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
70 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
71 if (attr && !((::llvm::isa<::mlir::AffineMapAttr>(attr))))
72 return emitError() << "attribute '" << attrName
73 << "' failed to satisfy constraint: AffineMap attribute";
74 return ::mlir::success();
75}
76static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
77 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
78 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
79 return op->emitOpError();
80 });
81}
82
83static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
84 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
85 if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(attr).getType())))))
86 return emitError() << "attribute '" << attrName
87 << "' failed to satisfy constraint: index attribute";
88 return ::mlir::success();
89}
90static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
91 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
92 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
93 return op->emitOpError();
94 });
95}
96
97static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
98 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
99 if (attr && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr))))
100 return emitError() << "attribute '" << attrName
101 << "' failed to satisfy constraint: flat symbol reference attribute";
102 return ::mlir::success();
103}
104static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
105 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
106 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
107 return op->emitOpError();
108 });
109}
110} // namespace polymorphic
111} // namespace llzk
112namespace llzk {
113namespace polymorphic {
114
115//===----------------------------------------------------------------------===//
116// ::llzk::polymorphic::ApplyMapOp definitions
117//===----------------------------------------------------------------------===//
118
119namespace detail {
120ApplyMapOpGenericAdaptorBase::ApplyMapOpGenericAdaptorBase(ApplyMapOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
121
122std::pair<unsigned, unsigned> ApplyMapOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
123 bool isVariadic[] = {true};
124 int prevVariadicCount = 0;
125 for (unsigned i = 0; i < index; ++i)
126 if (isVariadic[i]) ++prevVariadicCount;
127
128 // Calculate how many dynamic values a static variadic operand corresponds to.
129 // This assumes all static variadic operands have the same dynamic value count.
130 int variadicSize = (odsOperandsSize - 0) / 1;
131 // `index` passed in as the parameter is the static index which counts each
132 // operand (variadic or not) as size 1. So here for each previous static variadic
133 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
134 // value pack for this static operand starts.
135 int start = index + (variadicSize - 1) * prevVariadicCount;
136 int size = isVariadic[index] ? variadicSize : 1;
137 return {start, size};
138}
139
141 auto attr = getMapAttr();
142 return attr.getValue();
143}
144
146 auto attr = getNumDimsAttr();
147 return attr.getValue();
148}
149
150} // namespace detail
152
153::llvm::LogicalResult ApplyMapOpAdaptor::verify(::mlir::Location loc) {
154 auto tblgen_map = getProperties().map; (void)tblgen_map;
155 if (!tblgen_map) return emitError(loc, "'poly.applymap' op ""requires attribute 'map'");
156 auto tblgen_numDims = getProperties().numDims; (void)tblgen_numDims;
157 if (!tblgen_numDims) return emitError(loc, "'poly.applymap' op ""requires attribute 'numDims'");
158
159 if (tblgen_map && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_map))))
160 return emitError(loc, "'poly.applymap' op ""attribute 'map' failed to satisfy constraint: AffineMap attribute");
161
162 if (tblgen_numDims && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_numDims))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_numDims).getType())))))
163 return emitError(loc, "'poly.applymap' op ""attribute 'numDims' failed to satisfy constraint: index attribute");
164 return ::mlir::success();
165}
166
167std::pair<unsigned, unsigned> ApplyMapOp::getODSOperandIndexAndLength(unsigned index) {
168 bool isVariadic[] = {true};
169 int prevVariadicCount = 0;
170 for (unsigned i = 0; i < index; ++i)
171 if (isVariadic[i]) ++prevVariadicCount;
172
173 // Calculate how many dynamic values a static variadic operand corresponds to.
174 // This assumes all static variadic operands have the same dynamic value count.
175 int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
176 // `index` passed in as the parameter is the static index which counts each
177 // operand (variadic or not) as size 1. So here for each previous static variadic
178 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
179 // value pack for this static operand starts.
180 int start = index + (variadicSize - 1) * prevVariadicCount;
181 int size = isVariadic[index] ? variadicSize : 1;
182 return {start, size};
183}
184
185::mlir::MutableOperandRange ApplyMapOp::getMapOperandsMutable() {
186 auto range = getODSOperandIndexAndLength(0);
187 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
188 return mutableRange;
189}
190
191::llvm::LogicalResult ApplyMapOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
192 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
193 if (!dict) {
194 emitError() << "expected DictionaryAttr to set properties";
195 return ::mlir::failure();
196 }
197
198 {
199 auto &propStorage = prop.map;
200 auto attr = dict.get("map");
201 if (attr) {
202 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
203 if (convertedAttr) {
204 propStorage = convertedAttr;
205 } else {
206 emitError() << "Invalid attribute `map` in property conversion: " << attr;
207 return ::mlir::failure();
208 }
209 }
210 }
211
212 {
213 auto &propStorage = prop.numDims;
214 auto attr = dict.get("numDims");
215 if (attr) {
216 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
217 if (convertedAttr) {
218 propStorage = convertedAttr;
219 } else {
220 emitError() << "Invalid attribute `numDims` in property conversion: " << attr;
221 return ::mlir::failure();
222 }
223 }
224 }
225 return ::mlir::success();
226}
227
228::mlir::Attribute ApplyMapOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
229 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
230 ::mlir::Builder odsBuilder{ctx};
231
232 {
233 const auto &propStorage = prop.map;
234 if (propStorage)
235 attrs.push_back(odsBuilder.getNamedAttr("map",
236 propStorage));
237 }
238
239 {
240 const auto &propStorage = prop.numDims;
241 if (propStorage)
242 attrs.push_back(odsBuilder.getNamedAttr("numDims",
243 propStorage));
244 }
245
246 if (!attrs.empty())
247 return odsBuilder.getDictionaryAttr(attrs);
248 return {};
249}
250
251llvm::hash_code ApplyMapOp::computePropertiesHash(const Properties &prop) {
252 return llvm::hash_combine(
253 llvm::hash_value(prop.map.getAsOpaquePointer()),
254 llvm::hash_value(prop.numDims.getAsOpaquePointer()));
255}
256
257std::optional<mlir::Attribute> ApplyMapOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
258 if (name == "map")
259 return prop.map;
260
261 if (name == "numDims")
262 return prop.numDims;
263 return std::nullopt;
264}
265
266void ApplyMapOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
267 if (name == "map") {
268 prop.map = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.map)>>(value);
269 return;
270 }
271
272 if (name == "numDims") {
273 prop.numDims = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDims)>>(value);
274 return;
275 }
276}
277
278void ApplyMapOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
279 if (prop.map) attrs.append("map", prop.map);
280
281 if (prop.numDims) attrs.append("numDims", prop.numDims);
282}
283
284::llvm::LogicalResult ApplyMapOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
285 {
286 ::mlir::Attribute attr = attrs.get(getMapAttrName(opName));
287 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "map", emitError)))
288 return ::mlir::failure();
289 }
290
291 {
292 ::mlir::Attribute attr = attrs.get(getNumDimsAttrName(opName));
293 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "numDims", emitError)))
294 return ::mlir::failure();
295 }
296 return ::mlir::success();
297}
298
299::llvm::LogicalResult ApplyMapOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
300 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
301 if (::mlir::failed(reader.readAttribute(prop.map)))
302 return ::mlir::failure();
303
304 if (::mlir::failed(reader.readAttribute(prop.numDims)))
305 return ::mlir::failure();
306 return ::mlir::success();
307}
308
309void ApplyMapOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
310 auto &prop = getProperties(); (void)prop;
311 writer.writeAttribute(prop.map);
312 writer.writeAttribute(prop.numDims);
313}
314
315::mlir::AffineMap ApplyMapOp::getMap() {
316 auto attr = getMapAttr();
317 return attr.getValue();
318}
319
320::llvm::APInt ApplyMapOp::getNumDims() {
321 auto attr = getNumDimsAttr();
322 return attr.getValue();
323}
324
325void ApplyMapOp::setMap(::mlir::AffineMap attrValue) {
326 getProperties().map = ::mlir::AffineMapAttr::get(attrValue);
327}
328
329void ApplyMapOp::setNumDims(::llvm::APInt attrValue) {
330 getProperties().numDims = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue);
331}
332
333void ApplyMapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::AffineMapAttr map, ::mlir::ValueRange mapOperands) {
334 odsState.addOperands(mapOperands);
335 Properties &props = odsState.getOrAddProperties<Properties>();
336 props.setMap(map);
337 props.setNumDims(odsBuilder.getIntegerAttr(odsBuilder.getIndexType(),
338 map.getAffineMap().getNumDims()));
339 odsState.addTypes(odsBuilder.getIndexType());
340
341}
342
343void ApplyMapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::AffineMap map, ::mlir::ValueRange mapOperands) {
344 build(odsBuilder, odsState, ::mlir::AffineMapAttr::get(map), mapOperands);
345
346}
347
348void ApplyMapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::AffineExpr expr, ::mlir::ValueRange mapOperands) {
349 auto map = ::mlir::AffineMap::inferFromExprList({expr}, odsBuilder.getContext()).front();
350 build(odsBuilder, odsState, map, mapOperands);
351
352}
353
354::llvm::LogicalResult ApplyMapOp::verifyInvariantsImpl() {
355 auto tblgen_map = getProperties().map; (void)tblgen_map;
356 if (!tblgen_map) return emitOpError("requires attribute 'map'");
357 auto tblgen_numDims = getProperties().numDims; (void)tblgen_numDims;
358 if (!tblgen_numDims) return emitOpError("requires attribute 'numDims'");
359
360 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_map, "map")))
361 return ::mlir::failure();
362
363 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_numDims, "numDims")))
364 return ::mlir::failure();
365 {
366 unsigned index = 0; (void)index;
367 auto valueGroup0 = getODSOperands(0);
368
369 for (auto v : valueGroup0) {
370 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
371 return ::mlir::failure();
372 }
373 }
374 {
375 unsigned index = 0; (void)index;
376 auto valueGroup0 = getODSResults(0);
377
378 for (auto v : valueGroup0) {
379 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "result", index++)))
380 return ::mlir::failure();
381 }
382 }
383 return ::mlir::success();
384}
385
386::llvm::LogicalResult ApplyMapOp::verifyInvariants() {
387 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
388 return ::mlir::success();
389 return ::mlir::failure();
390}
391
392::mlir::ParseResult ApplyMapOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
393 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> mapOperandsOperands;
394 ::llvm::SMLoc mapOperandsOperandsLoc;
395 (void)mapOperandsOperandsLoc;
396 ::mlir::IntegerAttr numDimsAttr;
397 ::mlir::AffineMapAttr mapAttr;
398 {
399 mapOperandsOperandsLoc = parser.getCurrentLocation();
400 auto odsResult = parseDimAndSymbolList(parser, mapOperandsOperands, numDimsAttr);
401 if (odsResult) return ::mlir::failure();
402 result.getOrAddProperties<ApplyMapOp::Properties>().numDims = numDimsAttr;
403 }
404
405 if (parser.parseCustomAttributeWithFallback(mapAttr, parser.getBuilder().getIndexType())) {
406 return ::mlir::failure();
407 }
408 if (mapAttr) result.getOrAddProperties<ApplyMapOp::Properties>().map = mapAttr;
409 {
410 auto loc = parser.getCurrentLocation();(void)loc;
411 if (parser.parseOptionalAttrDict(result.attributes))
412 return ::mlir::failure();
413 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
414 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
415 })))
416 return ::mlir::failure();
417 }
418 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
419 result.addTypes(odsBuildableType0);
420 if (parser.resolveOperands(mapOperandsOperands, odsBuildableType0, mapOperandsOperandsLoc, result.operands))
421 return ::mlir::failure();
422 return ::mlir::success();
423}
424
425void ApplyMapOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
426 _odsPrinter << ' ';
427 printDimAndSymbolList(_odsPrinter, *this, getMapOperands(), getNumDimsAttr());
428 _odsPrinter << ' ';
429 _odsPrinter.printAttributeWithoutType(getMapAttr());
430 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
431 elidedAttrs.push_back("numDims");
432 elidedAttrs.push_back("map");
433 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
434}
435
436void ApplyMapOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
437}
438
439} // namespace polymorphic
440} // namespace llzk
441MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::polymorphic::ApplyMapOp)
442
443namespace llzk {
444namespace polymorphic {
445
446//===----------------------------------------------------------------------===//
447// ::llzk::polymorphic::ConstReadOp definitions
448//===----------------------------------------------------------------------===//
449
450namespace detail {
451ConstReadOpGenericAdaptorBase::ConstReadOpGenericAdaptorBase(ConstReadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
452
454 auto attr = getConstNameAttr();
455 return attr.getValue();
456}
457
458} // namespace detail
460
461::llvm::LogicalResult ConstReadOpAdaptor::verify(::mlir::Location loc) {
462 auto tblgen_const_name = getProperties().const_name; (void)tblgen_const_name;
463 if (!tblgen_const_name) return emitError(loc, "'poly.read_const' op ""requires attribute 'const_name'");
464
465 if (tblgen_const_name && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_const_name))))
466 return emitError(loc, "'poly.read_const' op ""attribute 'const_name' failed to satisfy constraint: flat symbol reference attribute");
467 return ::mlir::success();
468}
469
470::llvm::LogicalResult ConstReadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
471 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
472 if (!dict) {
473 emitError() << "expected DictionaryAttr to set properties";
474 return ::mlir::failure();
475 }
476
477 {
478 auto &propStorage = prop.const_name;
479 auto attr = dict.get("const_name");
480 if (attr) {
481 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
482 if (convertedAttr) {
483 propStorage = convertedAttr;
484 } else {
485 emitError() << "Invalid attribute `const_name` in property conversion: " << attr;
486 return ::mlir::failure();
487 }
488 }
489 }
490 return ::mlir::success();
491}
492
493::mlir::Attribute ConstReadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
494 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
495 ::mlir::Builder odsBuilder{ctx};
496
497 {
498 const auto &propStorage = prop.const_name;
499 if (propStorage)
500 attrs.push_back(odsBuilder.getNamedAttr("const_name",
501 propStorage));
502 }
503
504 if (!attrs.empty())
505 return odsBuilder.getDictionaryAttr(attrs);
506 return {};
507}
508
509llvm::hash_code ConstReadOp::computePropertiesHash(const Properties &prop) {
510 return llvm::hash_combine(
511 llvm::hash_value(prop.const_name.getAsOpaquePointer()));
512}
513
514std::optional<mlir::Attribute> ConstReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
515 if (name == "const_name")
516 return prop.const_name;
517 return std::nullopt;
518}
519
520void ConstReadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
521 if (name == "const_name") {
522 prop.const_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.const_name)>>(value);
523 return;
524 }
525}
526
527void ConstReadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
528 if (prop.const_name) attrs.append("const_name", prop.const_name);
529}
530
531::llvm::LogicalResult ConstReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
532 {
533 ::mlir::Attribute attr = attrs.get(getConstNameAttrName(opName));
534 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "const_name", emitError)))
535 return ::mlir::failure();
536 }
537 return ::mlir::success();
538}
539
540::llvm::LogicalResult ConstReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
541 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
542 if (::mlir::failed(reader.readAttribute(prop.const_name)))
543 return ::mlir::failure();
544 return ::mlir::success();
545}
546
547void ConstReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
548 auto &prop = getProperties(); (void)prop;
549 writer.writeAttribute(prop.const_name);
550}
551
552::llvm::StringRef ConstReadOp::getConstName() {
553 auto attr = getConstNameAttr();
554 return attr.getValue();
555}
556
557void ConstReadOp::setConstName(::llvm::StringRef attrValue) {
558 getProperties().const_name = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
559}
560
561void ConstReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::FlatSymbolRefAttr const_name) {
562 odsState.getOrAddProperties<Properties>().const_name = const_name;
563 odsState.addTypes(val);
564}
565
566void ConstReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::FlatSymbolRefAttr const_name) {
567 odsState.getOrAddProperties<Properties>().const_name = const_name;
568 assert(resultTypes.size() == 1u && "mismatched number of results");
569 odsState.addTypes(resultTypes);
570}
571
572void ConstReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::llvm::StringRef const_name) {
573 odsState.getOrAddProperties<Properties>().const_name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), const_name);
574 odsState.addTypes(val);
575}
576
577void ConstReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef const_name) {
578 odsState.getOrAddProperties<Properties>().const_name = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), const_name);
579 assert(resultTypes.size() == 1u && "mismatched number of results");
580 odsState.addTypes(resultTypes);
581}
582
583void ConstReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
584 assert(operands.size() == 0u && "mismatched number of parameters");
585 odsState.addOperands(operands);
586 odsState.addAttributes(attributes);
587 assert(resultTypes.size() == 1u && "mismatched number of return types");
588 odsState.addTypes(resultTypes);
589
590 if (!attributes.empty()) {
591 ::mlir::OpaqueProperties properties =
592 &odsState.getOrAddProperties<ConstReadOp::Properties>();
593 std::optional<::mlir::RegisteredOperationName> info =
594 odsState.name.getRegisteredInfo();
595 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
596 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
597 ::llvm::report_fatal_error("Property conversion failed.");
598 }
599}
600
601::llvm::LogicalResult ConstReadOp::verifyInvariantsImpl() {
602 auto tblgen_const_name = getProperties().const_name; (void)tblgen_const_name;
603 if (!tblgen_const_name) return emitOpError("requires attribute 'const_name'");
604
605 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_const_name, "const_name")))
606 return ::mlir::failure();
607 {
608 unsigned index = 0; (void)index;
609 auto valueGroup0 = getODSResults(0);
610
611 for (auto v : valueGroup0) {
612 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "result", index++)))
613 return ::mlir::failure();
614 }
615 }
616 return ::mlir::success();
617}
618
619::llvm::LogicalResult ConstReadOp::verifyInvariants() {
620 return verifyInvariantsImpl();
621}
622
623::mlir::ParseResult ConstReadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
624 ::mlir::FlatSymbolRefAttr const_nameAttr;
625 ::mlir::Type valRawType{};
626 ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1);
627
628 if (parser.parseCustomAttributeWithFallback(const_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
629 return ::mlir::failure();
630 }
631 if (const_nameAttr) result.getOrAddProperties<ConstReadOp::Properties>().const_name = const_nameAttr;
632 if (parser.parseColon())
633 return ::mlir::failure();
634
635 {
636 ::mlir::Type type;
637 if (parser.parseCustomTypeWithFallback(type))
638 return ::mlir::failure();
639 valRawType = type;
640 }
641 {
642 auto loc = parser.getCurrentLocation();(void)loc;
643 if (parser.parseOptionalAttrDict(result.attributes))
644 return ::mlir::failure();
645 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
646 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
647 })))
648 return ::mlir::failure();
649 }
650 result.addTypes(valTypes);
651 return ::mlir::success();
652}
653
654void ConstReadOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
655 _odsPrinter << ' ';
656 _odsPrinter.printAttributeWithoutType(getConstNameAttr());
657 _odsPrinter << ' ' << ":";
658 _odsPrinter << ' ';
659 {
660 auto type = getVal().getType();
661 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
662 _odsPrinter.printStrippedAttrOrType(validType);
663 else
664 _odsPrinter << type;
665 }
666 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
667 elidedAttrs.push_back("const_name");
668 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
669}
670
671} // namespace polymorphic
672} // namespace llzk
673MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::polymorphic::ConstReadOp)
674
675namespace llzk {
676namespace polymorphic {
677
678//===----------------------------------------------------------------------===//
679// ::llzk::polymorphic::UnifiableCastOp definitions
680//===----------------------------------------------------------------------===//
681
682namespace detail {
683} // namespace detail
685
686::llvm::LogicalResult UnifiableCastOpAdaptor::verify(::mlir::Location loc) {
687 return ::mlir::success();
688}
689
690void UnifiableCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input) {
691 odsState.addOperands(input);
692 odsState.addTypes(result);
693}
694
695void UnifiableCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) {
696 odsState.addOperands(input);
697 assert(resultTypes.size() == 1u && "mismatched number of results");
698 odsState.addTypes(resultTypes);
699}
700
701void UnifiableCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
702 assert(operands.size() == 1u && "mismatched number of parameters");
703 odsState.addOperands(operands);
704 odsState.addAttributes(attributes);
705 assert(resultTypes.size() == 1u && "mismatched number of return types");
706 odsState.addTypes(resultTypes);
707}
708
710 {
711 unsigned index = 0; (void)index;
712 auto valueGroup0 = getODSOperands(0);
713
714 for (auto v : valueGroup0) {
715 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
716 return ::mlir::failure();
717 }
718 }
719 {
720 unsigned index = 0; (void)index;
721 auto valueGroup0 = getODSResults(0);
722
723 for (auto v : valueGroup0) {
724 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "result", index++)))
725 return ::mlir::failure();
726 }
727 }
728 return ::mlir::success();
729}
730
731::llvm::LogicalResult UnifiableCastOp::verifyInvariants() {
732 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
733 return ::mlir::success();
734 return ::mlir::failure();
735}
736
737::mlir::ParseResult UnifiableCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
738 ::mlir::OpAsmParser::UnresolvedOperand inputRawOperand{};
739 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(&inputRawOperand, 1); ::llvm::SMLoc inputOperandsLoc;
740 (void)inputOperandsLoc;
741 ::llvm::ArrayRef<::mlir::Type> inputTypes;
742 ::llvm::ArrayRef<::mlir::Type> allResultTypes;
743
744 inputOperandsLoc = parser.getCurrentLocation();
745 if (parser.parseOperand(inputRawOperand))
746 return ::mlir::failure();
747 if (parser.parseColon())
748 return ::mlir::failure();
749
750 ::mlir::FunctionType input__allResult_functionType;
751 if (parser.parseType(input__allResult_functionType))
752 return ::mlir::failure();
753 inputTypes = input__allResult_functionType.getInputs();
754 allResultTypes = input__allResult_functionType.getResults();
755 {
756 auto loc = parser.getCurrentLocation();(void)loc;
757 if (parser.parseOptionalAttrDict(result.attributes))
758 return ::mlir::failure();
759 }
760 result.addTypes(allResultTypes);
761 if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands))
762 return ::mlir::failure();
763 return ::mlir::success();
764}
765
766void UnifiableCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
767 _odsPrinter << ' ';
768 _odsPrinter << getInput();
769 _odsPrinter << ' ' << ":";
770 _odsPrinter << ' ';
771 _odsPrinter.printFunctionalType(::llvm::ArrayRef<::mlir::Type>(getInput().getType()), getOperation()->getResultTypes());
772 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
773 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
774}
775
776void UnifiableCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
777}
778
779} // namespace polymorphic
780} // namespace llzk
781MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::polymorphic::UnifiableCastOp)
782
783
784#endif // GET_OP_CLASSES
785
MlirStringRef name
Definition Poly.cpp:48
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:153
ApplyMapOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:109
::mlir::AffineMapAttr getMapAttr()
Definition Ops.h.inc:213
::mlir::IntegerAttr getNumDimsAttr()
Definition Ops.h.inc:218
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:167
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:198
::mlir::Operation::operand_range getMapOperands()
Definition Ops.h.inc:189
::llvm::LogicalResult verify()
Definition Ops.cpp:48
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:425
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:392
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:386
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:251
FoldAdaptor::Properties Properties
Definition Ops.h.inc:156
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:183
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::AffineMapAttr map, ::mlir::ValueRange mapOperands={})
Definition Ops.cpp.inc:333
::mlir::StringAttr getMapAttrName()
Definition Ops.h.inc:162
::mlir::AffineMap getMap()
Definition Ops.cpp.inc:315
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:278
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:309
void setMap(::mlir::AffineMap attrValue)
Definition Ops.cpp.inc:325
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:228
::mlir::StringAttr getNumDimsAttrName()
Definition Ops.h.inc:170
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:284
::mlir::MutableOperandRange getMapOperandsMutable()
Definition Ops.cpp.inc:185
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:354
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:266
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:299
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:191
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:436
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:257
void setNumDims(::llvm::APInt attrValue)
Definition Ops.cpp.inc:329
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:461
ConstReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:349
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:547
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:623
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:654
FoldAdaptor::Properties Properties
Definition Ops.h.inc:392
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:531
::mlir::TypedValue<::mlir::Type > getVal()
Definition Ops.h.inc:430
::mlir::StringAttr getConstNameAttrName()
Definition Ops.h.inc:398
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:493
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:520
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:424
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:470
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:509
void setConstName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:557
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:601
::mlir::FlatSymbolRefAttr getConstNameAttr()
Definition Ops.h.inc:443
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::FlatSymbolRefAttr const_name)
Definition Ops.cpp.inc:561
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:514
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:527
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:540
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:619
::llvm::StringRef getConstName()
Definition Ops.cpp.inc:552
UnifiableCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs={}, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:518
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:686
::llvm::LogicalResult verify()
Definition Ops.cpp:72
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input)
Definition Ops.cpp.inc:690
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:776
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:575
::mlir::TypedValue<::mlir::Type > getInput()
Definition Ops.h.inc:581
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:709
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:731
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:594
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:737
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:766
ApplyMapOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:75
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:122
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:71
ConstReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:318
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:314
void printDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands, mlir::IntegerAttr numDims)
Definition OpHelpers.h:100
bool isValidType(Type type)
mlir::ParseResult parseDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand, N > &mapOperands, mlir::IntegerAttr &numDims)
Definition OpHelpers.h:92
bool isValidConstReadType(Type type)
void setMap(const ::mlir::AffineMapAttr &propValue)
Definition Ops.h.inc:46
void setNumDims(const ::mlir::IntegerAttr &propValue)
Definition Ops.h.inc:56