diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -87,6 +87,15 @@ friend ::llvm::hash_code hash_value(Attribute arg); + /// Returns true if `InterfaceT` has been promised by the dialect or + /// implemented. + template + bool hasPromiseOrImplementsInterface() { + return dialect_extension_detail::hasPromisedInterface( + getDialect(), getTypeID(), InterfaceT::getInterfaceID()) || + mlir::isa(*this); + } + /// Returns true if the type was registered with a particular trait. template