14#include <mlir/IR/Builders.h>
15#include <mlir/IR/OpImplementation.h>
16#include <mlir/IR/Operation.h>
17#include <mlir/IR/ValueRange.h>
19#include <llvm/ADT/SmallVector.h>
26 mlir::OpAsmParser &parser,
27 mlir::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &mapOperands,
28 mlir::IntegerAttr &numDims
33 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands,
34 mlir::IntegerAttr numDims
39 mlir::OpAsmParser &parser,
40 mlir::SmallVectorImpl<mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand>>
42 mlir::DenseI32ArrayAttr &numDimsPerMap
47 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands,
48 mlir::DenseI32ArrayAttr numDimsPerMap
55 mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state
58template <
typename ConcreteOp>
60 mlir::OpAsmPrinter &printer, ConcreteOp , mlir::DictionaryAttr extraAttrs,
61 typename ConcreteOp::Properties
63 printer.printOptionalAttrDict(extraAttrs.getValue(), ConcreteOp::getAttributeNames());
69 mlir::Operation *op, int32_t segmentSize, mlir::ArrayRef<int32_t> mapOpGroupSizes,
70 mlir::OperandRangeRange mapOperands, mlir::ArrayRef<int32_t> numDimsPerMap
76 mlir::OperandRangeRange mapOps, mlir::ArrayRef<int32_t> numDimsPerMap,
77 mlir::ArrayRef<mlir::AffineMapAttr> mapAttrs, mlir::Operation *origin
85template <
typename OpClass>
87 mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState,
88 mlir::ArrayRef<mlir::ValueRange> mapOperands, mlir::DenseI32ArrayAttr numDimsPerMap,
89 int32_t firstSegmentSize = 0
91 int32_t mapOpsSegmentSize = 0;
92 mlir::SmallVector<int32_t> rangeSegments;
93 for (mlir::ValueRange r : mapOperands) {
94 odsState.addOperands(r);
96 rangeSegments.push_back(s);
97 mapOpsSegmentSize += s;
99 typename OpClass::Properties &props = odsState.getOrAddProperties<
typename OpClass::Properties>();
100 props.setMapOpGroupSizes(odsBuilder.getDenseI32ArrayAttr(rangeSegments));
101 props.setOperandSegmentSizes({firstSegmentSize, mapOpsSegmentSize});
103 props.setNumDimsPerMap(numDimsPerMap);
111template <
typename OpClass>
113 mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState,
114 mlir::ArrayRef<mlir::ValueRange> mapOperands, mlir::DenseI32ArrayAttr numDimsPerMap
116 mlir::SmallVector<int32_t> rangeSegments;
117 for (mlir::ValueRange r : mapOperands) {
118 odsState.addOperands(r);
120 rangeSegments.push_back(s);
122 typename OpClass::Properties &props = odsState.getOrAddProperties<
typename OpClass::Properties>();
123 props.setMapOpGroupSizes(odsBuilder.getDenseI32ArrayAttr(rangeSegments));
125 props.setNumDimsPerMap(numDimsPerMap);
132template <
typename OpClass>
134 mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState, int32_t firstSegmentSize = 0
136 typename OpClass::Properties &props = odsState.getOrAddProperties<
typename OpClass::Properties>();
138 props.setOperandSegmentSizes({firstSegmentSize, 0});
140 props.setMapOpGroupSizes(odsBuilder.getDenseI32ArrayAttr({}));
141 props.setNumDimsPerMap(odsBuilder.getDenseI32ArrayAttr({}));
148template <
typename OpClass>
150 mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState
152 typename OpClass::Properties &props = odsState.getOrAddProperties<
typename OpClass::Properties>();
154 props.setMapOpGroupSizes(odsBuilder.getDenseI32ArrayAttr({}));
155 props.setNumDimsPerMap(odsBuilder.getDenseI32ArrayAttr({}));
Group together all implementation related to AffineMap type parameters.
OpClass::Properties & buildInstantiationAttrsEmptyNoSegments(mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState)
Utility for build() functions that initializes the mapOpGroupSizes, and numDimsPerMap attributes for ...
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,...
void buildInstantiationAttrsNoSegments(mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState, mlir::ArrayRef< mlir::ValueRange > mapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
Utility for build() functions that initializes the mapOpGroupSizes, and numDimsPerMap attributes for ...
LogicalResult verifySizesForMultiAffineOps(Operation *op, int32_t segmentSize, ArrayRef< int32_t > mapOpGroupSizes, OperandRangeRange mapOperands, ArrayRef< int32_t > numDimsPerMap)
ParseResult parseMultiDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl< SmallVector< OpAsmParser::UnresolvedOperand > > &multiMapOperands, DenseI32ArrayAttr &numDimsPerMap)
LogicalResult verifyAffineMapInstantiations(OperandRangeRange mapOps, ArrayRef< int32_t > numDimsPerMap, ArrayRef< AffineMapAttr > mapAttrs, Operation *origin)
ParseResult parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &mapOperands, IntegerAttr &numDims)
OpClass::Properties & buildInstantiationAttrsEmpty(mlir::OpBuilder &odsBuilder, mlir::OperationState &odsState, int32_t firstSegmentSize=0)
Utility for build() functions that initializes the operandSegmentSizes, mapOpGroupSizes,...
ParseResult parseAttrDictWithWarnings(OpAsmParser &parser, NamedAttrList &extraAttrs, OperationState &state)
void printMultiDimAndSymbolList(OpAsmPrinter &printer, Operation *, OperandRangeRange multiMapOperands, DenseI32ArrayAttr numDimsPerMap)
void printDimAndSymbolList(OpAsmPrinter &printer, Operation *, OperandRange mapOperands, IntegerAttr numDims)
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp, mlir::DictionaryAttr extraAttrs, typename ConcreteOp::Properties)
constexpr T checkedCast(U u) noexcept