-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[mlir][nfc] Remove TrivialPatternRewriter
s
#155248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-mlir-linalg Author: Ivan Butygin (Hardcode84) ChangesThese are relics from the times when Full diff: https://github.com/llvm/llvm-project/pull/155248.diff 3 Files Affected:
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 639e0feabc9bd..f0c1f4485b054 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -70,12 +70,7 @@ static FailureOr<LinalgOp> tryApply(Operation *operation, Args &&...args) {
PatternTy pattern(operation->getContext(), std::forward<Args>(args)...);
// We want to discourage direct use of PatternRewriter in APIs but In this
// very specific case, an IRRewriter is not enough.
- struct TrivialPatternRewriter : public PatternRewriter {
- public:
- explicit TrivialPatternRewriter(MLIRContext *context)
- : PatternRewriter(context) {}
- };
- TrivialPatternRewriter rewriter(operation->getContext());
+ PatternRewriter rewriter(operation->getContext());
rewriter.setInsertionPoint(operation);
auto result = pattern.returningMatchAndRewrite(op, rewriter);
if (failed(result))
diff --git a/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp b/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
index 41955c8a278f2..3ced1a6582ce3 100644
--- a/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
+++ b/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
@@ -100,12 +100,7 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
PatternApplicator applicator(it->second);
// We want to discourage direct use of PatternRewriter in APIs but In this
// very specific case, an IRRewriter is not enough.
- struct TrivialPatternRewriter : public PatternRewriter {
- public:
- explicit TrivialPatternRewriter(MLIRContext *context)
- : PatternRewriter(context) {}
- };
- TrivialPatternRewriter rewriter(root->getContext());
+ PatternRewriter rewriter(root->getContext());
applicator.applyDefaultCostModel();
root->walk([&](Operation *op) {
if (succeeded(applicator.matchAndRewrite(op, rewriter)))
diff --git a/mlir/unittests/Rewrite/PatternBenefit.cpp b/mlir/unittests/Rewrite/PatternBenefit.cpp
index 65ea4ee6683db..e4363f9f4b8bb 100644
--- a/mlir/unittests/Rewrite/PatternBenefit.cpp
+++ b/mlir/unittests/Rewrite/PatternBenefit.cpp
@@ -66,12 +66,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
PatternApplicator pa(frozenPatterns);
pa.applyDefaultCostModel();
- class MyPatternRewriter : public PatternRewriter {
- public:
- MyPatternRewriter(MLIRContext *ctx) : PatternRewriter(ctx) {}
- };
-
- MyPatternRewriter rewriter(&context);
+ PatternRewriter rewriter(&context);
(void)pa.matchAndRewrite(*module, rewriter);
EXPECT_TRUE(called1);
|
@llvm/pr-subscribers-mlir Author: Ivan Butygin (Hardcode84) ChangesThese are relics from the times when Full diff: https://github.com/llvm/llvm-project/pull/155248.diff 3 Files Affected:
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 639e0feabc9bd..f0c1f4485b054 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -70,12 +70,7 @@ static FailureOr<LinalgOp> tryApply(Operation *operation, Args &&...args) {
PatternTy pattern(operation->getContext(), std::forward<Args>(args)...);
// We want to discourage direct use of PatternRewriter in APIs but In this
// very specific case, an IRRewriter is not enough.
- struct TrivialPatternRewriter : public PatternRewriter {
- public:
- explicit TrivialPatternRewriter(MLIRContext *context)
- : PatternRewriter(context) {}
- };
- TrivialPatternRewriter rewriter(operation->getContext());
+ PatternRewriter rewriter(operation->getContext());
rewriter.setInsertionPoint(operation);
auto result = pattern.returningMatchAndRewrite(op, rewriter);
if (failed(result))
diff --git a/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp b/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
index 41955c8a278f2..3ced1a6582ce3 100644
--- a/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
+++ b/mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp
@@ -100,12 +100,7 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
PatternApplicator applicator(it->second);
// We want to discourage direct use of PatternRewriter in APIs but In this
// very specific case, an IRRewriter is not enough.
- struct TrivialPatternRewriter : public PatternRewriter {
- public:
- explicit TrivialPatternRewriter(MLIRContext *context)
- : PatternRewriter(context) {}
- };
- TrivialPatternRewriter rewriter(root->getContext());
+ PatternRewriter rewriter(root->getContext());
applicator.applyDefaultCostModel();
root->walk([&](Operation *op) {
if (succeeded(applicator.matchAndRewrite(op, rewriter)))
diff --git a/mlir/unittests/Rewrite/PatternBenefit.cpp b/mlir/unittests/Rewrite/PatternBenefit.cpp
index 65ea4ee6683db..e4363f9f4b8bb 100644
--- a/mlir/unittests/Rewrite/PatternBenefit.cpp
+++ b/mlir/unittests/Rewrite/PatternBenefit.cpp
@@ -66,12 +66,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
PatternApplicator pa(frozenPatterns);
pa.applyDefaultCostModel();
- class MyPatternRewriter : public PatternRewriter {
- public:
- MyPatternRewriter(MLIRContext *ctx) : PatternRewriter(ctx) {}
- };
-
- MyPatternRewriter rewriter(&context);
+ PatternRewriter rewriter(&context);
(void)pa.matchAndRewrite(*module, rewriter);
EXPECT_TRUE(called1);
|
@Hardcode84 there's also |
These are relics from the times when
PatternRewriter
was not instantiable directly, I suppose.