LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Ops.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#ifdef GET_OP_LIST
11#undef GET_OP_LIST
12
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
29namespace llzk {
30namespace array {
31
32static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops0(
33 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
34 unsigned valueIndex) {
35 if (!((::llvm::isa<::llzk::array::ArrayType>(type)))) {
36 return op->emitOpError(valueKind) << " #" << valueIndex
37 << " must be n-dimensional array, but got " << type;
38 }
39 return ::mlir::success();
40}
41
42static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops1(
43 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
44 unsigned valueIndex) {
45 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
46 return op->emitOpError(valueKind) << " #" << valueIndex
47 << " must be index, but got " << type;
48 }
49 return ::mlir::success();
50}
51
52static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops2(
53 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
54 unsigned valueIndex) {
55 if (!((::llzk::isValidArrayElemType(type)))) {
56 return op->emitOpError(valueKind) << " #" << valueIndex
57 << " must be variadic of a valid array element type, but got " << type;
58 }
59 return ::mlir::success();
60}
61
62static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops3(
63 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
64 unsigned valueIndex) {
65 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
66 return op->emitOpError(valueKind) << " #" << valueIndex
67 << " must be variadic of index, but got " << type;
68 }
69 return ::mlir::success();
70}
71
72static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops4(
73 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
74 unsigned valueIndex) {
75 if (!((::llzk::isValidArrayElemType(type)))) {
76 return op->emitOpError(valueKind) << " #" << valueIndex
77 << " must be a valid array element type, but got " << type;
78 }
79 return ::mlir::success();
80}
81
82static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
83 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
84 if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
85 return emitError() << "attribute '" << attrName
86 << "' failed to satisfy constraint: i32 dense array attribute";
87 return ::mlir::success();
88}
89static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
90 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
91 return __mlir_ods_local_attr_constraint_Ops0(attr, attrName, [op]() {
92 return op->emitOpError();
93 });
94}
95} // namespace array
96} // namespace llzk
97namespace llzk {
98namespace array {
99
100//===----------------------------------------------------------------------===//
101// ::llzk::array::ArrayLengthOp definitions
102//===----------------------------------------------------------------------===//
103
104namespace detail {
105ArrayLengthOpGenericAdaptorBase::ArrayLengthOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
106 odsOpName.emplace("array.len", odsAttrs.getContext());
107}
108
110
111std::pair<unsigned, unsigned> ArrayLengthOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
112 return {index, 1};
113}
114
116 return odsAttrs;
117}
118
119} // namespace detail
121
122::mlir::LogicalResult ArrayLengthOpAdaptor::verify(::mlir::Location loc) {
123 return ::mlir::success();
124}
125
126std::pair<unsigned, unsigned> ArrayLengthOp::getODSOperandIndexAndLength(unsigned index) {
127 return {index, 1};
128}
129
130::mlir::Operation::operand_range ArrayLengthOp::getODSOperands(unsigned index) {
131 auto valueRange = getODSOperandIndexAndLength(index);
132 return {std::next(getOperation()->operand_begin(), valueRange.first),
133 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
134}
135
136::mlir::TypedValue<::llzk::array::ArrayType> ArrayLengthOp::getArrRef() {
137 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(0).begin());
138}
139
140::mlir::TypedValue<::mlir::IndexType> ArrayLengthOp::getDim() {
141 return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(1).begin());
142}
143
145 auto range = getODSOperandIndexAndLength(0);
146 return getOperation()->getOpOperand(range.first);
147}
148
149::mlir::OpOperand &ArrayLengthOp::getDimMutable() {
150 auto range = getODSOperandIndexAndLength(1);
151 return getOperation()->getOpOperand(range.first);
152}
153
154std::pair<unsigned, unsigned> ArrayLengthOp::getODSResultIndexAndLength(unsigned index) {
155 return {index, 1};
156}
157
158::mlir::Operation::result_range ArrayLengthOp::getODSResults(unsigned index) {
159 auto valueRange = getODSResultIndexAndLength(index);
160 return {std::next(getOperation()->result_begin(), valueRange.first),
161 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
162}
163
164::mlir::TypedValue<::mlir::IndexType> ArrayLengthOp::getLength() {
165 return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin());
166}
167
168void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim) {
169 odsState.addOperands(arr_ref);
170 odsState.addOperands(dim);
171 odsState.addTypes(length);
172}
173
174void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::Value dim) {
175 odsState.addOperands(arr_ref);
176 odsState.addOperands(dim);
177
178 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
179 if (::mlir::succeeded(ArrayLengthOp::inferReturnTypes(odsBuilder.getContext(),
180 odsState.location, odsState.operands,
181 odsState.attributes.getDictionary(odsState.getContext()),
182 odsState.getRawProperties(),
183 odsState.regions, inferredReturnTypes)))
184 odsState.addTypes(inferredReturnTypes);
185 else
186 ::llvm::report_fatal_error("Failed to infer result type(s).");
187}
188
189void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::Value dim) {
190 odsState.addOperands(arr_ref);
191 odsState.addOperands(dim);
192 assert(resultTypes.size() == 1u && "mismatched number of results");
193 odsState.addTypes(resultTypes);
194}
195
196void ArrayLengthOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
197 assert(operands.size() == 2u && "mismatched number of parameters");
198 odsState.addOperands(operands);
199 odsState.addAttributes(attributes);
200 assert(resultTypes.size() == 1u && "mismatched number of return types");
201 odsState.addTypes(resultTypes);
202}
203
204void ArrayLengthOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
205 assert(operands.size() == 2u && "mismatched number of parameters");
206 odsState.addOperands(operands);
207 odsState.addAttributes(attributes);
208
209 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
210 if (::mlir::succeeded(ArrayLengthOp::inferReturnTypes(odsBuilder.getContext(),
211 odsState.location, operands,
212 odsState.attributes.getDictionary(odsState.getContext()),
213 odsState.getRawProperties(),
214 odsState.regions, inferredReturnTypes))) {
215 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
216 odsState.addTypes(inferredReturnTypes);
217 } else {
218 ::llvm::report_fatal_error("Failed to infer result type(s).");
219 }
220}
221
222::mlir::LogicalResult ArrayLengthOp::verifyInvariantsImpl() {
223 {
224 unsigned index = 0; (void)index;
225 auto valueGroup0 = getODSOperands(0);
226
227 for (auto v : valueGroup0) {
228 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
229 return ::mlir::failure();
230 }
231 auto valueGroup1 = getODSOperands(1);
232
233 for (auto v : valueGroup1) {
234 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
235 return ::mlir::failure();
236 }
237 }
238 {
239 unsigned index = 0; (void)index;
240 auto valueGroup0 = getODSResults(0);
241
242 for (auto v : valueGroup0) {
243 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
244 return ::mlir::failure();
245 }
246 }
247 return ::mlir::success();
248}
249
250::mlir::LogicalResult ArrayLengthOp::verifyInvariants() {
251 return verifyInvariantsImpl();
252}
253
254::mlir::LogicalResult ArrayLengthOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) {
255 inferredReturnTypes.resize(1);
256 ::mlir::Builder odsBuilder(context);
257 ::mlir::Type odsInferredType0 = odsBuilder.getIndexType();
258 inferredReturnTypes[0] = odsInferredType0;
259 return ::mlir::success();
260}
261
262::mlir::ParseResult ArrayLengthOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
263 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperands[1];
264 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(arr_refRawOperands); ::llvm::SMLoc arr_refOperandsLoc;
265 (void)arr_refOperandsLoc;
266 ::mlir::OpAsmParser::UnresolvedOperand dimRawOperands[1];
267 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dimOperands(dimRawOperands); ::llvm::SMLoc dimOperandsLoc;
268 (void)dimOperandsLoc;
269 ::mlir::Type arr_refRawTypes[1];
270 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(arr_refRawTypes);
271
272 arr_refOperandsLoc = parser.getCurrentLocation();
273 if (parser.parseOperand(arr_refRawOperands[0]))
274 return ::mlir::failure();
275 if (parser.parseComma())
276 return ::mlir::failure();
277
278 dimOperandsLoc = parser.getCurrentLocation();
279 if (parser.parseOperand(dimRawOperands[0]))
280 return ::mlir::failure();
281 if (parser.parseColon())
282 return ::mlir::failure();
283
284 {
286 if (parser.parseCustomTypeWithFallback(type))
287 return ::mlir::failure();
288 arr_refRawTypes[0] = type;
289 }
290 {
291 auto loc = parser.getCurrentLocation();(void)loc;
292 if (parser.parseOptionalAttrDict(result.attributes))
293 return ::mlir::failure();
294 }
295 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
296 result.addTypes(odsBuildableType0);
297 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
298 return ::mlir::failure();
299 if (parser.resolveOperands(dimOperands, odsBuildableType0, dimOperandsLoc, result.operands))
300 return ::mlir::failure();
301 return ::mlir::success();
302}
303
304void ArrayLengthOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
305 _odsPrinter << ' ';
306 _odsPrinter << getArrRef();
307 _odsPrinter << ",";
308 _odsPrinter << ' ';
309 _odsPrinter << getDim();
310 _odsPrinter << ' ' << ":";
311 _odsPrinter << ' ';
312 {
313 auto type = getArrRef().getType();
314 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
315 _odsPrinter.printStrippedAttrOrType(validType);
316 else
317 _odsPrinter << type;
318 }
319 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
320 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
321}
322
323void ArrayLengthOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
324}
325
326} // namespace array
327} // namespace llzk
328MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ArrayLengthOp)
329
330namespace llzk {
331namespace array {
332
333//===----------------------------------------------------------------------===//
334// ::llzk::array::CreateArrayOp definitions
335//===----------------------------------------------------------------------===//
336
337namespace detail {
338CreateArrayOpGenericAdaptorBase::CreateArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
339 odsOpName.emplace("array.new", odsAttrs.getContext());
340}
341
343
344std::pair<unsigned, unsigned> CreateArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
345 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
346
347 unsigned start = 0;
348 for (unsigned i = 0; i < index; ++i)
349 start += sizeAttr[i];
350 return {start, sizeAttr[index]};
351}
352
354 return odsAttrs;
355}
356
358 auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
359 return attr;
360}
361
363 auto attr = getNumDimsPerMapAttr();
364 return attr;
365}
366
368 auto attr = ::llvm::cast<::mlir::DenseI32ArrayAttr>(getProperties().mapOpGroupSizes);
369 return attr;
370}
371
373 auto attr = getMapOpGroupSizesAttr();
374 return attr;
375}
376
377} // namespace detail
379
380::mlir::LogicalResult CreateArrayOpAdaptor::verify(::mlir::Location loc) {
381 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
382 if (!tblgen_mapOpGroupSizes) return emitError(loc, "'array.new' op ""requires attribute 'mapOpGroupSizes'");
383 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
384
385 if (tblgen_numDimsPerMap && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_numDimsPerMap))))
386 return emitError(loc, "'array.new' op ""attribute 'numDimsPerMap' failed to satisfy constraint: i32 dense array attribute");
387
388 if (tblgen_mapOpGroupSizes && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_mapOpGroupSizes))))
389 return emitError(loc, "'array.new' op ""attribute 'mapOpGroupSizes' failed to satisfy constraint: i32 dense array attribute");
390 return ::mlir::success();
391}
392
393std::pair<unsigned, unsigned> CreateArrayOp::getODSOperandIndexAndLength(unsigned index) {
394 ::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
395
396 unsigned start = 0;
397 for (unsigned i = 0; i < index; ++i)
398 start += sizeAttr[i];
399 return {start, sizeAttr[index]};
400}
401
402::mlir::Operation::operand_range CreateArrayOp::getODSOperands(unsigned index) {
403 auto valueRange = getODSOperandIndexAndLength(index);
404 return {std::next(getOperation()->operand_begin(), valueRange.first),
405 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
406}
407
408::mlir::Operation::operand_range CreateArrayOp::getElements() {
409 return getODSOperands(0);
410}
411
412::mlir::OperandRangeRange CreateArrayOp::getMapOperands() {
413 return getODSOperands(1).split(getMapOpGroupSizesAttr());
414}
415
416::mlir::MutableOperandRange CreateArrayOp::getElementsMutable() {
417 auto range = getODSOperandIndexAndLength(0);
418 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
419 return mutableRange;
420}
421
422::mlir::MutableOperandRangeRange CreateArrayOp::getMapOperandsMutable() {
423 auto range = getODSOperandIndexAndLength(1);
424 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)}));
425 return mutableRange.split(*(*this)->getAttrDictionary().getNamed(getMapOpGroupSizesAttrName()));
426}
427
428std::pair<unsigned, unsigned> CreateArrayOp::getODSResultIndexAndLength(unsigned index) {
429 return {index, 1};
430}
431
432::mlir::Operation::result_range CreateArrayOp::getODSResults(unsigned index) {
433 auto valueRange = getODSResultIndexAndLength(index);
434 return {std::next(getOperation()->result_begin(), valueRange.first),
435 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
436}
437
438::mlir::TypedValue<::llzk::array::ArrayType> CreateArrayOp::getResult() {
439 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSResults(0).begin());
440}
441
442::mlir::LogicalResult CreateArrayOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
443 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
444 if (!dict) {
445 emitError() << "expected DictionaryAttr to set properties";
446 return ::mlir::failure();
447 }
448
449 {
450 auto &propStorage = prop.mapOpGroupSizes;
451 auto attr = dict.get("mapOpGroupSizes");
452 if (attr || /*isRequired=*/true) {
453 if (!attr) {
454 emitError() << "expected key entry for mapOpGroupSizes in DictionaryAttr to set "
455 "Properties.";
456 return ::mlir::failure();
457 }
458 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
459 if (convertedAttr) {
460 propStorage = convertedAttr;
461 } else {
462 emitError() << "Invalid attribute `mapOpGroupSizes` in property conversion: " << attr;
463 return ::mlir::failure();
464 }
465 }
466 }
467
468 {
469 auto &propStorage = prop.numDimsPerMap;
470 auto attr = dict.get("numDimsPerMap");
471 if (attr || /*isRequired=*/false) {
472 if (!attr) {
473 emitError() << "expected key entry for numDimsPerMap in DictionaryAttr to set "
474 "Properties.";
475 return ::mlir::failure();
476 }
477 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
478 if (convertedAttr) {
479 propStorage = convertedAttr;
480 } else {
481 emitError() << "Invalid attribute `numDimsPerMap` in property conversion: " << attr;
482 return ::mlir::failure();
483 }
484 }
485 }
486;
487 {
488 auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
489 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
490 return convertFromAttribute(propStorage, propAttr, emitError);;
491 };
492 auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
493 if (!attr) {
494 emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set "
495 "Properties.";
496 return ::mlir::failure();
497 }
498 if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError)))
499 return ::mlir::failure();
500 }
501 return ::mlir::success();
502}
503
504::mlir::Attribute CreateArrayOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
505 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
506 ::mlir::Builder odsBuilder{ctx};
507
508 {
509 const auto &propStorage = prop.mapOpGroupSizes;
510 if (propStorage)
511 attrs.push_back(odsBuilder.getNamedAttr("mapOpGroupSizes",
512 propStorage));
513 }
514
515 {
516 const auto &propStorage = prop.numDimsPerMap;
517 if (propStorage)
518 attrs.push_back(odsBuilder.getNamedAttr("numDimsPerMap",
519 propStorage));
520 }
521
522 {
523 const auto &propStorage = prop.operandSegmentSizes;
524 attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes",
525 ::mlir::DenseI32ArrayAttr::get(ctx, propStorage)));
526 }
527
528 if (!attrs.empty())
529 return odsBuilder.getDictionaryAttr(attrs);
530 return {};
531}
532
534 auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code {
535 return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
536 };
537 return llvm::hash_combine(
538 llvm::hash_value(prop.mapOpGroupSizes.getAsOpaquePointer()),
539 llvm::hash_value(prop.numDimsPerMap.getAsOpaquePointer()),
540 hash_operandSegmentSizes(prop.operandSegmentSizes));
541}
542
543std::optional<mlir::Attribute> CreateArrayOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
544 if (name == "mapOpGroupSizes")
545 return prop.mapOpGroupSizes;
546
547 if (name == "numDimsPerMap")
548 return prop.numDimsPerMap;
549 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes);
550 return std::nullopt;
551}
552
553void CreateArrayOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
554 if (name == "mapOpGroupSizes") {
555 prop.mapOpGroupSizes = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mapOpGroupSizes)>>(value);
556 return;
557 }
558
559 if (name == "numDimsPerMap") {
560 prop.numDimsPerMap = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.numDimsPerMap)>>(value);
561 return;
562 }
563 if (name == "operand_segment_sizes" || name == "operandSegmentSizes") {
564 auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value);
565 if (!arrAttr) return;
566 if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t))
567 return;
568 llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin());
569 return;
570 }
571}
572
573void CreateArrayOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
574 if (prop.mapOpGroupSizes) attrs.append("mapOpGroupSizes", prop.mapOpGroupSizes);
575
576 if (prop.numDimsPerMap) attrs.append("numDimsPerMap", prop.numDimsPerMap);
577 attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes));
578}
579
580::mlir::LogicalResult CreateArrayOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
581 {
582 ::mlir::Attribute attr = attrs.get(getMapOpGroupSizesAttrName(opName));
583 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "mapOpGroupSizes", emitError)))
584 return ::mlir::failure();
585 }
586
587 {
588 ::mlir::Attribute attr = attrs.get(getNumDimsPerMapAttrName(opName));
589 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "numDimsPerMap", emitError)))
590 return ::mlir::failure();
591 }
592 return ::mlir::success();
593}
594
595::mlir::LogicalResult CreateArrayOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
596 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
597 if (::mlir::failed(reader.readAttribute(prop.mapOpGroupSizes)))
598 return ::mlir::failure();
599
600 if (::mlir::failed(reader.readOptionalAttribute(prop.numDimsPerMap)))
601 return ::mlir::failure();
602
603 if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
604 auto &propStorage = prop.operandSegmentSizes;
605 ::mlir::DenseI32ArrayAttr attr;
606 if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
607 if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
608 reader.emitError("size mismatch for operand/result_segment_size");
609 return ::mlir::failure();
610 }
611 ::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
612 }
613
614 {
615 auto &propStorage = prop.operandSegmentSizes;
616 auto readProp = [&]() {
617
618 if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
619 return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
620;
621 return ::mlir::success();
622 };
623 if (::mlir::failed(readProp()))
624 return ::mlir::failure();
625 }
626 return ::mlir::success();
627}
628
629void CreateArrayOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
630 auto &prop = getProperties(); (void)prop;
631 writer.writeAttribute(prop.mapOpGroupSizes);
632
633 writer.writeOptionalAttribute(prop.numDimsPerMap);
634
635if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
636 auto &propStorage = prop.operandSegmentSizes;
637 writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
638}
639
640 {
641 auto &propStorage = prop.operandSegmentSizes;
642
643 if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
644 writer.writeSparseArray(::llvm::ArrayRef(propStorage));
645;
646 }
647}
648
649::mlir::DenseI32ArrayAttr CreateArrayOp::getNumDimsPerMapAttr() {
650 return ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(getProperties().numDimsPerMap);
651}
652
653::llvm::ArrayRef<int32_t> CreateArrayOp::getNumDimsPerMap() {
654 auto attr = getNumDimsPerMapAttr();
655 return attr;
656}
657
658::mlir::DenseI32ArrayAttr CreateArrayOp::getMapOpGroupSizesAttr() {
659 return ::llvm::cast<::mlir::DenseI32ArrayAttr>(getProperties().mapOpGroupSizes);
660}
661
662::llvm::ArrayRef<int32_t> CreateArrayOp::getMapOpGroupSizes() {
663 auto attr = getMapOpGroupSizesAttr();
664 return attr;
665}
666
667void CreateArrayOp::setNumDimsPerMapAttr(::mlir::DenseI32ArrayAttr attr) {
668 (*this)->setAttr(getNumDimsPerMapAttrName(), attr);
669}
670
671void CreateArrayOp::setNumDimsPerMap(::llvm::ArrayRef<int32_t> attrValue) {
672 (*this)->setAttr(getNumDimsPerMapAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue));
673}
674
675void CreateArrayOp::setMapOpGroupSizesAttr(::mlir::DenseI32ArrayAttr attr) {
676 (*this)->setAttr(getMapOpGroupSizesAttrName(), attr);
677}
678
679void CreateArrayOp::setMapOpGroupSizes(::llvm::ArrayRef<int32_t> attrValue) {
680 (*this)->setAttr(getMapOpGroupSizesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue));
681}
682
683void CreateArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::array::ArrayType result, ::llvm::ArrayRef<::mlir::ValueRange> mapOperands, ::llvm::ArrayRef<int32_t> numDimsPerMap) {
684 build(odsBuilder, odsState, result, mapOperands, odsBuilder.getDenseI32ArrayAttr(numDimsPerMap));
685
686}
687
688void CreateArrayOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
689 ::mlir::Builder odsBuilder(opName.getContext());
690 if (!properties.numDimsPerMap)
691 properties.numDimsPerMap = odsBuilder.getDenseI32ArrayAttr({});
692}
693
694::mlir::LogicalResult CreateArrayOp::verifyInvariantsImpl() {
695 auto tblgen_mapOpGroupSizes = getProperties().mapOpGroupSizes; (void)tblgen_mapOpGroupSizes;
696 if (!tblgen_mapOpGroupSizes) return emitOpError("requires attribute 'mapOpGroupSizes'");
697 auto tblgen_numDimsPerMap = getProperties().numDimsPerMap; (void)tblgen_numDimsPerMap;
698
699 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_numDimsPerMap, "numDimsPerMap")))
700 return ::mlir::failure();
701
702 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_mapOpGroupSizes, "mapOpGroupSizes")))
703 return ::mlir::failure();
704 {
705 unsigned index = 0; (void)index;
706 auto valueGroup0 = getODSOperands(0);
707
708 for (auto v : valueGroup0) {
709 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
710 return ::mlir::failure();
711 }
712 auto valueGroup1 = getODSOperands(1);
713 if (::mlir::failed(::mlir::OpTrait::impl::verifyValueSizeAttr(*this, "mapOpGroupSizes", "mapOperands", valueGroup1.size())))
714 return ::mlir::failure();
715
716 for (auto v : valueGroup1) {
717 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
718 return ::mlir::failure();
719 }
720 }
721 {
722 unsigned index = 0; (void)index;
723 auto valueGroup0 = getODSResults(0);
724
725 for (auto v : valueGroup0) {
726 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "result", index++)))
727 return ::mlir::failure();
728 }
729 }
730 if (!((getElements().empty() || std::equal_to<>()(resultTypeToElementsTypes((*this->getODSResults(0).begin()).getType()), this->getODSOperands(0).getType()))))
731 return emitOpError("failed to verify that operand types match result type");
732 return ::mlir::success();
733}
734
735::mlir::LogicalResult CreateArrayOp::verifyInvariants() {
736 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
737 return ::mlir::success();
738 return ::mlir::failure();
739}
740
741::mlir::ParseResult CreateArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
742 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> mapOperandsOperands;
743 llvm::SmallVector<int32_t> mapOperandsOperandGroupSizes;
744 ::llvm::SMLoc mapOperandsOperandsLoc;
745 (void)mapOperandsOperandsLoc;
746 ::mlir::DenseI32ArrayAttr numDimsPerMapAttr;
747 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> elementsOperands;
748 ::llvm::SMLoc elementsOperandsLoc;
749 (void)elementsOperandsLoc;
750 ::mlir::Type resultRawTypes[1];
751 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
752 ::llvm::SmallVector<::mlir::Type, 1> elementsTypes;
753 if (::mlir::succeeded(parser.parseOptionalLBrace())) {
754 {
755 mapOperandsOperandsLoc = parser.getCurrentLocation();
756 ::llvm::SmallVector<::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand>> mapOperandsOperandGroups;
757 auto odsResult = parseMultiDimAndSymbolList(parser, mapOperandsOperandGroups, numDimsPerMapAttr);
758 if (odsResult) return ::mlir::failure();
759 for (const auto &subRange : mapOperandsOperandGroups) {
760 mapOperandsOperands.append(subRange.begin(), subRange.end());
761 mapOperandsOperandGroupSizes.push_back(subRange.size());
762 }
763 if (numDimsPerMapAttr)
764 result.getOrAddProperties<CreateArrayOp::Properties>().numDimsPerMap = numDimsPerMapAttr;
765 }
766 if (parser.parseRBrace())
767 return ::mlir::failure();
768 } else {
769
770 elementsOperandsLoc = parser.getCurrentLocation();
771 if (parser.parseOperandList(elementsOperands))
772 return ::mlir::failure();
773 }
774 if (parser.parseColon())
775 return ::mlir::failure();
776
777 {
779 if (parser.parseCustomTypeWithFallback(type))
780 return ::mlir::failure();
781 resultRawTypes[0] = type;
782 }
783 {
784 auto odsResult = parseInferredArrayType(parser, elementsTypes, elementsOperands, resultRawTypes[0]);
785 if (odsResult) return ::mlir::failure();
786 }
787 {
788 auto odsResult = parseAttrDictWithWarnings(parser, result.attributes, result);
789 if (odsResult) return ::mlir::failure();
790 }
791::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(elementsOperands.size()), static_cast<int32_t>(mapOperandsOperands.size())}), result.getOrAddProperties<CreateArrayOp::Properties>().operandSegmentSizes.begin());
792 result.getOrAddProperties<CreateArrayOp::Properties>().mapOpGroupSizes = parser.getBuilder().getDenseI32ArrayAttr(mapOperandsOperandGroupSizes);
793 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
794 result.addTypes(resultTypes);
795 if (parser.resolveOperands(elementsOperands, elementsTypes, elementsOperandsLoc, result.operands))
796 return ::mlir::failure();
797 if (parser.resolveOperands(mapOperandsOperands, odsBuildableType0, mapOperandsOperandsLoc, result.operands))
798 return ::mlir::failure();
799 return ::mlir::success();
800}
801
802void CreateArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
803 if (((!getMapOperands().empty()) || (getNumDimsPerMapAttr() && getNumDimsPerMapAttr() != ::mlir::OpBuilder((*this)->getContext()).getDenseI32ArrayAttr({})))) {
804 _odsPrinter << "{";
806 _odsPrinter << "}";
807 } else {
808 _odsPrinter << ' ';
809 _odsPrinter << getElements();
810 }
811 _odsPrinter << ' ' << ":";
812 _odsPrinter << ' ';
813 {
814 auto type = getResult().getType();
815 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
816 _odsPrinter.printStrippedAttrOrType(validType);
817 else
818 _odsPrinter << type;
819 }
820 printInferredArrayType(_odsPrinter, *this, getElements().getTypes(), getElements(), getResult().getType());
821 _odsPrinter << ' ';
822 printAttrDictWithWarnings(_odsPrinter, *this, getOperation()->getAttrDictionary(), getProperties());
823}
824
825void CreateArrayOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
826}
827
828} // namespace array
829} // namespace llzk
830MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::CreateArrayOp)
831
832namespace llzk {
833namespace array {
834
835//===----------------------------------------------------------------------===//
836// ::llzk::array::ExtractArrayOp definitions
837//===----------------------------------------------------------------------===//
838
839namespace detail {
840ExtractArrayOpGenericAdaptorBase::ExtractArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
841 odsOpName.emplace("array.extract", odsAttrs.getContext());
842}
843
845
846std::pair<unsigned, unsigned> ExtractArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
847 bool isVariadic[] = {false, true};
848 int prevVariadicCount = 0;
849 for (unsigned i = 0; i < index; ++i)
850 if (isVariadic[i]) ++prevVariadicCount;
851
852 // Calculate how many dynamic values a static variadic operand corresponds to.
853 // This assumes all static variadic operands have the same dynamic value count.
854 int variadicSize = (odsOperandsSize - 1) / 1;
855 // `index` passed in as the parameter is the static index which counts each
856 // operand (variadic or not) as size 1. So here for each previous static variadic
857 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
858 // value pack for this static operand starts.
859 int start = index + (variadicSize - 1) * prevVariadicCount;
860 int size = isVariadic[index] ? variadicSize : 1;
861 return {start, size};
862}
863
865 return odsAttrs;
866}
867
868} // namespace detail
870
871::mlir::LogicalResult ExtractArrayOpAdaptor::verify(::mlir::Location loc) {
872 return ::mlir::success();
873}
874
875std::pair<unsigned, unsigned> ExtractArrayOp::getODSOperandIndexAndLength(unsigned index) {
876 bool isVariadic[] = {false, true};
877 int prevVariadicCount = 0;
878 for (unsigned i = 0; i < index; ++i)
879 if (isVariadic[i]) ++prevVariadicCount;
880
881 // Calculate how many dynamic values a static variadic operand corresponds to.
882 // This assumes all static variadic operands have the same dynamic value count.
883 int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
884 // `index` passed in as the parameter is the static index which counts each
885 // operand (variadic or not) as size 1. So here for each previous static variadic
886 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
887 // value pack for this static operand starts.
888 int start = index + (variadicSize - 1) * prevVariadicCount;
889 int size = isVariadic[index] ? variadicSize : 1;
890 return {start, size};
891}
892
893::mlir::Operation::operand_range ExtractArrayOp::getODSOperands(unsigned index) {
894 auto valueRange = getODSOperandIndexAndLength(index);
895 return {std::next(getOperation()->operand_begin(), valueRange.first),
896 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
897}
898
899::mlir::TypedValue<::llzk::array::ArrayType> ExtractArrayOp::getArrRef() {
900 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(0).begin());
901}
902
903::mlir::Operation::operand_range ExtractArrayOp::getIndices() {
904 return getODSOperands(1);
905}
906
908 auto range = getODSOperandIndexAndLength(0);
909 return getOperation()->getOpOperand(range.first);
910}
911
912::mlir::MutableOperandRange ExtractArrayOp::getIndicesMutable() {
913 auto range = getODSOperandIndexAndLength(1);
914 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
915 return mutableRange;
916}
917
918std::pair<unsigned, unsigned> ExtractArrayOp::getODSResultIndexAndLength(unsigned index) {
919 return {index, 1};
920}
921
922::mlir::Operation::result_range ExtractArrayOp::getODSResults(unsigned index) {
923 auto valueRange = getODSResultIndexAndLength(index);
924 return {std::next(getOperation()->result_begin(), valueRange.first),
925 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
926}
927
928::mlir::TypedValue<::llzk::array::ArrayType> ExtractArrayOp::getResult() {
929 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSResults(0).begin());
930}
931
932void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
933 odsState.addOperands(arr_ref);
934 odsState.addOperands(indices);
935 odsState.addTypes(result);
936}
937
938void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
939 odsState.addOperands(arr_ref);
940 odsState.addOperands(indices);
941
942 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
943 if (::mlir::succeeded(ExtractArrayOp::inferReturnTypes(odsBuilder.getContext(),
944 odsState.location, odsState.operands,
945 odsState.attributes.getDictionary(odsState.getContext()),
946 odsState.getRawProperties(),
947 odsState.regions, inferredReturnTypes)))
948 odsState.addTypes(inferredReturnTypes);
949 else
950 ::llvm::report_fatal_error("Failed to infer result type(s).");
951}
952
953void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
954 odsState.addOperands(arr_ref);
955 odsState.addOperands(indices);
956 assert(resultTypes.size() == 1u && "mismatched number of results");
957 odsState.addTypes(resultTypes);
958}
959
960void ExtractArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
961 assert(operands.size() >= 1u && "mismatched number of parameters");
962 odsState.addOperands(operands);
963 odsState.addAttributes(attributes);
964 assert(resultTypes.size() == 1u && "mismatched number of return types");
965 odsState.addTypes(resultTypes);
966}
967
968void ExtractArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
969 assert(operands.size() >= 1u && "mismatched number of parameters");
970 odsState.addOperands(operands);
971 odsState.addAttributes(attributes);
972
973 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
974 if (::mlir::succeeded(ExtractArrayOp::inferReturnTypes(odsBuilder.getContext(),
975 odsState.location, operands,
976 odsState.attributes.getDictionary(odsState.getContext()),
977 odsState.getRawProperties(),
978 odsState.regions, inferredReturnTypes))) {
979 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
980 odsState.addTypes(inferredReturnTypes);
981 } else {
982 ::llvm::report_fatal_error("Failed to infer result type(s).");
983 }
984}
985
987 {
988 unsigned index = 0; (void)index;
989 auto valueGroup0 = getODSOperands(0);
990
991 for (auto v : valueGroup0) {
992 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
993 return ::mlir::failure();
994 }
995 auto valueGroup1 = getODSOperands(1);
996
997 for (auto v : valueGroup1) {
998 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
999 return ::mlir::failure();
1000 }
1001 }
1002 {
1003 unsigned index = 0; (void)index;
1004 auto valueGroup0 = getODSResults(0);
1005
1006 for (auto v : valueGroup0) {
1007 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "result", index++)))
1008 return ::mlir::failure();
1009 }
1010 }
1011 return ::mlir::success();
1012}
1013
1014::mlir::LogicalResult ExtractArrayOp::verifyInvariants() {
1015 return verifyInvariantsImpl();
1016}
1017
1018::mlir::ParseResult ExtractArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1019 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperands[1];
1020 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(arr_refRawOperands); ::llvm::SMLoc arr_refOperandsLoc;
1021 (void)arr_refOperandsLoc;
1022 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1023 ::llvm::SMLoc indicesOperandsLoc;
1024 (void)indicesOperandsLoc;
1025 ::mlir::Type arr_refRawTypes[1];
1026 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(arr_refRawTypes);
1027
1028 arr_refOperandsLoc = parser.getCurrentLocation();
1029 if (parser.parseOperand(arr_refRawOperands[0]))
1030 return ::mlir::failure();
1031 if (parser.parseLSquare())
1032 return ::mlir::failure();
1033
1034 indicesOperandsLoc = parser.getCurrentLocation();
1035 if (parser.parseOperandList(indicesOperands))
1036 return ::mlir::failure();
1037 if (parser.parseRSquare())
1038 return ::mlir::failure();
1039 if (parser.parseColon())
1040 return ::mlir::failure();
1041
1042 {
1044 if (parser.parseCustomTypeWithFallback(type))
1045 return ::mlir::failure();
1046 arr_refRawTypes[0] = type;
1047 }
1048 {
1049 auto loc = parser.getCurrentLocation();(void)loc;
1050 if (parser.parseOptionalAttrDict(result.attributes))
1051 return ::mlir::failure();
1052 }
1053 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1054 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1055 return ::mlir::failure();
1056 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1057 return ::mlir::failure();
1058
1059 ::llvm::SmallVector<::mlir::Type> inferredReturnTypes;
1060 if (::mlir::failed(ExtractArrayOp::inferReturnTypes(parser.getContext(),
1061 result.location, result.operands,
1062 result.attributes.getDictionary(parser.getContext()),
1063 result.getRawProperties(),
1064 result.regions, inferredReturnTypes)))
1065 return ::mlir::failure();
1066 result.addTypes(inferredReturnTypes);
1067 return ::mlir::success();
1068}
1069
1070void ExtractArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1071 _odsPrinter << ' ';
1072 _odsPrinter << getArrRef();
1073 _odsPrinter << "[";
1074 _odsPrinter << getIndices();
1075 _odsPrinter << "]";
1076 _odsPrinter << ' ' << ":";
1077 _odsPrinter << ' ';
1078 {
1079 auto type = getArrRef().getType();
1080 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1081 _odsPrinter.printStrippedAttrOrType(validType);
1082 else
1083 _odsPrinter << type;
1084 }
1085 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1086 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1087}
1088
1089 ::mlir::LogicalResult
1090 ExtractArrayOp::inferReturnTypes(::mlir::MLIRContext *context,
1091 std::optional<::mlir::Location> location,
1092 ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
1093 ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions,
1094 ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
1095 ExtractArrayOp::Adaptor adaptor(operands, attributes, properties, regions);
1096 return ExtractArrayOp::inferReturnTypes(context,
1097 location, adaptor, inferredReturnTypes);
1098 }
1099
1100
1103 return true;
1104}
1105} // namespace array
1106} // namespace llzk
1107MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ExtractArrayOp)
1108
1109namespace llzk {
1110namespace array {
1111
1112//===----------------------------------------------------------------------===//
1113// ::llzk::array::InsertArrayOp definitions
1114//===----------------------------------------------------------------------===//
1115
1116namespace detail {
1117InsertArrayOpGenericAdaptorBase::InsertArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
1118 odsOpName.emplace("array.insert", odsAttrs.getContext());
1119}
1120
1122
1123std::pair<unsigned, unsigned> InsertArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1124 bool isVariadic[] = {false, true, false};
1125 int prevVariadicCount = 0;
1126 for (unsigned i = 0; i < index; ++i)
1127 if (isVariadic[i]) ++prevVariadicCount;
1128
1129 // Calculate how many dynamic values a static variadic operand corresponds to.
1130 // This assumes all static variadic operands have the same dynamic value count.
1131 int variadicSize = (odsOperandsSize - 2) / 1;
1132 // `index` passed in as the parameter is the static index which counts each
1133 // operand (variadic or not) as size 1. So here for each previous static variadic
1134 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1135 // value pack for this static operand starts.
1136 int start = index + (variadicSize - 1) * prevVariadicCount;
1137 int size = isVariadic[index] ? variadicSize : 1;
1138 return {start, size};
1139}
1140
1142 return odsAttrs;
1143}
1144
1145} // namespace detail
1147
1148::mlir::LogicalResult InsertArrayOpAdaptor::verify(::mlir::Location loc) {
1149 return ::mlir::success();
1150}
1151
1152std::pair<unsigned, unsigned> InsertArrayOp::getODSOperandIndexAndLength(unsigned index) {
1153 bool isVariadic[] = {false, true, false};
1154 int prevVariadicCount = 0;
1155 for (unsigned i = 0; i < index; ++i)
1156 if (isVariadic[i]) ++prevVariadicCount;
1157
1158 // Calculate how many dynamic values a static variadic operand corresponds to.
1159 // This assumes all static variadic operands have the same dynamic value count.
1160 int variadicSize = (getOperation()->getNumOperands() - 2) / 1;
1161 // `index` passed in as the parameter is the static index which counts each
1162 // operand (variadic or not) as size 1. So here for each previous static variadic
1163 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1164 // value pack for this static operand starts.
1165 int start = index + (variadicSize - 1) * prevVariadicCount;
1166 int size = isVariadic[index] ? variadicSize : 1;
1167 return {start, size};
1168}
1169
1170::mlir::Operation::operand_range InsertArrayOp::getODSOperands(unsigned index) {
1171 auto valueRange = getODSOperandIndexAndLength(index);
1172 return {std::next(getOperation()->operand_begin(), valueRange.first),
1173 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1174}
1175
1176::mlir::TypedValue<::llzk::array::ArrayType> InsertArrayOp::getArrRef() {
1177 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(0).begin());
1178}
1179
1180::mlir::Operation::operand_range InsertArrayOp::getIndices() {
1181 return getODSOperands(1);
1182}
1183
1184::mlir::TypedValue<::llzk::array::ArrayType> InsertArrayOp::getRvalue() {
1185 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(2).begin());
1186}
1187
1189 auto range = getODSOperandIndexAndLength(0);
1190 return getOperation()->getOpOperand(range.first);
1191}
1192
1193::mlir::MutableOperandRange InsertArrayOp::getIndicesMutable() {
1194 auto range = getODSOperandIndexAndLength(1);
1195 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1196 return mutableRange;
1197}
1198
1200 auto range = getODSOperandIndexAndLength(2);
1201 return getOperation()->getOpOperand(range.first);
1202}
1203
1204std::pair<unsigned, unsigned> InsertArrayOp::getODSResultIndexAndLength(unsigned index) {
1205 return {index, 1};
1206}
1207
1208::mlir::Operation::result_range InsertArrayOp::getODSResults(unsigned index) {
1209 auto valueRange = getODSResultIndexAndLength(index);
1210 return {std::next(getOperation()->result_begin(), valueRange.first),
1211 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1212}
1213
1214void InsertArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1215 odsState.addOperands(arr_ref);
1216 odsState.addOperands(indices);
1217 odsState.addOperands(rvalue);
1218}
1219
1220void InsertArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1221 odsState.addOperands(arr_ref);
1222 odsState.addOperands(indices);
1223 odsState.addOperands(rvalue);
1224 assert(resultTypes.size() == 0u && "mismatched number of results");
1225 odsState.addTypes(resultTypes);
1226}
1227
1228void InsertArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1229 assert(operands.size() >= 2u && "mismatched number of parameters");
1230 odsState.addOperands(operands);
1231 odsState.addAttributes(attributes);
1232 assert(resultTypes.size() == 0u && "mismatched number of return types");
1233 odsState.addTypes(resultTypes);
1234}
1235
1237 {
1238 unsigned index = 0; (void)index;
1239 auto valueGroup0 = getODSOperands(0);
1240
1241 for (auto v : valueGroup0) {
1242 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
1243 return ::mlir::failure();
1244 }
1245 auto valueGroup1 = getODSOperands(1);
1246
1247 for (auto v : valueGroup1) {
1248 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
1249 return ::mlir::failure();
1250 }
1251 auto valueGroup2 = getODSOperands(2);
1252
1253 for (auto v : valueGroup2) {
1254 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
1255 return ::mlir::failure();
1256 }
1257 }
1258 return ::mlir::success();
1259}
1260
1261::mlir::LogicalResult InsertArrayOp::verifyInvariants() {
1262 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1263 return ::mlir::success();
1264 return ::mlir::failure();
1265}
1266
1267::mlir::ParseResult InsertArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1268 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperands[1];
1269 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(arr_refRawOperands); ::llvm::SMLoc arr_refOperandsLoc;
1270 (void)arr_refOperandsLoc;
1271 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1272 ::llvm::SMLoc indicesOperandsLoc;
1273 (void)indicesOperandsLoc;
1274 ::mlir::OpAsmParser::UnresolvedOperand rvalueRawOperands[1];
1275 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rvalueOperands(rvalueRawOperands); ::llvm::SMLoc rvalueOperandsLoc;
1276 (void)rvalueOperandsLoc;
1277 ::mlir::Type arr_refRawTypes[1];
1278 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(arr_refRawTypes);
1279 ::mlir::Type rvalueRawTypes[1];
1280 ::llvm::ArrayRef<::mlir::Type> rvalueTypes(rvalueRawTypes);
1281
1282 arr_refOperandsLoc = parser.getCurrentLocation();
1283 if (parser.parseOperand(arr_refRawOperands[0]))
1284 return ::mlir::failure();
1285 if (parser.parseLSquare())
1286 return ::mlir::failure();
1287
1288 indicesOperandsLoc = parser.getCurrentLocation();
1289 if (parser.parseOperandList(indicesOperands))
1290 return ::mlir::failure();
1291 if (parser.parseRSquare())
1292 return ::mlir::failure();
1293 if (parser.parseEqual())
1294 return ::mlir::failure();
1295
1296 rvalueOperandsLoc = parser.getCurrentLocation();
1297 if (parser.parseOperand(rvalueRawOperands[0]))
1298 return ::mlir::failure();
1299 if (parser.parseColon())
1300 return ::mlir::failure();
1301
1302 {
1304 if (parser.parseCustomTypeWithFallback(type))
1305 return ::mlir::failure();
1306 arr_refRawTypes[0] = type;
1307 }
1308 if (parser.parseComma())
1309 return ::mlir::failure();
1310
1311 {
1313 if (parser.parseCustomTypeWithFallback(type))
1314 return ::mlir::failure();
1315 rvalueRawTypes[0] = type;
1316 }
1317 {
1318 auto loc = parser.getCurrentLocation();(void)loc;
1319 if (parser.parseOptionalAttrDict(result.attributes))
1320 return ::mlir::failure();
1321 }
1322 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1323 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1324 return ::mlir::failure();
1325 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1326 return ::mlir::failure();
1327 if (parser.resolveOperands(rvalueOperands, rvalueTypes, rvalueOperandsLoc, result.operands))
1328 return ::mlir::failure();
1329 return ::mlir::success();
1330}
1331
1332void InsertArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1333 _odsPrinter << ' ';
1334 _odsPrinter << getArrRef();
1335 _odsPrinter << "[";
1336 _odsPrinter << getIndices();
1337 _odsPrinter << "]";
1338 _odsPrinter << ' ' << "=";
1339 _odsPrinter << ' ';
1340 _odsPrinter << getRvalue();
1341 _odsPrinter << ' ' << ":";
1342 _odsPrinter << ' ';
1343 {
1344 auto type = getArrRef().getType();
1345 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1346 _odsPrinter.printStrippedAttrOrType(validType);
1347 else
1348 _odsPrinter << type;
1349 }
1350 _odsPrinter << ",";
1351 _odsPrinter << ' ';
1352 {
1353 auto type = getRvalue().getType();
1354 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1355 _odsPrinter.printStrippedAttrOrType(validType);
1356 else
1357 _odsPrinter << type;
1358 }
1359 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1360 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1361}
1362
1365 return false;
1366}
1367} // namespace array
1368} // namespace llzk
1369MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::InsertArrayOp)
1370
1371namespace llzk {
1372namespace array {
1373
1374//===----------------------------------------------------------------------===//
1375// ::llzk::array::ReadArrayOp definitions
1376//===----------------------------------------------------------------------===//
1377
1378namespace detail {
1379ReadArrayOpGenericAdaptorBase::ReadArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
1380 odsOpName.emplace("array.read", odsAttrs.getContext());
1381}
1382
1383ReadArrayOpGenericAdaptorBase::ReadArrayOpGenericAdaptorBase(ReadArrayOp op) : ReadArrayOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {}
1384
1385std::pair<unsigned, unsigned> ReadArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1386 bool isVariadic[] = {false, true};
1387 int prevVariadicCount = 0;
1388 for (unsigned i = 0; i < index; ++i)
1389 if (isVariadic[i]) ++prevVariadicCount;
1390
1391 // Calculate how many dynamic values a static variadic operand corresponds to.
1392 // This assumes all static variadic operands have the same dynamic value count.
1393 int variadicSize = (odsOperandsSize - 1) / 1;
1394 // `index` passed in as the parameter is the static index which counts each
1395 // operand (variadic or not) as size 1. So here for each previous static variadic
1396 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1397 // value pack for this static operand starts.
1398 int start = index + (variadicSize - 1) * prevVariadicCount;
1399 int size = isVariadic[index] ? variadicSize : 1;
1400 return {start, size};
1401}
1402
1404 return odsAttrs;
1405}
1406
1407} // namespace detail
1409
1410::mlir::LogicalResult ReadArrayOpAdaptor::verify(::mlir::Location loc) {
1411 return ::mlir::success();
1412}
1413
1414std::pair<unsigned, unsigned> ReadArrayOp::getODSOperandIndexAndLength(unsigned index) {
1415 bool isVariadic[] = {false, true};
1416 int prevVariadicCount = 0;
1417 for (unsigned i = 0; i < index; ++i)
1418 if (isVariadic[i]) ++prevVariadicCount;
1419
1420 // Calculate how many dynamic values a static variadic operand corresponds to.
1421 // This assumes all static variadic operands have the same dynamic value count.
1422 int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
1423 // `index` passed in as the parameter is the static index which counts each
1424 // operand (variadic or not) as size 1. So here for each previous static variadic
1425 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1426 // value pack for this static operand starts.
1427 int start = index + (variadicSize - 1) * prevVariadicCount;
1428 int size = isVariadic[index] ? variadicSize : 1;
1429 return {start, size};
1430}
1431
1432::mlir::Operation::operand_range ReadArrayOp::getODSOperands(unsigned index) {
1433 auto valueRange = getODSOperandIndexAndLength(index);
1434 return {std::next(getOperation()->operand_begin(), valueRange.first),
1435 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1436}
1437
1438::mlir::TypedValue<::llzk::array::ArrayType> ReadArrayOp::getArrRef() {
1439 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(0).begin());
1440}
1441
1442::mlir::Operation::operand_range ReadArrayOp::getIndices() {
1443 return getODSOperands(1);
1444}
1445
1446::mlir::OpOperand &ReadArrayOp::getArrRefMutable() {
1447 auto range = getODSOperandIndexAndLength(0);
1448 return getOperation()->getOpOperand(range.first);
1449}
1450
1451::mlir::MutableOperandRange ReadArrayOp::getIndicesMutable() {
1452 auto range = getODSOperandIndexAndLength(1);
1453 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1454 return mutableRange;
1455}
1456
1457std::pair<unsigned, unsigned> ReadArrayOp::getODSResultIndexAndLength(unsigned index) {
1458 return {index, 1};
1459}
1460
1461::mlir::Operation::result_range ReadArrayOp::getODSResults(unsigned index) {
1462 auto valueRange = getODSResultIndexAndLength(index);
1463 return {std::next(getOperation()->result_begin(), valueRange.first),
1464 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1465}
1466
1467::mlir::Value ReadArrayOp::getResult() {
1468 return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin());
1469}
1470
1471void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1472 odsState.addOperands(arr_ref);
1473 odsState.addOperands(indices);
1474 odsState.addTypes(result);
1475}
1476
1477void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1478 odsState.addOperands(arr_ref);
1479 odsState.addOperands(indices);
1480
1481 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1482 if (::mlir::succeeded(ReadArrayOp::inferReturnTypes(odsBuilder.getContext(),
1483 odsState.location, odsState.operands,
1484 odsState.attributes.getDictionary(odsState.getContext()),
1485 odsState.getRawProperties(),
1486 odsState.regions, inferredReturnTypes)))
1487 odsState.addTypes(inferredReturnTypes);
1488 else
1489 ::llvm::report_fatal_error("Failed to infer result type(s).");
1490}
1491
1492void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices) {
1493 odsState.addOperands(arr_ref);
1494 odsState.addOperands(indices);
1495 assert(resultTypes.size() == 1u && "mismatched number of results");
1496 odsState.addTypes(resultTypes);
1497}
1498
1499void ReadArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1500 assert(operands.size() >= 1u && "mismatched number of parameters");
1501 odsState.addOperands(operands);
1502 odsState.addAttributes(attributes);
1503 assert(resultTypes.size() == 1u && "mismatched number of return types");
1504 odsState.addTypes(resultTypes);
1505}
1506
1507void ReadArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1508 assert(operands.size() >= 1u && "mismatched number of parameters");
1509 odsState.addOperands(operands);
1510 odsState.addAttributes(attributes);
1511
1512 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
1513 if (::mlir::succeeded(ReadArrayOp::inferReturnTypes(odsBuilder.getContext(),
1514 odsState.location, operands,
1515 odsState.attributes.getDictionary(odsState.getContext()),
1516 odsState.getRawProperties(),
1517 odsState.regions, inferredReturnTypes))) {
1518 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
1519 odsState.addTypes(inferredReturnTypes);
1520 } else {
1521 ::llvm::report_fatal_error("Failed to infer result type(s).");
1522 }
1523}
1524
1525::mlir::LogicalResult ReadArrayOp::verifyInvariantsImpl() {
1526 {
1527 unsigned index = 0; (void)index;
1528 auto valueGroup0 = getODSOperands(0);
1529
1530 for (auto v : valueGroup0) {
1531 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
1532 return ::mlir::failure();
1533 }
1534 auto valueGroup1 = getODSOperands(1);
1535
1536 for (auto v : valueGroup1) {
1537 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
1538 return ::mlir::failure();
1539 }
1540 }
1541 {
1542 unsigned index = 0; (void)index;
1543 auto valueGroup0 = getODSResults(0);
1544
1545 for (auto v : valueGroup0) {
1546 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "result", index++)))
1547 return ::mlir::failure();
1548 }
1549 }
1550 if (!((::llzk::typesUnify(::llvm::cast<::llzk::array::ArrayType>((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType()))))
1551 return emitOpError("failed to verify that result type matches with arr_ref element type");
1552 return ::mlir::success();
1553}
1554
1555::mlir::LogicalResult ReadArrayOp::verifyInvariants() {
1556 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1557 return ::mlir::success();
1558 return ::mlir::failure();
1559}
1560
1561::mlir::ParseResult ReadArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1562 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperands[1];
1563 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(arr_refRawOperands); ::llvm::SMLoc arr_refOperandsLoc;
1564 (void)arr_refOperandsLoc;
1565 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1566 ::llvm::SMLoc indicesOperandsLoc;
1567 (void)indicesOperandsLoc;
1568 ::mlir::Type arr_refRawTypes[1];
1569 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(arr_refRawTypes);
1570 ::mlir::Type resultRawTypes[1];
1571 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
1572
1573 arr_refOperandsLoc = parser.getCurrentLocation();
1574 if (parser.parseOperand(arr_refRawOperands[0]))
1575 return ::mlir::failure();
1576 if (parser.parseLSquare())
1577 return ::mlir::failure();
1578
1579 indicesOperandsLoc = parser.getCurrentLocation();
1580 if (parser.parseOperandList(indicesOperands))
1581 return ::mlir::failure();
1582 if (parser.parseRSquare())
1583 return ::mlir::failure();
1584 if (parser.parseColon())
1585 return ::mlir::failure();
1586
1587 {
1589 if (parser.parseCustomTypeWithFallback(type))
1590 return ::mlir::failure();
1591 arr_refRawTypes[0] = type;
1592 }
1593 if (parser.parseComma())
1594 return ::mlir::failure();
1595
1596 {
1597 ::mlir::Type type;
1598 if (parser.parseCustomTypeWithFallback(type))
1599 return ::mlir::failure();
1600 resultRawTypes[0] = type;
1601 }
1602 {
1603 auto loc = parser.getCurrentLocation();(void)loc;
1604 if (parser.parseOptionalAttrDict(result.attributes))
1605 return ::mlir::failure();
1606 }
1607 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1608 result.addTypes(resultTypes);
1609 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1610 return ::mlir::failure();
1611 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1612 return ::mlir::failure();
1613 return ::mlir::success();
1614}
1615
1616void ReadArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1617 _odsPrinter << ' ';
1618 _odsPrinter << getArrRef();
1619 _odsPrinter << "[";
1620 _odsPrinter << getIndices();
1621 _odsPrinter << "]";
1622 _odsPrinter << ' ' << ":";
1623 _odsPrinter << ' ';
1624 {
1625 auto type = getArrRef().getType();
1626 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1627 _odsPrinter.printStrippedAttrOrType(validType);
1628 else
1629 _odsPrinter << type;
1630 }
1631 _odsPrinter << ",";
1632 _odsPrinter << ' ';
1633 {
1634 auto type = getResult().getType();
1635 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1636 _odsPrinter.printStrippedAttrOrType(validType);
1637 else
1638 _odsPrinter << type;
1639 }
1640 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1641 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1642}
1643
1644 ::mlir::LogicalResult
1645 ReadArrayOp::inferReturnTypes(::mlir::MLIRContext *context,
1646 std::optional<::mlir::Location> location,
1647 ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
1648 ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions,
1649 ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
1650 ReadArrayOp::Adaptor adaptor(operands, attributes, properties, regions);
1651 return ReadArrayOp::inferReturnTypes(context,
1652 location, adaptor, inferredReturnTypes);
1653 }
1654
1655
1657bool ReadArrayOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
1658 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
1659 ::mlir::SmallVectorImpl<::mlir::MemorySlot>
1660 &mustBeSafelyUsed) {
1661 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
1662 .canRewire(slot, usedIndices, mustBeSafelyUsed);
1663}
1664
1666::mlir::DeletionKind ReadArrayOp::rewire(const
1667::mlir::DestructurableMemorySlot &slot,
1668 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
1669 ::mlir::RewriterBase &rewriter) {
1670 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
1671 .rewire(slot, subslots, rewriter);
1672}
1673
1675bool ReadArrayOp::loadsFrom(const ::mlir::MemorySlot &slot) {
1676 return getArrRef() == slot.ptr;
1677}
1678
1680bool ReadArrayOp::storesTo(const ::mlir::MemorySlot &slot) {
1681 return false;
1682}
1683
1685::mlir::Value ReadArrayOp::getStored(const ::mlir::MemorySlot &, ::mlir::RewriterBase &) {
1686 llvm_unreachable("getStored() should not be called on ReadArrayOp");
1687}
1688
1691 return true;
1692}
1693} // namespace array
1694} // namespace llzk
1695MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::ReadArrayOp)
1696
1697namespace llzk {
1698namespace array {
1699
1700//===----------------------------------------------------------------------===//
1701// ::llzk::array::WriteArrayOp definitions
1702//===----------------------------------------------------------------------===//
1703
1704namespace detail {
1705WriteArrayOpGenericAdaptorBase::WriteArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
1706 odsOpName.emplace("array.write", odsAttrs.getContext());
1707}
1708
1709WriteArrayOpGenericAdaptorBase::WriteArrayOpGenericAdaptorBase(WriteArrayOp op) : WriteArrayOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {}
1710
1711std::pair<unsigned, unsigned> WriteArrayOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
1712 bool isVariadic[] = {false, true, false};
1713 int prevVariadicCount = 0;
1714 for (unsigned i = 0; i < index; ++i)
1715 if (isVariadic[i]) ++prevVariadicCount;
1716
1717 // Calculate how many dynamic values a static variadic operand corresponds to.
1718 // This assumes all static variadic operands have the same dynamic value count.
1719 int variadicSize = (odsOperandsSize - 2) / 1;
1720 // `index` passed in as the parameter is the static index which counts each
1721 // operand (variadic or not) as size 1. So here for each previous static variadic
1722 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1723 // value pack for this static operand starts.
1724 int start = index + (variadicSize - 1) * prevVariadicCount;
1725 int size = isVariadic[index] ? variadicSize : 1;
1726 return {start, size};
1727}
1728
1730 return odsAttrs;
1731}
1732
1733} // namespace detail
1735
1736::mlir::LogicalResult WriteArrayOpAdaptor::verify(::mlir::Location loc) {
1737 return ::mlir::success();
1738}
1739
1740std::pair<unsigned, unsigned> WriteArrayOp::getODSOperandIndexAndLength(unsigned index) {
1741 bool isVariadic[] = {false, true, false};
1742 int prevVariadicCount = 0;
1743 for (unsigned i = 0; i < index; ++i)
1744 if (isVariadic[i]) ++prevVariadicCount;
1745
1746 // Calculate how many dynamic values a static variadic operand corresponds to.
1747 // This assumes all static variadic operands have the same dynamic value count.
1748 int variadicSize = (getOperation()->getNumOperands() - 2) / 1;
1749 // `index` passed in as the parameter is the static index which counts each
1750 // operand (variadic or not) as size 1. So here for each previous static variadic
1751 // operand, we need to offset by (variadicSize - 1) to get where the dynamic
1752 // value pack for this static operand starts.
1753 int start = index + (variadicSize - 1) * prevVariadicCount;
1754 int size = isVariadic[index] ? variadicSize : 1;
1755 return {start, size};
1756}
1757
1758::mlir::Operation::operand_range WriteArrayOp::getODSOperands(unsigned index) {
1759 auto valueRange = getODSOperandIndexAndLength(index);
1760 return {std::next(getOperation()->operand_begin(), valueRange.first),
1761 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1762}
1763
1764::mlir::TypedValue<::llzk::array::ArrayType> WriteArrayOp::getArrRef() {
1765 return ::llvm::cast<::mlir::TypedValue<::llzk::array::ArrayType>>(*getODSOperands(0).begin());
1766}
1767
1768::mlir::Operation::operand_range WriteArrayOp::getIndices() {
1769 return getODSOperands(1);
1770}
1771
1773 return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin());
1774}
1775
1777 auto range = getODSOperandIndexAndLength(0);
1778 return getOperation()->getOpOperand(range.first);
1779}
1780
1781::mlir::MutableOperandRange WriteArrayOp::getIndicesMutable() {
1782 auto range = getODSOperandIndexAndLength(1);
1783 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1784 return mutableRange;
1785}
1786
1788 auto range = getODSOperandIndexAndLength(2);
1789 return getOperation()->getOpOperand(range.first);
1790}
1791
1792std::pair<unsigned, unsigned> WriteArrayOp::getODSResultIndexAndLength(unsigned index) {
1793 return {index, 1};
1794}
1795
1796::mlir::Operation::result_range WriteArrayOp::getODSResults(unsigned index) {
1797 auto valueRange = getODSResultIndexAndLength(index);
1798 return {std::next(getOperation()->result_begin(), valueRange.first),
1799 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1800}
1801
1802void WriteArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1803 odsState.addOperands(arr_ref);
1804 odsState.addOperands(indices);
1805 odsState.addOperands(rvalue);
1806}
1807
1808void WriteArrayOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue) {
1809 odsState.addOperands(arr_ref);
1810 odsState.addOperands(indices);
1811 odsState.addOperands(rvalue);
1812 assert(resultTypes.size() == 0u && "mismatched number of results");
1813 odsState.addTypes(resultTypes);
1814}
1815
1816void WriteArrayOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1817 assert(operands.size() >= 2u && "mismatched number of parameters");
1818 odsState.addOperands(operands);
1819 odsState.addAttributes(attributes);
1820 assert(resultTypes.size() == 0u && "mismatched number of return types");
1821 odsState.addTypes(resultTypes);
1822}
1823
1824::mlir::LogicalResult WriteArrayOp::verifyInvariantsImpl() {
1825 {
1826 unsigned index = 0; (void)index;
1827 auto valueGroup0 = getODSOperands(0);
1828
1829 for (auto v : valueGroup0) {
1830 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
1831 return ::mlir::failure();
1832 }
1833 auto valueGroup1 = getODSOperands(1);
1834
1835 for (auto v : valueGroup1) {
1836 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
1837 return ::mlir::failure();
1838 }
1839 auto valueGroup2 = getODSOperands(2);
1840
1841 for (auto v : valueGroup2) {
1842 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops4(*this, v.getType(), "operand", index++)))
1843 return ::mlir::failure();
1844 }
1845 }
1846 if (!((::llzk::typesUnify(::llvm::cast<::llzk::array::ArrayType>((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSOperands(2).begin()).getType()))))
1847 return emitOpError("failed to verify that rvalue type matches with arr_ref element type");
1848 return ::mlir::success();
1849}
1850
1851::mlir::LogicalResult WriteArrayOp::verifyInvariants() {
1852 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
1853 return ::mlir::success();
1854 return ::mlir::failure();
1855}
1856
1857::mlir::ParseResult WriteArrayOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1858 ::mlir::OpAsmParser::UnresolvedOperand arr_refRawOperands[1];
1859 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arr_refOperands(arr_refRawOperands); ::llvm::SMLoc arr_refOperandsLoc;
1860 (void)arr_refOperandsLoc;
1861 ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands;
1862 ::llvm::SMLoc indicesOperandsLoc;
1863 (void)indicesOperandsLoc;
1864 ::mlir::OpAsmParser::UnresolvedOperand rvalueRawOperands[1];
1865 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rvalueOperands(rvalueRawOperands); ::llvm::SMLoc rvalueOperandsLoc;
1866 (void)rvalueOperandsLoc;
1867 ::mlir::Type arr_refRawTypes[1];
1868 ::llvm::ArrayRef<::mlir::Type> arr_refTypes(arr_refRawTypes);
1869 ::mlir::Type rvalueRawTypes[1];
1870 ::llvm::ArrayRef<::mlir::Type> rvalueTypes(rvalueRawTypes);
1871
1872 arr_refOperandsLoc = parser.getCurrentLocation();
1873 if (parser.parseOperand(arr_refRawOperands[0]))
1874 return ::mlir::failure();
1875 if (parser.parseLSquare())
1876 return ::mlir::failure();
1877
1878 indicesOperandsLoc = parser.getCurrentLocation();
1879 if (parser.parseOperandList(indicesOperands))
1880 return ::mlir::failure();
1881 if (parser.parseRSquare())
1882 return ::mlir::failure();
1883 if (parser.parseEqual())
1884 return ::mlir::failure();
1885
1886 rvalueOperandsLoc = parser.getCurrentLocation();
1887 if (parser.parseOperand(rvalueRawOperands[0]))
1888 return ::mlir::failure();
1889 if (parser.parseColon())
1890 return ::mlir::failure();
1891
1892 {
1894 if (parser.parseCustomTypeWithFallback(type))
1895 return ::mlir::failure();
1896 arr_refRawTypes[0] = type;
1897 }
1898 if (parser.parseComma())
1899 return ::mlir::failure();
1900
1901 {
1902 ::mlir::Type type;
1903 if (parser.parseCustomTypeWithFallback(type))
1904 return ::mlir::failure();
1905 rvalueRawTypes[0] = type;
1906 }
1907 {
1908 auto loc = parser.getCurrentLocation();(void)loc;
1909 if (parser.parseOptionalAttrDict(result.attributes))
1910 return ::mlir::failure();
1911 }
1912 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
1913 if (parser.resolveOperands(arr_refOperands, arr_refTypes, arr_refOperandsLoc, result.operands))
1914 return ::mlir::failure();
1915 if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands))
1916 return ::mlir::failure();
1917 if (parser.resolveOperands(rvalueOperands, rvalueTypes, rvalueOperandsLoc, result.operands))
1918 return ::mlir::failure();
1919 return ::mlir::success();
1920}
1921
1922void WriteArrayOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1923 _odsPrinter << ' ';
1924 _odsPrinter << getArrRef();
1925 _odsPrinter << "[";
1926 _odsPrinter << getIndices();
1927 _odsPrinter << "]";
1928 _odsPrinter << ' ' << "=";
1929 _odsPrinter << ' ';
1930 _odsPrinter << getRvalue();
1931 _odsPrinter << ' ' << ":";
1932 _odsPrinter << ' ';
1933 {
1934 auto type = getArrRef().getType();
1935 if (auto validType = ::llvm::dyn_cast<::llzk::array::ArrayType>(type))
1936 _odsPrinter.printStrippedAttrOrType(validType);
1937 else
1938 _odsPrinter << type;
1939 }
1940 _odsPrinter << ",";
1941 _odsPrinter << ' ';
1942 {
1943 auto type = getRvalue().getType();
1944 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1945 _odsPrinter.printStrippedAttrOrType(validType);
1946 else
1947 _odsPrinter << type;
1948 }
1949 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1950 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1951}
1952
1954bool WriteArrayOp::canRewire(const ::mlir::DestructurableMemorySlot &slot,
1955 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
1956 ::mlir::SmallVectorImpl<::mlir::MemorySlot>
1957 &mustBeSafelyUsed) {
1958 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
1959 .canRewire(slot, usedIndices, mustBeSafelyUsed);
1960}
1961
1963::mlir::DeletionKind WriteArrayOp::rewire(const
1964::mlir::DestructurableMemorySlot &slot,
1965 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
1966 ::mlir::RewriterBase &rewriter) {
1967 return ::llvm::cast<ArrayAccessOpInterface>(getOperation())
1968 .rewire(slot, subslots, rewriter);
1969}
1970
1972bool WriteArrayOp::loadsFrom(const ::mlir::MemorySlot &slot) {
1973 return false;
1974}
1975
1977bool WriteArrayOp::storesTo(const ::mlir::MemorySlot &slot) {
1978 return getArrRef() == slot.ptr;
1979}
1980
1982::mlir::Value WriteArrayOp::getStored(const ::mlir::MemorySlot &, ::mlir::RewriterBase &) {
1983 return getRvalue();
1984}
1985
1988 return false;
1989}
1990} // namespace array
1991} // namespace llzk
1992MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::array::WriteArrayOp)
1993
1994
1995#endif // GET_OP_CLASSES
1996
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:122
ArrayLengthOpAdaptor(ArrayLengthOp op)
Definition Ops.cpp.inc:120
ArrayLengthOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:80
::mlir::TypedValue<::mlir::IndexType > getDim()
Definition Ops.cpp.inc:140
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:154
::mlir::OpOperand & getDimMutable()
Definition Ops.cpp.inc:149
::mlir::OpOperand & getArrRefMutable()
Definition Ops.cpp.inc:144
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:222
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:323
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:158
::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:254
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:304
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type length, ::mlir::Value arr_ref, ::mlir::Value dim)
Definition Ops.cpp.inc:168
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:262
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.cpp.inc:136
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:130
::mlir::TypedValue<::mlir::IndexType > getLength()
Definition Ops.cpp.inc:164
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:126
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:250
CreateArrayOpAdaptor(CreateArrayOp op)
Definition Ops.cpp.inc:378
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:380
CreateArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:245
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:432
static void printInferredArrayType(::mlir::OpAsmPrinter &printer, CreateArrayOp, ::mlir::TypeRange, ::mlir::OperandRange, ::mlir::Type)
Definition Ops.cpp:94
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:629
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:393
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:428
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:573
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:802
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:442
void setNumDimsPerMapAttr(::mlir::DenseI32ArrayAttr attr)
Definition Ops.cpp.inc:667
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::array::ArrayType result, ::mlir::ValueRange elements={})
void setMapOpGroupSizesAttr(::mlir::DenseI32ArrayAttr attr)
Definition Ops.cpp.inc:675
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:825
::mlir::ParseResult parseInferredArrayType(::mlir::OpAsmParser &parser, ::llvm::SmallVector<::mlir::Type, 1 > &elementsTypes, ::mlir::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand > elements, ::mlir::Type resultType)
Definition Ops.cpp:81
::mlir::MutableOperandRangeRange getMapOperandsMutable()
Definition Ops.cpp.inc:422
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:595
void setNumDimsPerMap(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:671
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:543
::mlir::StringAttr getNumDimsPerMapAttrName()
Definition Ops.h.inc:314
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:735
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:533
::mlir::LogicalResult verify()
Definition Ops.cpp:100
::mlir::DenseI32ArrayAttr getNumDimsPerMapAttr()
Definition Ops.cpp.inc:649
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:402
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:580
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:653
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:694
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:662
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:504
FoldAdaptor::Properties Properties
Definition Ops.h.inc:300
::mlir::StringAttr getMapOpGroupSizesAttrName()
Definition Ops.h.inc:306
::mlir::MutableOperandRange getElementsMutable()
Definition Ops.cpp.inc:416
::mlir::OperandRangeRange getMapOperands()
Definition Ops.cpp.inc:412
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:741
::mlir::Operation::operand_range getElements()
Definition Ops.cpp.inc:408
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:553
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:688
void setMapOpGroupSizes(::llvm::ArrayRef< int32_t > attrValue)
Definition Ops.cpp.inc:679
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.cpp.inc:658
::mlir::TypedValue<::llzk::array::ArrayType > getResult()
Definition Ops.cpp.inc:438
ExtractArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:436
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:871
ExtractArrayOpAdaptor(ExtractArrayOp op)
Definition Ops.cpp.inc:869
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:932
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:918
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1018
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:893
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:912
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1014
::mlir::TypedValue<::llzk::array::ArrayType > getResult()
Definition Ops.cpp.inc:928
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1102
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:986
ExtractArrayOpAdaptor Adaptor
Definition Ops.h.inc:479
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:922
::mlir::Operation::operand_range getIndices()
Definition Ops.cpp.inc:903
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.cpp.inc:899
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1070
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:875
::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
::mlir::OpOperand & getArrRefMutable()
Definition Ops.cpp.inc:907
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1148
InsertArrayOpAdaptor(InsertArrayOp op)
Definition Ops.cpp.inc:1146
InsertArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:559
::mlir::TypedValue<::llzk::array::ArrayType > getRvalue()
Definition Ops.cpp.inc:1184
::mlir::Operation::operand_range getIndices()
Definition Ops.cpp.inc:1180
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1364
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:1170
::mlir::LogicalResult verify()
Definition Ops.cpp:428
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1261
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1267
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:1208
::mlir::OpOperand & getRvalueMutable()
Definition Ops.cpp.inc:1199
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1332
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1236
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.cpp.inc:1176
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1152
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1204
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:1214
::mlir::OpOperand & getArrRefMutable()
Definition Ops.cpp.inc:1188
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1193
ReadArrayOpAdaptor(ReadArrayOp op)
Definition Ops.cpp.inc:1408
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1410
ReadArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:676
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:1432
::mlir::Operation::operand_range getIndices()
Definition Ops.cpp.inc:1442
::mlir::OpOperand & getArrRefMutable()
Definition Ops.cpp.inc:1446
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1680
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1675
::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > &subslots, ::mlir::RewriterBase &rewriter)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1666
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.cpp.inc:1438
::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1561
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1690
::mlir::LogicalResult verify()
Definition Ops.cpp:307
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arr_ref, ::mlir::ValueRange indices)
Definition Ops.cpp.inc:1471
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1457
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1616
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1555
::mlir::Value getStored(const ::mlir::MemorySlot &slot, ::mlir::RewriterBase &rewriter)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1685
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:1461
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1525
bool canRewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot > &mustBeSafelyUsed)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1657
ReadArrayOpAdaptor Adaptor
Definition Ops.h.inc:719
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1414
::mlir::Value getResult()
Definition Ops.cpp.inc:1467
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1451
WriteArrayOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:807
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:1736
WriteArrayOpAdaptor(WriteArrayOp op)
Definition Ops.cpp.inc:1734
bool isRead()
Return true if the op is a read, false if it's a write.
Definition Ops.cpp.inc:1987
bool loadsFrom(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1972
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1824
::mlir::OpOperand & getRvalueMutable()
Definition Ops.cpp.inc:1787
::mlir::OpOperand & getArrRefMutable()
Definition Ops.cpp.inc:1776
::mlir::Operation::operand_range getIndices()
Definition Ops.cpp.inc:1768
::mlir::LogicalResult verify()
Definition Ops.cpp:346
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1922
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1857
::mlir::Value getRvalue()
Definition Ops.cpp.inc:1772
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.cpp.inc:1764
bool storesTo(const ::mlir::MemorySlot &slot)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1977
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1851
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arr_ref, ::mlir::ValueRange indices, ::mlir::Value rvalue)
Definition Ops.cpp.inc:1802
::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > &subslots, ::mlir::RewriterBase &rewriter)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1963
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1792
::mlir::MutableOperandRange getIndicesMutable()
Definition Ops.cpp.inc:1781
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:1758
bool canRewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot > &mustBeSafelyUsed)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp.inc:1954
::mlir::Value getStored(const ::mlir::MemorySlot &slot, ::mlir::RewriterBase &rewriter)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp.inc:1982
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:1796
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1740
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:111
ArrayLengthOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:105
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:64
::llvm::ArrayRef< int32_t > getMapOpGroupSizes()
Definition Ops.cpp.inc:372
CreateArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:338
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:362
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:344
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:220
::mlir::DenseI32ArrayAttr getMapOpGroupSizesAttr()
Definition Ops.cpp.inc:367
ExtractArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:840
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:420
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:846
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1123
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:543
InsertArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:1117
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:660
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1385
ReadArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:1379
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:1711
WriteArrayOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:1705
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:791
bool isValidArrayElemType(Type type)
mlir::ParseResult parseAttrDictWithWarnings(mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state)
Definition OpHelpers.h:109
void printMultiDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
Definition OpHelpers.h:102
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename mlir::PropertiesSelector< ConcreteOp >::type state)
Definition OpHelpers.h:116
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:94