llvm-project/mlir/lib/Transforms/TopologicalSort.cpp
Michele Scuttari 039b969b32
Revert "[MLIR] Update pass declarations to new autogenerated files"
This reverts commit 2be8af8f0e0780901213b6fd3013a5268ddc3359.
2022-08-30 22:21:55 +02:00

34 lines
1.1 KiB
C++

//===- TopologicalSort.cpp - Topological sort pass ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "PassDetail.h"
#include "mlir/IR/RegionKindInterface.h"
#include "mlir/Transforms/TopologicalSortUtils.h"
using namespace mlir;
namespace {
struct TopologicalSortPass : public TopologicalSortBase<TopologicalSortPass> {
void runOnOperation() override {
// Topologically sort the regions of the operation without SSA dominance.
getOperation()->walk([](RegionKindInterface op) {
for (auto &it : llvm::enumerate(op->getRegions())) {
if (op.hasSSADominance(it.index()))
continue;
for (Block &block : it.value())
sortTopologically(&block);
}
});
}
};
} // end anonymous namespace
std::unique_ptr<Pass> mlir::createTopologicalSortPass() {
return std::make_unique<TopologicalSortPass>();
}