LLZK 2.1.1
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.cpp
Go to the documentation of this file.
1//===-- Ops.cpp - Array operation implementations ---------------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
11
15#include "llzk/Util/Compare.h"
17
18#include <mlir/Dialect/Arith/IR/Arith.h>
19#include <mlir/Dialect/Utils/IndexingUtils.h>
20#include <mlir/IR/Attributes.h>
21#include <mlir/IR/BuiltinOps.h>
22#include <mlir/IR/Diagnostics.h>
23#include <mlir/IR/Matchers.h>
24#include <mlir/IR/OwningOpRef.h>
25#include <mlir/IR/SymbolTable.h>
26#include <mlir/IR/ValueRange.h>
27#include <mlir/Support/LogicalResult.h>
28
29#include <llvm/ADT/ArrayRef.h>
30#include <llvm/ADT/Twine.h>
31
32#include <optional>
33
34// TableGen'd implementation files
36
37// TableGen'd implementation files
38#define GET_OP_CLASSES
40
41using namespace mlir;
42
43namespace llzk::array {
44
45//===------------------------------------------------------------------===//
46// CreateArrayOp
47//===------------------------------------------------------------------===//
48
50 OpBuilder &odsBuilder, OperationState &odsState, ArrayType result, ValueRange elements
51) {
52 odsState.addTypes(result);
53 odsState.addOperands(elements);
54 // This builds CreateArrayOp from a list of elements. In that case, the dimensions of the array
55 // type cannot be defined via an affine map which means there are no affine map operands.
57 odsBuilder, odsState, llzk::checkedCast<int32_t>(elements.size())
58 );
59}
60
62 OpBuilder &odsBuilder, OperationState &odsState, ArrayType result,
63 ArrayRef<ValueRange> mapOperands, DenseI32ArrayAttr numDimsPerMap
64) {
65 odsState.addTypes(result);
67 odsBuilder, odsState, mapOperands, numDimsPerMap
68 );
69}
70
71LogicalResult CreateArrayOp::verifySymbolUses(SymbolTableCollection &tables) {
72 // Ensure any SymbolRef used in the type are valid
73 return verifyTypeResolution(tables, *this, llvm::cast<Type>(getType()));
74}
75
76void CreateArrayOp::getAsmResultNames(OpAsmSetValueNameFn setNameFn) {
77 setNameFn(getResult(), "array");
78}
79
80llvm::SmallVector<Type> CreateArrayOp::resultTypeToElementsTypes(Type resultType) {
81 // The ODS restricts $result with LLZK_ArrayType so this cast is safe.
82 ArrayType a = llvm::cast<ArrayType>(resultType);
83 return llvm::SmallVector<Type>(a.getNumElements(), a.getElementType());
84}
85
86ParseResult CreateArrayOp::parseInferredArrayType(
87 OpAsmParser & /*parser*/, llvm::SmallVector<Type, 1> &elementsTypes,
88 ArrayRef<OpAsmParser::UnresolvedOperand> elements, Type resultType
89) {
90 assert(elementsTypes.size() == 0); // it was not yet initialized
91 // If the '$elements' operand is not empty, then the expected type for the operand
92 // is computed to match the type of the '$result'. Otherwise, it remains empty.
93 if (elements.size() > 0) {
94 elementsTypes.append(resultTypeToElementsTypes(resultType));
95 }
96 return success();
97}
98
99void CreateArrayOp::printInferredArrayType(
100 OpAsmPrinter &printer, CreateArrayOp, TypeRange, OperandRange, Type
101) {
102 // nothing to print, it's derived and therefore not represented in the output
103}
104
105LogicalResult CreateArrayOp::verify() {
106 Type retTy = getResult().getType();
107 assert(llvm::isa<ArrayType>(retTy)); // per ODS spec of CreateArrayOp
108
109 // Collect the array dimensions that are defined via AffineMapAttr
110 SmallVector<AffineMapAttr> mapAttrs;
111 // Extend the lifetime of the temporary to suppress warnings.
112 ArrayType arrTy = llvm::cast<ArrayType>(retTy);
113 for (Attribute a : arrTy.getDimensionSizes()) {
114 if (AffineMapAttr m = dyn_cast<AffineMapAttr>(a)) {
115 mapAttrs.push_back(m);
116 }
117 }
119 getMapOperands(), getNumDimsPerMap(), mapAttrs, *this
120 );
121}
122
124SmallVector<DestructurableMemorySlot> CreateArrayOp::getDestructurableSlots() {
125 assert(getElements().empty() && "must run after initialization is split from allocation");
126 ArrayType arrType = getType();
127 if (!arrType.hasStaticShape() || arrType.getNumElements() == 1) {
128 return {};
129 }
130 if (auto destructured = arrType.getSubelementIndexMap()) {
131 return {DestructurableMemorySlot {{getResult(), arrType}, std::move(*destructured)}};
132 }
133 return {};
134}
135
137DenseMap<Attribute, MemorySlot> CreateArrayOp::destructure(
138 const DestructurableMemorySlot &slot, const SmallPtrSetImpl<Attribute> &usedIndices,
139 OpBuilder &builder, SmallVectorImpl<DestructurableAllocationOpInterface> &newAllocators
140) {
141 assert(slot.ptr == getResult());
142 assert(slot.elemType == getType());
143
144 builder.setInsertionPointAfter(*this);
145
146 DenseMap<Attribute, MemorySlot> slotMap; // result
147 for (Attribute index : usedIndices) {
148 // This is an ArrayAttr since indexing is multi-dimensional
149 ArrayAttr indexAsArray = llvm::dyn_cast<ArrayAttr>(index);
150 assert(indexAsArray && "expected ArrayAttr");
151
152 Type destructAs = getType().getTypeAtIndex(indexAsArray);
153 assert(destructAs == slot.subelementTypes.lookup(indexAsArray));
154
155 ArrayType destructAsArrayTy = llvm::dyn_cast<ArrayType>(destructAs);
156 assert(destructAsArrayTy && "expected ArrayType");
157
158 auto subCreate = builder.create<CreateArrayOp>(getLoc(), destructAsArrayTy);
159 newAllocators.push_back(subCreate);
160 slotMap.try_emplace<MemorySlot>(index, {subCreate.getResult(), destructAs});
161 }
162
163 return slotMap;
164}
165
167std::optional<DestructurableAllocationOpInterface> CreateArrayOp::handleDestructuringComplete(
168 const DestructurableMemorySlot &slot, OpBuilder & /*builder*/
169) {
170 assert(slot.ptr == getResult());
171 this->erase();
172 return std::nullopt;
173}
174
176SmallVector<MemorySlot> CreateArrayOp::getPromotableSlots() {
177 ArrayType arrType = getType();
178 if (!arrType.hasStaticShape()) {
179 return {};
180 }
181 // Can only support arrays containing a single element (the SROA pass can be run first to
182 // destructure all arrays into size-1 arrays).
183 if (arrType.getNumElements() != 1) {
184 return {};
185 }
186 return {MemorySlot {getResult(), arrType.getElementType()}};
187}
188
190Value CreateArrayOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) {
191 return builder.create<llzk::NonDetOp>(getLoc(), slot.elemType);
192}
193
195void CreateArrayOp::handleBlockArgument(const MemorySlot &, BlockArgument, OpBuilder &) {}
196
198std::optional<PromotableAllocationOpInterface> CreateArrayOp::handlePromotionComplete(
199 const MemorySlot & /*slot*/, Value defaultValue, OpBuilder & /*builder*/
200) {
201 if (defaultValue.use_empty()) {
202 defaultValue.getDefiningOp()->erase();
203 } else {
204 this->erase();
205 }
206 // Return `nullopt` because it produces only a single slot
207 return std::nullopt;
208}
209
210//===------------------------------------------------------------------===//
211// ArrayAccessOpInterface
212//===------------------------------------------------------------------===//
213
217 ArrayType arrTy = getArrRefType();
218 if (arrTy.hasStaticShape()) {
219 if (auto converted = ArrayIndexGen::from(arrTy).checkAndConvert(getIndices())) {
220 return ArrayAttr::get(getContext(), *converted);
221 }
222 }
223 return nullptr;
224}
225
228 const DestructurableMemorySlot &slot, SmallPtrSetImpl<Attribute> &usedIndices,
229 SmallVectorImpl<MemorySlot> & /*mustBeSafelyUsed*/, const DataLayout & /*dataLayout*/
230) {
231 if (slot.ptr != getArrRef()) {
232 return false;
233 }
234
235 ArrayAttr indexAsAttr = indexOperandsToAttributeArray();
236 if (!indexAsAttr) {
237 return false;
238 }
239
240 // Scalar read/write case has 0 dimensions in the read/write value.
241 if (!getValueOperandDims().empty()) {
242 return false;
243 }
244
245 // Just insert the index.
246 usedIndices.insert(indexAsAttr);
247 return true;
248}
249
252 const DestructurableMemorySlot &slot, DenseMap<Attribute, MemorySlot> &subslots,
253 OpBuilder &builder, const DataLayout & /*dataLayout*/
254) {
255 assert(slot.ptr == getArrRef());
256 assert(slot.elemType == getArrRefType());
257 // ASSERT: non-scalar read/write should have been desugared earlier
258 assert(getValueOperandDims().empty() && "only scalar read/write supported");
259
260 ArrayAttr indexAsAttr = indexOperandsToAttributeArray();
261 assert(indexAsAttr && "canRewire() should have returned false");
262 const MemorySlot &memorySlot = subslots.at(indexAsAttr);
263
264 // Temporarily set insertion point before the current op for what's built below
265 OpBuilder::InsertionGuard guard(builder);
266 builder.setInsertionPoint(this->getOperation());
267
268 // Write to the sub-slot created for the index of `this`, using index 0
269 getArrRefMutable().set(memorySlot.ptr);
270 getIndicesMutable().clear();
271 getIndicesMutable().assign(builder.create<arith::ConstantIndexOp>(getLoc(), 0));
272
273 return DeletionKind::Keep;
274}
275
276//===------------------------------------------------------------------===//
277// ReadArrayOp
278//===------------------------------------------------------------------===//
279
280namespace {
281
282LogicalResult
283ensureNumIndicesMatchDims(ArrayType ty, size_t numIndices, const OwningEmitErrorFn &errFn) {
284 ArrayRef<Attribute> dims = ty.getDimensionSizes();
285 // Ensure the number of provided indices matches the array dimensions
286 auto compare = numIndices <=> dims.size();
287 if (compare != 0) {
288 return errFn().append(
289 "has ", (compare < 0 ? "insufficient" : "too many"), " indexed dimensions: expected ",
290 dims.size(), " but found ", numIndices
291 );
292 }
293 return success();
294}
295
296} // namespace
297
298LogicalResult ReadArrayOp::verifySymbolUses(SymbolTableCollection &tables) {
299 // Ensure any SymbolRef used in the type are valid
300 return verifyTypeResolution(tables, *this, ArrayRef<Type> {getArrRef().getType(), getType()});
301}
302
304 MLIRContext * /*context*/, std::optional<Location> /*location*/, ReadArrayOpAdaptor adaptor,
305 llvm::SmallVectorImpl<Type> &inferredReturnTypes
306) {
307 inferredReturnTypes.resize(1);
308 Type lvalType = adaptor.getArrRef().getType();
309 assert(llvm::isa<ArrayType>(lvalType)); // per ODS spec of ReadArrayOp
310 inferredReturnTypes[0] = llvm::cast<ArrayType>(lvalType).getElementType();
311 return success();
312}
313
314bool ReadArrayOp::isCompatibleReturnTypes(TypeRange l, TypeRange r) {
315 return singletonTypeListsUnify(l, r);
316}
317
318LogicalResult ReadArrayOp::verify() {
319 // Ensure the number of indices used match the shape of the array exactly.
320 return ensureNumIndicesMatchDims(getArrRefType(), getIndices().size(), getEmitOpErrFn(this));
321}
322
325 const MemorySlot &slot, const SmallPtrSetImpl<OpOperand *> &blockingUses,
326 SmallVectorImpl<OpOperand *> & /*newBlockingUses*/, const DataLayout & /*datalayout*/
327) {
328 if (blockingUses.size() != 1) {
329 return false;
330 }
331 Value blockingUse = (*blockingUses.begin())->get();
332 return blockingUse == slot.ptr && getArrRef() == slot.ptr &&
333 getResult().getType() == slot.elemType;
334}
335
338 const MemorySlot & /*slot*/, const SmallPtrSetImpl<OpOperand *> & /*blockingUses*/,
339 OpBuilder & /*builder*/, Value reachingDefinition, const DataLayout & /*dataLayout*/
340) {
341 // `canUsesBeRemoved` checked this blocking use must be the loaded `slot.ptr`
342 getResult().replaceAllUsesWith(reachingDefinition);
343 return DeletionKind::Delete;
344}
345
346//===------------------------------------------------------------------===//
347// WriteArrayOp
348//===------------------------------------------------------------------===//
349
350LogicalResult WriteArrayOp::verifySymbolUses(SymbolTableCollection &tables) {
351 // Ensure any SymbolRef used in the type are valid
353 tables, *this, ArrayRef<Type> {getArrRefType(), getRvalue().getType()}
354 );
355}
356
357LogicalResult WriteArrayOp::verify() {
358 // Ensure the number of indices used match the shape of the array exactly.
359 return ensureNumIndicesMatchDims(getArrRefType(), getIndices().size(), getEmitOpErrFn(this));
360}
361
364 const MemorySlot &slot, const SmallPtrSetImpl<OpOperand *> &blockingUses,
365 SmallVectorImpl<OpOperand *> & /*newBlockingUses*/, const DataLayout & /*datalayout*/
366) {
367 if (blockingUses.size() != 1) {
368 return false;
369 }
370 Value blockingUse = (*blockingUses.begin())->get();
371 return blockingUse == slot.ptr && getArrRef() == slot.ptr && getRvalue() != slot.ptr &&
372 getRvalue().getType() == slot.elemType;
373}
374
377 const MemorySlot &, const SmallPtrSetImpl<OpOperand *> &, OpBuilder &, Value, const DataLayout &
378) {
379 return DeletionKind::Delete;
380}
381
382//===------------------------------------------------------------------===//
383// ExtractArrayOp
384//===------------------------------------------------------------------===//
385
386LogicalResult ExtractArrayOp::verifySymbolUses(SymbolTableCollection &tables) {
387 // Ensure any SymbolRef used in the type are valid
388 return verifyTypeResolution(tables, *this, getArrRefType());
389}
390
392 MLIRContext * /*context*/, std::optional<Location> location, ExtractArrayOpAdaptor adaptor,
393 llvm::SmallVectorImpl<Type> &inferredReturnTypes
394) {
395 size_t numToSkip = adaptor.getIndices().size();
396 Type arrRefType = adaptor.getArrRef().getType();
397 assert(llvm::isa<ArrayType>(arrRefType)); // per ODS spec of ExtractArrayOp
398 ArrayType arrRefArrType = llvm::cast<ArrayType>(arrRefType);
399 ArrayRef<Attribute> arrRefDimSizes = arrRefArrType.getDimensionSizes();
400
401 // Check for invalid cases
402 auto compare = numToSkip <=> arrRefDimSizes.size();
403 if (compare == 0) {
404 return mlir::emitOptionalError(
405 location, '\'', ExtractArrayOp::getOperationName(),
406 "' op cannot select all dimensions of an array. Use '", ReadArrayOp::getOperationName(),
407 "' instead."
408 );
409 } else if (compare > 0) {
410 return mlir::emitOptionalError(
411 location, '\'', ExtractArrayOp::getOperationName(),
412 "' op cannot select more dimensions than exist in the source array"
413 );
414 }
415
416 // Generate and store reduced array type
417 inferredReturnTypes.resize(1);
418 inferredReturnTypes[0] =
419 ArrayType::get(arrRefArrType.getElementType(), arrRefDimSizes.drop_front(numToSkip));
420 return success();
421}
422
423bool ExtractArrayOp::isCompatibleReturnTypes(TypeRange l, TypeRange r) {
424 return singletonTypeListsUnify(l, r);
425}
426
427//===------------------------------------------------------------------===//
428// InsertArrayOp
429//===------------------------------------------------------------------===//
430
431LogicalResult InsertArrayOp::verifySymbolUses(SymbolTableCollection &tables) {
432 // Ensure any SymbolRef used in the types are valid
434 tables, *this, ArrayRef<Type> {getArrRefType(), getRvalue().getType()}
435 );
436}
437
438LogicalResult InsertArrayOp::verify() {
439 ArrayType baseArrRefArrType = getArrRefType();
440 Type rValueType = getRvalue().getType();
441 assert(llvm::isa<ArrayType>(rValueType)); // per ODS spec of InsertArrayOp
442 ArrayType rValueArrType = llvm::cast<ArrayType>(rValueType);
443
444 // size of lhs dimensions == numIndices + size of rhs dimensions
445 size_t lhsDims = baseArrRefArrType.getDimensionSizes().size();
446 size_t numIndices = getIndices().size();
447 size_t rhsDims = rValueArrType.getDimensionSizes().size();
448
449 // Ensure the number of indices specified does not exceed base dimension count.
450 if (numIndices > lhsDims) {
451 return emitOpError("cannot select more dimensions than exist in the source array");
452 }
453
454 // Ensure the rValue dimension count equals the base reduced dimension count
455 auto compare = (numIndices + rhsDims) <=> lhsDims;
456 if (compare != 0) {
457 return emitOpError().append(
458 "has ", (compare < 0 ? "insufficient" : "too many"), " indexed dimensions: expected ",
459 (lhsDims - rhsDims), " but found ", numIndices
460 );
461 }
462
463 // Having verified the indices are of appropriate size, we verify the subarray type.
464 // This will verify the dimensions of the subarray, which is why we only check the
465 // size of the indices above.
466 return verifySubArrayType(getEmitOpErrFn(this), baseArrRefArrType, rValueArrType);
467}
468
469//===------------------------------------------------------------------===//
470// ArrayLengthOp
471//===------------------------------------------------------------------===//
472
473LogicalResult ArrayLengthOp::verifySymbolUses(SymbolTableCollection &tables) {
474 // Ensure any SymbolRef used in the type are valid
475 if (failed(verifyTypeResolution(tables, *this, getArrRefType()))) {
476 return failure();
477 }
478
479 auto dimValue = getDim();
480 llvm::APInt dim;
481 if (!matchPattern(dimValue, m_ConstantInt(&dim))) {
482 return success();
483 }
484
485 std::optional<int64_t> idxOpt = dim.trySExtValue();
486 if (!idxOpt || *idxOpt < 0) {
487 auto diag = emitOpError("dimension must be a non-negative 64-bit integer");
488 if (!llvm::isa<UnknownLoc>(dimValue.getLoc())) {
489 diag.attachNote(dimValue.getLoc()).append("dimension defined here");
490 }
491 return diag;
492 }
493 size_t idx = checkedCast<size_t>(*idxOpt);
494 size_t rank = getArrRefType().getDimensionSizes().size();
495 if (idx >= rank) {
496 InFlightDiagnostic diag = emitOpError().append(
497 "dimension index ", idx, " is not valid for array with ", rank, " dimensions"
498 );
499 if (!llvm::isa<UnknownLoc>(getArrRef().getLoc())) {
500 diag.attachNote(getArrRef().getLoc()).append("array defined here");
501 }
502 if (!llvm::isa<UnknownLoc>(dimValue.getLoc())) {
503 diag.attachNote(dimValue.getLoc()).append("dimension defined here");
504 }
505 return diag;
506 }
507 return success();
508}
509
510} // namespace llzk::array
::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > &subslots, ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout)
Required by companion interface DestructurableAccessorOpInterface / SROA pass.
Definition Ops.cpp:251
::mlir::Operation::operand_range getIndices()
Gets the operand range containing the index for each dimension.
::mlir::OpOperand & getArrRefMutable()
Gets the mutable operand slot holding the SSA Value for the referenced array.
inline ::mlir::ArrayRef<::mlir::Attribute > getValueOperandDims()
Compute the dimensions of the read/write value.
::mlir::ArrayAttr indexOperandsToAttributeArray()
Returns the multi-dimensional indices of the array access as an Attribute array or a null pointer if ...
Definition Ops.cpp:216
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Gets the SSA Value for the referenced array.
bool canRewire(const ::mlir::DestructurableMemorySlot &slot, ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::SmallVectorImpl<::mlir::MemorySlot > &mustBeSafelyUsed, const ::mlir::DataLayout &dataLayout)
Required by companion interface DestructurableAccessorOpInterface / SROA pass.
Definition Ops.cpp:227
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced array.
::mlir::MutableOperandRange getIndicesMutable()
Gets the mutable operand range containing the index for each dimension.
static ArrayIndexGen from(ArrayType)
Construct new ArrayIndexGen. Will assert if hasStaticShape() is false.
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced base array.
Definition Ops.h.inc:192
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:146
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:473
::mlir::TypedValue<::mlir::IndexType > getDim()
Definition Ops.h.inc:150
::mlir::Type getElementType() const
::std::optional<::llvm::DenseMap<::mlir::Attribute, ::mlir::Type > > getSubelementIndexMap() const
Required by DestructurableTypeInterface / SROA pass.
Definition Types.cpp:120
static ArrayType get(::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes)
Definition Types.cpp.inc:83
::llvm::ArrayRef<::mlir::Attribute > getDimensionSizes() const
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::array::ArrayType result, ::mlir::ValueRange elements={})
::mlir::TypedValue<::llzk::array::ArrayType > getResult()
Definition Ops.h.inc:408
::llvm::SmallVector<::mlir::DestructurableMemorySlot > getDestructurableSlots()
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp:124
::std::optional<::mlir::PromotableAllocationOpInterface > handlePromotionComplete(const ::mlir::MemorySlot &slot, ::mlir::Value defaultValue, ::mlir::OpBuilder &builder)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp:198
::std::optional<::mlir::DestructurableAllocationOpInterface > handleDestructuringComplete(const ::mlir::DestructurableMemorySlot &slot, ::mlir::OpBuilder &builder)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp:167
::llvm::LogicalResult verify()
Definition Ops.cpp:105
::mlir::Value getDefaultValue(const ::mlir::MemorySlot &slot, ::mlir::OpBuilder &builder)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp:190
::llvm::SmallVector<::mlir::MemorySlot > getPromotableSlots()
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp:176
::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot > destructure(const ::mlir::DestructurableMemorySlot &slot, const ::llvm::SmallPtrSetImpl<::mlir::Attribute > &usedIndices, ::mlir::OpBuilder &builder, ::mlir::SmallVectorImpl<::mlir::DestructurableAllocationOpInterface > &newAllocators)
Required by DestructurableAllocationOpInterface / SROA pass.
Definition Ops.cpp:137
::llvm::ArrayRef< int32_t > getNumDimsPerMap()
Definition Ops.cpp.inc:541
void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn)
Definition Ops.cpp:76
void handleBlockArgument(const ::mlir::MemorySlot &slot, ::mlir::BlockArgument argument, ::mlir::OpBuilder &builder)
Required by PromotableAllocationOpInterface / mem2reg pass.
Definition Ops.cpp:195
::mlir::OperandRangeRange getMapOperands()
Definition Ops.h.inc:392
::mlir::Operation::operand_range getElements()
Definition Ops.h.inc:388
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:71
static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r)
Definition Ops.cpp:423
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:386
::llvm::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)
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced base array.
Definition Ops.h.inc:640
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:578
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced base array.
Definition Ops.h.inc:794
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:753
::llvm::LogicalResult verify()
Definition Ops.cpp:438
::mlir::TypedValue<::llzk::array::ArrayType > getRvalue()
Definition Ops.h.inc:757
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:431
::mlir::DeletionKind removeBlockingUses(const ::mlir::MemorySlot &slot, const ::llvm::SmallPtrSetImpl< mlir::OpOperand * > &blockingUses, ::mlir::OpBuilder &builder, ::mlir::Value reachingDefinition, const ::mlir::DataLayout &dataLayout)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp:337
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced base array.
Definition Ops.h.inc:961
::mlir::TypedValue<::mlir::Type > getResult()
Definition Ops.h.inc:923
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:899
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:903
::llvm::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)
::llvm::LogicalResult verify()
Definition Ops.cpp:318
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:298
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:888
static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r)
Definition Ops.cpp:314
bool canUsesBeRemoved(const ::mlir::MemorySlot &slot, const ::llvm::SmallPtrSetImpl<::mlir::OpOperand * > &blockingUses, ::llvm::SmallVectorImpl<::mlir::OpOperand * > &newBlockingUses, const ::mlir::DataLayout &datalayout)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp:324
::llvm::LogicalResult verify()
Definition Ops.cpp:357
::mlir::Operation::operand_range getIndices()
Definition Ops.h.inc:1074
inline ::llzk::array::ArrayType getArrRefType()
Gets the type of the referenced base array.
Definition Ops.h.inc:1125
bool canUsesBeRemoved(const ::mlir::MemorySlot &slot, const ::llvm::SmallPtrSetImpl<::mlir::OpOperand * > &blockingUses, ::llvm::SmallVectorImpl<::mlir::OpOperand * > &newBlockingUses, const ::mlir::DataLayout &datalayout)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp:363
::mlir::DeletionKind removeBlockingUses(const ::mlir::MemorySlot &slot, const ::llvm::SmallPtrSetImpl< mlir::OpOperand * > &blockingUses, ::mlir::OpBuilder &builder, ::mlir::Value reachingDefinition, const ::mlir::DataLayout &dataLayout)
Required by PromotableMemOpInterface / mem2reg pass.
Definition Ops.cpp:376
::mlir::TypedValue<::llzk::array::ArrayType > getArrRef()
Definition Ops.h.inc:1070
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
Definition Ops.cpp:350
::mlir::TypedValue<::mlir::Type > getRvalue()
Definition Ops.h.inc:1078
OpClass::Properties & buildInstantiationAttrs(mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState, mlir::ArrayRef< mlir::ValueRange > mapOperands, mlir::DenseI32ArrayAttr numDimsPerMap, int32_t firstSegmentSize=0)
Utility for build() functions that initializes the operandSegmentSizes, mapOpGroupSizes,...
LogicalResult verifyAffineMapInstantiations(OperandRangeRange mapOps, ArrayRef< int32_t > numDimsPerMap, ArrayRef< AffineMapAttr > mapAttrs, Operation *origin)
OpClass::Properties & buildInstantiationAttrsEmpty(mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState, int32_t firstSegmentSize=0)
Utility for build() functions that initializes the operandSegmentSizes, mapOpGroupSizes,...
LogicalResult verifySubArrayType(EmitErrorFn emitError, ArrayType arrayType, ArrayType subArrayType)
Determine if the subArrayType is a valid subarray of arrayType.
bool singletonTypeListsUnify(Iter1 lhs, Iter2 rhs, mlir::ArrayRef< llvm::StringRef > rhsReversePrefix={}, UnificationMap *unifications=nullptr)
Definition TypeHelper.h:251
constexpr T checkedCast(U u) noexcept
Definition Compare.h:81
LogicalResult verifyTypeResolution(SymbolTableCollection &tables, Operation *origin, Type ty)
OwningEmitErrorFn getEmitOpErrFn(mlir::Operation *op)
std::function< InFlightDiagnosticWrapper()> OwningEmitErrorFn
This type is required in cases like the functions below to take ownership of the lambda so it is not ...