19 #define GEN_PASS_DEF_SCFFORALLTOPARALLELLOOP
20 #include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
26 scf::ForallOp forallOp,
27 scf::ParallelOp *result) {
32 if (!forallOp.getOutputs().empty())
35 "only fully bufferized scf.forall ops can be lowered to scf.parallel");
43 auto parallelOp = rewriter.
create<scf::ParallelOp>(loc, lbs, ubs, steps);
44 rewriter.
eraseBlock(¶llelOp.getRegion().front());
46 parallelOp.getRegion().begin());
50 parallelOp.getRegion().front().getTerminator());
53 if (forallOp.getMapping())
54 parallelOp->setAttr(
"mapping", *forallOp.getMapping());
66 struct ForallToParallelLoop final
67 :
public impl::SCFForallToParallelLoopBase<ForallToParallelLoop> {
68 void runOnOperation()
override {
72 parentOp->
walk([&](scf::ForallOp forallOp) {
74 return signalPassFailure();
82 return std::make_unique<ForallToParallelLoop>();
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.
void setInsertionPointToEnd(Block *block)
Sets the insertion point to the end of the specified block.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
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...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
virtual void eraseBlock(Block *block)
This method erases all operations in a block.
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
LogicalResult forallToParallelLoop(RewriterBase &rewriter, ForallOp forallOp, ParallelOp *result=nullptr)
Try converting scf.forall into an scf.parallel loop.
Include the generated interface declarations.
std::unique_ptr< Pass > createForallToParallelLoopPass()
Creates a pass that converts SCF forall loops to SCF parallel loops.