15#ifndef MLIR_DIALECT_AFFINE_LOOPFUSIONUTILS_H
16#define MLIR_DIALECT_AFFINE_LOOPFUSIONUTILS_H
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/ADT/SmallVector.h"
77 "Sibling fusion strategy requires a specific memref");
89 assert(strategy ==
Sibling &&
"Memref is only valid for sibling fusion");
95 StrategyEnum strategy;
110canFuseLoops(AffineForOp srcForOp, AffineForOp dstForOp,
unsigned dstLoopDepth,
111 ComputationSliceState *srcSlice,
118void fuseLoops(AffineForOp srcForOp, AffineForOp dstForOp,
119 const ComputationSliceState &srcSlice,
120 bool isInnermostSiblingInsertionFusion =
false);
Operation is the basic unit of execution within MLIR.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
StrategyEnum getStrategy() const
Returns the fusion strategy.
FusionStrategy(StrategyEnum strategy)
Construct a generic or producer-consumer fusion strategy.
FusionStrategy(Value memref)
Construct a sibling fusion strategy targeting 'memref'.
Value getSiblingFusionMemRef() const
Returns the memref attached to this sibling fusion strategy.
bool getFusionComputeCost(AffineForOp srcForOp, LoopNestStats &srcStats, AffineForOp dstForOp, LoopNestStats &dstStats, const ComputationSliceState &slice, int64_t *computeCost)
Computes and returns in 'computeCost', the total compute cost of fusing the 'slice' of the loop nest ...
void gatherProducerConsumerMemrefs(ArrayRef< Operation * > srcOps, ArrayRef< Operation * > dstOps, DenseSet< Value > &producerConsumerMemrefs)
Returns in 'producerConsumerMemrefs' the memrefs involved in a producer-consumer dependence between w...
int64_t getComputeCost(AffineForOp forOp, LoopNestStats &stats)
Computes the total cost of the loop nest rooted at 'forOp' using 'stats'.
void fuseLoops(AffineForOp srcForOp, AffineForOp dstForOp, const ComputationSliceState &srcSlice, bool isInnermostSiblingInsertionFusion=false)
Fuses 'srcForOp' into 'dstForOp' with destination loop block insertion point and source slice loop bo...
bool getLoopNestStats(AffineForOp forOp, LoopNestStats *stats)
Collect loop nest statistics (eg.
FusionResult canFuseLoops(AffineForOp srcForOp, AffineForOp dstForOp, unsigned dstLoopDepth, ComputationSliceState *srcSlice, FusionStrategy fusionStrategy=FusionStrategy::Generic)
Checks the feasibility of fusing the loop nest rooted at 'srcForOp' into the loop nest rooted at 'dst...
Include the generated interface declarations.
llvm::DenseSet< ValueT, ValueInfoT > DenseSet
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their associated operands for a ...
FusionResult(ResultEnum v)
enum mlir::affine::FusionResult::ResultEnum value
LoopNestStats aggregates various per-loop statistics (eg.
DenseMap< Operation *, uint64_t > opCountMap
Map from AffineForOp to count of operations in its loop body.
DenseMap< Operation *, SmallVector< AffineForOp, 2 > > loopMap
Map from AffineForOp to immediate child AffineForOps in its loop body.
DenseMap< Operation *, uint64_t > tripCountMap
Map from AffineForOp to its constant trip count.