24 #define GEN_PASS_DEF_CONTROLFLOWSINK
25 #include "mlir/Transforms/Passes.h.inc"
32 struct ControlFlowSink :
public impl::ControlFlowSinkBase<ControlFlowSink> {
33 void runOnOperation()
override;
37 void ControlFlowSink::runOnOperation() {
38 auto &domInfo = getAnalysis<DominanceInfo>();
39 getOperation()->walk([&](RegionBranchOpInterface branch) {
45 regionsToSink, domInfo,
51 op->
moveBefore(®ion->front(), region->front().begin());
57 return std::make_unique<ControlFlowSink>();
Operation is the basic unit of execution within MLIR.
void moveBefore(Operation *existingOp)
Unlink this operation from its current block and insert it right before existingOp which may be in th...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Include the generated interface declarations.
void getSinglyExecutedRegionsToSink(RegionBranchOpInterface branch, SmallVectorImpl< Region * > ®ions)
Populates regions with regions of the provided region branch op that are executed at most once at tha...
bool isMemoryEffectFree(Operation *op)
Returns true if the given operation is free of memory effects.
std::unique_ptr< Pass > createControlFlowSinkPass()
Creates a pass to perform control-flow sinking.
size_t controlFlowSink(RegionRange regions, DominanceInfo &domInfo, function_ref< bool(Operation *, Region *)> shouldMoveIntoRegion, function_ref< void(Operation *, Region *)> moveIntoRegion)
Given a list of regions, perform control flow sinking on them.