13 #ifndef MLIR_DIALECT_IRDL_IRDLVERIFIERS_H
14 #define MLIR_DIALECT_IRDL_IRDLVERIFIERS_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/SmallVector.h"
25 class InFlightDiagnostic;
26 class DynamicAttrDefinition;
27 class DynamicTypeDefinition;
93 : expectedAttribute(expectedAttribute) {}
110 : baseTypeID(baseTypeID), baseName(baseName) {}
131 : baseTypeID(baseTypeID), baseName(baseName) {}
154 : attrDef(attrDef), constraints(std::move(constraints)) {}
173 : typeDef(typeDef), constraints(std::move(constraints)) {}
190 : constraints(std::move(constraints)) {}
206 : constraints(std::move(constraints)) {}
237 std::optional<size_t> blockCount)
238 : argumentConstraints(std::move(argumentConstraints)),
239 blockCount(blockCount) {}
249 std::optional<SmallVector<unsigned>> argumentConstraints;
250 std::optional<size_t> blockCount;
255 OperationOp operation,
256 const DenseMap<irdl::TypeOp, std::unique_ptr<DynamicTypeDefinition>>
258 const DenseMap<irdl::AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
Attributes are known-constant values of operations.
The definition of a dynamic attribute.
The definition of a dynamic type.
This class represents a diagnostic that is inflight and set to be reported.
Operation is the basic unit of execution within MLIR.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class provides an efficient unique identifier for a specific C++ type.
A constraint checking that all of the given constraints are satisfied.
virtual ~AllOfConstraint()=default
AllOfConstraint(SmallVector< unsigned > constraints)
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
A constraint that is always satisfied.
virtual ~AnyAttributeConstraint()=default
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
A constraint checking that one of the given constraints is satisfied.
AnyOfConstraint(SmallVector< unsigned > constraints)
virtual ~AnyOfConstraint()=default
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
A constraint that checks that an attribute is of a given attribute base (e.g.
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
virtual ~BaseAttrConstraint()=default
BaseAttrConstraint(TypeID baseTypeID, StringRef baseName)
A constraint that checks that a type is of a given type base (e.g.
virtual ~BaseTypeConstraint()=default
BaseTypeConstraint(TypeID baseTypeID, StringRef baseName)
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
Provides context to the verification of constraints.
ConstraintVerifier(ArrayRef< std::unique_ptr< Constraint >> constraints)
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, unsigned variable)
Check that a constraint is satisfied by an attribute.
Once turned into IRDL verifiers, all constraints are attribute constraints.
virtual ~Constraint()=default
virtual LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const =0
Check that an attribute is satisfying the constraint.
A constraint that checks that an attribute is of a specific dynamic attribute definition,...
virtual ~DynParametricAttrConstraint()=default
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
DynParametricAttrConstraint(DynamicAttrDefinition *attrDef, SmallVector< unsigned > constraints)
A constraint that checks that a type is of a specific dynamic type definition, and that all of its pa...
virtual ~DynParametricTypeConstraint()=default
DynParametricTypeConstraint(DynamicTypeDefinition *typeDef, SmallVector< unsigned > constraints)
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
A constraint that checks that an attribute is equal to a given attribute.
LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Attribute attr, ConstraintVerifier &context) const override
Check that an attribute is satisfying the constraint.
IsConstraint(Attribute expectedAttribute)
virtual ~IsConstraint()=default
llvm::unique_function< LogicalResult(Operation *) const > createVerifier(OperationOp operation, const DenseMap< irdl::TypeOp, std::unique_ptr< DynamicTypeDefinition >> &typeDefs, const DenseMap< irdl::AttributeOp, std::unique_ptr< DynamicAttrDefinition >> &attrDefs)
Generate an op verifier function from the given IRDL operation definition.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
This class represents an efficient way to signal success or failure.
A constraint checking that a region satisfies irdl.region requirements.
LogicalResult verify(mlir::Region ®ion, ConstraintVerifier &constraintContext)
Check that the region satisfies the constraint.
RegionConstraint(std::optional< SmallVector< unsigned >> argumentConstraints, std::optional< size_t > blockCount)
The constructor accepts constrained entities from the irdl.region operation, such as slots of constra...