[Mlir-commits] [mlir] [mlir][transform] Add an op for replacing values with function calls (PR #78398)

Quinn Dawkins llvmlistbot at llvm.org
Wed Jan 17 06:50:04 PST 2024


================
@@ -280,6 +280,28 @@ def PatternDescriptorOpInterface : OpInterface<"PatternDescriptorOpInterface"> {
   ];
 }
 
+def TypeConversionOpInterface : OpInterface<"TypeConversionOpInterface"> {
+  let description = [{
+    This interface should be implemented by ops that populate type casting
+    of a `transform.cast_and_inline` op. It provides a method to populate a
+    type converter with source/target materialization patterns.
+  }];
+
+  let cppNamespace = "::mlir::transform";
+
+  let methods = [
+    InterfaceMethod<
+      /*desc=*/[{
+        Populate the given type converter with source/target materialization
+        functions.
+      }],
+      /*returnType=*/"void",
+      /*name=*/"populateTypeMaterializations",
+      /*arguments=*/(ins "::mlir::TypeConverter &":$converter)
+    >
+  ];
----------------
qedawkins wrote:

We need a way to update a preexisting converter. If I have a conversion for tensors (like in this PR) next to a conversion for `my_dialect_a`, the conversion implementation for `my_dialect_a` shouldn't have to reimplement the one for tensors (essentially because this isn't actually doing dialect conversion, just piggybacking off of the infrastructure for adding conversions based on a type).

We could add `populateTypeMaterializations` to `TypeConverterBuilderOpInterface` with a default implementation that does nothing. Adding a converter handle would only be for if we wanted to reuse the converter with other transforms (which maybe we do?)

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


More information about the Mlir-commits mailing list