[Mlir-commits] [mlir] cafaa9e - [mlir] fix memory effects of transform::PDLMatchOp

Alex Zinenko llvmlistbot at llvm.org
Fri Oct 7 01:17:22 PDT 2022


Author: Alex Zinenko
Date: 2022-10-07T08:14:30Z
New Revision: cafaa9eb7056b8ce91cf08f62da982a898ab4c95

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

LOG: [mlir] fix memory effects of transform::PDLMatchOp

The op was declaring the effects associated with payload IR as attached
to its operand since ODS doesn't allow otherwise. Implement the memory
effects query method in C++ instead to make the effect not attached to
the operand.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
    mlir/lib/Dialect/Transform/IR/TransformOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
index 99408eb3a60d7..4b979928314b8 100644
--- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
+++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
@@ -211,7 +211,8 @@ def MergeHandlesOp : TransformDialectOp<"merge_handles",
 }
 
 def PDLMatchOp : TransformDialectOp<"pdl_match",
-    [DeclareOpInterfaceMethods<TransformOpInterface>]> {
+    [DeclareOpInterfaceMethods<TransformOpInterface>,
+     DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "Finds ops that match the named PDL pattern";
   let description = [{
     Find Payload IR ops nested within the Payload IR op associated with the
@@ -231,12 +232,10 @@ def PDLMatchOp : TransformDialectOp<"pdl_match",
   }];
 
   let arguments = (ins
-    Arg<PDL_Operation, "Payload IR scope to match within",
-        [TransformMappingRead, PayloadIRRead]>:$root, 
+    Arg<PDL_Operation, "Payload IR scope to match within">:$root, 
     SymbolRefAttr:$pattern_name);
   let results = (outs
-    Res<PDL_Operation, "Handle to the matched Payload IR ops",
-        [TransformMappingAlloc, TransformMappingWrite]>:$matched);
+    Res<PDL_Operation, "Handle to the matched Payload IR ops">:$matched);
 
   let assemblyFormat = "$pattern_name `in` $root attr-dict";
 }

diff  --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index 116b6d93409f7..26a2bafbe8746 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -474,6 +474,13 @@ transform::PDLMatchOp::apply(transform::TransformResults &results,
   return DiagnosedSilenceableFailure::success();
 }
 
+void transform::PDLMatchOp::getEffects(
+    SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
+  onlyReadsHandle(getRoot(), effects);
+  producesHandle(getMatched(), effects);
+  onlyReadsPayload(effects);
+}
+
 //===----------------------------------------------------------------------===//
 // ReplicateOp
 //===----------------------------------------------------------------------===//


        


More information about the Mlir-commits mailing list