diff --git a/include/llvm-dialects/Dialect/OpSet.h b/include/llvm-dialects/Dialect/OpSet.h index 6f39599..3bb0b3e 100644 --- a/include/llvm-dialects/Dialect/OpSet.h +++ b/include/llvm-dialects/Dialect/OpSet.h @@ -89,9 +89,15 @@ class OpSet final { // Construct an OpSet from a set of dialect ops, given as template // arguments. - template static const OpSet get() { - static OpSet set; - (... && appendT(set)); + template static const OpSet &get() { + static const auto set = ([]() { + OpSet set; + (void)(... && ([&set]() { + set.tryInsertOp(OpDescription::get()); + return true; + })()); + return set; + })(); return set; } @@ -169,15 +175,6 @@ class OpSet final { } private: - // Generates an `OpDescription` for a given `OpT`, extracts the - // internal operation representation and collects it in the set. - template static bool appendT(OpSet &set) { - static OpDescription desc = OpDescription::get(); - set.tryInsertOp(desc); - - return true; - } - // Checks if `mnemonic` can be described by any of the stored dialect // operations. bool isMatchingDialectOp(llvm::StringRef mnemonic) const {