[Mlir-commits] [mlir] c0c2e38 - [MLIR] Generate DataLayoutDialectInterface using ODS (#181217)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Feb 15 07:13:14 PST 2026


Author: AidinT
Date: 2026-02-15T07:13:09-08:00
New Revision: c0c2e38d4a69e21c16a0a34ebecf888caadcb81f

URL: https://github.com/llvm/llvm-project/commit/c0c2e38d4a69e21c16a0a34ebecf888caadcb81f
DIFF: https://github.com/llvm/llvm-project/commit/c0c2e38d4a69e21c16a0a34ebecf888caadcb81f.diff

LOG: [MLIR] Generate DataLayoutDialectInterface using ODS (#181217)

This PR converts DataLayoutDialectInterface to a ODS dialect
interface.

Added: 
    

Modified: 
    mlir/include/mlir/Interfaces/CMakeLists.txt
    mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
    mlir/include/mlir/Interfaces/DataLayoutInterfaces.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt
index 7a35654998ba5..3cbc9df05f3d7 100644
--- a/mlir/include/mlir/Interfaces/CMakeLists.txt
+++ b/mlir/include/mlir/Interfaces/CMakeLists.txt
@@ -35,6 +35,7 @@ mlir_tablegen(DataLayoutOpInterface.h.inc -gen-op-interface-decls)
 mlir_tablegen(DataLayoutOpInterface.cpp.inc -gen-op-interface-defs)
 mlir_tablegen(DataLayoutTypeInterface.h.inc -gen-type-interface-decls)
 mlir_tablegen(DataLayoutTypeInterface.cpp.inc -gen-type-interface-defs)
+mlir_tablegen(DataLayoutDialectInterface.h.inc -gen-dialect-interface-decls)
 add_mlir_generic_tablegen_target(MLIRDataLayoutInterfacesIncGen)
 
 set(LLVM_TARGET_DEFINITIONS DialectFoldInterface.td)

diff  --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
index bf509ba3e1c11..20de0c6ba7e43 100644
--- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
+++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
@@ -153,57 +153,12 @@ llvm::TypeSize divideCeil(llvm::TypeSize numerator, uint64_t denominator);
 } // namespace mlir
 
 #include "mlir/Interfaces/DataLayoutAttrInterface.h.inc"
+#include "mlir/Interfaces/DataLayoutDialectInterface.h.inc"
 #include "mlir/Interfaces/DataLayoutOpInterface.h.inc"
 #include "mlir/Interfaces/DataLayoutTypeInterface.h.inc"
 
 namespace mlir {
 
-//===----------------------------------------------------------------------===//
-// DataLayoutDialectInterface
-//===----------------------------------------------------------------------===//
-
-/// An interface to be implemented by dialects that can have identifiers in the
-/// data layout specification entries. Provides hooks for verifying the entry
-/// validity and combining two entries.
-class DataLayoutDialectInterface
-    : public DialectInterface::Base<DataLayoutDialectInterface> {
-public:
-  DataLayoutDialectInterface(Dialect *dialect) : Base(dialect) {}
-
-  /// Checks whether the given data layout entry is valid and reports any errors
-  /// at the provided location. Derived classes should override this.
-  virtual LogicalResult verifyEntry(DataLayoutEntryInterface entry,
-                                    Location loc) const {
-    return success();
-  }
-
-  /// Checks whether the given data layout entry is valid and reports any errors
-  /// at the provided location. Derived classes should override this.
-  virtual LogicalResult verifyEntry(TargetDeviceSpecInterface entry,
-                                    Location loc) const {
-    return success();
-  }
-
-  /// Default implementation of entry combination that combines identical
-  /// entries and returns null otherwise.
-  static DataLayoutEntryInterface
-  defaultCombine(DataLayoutEntryInterface outer,
-                 DataLayoutEntryInterface inner) {
-    if (!outer || outer == inner)
-      return inner;
-    return {};
-  }
-
-  /// Combines two entries with identifiers that belong to this dialect. Returns
-  /// the combined entry or null if the entries are not compatible. Derived
-  /// classes likely need to reimplement this.
-  virtual DataLayoutEntryInterface
-  combine(DataLayoutEntryInterface outer,
-          DataLayoutEntryInterface inner) const {
-    return defaultCombine(outer, inner);
-  }
-};
-
 //===----------------------------------------------------------------------===//
 // DataLayout
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
index a22aa0012ddd3..9d35f78b218f8 100644
--- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
+++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
@@ -717,4 +717,64 @@ def DataLayoutTypeInterface : TypeInterface<"DataLayoutTypeInterface"> {
   ];
 }
 
+//===----------------------------------------------------------------------===//
+// Dialect interface
+//===----------------------------------------------------------------------===//
+
+def DataLayoutDialectInterface : DialectInterface<"DataLayoutDialectInterface"> {
+  let description = [{
+    An interface to be implemented by dialects that can have identifiers in the
+    data layout specification entries. Provides hooks for verifying the entry
+    validity and combining two entries.
+  }];
+  let cppNamespace = "::mlir";
+
+  let extraClassDeclaration = [{
+    /// Default implementation of entry combination that combines identical
+    /// entries and returns null otherwise.
+    static ::mlir::DataLayoutEntryInterface
+    defaultCombine(::mlir::DataLayoutEntryInterface outer,
+                   ::mlir::DataLayoutEntryInterface inner) {
+      if (!outer || outer == inner)
+        return inner;
+      return {};
+    }
+  }];
+
+  let methods = [
+    InterfaceMethod<[{
+        Checks whether the given data layout entry is valid and reports any errors
+        at the provided location. Derived classes should override this.
+      }],
+      "::mlir::LogicalResult", "verifyEntry",
+      (ins "::mlir::DataLayoutEntryInterface":$entry, "::mlir::Location":$loc),
+      [{
+        return ::llvm::success();
+      }]
+    >,
+    InterfaceMethod<[{
+        Checks whether the given data layout entry is valid and reports any errors
+        at the provided location. Derived classes should override this.
+      }],
+      "::mlir::LogicalResult", "verifyEntry",
+      (ins "::mlir::TargetDeviceSpecInterface":$entry, "::mlir::Location":$loc),
+      [{
+        return ::llvm::success();
+      }]
+    >,
+    InterfaceMethod<[{
+        Combines two entries with identifiers that belong to this dialect. Returns
+        the combined entry or null if the entries are not compatible. Derived
+        classes likely need to reimplement this.
+      }],
+      "::mlir::DataLayoutEntryInterface", "combine",
+      (ins "::mlir::DataLayoutEntryInterface":$outer, 
+           "::mlir::DataLayoutEntryInterface":$inner),
+      [{
+        return defaultCombine(outer, inner);
+      }]
+    > 
+  ];
+}
+
 #endif // MLIR_DATALAYOUTINTERFACES


        


More information about the Mlir-commits mailing list