21 for (
Value arg : args) {
22 for (
auto [i, value] :
enumerate(valueToConstr)) {
24 constraints.push_back(i);
32 std::unique_ptr<Constraint> IsOp::getVerifier(
34 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
35 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
37 return std::make_unique<IsConstraint>(getExpectedAttr());
40 std::unique_ptr<Constraint> BaseOp::getVerifier(
42 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
43 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
49 if (
auto baseRef = getBaseRef()) {
54 if (
auto typeOp = dyn_cast<TypeOp>(defOp)) {
57 "." + typeDef->
getName().str());
58 return std::make_unique<BaseTypeConstraint>(typeDef->
getTypeID(), name);
62 auto attrOp = cast<AttributeOp>(defOp);
65 "." + attrDef->
getName().str());
66 return std::make_unique<BaseAttrConstraint>(attrDef->
getTypeID(), name);
72 StringRef baseName = getBaseName().value();
75 if (baseName[0] ==
'!') {
78 emitError() <<
"no registered type with name " << baseName;
81 return std::make_unique<BaseTypeConstraint>(abstractType->get().getTypeID(),
82 abstractType->get().getName());
87 emitError() <<
"no registered attribute with name " << baseName;
90 return std::make_unique<BaseAttrConstraint>(abstractAttr->get().getTypeID(),
91 abstractAttr->get().getName());
94 std::unique_ptr<Constraint> ParametricOp::getVerifier(
96 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
97 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
103 SymbolRefAttr symRef = getBaseType();
107 emitError() << symRef <<
" does not refer to any existing symbol";
111 if (
auto typeOp = dyn_cast<TypeOp>(defOp))
112 return std::make_unique<DynParametricTypeConstraint>(types.at(typeOp).get(),
115 if (
auto attrOp = dyn_cast<AttributeOp>(defOp))
116 return std::make_unique<DynParametricAttrConstraint>(attrs.at(attrOp).get(),
119 llvm_unreachable(
"verifier should ensure that the referenced operation is "
120 "either a type or an attribute definition");
123 std::unique_ptr<Constraint> AnyOfOp::getVerifier(
125 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
126 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
128 return std::make_unique<AnyOfConstraint>(
132 std::unique_ptr<Constraint> AllOfOp::getVerifier(
134 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
135 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
137 return std::make_unique<AllOfConstraint>(
141 std::unique_ptr<Constraint> AnyOp::getVerifier(
143 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
144 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
146 return std::make_unique<AnyAttributeConstraint>();
149 std::unique_ptr<RegionConstraint> RegionOp::getVerifier(
151 DenseMap<TypeOp, std::unique_ptr<DynamicTypeDefinition>>
const &types,
152 DenseMap<AttributeOp, std::unique_ptr<DynamicAttrDefinition>>
const
154 return std::make_unique<RegionConstraint>(
156 getEntryBlockArgs(), valueToConstr)}
158 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.
static Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
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)
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...