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();
32template <
typename OpClass>
inline mlir::FailureOr<OpClass>
getParentOfType(mlir::Operation *op) {
33 if (OpClass p = op->getParentOfType<OpClass>()) {
36 return mlir::failure();
43 template <
typename TypeClass>
class Impl :
public mlir::OpTrait::TraitBase<TypeClass, Impl> {
44 inline static mlir::LogicalResult verifyHelper(mlir::Operation *op, int32_t segmentSize) {
45 TypeClass c = llvm::cast<TypeClass>(op);
47 op, segmentSize, c.getMapOpGroupSizesAttr(), c.getMapOperands(), c.getNumDimsPerMapAttr()
53 if (TypeClass::template hasTrait<mlir::OpTrait::AttrSizedOperandSegments>()) {
56 OperandSegmentIndex >= 0,
57 "When the `AttrSizedOperandSegments` trait is present, the index of `$mapOperands` "
58 "within the `operandSegmentSizes` attribute must be specified."
60 mlir::DenseI32ArrayAttr segmentSizes = op->getAttrOfType<mlir::DenseI32ArrayAttr>(
61 mlir::OpTrait::AttrSizedOperandSegments<TypeClass>::getOperandSegmentSizeAttr()
64 OperandSegmentIndex < segmentSizes.size() &&
65 "Parameter of `VerifySizesForMultiAffineOps` exceeds the number of ODS-declared "
68 return verifyHelper(op, segmentSizes[OperandSegmentIndex]);
72 return verifyHelper(op, -1);
80 mlir::OpAsmParser &parser,
81 mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand, N> &mapOperands,
82 mlir::IntegerAttr &numDims
88 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands,
89 mlir::IntegerAttr numDims
95 mlir::OpAsmParser &parser,
96 mlir::SmallVector<mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &multiMapOperands,
97 mlir::DenseI32ArrayAttr &numDimsPerMap
103 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands,
104 mlir::DenseI32ArrayAttr numDimsPerMap
110 mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state
115template <
typename ConcreteOp>
117 mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs,
118 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.
mlir::ParseResult parseDimAndSymbolList(mlir::OpAsmParser &parser, mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand, N > &mapOperands, mlir::IntegerAttr &numDims)