[mlir] Allow derived rewrite patterns to define a non-virtual initialize hook
This is a hook that allows for providing custom initialization of the pattern, e.g. if it has bounded recursion, setting the debug name, etc., without needing to define a custom constructor. A non-virtual hook was chosen to avoid polluting the vtable with code that we really just want to be inlined when constructing the pattern. The alternative to this would be to just define a constructor for each pattern, this unfortunately creates a lot of otherwise unnecessary boiler plate for a lot of patterns and a hook provides a much simpler/cleaner interface for the very common case. Differential Revision: https://reviews.llvm.org/D102440
This commit is contained in:
@@ -935,8 +935,9 @@ public:
|
||||
class VectorInsertStridedSliceOpSameRankRewritePattern
|
||||
: public OpRewritePattern<InsertStridedSliceOp> {
|
||||
public:
|
||||
VectorInsertStridedSliceOpSameRankRewritePattern(MLIRContext *ctx)
|
||||
: OpRewritePattern<InsertStridedSliceOp>(ctx) {
|
||||
using OpRewritePattern<InsertStridedSliceOp>::OpRewritePattern;
|
||||
|
||||
void initialize() {
|
||||
// This pattern creates recursive InsertStridedSliceOp, but the recursion is
|
||||
// bounded as the rank is strictly decreasing.
|
||||
setHasBoundedRewriteRecursion();
|
||||
@@ -1330,8 +1331,9 @@ private:
|
||||
class VectorExtractStridedSliceOpConversion
|
||||
: public OpRewritePattern<ExtractStridedSliceOp> {
|
||||
public:
|
||||
VectorExtractStridedSliceOpConversion(MLIRContext *ctx)
|
||||
: OpRewritePattern<ExtractStridedSliceOp>(ctx) {
|
||||
using OpRewritePattern<ExtractStridedSliceOp>::OpRewritePattern;
|
||||
|
||||
void initialize() {
|
||||
// This pattern creates recursive ExtractStridedSliceOp, but the recursion
|
||||
// is bounded as the rank is strictly decreasing.
|
||||
setHasBoundedRewriteRecursion();
|
||||
|
||||
Reference in New Issue
Block a user