[Mlir-commits] [mlir] [mlir] Init the `TransformsInterfaces` for configuring transformations (PR #99566)
Fabian Mora
llvmlistbot at llvm.org
Sun Jul 21 11:25:32 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)>
+ ];
+}
----------------
fabianmcg wrote:
It provides the ability to configure the dialect conversion data structures, regardless if the target is LLVM, SPIR-V, or things like `scf` to `cf`.
I debated with myself whether scope it to a `ConvertToLLVM` interface, or let it have a more generic purpose if someone else found it useful, and avoid recreating this interface for every possible dialect conversion.
I choose the generic version. However, I don't have strong opinions for it, I can switch it to a `ConvertToLLVM` specific interface.
https://github.com/llvm/llvm-project/pull/99566
More information about the Mlir-commits
mailing list