mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-27 15:14:31 +00:00
[mlir][Pattern] Refactor the Pattern class into a "metadata only" class
The Pattern class was originally intended to be used for solely matching operations, but that use never materialized. All of the pattern infrastructure uses RewritePattern, and the infrastructure for pure matching(Matchers.h) is implemented inline. This means that this class isn't a useful abstraction at the moment, so this revision refactors it to solely encapsulate the "metadata" of a pattern. The metadata includes the various state describing a pattern; benefit, root operation, etc. The API on PatternApplicator is updated to now operate on `Pattern`s as nothing special from `RewritePattern` is necessary. This refactoring is also necessary for the upcoming use of PDL patterns alongside C++ rewrite patterns. Differential Revision: https://reviews.llvm.org/D86258
This commit is contained in:
1 parent
8a1ca2cd34
commit
b99bd77162
6 files changed
+160
-158
No files matched your search
@@ -1042,7 +1042,12 @@ public:
|
||||
class VectorInsertStridedSliceOpSameRankRewritePattern
|
||||
: public OpRewritePattern<InsertStridedSliceOp> {
|
||||
public:
|
||||
using OpRewritePattern<InsertStridedSliceOp>::OpRewritePattern;
|
||||
VectorInsertStridedSliceOpSameRankRewritePattern(MLIRContext *ctx)
|
||||
: OpRewritePattern<InsertStridedSliceOp>(ctx) {
|
||||
// This pattern creates recursive InsertStridedSliceOp, but the recursion is
|
||||
// bounded as the rank is strictly decreasing.
|
||||
setHasBoundedRewriteRecursion();
|
||||
}
|
||||
|
||||
LogicalResult matchAndRewrite(InsertStridedSliceOp op,
|
||||
PatternRewriter &rewriter) const override {
|
||||
@@ -1093,9 +1098,6 @@ public:
|
||||
rewriter.replaceOp(op, res);
|
||||
return success();
|
||||
}
|
||||
/// This pattern creates recursive InsertStridedSliceOp, but the recursion is
|
||||
/// bounded as the rank is strictly decreasing.
|
||||
bool hasBoundedRewriteRecursion() const final { return true; }
|
||||
};
|
||||
|
||||
/// Returns the strides if the memory underlying `memRefType` has a contiguous
|
||||
@@ -1505,7 +1507,12 @@ private:
|
||||
class VectorExtractStridedSliceOpConversion
|
||||
: public OpRewritePattern<ExtractStridedSliceOp> {
|
||||
public:
|
||||
using OpRewritePattern<ExtractStridedSliceOp>::OpRewritePattern;
|
||||
VectorExtractStridedSliceOpConversion(MLIRContext *ctx)
|
||||
: OpRewritePattern<ExtractStridedSliceOp>(ctx) {
|
||||
// This pattern creates recursive ExtractStridedSliceOp, but the recursion
|
||||
// is bounded as the rank is strictly decreasing.
|
||||
setHasBoundedRewriteRecursion();
|
||||
}
|
||||
|
||||
LogicalResult matchAndRewrite(ExtractStridedSliceOp op,
|
||||
PatternRewriter &rewriter) const override {
|
||||
@@ -1552,9 +1559,6 @@ public:
|
||||
rewriter.replaceOp(op, res);
|
||||
return success();
|
||||
}
|
||||
/// This pattern creates recursive ExtractStridedSliceOp, but the recursion is
|
||||
/// bounded as the rank is strictly decreasing.
|
||||
bool hasBoundedRewriteRecursion() const final { return true; }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in new issue
Block a user