[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:16 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: AidinT (aidint)
<details>
<summary>Changes</summary>
Two modifications:
1. Reflect newly added dialect interface methods in the documentation
2. Remove the bug in the `MLIR Reduce` documentation
---
Full diff: https://github.com/llvm/llvm-project/pull/189258.diff
2 Files Affected:
- (modified) mlir/docs/Interfaces.md (+29-2)
- (modified) mlir/docs/Tools/mlir-reduce.md (+3)
``````````diff
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.
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/189258
More information about the Mlir-commits
mailing list