[Mlir-commits] [mlir] 9debc35 - [mlir:PDL] Fix assembly format for pdl.apply_native_rewrite
River Riddle
llvmlistbot at llvm.org
Fri Dec 10 11:50:31 PST 2021
Author: River Riddle
Date: 2021-12-10T19:38:42Z
New Revision: 9debc35f02e90352e49ae5ce7bcfb0b7a233d81a
URL: https://github.com/llvm/llvm-project/commit/9debc35f02e90352e49ae5ce7bcfb0b7a233d81a
DIFF: https://github.com/llvm/llvm-project/commit/9debc35f02e90352e49ae5ce7bcfb0b7a233d81a.diff
LOG: [mlir:PDL] Fix assembly format for pdl.apply_native_rewrite
The results of a rewrite are optional, but we currently require
them to be present in the assembly format. This commit
makes the results component in the format optional.
Differential Revision: https://reviews.llvm.org/D114814
Added:
Modified:
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/test/Dialect/PDL/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
index 96ea659dd1f49..b630a73cbf45e 100644
--- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
+++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
@@ -114,8 +114,8 @@ def PDL_ApplyNativeRewriteOp
OptionalAttr<ArrayAttr>:$constParams);
let results = (outs Variadic<PDL_AnyType>:$results);
let assemblyFormat = [{
- $name ($constParams^)? (`(` $args^ `:` type($args) `)`)? `:` type($results)
- attr-dict
+ $name ($constParams^)? (`(` $args^ `:` type($args) `)`)?
+ (`:` type($results)^)? attr-dict
}];
}
diff --git a/mlir/test/Dialect/PDL/ops.mlir b/mlir/test/Dialect/PDL/ops.mlir
index 1993895c0d6de..8a35693fa7064 100644
--- a/mlir/test/Dialect/PDL/ops.mlir
+++ b/mlir/test/Dialect/PDL/ops.mlir
@@ -110,3 +110,12 @@ pdl.pattern @infer_type_from_type_used_in_match : benefit(1) {
%newOp = pdl.operation "foo.op" -> (%types, %otherTypes : !pdl.range<type>, !pdl.range<type>)
}
}
+
+// -----
+
+pdl.pattern @apply_rewrite_with_no_results : benefit(1) {
+ %root = pdl.operation
+ pdl.rewrite %root {
+ pdl.apply_native_rewrite "NativeRewrite"(%root : !pdl.operation)
+ }
+}
More information about the Mlir-commits
mailing list