[Mlir-commits] [mlir] [mlir-c] Add structural operation equivalence (PR #206537)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jul 30 21:04:26 PDT 2026


================
@@ -656,6 +656,25 @@ size_t mlirOperationHashValue(MlirOperation op) {
   return OperationEquivalence::computeHash(unwrap(op));
 }
 
+/// Translates the C equivalence flags to mlir::OperationEquivalence::Flags. The
+/// enumerator values mirror each other.
+static OperationEquivalence::Flags unwrapEquivalenceFlags(uint32_t flags) {
+  return static_cast<OperationEquivalence::Flags>(flags);
+}
+
+bool mlirOperationIsStructurallyEquivalent(MlirOperation lhs, MlirOperation rhs,
+                                           uint32_t flags) {
+  return OperationEquivalence::isEquivalentTo(unwrap(lhs), unwrap(rhs),
+                                              unwrapEquivalenceFlags(flags));
+}
+
+size_t mlirOperationStructuralHashValue(MlirOperation op, uint32_t flags) {
+  return OperationEquivalence::computeHash(
+      unwrap(op), /*hashOperands=*/OperationEquivalence::directHashValue,
+      /*hashResults=*/OperationEquivalence::ignoreHashValue,
+      unwrapEquivalenceFlags(flags));
+}
----------------
PragmaTwice wrote:

Should we expose `hashOperands` and `hashResults` callbacks or the current form is enough for most uses?

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


More information about the Mlir-commits mailing list