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 @@ -181,57 +181,22 @@ /// This method is used by derived classes to add their operations to the set. /// template void addOperations() { - VariadicOperationAdder::addToSet(*this); + (void)std::initializer_list{ + 0, (addOperation(AbstractOperation::get(*this)), 0)...}; } - // It would be nice to define this as variadic functions instead of a nested - // variadic type, but we can't do that: function template partial - // specialization is not allowed, and we can't define an overload set because - // we don't have any arguments of the types we are pushing around. - template class VariadicOperationAdder { - public: - static void addToSet(Dialect &dialect) { - dialect.addOperation(AbstractOperation::get(dialect)); - VariadicOperationAdder::addToSet(dialect); - } - }; - - template class VariadicOperationAdder { - public: - static void addToSet(Dialect &dialect) { - dialect.addOperation(AbstractOperation::get(dialect)); - } - }; - void addOperation(AbstractOperation opInfo); /// This method is used by derived classes to add their types to the set. template void addTypes() { - VariadicSymbolAdder::addToSet(*this); + (void)std::initializer_list{0, (addSymbol(Args::getClassID()), 0)...}; } /// This method is used by derived classes to add their attributes to the set. template void addAttributes() { - VariadicSymbolAdder::addToSet(*this); + (void)std::initializer_list{0, (addSymbol(Args::getClassID()), 0)...}; } - // It would be nice to define this as variadic functions instead of a nested - // variadic type, but we can't do that: function template partial - // specialization is not allowed, and we can't define an overload set - // because we don't have any arguments of the types we are pushing around. - template struct VariadicSymbolAdder { - static void addToSet(Dialect &dialect) { - VariadicSymbolAdder::addToSet(dialect); - VariadicSymbolAdder::addToSet(dialect); - } - }; - - template struct VariadicSymbolAdder { - static void addToSet(Dialect &dialect) { - dialect.addSymbol(First::getClassID()); - } - }; - /// Enable support for unregistered operations. void allowUnknownOperations(bool allow = true) { unknownOpsAllowed = allow; } @@ -242,12 +207,9 @@ void addInterface(std::unique_ptr interface); /// Register a set of dialect interfaces with this dialect instance. - template void addInterfaces() { - addInterfaces(); - addInterfaces(); - } - template void addInterfaces() { - addInterface(std::make_unique(this)); + template void addInterfaces() { + (void)std::initializer_list{ + 0, (addInterface(std::make_unique(this)), 0)...}; } private: