LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#ifdef GET_OP_LIST
11#undef GET_OP_LIST
12
16#endif // GET_OP_LIST
17
18#ifdef GET_OP_CLASSES
19#undef GET_OP_CLASSES
20
21
22//===----------------------------------------------------------------------===//
23// Local Utility Method Definitions
24//===----------------------------------------------------------------------===//
25
26
27static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
28 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
29 unsigned valueIndex) {
30 if (!((::llzk::isValidType(type)))) {
31 return op->emitOpError(valueKind) << " #" << valueIndex
32 << " must be variadic of a valid LLZK type, but got " << type;
33 }
34 return ::mlir::success();
35}
36
37static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops2(
38 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
39 unsigned valueIndex) {
40 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
41 return op->emitOpError(valueKind) << " #" << valueIndex
42 << " must be variadic of index, but got " << type;
43 }
44 return ::mlir::success();
45}
46
47static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops3(
48 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
49 unsigned valueIndex) {
50 if (!((::llvm::isa<::llzk::pod::PodType>(type)))) {
51 return op->emitOpError(valueKind) << " #" << valueIndex
52 << " must be plain-old-data struct, but got " << type;
53 }
54 return ::mlir::success();
55}
56
57static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops4(
58 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
59 unsigned valueIndex) {
60 if (!((::llzk::isValidType(type)))) {
61 return op->emitOpError(valueKind) << " #" << valueIndex
62 << " must be a valid LLZK type, but got " << type;
63 }
64 return ::mlir::success();
65}
66
67static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
68 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
69 if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); }))))
70 return emitError() << "attribute '" << attrName
71 << "' failed to satisfy constraint: string array attribute";
72 return ::mlir::success();
73}
74static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
75 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
76 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
77 return op->emitOpError();
78 });
79}
80
81static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
82 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
83 if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
84 return emitError() << "attribute '" << attrName
85 << "' failed to satisfy constraint: i32 dense array attribute";
86 return ::mlir::success();
87}
88static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
89 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
90 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
91 return op->emitOpError();
92 });
93}
94
95static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
96 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
97 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
98 return emitError() << "attribute '" << attrName
99 << "' failed to satisfy constraint: string attribute";
100 return ::mlir::success();
101}
102static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
103 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
104 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
105 return op->emitOpError();
106 });
107}
108namespace llzk::pod {
109
110
111//===----------------------------------------------------------------------===//
112// ::llzk::pod::NewPodOp definitions
113//===----------------------------------------------------------------------===//
114
115namespace detail {
116
117NewPodOpGenericAdaptorBase::NewPodOpGenericAdaptorBase(NewPodOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
118
119std::pair<unsigned, unsigned> NewPodOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
120 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
121
122 unsigned start = 0;
123 for (unsigned i = 0; i < index; ++i)
124 start += sizeAttr[i];
125 return {start, sizeAttr[index]};
126}
127
129 auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().initializedRecords);
130 return attr;
131}
132
134 auto attr = getInitializedRecordsAttr();
135 return attr;
136}
137
139 auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
140 return attr;
141}
142
144 auto attr = getNumDimsPerMapAttr();
145 return attr;
146}
147
149 auto attr = getMapOpGroupSizesAttr();
150 return attr;
151}
152
153
154} // namespace detail
156
157::llvm::LogicalResult NewPodOpAdaptor::verify(::mlir::Location loc) {
158 auto tblgen_initializedRecords = getProperties().initializedRecords; (void)tblgen_initializedRecords;
159 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
160 if (!tblgen_mapOpGroupSizes) return emitError(loc, "'pod.new' op requires attribute 'mapOpGroupSizes'");
161 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
162
163 if (tblgen_initializedRecords && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_initializedRecords))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_initializedRecords), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); }))))
164 return emitError(loc, "'pod.new' op attribute 'initializedRecords' failed to satisfy constraint: string array attribute");
165
166 if (tblgen_numDimsPerMap && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numDimsPerMap))))
167 return emitError(loc, "'pod.new' op attribute 'numDimsPerMap' failed to satisfy constraint: i32 dense array attribute");
168
169 if (tblgen_mapOpGroupSizes && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_mapOpGroupSizes))))
170 return emitError(loc, "'pod.new' op attribute 'mapOpGroupSizes' failed to satisfy constraint: i32 dense array attribute");
171 return ::mlir::success();
172}
173
174std::pair<unsigned, unsigned> NewPodOp::getODSOperandIndexAndLength(unsigned index) {
175 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
176
177 unsigned start = 0;
178 for (unsigned i = 0; i < index; ++i)
179 start += sizeAttr[i];
180 return {start, sizeAttr[index]};
181}
182
183::mlir::MutableOperandRange NewPodOp::getInitialValuesMutable() {
184 auto range = getODSOperandIndexAndLength(0);
185 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
186 return mutableRange;
187}
188
189::mlir::MutableOperandRangeRange NewPodOp::getMapOperandsMutable() {
190 auto range = getODSOperandIndexAndLength(1);
191 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
192 return mutableRange.split(*(*this)->getAttrDictionary().getNamed(getMapOpGroupSizesAttrName()));
193}
194
195::llvm::LogicalResult NewPodOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
196 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
197 if (!dict) {
198 emitError() << "expected DictionaryAttr to set properties";
199 return ::mlir::failure();
200 }
201
202 {
203 auto &propStorage = prop.initializedRecords;
204 auto attr = dict.get("initializedRecords");
205 if (attr) {
206 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
207 if (convertedAttr) {
208 propStorage = convertedAttr;
209 } else {
210 emitError() << "Invalid attribute `initializedRecords` in property conversion: " << attr;
211 return ::mlir::failure();
212 }
213 }
214 }
215
216 {
217 auto &propStorage = prop.mapOpGroupSizes;
218 auto attr = dict.get("mapOpGroupSizes");
219 if (attr) {
220 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
221 if (convertedAttr) {
222 propStorage = convertedAttr;
223 } else {
224 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
225 return ::mlir::failure();
226 }
227 }
228 }
229
230 {
231 auto &propStorage = prop.numDimsPerMap;
232 auto attr = dict.get("numDimsPerMap");
233 if (attr) {
234 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
235 if (convertedAttr) {
236 propStorage = convertedAttr;
237 } else {
238 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
239 return ::mlir::failure();
240 }
241 }
242 }
243{
244
245 auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
246 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {
247 return convertFromAttribute(propStorage, propAttr, emitError);
248 };
249 auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
250;
251 if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() {
252 return emitError() << "for `operandSegmentSizes`: ";
253 })))
254 return ::mlir::failure();
255 }
256 return ::mlir::success();
257}
258
259::mlir::Attribute NewPodOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
260 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
261 ::mlir::Builder odsBuilder{ctx};
262
263 {
264 const auto &propStorage = prop.initializedRecords;
265 if (propStorage)
266 attrs.push_back(odsBuilder.getNamedAttr("initializedRecords",
267 propStorage));
268 }
269
270 {
271 const auto &propStorage = prop.mapOpGroupSizes;
272 if (propStorage)
273 attrs.push_back(odsBuilder.getNamedAttr("mapOpGroupSizes",
274 propStorage));
275 }
276
277 {
278 const auto &propStorage = prop.numDimsPerMap;
279 if (propStorage)
280 attrs.push_back(odsBuilder.getNamedAttr("numDimsPerMap",
281 propStorage));
282 }
283
284 {
285 const auto &propStorage = prop.operandSegmentSizes;
286 auto attr = [&]() -> ::mlir::Attribute {
287 return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
288 }();
289 attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
290 }
291
292 if (!attrs.empty())
293 return odsBuilder.getDictionaryAttr(attrs);
294 return {};
295}
296
297llvm::hash_code NewPodOp::computePropertiesHash(const Properties &prop) {
298 auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code {
299 using ::llvm::hash_value;
300 return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
301 };
302 using llvm::hash_value;
303 return llvm::hash_combine(
304 llvm::hash_value(prop.initializedRecords.getAsOpaquePointer()),
305 llvm::hash_value(prop.mapOpGroupSizes.getAsOpaquePointer()),
306 llvm::hash_value(prop.numDimsPerMap.getAsOpaquePointer()),
307 hash_operandSegmentSizes_(prop.operandSegmentSizes));
308}
309
310std::optional<mlir::Attribute> NewPodOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
311 if (name == "initializedRecords")
312 return prop.initializedRecords;
313
314 if (name == "mapOpGroupSizes")
315 return prop.mapOpGroupSizes;
316
317 if (name == "numDimsPerMap")
318 return prop.numDimsPerMap;
319 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
320 return std::nullopt;
321}
322
323void NewPodOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
324 if (name == "initializedRecords") {
325 prop.initializedRecords = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.initializedRecords)>>(value);
326 return;
327 }
328
329 if (name == "mapOpGroupSizes") {
330 prop.mapOpGroupSizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapOpGroupSizes)>>(value);
331 return;
332 }
333
334 if (name == "numDimsPerMap") {
335 prop.numDimsPerMap = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDimsPerMap)>>(value);
336 return;
337 }
338 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") {
339 auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value);
340 if (!arrAttr) return;
341 if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t))
342 return;
343 llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin());
344 return;
345 }
346}
347
348void NewPodOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
349 if (prop.initializedRecords) attrs.append("initializedRecords", prop.initializedRecords);
350
351 if (prop.mapOpGroupSizes) attrs.append("mapOpGroupSizes", prop.mapOpGroupSizes);
352
353 if (prop.numDimsPerMap) attrs.append("numDimsPerMap", prop.numDimsPerMap);
354 attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
355}
356
357::llvm::LogicalResult NewPodOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
358 {
359 ::mlir::Attribute attr = attrs.get(getInitializedRecordsAttrName(opName));
360 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "initializedRecords", emitError)))
361 return ::mlir::failure();
362 }
363
364 {
365 ::mlir::Attribute attr = attrs.get(getMapOpGroupSizesAttrName(opName));
366 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "mapOpGroupSizes", emitError)))
367 return ::mlir::failure();
368 }
369
370 {
371 ::mlir::Attribute attr = attrs.get(getNumDimsPerMapAttrName(opName));
372 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "numDimsPerMap", emitError)))
373 return ::mlir::failure();
374 }
375 return ::mlir::success();
376}
377
378::llvm::LogicalResult NewPodOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
379 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
380 if (::mlir::failed(reader.readOptionalAttribute(prop.initializedRecords)))
381 return ::mlir::failure();
382
383 if (::mlir::failed(reader.readAttribute(prop.mapOpGroupSizes)))
384 return ::mlir::failure();
385
386 if (::mlir::failed(reader.readOptionalAttribute(prop.numDimsPerMap)))
387 return ::mlir::failure();
388
389 if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
390 auto &propStorage = prop.operandSegmentSizes;
391 ::mlir::DenseI32ArrayAttr attr;
392 if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
393 if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
394 reader.emitError("size mismatch for operand/result_segment_size");
395 return ::mlir::failure();
396 }
397 ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
398 }
399
400 {
401 auto &propStorage = prop.operandSegmentSizes;
402 auto readProp = [&]() {
403
404 if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
405 return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
406;
407 return ::mlir::success();
408 };
409 if (::mlir::failed(readProp()))
410 return ::mlir::failure();
411 }
412 return ::mlir::success();
413}
414
415void NewPodOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
416 auto &prop = getProperties(); (void)prop;
417
418 writer.writeOptionalAttribute(prop.initializedRecords);
419 writer.writeAttribute(prop.mapOpGroupSizes);
420
421 writer.writeOptionalAttribute(prop.numDimsPerMap);
422
423if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
424 auto &propStorage = prop.operandSegmentSizes;
425 writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
426}
427
428 {
429 auto &propStorage = prop.operandSegmentSizes;
430
431 if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
432 writer.writeSparseArray(::llvm::ArrayRef(propStorage));
433;
434 }
435}
436
438 auto attr = getInitializedRecordsAttr();
439 return attr;
440}
441
442::llvm::ArrayRef<int32_t> NewPodOp::getNumDimsPerMap() {
443 auto attr = getNumDimsPerMapAttr();
444 return attr;
445}
446
447::llvm::ArrayRef<int32_t> NewPodOp::getMapOpGroupSizes() {
448 auto attr = getMapOpGroupSizesAttr();
449 return attr;
450}
451
452void NewPodOp::setNumDimsPerMap(::llvm::ArrayRef<int32_t> attrValue) {
453 getProperties().numDimsPerMap = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
454}
455
456void NewPodOp::setMapOpGroupSizes(::llvm::ArrayRef<int32_t> attrValue) {
457 getProperties().mapOpGroupSizes = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
458}
459
460void NewPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::pod::InitializedRecords initialValues) {
461 auto resultType = ::llzk::pod::PodType::fromInitialValues(odsBuilder.getContext(), initialValues);
462 build(odsBuilder, odsState, resultType, initialValues);
463
464}
465
466NewPodOp NewPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::pod::InitializedRecords initialValues) {
467 ::mlir::OperationState __state__(location, getOperationName());
468 build(builder, __state__, std::forward<decltype(initialValues)>(initialValues));
469 auto __res__ = ::llvm::dyn_cast<NewPodOp>(builder.create(__state__));
470 assert(__res__ && "builder didn't return the right type");
471 return __res__;
472}
473
474NewPodOp NewPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::pod::InitializedRecords initialValues) {
475 return create(builder, builder.getLoc(), std::forward<decltype(initialValues)>(initialValues));
476}
477
478NewPodOp NewPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::pod::PodType resultType, ::llzk::pod::InitializedRecords initialValues) {
479 ::mlir::OperationState __state__(location, getOperationName());
480 build(builder, __state__, std::forward<decltype(resultType)>(resultType), std::forward<decltype(initialValues)>(initialValues));
481 auto __res__ = ::llvm::dyn_cast<NewPodOp>(builder.create(__state__));
482 assert(__res__ && "builder didn't return the right type");
483 return __res__;
484}
485
486NewPodOp NewPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::pod::PodType resultType, ::llzk::pod::InitializedRecords initialValues) {
487 return create(builder, builder.getLoc(), std::forward<decltype(resultType)>(resultType), std::forward<decltype(initialValues)>(initialValues));
488}
489
490NewPodOp NewPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::pod::PodType resultType, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::llzk::pod::InitializedRecords initialValues) {
491 ::mlir::OperationState __state__(location, getOperationName());
492 build(builder, __state__, std::forward<decltype(resultType)>(resultType), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(initialValues)>(initialValues));
493 auto __res__ = ::llvm::dyn_cast<NewPodOp>(builder.create(__state__));
494 assert(__res__ && "builder didn't return the right type");
495 return __res__;
496}
497
498NewPodOp NewPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::pod::PodType resultType, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap, ::llzk::pod::InitializedRecords initialValues) {
499 return create(builder, builder.getLoc(), std::forward<decltype(resultType)>(resultType), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(initialValues)>(initialValues));
500}
501
502void NewPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::pod::PodType resultType, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::llzk::pod::InitializedRecords initialValues) {
503 build(odsBuilder, odsState, resultType, mapOperands,
504 odsBuilder.getDenseI32ArrayAttr(numDimsPerMap), initialValues);
505
506}
507
508NewPodOp NewPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::pod::PodType resultType, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::llzk::pod::InitializedRecords initialValues) {
509 ::mlir::OperationState __state__(location, getOperationName());
510 build(builder, __state__, std::forward<decltype(resultType)>(resultType), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(initialValues)>(initialValues));
511 auto __res__ = ::llvm::dyn_cast<NewPodOp>(builder.create(__state__));
512 assert(__res__ && "builder didn't return the right type");
513 return __res__;
514}
515
516NewPodOp NewPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::pod::PodType resultType, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap, ::llzk::pod::InitializedRecords initialValues) {
517 return create(builder, builder.getLoc(), std::forward<decltype(resultType)>(resultType), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap), std::forward<decltype(initialValues)>(initialValues));
518}
519
520void NewPodOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
521 ::mlir::Builder odsBuilder(opName.getContext());
522 if (!properties.initializedRecords)
523 properties.initializedRecords = odsBuilder.getStrArrayAttr({});
524 if (!properties.numDimsPerMap)
525 properties.numDimsPerMap = odsBuilder.getDenseI32ArrayAttr({});
526}
527
528::llvm::LogicalResult NewPodOp::verifyInvariantsImpl() {
529 auto tblgen_initializedRecords = getProperties().initializedRecords; (void)tblgen_initializedRecords;
530 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
531 if (!tblgen_mapOpGroupSizes) return emitOpError("requires attribute 'mapOpGroupSizes'");
532 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
533
534 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_initializedRecords, "initializedRecords")))
535 return ::mlir::failure();
536
537 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_numDimsPerMap, "numDimsPerMap")))
538 return ::mlir::failure();
539
540 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_mapOpGroupSizes, "mapOpGroupSizes")))
541 return ::mlir::failure();
542 {
543 unsigned index = 0; (void)index;
544 auto valueGroup0 = getODSOperands(0);
545
546 for (auto v : valueGroup0) {
547 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
548 return ::mlir::failure();
549 }
550 auto valueGroup1 = getODSOperands(1);
551 if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr(*this, "mapOpGroupSizes", "mapOperands", valueGroup1.size())))
552 return ::mlir::failure();
553
554 for (auto v : valueGroup1) {
555 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
556 return ::mlir::failure();
557 }
558 }
559 {
560 unsigned index = 0; (void)index;
561 auto valueGroup0 = getODSResults(0);
562
563 for (auto v : valueGroup0) {
564 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "result", index++)))
565 return ::mlir::failure();
566 }
567 }
568 return ::mlir::success();
569}
570
571::llvm::LogicalResult NewPodOp::verifyInvariants() {
572 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
573 return ::mlir::success();
574 return ::mlir::failure();
575}
576
577::llvm::LogicalResult NewPodOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
578 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
579 if (!dict) {
580 emitError() << "expected DictionaryAttr to set properties";
581 return ::mlir::failure();
582 }
583 // keep track of used keys in the input dictionary to be able to error out
584 // if there are some unknown ones.
585 ::mlir::DenseSet<::mlir::StringAttr> usedKeys;
586 ::mlir::MLIRContext *ctx = dict.getContext();
587 (void)ctx;
588 {
589
590 auto &propStorage = prop.initializedRecords;
591 auto initializedRecordsAttrName = ::mlir::StringAttr::get(ctx, "initializedRecords");
592 auto attr = dict.get(initializedRecordsAttrName);
593 usedKeys.insert(initializedRecordsAttrName);
594 if (attr || /*isRequired=*/false) {
595 if (!attr) {
596 emitError() << "expected key entry for initializedRecords in DictionaryAttr to set "
597 "Properties.";
598 return ::mlir::failure();
599 }
600 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
601 if (convertedAttr) {
602 propStorage = convertedAttr;
603 } else {
604 emitError() << "Invalid attribute `initializedRecords` in property conversion: " << attr;
605 return ::mlir::failure();
606 }
607 }
608 }
609 {
610
611 auto &propStorage = prop.numDimsPerMap;
612 auto numDimsPerMapAttrName = ::mlir::StringAttr::get(ctx, "numDimsPerMap");
613 auto attr = dict.get(numDimsPerMapAttrName);
614 usedKeys.insert(numDimsPerMapAttrName);
615 if (attr || /*isRequired=*/false) {
616 if (!attr) {
617 emitError() << "expected key entry for numDimsPerMap in DictionaryAttr to set "
618 "Properties.";
619 return ::mlir::failure();
620 }
621 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
622 if (convertedAttr) {
623 propStorage = convertedAttr;
624 } else {
625 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
626 return ::mlir::failure();
627 }
628 }
629 }
630 {
631
632 auto &propStorage = prop.mapOpGroupSizes;
633 auto mapOpGroupSizesAttrName = ::mlir::StringAttr::get(ctx, "mapOpGroupSizes");
634 auto attr = dict.get(mapOpGroupSizesAttrName);
635 usedKeys.insert(mapOpGroupSizesAttrName);
636 if (attr || /*isRequired=*/true) {
637 if (!attr) {
638 emitError() << "expected key entry for mapOpGroupSizes in DictionaryAttr to set "
639 "Properties.";
640 return ::mlir::failure();
641 }
642 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
643 if (convertedAttr) {
644 propStorage = convertedAttr;
645 } else {
646 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
647 return ::mlir::failure();
648 }
649 }
650 }
651
652 for (::mlir::NamedAttribute attr : dict) {
653 if (!usedKeys.contains(attr.getName()))
654 return emitError() << "unknown key '" << attr.getName() <<
655 "' when parsing properties dictionary";
656 }
657 return ::mlir::success();
658}
659
660void NewPodOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
661 effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), 0, false, ::llzk::DiscardableAllocationResource::get());
662}
663
664
665} // namespace llzk::pod
666MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::NewPodOp)
668
669namespace llzk::pod {
670
671
672//===----------------------------------------------------------------------===//
673// ::llzk::pod::ReadPodOp definitions
674//===----------------------------------------------------------------------===//
675
676namespace detail {
677
678ReadPodOpGenericAdaptorBase::ReadPodOpGenericAdaptorBase(ReadPodOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
679
681 auto attr = getRecordNameAttr();
682 return attr.getValue();
683}
684
685
686} // namespace detail
688
689::llvm::LogicalResult ReadPodOpAdaptor::verify(::mlir::Location loc) {
690 auto tblgen_record_name = getProperties().record_name; (void)tblgen_record_name;
691 if (!tblgen_record_name) return emitError(loc, "'pod.read' op requires attribute 'record_name'");
692
693 if (tblgen_record_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_record_name))))
694 return emitError(loc, "'pod.read' op attribute 'record_name' failed to satisfy constraint: string attribute");
695 return ::mlir::success();
696}
697
698::llvm::LogicalResult ReadPodOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
699 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
700 if (!dict) {
701 emitError() << "expected DictionaryAttr to set properties";
702 return ::mlir::failure();
703 }
704
705 {
706 auto &propStorage = prop.record_name;
707 auto attr = dict.get("record_name");
708 if (attr) {
709 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
710 if (convertedAttr) {
711 propStorage = convertedAttr;
712 } else {
713 emitError() << "Invalid attribute `record_name` in property conversion: " << attr;
714 return ::mlir::failure();
715 }
716 }
717 }
718 return ::mlir::success();
719}
720
721::mlir::Attribute ReadPodOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
722 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
723 ::mlir::Builder odsBuilder{ctx};
724
725 {
726 const auto &propStorage = prop.record_name;
727 if (propStorage)
728 attrs.push_back(odsBuilder.getNamedAttr("record_name",
729 propStorage));
730 }
731
732 if (!attrs.empty())
733 return odsBuilder.getDictionaryAttr(attrs);
734 return {};
735}
736
737llvm::hash_code ReadPodOp::computePropertiesHash(const Properties &prop) {
738 using llvm::hash_value;
739 return llvm::hash_combine(
740 llvm::hash_value(prop.record_name.getAsOpaquePointer()));
741}
742
743std::optional<mlir::Attribute> ReadPodOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
744 if (name == "record_name")
745 return prop.record_name;
746 return std::nullopt;
747}
748
749void ReadPodOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
750 if (name == "record_name") {
751 prop.record_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.record_name)>>(value);
752 return;
753 }
754}
755
756void ReadPodOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
757 if (prop.record_name) attrs.append("record_name", prop.record_name);
758}
759
760::llvm::LogicalResult ReadPodOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
761 {
762 ::mlir::Attribute attr = attrs.get(getRecordNameAttrName(opName));
763 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "record_name", emitError)))
764 return ::mlir::failure();
765 }
766 return ::mlir::success();
767}
768
769::llvm::StringRef ReadPodOp::getRecordName() {
770 auto attr = getRecordNameAttr();
771 return attr.getValue();
772}
773
774void ReadPodOp::setRecordName(::llvm::StringRef attrValue) {
775 getProperties().record_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
776}
777
778void ReadPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
779 odsState.addOperands(pod_ref);
780 odsState.getOrAddProperties<Properties>().record_name = record_name;
781 odsState.addTypes(result);
782}
783
784ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
785 ::mlir::OperationState __state__(location, getOperationName());
786 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
787 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
788 assert(__res__ && "builder didn't return the right type");
789 return __res__;
790}
791
792ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
793 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
794}
795
796void ReadPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
797 odsState.addOperands(pod_ref);
798 odsState.getOrAddProperties<Properties>().record_name = record_name;
799 assert(resultTypes.size() == 1u && "mismatched number of results");
800 odsState.addTypes(resultTypes);
801}
802
803ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
804 ::mlir::OperationState __state__(location, getOperationName());
805 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
806 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
807 assert(__res__ && "builder didn't return the right type");
808 return __res__;
809}
810
811ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name) {
812 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
813}
814
815void ReadPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
816 odsState.addOperands(pod_ref);
817 odsState.getOrAddProperties<Properties>().record_name = odsBuilder.getStringAttr(record_name);
818 odsState.addTypes(result);
819}
820
821ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
822 ::mlir::OperationState __state__(location, getOperationName());
823 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
824 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
825 assert(__res__ && "builder didn't return the right type");
826 return __res__;
827}
828
829ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
830 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
831}
832
833void ReadPodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
834 odsState.addOperands(pod_ref);
835 odsState.getOrAddProperties<Properties>().record_name = odsBuilder.getStringAttr(record_name);
836 assert(resultTypes.size() == 1u && "mismatched number of results");
837 odsState.addTypes(resultTypes);
838}
839
840ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
841 ::mlir::OperationState __state__(location, getOperationName());
842 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
843 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
844 assert(__res__ && "builder didn't return the right type");
845 return __res__;
846}
847
848ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name) {
849 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name));
850}
851
852void ReadPodOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
853 assert(operands.size() == 1u && "mismatched number of parameters");
854 odsState.addOperands(operands);
855 odsState.addAttributes(attributes);
856 assert(resultTypes.size() == 1u && "mismatched number of return types");
857 odsState.addTypes(resultTypes);
858
859 if (!attributes.empty()) {
860 (void)odsState.getOrAddProperties<ReadPodOp::Properties>();
861 ::mlir::PropertyRef properties = odsState.getRawProperties();
862 std::optional<::mlir::RegisteredOperationName> info =
863 odsState.name.getRegisteredInfo();
864 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
865 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
866 ::llvm::report_fatal_error("Property conversion failed.");
867 }
868}
869
870ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
871 ::mlir::OperationState __state__(location, getOperationName());
872 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
873 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
874 assert(__res__ && "builder didn't return the right type");
875 return __res__;
876}
877
878ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
879 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
880}
881
882void ReadPodOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
883 assert(operands.size() == 1u && "mismatched number of parameters");
884 odsState.addOperands(operands);
885 odsState.useProperties(const_cast<Properties&>(properties));
886 odsState.addAttributes(discardableAttributes);
887 assert(resultTypes.size() == 1u && "mismatched number of return types");
888 odsState.addTypes(resultTypes);
889}
890
891ReadPodOp ReadPodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
892 ::mlir::OperationState __state__(location, getOperationName());
893 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
894 auto __res__ = ::llvm::dyn_cast<ReadPodOp>(builder.create(__state__));
895 assert(__res__ && "builder didn't return the right type");
896 return __res__;
897}
898
899ReadPodOp ReadPodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
900 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
901}
902
903::llvm::LogicalResult ReadPodOp::verifyInvariantsImpl() {
904 auto tblgen_record_name = getProperties().record_name; (void)tblgen_record_name;
905 if (!tblgen_record_name) return emitOpError("requires attribute 'record_name'");
906
907 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_record_name, "record_name")))
908 return ::mlir::failure();
909 {
910 unsigned index = 0; (void)index;
911 auto valueGroup0 = getODSOperands(0);
912
913 for (auto v : valueGroup0) {
914 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
915 return ::mlir::failure();
916 }
917 }
918 {
919 unsigned index = 0; (void)index;
920 auto valueGroup0 = getODSResults(0);
921
922 for (auto v : valueGroup0) {
923 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "result", index++)))
924 return ::mlir::failure();
925 }
926 }
927 return ::mlir::success();
928}
929
930::llvm::LogicalResult ReadPodOp::verifyInvariants() {
931 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
932 return ::mlir::success();
933 return ::mlir::failure();
934}
935
936::mlir::ParseResult ReadPodOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
937 ::mlir::OpAsmParser::UnresolvedOperand pod_refRawOperand{};
938 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> pod_refOperands(&pod_refRawOperand, 1); ::llvm::SMLoc pod_refOperandsLoc;
939 (void)pod_refOperandsLoc;
940 ::mlir::StringAttr record_nameAttr;
941 ::mlir::Type pod_refRawType{};
942 ::llvm::ArrayRef<::mlir::Type> pod_refTypes(&pod_refRawType, 1);
943 ::mlir::Type resultRawType{};
944 ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1);
945
946 pod_refOperandsLoc = parser.getCurrentLocation();
947 if (parser.parseOperand(pod_refRawOperand))
948 return ::mlir::failure();
949 if (parser.parseLSquare())
950 return ::mlir::failure();
951 {
952 auto odsResult = parseRecordName(parser, record_nameAttr);
953 if (odsResult) return ::mlir::failure();
954 result.getOrAddProperties<ReadPodOp::Properties>().record_name = record_nameAttr;
955 }
956 if (parser.parseRSquare())
957 return ::mlir::failure();
958 if (parser.parseColon())
959 return ::mlir::failure();
960
961 {
963 if (parser.parseCustomTypeWithFallback(type))
964 return ::mlir::failure();
965 pod_refRawType = type;
966 }
967 if (parser.parseComma())
968 return ::mlir::failure();
969
970 {
971 ::mlir::Type type;
972 if (parser.parseCustomTypeWithFallback(type))
973 return ::mlir::failure();
974 resultRawType = type;
975 }
976 {
977 auto loc = parser.getCurrentLocation();(void)loc;
978 if (parser.parseOptionalAttrDict(result.attributes))
979 return ::mlir::failure();
980 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
981 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
982 })))
983 return ::mlir::failure();
984 }
985 result.addTypes(resultTypes);
986 if (parser.resolveOperands(pod_refOperands, pod_refTypes, pod_refOperandsLoc, result.operands))
987 return ::mlir::failure();
988 return ::mlir::success();
989}
990
991void ReadPodOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
992 _odsPrinter << ' ';
993 _odsPrinter << getPodRef();
994 _odsPrinter << "[";
995 printRecordName(_odsPrinter, *this, getRecordNameAttr());
996 _odsPrinter << "]";
997 _odsPrinter << ' ' << ":";
998 _odsPrinter << ' ';
999 {
1000 auto type = getPodRef().getType();
1001 if (auto validType = ::llvm::dyn_cast<::llzk::pod::PodType>(type))
1002 _odsPrinter.printStrippedAttrOrType(validType);
1003 else
1004 _odsPrinter << type;
1005 }
1006 _odsPrinter << ",";
1007 _odsPrinter << ' ';
1008 {
1009 auto type = getResult().getType();
1010 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1011 _odsPrinter.printStrippedAttrOrType(validType);
1012 else
1013 _odsPrinter << type;
1014 }
1015 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1016 elidedAttrs.push_back("record_name");
1017 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1018}
1019
1021bool ReadPodOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
1022 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
1023 ::mlir::SmallVectorImpl<::mlir::MemorySlot> &mustBeSafelyUsed,
1024 const ::mlir::DataLayout &dataLayout) {
1025 return ::llvm::cast<PodAccessOpInterface>(getOperation())
1026 .canRewire(slot, usedIndices, mustBeSafelyUsed, dataLayout);
1027}
1028
1030::mlir::DeletionKind ReadPodOp::rewire(const ::mlir::DestructurableMemorySlot &slot,
1031 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
1032 ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout) {
1033 return ::llvm::cast<PodAccessOpInterface>(getOperation())
1034 .rewire(slot, subslots, builder, dataLayout);
1035}
1036
1038bool ReadPodOp::loadsFrom(const ::mlir::MemorySlot &slot) {
1039 return getPodRef() == slot.ptr;
1040}
1041
1043bool ReadPodOp::storesTo(const ::mlir::MemorySlot &slot) {
1044 return false;
1045}
1046
1049 return true;
1050}
1051
1054 return getPodRef() == ptr;
1055}
1056
1059 return false;
1060}
1061
1063bool ReadPodOp::canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &) {
1064 return false;
1065}
1066
1067} // namespace llzk::pod
1068MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::ReadPodOp)
1070
1071namespace llzk::pod {
1072
1073
1074//===----------------------------------------------------------------------===//
1075// ::llzk::pod::WritePodOp definitions
1076//===----------------------------------------------------------------------===//
1077
1078namespace detail {
1079
1080WritePodOpGenericAdaptorBase::WritePodOpGenericAdaptorBase(WritePodOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
1081
1083 auto attr = getRecordNameAttr();
1084 return attr.getValue();
1085}
1086
1087
1088} // namespace detail
1090
1091::llvm::LogicalResult WritePodOpAdaptor::verify(::mlir::Location loc) {
1092 auto tblgen_record_name = getProperties().record_name; (void)tblgen_record_name;
1093 if (!tblgen_record_name) return emitError(loc, "'pod.write' op requires attribute 'record_name'");
1094
1095 if (tblgen_record_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_record_name))))
1096 return emitError(loc, "'pod.write' op attribute 'record_name' failed to satisfy constraint: string attribute");
1097 return ::mlir::success();
1098}
1099
1100::llvm::LogicalResult WritePodOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1101 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1102 if (!dict) {
1103 emitError() << "expected DictionaryAttr to set properties";
1104 return ::mlir::failure();
1105 }
1106
1107 {
1108 auto &propStorage = prop.record_name;
1109 auto attr = dict.get("record_name");
1110 if (attr) {
1111 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1112 if (convertedAttr) {
1113 propStorage = convertedAttr;
1114 } else {
1115 emitError() << "Invalid attribute `record_name` in property conversion: " << attr;
1116 return ::mlir::failure();
1117 }
1118 }
1119 }
1120 return ::mlir::success();
1121}
1122
1123::mlir::Attribute WritePodOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1124 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1125 ::mlir::Builder odsBuilder{ctx};
1126
1127 {
1128 const auto &propStorage = prop.record_name;
1129 if (propStorage)
1130 attrs.push_back(odsBuilder.getNamedAttr("record_name",
1131 propStorage));
1132 }
1133
1134 if (!attrs.empty())
1135 return odsBuilder.getDictionaryAttr(attrs);
1136 return {};
1137}
1138
1139llvm::hash_code WritePodOp::computePropertiesHash(const Properties &prop) {
1140 using llvm::hash_value;
1141 return llvm::hash_combine(
1142 llvm::hash_value(prop.record_name.getAsOpaquePointer()));
1143}
1144
1145std::optional<mlir::Attribute> WritePodOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1146 if (name == "record_name")
1147 return prop.record_name;
1148 return std::nullopt;
1149}
1150
1151void WritePodOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1152 if (name == "record_name") {
1153 prop.record_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.record_name)>>(value);
1154 return;
1155 }
1156}
1157
1158void WritePodOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1159 if (prop.record_name) attrs.append("record_name", prop.record_name);
1160}
1161
1162::llvm::LogicalResult WritePodOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1163 {
1164 ::mlir::Attribute attr = attrs.get(getRecordNameAttrName(opName));
1165 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "record_name", emitError)))
1166 return ::mlir::failure();
1167 }
1168 return ::mlir::success();
1169}
1170
1171::llvm::StringRef WritePodOp::getRecordName() {
1172 auto attr = getRecordNameAttr();
1173 return attr.getValue();
1174}
1175
1176void WritePodOp::setRecordName(::llvm::StringRef attrValue) {
1177 getProperties().record_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
1178}
1179
1180void WritePodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1181 odsState.addOperands(pod_ref);
1182 odsState.addOperands(value);
1183 odsState.getOrAddProperties<Properties>().record_name = record_name;
1184}
1185
1186WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1187 ::mlir::OperationState __state__(location, getOperationName());
1188 build(builder, __state__, std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1189 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1190 assert(__res__ && "builder didn't return the right type");
1191 return __res__;
1192}
1193
1194WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1195 return create(builder, builder.getLoc(), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1196}
1197
1198void WritePodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1199 odsState.addOperands(pod_ref);
1200 odsState.addOperands(value);
1201 odsState.getOrAddProperties<Properties>().record_name = record_name;
1202 assert(resultTypes.size() == 0u && "mismatched number of results");
1203 odsState.addTypes(resultTypes);
1204}
1205
1206WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1207 ::mlir::OperationState __state__(location, getOperationName());
1208 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1209 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1210 assert(__res__ && "builder didn't return the right type");
1211 return __res__;
1212}
1213
1214WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value) {
1215 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1216}
1217
1218void WritePodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1219 odsState.addOperands(pod_ref);
1220 odsState.addOperands(value);
1221 odsState.getOrAddProperties<Properties>().record_name = odsBuilder.getStringAttr(record_name);
1222}
1223
1224WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1225 ::mlir::OperationState __state__(location, getOperationName());
1226 build(builder, __state__, std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1227 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1228 assert(__res__ && "builder didn't return the right type");
1229 return __res__;
1230}
1231
1232WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1233 return create(builder, builder.getLoc(), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1234}
1235
1236void WritePodOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1237 odsState.addOperands(pod_ref);
1238 odsState.addOperands(value);
1239 odsState.getOrAddProperties<Properties>().record_name = odsBuilder.getStringAttr(record_name);
1240 assert(resultTypes.size() == 0u && "mismatched number of results");
1241 odsState.addTypes(resultTypes);
1242}
1243
1244WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1245 ::mlir::OperationState __state__(location, getOperationName());
1246 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1247 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1248 assert(__res__ && "builder didn't return the right type");
1249 return __res__;
1250}
1251
1252WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value pod_ref, ::llvm::StringRef record_name, ::mlir::Value value) {
1253 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(pod_ref)>(pod_ref), std::forward<decltype(record_name)>(record_name), std::forward<decltype(value)>(value));
1254}
1255
1256void WritePodOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1257 assert(operands.size() == 2u && "mismatched number of parameters");
1258 odsState.addOperands(operands);
1259 odsState.addAttributes(attributes);
1260 assert(resultTypes.size() == 0u && "mismatched number of return types");
1261 odsState.addTypes(resultTypes);
1262
1263 if (!attributes.empty()) {
1264 (void)odsState.getOrAddProperties<WritePodOp::Properties>();
1265 ::mlir::PropertyRef properties = odsState.getRawProperties();
1266 std::optional<::mlir::RegisteredOperationName> info =
1267 odsState.name.getRegisteredInfo();
1268 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
1269 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
1270 ::llvm::report_fatal_error("Property conversion failed.");
1271 }
1272}
1273
1274WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1275 ::mlir::OperationState __state__(location, getOperationName());
1276 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1277 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1278 assert(__res__ && "builder didn't return the right type");
1279 return __res__;
1280}
1281
1282WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1283 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1284}
1285
1286void WritePodOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1287 assert(operands.size() == 2u && "mismatched number of parameters");
1288 odsState.addOperands(operands);
1289 odsState.useProperties(const_cast<Properties&>(properties));
1290 odsState.addAttributes(discardableAttributes);
1291 assert(resultTypes.size() == 0u && "mismatched number of return types");
1292 odsState.addTypes(resultTypes);
1293}
1294
1295WritePodOp WritePodOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1296 ::mlir::OperationState __state__(location, getOperationName());
1297 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1298 auto __res__ = ::llvm::dyn_cast<WritePodOp>(builder.create(__state__));
1299 assert(__res__ && "builder didn't return the right type");
1300 return __res__;
1301}
1302
1303WritePodOp WritePodOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1304 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1305}
1306
1307::llvm::LogicalResult WritePodOp::verifyInvariantsImpl() {
1308 auto tblgen_record_name = getProperties().record_name; (void)tblgen_record_name;
1309 if (!tblgen_record_name) return emitOpError("requires attribute 'record_name'");
1310
1311 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_record_name, "record_name")))
1312 return ::mlir::failure();
1313 {
1314 unsigned index = 0; (void)index;
1315 auto valueGroup0 = getODSOperands(0);
1316
1317 for (auto v : valueGroup0) {
1318 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
1319 return ::mlir::failure();
1320 }
1321 auto valueGroup1 = getODSOperands(1);
1322
1323 for (auto v : valueGroup1) {
1324 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
1325 return ::mlir::failure();
1326 }
1327 }
1328 return ::mlir::success();
1329}
1330
1331::llvm::LogicalResult WritePodOp::verifyInvariants() {
1332 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1333 return ::mlir::success();
1334 return ::mlir::failure();
1335}
1336
1337::mlir::ParseResult WritePodOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1338 ::mlir::OpAsmParser::UnresolvedOperand pod_refRawOperand{};
1339 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> pod_refOperands(&pod_refRawOperand, 1); ::llvm::SMLoc pod_refOperandsLoc;
1340 (void)pod_refOperandsLoc;
1341 ::mlir::StringAttr record_nameAttr;
1342 ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{};
1343 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc;
1344 (void)valueOperandsLoc;
1345 ::mlir::Type pod_refRawType{};
1346 ::llvm::ArrayRef<::mlir::Type> pod_refTypes(&pod_refRawType, 1);
1347 ::mlir::Type valueRawType{};
1348 ::llvm::ArrayRef<::mlir::Type> valueTypes(&valueRawType, 1);
1349
1350 pod_refOperandsLoc = parser.getCurrentLocation();
1351 if (parser.parseOperand(pod_refRawOperand))
1352 return ::mlir::failure();
1353 if (parser.parseLSquare())
1354 return ::mlir::failure();
1355 {
1356 auto odsResult = parseRecordName(parser, record_nameAttr);
1357 if (odsResult) return ::mlir::failure();
1358 result.getOrAddProperties<WritePodOp::Properties>().record_name = record_nameAttr;
1359 }
1360 if (parser.parseRSquare())
1361 return ::mlir::failure();
1362 if (parser.parseEqual())
1363 return ::mlir::failure();
1364
1365 valueOperandsLoc = parser.getCurrentLocation();
1366 if (parser.parseOperand(valueRawOperand))
1367 return ::mlir::failure();
1368 if (parser.parseColon())
1369 return ::mlir::failure();
1370
1371 {
1373 if (parser.parseCustomTypeWithFallback(type))
1374 return ::mlir::failure();
1375 pod_refRawType = type;
1376 }
1377 if (parser.parseComma())
1378 return ::mlir::failure();
1379
1380 {
1381 ::mlir::Type type;
1382 if (parser.parseCustomTypeWithFallback(type))
1383 return ::mlir::failure();
1384 valueRawType = type;
1385 }
1386 {
1387 auto loc = parser.getCurrentLocation();(void)loc;
1388 if (parser.parseOptionalAttrDict(result.attributes))
1389 return ::mlir::failure();
1390 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
1391 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
1392 })))
1393 return ::mlir::failure();
1394 }
1395 if (parser.resolveOperands(pod_refOperands, pod_refTypes, pod_refOperandsLoc, result.operands))
1396 return ::mlir::failure();
1397 if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands))
1398 return ::mlir::failure();
1399 return ::mlir::success();
1400}
1401
1402void WritePodOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1403 _odsPrinter << ' ';
1404 _odsPrinter << getPodRef();
1405 _odsPrinter << "[";
1406 printRecordName(_odsPrinter, *this, getRecordNameAttr());
1407 _odsPrinter << "]";
1408 _odsPrinter << ' ' << "=";
1409 _odsPrinter << ' ';
1410 _odsPrinter << getValue();
1411 _odsPrinter << ' ' << ":";
1412 _odsPrinter << ' ';
1413 {
1414 auto type = getPodRef().getType();
1415 if (auto validType = ::llvm::dyn_cast<::llzk::pod::PodType>(type))
1416 _odsPrinter.printStrippedAttrOrType(validType);
1417 else
1418 _odsPrinter << type;
1419 }
1420 _odsPrinter << ",";
1421 _odsPrinter << ' ';
1422 {
1423 auto type = getValue().getType();
1424 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1425 _odsPrinter.printStrippedAttrOrType(validType);
1426 else
1427 _odsPrinter << type;
1428 }
1429 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1430 elidedAttrs.push_back("record_name");
1431 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1432}
1433
1435bool WritePodOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
1436 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
1437 ::mlir::SmallVectorImpl<::mlir::MemorySlot> &mustBeSafelyUsed,
1438 const ::mlir::DataLayout &dataLayout) {
1439 return ::llvm::cast<PodAccessOpInterface>(getOperation())
1440 .canRewire(slot, usedIndices, mustBeSafelyUsed, dataLayout);
1441}
1442
1444::mlir::DeletionKind WritePodOp::rewire(const ::mlir::DestructurableMemorySlot &slot,
1445 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
1446 ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout) {
1447 return ::llvm::cast<PodAccessOpInterface>(getOperation())
1448 .rewire(slot, subslots, builder, dataLayout);
1449}
1450
1452bool WritePodOp::loadsFrom(const ::mlir::MemorySlot &slot) {
1453 return false;
1454}
1455
1457bool WritePodOp::storesTo(const ::mlir::MemorySlot &slot) {
1458 return getPodRef() == slot.ptr;
1459}
1460
1463 return false;
1464}
1465
1468 return false;
1469}
1470
1473 return getPodRef() == ptr && getValue() != ptr;
1474}
1475
1477bool WritePodOp::canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &) {
1478 return getPodRef() == ptr && getValue() != ptr;
1479}
1480
1481} // namespace llzk::pod
1482MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::WritePodOp)
1484
1485
1486#endif // GET_OP_CLASSES
1487
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:157
NewPodOpAdaptor(NewPodOp op)
Definition Ops.cpp.inc:155
NewPodOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:212
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:571
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:195
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:577
static NewPodOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::pod::InitializedRecords initialValues={})
Definition Ops.cpp.inc:466
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:297
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:660
::mlir::ArrayAttr getInitializedRecordsAttr()
Definition Ops.h.inc:358
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:378
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:528
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:310
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:259
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:520
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:323
void setMapOpGroupSizes(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:456
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::pod::InitializedRecords initialValues={})
Definition Ops.cpp.inc:460
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:442
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:348
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:174
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.h.inc:363
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:339
::mlir::StringAttr getInitializedRecordsAttrName()
Definition Ops.h.inc:282
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:447
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:319
::mlir::StringAttr getMapOpGroupSizesAttrName()
Definition Ops.h.inc:290
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:368
::mlir::MutableOperandRange getInitialValuesMutable()
Definition Ops.cpp.inc:183
void setNumDimsPerMap(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:452
FoldAdaptor::Properties Properties
Definition Ops.h.inc:273
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:357
::mlir::MutableOperandRangeRange getMapOperandsMutable()
Definition Ops.cpp.inc:189
::llvm::LogicalResult verify()
Definition Ops.cpp:374
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:415
::mlir::ArrayAttr getInitializedRecords()
Definition Ops.cpp.inc:437
::mlir::StringAttr getNumDimsPerMapAttrName()
Definition Ops.h.inc:298
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:314
static PodType fromInitialValues(::mlir::MLIRContext *ctx, InitializedRecords init)
Creates a new type from a set of initialized records.
Definition Types.cpp:42
ReadPodOpAdaptor(ReadPodOp op)
Definition Ops.cpp.inc:687
ReadPodOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:506
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:689
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:930
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:721
::llvm::StringRef getRecordName()
Definition Ops.cpp.inc:769
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:756
::mlir::TypedValue<::mlir::Type > getResult()
Definition Ops.h.inc:601
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:576
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1043
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1048
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:903
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:936
::llvm::LogicalResult verify()
Definition Ops.cpp:621
FoldAdaptor::Properties Properties
Definition Ops.h.inc:554
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:698
::mlir::TypedValue<::llzk::pod::PodType > getPodRef()
Definition Ops.h.inc:582
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:991
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:737
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pod_ref, ::mlir::StringAttr record_name)
Definition Ops.cpp.inc:778
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:749
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:568
bool canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &dataLayout)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1063
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:743
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:595
::mlir::StringAttr getRecordNameAttr()
Definition Ops.h.inc:614
::mlir::StringAttr getRecordNameAttrName()
Definition Ops.h.inc:560
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1038
bool canRewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot > &mustBeSafelyUsed, const ::mlir::DataLayout &dataLayout)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1021
bool storesToDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1058
void setRecordName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:774
bool loadsFromDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1053
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:760
static ReadPodOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value pod_ref, ::mlir::StringAttr record_name)
Definition Ops.cpp.inc:784
::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > &subslots, ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1030
WritePodOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:753
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1091
WritePodOpAdaptor(WritePodOp op)
Definition Ops.cpp.inc:1089
::llvm::LogicalResult verify()
Definition Ops.cpp:654
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1139
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value)
Definition Ops.cpp.inc:1180
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1402
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1331
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:820
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1337
bool loadsFromDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1467
::mlir::StringAttr getRecordNameAttr()
Definition Ops.h.inc:871
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1162
::mlir::TypedValue<::mlir::Type > getValue()
Definition Ops.h.inc:838
void setRecordName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:1176
::mlir::TypedValue<::llzk::pod::PodType > getPodRef()
Definition Ops.h.inc:834
FoldAdaptor::Properties Properties
Definition Ops.h.inc:806
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1145
::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > &subslots, ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1444
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1462
bool canRewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot > &mustBeSafelyUsed, const ::mlir::DataLayout &dataLayout)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1435
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:828
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1307
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1457
::llvm::StringRef getRecordName()
Definition Ops.cpp.inc:1171
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1158
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1100
bool canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &dataLayout)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1477
bool storesToDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:1472
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1452
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1151
static WritePodOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value pod_ref, ::mlir::StringAttr record_name, ::mlir::Value value)
Definition Ops.cpp.inc:1186
::mlir::StringAttr getRecordNameAttrName()
Definition Ops.h.inc:812
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1123
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:196
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:119
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:148
NewPodOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:177
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:143
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.cpp.inc:138
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:173
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:469
ReadPodOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:473
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:715
WritePodOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:719
Common interface for operations that reference a plain-old-data struct value.
mlir::ArrayRef< RecordValue > InitializedRecords
Definition Types.h:25
void printRecordName(AsmPrinter &printer, Operation *, StringAttr name)
Definition Ops.cpp:687
ParseResult parseRecordName(AsmParser &parser, StringAttr &name)
Definition Ops.cpp:678
Common interface for constant parameter-like symbol operations that can be defined within a TemplateO...
bool isValidType(Type type)