[Mlir-commits] [mlir] 223a0f6 - [mlir][transform] Add builder to ApplyPatternsOp
Matthias Springer
llvmlistbot at llvm.org
Wed Jun 7 03:07:41 PDT 2023
Author: Matthias Springer
Date: 2023-06-07T12:06:55+02:00
New Revision: 223a0f63745635c50951960b0ffcf42c77988ed7
URL: https://github.com/llvm/llvm-project/commit/223a0f63745635c50951960b0ffcf42c77988ed7
DIFF: https://github.com/llvm/llvm-project/commit/223a0f63745635c50951960b0ffcf42c77988ed7.diff
LOG: [mlir][transform] Add builder to ApplyPatternsOp
Add a builder that takes a callback to construct the body of the op.
Differential Revision: https://reviews.llvm.org/D152352
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 6c75e4b622682..2dbb95afdb3aa 100644
--- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
+++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
@@ -166,6 +166,15 @@ def ApplyPatternsOp : TransformDialectOp<"apply_patterns",
let assemblyFormat = "`to` $target $region attr-dict `:` type($target)";
let hasVerifier = 1;
+ let skipDefaultBuilders = 1;
+ let builders = [
+ OpBuilder<(ins
+ "Value":$target,
+ CArg<"function_ref<void(OpBuilder &, Location)>", "nullptr">:
+ $bodyBuilder,
+ CArg<"bool", "true">:$failOnPayloadReplacementNotFound)>,
+ ];
+
let extraClassDeclaration = [{
::mlir::DiagnosedSilenceableFailure applyToOne(
::mlir::Operation *target,
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index e2029560e67ee..69d0b2b20307b 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -477,6 +477,22 @@ void transform::ApplyPatternsOp::getEffects(
transform::modifiesPayload(effects);
}
+void transform::ApplyPatternsOp::build(
+ OpBuilder &builder, OperationState &result, Value target,
+ function_ref<void(OpBuilder &, Location)> bodyBuilder,
+ bool failOnPayloadReplacementNotFound) {
+ result.addOperands(target);
+ result.getOrAddProperties<Properties>()
+ .fail_on_payload_replacement_not_found =
+ builder.getBoolAttr(failOnPayloadReplacementNotFound);
+
+ OpBuilder::InsertionGuard g(builder);
+ Region *region = result.addRegion();
+ builder.createBlock(region);
+ if (bodyBuilder)
+ bodyBuilder(builder, result.location);
+}
+
//===----------------------------------------------------------------------===//
// ApplyCanonicalizationPatternsOp
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list