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 @@ -182,6 +182,11 @@ 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; @@ -200,7 +205,6 @@ addType(T::getTypeID(), AbstractType::get(*this)); detail::TypeUniquer::registerType(context); } - void addType(TypeID typeID, AbstractType &&typeInfo); /// The namespace of this dialect. StringRef name; diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -156,7 +156,9 @@ T::getHasTraitFn()); } -private: + /// Register a new operation in a Dialect object. + /// The use of this method is in general discouraged in favor of + /// 'insert(dialect)'. static void insert(StringRef name, Dialect &dialect, TypeID typeID, ParseAssemblyFn parseAssembly, PrintAssemblyFn printAssembly, @@ -164,6 +166,7 @@ GetCanonicalizationPatternsFn getCanonicalizationPatterns, detail::InterfaceMap &&interfaceMap, HasTraitFn hasTrait); +private: AbstractOperation(StringRef name, Dialect &dialect, TypeID typeID, ParseAssemblyFn parseAssembly, PrintAssemblyFn printAssembly, 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 @@ -52,12 +52,14 @@ /// Return the unique identifier representing the concrete type class. TypeID getTypeID() const { return typeID; } -private: + /// The use of this constructor is in general discouraged in favor of + /// 'AbstractType::get()'. 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; diff --git a/mlir/include/mlir/Support/InterfaceSupport.h b/mlir/include/mlir/Support/InterfaceSupport.h --- a/mlir/include/mlir/Support/InterfaceSupport.h +++ b/mlir/include/mlir/Support/InterfaceSupport.h @@ -183,6 +183,16 @@ return reinterpret_cast(lookup(T::getInterfaceID())); } + /// Create an InterfaceMap given with the implementation of the interfaces. + /// The use of this constructor is in general discouraged in favor of + /// 'InterfaceMap::get()'. + InterfaceMap(MutableArrayRef> elements) + : interfaces(elements.begin(), elements.end()) { + llvm::sort(interfaces, [](const auto &lhs, const auto &rhs) { + return compare(lhs.first, rhs.first); + }); + } + private: /// Compare two TypeID instances by comparing the underlying pointer. static bool compare(TypeID lhs, TypeID rhs) { @@ -190,12 +200,6 @@ } InterfaceMap() = default; - InterfaceMap(MutableArrayRef> elements) - : interfaces(elements.begin(), elements.end()) { - llvm::sort(interfaces, [](const auto &lhs, const auto &rhs) { - return compare(lhs.first, rhs.first); - }); - } template static InterfaceMap getImpl(std::tuple *) {