diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md index d3e1888c48baf..2de79eadd0052 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,28 @@ 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 +532,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);