[Mlir-commits] [mlir] 0cd5e02 - [mlir][transform] Improve assembly format of apply_conversion_patterns
Matthias Springer
llvmlistbot at llvm.org
Wed Aug 9 02:07:31 PDT 2023
Author: Matthias Springer
Date: 2023-08-09T11:07:22+02:00
New Revision: 0cd5e02847bdce0a35e8e94028efd43b18733d6a
URL: https://github.com/llvm/llvm-project/commit/0cd5e02847bdce0a35e8e94028efd43b18733d6a
DIFF: https://github.com/llvm/llvm-project/commit/0cd5e02847bdce0a35e8e94028efd43b18733d6a.diff
LOG: [mlir][transform] Improve assembly format of apply_conversion_patterns
This change was extracted from D157278.
Differential Revision: https://reviews.llvm.org/D157482
Added:
Modified:
mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
mlir/test/Dialect/Transform/test-pattern-application.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
index c41c6d7768ac7f..88e69725cdb268 100644
--- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
+++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
@@ -203,10 +203,14 @@ def ApplyConversionPatternsOp : TransformDialectOp<"apply_conversion_patterns",
OptionalAttr<StrArrayAttr>:$illegal_dialects,
UnitAttr:$partialConversion);
let results = (outs);
- let regions = (region VariadicRegion<MaxSizedRegion<1>>:$regions);
+ let regions = (region
+ MaxSizedRegion<1>:$patterns,
+ VariadicRegion<MaxSizedRegion<1>>:$default_type_converter_region);
let assemblyFormat = [{
- `to` $target $regions attr-dict `:` type($target)
+ `to` $target $patterns
+ (`with` `type_converter` $default_type_converter_region^)?
+ attr-dict `:` type($target)
}];
let hasVerifier = 1;
@@ -221,15 +225,11 @@ def ApplyConversionPatternsOp : TransformDialectOp<"apply_conversion_patterns",
];
let extraClassDeclaration = [{
- ::mlir::Region &getPatterns() {
- return getRegion(0);
- }
-
::mlir::transform::TypeConverterBuilderOpInterface getDefaultTypeConverter() {
- if (getNumRegions() < 2)
+ if (getDefaultTypeConverterRegion().size() == 0)
return {};
return ::llvm::cast<::mlir::transform::TypeConverterBuilderOpInterface>(
- &getRegion(1).front().front());
+ &getDefaultTypeConverterRegion()[0].front().front());
}
}];
}
diff --git a/mlir/test/Dialect/Transform/test-pattern-application.mlir b/mlir/test/Dialect/Transform/test-pattern-application.mlir
index 8ac6d4ef3b9778..a3ea93a6f85f56 100644
--- a/mlir/test/Dialect/Transform/test-pattern-application.mlir
+++ b/mlir/test/Dialect/Transform/test-pattern-application.mlir
@@ -248,7 +248,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
transform.apply_conversion_patterns to %0 {
transform.apply_conversion_patterns.transform.test_conversion_patterns
- }, {
+ } with type_converter {
transform.apply_conversion_patterns.transform.test_type_converter
} {illegal_ops = ["test.foo"],
legal_ops = ["func.func", "func.return", "test.new_op"]}
@@ -263,7 +263,7 @@ transform.sequence failures(propagate) {
// expected-error @below{{conversion target is not specified}}
transform.apply_conversion_patterns to %0 {
transform.apply_conversion_patterns.transform.test_conversion_patterns
- }, {
+ } with type_converter {
transform.apply_conversion_patterns.transform.test_type_converter
} : !transform.any_op
}
More information about the Mlir-commits
mailing list