[Mlir-commits] [mlir] [mlir][docs] dialect interfaces and mlir reduce documentation fix (PR #189258)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Mar 29 09:17:48 PDT 2026
https://github.com/aidint updated https://github.com/llvm/llvm-project/pull/189258
>From fee863c65fed86b0c506e3508773ee3c07122e00 Mon Sep 17 00:00:00 2001
From: aidint <at.aidin at gmail.com>
Date: Sun, 29 Mar 2026 17:45:47 +0200
Subject: [PATCH 1/3] change mlir-reduce rewrite pattern interface example
---
mlir/docs/Tools/mlir-reduce.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mlir/docs/Tools/mlir-reduce.md b/mlir/docs/Tools/mlir-reduce.md
index b60cdd799ba0c..ed6172f76a337 100644
--- a/mlir/docs/Tools/mlir-reduce.md
+++ b/mlir/docs/Tools/mlir-reduce.md
@@ -76,6 +76,9 @@ example,
#include "mlir/Reducer/ReductionPatternInterface.h"
struct MyReductionPatternInterface : public DialectReductionPatternInterface {
+ MyReductionPatternInterface(Dialect *dialect)
+ : DialectReductionPatternInterface(dialect) {};
+
virtual void
populateReductionPatterns(RewritePatternSet &patterns) const final {
populateMyReductionPatterns(patterns);
>From bb411b8212f95a8c3c526a14b90e917087732373 Mon Sep 17 00:00:00 2001
From: aidint <at.aidin at gmail.com>
Date: Sun, 29 Mar 2026 18:13:20 +0200
Subject: [PATCH 2/3] add different dialect interface method types to
documentation
---
mlir/docs/Interfaces.md | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index d3e1888c48baf..546b56c62ce90 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -133,7 +133,7 @@ def DialectInlinerInterface : DialectInterface<"DialectInlinerInterface"> {
- The C++ namespace that the interface class should be generated in.
* Methods (`methods`)
- The list of interface hook methods that are defined by the IR object.
- - The structure of these methods is defined [here](#interface-methods).
+ - The structure of these methods is defined [here](#dialect-interface-methods).
The header file can be generated via the following command:
@@ -151,6 +151,33 @@ mlir_tablegen(DialectInlinerInterface.h.inc -gen-dialect-interface-decls)
An example of this can be found in the DialectInlinerInterface implementation
and the related `CMakeLists.txt` under `mlir/include/mlir/Transforms`.
+##### Dialect Interface Methods
+
+There are three types of methods that can be used with a dialect interface,
+`InterfaceMethod`, `InterfaceMethodDeclaration` and `PureVirtualInterfaceMethod`.
+They are all comprised of the same core components, with the distinction that
+`InterfaceMethod` also supports a default method body.
+
+Interface methods are comprised of the following components:
+
+* Description
+ - A string description of this method, its invariants, example usages,
+ etc.
+* ReturnType
+ - A string corresponding to the C++ return type of the method.
+* MethodName
+ - A string corresponding to the C++ name of the method.
+* Arguments (Optional)
+ - A dag of strings that correspond to a C++ type and variable name
+ respectively.
+* MethodBody (Optional, only in `InterfaceMethod`)
+ - An optional explicit implementation of the interface method.
+
+`InterfaceMethodDeclaration` will only declare the class method. On the other hand,
+`PureVirtualInterfaceMethod` marks the method as pure virtual, but also makes the
+constructor of the dialect calss protected.
+
+
#### DialectInterfaceCollection
An additional utility is provided via `DialectInterfaceCollection`. This class
@@ -510,7 +537,7 @@ comprised of the following components:
##### Interface Methods
-There are two types of methods that can be used with an interface,
+There are two types of methods that can be used with an attr/op/type interface,
`InterfaceMethod` and `StaticInterfaceMethod`. They are both comprised of the
same core components, with the distinction that `StaticInterfaceMethod` models a
static method on the derived IR object.
>From 930734fdf088c26b784260bdb08887fee466fa3f Mon Sep 17 00:00:00 2001
From: aidint <at.aidin at gmail.com>
Date: Sun, 29 Mar 2026 18:17:35 +0200
Subject: [PATCH 3/3] remove extra line
---
mlir/docs/Interfaces.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index 546b56c62ce90..46b565e255d45 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -177,7 +177,6 @@ Interface methods are comprised of the following components:
`PureVirtualInterfaceMethod` marks the method as pure virtual, but also makes the
constructor of the dialect calss protected.
-
#### DialectInterfaceCollection
An additional utility is provided via `DialectInterfaceCollection`. This class
More information about the Mlir-commits
mailing list