#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 {
getOperation()->walk([](RegionKindInterface op) {
for (auto &it : llvm::enumerate(op->getRegions())) {
if (op.hasSSADominance(it.index()))
continue;
for (Block &block : it.value())
sortTopologically(&block);
}
});
}
};
}
std::unique_ptr<Pass> mlir::createTopologicalSortPass() {
return std::make_unique<TopologicalSortPass>();
}