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"
24 class InFlightDiagnostic;
25 class DynamicAttrDefinition;
26 class DynamicTypeDefinition;
92 : expectedAttribute(expectedAttribute) {}
109 : baseTypeID(baseTypeID), baseName(baseName) {}
130 : baseTypeID(baseTypeID), baseName(baseName) {}
153 : attrDef(attrDef), constraints(std::move(constraints)) {}
172 : typeDef(typeDef), constraints(std::move(constraints)) {}
189 : constraints(std::move(constraints)) {}
205 : constraints(std::move(constraints)) {}
236 std::optional<size_t> blockCount)
237 : argumentConstraints(std::move(argumentConstraints)),
238 blockCount(blockCount) {}
248 std::optional<SmallVector<unsigned>> argumentConstraints;
249 std::optional<size_t> blockCount;
254 OperationOp operation,
255 const DenseMap<irdl::TypeOp, std::unique_ptr<DynamicTypeDefinition>>
257 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.
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...