[Mlir-commits] [mlir] [mlir] Init the `TransformsInterfaces` for configuring transformations (PR #99566)

Mehdi Amini llvmlistbot at llvm.org
Sun Jul 21 11:38:47 PDT 2024


================
@@ -0,0 +1,77 @@
+//===- TransformsInterfaces.td - Transforms interfaces -----*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines interfaces for managing transformations, including populating
+// pattern rewrites.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INTERFACES_TRANSFORMSINTERFACES_TD
+#define MLIR_INTERFACES_TRANSFORMSINTERFACES_TD
+
+include "mlir/IR/OpBase.td"
+
+//===----------------------------------------------------------------------===//
+// Conversion patterns attribute interface
+//===----------------------------------------------------------------------===//
+
+def ConversionPatternsAttrInterface :
+    AttrInterface<"ConversionPatternsAttrInterface"> {
+  let description = [{
+    This interfaces allows using attributes to configure the dialect conversion
+    infrastructure, this includes:
+     - The conversion target.
+     - The type converter.
+     - The pattern set.
+    
+    The conversion target and type converter are passed through the
+    `ConversionPatternAttrOptions` class. Passing them through this class
+    and by reference allows sub-classing the base option class, allowing
+    specializations like `LLVMConversionPatternAttrOptions` for converting to
+    LLVM.
+  }];
+  let cppNamespace = "::mlir";
+  let methods = [
+    InterfaceMethod<
+      /*desc=*/[{
+        Populate the dialect conversion target, type converter and pattern set.
+      }],
+      /*retTy=*/"void",
+      /*methodName=*/"populateConversionPatterns",
+      /*args=*/(ins "::mlir::ConversionPatternAttrOptions&":$options,
+                    "::mlir::RewritePatternSet&":$patternSet)>
+  ];
+}
----------------
joker-eph wrote:

> regardless if the target is LLVM, SPIR-V, or things like scf to cf. 

Right: I don't quite understand this. How can it be useful to have this interface if you don't know the target? The patterns to populate for an operation are entirely dependent of the conversion you're doing aren't they?

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


More information about the Mlir-commits mailing list