15#include <mlir/IR/OpImplementation.h>
16#include <mlir/IR/Operation.h>
17#include <mlir/Support/LogicalResult.h>
19#include <llvm/ADT/SmallString.h>
20#include <llvm/ADT/StringRef.h>
28 return OpClass::getOperationName();
34 if (OpClass self = llvm::dyn_cast<OpClass>(op)) {
37 if (OpClass parent = op->getParentOfType<OpClass>()) {
45template <
typename OpClass>
inline mlir::FailureOr<OpClass>
getParentOfType(mlir::Operation *op) {
46 if (OpClass p = op->getParentOfType<OpClass>()) {
49 return mlir::failure();
56 template <
typename TypeClass>
class Impl :
public mlir::OpTrait::TraitBase<TypeClass, Impl> {
57 inline static mlir::LogicalResult verifyHelper(mlir::Operation *op, int32_t segmentSize) {
58 TypeClass c = llvm::cast<TypeClass>(op);
60 op, segmentSize, c.getMapOpGroupSizesAttr(), c.getMapOperands(), c.getNumDimsPerMapAttr()
66 if (TypeClass::template hasTrait<mlir::OpTrait::AttrSizedOperandSegments>()) {
69 OperandSegmentIndex >= 0,
70 "When the `AttrSizedOperandSegments` trait is present, the index of `$mapOperands` "
71 "within the `operandSegmentSizes` attribute must be specified."
73 mlir::DenseI32ArrayAttr segmentSizes = op->getAttrOfType<mlir::DenseI32ArrayAttr>(
74 mlir::OpTrait::AttrSizedOperandSegments<TypeClass>::getOperandSegmentSizeAttr()
77 OperandSegmentIndex < segmentSizes.size() &&
78 "Parameter of `VerifySizesForMultiAffineOps` exceeds the number of ODS-declared "
81 return verifyHelper(op, segmentSizes[OperandSegmentIndex]);
85 return verifyHelper(op, -1);
93 mlir::OpAsmParser &parser,
94 mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand, N> &mapOperands,
95 mlir::IntegerAttr &numDims
101 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands,
102 mlir::IntegerAttr numDims
108 mlir::OpAsmParser &parser,
109 mlir::SmallVector<mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &multiMapOperands,
110 mlir::DenseI32ArrayAttr &numDimsPerMap
116 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands,
117 mlir::DenseI32ArrayAttr numDimsPerMap
123 mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state
128template <
typename ConcreteOp>
130 mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs,
131 typename mlir::PropertiesSelector<ConcreteOp>::type state
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename ConcreteOp::Properties state)
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)
void printDimAndSymbolList(OpAsmPrinter &printer, Operation *op, OperandRange mapOperands, IntegerAttr numDims)
ParseResult parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &mapOperands, IntegerAttr &numDims)
ParseResult parseAttrDictWithWarnings(OpAsmParser &parser, NamedAttrList &extraAttrs, OperationState &state)
void printMultiDimAndSymbolList(OpAsmPrinter &printer, Operation *op, OperandRangeRange multiMapOperands, DenseI32ArrayAttr numDimsPerMap)
void printDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands, mlir::IntegerAttr numDims)
mlir::ParseResult parseAttrDictWithWarnings(mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state)
void printMultiDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands, mlir::DenseI32ArrayAttr numDimsPerMap)
void printAttrDictWithWarnings(mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs, typename mlir::PropertiesSelector< ConcreteOp >::type state)
mlir::FailureOr< OpClass > getParentOfType(mlir::Operation *op)
Return the closest surrounding parent operation that is of type 'OpClass'.
mlir::ParseResult parseMultiDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &multiMapOperands, mlir::DenseI32ArrayAttr &numDimsPerMap)
llvm::StringLiteral getOperationName()
Get the operation name, like "constrain.eq" for the given OpClass.
OpClass getSelfOrParentOfType(mlir::Operation *op)
Return the closest operation that is of type 'OpClass', either the op itself or an ancestor.
mlir::ParseResult parseDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand, N > &mapOperands, mlir::IntegerAttr &numDims)