18#include <mlir/IR/OpImplementation.h>
19#include <mlir/IR/Operation.h>
20#include <mlir/IR/SymbolTable.h>
21#include <mlir/Support/LogicalResult.h>
23#include <llvm/ADT/SmallString.h>
24#include <llvm/ADT/StringRef.h>
29template <
typename TypeClass>
33 :
public mlir::OpTrait::TraitBase<TypeClass, LLZKSymbolTableImplTrait> {
39 while ((op = op->getParentWithTrait<mlir::OpTrait::SymbolTable>())) {
40 if (mlir::failed(mlir::detail::verifySymbolTable(op))) {
41 return mlir::failure();
44 return mlir::success();
52 return OpClass::getOperationName();
58 if (OpClass self = llvm::dyn_cast<OpClass>(op)) {
61 if (OpClass parent = op->getParentOfType<OpClass>()) {
71 if (OpClass p = op->getParentOfType<OpClass>()) {
81 template <
typename TypeClass>
class Impl :
public mlir::OpTrait::TraitBase<TypeClass, Impl> {
82 inline static mlir::LogicalResult verifyHelper(mlir::Operation *op, int32_t segmentSize) {
83 TypeClass c = llvm::cast<TypeClass>(op);
85 op, segmentSize, c.getMapOpGroupSizesAttr(), c.getMapOperands(), c.getNumDimsPerMapAttr()
91 if (TypeClass::template hasTrait<mlir::OpTrait::AttrSizedOperandSegments>()) {
94 OperandSegmentIndex >= 0,
95 "When the `AttrSizedOperandSegments` trait is present, the index of `$mapOperands` "
96 "within the `operandSegmentSizes` attribute must be specified."
98 mlir::DenseI32ArrayAttr segmentSizes = op->getAttrOfType<mlir::DenseI32ArrayAttr>(
99 mlir::OpTrait::AttrSizedOperandSegments<TypeClass>::getOperandSegmentSizeAttr()
102 OperandSegmentIndex < segmentSizes.size() &&
103 "Parameter of `VerifySizesForMultiAffineOps` exceeds the number of ODS-declared "
106 return verifyHelper(op, segmentSizes[OperandSegmentIndex]);
110 return verifyHelper(op, -1);
118 mlir::OpAsmParser &parser,
119 mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand, N> &mapOperands,
120 mlir::IntegerAttr &numDims
126 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands,
127 mlir::IntegerAttr numDims
133 mlir::OpAsmParser &parser,
134 mlir::SmallVector<mlir::SmallVector<mlir::OpAsmParser::UnresolvedOperand>> &multiMapOperands,
135 mlir::DenseI32ArrayAttr &numDimsPerMap
141 mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRangeRange multiMapOperands,
142 mlir::DenseI32ArrayAttr numDimsPerMap
148 mlir::OpAsmParser &parser, mlir::NamedAttrList &extraAttrs, mlir::OperationState &state
153template <
typename ConcreteOp>
155 mlir::OpAsmPrinter &printer, ConcreteOp op, mlir::DictionaryAttr extraAttrs,
156 typename mlir::PropertiesSelector<ConcreteOp>::type state
163 if (mlir::failed(parseResult)) {
164 return parser.emitError(parser.getCurrentLocation(),
"failed to parse template parameters");
166 auto emitError = [&parser] {
169 mlir::FailureOr<mlir::SmallVector<mlir::Attribute>> res =
171 if (mlir::failed(res)) {
172 return mlir::failure();
174 value = parser.getBuilder().getArrayAttr(*res);
175 return mlir::success();
Wrapper around InFlightDiagnostic that can either be a regular InFlightDiagnostic or a special versio...
See LLZKSymbolTable ODS documentation for details.
static mlir::LogicalResult verifyRegionTrait(mlir::Operation *op)
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)
ParseResult parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &mapOperands, IntegerAttr &numDims)
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)
void printTemplateParams(mlir::AsmPrinter &printer, mlir::ArrayAttr value)
void printDimAndSymbolList(mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::OperandRange mapOperands, mlir::IntegerAttr numDims)
void printAttrs(AsmPrinter &printer, ArrayRef< Attribute > attrs, const StringRef &separator)
FailureOr< SmallVector< Attribute > > forceIntAttrTypes(ArrayRef< Attribute > attrList, EmitErrorFn emitError)
OpClass getParentOfType(mlir::Operation *op)
Return the closest surrounding parent operation that is of type 'OpClass'.
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::ParseResult parseTemplateParams(mlir::AsmParser &parser, mlir::ArrayAttr &value)
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)