forked from OSchip/llvm-project
[MLIR] Add isa<> support for Dialects.
Summary: The purpose of this is to aid in having code behave differently on Operations based on their Dialect without caring about the specific Op. Additionally this is consistent with most other types supporting isa<> and dyn_cast<>. A Dialect matches isa<> based only on its namespace and relies on each namespace being unique. Differential Revision: https://reviews.llvm.org/D79088
This commit is contained in:
parent
3acf62f3ad
commit
70619fa82d
|
@ -281,4 +281,14 @@ template <typename ConcreteDialect> struct DialectRegistration {
|
|||
|
||||
} // namespace mlir
|
||||
|
||||
namespace llvm {
|
||||
/// Provide isa functionality for Dialects.
|
||||
template <typename T>
|
||||
struct isa_impl<T, ::mlir::Dialect> {
|
||||
static inline bool doit(const ::mlir::Dialect &dialect) {
|
||||
return T::getDialectNamespace() == dialect.getNamespace();
|
||||
}
|
||||
};
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue