MLIR 22.0.0git
Utils.h File Reference
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/STLExtras.h"
#include <optional>

Go to the source code of this file.

Classes

struct  mlir::UnrolledLoopInfo

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::func

Typedefs

using mlir::Loops = SmallVector<scf::ForOp, 8>
 Tile a nest of standard for loops rooted at rootForOp by finding such parametric tile sizes that the outer loops have a fixed number of iterations as defined in sizes.
using mlir::TileLoops = std::pair<Loops, Loops>

Functions

SmallVector< scf::ForOp > mlir::replaceLoopNestWithNewYields (RewriterBase &rewriter, MutableArrayRef< scf::ForOp > loopNest, ValueRange newIterOperands, const NewYieldValuesFn &newYieldValuesFn, bool replaceIterOperandsUsesInLoop=true)
 Update a perfectly nested loop nest to yield new values from the innermost loop and propagating it up through the loop nest.
FailureOr< func::FuncOp > mlir::outlineSingleBlockRegion (RewriterBase &rewriter, Location loc, Region &region, StringRef funcName, func::CallOp *callOp=nullptr)
 Outline a region with a single block into a new FuncOp.
LogicalResult mlir::outlineIfOp (RewriterBase &b, scf::IfOp ifOp, func::FuncOp *thenFn, StringRef thenFnName, func::FuncOp *elseFn, StringRef elseFnName)
 Outline the then and/or else regions of ifOp as follows:
bool mlir::getInnermostParallelLoops (Operation *rootOp, SmallVectorImpl< scf::ParallelOp > &result)
 Get a list of innermost parallel loops contained in rootOp.
std::optional< std::pair< AffineExpr, AffineExpr > > mlir::getSCFMinMaxExpr (Value value, SmallVectorImpl< Value > &dims, SmallVectorImpl< Value > &symbols, llvm::function_ref< bool(Operation *)> loopFilter=nullptr)
 Return the min/max expressions for value if it is an induction variable from scf.for or scf.parallel loop.
LogicalResult mlir::coalesceLoops (MutableArrayRef< scf::ForOp > loops)
 Replace a perfect nest of "for" loops with a single linearized loop.
LogicalResult mlir::coalesceLoops (RewriterBase &rewriter, MutableArrayRef< scf::ForOp >)
LogicalResult mlir::coalescePerfectlyNestedSCFForLoops (scf::ForOp op)
 Walk an affine.for to find a band to coalesce.
void mlir::collapseParallelLoops (RewriterBase &rewriter, scf::ParallelOp loops, ArrayRef< std::vector< unsigned > > combinedDimensions)
 Take the ParallelLoop and for each set of dimension indices, combine them into a single dimension.
FailureOr< UnrolledLoopInfomlir::loopUnrollByFactor (scf::ForOp forOp, uint64_t unrollFactor, function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn=nullptr)
 Unrolls this for operation by the specified unroll factor.
LogicalResult mlir::loopUnrollFull (scf::ForOp forOp)
 Unrolls this loop completely.
LogicalResult mlir::loopUnrollJamByFactor (scf::ForOp forOp, uint64_t unrollFactor)
 Unrolls and jams this scf.for operation by the specified unroll factor.
Range mlir::emitNormalizedLoopBounds (RewriterBase &rewriter, Location loc, OpFoldResult lb, OpFoldResult ub, OpFoldResult step)
 Materialize bounds and step of a zero-based and unit-step loop derived by normalizing the specified bounds and step.
void mlir::denormalizeInductionVariable (RewriterBase &rewriter, Location loc, Value normalizedIv, OpFoldResult origLb, OpFoldResult origStep)
 Get back the original induction variable values after loop normalization.
TileLoops mlir::extractFixedOuterLoops (scf::ForOp rootFOrOp, ArrayRef< int64_t > sizes)
SmallVector< Loops, 8 > mlir::tile (ArrayRef< scf::ForOp > forOps, ArrayRef< Value > sizes, ArrayRef< scf::ForOp > targets)
 Performs tiling fo imperfectly nested loops (with interchange) by strip-mining the forOps by sizes and sinking them, in their order of occurrence in forOps, under each of the targets.
Loops mlir::tile (ArrayRef< scf::ForOp > forOps, ArrayRef< Value > sizes, scf::ForOp target)
 Performs tiling (with interchange) by strip-mining the forOps by sizes and sinking them, in their order of occurrence in forOps, under target.
Loops mlir::tilePerfectlyNested (scf::ForOp rootForOp, ArrayRef< Value > sizes)
 Tile a nest of scf::ForOp loops rooted at rootForOp with the given (parametric) sizes.
void mlir::getPerfectlyNestedLoops (SmallVectorImpl< scf::ForOp > &nestedLoops, scf::ForOp root)
 Get perfectly nested sequence of loops starting at root of loop nest (the first op being another AffineFor, and the second op - a terminator).
scf::ForallOp mlir::fuseIndependentSiblingForallLoops (scf::ForallOp target, scf::ForallOp source, RewriterBase &rewriter)
 Given two scf.forall loops, target and source, fuses target into source.
scf::ForOp mlir::fuseIndependentSiblingForLoops (scf::ForOp target, scf::ForOp source, RewriterBase &rewriter)
 Given two scf.for loops, target and source, fuses target into source.
FailureOr< scf::ForallOp > mlir::normalizeForallOp (RewriterBase &rewriter, scf::ForallOp forallOp)
 Normalize an scf.forall operation.
bool mlir::isPerfectlyNestedForLoops (MutableArrayRef< LoopLikeOpInterface > loops)
 Check if the provided loops are perfectly nested for-loops.
void mlir::generateUnrolledLoop (Block *loopBodyBlock, Value iv, uint64_t unrollFactor, function_ref< Value(unsigned, Value, OpBuilder)> ivRemapFn, function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn, ValueRange iterArgs, ValueRange yieldedValues, IRMapping *clonedToSrcOpsMap=nullptr)
 Generate unrolled copies of an scf loop's 'loopBodyBlock', with 'iterArgs' and 'yieldedValues' as the block arguments and yielded values of the loop.
FailureOr< scf::ParallelOp > mlir::parallelLoopUnrollByFactors (scf::ParallelOp op, ArrayRef< uint64_t > unrollFactors, RewriterBase &rewriter, function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn=nullptr, IRMapping *clonedToSrcOpsMap=nullptr)
 Unroll this scf::Parallel loop by the specified unroll factors.
llvm::SmallVector< int64_tmlir::getConstLoopTripCounts (mlir::LoopLikeOpInterface loopOp)
 Get constant trip counts for each of the induction variables of the given loop operation.