[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
This commit is contained in:
River Riddle 2021-12-10 19:35:43 +00:00
parent e40624ae60
commit 9debc35f02
2 changed files with 11 additions and 2 deletions

View File

@ -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
}];
}

View File

@ -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)
}
}