[Mlir-commits] [mlir] [mlir] Method to iterate over registered operations for a given dialect class. (PR #112344)

River Riddle llvmlistbot at llvm.org
Wed Oct 16 12:14:36 PDT 2024


================
@@ -976,12 +994,19 @@ void RegisteredOperationName::insert(
          "operation name registration must be successful");
 
   // Add emplaced operation name to the sorted operations container.
+  StringRef dialectClass = impl->getDialect()->getNamespace();
+  ctxImpl.getCountByDialectName[dialectClass] += 1;
+
   RegisteredOperationName &value = emplaced.first->second;
   ctxImpl.sortedRegisteredOperations.insert(
       llvm::upper_bound(ctxImpl.sortedRegisteredOperations, value,
                         [](auto &lhs, auto &rhs) {
-                          return lhs.getIdentifier().compare(
-                              rhs.getIdentifier());
+                          if (lhs.getDialect().getNamespace() ==
+                              rhs.getDialect().getNamespace())
+                            return lhs.getIdentifier().compare(
+                                rhs.getIdentifier());
+                          return lhs.getDialect().getNamespace().compare(
+                              rhs.getDialect().getNamespace());
----------------
River707 wrote:

Why won't the existing code work? The operation name is already prefixed with the dialect, which I would assume ensures that all operations with the same dialect are ordered next to each other.

https://github.com/llvm/llvm-project/pull/112344


More information about the Mlir-commits mailing list