22 for (
Value arg : args) {
23 for (
auto [i, value] :
enumerate(valueToConstr)) {
25 constraints.push_back(i);
33 std::unique_ptr<Constraint> IsOp::getVerifier(
35 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
36 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
38 return std::make_unique<IsConstraint>(getExpectedAttr());
41 std::unique_ptr<Constraint> BaseOp::getVerifier(
43 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
44 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
50 if (
auto baseRef = getBaseRef()) {
56 if (
auto typeOp = dyn_cast<TypeOp>(defOp)) {
59 "." + typeDef->
getName().str());
60 return std::make_unique<BaseTypeConstraint>(typeDef->
getTypeID(), name);
64 auto attrOp = cast<AttributeOp>(defOp);
67 "." + attrDef->
getName().str());
68 return std::make_unique<BaseAttrConstraint>(attrDef->
getTypeID(), name);
74 StringRef baseName = getBaseName().value();
77 if (baseName[0] ==
'!') {
80 emitError() <<
"no registered type with name " << baseName;
83 return std::make_unique<BaseTypeConstraint>(abstractType->get().getTypeID(),
84 abstractType->get().getName());
89 emitError() <<
"no registered attribute with name " << baseName;
92 return std::make_unique<BaseAttrConstraint>(abstractAttr->get().getTypeID(),
93 abstractAttr->get().getName());
96 std::unique_ptr<Constraint> ParametricOp::getVerifier(
98 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
99 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
106 SymbolRefAttr symRef = getBaseType();
109 emitError() << symRef <<
" does not refer to any existing symbol";
113 if (
auto typeOp = dyn_cast<TypeOp>(defOp))
114 return std::make_unique<DynParametricTypeConstraint>(types.at(typeOp).get(),
117 if (
auto attrOp = dyn_cast<AttributeOp>(defOp))
118 return std::make_unique<DynParametricAttrConstraint>(attrs.at(attrOp).get(),
121 llvm_unreachable(
"verifier should ensure that the referenced operation is "
122 "either a type or an attribute definition");
125 std::unique_ptr<Constraint> AnyOfOp::getVerifier(
127 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
128 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
130 return std::make_unique<AnyOfConstraint>(
134 std::unique_ptr<Constraint> AllOfOp::getVerifier(
136 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
137 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
139 return std::make_unique<AllOfConstraint>(
143 std::unique_ptr<Constraint> AnyOp::getVerifier(
145 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
146 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
148 return std::make_unique<AnyAttributeConstraint>();
151 std::unique_ptr<RegionConstraint> RegionOp::getVerifier(
153 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
154 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
156 return std::make_unique<RegionConstraint>(
158 getEntryBlockArgs(), valueToConstr)}
160 getNumberOfBlocks());
static SmallVector< unsigned > getConstraintIndicesForArgs(mlir::OperandRange args, ArrayRef< Value > valueToConstr)
Maps given args to the index in the valueToConstr
static MLIRContext * getContext(OpFoldResult val)
static const AbstractAttribute & lookup(TypeID typeID, MLIRContext *context)
Look up the specified abstract attribute in the MLIRContext and return a reference to it.
static const AbstractType & lookup(TypeID typeID, MLIRContext *context)
Look up the specified abstract type in the MLIRContext and return a reference to it.
StringRef getNamespace() const
The definition of a dynamic attribute.
ExtensibleDialect * getDialect() const
Return the dialect defining the attribute.
static std::unique_ptr< DynamicAttrDefinition > get(StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier)
Create a new attribute definition at runtime.
StringRef getName() const
Return the name of the attribute, in the format 'attrname' and not 'dialectname.attrname'.
The definition of a dynamic type.
StringRef getName() const
Return the name of the type, in the format 'typename' and not 'dialectname.typename'.
ExtensibleDialect * getDialect() const
Return the dialect defining the type.
static std::unique_ptr< DynamicTypeDefinition > get(StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier)
Create a new dynamic type definition.
MLIRContext is the top-level object for a collection of MLIR operations.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
TypeID getTypeID() const
Return the TypeID owned by this object.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)
Operation * lookupSymbolNearDialect(SymbolTableCollection &symbolTable, Operation *source, SymbolRefAttr symbol)
Looks up a symbol from the symbol table containing the source operation's dialect definition operatio...
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...