From 456efbc0f14d8d145d19eaa046f3c1b49b1bf4c8 Mon Sep 17 00:00:00 2001 From: Frederik Gossen Date: Mon, 3 May 2021 21:05:43 +0200 Subject: [PATCH] [MLIR][Linalg] Avoid forward declaration in `Loops.cpp` Differential Revision: https://reviews.llvm.org/D101771 --- mlir/lib/Dialect/Linalg/Transforms/Loops.cpp | 28 +++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp index f03e590bbde3..aa0297fdab7d 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -590,22 +590,6 @@ struct TiledLoopToSCFPattern : public OpRewritePattern { } }; -struct FoldAffineOp; -} // namespace - -template -static void lowerLinalgToLoopsImpl(FuncOp funcOp) { - MLIRContext *context = funcOp.getContext(); - RewritePatternSet patterns(context); - patterns.add>(context); - memref::DimOp::getCanonicalizationPatterns(patterns, context); - AffineApplyOp::getCanonicalizationPatterns(patterns, context); - patterns.add(context); - // Just apply the patterns greedily. - (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns)); -} - -namespace { /// Local folding pattern for AffineApplyOp that we can apply greedily. /// This replaces AffineApplyOp by the proper value in cases where the /// associated map is trivial. @@ -643,6 +627,18 @@ struct FoldAffineOp : public RewritePattern { } }; +template +static void lowerLinalgToLoopsImpl(FuncOp funcOp) { + MLIRContext *context = funcOp.getContext(); + RewritePatternSet patterns(context); + patterns.add>(context); + memref::DimOp::getCanonicalizationPatterns(patterns, context); + AffineApplyOp::getCanonicalizationPatterns(patterns, context); + patterns.add(context); + // Just apply the patterns greedily. + (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns)); +} + struct LowerToAffineLoops : public LinalgLowerToAffineLoopsBase { void getDependentDialects(DialectRegistry ®istry) const override {