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
19#endif // GET_OP_LIST
20
21#ifdef GET_OP_CLASSES
22#undef GET_OP_CLASSES
23
24
25//===----------------------------------------------------------------------===//
26// Local Utility Method Definitions
27//===----------------------------------------------------------------------===//
28
29
30static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
31 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
32 unsigned valueIndex) {
33 if (!((::llvm::isa<::llzk::array::ArrayType>(type)))) {
34 return op->emitOpError(valueKind) << " #" << valueIndex
35 << " must be n-dimensional array, but got " << type;
36 }
37 return ::mlir::success();
38}
39
40static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops2(
41 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
42 unsigned valueIndex) {
43 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
44 return op->emitOpError(valueKind) << " #" << valueIndex
45 << " must be index, but got " << type;
46 }
47 return ::mlir::success();
48}
49
50static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops3(
51 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
52 unsigned valueIndex) {
53 if (!((::llzk::isValidArrayElemType(type)))) {
54 return op->emitOpError(valueKind) << " #" << valueIndex
55 << " must be variadic of a valid array element type, but got " << type;
56 }
57 return ::mlir::success();
58}
59
60static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops4(
61 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
62 unsigned valueIndex) {
63 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
64 return op->emitOpError(valueKind) << " #" << valueIndex
65 << " must be variadic of index, but got " << type;
66 }
67 return ::mlir::success();
68}
69
70static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops5(
71 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
72 unsigned valueIndex) {
73 if (!((::llzk::isValidArrayElemType(type)))) {
74 return op->emitOpError(valueKind) << " #" << valueIndex
75 << " must be a valid array element type, but got " << type;
76 }
77 return ::mlir::success();
78}
79
80static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
81 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
82 if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
83 return emitError() << "attribute '" << attrName
84 << "' failed to satisfy constraint: i32 dense array attribute";
85 return ::mlir::success();
86}
87static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
88 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
89 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
90 return op->emitOpError();
91 });
92}
93namespace llzk::array {
94
95
96//===----------------------------------------------------------------------===//
97// ::llzk::array::ArrayLengthOp definitions
98//===----------------------------------------------------------------------===//
99
100namespace detail {
101
103
104
105} // namespace detail
107
108::llvm::LogicalResult ArrayLengthOpAdaptor::verify(::mlir::Location loc) {
109 return ::mlir::success();
110}
111
112::llvm::LogicalResult ArrayLengthOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
113 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
114 if (!dict) {
115 emitError() << "expected DictionaryAttr to set properties";
116 return ::mlir::failure();
117 }
118 return ::mlir::success();
119}
120
121::mlir::Attribute ArrayLengthOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
122 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
123 ::mlir::Builder odsBuilder{ctx};
124
125 if (!attrs.empty())
126 return odsBuilder.getDictionaryAttr(attrs);
127 return {};
128}
129
131 using llvm::hash_value;
132 return llvm::hash_combine();
133}
134
135std::optional<mlir::Attribute> ArrayLengthOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
136 return std::nullopt;
137}
138
139void ArrayLengthOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
140}
141
142void ArrayLengthOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
143}
144
145::llvm::LogicalResult ArrayLengthOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
146 return ::mlir::success();
147}
148
149void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim) {
150 odsState.addOperands(arr_ref);
151 odsState.addOperands(dim);
152 odsState.addTypes(length);
153}
154
155ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim) {
156 ::mlir::OperationState __state__(location, getOperationName());
157 build(builder, __state__, std::forward<decltype(length)>(length), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
158 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
159 assert(__res__ && "builder didn't return the right type");
160 return __res__;
161}
162
163ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim) {
164 return create(builder, builder.getLoc(), std::forward<decltype(length)>(length), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
165}
166
167void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::Value dim) {
168 odsState.addOperands(arr_ref);
169 odsState.addOperands(dim);
170
171 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
172 if (::mlir::succeeded(ArrayLengthOp::inferReturnTypes(odsBuilder.getContext(),
173 odsState.location, odsState.operands,
174 odsState.attributes.getDictionary(odsState.getContext()),
175 odsState.getRawProperties(),
176 odsState.regions, inferredReturnTypes)))
177 odsState.addTypes(inferredReturnTypes);
178 else
179 ::mlir::detail::reportFatalInferReturnTypesError(odsState);
180
181}
182
183ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::Value dim) {
184 ::mlir::OperationState __state__(location, getOperationName());
185 build(builder, __state__, std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
186 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
187 assert(__res__ && "builder didn't return the right type");
188 return __res__;
189}
190
191ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arr_ref, ::mlir::Value dim) {
192 return create(builder, builder.getLoc(), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
193}
194
195void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::Value dim) {
196 odsState.addOperands(arr_ref);
197 odsState.addOperands(dim);
198 assert(resultTypes.size() == 1u && "mismatched number of results");
199 odsState.addTypes(resultTypes);
200}
201
202ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::Value dim) {
203 ::mlir::OperationState __state__(location, getOperationName());
204 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
205 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
206 assert(__res__ && "builder didn't return the right type");
207 return __res__;
208}
209
210ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::Value dim) {
211 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(dim)>(dim));
212}
213
214void ArrayLengthOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
215 assert(operands.size() == 2u && "mismatched number of parameters");
216 odsState.addOperands(operands);
217 odsState.addAttributes(attributes);
218 assert(resultTypes.size() == 1u && "mismatched number of return types");
219 odsState.addTypes(resultTypes);
220}
221
222ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
223 ::mlir::OperationState __state__(location, getOperationName());
224 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
225 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
226 assert(__res__ && "builder didn't return the right type");
227 return __res__;
228}
229
230ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
231 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
232}
233
234void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
235 assert(operands.size() == 2u && "mismatched number of parameters");
236 odsState.addOperands(operands);
237 odsState.addAttributes(attributes);
238
239 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
240 if (::mlir::succeeded(ArrayLengthOp::inferReturnTypes(odsBuilder.getContext(),
241 odsState.location, operands,
242 odsState.attributes.getDictionary(odsState.getContext()),
243 odsState.getRawProperties(),
244 odsState.regions, inferredReturnTypes))) {
245 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
246 odsState.addTypes(inferredReturnTypes);
247 } else {
248 ::llvm::report_fatal_error("Failed to infer result type(s).");
249 }
250}
251
252ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
253 ::mlir::OperationState __state__(location, getOperationName());
254 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
255 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
256 assert(__res__ && "builder didn't return the right type");
257 return __res__;
258}
259
260ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
261 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
262}
263
264void ArrayLengthOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
265 assert(operands.size() == 2u && "mismatched number of parameters");
266 odsState.addOperands(operands);
267 odsState.useProperties(const_cast<Properties&>(properties));
268 odsState.addAttributes(discardableAttributes);
269 assert(resultTypes.size() == 1u && "mismatched number of return types");
270 odsState.addTypes(resultTypes);
271}
272
273ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
274 ::mlir::OperationState __state__(location, getOperationName());
275 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
276 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
277 assert(__res__ && "builder didn't return the right type");
278 return __res__;
279}
280
281ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
282 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));
283}
284
285void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
286 assert(operands.size() == 2u && "mismatched number of parameters");
287 odsState.addOperands(operands);
288 odsState.useProperties(const_cast<Properties &>(properties));
289 odsState.addAttributes(discardableAttributes);
290
291 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
292 if (::mlir::succeeded(ArrayLengthOp::inferReturnTypes(odsBuilder.getContext(),
293 odsState.location, operands,
294 odsState.attributes.getDictionary(odsState.getContext()),
295 odsState.getRawProperties(),
296 odsState.regions, inferredReturnTypes))) {
297 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
298 odsState.addTypes(inferredReturnTypes);
299 } else {
300 ::llvm::report_fatal_error("Failed to infer result type(s).");
301 }
302}
303
304ArrayLengthOp ArrayLengthOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
305 ::mlir::OperationState __state__(location, getOperationName());
306 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
307 auto __res__ = ::llvm::dyn_cast<ArrayLengthOp>(builder.create(__state__));
308 assert(__res__ && "builder didn't return the right type");
309 return __res__;
310}
311
312ArrayLengthOp ArrayLengthOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
313 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
314}
315
316::llvm::LogicalResult ArrayLengthOp::verifyInvariantsImpl() {
317 {
318 unsigned index = 0; (void)index;
319 auto valueGroup0 = getODSOperands(0);
320
321 for (auto v : valueGroup0) {
322 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
323 return ::mlir::failure();
324 }
325 auto valueGroup1 = getODSOperands(1);
326
327 for (auto v : valueGroup1) {
328 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
329 return ::mlir::failure();
330 }
331 }
332 {
333 unsigned index = 0; (void)index;
334 auto valueGroup0 = getODSResults(0);
335
336 for (auto v : valueGroup0) {
337 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "result", index++)))
338 return ::mlir::failure();
339 }
340 }
341 return ::mlir::success();
342}
343
344::llvm::LogicalResult ArrayLengthOp::verifyInvariants() {
345 return verifyInvariantsImpl();
346}
347
348::llvm::LogicalResult ArrayLengthOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) {
349 inferredReturnTypes.resize(1);
350 ::mlir::Builder odsBuilder(context);
351 ::mlir::Type odsInferredType0 = odsBuilder.getIndexType();
352 inferredReturnTypes[0] = odsInferredType0;
353 return ::mlir::success();
354}
355
356::mlir::ParseResult ArrayLengthOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
357 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperand{};
358 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(&arr_refRawOperand, 1); ::llvm::SMLoc arr_refOperandsLoc;
359 (void)arr_refOperandsLoc;
360 ::mlir::OpAsmParser::UnresolvedOperand dimRawOperand{};
361 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dimOperands(&dimRawOperand, 1); ::llvm::SMLoc dimOperandsLoc;
362 (void)dimOperandsLoc;
363 ::mlir::Type arr_refRawType{};
364 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(&arr_refRawType, 1);
365
366 arr_refOperandsLoc = parser.getCurrentLocation();
367 if (parser.parseOperand(arr_refRawOperand))
368 return ::mlir::failure();
369 if (parser.parseComma())
370 return ::mlir::failure();
371
372 dimOperandsLoc = parser.getCurrentLocation();
373 if (parser.parseOperand(dimRawOperand))
374 return ::mlir::failure();
375 if (parser.parseColon())
376 return ::mlir::failure();
377
378 {
380 if (parser.parseCustomTypeWithFallback(type))
381 return ::mlir::failure();
382 arr_refRawType = type;
383 }
384 {
385 auto loc = parser.getCurrentLocation();(void)loc;
386 if (parser.parseOptionalAttrDict(result.attributes))
387 return ::mlir::failure();
388 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
389 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
390 })))
391 return ::mlir::failure();
392 }
393 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
394 result.addTypes(odsBuildableType0);
395 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
396 return ::mlir::failure();
397 if (parser.resolveOperands(dimOperands, odsBuildableType0, dimOperandsLoc, result.operands))
398 return ::mlir::failure();
399 return ::mlir::success();
400}
401
402void ArrayLengthOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
403 _odsPrinter << ' ';
404 _odsPrinter << getArrRef();
405 _odsPrinter << ",";
406 _odsPrinter << ' ';
407 _odsPrinter << getDim();
408 _odsPrinter << ' ' << ":";
409 _odsPrinter << ' ';
410 {
411 auto type = getArrRef().getType();
412 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
413 _odsPrinter.printStrippedAttrOrType(validType);
414 else
415 _odsPrinter << type;
416 }
417 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
418 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
419}
420
421void ArrayLengthOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
422}
423
424
425} // namespace llzk::array
426MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ArrayLengthOp)
427
428namespace llzk::array {
429
430
431//===----------------------------------------------------------------------===//
432// ::llzk::array::CreateArrayOp definitions
433//===----------------------------------------------------------------------===//
434
435namespace detail {
436
438
439std::pair<unsigned, unsigned> CreateArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
440 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
441
442 unsigned start = 0;
443 for (unsigned i = 0; i < index; ++i)
444 start += sizeAttr[i];
445 return {start, sizeAttr[index]};
446}
447
449 auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
450 return attr;
451}
452
454 auto attr = getNumDimsPerMapAttr();
455 return attr;
456}
457
459 auto attr = getMapOpGroupSizesAttr();
460 return attr;
461}
462
463
464} // namespace detail
466
467::llvm::LogicalResult CreateArrayOpAdaptor::verify(::mlir::Location loc) {
468 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
469 if (!tblgen_mapOpGroupSizes) return emitError(loc, "'array.new' op requires attribute 'mapOpGroupSizes'");
470 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
471
472 if (tblgen_numDimsPerMap && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numDimsPerMap))))
473 return emitError(loc, "'array.new' op attribute 'numDimsPerMap' failed to satisfy constraint: i32 dense array attribute");
474
475 if (tblgen_mapOpGroupSizes && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_mapOpGroupSizes))))
476 return emitError(loc, "'array.new' op attribute 'mapOpGroupSizes' failed to satisfy constraint: i32 dense array attribute");
477 return ::mlir::success();
478}
479
480std::pair<unsigned, unsigned> CreateArrayOp::getODSOperandIndexAndLength(unsigned index) {
481 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
482
483 unsigned start = 0;
484 for (unsigned i = 0; i < index; ++i)
485 start += sizeAttr[i];
486 return {start, sizeAttr[index]};
487}
488
489::mlir::MutableOperandRange CreateArrayOp::getElementsMutable() {
490 auto range = getODSOperandIndexAndLength(0);
491 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
492 return mutableRange;
493}
494
495::mlir::MutableOperandRangeRange CreateArrayOp::getMapOperandsMutable() {
496 auto range = getODSOperandIndexAndLength(1);
497 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
498 return mutableRange.split(*(*this)->getAttrDictionary().getNamed(getMapOpGroupSizesAttrName()));
499}
500
501::llvm::LogicalResult CreateArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
502 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
503 if (!dict) {
504 emitError() << "expected DictionaryAttr to set properties";
505 return ::mlir::failure();
506 }
507
508 {
509 auto &propStorage = prop.mapOpGroupSizes;
510 auto attr = dict.get("mapOpGroupSizes");
511 if (attr) {
512 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
513 if (convertedAttr) {
514 propStorage = convertedAttr;
515 } else {
516 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
517 return ::mlir::failure();
518 }
519 }
520 }
521
522 {
523 auto &propStorage = prop.numDimsPerMap;
524 auto attr = dict.get("numDimsPerMap");
525 if (attr) {
526 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
527 if (convertedAttr) {
528 propStorage = convertedAttr;
529 } else {
530 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
531 return ::mlir::failure();
532 }
533 }
534 }
535{
536
537 auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
538 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {
539 return convertFromAttribute(propStorage, propAttr, emitError);
540 };
541 auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
542;
543 if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() {
544 return emitError() << "for `operandSegmentSizes`: ";
545 })))
546 return ::mlir::failure();
547 }
548 return ::mlir::success();
549}
550
551::mlir::Attribute CreateArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
552 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
553 ::mlir::Builder odsBuilder{ctx};
554
555 {
556 const auto &propStorage = prop.mapOpGroupSizes;
557 if (propStorage)
558 attrs.push_back(odsBuilder.getNamedAttr("mapOpGroupSizes",
559 propStorage));
560 }
561
562 {
563 const auto &propStorage = prop.numDimsPerMap;
564 if (propStorage)
565 attrs.push_back(odsBuilder.getNamedAttr("numDimsPerMap",
566 propStorage));
567 }
568
569 {
570 const auto &propStorage = prop.operandSegmentSizes;
571 auto attr = [&]() -> ::mlir::Attribute {
572 return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
573 }();
574 attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
575 }
576
577 if (!attrs.empty())
578 return odsBuilder.getDictionaryAttr(attrs);
579 return {};
580}
581
583 auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code {
584 using ::llvm::hash_value;
585 return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
586 };
587 using llvm::hash_value;
588 return llvm::hash_combine(
589 llvm::hash_value(prop.mapOpGroupSizes.getAsOpaquePointer()),
590 llvm::hash_value(prop.numDimsPerMap.getAsOpaquePointer()),
591 hash_operandSegmentSizes_(prop.operandSegmentSizes));
592}
593
594std::optional<mlir::Attribute> CreateArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
595 if (name == "mapOpGroupSizes")
596 return prop.mapOpGroupSizes;
597
598 if (name == "numDimsPerMap")
599 return prop.numDimsPerMap;
600 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
601 return std::nullopt;
602}
603
604void CreateArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
605 if (name == "mapOpGroupSizes") {
606 prop.mapOpGroupSizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapOpGroupSizes)>>(value);
607 return;
608 }
609
610 if (name == "numDimsPerMap") {
611 prop.numDimsPerMap = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDimsPerMap)>>(value);
612 return;
613 }
614 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") {
615 auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value);
616 if (!arrAttr) return;
617 if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t))
618 return;
619 llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin());
620 return;
621 }
622}
623
624void CreateArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
625 if (prop.mapOpGroupSizes) attrs.append("mapOpGroupSizes", prop.mapOpGroupSizes);
626
627 if (prop.numDimsPerMap) attrs.append("numDimsPerMap", prop.numDimsPerMap);
628 attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
629}
630
631::llvm::LogicalResult CreateArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
632 {
633 ::mlir::Attribute attr = attrs.get(getMapOpGroupSizesAttrName(opName));
634 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "mapOpGroupSizes", emitError)))
635 return ::mlir::failure();
636 }
637
638 {
639 ::mlir::Attribute attr = attrs.get(getNumDimsPerMapAttrName(opName));
640 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "numDimsPerMap", emitError)))
641 return ::mlir::failure();
642 }
643 return ::mlir::success();
644}
645
646::llvm::LogicalResult CreateArrayOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
647 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
648 if (::mlir::failed(reader.readAttribute(prop.mapOpGroupSizes)))
649 return ::mlir::failure();
650
651 if (::mlir::failed(reader.readOptionalAttribute(prop.numDimsPerMap)))
652 return ::mlir::failure();
653
654 if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
655 auto &propStorage = prop.operandSegmentSizes;
656 ::mlir::DenseI32ArrayAttr attr;
657 if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
658 if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
659 reader.emitError("size mismatch for operand/result_segment_size");
660 return ::mlir::failure();
661 }
662 ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
663 }
664
665 {
666 auto &propStorage = prop.operandSegmentSizes;
667 auto readProp = [&]() {
668
669 if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
670 return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
671;
672 return ::mlir::success();
673 };
674 if (::mlir::failed(readProp()))
675 return ::mlir::failure();
676 }
677 return ::mlir::success();
678}
679
680void CreateArrayOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
681 auto &prop = getProperties(); (void)prop;
682 writer.writeAttribute(prop.mapOpGroupSizes);
683
684 writer.writeOptionalAttribute(prop.numDimsPerMap);
685
686if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
687 auto &propStorage = prop.operandSegmentSizes;
688 writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
689}
690
691 {
692 auto &propStorage = prop.operandSegmentSizes;
693
694 if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
695 writer.writeSparseArray(::llvm::ArrayRef(propStorage));
696;
697 }
698}
699
700::llvm::ArrayRef<int32_t> CreateArrayOp::getNumDimsPerMap() {
701 auto attr = getNumDimsPerMapAttr();
702 return attr;
703}
704
705::llvm::ArrayRef<int32_t> CreateArrayOp::getMapOpGroupSizes() {
706 auto attr = getMapOpGroupSizesAttr();
707 return attr;
708}
709
710void CreateArrayOp::setNumDimsPerMap(::llvm::ArrayRef<int32_t> attrValue) {
711 getProperties().numDimsPerMap = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
712}
713
714void CreateArrayOp::setMapOpGroupSizes(::llvm::ArrayRef<int32_t> attrValue) {
715 getProperties().mapOpGroupSizes = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
716}
717
718CreateArrayOp CreateArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::array::ArrayType result, ::mlir::ValueRange elements) {
719 ::mlir::OperationState __state__(location, getOperationName());
720 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(elements)>(elements));
721 auto __res__ = ::llvm::dyn_cast<CreateArrayOp>(builder.create(__state__));
722 assert(__res__ && "builder didn't return the right type");
723 return __res__;
724}
725
726CreateArrayOp CreateArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::array::ArrayType result, ::mlir::ValueRange elements) {
727 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(elements)>(elements));
728}
729
730CreateArrayOp CreateArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap) {
731 ::mlir::OperationState __state__(location, getOperationName());
732 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap));
733 auto __res__ = ::llvm::dyn_cast<CreateArrayOp>(builder.create(__state__));
734 assert(__res__ && "builder didn't return the right type");
735 return __res__;
736}
737
738CreateArrayOp CreateArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::mlir::DenseI32ArrayAttr numDimsPerMap) {
739 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap));
740}
741
742void CreateArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap) {
743 build(odsBuilder, odsState, result, mapOperands, odsBuilder.getDenseI32ArrayAttr(numDimsPerMap));
744
745}
746
747CreateArrayOp CreateArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap) {
748 ::mlir::OperationState __state__(location, getOperationName());
749 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap));
750 auto __res__ = ::llvm::dyn_cast<CreateArrayOp>(builder.create(__state__));
751 assert(__res__ && "builder didn't return the right type");
752 return __res__;
753}
754
755CreateArrayOp CreateArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap) {
756 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(mapOperands)>(mapOperands), std::forward<decltype(numDimsPerMap)>(numDimsPerMap));
757}
758
759void CreateArrayOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
760 ::mlir::Builder odsBuilder(opName.getContext());
761 if (!properties.numDimsPerMap)
762 properties.numDimsPerMap = odsBuilder.getDenseI32ArrayAttr({});
763}
764
765::llvm::LogicalResult CreateArrayOp::verifyInvariantsImpl() {
766 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
767 if (!tblgen_mapOpGroupSizes) return emitOpError("requires attribute 'mapOpGroupSizes'");
768 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
769
770 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_numDimsPerMap, "numDimsPerMap")))
771 return ::mlir::failure();
772
773 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_mapOpGroupSizes, "mapOpGroupSizes")))
774 return ::mlir::failure();
775 {
776 unsigned index = 0; (void)index;
777 auto valueGroup0 = getODSOperands(0);
778
779 for (auto v : valueGroup0) {
780 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
781 return ::mlir::failure();
782 }
783 auto valueGroup1 = getODSOperands(1);
784 if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr(*this, "mapOpGroupSizes", "mapOperands", valueGroup1.size())))
785 return ::mlir::failure();
786
787 for (auto v : valueGroup1) {
788 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
789 return ::mlir::failure();
790 }
791 }
792 {
793 unsigned index = 0; (void)index;
794 auto valueGroup0 = getODSResults(0);
795
796 for (auto v : valueGroup0) {
797 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
798 return ::mlir::failure();
799 }
800 }
801 if (!((getElements().empty() || std::equal_to<>()(resultTypeToElementsTypes((*this->getODSResults(0).begin()).getType()), this->getODSOperands(0).getType()))))
802 return emitOpError("failed to verify that operand types match result type");
803 return ::mlir::success();
804}
805
806::llvm::LogicalResult CreateArrayOp::verifyInvariants() {
807 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
808 return ::mlir::success();
809 return ::mlir::failure();
810}
811
812::mlir::ParseResult CreateArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
813 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> mapOperandsOperands;
814 llvm::SmallVector<int32_t> mapOperandsOperandGroupSizes;
815 ::llvm::SMLoc mapOperandsOperandsLoc;
816 (void)mapOperandsOperandsLoc;
817 ::mlir::DenseI32ArrayAttr numDimsPerMapAttr;
818 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> elementsOperands;
819 ::llvm::SMLoc elementsOperandsLoc;
820 (void)elementsOperandsLoc;
821 ::mlir::Type resultRawType{};
822 ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1);
823 ::llvm::SmallVector<::mlir::Type, 1> elementsTypes;
824 if (::mlir::succeeded(parser.parseOptionalLBrace())) {
825 {
826 mapOperandsOperandsLoc = parser.getCurrentLocation();
827 ::llvm::SmallVector<::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand>> mapOperandsOperandGroups;
828 auto odsResult = parseMultiDimAndSymbolList(parser, mapOperandsOperandGroups, numDimsPerMapAttr);
829 if (odsResult) return ::mlir::failure();
830 for (const auto &subRange : mapOperandsOperandGroups) {
831 mapOperandsOperands.append(subRange.begin(), subRange.end());
832 mapOperandsOperandGroupSizes.push_back(subRange.size());
833 }
834 if (numDimsPerMapAttr)
835 result.getOrAddProperties<CreateArrayOp::Properties>().numDimsPerMap = numDimsPerMapAttr;
836 }
837 if (parser.parseRBrace())
838 return ::mlir::failure();
839 } else {
840
841 elementsOperandsLoc = parser.getCurrentLocation();
842 if (parser.parseOperandList(elementsOperands))
843 return ::mlir::failure();
844 }
845 if (parser.parseColon())
846 return ::mlir::failure();
847
848 {
850 if (parser.parseCustomTypeWithFallback(type))
851 return ::mlir::failure();
852 resultRawType = type;
853 }
854 {
855 auto odsResult = parseInferredArrayType(parser, elementsTypes, elementsOperands, resultRawType);
856 if (odsResult) return ::mlir::failure();
857 }
858 {
859 auto odsResult = parseAttrDictWithWarnings(parser, result.attributes, result);
860 if (odsResult) return ::mlir::failure();
861 }
862::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(elementsOperands.size()), static_cast<int32_t>(mapOperandsOperands.size())}), result.getOrAddProperties<CreateArrayOp::Properties>().operandSegmentSizes.begin());
863 result.getOrAddProperties<CreateArrayOp::Properties>().mapOpGroupSizes = parser.getBuilder().getDenseI32ArrayAttr(mapOperandsOperandGroupSizes);
864 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
865 result.addTypes(resultTypes);
866 if (parser.resolveOperands(elementsOperands, elementsTypes, elementsOperandsLoc, result.operands))
867 return ::mlir::failure();
868 if (parser.resolveOperands(mapOperandsOperands, odsBuildableType0, mapOperandsOperandsLoc, result.operands))
869 return ::mlir::failure();
870 return ::mlir::success();
871}
872
873::llvm::LogicalResult CreateArrayOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
874 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
875 if (!dict) {
876 emitError() << "expected DictionaryAttr to set properties";
877 return ::mlir::failure();
878 }
879 // keep track of used keys in the input dictionary to be able to error out
880 // if there are some unknown ones.
881 ::mlir::DenseSet<::mlir::StringAttr> usedKeys;
882 ::mlir::MLIRContext *ctx = dict.getContext();
883 (void)ctx;
884 {
885
886 auto &propStorage = prop.mapOpGroupSizes;
887 auto mapOpGroupSizesAttrName = ::mlir::StringAttr::get(ctx, "mapOpGroupSizes");
888 auto attr = dict.get(mapOpGroupSizesAttrName);
889 usedKeys.insert(mapOpGroupSizesAttrName);
890 if (attr || /*isRequired=*/true) {
891 if (!attr) {
892 emitError() << "expected key entry for mapOpGroupSizes in DictionaryAttr to set "
893 "Properties.";
894 return ::mlir::failure();
895 }
896 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
897 if (convertedAttr) {
898 propStorage = convertedAttr;
899 } else {
900 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
901 return ::mlir::failure();
902 }
903 }
904 }
905
906 for (::mlir::NamedAttribute attr : dict) {
907 if (!usedKeys.contains(attr.getName()))
908 return emitError() << "unknown key '" << attr.getName() <<
909 "' when parsing properties dictionary";
910 }
911 return ::mlir::success();
912}
913
914void CreateArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
915 if (((!getMapOperands().empty()) || (getNumDimsPerMapAttr() != ::mlir::OpBuilder((*this)->getContext()).getDenseI32ArrayAttr({})))) {
916 _odsPrinter << "{";
918 _odsPrinter << "}";
919 } else {
920 _odsPrinter << ' ';
921 _odsPrinter << getElements();
922 }
923 _odsPrinter << ' ' << ":";
924 _odsPrinter << ' ';
925 {
926 auto type = getResult().getType();
927 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
928 _odsPrinter.printStrippedAttrOrType(validType);
929 else
930 _odsPrinter << type;
931 }
932 printInferredArrayType(_odsPrinter, *this, getElements().getTypes(), getElements(), getResult().getType());
933 _odsPrinter << ' ';
934 printAttrDictWithWarnings(_odsPrinter, *this, getOperation()->getAttrDictionary(), getProperties());
935}
936
937void CreateArrayOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
938 effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), 0, false, ::llzk::DiscardableAllocationResource::get());
939}
940
941
942} // namespace llzk::array
943MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::CreateArrayOp)
945
946namespace llzk::array {
947
948
949//===----------------------------------------------------------------------===//
950// ::llzk::array::ExtractArrayOp definitions
951//===----------------------------------------------------------------------===//
952
953namespace detail {
954
956
957std::pair<unsigned, unsigned> ExtractArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
958 bool isVariadic[] = {false, true};
959 int prevVariadicCount = 0;
960 for (unsigned i = 0; i < index; ++i)
961 if (isVariadic[i]) ++prevVariadicCount;
962
963 // Calculate how many dynamic values a static variadic operand corresponds to.
964 // This assumes all static variadic operands have the same dynamic value count.
965 int variadicSize = (odsOperandsSize - 1) / 1;
966 // `index` passed in as the parameter is the static index which counts each
967 // operand (variadic or not) as size 1. So here for each previous static variadic
968 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
969 // value pack for this static operand starts.
970 int start = index + (variadicSize - 1) * prevVariadicCount;
971 int size = isVariadic[index] ? variadicSize : 1;
972 return {start, size};
973}
974
975
976} // namespace detail
978
979::llvm::LogicalResult ExtractArrayOpAdaptor::verify(::mlir::Location loc) {
980 return ::mlir::success();
981}
982
983std::pair<unsigned, unsigned> ExtractArrayOp::getODSOperandIndexAndLength(unsigned index) {
984 bool isVariadic[] = {false, true};
985 int prevVariadicCount = 0;
986 for (unsigned i = 0; i < index; ++i)
987 if (isVariadic[i]) ++prevVariadicCount;
988
989 // Calculate how many dynamic values a static variadic operand corresponds to.
990 // This assumes all static variadic operands have the same dynamic value count.
991 int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
992 // `index` passed in as the parameter is the static index which counts each
993 // operand (variadic or not) as size 1. So here for each previous static variadic
994 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
995 // value pack for this static operand starts.
996 int start = index + (variadicSize - 1) * prevVariadicCount;
997 int size = isVariadic[index] ? variadicSize : 1;
998 return {start, size};
999}
1000
1001::mlir::MutableOperandRange ExtractArrayOp::getIndicesMutable() {
1002 auto range = getODSOperandIndexAndLength(1);
1003 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1004 return mutableRange;
1005}
1006
1007::llvm::LogicalResult ExtractArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1008 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1009 if (!dict) {
1010 emitError() << "expected DictionaryAttr to set properties";
1011 return ::mlir::failure();
1012 }
1013 return ::mlir::success();
1014}
1015
1016::mlir::Attribute ExtractArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1017 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1018 ::mlir::Builder odsBuilder{ctx};
1019
1020 if (!attrs.empty())
1021 return odsBuilder.getDictionaryAttr(attrs);
1022 return {};
1023}
1024
1026 using llvm::hash_value;
1027 return llvm::hash_combine();
1028}
1029
1030std::optional<mlir::Attribute> ExtractArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1031 return std::nullopt;
1032}
1033
1034void ExtractArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1035}
1036
1037void ExtractArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1038}
1039
1040::llvm::LogicalResult ExtractArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1041 return ::mlir::success();
1042}
1043
1044void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1045 odsState.addOperands(arr_ref);
1046 odsState.addOperands(indices);
1047 odsState.addTypes(result);
1048}
1049
1050ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1051 ::mlir::OperationState __state__(location, getOperationName());
1052 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1053 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1054 assert(__res__ && "builder didn't return the right type");
1055 return __res__;
1056}
1057
1058ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1059 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1060}
1061
1062void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1063 odsState.addOperands(arr_ref);
1064 odsState.addOperands(indices);
1065
1066 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1067 if (::mlir::succeeded(ExtractArrayOp::inferReturnTypes(odsBuilder.getContext(),
1068 odsState.location, odsState.operands,
1069 odsState.attributes.getDictionary(odsState.getContext()),
1070 odsState.getRawProperties(),
1071 odsState.regions, inferredReturnTypes)))
1072 odsState.addTypes(inferredReturnTypes);
1073 else
1074 ::mlir::detail::reportFatalInferReturnTypesError(odsState);
1075
1076}
1077
1078ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1079 ::mlir::OperationState __state__(location, getOperationName());
1080 build(builder, __state__, std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1081 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1082 assert(__res__ && "builder didn't return the right type");
1083 return __res__;
1084}
1085
1086ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1087 return create(builder, builder.getLoc(), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1088}
1089
1090void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1091 odsState.addOperands(arr_ref);
1092 odsState.addOperands(indices);
1093 assert(resultTypes.size() == 1u && "mismatched number of results");
1094 odsState.addTypes(resultTypes);
1095}
1096
1097ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1098 ::mlir::OperationState __state__(location, getOperationName());
1099 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1100 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1101 assert(__res__ && "builder didn't return the right type");
1102 return __res__;
1103}
1104
1105ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1106 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1107}
1108
1109void ExtractArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1110 assert(operands.size() >= 1u && "mismatched number of parameters");
1111 odsState.addOperands(operands);
1112 odsState.addAttributes(attributes);
1113 assert(resultTypes.size() == 1u && "mismatched number of return types");
1114 odsState.addTypes(resultTypes);
1115}
1116
1117ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1118 ::mlir::OperationState __state__(location, getOperationName());
1119 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1120 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1121 assert(__res__ && "builder didn't return the right type");
1122 return __res__;
1123}
1124
1125ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1126 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1127}
1128
1129void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1130 assert(operands.size() >= 1u && "mismatched number of parameters");
1131 odsState.addOperands(operands);
1132 odsState.addAttributes(attributes);
1133
1134 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1135 if (::mlir::succeeded(ExtractArrayOp::inferReturnTypes(odsBuilder.getContext(),
1136 odsState.location, operands,
1137 odsState.attributes.getDictionary(odsState.getContext()),
1138 odsState.getRawProperties(),
1139 odsState.regions, inferredReturnTypes))) {
1140 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
1141 odsState.addTypes(inferredReturnTypes);
1142 } else {
1143 ::llvm::report_fatal_error("Failed to infer result type(s).");
1144 }
1145}
1146
1147ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1148 ::mlir::OperationState __state__(location, getOperationName());
1149 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1150 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1151 assert(__res__ && "builder didn't return the right type");
1152 return __res__;
1153}
1154
1155ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1156 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1157}
1158
1159void ExtractArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1160 assert(operands.size() >= 1u && "mismatched number of parameters");
1161 odsState.addOperands(operands);
1162 odsState.useProperties(const_cast<Properties&>(properties));
1163 odsState.addAttributes(discardableAttributes);
1164 assert(resultTypes.size() == 1u && "mismatched number of return types");
1165 odsState.addTypes(resultTypes);
1166}
1167
1168ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1169 ::mlir::OperationState __state__(location, getOperationName());
1170 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1171 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1172 assert(__res__ && "builder didn't return the right type");
1173 return __res__;
1174}
1175
1176ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1177 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));
1178}
1179
1180void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1181 assert(operands.size() >= 1u && "mismatched number of parameters");
1182 odsState.addOperands(operands);
1183 odsState.useProperties(const_cast<Properties &>(properties));
1184 odsState.addAttributes(discardableAttributes);
1185
1186 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1187 if (::mlir::succeeded(ExtractArrayOp::inferReturnTypes(odsBuilder.getContext(),
1188 odsState.location, operands,
1189 odsState.attributes.getDictionary(odsState.getContext()),
1190 odsState.getRawProperties(),
1191 odsState.regions, inferredReturnTypes))) {
1192 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
1193 odsState.addTypes(inferredReturnTypes);
1194 } else {
1195 ::llvm::report_fatal_error("Failed to infer result type(s).");
1196 }
1197}
1198
1199ExtractArrayOp ExtractArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1200 ::mlir::OperationState __state__(location, getOperationName());
1201 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1202 auto __res__ = ::llvm::dyn_cast<ExtractArrayOp>(builder.create(__state__));
1203 assert(__res__ && "builder didn't return the right type");
1204 return __res__;
1205}
1206
1207ExtractArrayOp ExtractArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1208 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1209}
1210
1212 {
1213 unsigned index = 0; (void)index;
1214 auto valueGroup0 = getODSOperands(0);
1215
1216 for (auto v : valueGroup0) {
1217 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1218 return ::mlir::failure();
1219 }
1220 auto valueGroup1 = getODSOperands(1);
1221
1222 for (auto v : valueGroup1) {
1223 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
1224 return ::mlir::failure();
1225 }
1226 }
1227 {
1228 unsigned index = 0; (void)index;
1229 auto valueGroup0 = getODSResults(0);
1230
1231 for (auto v : valueGroup0) {
1232 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
1233 return ::mlir::failure();
1234 }
1235 }
1236 return ::mlir::success();
1237}
1238
1239::llvm::LogicalResult ExtractArrayOp::verifyInvariants() {
1240 return verifyInvariantsImpl();
1241}
1242
1243::mlir::ParseResult ExtractArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1244 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperand{};
1245 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(&arr_refRawOperand, 1); ::llvm::SMLoc arr_refOperandsLoc;
1246 (void)arr_refOperandsLoc;
1247 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1248 ::llvm::SMLoc indicesOperandsLoc;
1249 (void)indicesOperandsLoc;
1250 ::mlir::Type arr_refRawType{};
1251 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(&arr_refRawType, 1);
1252
1253 arr_refOperandsLoc = parser.getCurrentLocation();
1254 if (parser.parseOperand(arr_refRawOperand))
1255 return ::mlir::failure();
1256 if (parser.parseLSquare())
1257 return ::mlir::failure();
1258
1259 indicesOperandsLoc = parser.getCurrentLocation();
1260 if (parser.parseOperandList(indicesOperands))
1261 return ::mlir::failure();
1262 if (parser.parseRSquare())
1263 return ::mlir::failure();
1264 if (parser.parseColon())
1265 return ::mlir::failure();
1266
1267 {
1269 if (parser.parseCustomTypeWithFallback(type))
1270 return ::mlir::failure();
1271 arr_refRawType = type;
1272 }
1273 {
1274 auto loc = parser.getCurrentLocation();(void)loc;
1275 if (parser.parseOptionalAttrDict(result.attributes))
1276 return ::mlir::failure();
1277 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
1278 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
1279 })))
1280 return ::mlir::failure();
1281 }
1282 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1283 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1284 return ::mlir::failure();
1285 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1286 return ::mlir::failure();
1287
1288 ::llvm::SmallVector<::mlir::Type> inferredReturnTypes;
1289 if (::mlir::failed(ExtractArrayOp::inferReturnTypes(parser.getContext(),
1290 result.location, result.operands,
1291 result.attributes.getDictionary(parser.getContext()),
1292 result.getRawProperties(),
1293 result.regions, inferredReturnTypes)))
1294 return ::mlir::failure();
1295 result.addTypes(inferredReturnTypes);
1296 return ::mlir::success();
1297}
1298
1299void ExtractArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1300 _odsPrinter << ' ';
1301 _odsPrinter << getArrRef();
1302 _odsPrinter << "[";
1303 _odsPrinter << getIndices();
1304 _odsPrinter << "]";
1305 _odsPrinter << ' ' << ":";
1306 _odsPrinter << ' ';
1307 {
1308 auto type = getArrRef().getType();
1309 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1310 _odsPrinter.printStrippedAttrOrType(validType);
1311 else
1312 _odsPrinter << type;
1313 }
1314 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1315 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1316}
1317
1318 ::llvm::LogicalResult
1319 ExtractArrayOp::inferReturnTypes(::mlir::MLIRContext *context,
1320 std::optional<::mlir::Location> location,
1321 ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
1322 ::mlir::PropertyRef properties, ::mlir::RegionRange regions,
1323 ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
1324 ExtractArrayOp::Adaptor adaptor(operands, attributes, properties, regions);
1325 return ExtractArrayOp::inferReturnTypes(context,
1326 location, adaptor, inferredReturnTypes);
1327 }
1328
1329
1332 return true;
1333}
1334
1335} // namespace llzk::array
1336MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ExtractArrayOp)
1337
1338namespace llzk::array {
1339
1340
1341//===----------------------------------------------------------------------===//
1342// ::llzk::array::InsertArrayOp definitions
1343//===----------------------------------------------------------------------===//
1344
1345namespace detail {
1346
1348
1349std::pair<unsigned, unsigned> InsertArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1350 bool isVariadic[] = {false, true, false};
1351 int prevVariadicCount = 0;
1352 for (unsigned i = 0; i < index; ++i)
1353 if (isVariadic[i]) ++prevVariadicCount;
1354
1355 // Calculate how many dynamic values a static variadic operand corresponds to.
1356 // This assumes all static variadic operands have the same dynamic value count.
1357 int variadicSize = (odsOperandsSize - 2) / 1;
1358 // `index` passed in as the parameter is the static index which counts each
1359 // operand (variadic or not) as size 1. So here for each previous static variadic
1360 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1361 // value pack for this static operand starts.
1362 int start = index + (variadicSize - 1) * prevVariadicCount;
1363 int size = isVariadic[index] ? variadicSize : 1;
1364 return {start, size};
1365}
1366
1367
1368} // namespace detail
1370
1371::llvm::LogicalResult InsertArrayOpAdaptor::verify(::mlir::Location loc) {
1372 return ::mlir::success();
1373}
1374
1375std::pair<unsigned, unsigned> InsertArrayOp::getODSOperandIndexAndLength(unsigned index) {
1376 bool isVariadic[] = {false, true, false};
1377 int prevVariadicCount = 0;
1378 for (unsigned i = 0; i < index; ++i)
1379 if (isVariadic[i]) ++prevVariadicCount;
1380
1381 // Calculate how many dynamic values a static variadic operand corresponds to.
1382 // This assumes all static variadic operands have the same dynamic value count.
1383 int variadicSize = (getOperation()->getNumOperands() - 2) / 1;
1384 // `index` passed in as the parameter is the static index which counts each
1385 // operand (variadic or not) as size 1. So here for each previous static variadic
1386 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1387 // value pack for this static operand starts.
1388 int start = index + (variadicSize - 1) * prevVariadicCount;
1389 int size = isVariadic[index] ? variadicSize : 1;
1390 return {start, size};
1391}
1392
1393::mlir::MutableOperandRange InsertArrayOp::getIndicesMutable() {
1394 auto range = getODSOperandIndexAndLength(1);
1395 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1396 return mutableRange;
1397}
1398
1399::llvm::LogicalResult InsertArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1400 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1401 if (!dict) {
1402 emitError() << "expected DictionaryAttr to set properties";
1403 return ::mlir::failure();
1404 }
1405 return ::mlir::success();
1406}
1407
1408::mlir::Attribute InsertArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1409 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1410 ::mlir::Builder odsBuilder{ctx};
1411
1412 if (!attrs.empty())
1413 return odsBuilder.getDictionaryAttr(attrs);
1414 return {};
1415}
1416
1418 using llvm::hash_value;
1419 return llvm::hash_combine();
1420}
1421
1422std::optional<mlir::Attribute> InsertArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1423 return std::nullopt;
1424}
1425
1426void InsertArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1427}
1428
1429void InsertArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1430}
1431
1432::llvm::LogicalResult InsertArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1433 return ::mlir::success();
1434}
1435
1436void InsertArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1437 odsState.addOperands(arr_ref);
1438 odsState.addOperands(indices);
1439 odsState.addOperands(rvalue);
1440}
1441
1442InsertArrayOp InsertArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1443 ::mlir::OperationState __state__(location, getOperationName());
1444 build(builder, __state__, std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
1445 auto __res__ = ::llvm::dyn_cast<InsertArrayOp>(builder.create(__state__));
1446 assert(__res__ && "builder didn't return the right type");
1447 return __res__;
1448}
1449
1450InsertArrayOp InsertArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1451 return create(builder, builder.getLoc(), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
1452}
1453
1454void InsertArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1455 odsState.addOperands(arr_ref);
1456 odsState.addOperands(indices);
1457 odsState.addOperands(rvalue);
1458 assert(resultTypes.size() == 0u && "mismatched number of results");
1459 odsState.addTypes(resultTypes);
1460}
1461
1462InsertArrayOp InsertArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1463 ::mlir::OperationState __state__(location, getOperationName());
1464 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
1465 auto __res__ = ::llvm::dyn_cast<InsertArrayOp>(builder.create(__state__));
1466 assert(__res__ && "builder didn't return the right type");
1467 return __res__;
1468}
1469
1470InsertArrayOp InsertArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1471 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
1472}
1473
1474void InsertArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1475 assert(operands.size() >= 2u && "mismatched number of parameters");
1476 odsState.addOperands(operands);
1477 odsState.addAttributes(attributes);
1478 assert(resultTypes.size() == 0u && "mismatched number of return types");
1479 odsState.addTypes(resultTypes);
1480}
1481
1482InsertArrayOp InsertArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1483 ::mlir::OperationState __state__(location, getOperationName());
1484 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1485 auto __res__ = ::llvm::dyn_cast<InsertArrayOp>(builder.create(__state__));
1486 assert(__res__ && "builder didn't return the right type");
1487 return __res__;
1488}
1489
1490InsertArrayOp InsertArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1491 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1492}
1493
1494void InsertArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1495 assert(operands.size() >= 2u && "mismatched number of parameters");
1496 odsState.addOperands(operands);
1497 odsState.useProperties(const_cast<Properties&>(properties));
1498 odsState.addAttributes(discardableAttributes);
1499 assert(resultTypes.size() == 0u && "mismatched number of return types");
1500 odsState.addTypes(resultTypes);
1501}
1502
1503InsertArrayOp InsertArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1504 ::mlir::OperationState __state__(location, getOperationName());
1505 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1506 auto __res__ = ::llvm::dyn_cast<InsertArrayOp>(builder.create(__state__));
1507 assert(__res__ && "builder didn't return the right type");
1508 return __res__;
1509}
1510
1511InsertArrayOp InsertArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1512 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));
1513}
1514
1516 {
1517 unsigned index = 0; (void)index;
1518 auto valueGroup0 = getODSOperands(0);
1519
1520 for (auto v : valueGroup0) {
1521 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1522 return ::mlir::failure();
1523 }
1524 auto valueGroup1 = getODSOperands(1);
1525
1526 for (auto v : valueGroup1) {
1527 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
1528 return ::mlir::failure();
1529 }
1530 auto valueGroup2 = getODSOperands(2);
1531
1532 for (auto v : valueGroup2) {
1533 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1534 return ::mlir::failure();
1535 }
1536 }
1537 return ::mlir::success();
1538}
1539
1540::llvm::LogicalResult InsertArrayOp::verifyInvariants() {
1541 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1542 return ::mlir::success();
1543 return ::mlir::failure();
1544}
1545
1546::mlir::ParseResult InsertArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1547 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperand{};
1548 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(&arr_refRawOperand, 1); ::llvm::SMLoc arr_refOperandsLoc;
1549 (void)arr_refOperandsLoc;
1550 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1551 ::llvm::SMLoc indicesOperandsLoc;
1552 (void)indicesOperandsLoc;
1553 ::mlir::OpAsmParser::UnresolvedOperand rvalueRawOperand{};
1554 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rvalueOperands(&rvalueRawOperand, 1); ::llvm::SMLoc rvalueOperandsLoc;
1555 (void)rvalueOperandsLoc;
1556 ::mlir::Type arr_refRawType{};
1557 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(&arr_refRawType, 1);
1558 ::mlir::Type rvalueRawType{};
1559 ::llvm::ArrayRef<::mlir::Type> rvalueTypes(&rvalueRawType, 1);
1560
1561 arr_refOperandsLoc = parser.getCurrentLocation();
1562 if (parser.parseOperand(arr_refRawOperand))
1563 return ::mlir::failure();
1564 if (parser.parseLSquare())
1565 return ::mlir::failure();
1566
1567 indicesOperandsLoc = parser.getCurrentLocation();
1568 if (parser.parseOperandList(indicesOperands))
1569 return ::mlir::failure();
1570 if (parser.parseRSquare())
1571 return ::mlir::failure();
1572 if (parser.parseEqual())
1573 return ::mlir::failure();
1574
1575 rvalueOperandsLoc = parser.getCurrentLocation();
1576 if (parser.parseOperand(rvalueRawOperand))
1577 return ::mlir::failure();
1578 if (parser.parseColon())
1579 return ::mlir::failure();
1580
1581 {
1583 if (parser.parseCustomTypeWithFallback(type))
1584 return ::mlir::failure();
1585 arr_refRawType = type;
1586 }
1587 if (parser.parseComma())
1588 return ::mlir::failure();
1589
1590 {
1592 if (parser.parseCustomTypeWithFallback(type))
1593 return ::mlir::failure();
1594 rvalueRawType = type;
1595 }
1596 {
1597 auto loc = parser.getCurrentLocation();(void)loc;
1598 if (parser.parseOptionalAttrDict(result.attributes))
1599 return ::mlir::failure();
1600 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
1601 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
1602 })))
1603 return ::mlir::failure();
1604 }
1605 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1606 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1607 return ::mlir::failure();
1608 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1609 return ::mlir::failure();
1610 if (parser.resolveOperands(rvalueOperands, rvalueTypes, rvalueOperandsLoc, result.operands))
1611 return ::mlir::failure();
1612 return ::mlir::success();
1613}
1614
1615void InsertArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1616 _odsPrinter << ' ';
1617 _odsPrinter << getArrRef();
1618 _odsPrinter << "[";
1619 _odsPrinter << getIndices();
1620 _odsPrinter << "]";
1621 _odsPrinter << ' ' << "=";
1622 _odsPrinter << ' ';
1623 _odsPrinter << getRvalue();
1624 _odsPrinter << ' ' << ":";
1625 _odsPrinter << ' ';
1626 {
1627 auto type = getArrRef().getType();
1628 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1629 _odsPrinter.printStrippedAttrOrType(validType);
1630 else
1631 _odsPrinter << type;
1632 }
1633 _odsPrinter << ",";
1634 _odsPrinter << ' ';
1635 {
1636 auto type = getRvalue().getType();
1637 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1638 _odsPrinter.printStrippedAttrOrType(validType);
1639 else
1640 _odsPrinter << type;
1641 }
1642 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1643 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1644}
1645
1648 return false;
1649}
1650
1651} // namespace llzk::array
1652MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::InsertArrayOp)
1653
1654namespace llzk::array {
1655
1656
1657//===----------------------------------------------------------------------===//
1658// ::llzk::array::ReadArrayOp definitions
1659//===----------------------------------------------------------------------===//
1660
1661namespace detail {
1662
1663ReadArrayOpGenericAdaptorBase::ReadArrayOpGenericAdaptorBase(ReadArrayOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
1664
1665std::pair<unsigned, unsigned> ReadArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1666 bool isVariadic[] = {false, true};
1667 int prevVariadicCount = 0;
1668 for (unsigned i = 0; i < index; ++i)
1669 if (isVariadic[i]) ++prevVariadicCount;
1670
1671 // Calculate how many dynamic values a static variadic operand corresponds to.
1672 // This assumes all static variadic operands have the same dynamic value count.
1673 int variadicSize = (odsOperandsSize - 1) / 1;
1674 // `index` passed in as the parameter is the static index which counts each
1675 // operand (variadic or not) as size 1. So here for each previous static variadic
1676 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1677 // value pack for this static operand starts.
1678 int start = index + (variadicSize - 1) * prevVariadicCount;
1679 int size = isVariadic[index] ? variadicSize : 1;
1680 return {start, size};
1681}
1682
1683
1684} // namespace detail
1686
1687::llvm::LogicalResult ReadArrayOpAdaptor::verify(::mlir::Location loc) {
1688 return ::mlir::success();
1689}
1690
1691std::pair<unsigned, unsigned> ReadArrayOp::getODSOperandIndexAndLength(unsigned index) {
1692 bool isVariadic[] = {false, true};
1693 int prevVariadicCount = 0;
1694 for (unsigned i = 0; i < index; ++i)
1695 if (isVariadic[i]) ++prevVariadicCount;
1696
1697 // Calculate how many dynamic values a static variadic operand corresponds to.
1698 // This assumes all static variadic operands have the same dynamic value count.
1699 int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
1700 // `index` passed in as the parameter is the static index which counts each
1701 // operand (variadic or not) as size 1. So here for each previous static variadic
1702 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1703 // value pack for this static operand starts.
1704 int start = index + (variadicSize - 1) * prevVariadicCount;
1705 int size = isVariadic[index] ? variadicSize : 1;
1706 return {start, size};
1707}
1708
1709::mlir::MutableOperandRange ReadArrayOp::getIndicesMutable() {
1710 auto range = getODSOperandIndexAndLength(1);
1711 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1712 return mutableRange;
1713}
1714
1715::llvm::LogicalResult ReadArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1716 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1717 if (!dict) {
1718 emitError() << "expected DictionaryAttr to set properties";
1719 return ::mlir::failure();
1720 }
1721 return ::mlir::success();
1722}
1723
1724::mlir::Attribute ReadArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1725 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1726 ::mlir::Builder odsBuilder{ctx};
1727
1728 if (!attrs.empty())
1729 return odsBuilder.getDictionaryAttr(attrs);
1730 return {};
1731}
1732
1734 using llvm::hash_value;
1735 return llvm::hash_combine();
1736}
1737
1738std::optional<mlir::Attribute> ReadArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1739 return std::nullopt;
1740}
1741
1742void ReadArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1743}
1744
1745void ReadArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1746}
1747
1748::llvm::LogicalResult ReadArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1749 return ::mlir::success();
1750}
1751
1752void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1753 odsState.addOperands(arr_ref);
1754 odsState.addOperands(indices);
1755 odsState.addTypes(result);
1756}
1757
1758ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1759 ::mlir::OperationState __state__(location, getOperationName());
1760 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1761 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1762 assert(__res__ && "builder didn't return the right type");
1763 return __res__;
1764}
1765
1766ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1767 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1768}
1769
1770void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1771 odsState.addOperands(arr_ref);
1772 odsState.addOperands(indices);
1773
1774 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1775 if (::mlir::succeeded(ReadArrayOp::inferReturnTypes(odsBuilder.getContext(),
1776 odsState.location, odsState.operands,
1777 odsState.attributes.getDictionary(odsState.getContext()),
1778 odsState.getRawProperties(),
1779 odsState.regions, inferredReturnTypes)))
1780 odsState.addTypes(inferredReturnTypes);
1781 else
1782 ::mlir::detail::reportFatalInferReturnTypesError(odsState);
1783
1784}
1785
1786ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1787 ::mlir::OperationState __state__(location, getOperationName());
1788 build(builder, __state__, std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1789 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1790 assert(__res__ && "builder didn't return the right type");
1791 return __res__;
1792}
1793
1794ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1795 return create(builder, builder.getLoc(), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1796}
1797
1798void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1799 odsState.addOperands(arr_ref);
1800 odsState.addOperands(indices);
1801 assert(resultTypes.size() == 1u && "mismatched number of results");
1802 odsState.addTypes(resultTypes);
1803}
1804
1805ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1806 ::mlir::OperationState __state__(location, getOperationName());
1807 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1808 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1809 assert(__res__ && "builder didn't return the right type");
1810 return __res__;
1811}
1812
1813ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1814 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices));
1815}
1816
1817void ReadArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1818 assert(operands.size() >= 1u && "mismatched number of parameters");
1819 odsState.addOperands(operands);
1820 odsState.addAttributes(attributes);
1821 assert(resultTypes.size() == 1u && "mismatched number of return types");
1822 odsState.addTypes(resultTypes);
1823}
1824
1825ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1826 ::mlir::OperationState __state__(location, getOperationName());
1827 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1828 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1829 assert(__res__ && "builder didn't return the right type");
1830 return __res__;
1831}
1832
1833ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1834 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1835}
1836
1837void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1838 assert(operands.size() >= 1u && "mismatched number of parameters");
1839 odsState.addOperands(operands);
1840 odsState.addAttributes(attributes);
1841
1842 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1843 if (::mlir::succeeded(ReadArrayOp::inferReturnTypes(odsBuilder.getContext(),
1844 odsState.location, operands,
1845 odsState.attributes.getDictionary(odsState.getContext()),
1846 odsState.getRawProperties(),
1847 odsState.regions, inferredReturnTypes))) {
1848 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
1849 odsState.addTypes(inferredReturnTypes);
1850 } else {
1851 ::llvm::report_fatal_error("Failed to infer result type(s).");
1852 }
1853}
1854
1855ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1856 ::mlir::OperationState __state__(location, getOperationName());
1857 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1858 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1859 assert(__res__ && "builder didn't return the right type");
1860 return __res__;
1861}
1862
1863ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1864 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
1865}
1866
1867void ReadArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1868 assert(operands.size() >= 1u && "mismatched number of parameters");
1869 odsState.addOperands(operands);
1870 odsState.useProperties(const_cast<Properties&>(properties));
1871 odsState.addAttributes(discardableAttributes);
1872 assert(resultTypes.size() == 1u && "mismatched number of return types");
1873 odsState.addTypes(resultTypes);
1874}
1875
1876ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1877 ::mlir::OperationState __state__(location, getOperationName());
1878 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1879 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1880 assert(__res__ && "builder didn't return the right type");
1881 return __res__;
1882}
1883
1884ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1885 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));
1886}
1887
1888void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1889 assert(operands.size() >= 1u && "mismatched number of parameters");
1890 odsState.addOperands(operands);
1891 odsState.useProperties(const_cast<Properties &>(properties));
1892 odsState.addAttributes(discardableAttributes);
1893
1894 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1895 if (::mlir::succeeded(ReadArrayOp::inferReturnTypes(odsBuilder.getContext(),
1896 odsState.location, operands,
1897 odsState.attributes.getDictionary(odsState.getContext()),
1898 odsState.getRawProperties(),
1899 odsState.regions, inferredReturnTypes))) {
1900 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
1901 odsState.addTypes(inferredReturnTypes);
1902 } else {
1903 ::llvm::report_fatal_error("Failed to infer result type(s).");
1904 }
1905}
1906
1907ReadArrayOp ReadArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1908 ::mlir::OperationState __state__(location, getOperationName());
1909 build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1910 auto __res__ = ::llvm::dyn_cast<ReadArrayOp>(builder.create(__state__));
1911 assert(__res__ && "builder didn't return the right type");
1912 return __res__;
1913}
1914
1915ReadArrayOp ReadArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
1916 return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
1917}
1918
1919::llvm::LogicalResult ReadArrayOp::verifyInvariantsImpl() {
1920 {
1921 unsigned index = 0; (void)index;
1922 auto valueGroup0 = getODSOperands(0);
1923
1924 for (auto v : valueGroup0) {
1925 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
1926 return ::mlir::failure();
1927 }
1928 auto valueGroup1 = getODSOperands(1);
1929
1930 for (auto v : valueGroup1) {
1931 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
1932 return ::mlir::failure();
1933 }
1934 }
1935 {
1936 unsigned index = 0; (void)index;
1937 auto valueGroup0 = getODSResults(0);
1938
1939 for (auto v : valueGroup0) {
1940 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops5(*this, v.getType(), "result", index++)))
1941 return ::mlir::failure();
1942 }
1943 }
1944 if (!((::llzk::typesUnify(::llvm::cast<::llzk::array::ArrayType>((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType()))))
1945 return emitOpError("failed to verify that result type matches with arr_ref element type");
1946 return ::mlir::success();
1947}
1948
1949::llvm::LogicalResult ReadArrayOp::verifyInvariants() {
1950 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1951 return ::mlir::success();
1952 return ::mlir::failure();
1953}
1954
1955::mlir::ParseResult ReadArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1956 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperand{};
1957 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(&arr_refRawOperand, 1); ::llvm::SMLoc arr_refOperandsLoc;
1958 (void)arr_refOperandsLoc;
1959 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1960 ::llvm::SMLoc indicesOperandsLoc;
1961 (void)indicesOperandsLoc;
1962 ::mlir::Type arr_refRawType{};
1963 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(&arr_refRawType, 1);
1964 ::mlir::Type resultRawType{};
1965 ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1);
1966
1967 arr_refOperandsLoc = parser.getCurrentLocation();
1968 if (parser.parseOperand(arr_refRawOperand))
1969 return ::mlir::failure();
1970 if (parser.parseLSquare())
1971 return ::mlir::failure();
1972
1973 indicesOperandsLoc = parser.getCurrentLocation();
1974 if (parser.parseOperandList(indicesOperands))
1975 return ::mlir::failure();
1976 if (parser.parseRSquare())
1977 return ::mlir::failure();
1978 if (parser.parseColon())
1979 return ::mlir::failure();
1980
1981 {
1983 if (parser.parseCustomTypeWithFallback(type))
1984 return ::mlir::failure();
1985 arr_refRawType = type;
1986 }
1987 if (parser.parseComma())
1988 return ::mlir::failure();
1989
1990 {
1991 ::mlir::Type type;
1992 if (parser.parseCustomTypeWithFallback(type))
1993 return ::mlir::failure();
1994 resultRawType = type;
1995 }
1996 {
1997 auto loc = parser.getCurrentLocation();(void)loc;
1998 if (parser.parseOptionalAttrDict(result.attributes))
1999 return ::mlir::failure();
2000 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
2001 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
2002 })))
2003 return ::mlir::failure();
2004 }
2005 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
2006 result.addTypes(resultTypes);
2007 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
2008 return ::mlir::failure();
2009 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
2010 return ::mlir::failure();
2011 return ::mlir::success();
2012}
2013
2014void ReadArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2015 _odsPrinter << ' ';
2016 _odsPrinter << getArrRef();
2017 _odsPrinter << "[";
2018 _odsPrinter << getIndices();
2019 _odsPrinter << "]";
2020 _odsPrinter << ' ' << ":";
2021 _odsPrinter << ' ';
2022 {
2023 auto type = getArrRef().getType();
2024 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
2025 _odsPrinter.printStrippedAttrOrType(validType);
2026 else
2027 _odsPrinter << type;
2028 }
2029 _odsPrinter << ",";
2030 _odsPrinter << ' ';
2031 {
2032 auto type = getResult().getType();
2033 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
2034 _odsPrinter.printStrippedAttrOrType(validType);
2035 else
2036 _odsPrinter << type;
2037 }
2038 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
2039 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
2040}
2041
2042 ::llvm::LogicalResult
2043 ReadArrayOp::inferReturnTypes(::mlir::MLIRContext *context,
2044 std::optional<::mlir::Location> location,
2045 ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
2046 ::mlir::PropertyRef properties, ::mlir::RegionRange regions,
2047 ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
2048 ReadArrayOp::Adaptor adaptor(operands, attributes, properties, regions);
2049 return ReadArrayOp::inferReturnTypes(context,
2050 location, adaptor, inferredReturnTypes);
2051 }
2052
2053
2055bool ReadArrayOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
2056 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
2057 ::mlir::SmallVectorImpl<::mlir::MemorySlot> &mustBeSafelyUsed,
2058 const ::mlir::DataLayout &dataLayout) {
2059 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
2060 .canRewire(slot, usedIndices, mustBeSafelyUsed, dataLayout);
2061}
2062
2064::mlir::DeletionKind ReadArrayOp::rewire(const ::mlir::DestructurableMemorySlot &slot,
2065 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
2066 ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout) {
2067 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
2068 .rewire(slot, subslots, builder, dataLayout);
2069}
2070
2072bool ReadArrayOp::loadsFrom(const ::mlir::MemorySlot &slot) {
2073 return getArrRef() == slot.ptr;
2074}
2075
2077bool ReadArrayOp::storesTo(const ::mlir::MemorySlot &slot) {
2078 return false;
2079}
2080
2082::mlir::Value ReadArrayOp::getStored(const ::mlir::MemorySlot &, ::mlir::OpBuilder &,
2083 ::mlir::Value, const ::mlir::DataLayout &) {
2084 llvm_unreachable("getStored() should not be called on ReadArrayOp");
2085}
2086
2089 return true;
2090}
2091
2094 return getArrRef() == ptr;
2095}
2096
2099 return false;
2100}
2101
2103bool ReadArrayOp::canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &) {
2104 return false;
2105}
2106
2107} // namespace llzk::array
2108MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ReadArrayOp)
2109
2110namespace llzk::array {
2111
2112
2113//===----------------------------------------------------------------------===//
2114// ::llzk::array::WriteArrayOp definitions
2115//===----------------------------------------------------------------------===//
2116
2117namespace detail {
2118
2119WriteArrayOpGenericAdaptorBase::WriteArrayOpGenericAdaptorBase(WriteArrayOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
2120
2121std::pair<unsigned, unsigned> WriteArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
2122 bool isVariadic[] = {false, true, false};
2123 int prevVariadicCount = 0;
2124 for (unsigned i = 0; i < index; ++i)
2125 if (isVariadic[i]) ++prevVariadicCount;
2126
2127 // Calculate how many dynamic values a static variadic operand corresponds to.
2128 // This assumes all static variadic operands have the same dynamic value count.
2129 int variadicSize = (odsOperandsSize - 2) / 1;
2130 // `index` passed in as the parameter is the static index which counts each
2131 // operand (variadic or not) as size 1. So here for each previous static variadic
2132 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
2133 // value pack for this static operand starts.
2134 int start = index + (variadicSize - 1) * prevVariadicCount;
2135 int size = isVariadic[index] ? variadicSize : 1;
2136 return {start, size};
2137}
2138
2139
2140} // namespace detail
2142
2143::llvm::LogicalResult WriteArrayOpAdaptor::verify(::mlir::Location loc) {
2144 return ::mlir::success();
2145}
2146
2147std::pair<unsigned, unsigned> WriteArrayOp::getODSOperandIndexAndLength(unsigned index) {
2148 bool isVariadic[] = {false, true, false};
2149 int prevVariadicCount = 0;
2150 for (unsigned i = 0; i < index; ++i)
2151 if (isVariadic[i]) ++prevVariadicCount;
2152
2153 // Calculate how many dynamic values a static variadic operand corresponds to.
2154 // This assumes all static variadic operands have the same dynamic value count.
2155 int variadicSize = (getOperation()->getNumOperands() - 2) / 1;
2156 // `index` passed in as the parameter is the static index which counts each
2157 // operand (variadic or not) as size 1. So here for each previous static variadic
2158 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
2159 // value pack for this static operand starts.
2160 int start = index + (variadicSize - 1) * prevVariadicCount;
2161 int size = isVariadic[index] ? variadicSize : 1;
2162 return {start, size};
2163}
2164
2165::mlir::MutableOperandRange WriteArrayOp::getIndicesMutable() {
2166 auto range = getODSOperandIndexAndLength(1);
2167 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2168 return mutableRange;
2169}
2170
2171::llvm::LogicalResult WriteArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
2172 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
2173 if (!dict) {
2174 emitError() << "expected DictionaryAttr to set properties";
2175 return ::mlir::failure();
2176 }
2177 return ::mlir::success();
2178}
2179
2180::mlir::Attribute WriteArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
2181 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
2182 ::mlir::Builder odsBuilder{ctx};
2183
2184 if (!attrs.empty())
2185 return odsBuilder.getDictionaryAttr(attrs);
2186 return {};
2187}
2188
2190 using llvm::hash_value;
2191 return llvm::hash_combine();
2192}
2193
2194std::optional<mlir::Attribute> WriteArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
2195 return std::nullopt;
2196}
2197
2198void WriteArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
2199}
2200
2201void WriteArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
2202}
2203
2204::llvm::LogicalResult WriteArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
2205 return ::mlir::success();
2206}
2207
2208void WriteArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2209 odsState.addOperands(arr_ref);
2210 odsState.addOperands(indices);
2211 odsState.addOperands(rvalue);
2212}
2213
2214WriteArrayOp WriteArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2215 ::mlir::OperationState __state__(location, getOperationName());
2216 build(builder, __state__, std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
2217 auto __res__ = ::llvm::dyn_cast<WriteArrayOp>(builder.create(__state__));
2218 assert(__res__ && "builder didn't return the right type");
2219 return __res__;
2220}
2221
2222WriteArrayOp WriteArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2223 return create(builder, builder.getLoc(), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
2224}
2225
2226void WriteArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2227 odsState.addOperands(arr_ref);
2228 odsState.addOperands(indices);
2229 odsState.addOperands(rvalue);
2230 assert(resultTypes.size() == 0u && "mismatched number of results");
2231 odsState.addTypes(resultTypes);
2232}
2233
2234WriteArrayOp WriteArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2235 ::mlir::OperationState __state__(location, getOperationName());
2236 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
2237 auto __res__ = ::llvm::dyn_cast<WriteArrayOp>(builder.create(__state__));
2238 assert(__res__ && "builder didn't return the right type");
2239 return __res__;
2240}
2241
2242WriteArrayOp WriteArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
2243 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(arr_ref)>(arr_ref), std::forward<decltype(indices)>(indices), std::forward<decltype(rvalue)>(rvalue));
2244}
2245
2246void WriteArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2247 assert(operands.size() >= 2u && "mismatched number of parameters");
2248 odsState.addOperands(operands);
2249 odsState.addAttributes(attributes);
2250 assert(resultTypes.size() == 0u && "mismatched number of return types");
2251 odsState.addTypes(resultTypes);
2252}
2253
2254WriteArrayOp WriteArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2255 ::mlir::OperationState __state__(location, getOperationName());
2256 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
2257 auto __res__ = ::llvm::dyn_cast<WriteArrayOp>(builder.create(__state__));
2258 assert(__res__ && "builder didn't return the right type");
2259 return __res__;
2260}
2261
2262WriteArrayOp WriteArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2263 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
2264}
2265
2266void WriteArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
2267 assert(operands.size() >= 2u && "mismatched number of parameters");
2268 odsState.addOperands(operands);
2269 odsState.useProperties(const_cast<Properties&>(properties));
2270 odsState.addAttributes(discardableAttributes);
2271 assert(resultTypes.size() == 0u && "mismatched number of return types");
2272 odsState.addTypes(resultTypes);
2273}
2274
2275WriteArrayOp WriteArrayOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
2276 ::mlir::OperationState __state__(location, getOperationName());
2277 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
2278 auto __res__ = ::llvm::dyn_cast<WriteArrayOp>(builder.create(__state__));
2279 assert(__res__ && "builder didn't return the right type");
2280 return __res__;
2281}
2282
2283WriteArrayOp WriteArrayOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
2284 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));
2285}
2286
2287::llvm::LogicalResult WriteArrayOp::verifyInvariantsImpl() {
2288 {
2289 unsigned index = 0; (void)index;
2290 auto valueGroup0 = getODSOperands(0);
2291
2292 for (auto v : valueGroup0) {
2293 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
2294 return ::mlir::failure();
2295 }
2296 auto valueGroup1 = getODSOperands(1);
2297
2298 for (auto v : valueGroup1) {
2299 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
2300 return ::mlir::failure();
2301 }
2302 auto valueGroup2 = getODSOperands(2);
2303
2304 for (auto v : valueGroup2) {
2305 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops5(*this, v.getType(), "operand", index++)))
2306 return ::mlir::failure();
2307 }
2308 }
2309 if (!((::llzk::typesUnify(::llvm::cast<::llzk::array::ArrayType>((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSOperands(2).begin()).getType()))))
2310 return emitOpError("failed to verify that rvalue type matches with arr_ref element type");
2311 return ::mlir::success();
2312}
2313
2314::llvm::LogicalResult WriteArrayOp::verifyInvariants() {
2315 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
2316 return ::mlir::success();
2317 return ::mlir::failure();
2318}
2319
2320::mlir::ParseResult WriteArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2321 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperand{};
2322 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(&arr_refRawOperand, 1); ::llvm::SMLoc arr_refOperandsLoc;
2323 (void)arr_refOperandsLoc;
2324 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
2325 ::llvm::SMLoc indicesOperandsLoc;
2326 (void)indicesOperandsLoc;
2327 ::mlir::OpAsmParser::UnresolvedOperand rvalueRawOperand{};
2328 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rvalueOperands(&rvalueRawOperand, 1); ::llvm::SMLoc rvalueOperandsLoc;
2329 (void)rvalueOperandsLoc;
2330 ::mlir::Type arr_refRawType{};
2331 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(&arr_refRawType, 1);
2332 ::mlir::Type rvalueRawType{};
2333 ::llvm::ArrayRef<::mlir::Type> rvalueTypes(&rvalueRawType, 1);
2334
2335 arr_refOperandsLoc = parser.getCurrentLocation();
2336 if (parser.parseOperand(arr_refRawOperand))
2337 return ::mlir::failure();
2338 if (parser.parseLSquare())
2339 return ::mlir::failure();
2340
2341 indicesOperandsLoc = parser.getCurrentLocation();
2342 if (parser.parseOperandList(indicesOperands))
2343 return ::mlir::failure();
2344 if (parser.parseRSquare())
2345 return ::mlir::failure();
2346 if (parser.parseEqual())
2347 return ::mlir::failure();
2348
2349 rvalueOperandsLoc = parser.getCurrentLocation();
2350 if (parser.parseOperand(rvalueRawOperand))
2351 return ::mlir::failure();
2352 if (parser.parseColon())
2353 return ::mlir::failure();
2354
2355 {
2357 if (parser.parseCustomTypeWithFallback(type))
2358 return ::mlir::failure();
2359 arr_refRawType = type;
2360 }
2361 if (parser.parseComma())
2362 return ::mlir::failure();
2363
2364 {
2365 ::mlir::Type type;
2366 if (parser.parseCustomTypeWithFallback(type))
2367 return ::mlir::failure();
2368 rvalueRawType = type;
2369 }
2370 {
2371 auto loc = parser.getCurrentLocation();(void)loc;
2372 if (parser.parseOptionalAttrDict(result.attributes))
2373 return ::mlir::failure();
2374 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
2375 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
2376 })))
2377 return ::mlir::failure();
2378 }
2379 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
2380 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
2381 return ::mlir::failure();
2382 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
2383 return ::mlir::failure();
2384 if (parser.resolveOperands(rvalueOperands, rvalueTypes, rvalueOperandsLoc, result.operands))
2385 return ::mlir::failure();
2386 return ::mlir::success();
2387}
2388
2389void WriteArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2390 _odsPrinter << ' ';
2391 _odsPrinter << getArrRef();
2392 _odsPrinter << "[";
2393 _odsPrinter << getIndices();
2394 _odsPrinter << "]";
2395 _odsPrinter << ' ' << "=";
2396 _odsPrinter << ' ';
2397 _odsPrinter << getRvalue();
2398 _odsPrinter << ' ' << ":";
2399 _odsPrinter << ' ';
2400 {
2401 auto type = getArrRef().getType();
2402 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
2403 _odsPrinter.printStrippedAttrOrType(validType);
2404 else
2405 _odsPrinter << type;
2406 }
2407 _odsPrinter << ",";
2408 _odsPrinter << ' ';
2409 {
2410 auto type = getRvalue().getType();
2411 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
2412 _odsPrinter.printStrippedAttrOrType(validType);
2413 else
2414 _odsPrinter << type;
2415 }
2416 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
2417 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
2418}
2419
2421bool WriteArrayOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
2422 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
2423 ::mlir::SmallVectorImpl<::mlir::MemorySlot> &mustBeSafelyUsed,
2424 const ::mlir::DataLayout &dataLayout) {
2425 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
2426 .canRewire(slot, usedIndices, mustBeSafelyUsed, dataLayout);
2427}
2428
2430::mlir::DeletionKind WriteArrayOp::rewire(const ::mlir::DestructurableMemorySlot &slot,
2431 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
2432 ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout) {
2433 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
2434 .rewire(slot, subslots, builder, dataLayout);
2435}
2436
2438bool WriteArrayOp::loadsFrom(const ::mlir::MemorySlot &slot) {
2439 return false;
2440}
2441
2443bool WriteArrayOp::storesTo(const ::mlir::MemorySlot &slot) {
2444 return getArrRef() == slot.ptr;
2445}
2446
2448::mlir::Value WriteArrayOp::getStored(const ::mlir::MemorySlot &, ::mlir::OpBuilder &,
2449 ::mlir::Value, const ::mlir::DataLayout &) {
2450 return getRvalue();
2451}
2452
2455 return false;
2456}
2457
2460 return false;
2461}
2462
2465 return getArrRef() == ptr && getRvalue() != ptr;
2466}
2467
2469bool WriteArrayOp::canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &) {
2470 return getArrRef() == ptr && getRvalue() != ptr;
2471}
2472
2473} // namespace llzk::array
2474MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::WriteArrayOp)
2475
2476
2477#endif // GET_OP_CLASSES
2478
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:108
ArrayLengthOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:246
ArrayLengthOpAdaptor(ArrayLengthOp op)
Definition Ops.cpp.inc:106
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:318
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:135
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:112
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:340
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:304
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:421
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:142
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:139
::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:348
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:402
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:312
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:145
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:121
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim)
Definition Ops.cpp.inc:149
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:344
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:356
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:130
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:316
FoldAdaptor::Properties Properties
Definition Ops.h.inc:299
static ArrayLengthOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim)
Definition Ops.cpp.inc:155
::mlir::TypedValue<::mlir::IndexType > getDim()
Definition Ops.h.inc:322
CreateArrayOpAdaptor(CreateArrayOp op)
Definition Ops.cpp.inc:465
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:467
CreateArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:487
static CreateArrayOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::array::ArrayType result, ::mlir::ValueRange elements={})
Definition Ops.cpp.inc:718
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:680
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:480
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:624
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:914
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::array::ArrayType result, ::mlir::ValueRange elements={})
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:937
::mlir::TypedValue<::llzk::array::ArrayType > getResult()
Definition Ops.h.inc:612
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:873
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:631
::mlir::MutableOperandRangeRange getMapOperandsMutable()
Definition Ops.cpp.inc:495
void setNumDimsPerMap(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:710
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:594
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:765
::mlir::StringAttr getNumDimsPerMapAttrName()
Definition Ops.h.inc:565
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:501
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:606
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:582
::llvm::LogicalResult verify()
Definition Ops.cpp:105
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:586
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.h.inc:625
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:646
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:700
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:581
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:705
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:551
::mlir::OperandRangeRange getMapOperands()
Definition Ops.h.inc:596
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:806
FoldAdaptor::Properties Properties
Definition Ops.h.inc:548
::mlir::StringAttr getMapOpGroupSizesAttrName()
Definition Ops.h.inc:557
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:630
::mlir::MutableOperandRange getElementsMutable()
Definition Ops.cpp.inc:489
::mlir::Operation::operand_range getElements()
Definition Ops.h.inc:592
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:812
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:604
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:759
void setMapOpGroupSizes(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:714
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:979
ExtractArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:746
ExtractArrayOpAdaptor(ExtractArrayOp op)
Definition Ops.cpp.inc:977
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:834
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:1044
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1243
static ExtractArrayOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:1050
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1040
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1001
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1331
ExtractArrayOpAdaptor Adaptor
Definition Ops.h.inc:793
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1030
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1211
::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:1319
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1016
FoldAdaptor::Properties Properties
Definition Ops.h.inc:799
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1239
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1299
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:983
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:820
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1037
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:816
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1007
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:810
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:805
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1034
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1025
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1371
InsertArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:942
InsertArrayOpAdaptor(InsertArrayOp op)
Definition Ops.cpp.inc:1369
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:1020
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1399
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1426
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1515
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1432
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1647
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1408
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1422
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1540
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1417
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:1005
::llvm::LogicalResult verify()
Definition Ops.cpp:495
::mlir::TypedValue<::llzk::array::ArrayType > getRvalue()
Definition Ops.h.inc:1024
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:1010
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1546
FoldAdaptor::Properties Properties
Definition Ops.h.inc:1000
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1615
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:1016
static InsertArrayOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:1442
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1375
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:1436
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1429
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1393
ReadArrayOpAdaptor(ReadArrayOp op)
Definition Ops.cpp.inc:1685
ReadArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1128
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1687
::mlir::Value getStored(const ::mlir::MemorySlot &slot, ::mlir::OpBuilder &builder, ::mlir::Value reachingDef, const ::mlir::DataLayout &dataLayout)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2082
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1748
bool storesToDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2098
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1919
::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:2064
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1738
::mlir::TypedValue<::mlir::Type > getResult()
Definition Ops.h.inc:1222
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:1198
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2077
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:1202
FoldAdaptor::Properties Properties
Definition Ops.h.inc:1181
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2072
bool canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &dataLayout)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2103
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1955
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:2088
bool loadsFromDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2093
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1724
::llvm::LogicalResult verify()
Definition Ops.cpp:379
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:1752
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1733
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:2014
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:1216
::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::PropertyRef properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:2043
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:1192
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1742
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1715
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:2055
static ReadArrayOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:1758
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:1187
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1745
ReadArrayOpAdaptor Adaptor
Definition Ops.h.inc:1175
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1691
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1949
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1709
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:2143
WriteArrayOpAdaptor(WriteArrayOp op)
Definition Ops.cpp.inc:2141
WriteArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1335
::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:2430
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:2454
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:2194
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2438
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:2189
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:2314
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:2180
::llvm::LogicalResult verify()
Definition Ops.cpp:417
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:1413
::mlir::Value getStored(const ::mlir::MemorySlot &slot, ::mlir::OpBuilder &builder, ::mlir::Value reachingDef, const ::mlir::DataLayout &dataLayout)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2448
static WriteArrayOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:2214
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:2171
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:2198
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:2389
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:2421
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:2287
bool canEraseAsDeadStoreTo(::mlir::Value ptr, const ::mlir::DataLayout &dataLayout)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2469
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:2320
bool loadsFromDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2459
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:2201
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:1398
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:2443
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:2208
bool storesToDiscardableAllocation(::mlir::Value ptr)
Required by DiscardableAllocationAccessorOpInterface / unused allocation cleanup.
Definition Ops.cpp.inc:2464
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:2165
FoldAdaptor::Properties Properties
Definition Ops.h.inc:1393
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:1403
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:1409
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:2204
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:2147
::mlir::TypedValue<::mlir::Type > getRvalue()
Definition Ops.h.inc:1417
ArrayLengthOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:218
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:214
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.h.inc:471
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:458
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:453
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:439
CreateArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:454
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:450
ExtractArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:721
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:717
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:957
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1349
InsertArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:916
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:912
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:1099
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1665
ReadArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1103
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:2121
WriteArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:1309
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:1305
Common interface for operations that reference an array value.
Common interface for constant parameter-like symbol operations that can be defined within a TemplateO...
bool isValidArrayElemType(Type type)
mlir::ParseResult parseAttrDictWithWarnings(mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state)
Definition OpHelpers.h:151
void printMultiDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
Definition OpHelpers.h:144
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename mlir::PropertiesSelector< ConcreteOp >::type state)
Definition OpHelpers.h:158
bool typesUnify(Type lhs, Type rhs, ArrayRef< StringRef > rhsReversePrefix, UnificationMap *unifications)
mlir::ParseResult parseMultiDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &multiMapOperands, mlir::DenseI32ArrayAttr &numDimsPerMap)
Definition OpHelpers.h:136