[Mlir-commits] [mlir] 98f5bd3 - [mlir:PDL] Adjust the assembly format for AttributeOp to avoid conflicts with DictionaryAttr

River Riddle llvmlistbot at llvm.org
Fri Dec 10 11:50:33 PST 2021


Author: River Riddle
Date: 2021-12-10T19:38:42Z
New Revision: 98f5bd3489e68b65ae98d9424a24bc4c4ee021e7

URL: https://github.com/llvm/llvm-project/commit/98f5bd3489e68b65ae98d9424a24bc4c4ee021e7
DIFF: https://github.com/llvm/llvm-project/commit/98f5bd3489e68b65ae98d9424a24bc4c4ee021e7.diff

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
    mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.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 b630a73cbf45e..87918c3e4cb35 100644
--- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
+++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
@@ -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), [{

diff  --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
index 87033edc60f86..6918b9681ddc7 100644
--- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
+++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
@@ -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), [{

diff  --git a/mlir/test/Dialect/PDL/ops.mlir b/mlir/test/Dialect/PDL/ops.mlir
index 8a35693fa7064..758d5c6ac0314 100644
--- a/mlir/test/Dialect/PDL/ops.mlir
+++ b/mlir/test/Dialect/PDL/ops.mlir
@@ -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)
+  }
+}


        


More information about the Mlir-commits mailing list