diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -162,6 +162,11 @@ (void)std::initializer_list{0, (addType(), 0)...}; } + /// Register a type instance with this dialect. + /// The use of this method is in general discouraged in favor of + /// 'addTypes()'. + void addType(TypeID typeID, AbstractType &&typeInfo); + /// Register a set of attribute classes with this dialect. template void addAttributes() { (void)std::initializer_list{0, (addAttribute(), 0)...}; @@ -182,11 +187,6 @@ 0, (addInterface(std::make_unique(this)), 0)...}; } - /// Register a type instance with this dialect. - /// The use of this method is in general discouraged in favor of - /// 'addTypes()'. - void addType(TypeID typeID, AbstractType &&typeInfo); - private: Dialect(const Dialect &) = delete; void operator=(Dialect &) = delete; diff --git a/mlir/include/mlir/IR/TypeSupport.h b/mlir/include/mlir/IR/TypeSupport.h --- a/mlir/include/mlir/IR/TypeSupport.h +++ b/mlir/include/mlir/IR/TypeSupport.h @@ -39,6 +39,15 @@ return AbstractType(dialect, T::getInterfaceMap(), T::getTypeID()); } + /// This method is used by Dialect objects to register types with + /// custom TypeIDs. + /// The use of this method is in general discouraged in favor of + /// 'get(dialect)'; + static AbstractType get(Dialect &dialect, detail::InterfaceMap &&interfaceMap, + TypeID typeID) { + return AbstractType(dialect, std::move(interfaceMap), typeID); + } + /// Return the dialect this type was registered to. Dialect &getDialect() const { return const_cast(dialect); } @@ -52,14 +61,12 @@ /// Return the unique identifier representing the concrete type class. TypeID getTypeID() const { return typeID; } - /// The use of this constructor is in general discouraged in favor of - /// 'AbstractType::get()'. +private: AbstractType(Dialect &dialect, detail::InterfaceMap &&interfaceMap, TypeID typeID) : dialect(dialect), interfaceMap(std::move(interfaceMap)), typeID(typeID) {} -private: /// This is the dialect that this type was registered to. Dialect &dialect;