Skip to content

Commit 02540b2

Browse files
authored
[mlir][nfc] Remove TrivialPatternRewriters (#155248)
These are relics from the times when `PatternRewriter` was not instantiable directly, I suppose.
1 parent 7dbdb66 commit 02540b2

File tree

4 files changed

+4
-25
lines changed

4 files changed

+4
-25
lines changed

flang/lib/Optimizer/Transforms/SimplifyRegionLite.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,16 @@ class SimplifyRegionLitePass
2626
public:
2727
void runOnOperation() override;
2828
};
29-
30-
class DummyRewriter : public mlir::PatternRewriter {
31-
public:
32-
DummyRewriter(mlir::MLIRContext *ctx) : mlir::PatternRewriter(ctx) {}
33-
};
34-
3529
} // namespace
3630

3731
void SimplifyRegionLitePass::runOnOperation() {
3832
auto op = getOperation();
3933
auto regions = op->getRegions();
4034
mlir::RewritePatternSet patterns(op.getContext());
41-
DummyRewriter rewriter(op.getContext());
4235
if (regions.empty())
4336
return;
4437

38+
mlir::PatternRewriter rewriter(op.getContext());
4539
(void)mlir::eraseUnreachableBlocks(rewriter, regions);
4640
(void)mlir::runRegionDCE(rewriter, regions);
4741
}

mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ static FailureOr<LinalgOp> tryApply(Operation *operation, Args &&...args) {
7070
PatternTy pattern(operation->getContext(), std::forward<Args>(args)...);
7171
// We want to discourage direct use of PatternRewriter in APIs but In this
7272
// very specific case, an IRRewriter is not enough.
73-
struct TrivialPatternRewriter : public PatternRewriter {
74-
public:
75-
explicit TrivialPatternRewriter(MLIRContext *context)
76-
: PatternRewriter(context) {}
77-
};
78-
TrivialPatternRewriter rewriter(operation->getContext());
73+
PatternRewriter rewriter(operation->getContext());
7974
rewriter.setInsertionPoint(operation);
8075
auto result = pattern.returningMatchAndRewrite(op, rewriter);
8176
if (failed(result))

mlir/lib/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ LogicalResult PatternApplicatorExtension::findAllMatches(
100100
PatternApplicator applicator(it->second);
101101
// We want to discourage direct use of PatternRewriter in APIs but In this
102102
// very specific case, an IRRewriter is not enough.
103-
struct TrivialPatternRewriter : public PatternRewriter {
104-
public:
105-
explicit TrivialPatternRewriter(MLIRContext *context)
106-
: PatternRewriter(context) {}
107-
};
108-
TrivialPatternRewriter rewriter(root->getContext());
103+
PatternRewriter rewriter(root->getContext());
109104
applicator.applyDefaultCostModel();
110105
root->walk([&](Operation *op) {
111106
if (succeeded(applicator.matchAndRewrite(op, rewriter)))

mlir/unittests/Rewrite/PatternBenefit.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
6666
PatternApplicator pa(frozenPatterns);
6767
pa.applyDefaultCostModel();
6868

69-
class MyPatternRewriter : public PatternRewriter {
70-
public:
71-
MyPatternRewriter(MLIRContext *ctx) : PatternRewriter(ctx) {}
72-
};
73-
74-
MyPatternRewriter rewriter(&context);
69+
PatternRewriter rewriter(&context);
7570
(void)pa.matchAndRewrite(*module, rewriter);
7671

7772
EXPECT_TRUE(called1);

0 commit comments

Comments
 (0)