MLIR
23.0.0git
lib
Transforms
TopologicalSort.cpp
Go to the documentation of this file.
1
//===- TopologicalSort.cpp - Topological sort pass ------------------------===//
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
9
#include "
mlir/Transforms/Passes.h
"
10
11
#include "
mlir/Analysis/TopologicalSortUtils.h
"
12
#include "
mlir/IR/RegionKindInterface.h
"
13
14
namespace
mlir
{
15
#define GEN_PASS_DEF_TOPOLOGICALSORTPASS
16
#include "mlir/Transforms/Passes.h.inc"
17
}
// namespace mlir
18
19
using namespace
mlir
;
20
21
namespace
{
22
struct
TopologicalSortPass
23
:
public
impl::TopologicalSortPassBase<TopologicalSortPass> {
24
void
runOnOperation()
override
{
25
// Topologically sort the regions of the operation without SSA dominance.
26
getOperation()->walk([](RegionKindInterface op) {
27
for
(
auto
it : llvm::enumerate(op->getRegions())) {
28
if
(op.hasSSADominance(it.index()))
29
continue
;
30
for
(
Block
&block : it.value())
31
sortTopologically
(&block);
32
}
33
});
34
}
35
};
36
}
// end anonymous namespace
RegionKindInterface.h
TopologicalSortUtils.h
Passes.h
mlir
Include the generated interface declarations.
Definition
AliasAnalysis.h:19
mlir::HoistingKind::Block
@ Block
Definition
AllocationOpInterface.h:24
mlir::sortTopologically
bool sortTopologically(Block *block, iterator_range< Block::iterator > ops, function_ref< bool(Value, Operation *)> isOperandReady=nullptr)
Given a block, sort a range operations in said block in topological order.
Definition
TopologicalSortUtils.cpp:56
Generated on
for MLIR by
1.14.0