MLIR 22.0.0git
LoopCoalescing.cpp
Go to the documentation of this file.
1//===- LoopCoalescing.cpp - Pass transforming loop nests into single loops-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
16
17namespace mlir {
18namespace affine {
19#define GEN_PASS_DEF_LOOPCOALESCING
20#include "mlir/Dialect/Affine/Passes.h.inc"
21} // namespace affine
22} // namespace mlir
23
24#define PASS_NAME "loop-coalescing"
25#define DEBUG_TYPE PASS_NAME
26
27using namespace mlir;
28using namespace mlir::affine;
29
30namespace {
31struct LoopCoalescingPass
32 : public affine::impl::LoopCoalescingBase<LoopCoalescingPass> {
33
34 void runOnOperation() override {
35 func::FuncOp func = getOperation();
36 func.walk<WalkOrder::PreOrder>([](Operation *op) {
37 if (auto scfForOp = dyn_cast<scf::ForOp>(op))
39 else if (auto affineForOp = dyn_cast<AffineForOp>(op))
40 (void)coalescePerfectlyNestedAffineLoops(affineForOp);
41 });
42 }
43};
44
45} // namespace
46
47std::unique_ptr<OperationPass<func::FuncOp>>
49 return std::make_unique<LoopCoalescingPass>();
50}
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
std::unique_ptr< OperationPass< func::FuncOp > > createLoopCoalescingPass()
Creates a pass that transforms perfectly nested loops with independent bounds into a single loop.
Include the generated interface declarations.
LogicalResult coalescePerfectlyNestedSCFForLoops(scf::ForOp op)
Walk an affine.for to find a band to coalesce.
Definition Utils.cpp:994