[mlir:PDL] Adjust the assembly format for AttributeOp to avoid conflicts with DictionaryAttr

Switch the attribute creation operations to use attr-dict-with-
keyword to avoid conflicts (in the case of pdl.attribute) and
confusion(in the case of pdl_interp.create_attribute) with
having a DictionaryAttr as a value and specifying the
attributes of the operation itself (as a dictionary).

Differential Revision: https://reviews.llvm.org/D114815
This commit is contained in:
River Riddle 2021-12-10 19:35:55 +00:00
parent 9debc35f02
commit 98f5bd3489
3 changed files with 12 additions and 2 deletions

View File

@ -152,7 +152,7 @@ def PDL_AttributeOp : PDL_Op<"attribute"> {
let arguments = (ins Optional<PDL_Type>:$type,
OptionalAttr<AnyAttr>:$value);
let results = (outs PDL_Attribute:$attr);
let assemblyFormat = "attr-dict (`:` $type^)? ($value^)?";
let assemblyFormat = "(`:` $type^)? ($value^)? attr-dict-with-keyword";
let builders = [
OpBuilder<(ins CArg<"Value", "Value()">:$type), [{

View File

@ -413,7 +413,7 @@ def PDLInterp_CreateAttributeOp
let arguments = (ins AnyAttr:$value);
let results = (outs PDL_Attribute:$attribute);
let assemblyFormat = "$value attr-dict";
let assemblyFormat = "$value attr-dict-with-keyword";
let builders = [
OpBuilder<(ins "Attribute":$value), [{

View File

@ -119,3 +119,13 @@ pdl.pattern @apply_rewrite_with_no_results : benefit(1) {
pdl.apply_native_rewrite "NativeRewrite"(%root : !pdl.operation)
}
}
// -----
pdl.pattern @attribute_with_dict : benefit(1) {
%root = pdl.operation
pdl.rewrite %root {
%attr = pdl.attribute {some_unit_attr} attributes {pdl.special_attribute}
pdl.apply_native_rewrite "NativeRewrite"(%attr : !pdl.attribute)
}
}