20 #define GEN_PASS_DEF_SCFFORALLTOFORLOOP
21 #include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
41 loopNest.
loops, [](scf::ForOp loop) { return loop.getInductionVar(); });
43 Block *innermostBlock = loopNest.
loops.back().getBody();
44 rewriter.
eraseOp(forallOp.getBody()->getTerminator());
51 llvm::move(loopNest.
loops, std::back_inserter(*results));
58 struct ForallToForLoop :
public impl::SCFForallToForLoopBase<ForallToForLoop> {
59 void runOnOperation()
override {
63 parentOp->
walk([&](scf::ForallOp forallOp) {
65 return signalPassFailure();
73 return std::make_unique<ForallToForLoop>();
Block represents an ordered list of Operations.
Operation * getTerminator()
Get the terminator operation of this block.
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
RAII guard to reset the insertion point of the builder when destroyed.
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
Operation is the basic unit of execution within MLIR.
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
MLIRContext * getContext()
Return the context this operation is associated with.
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
virtual void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, ValueRange argValues=std::nullopt)
Inline the operations of block 'source' into block 'dest' before the given position.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
LogicalResult forallToForLoop(RewriterBase &rewriter, ForallOp forallOp, SmallVectorImpl< Operation * > *results=nullptr)
Try converting scf.forall into a set of nested scf.for loops.
LoopNest buildLoopNest(OpBuilder &builder, Location loc, ValueRange lbs, ValueRange ubs, ValueRange steps, ValueRange iterArgs, function_ref< ValueVector(OpBuilder &, Location, ValueRange, ValueRange)> bodyBuilder=nullptr)
Creates a perfect nest of "for" loops, i.e.
Include the generated interface declarations.
std::unique_ptr< Pass > createForallToForLoopPass()
Creates a pass that converts SCF forall loops to SCF for loops.