16 #ifndef MLIR_DIALECT_AFFINE_ANALYSIS_UTILS_H 17 #define MLIR_DIALECT_AFFINE_ANALYSIS_UTILS_H 24 #include "llvm/ADT/SmallVector.h" 39 void getLoopIVs(Operation &op, SmallVectorImpl<AffineForOp> *loops);
45 SmallVectorImpl<Operation *> *ops);
57 llvm::SmallDenseSet<Value, 8> *sequentialLoops);
186 unsigned loopDepth,
bool isBackwardSlice,
191 const llvm::SmallDenseMap<Operation *, uint64_t, 8> &sliceTripCountMap);
199 llvm::SmallDenseMap<Operation *, uint64_t, 8> *tripCountMap);
215 unsigned loopDepth,
unsigned numCommonLoops,
230 unsigned dstLoopDepth,
284 bool addMemRefDimBounds =
true);
308 void getLowerAndUpperBound(
unsigned pos,
AffineMap &lbMap,
318 int64_t *lbFloorDivisor =
nullptr)
const {
319 assert(pos < getRank() &&
"invalid position");
320 return cst.getConstantBoundOnDimSize(pos, lb);
330 unsigned getRank()
const;
360 template <
typename LoadOrStoreOpPo
inter>
370 int memorySpace = -1);
385 #endif // MLIR_DIALECT_AFFINE_ANALYSIS_UTILS_H Include the generated interface declarations.
Operation is a basic unit of execution within MLIR.
SmallVector< Value, 4 > ivs
SliceComputationResult(ResultEnum v)
Optional< int64_t > getMemoryFootprintBytes(AffineForOp forOp, int memorySpace=-1)
Gets the memory footprint of all data touched in the specified memory space in bytes; if the memory s...
bool isLoopParallelAndContainsReduction(AffineForOp forOp)
Returns whether a loop is a parallel loop and contains a reduction loop.
bool buildSliceTripCountMap(const ComputationSliceState &slice, llvm::SmallDenseMap< Operation *, uint64_t, 8 > *tripCountMap)
Builds a map 'tripCountMap' from AffineForOp to constant trip count for loop nest surrounding represe...
void getLoopIVs(Operation &op, SmallVectorImpl< AffineForOp > *loops)
Populates 'loops' with IVs of the loops surrounding 'op' ordered from the outermost 'affine...
unsigned getNumCommonSurroundingLoops(Operation &a, Operation &b)
Returns the number of surrounding loops common to both A and B.
bool isEmpty() const
Returns true if the computation slice is empty.
Enumerates different result statuses of slice computation by computeSliceUnion
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
FlatAffineValueConstraints cst
Region (data space) of the memref accessed.
Optional< uint64_t > getMemRefSizeInBytes(MemRefType memRefType)
Returns the size of memref data in bytes if it's statically shaped, None otherwise.
unsigned getInnermostCommonLoopDepth(ArrayRef< Operation *> ops, SmallVectorImpl< AffineForOp > *surroundingLoops=nullptr)
Returns the innermost common loop depth for the set of operations in 'ops'.
This class represents an efficient way to signal success or failure.
OpListType::iterator iterator
ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their associated operands for a ...
SmallVector< AffineMap, 4 > lbs
Location loc
If there is more than one load/store op associated with the region, the location information would co...
Block::iterator insertPoint
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued...
MemRefRegion(Location loc)
void getSequentialLoops(AffineForOp forOp, llvm::SmallDenseSet< Value, 8 > *sequentialLoops)
Returns in 'sequentialLoops' all sequential loops in loop nest rooted at 'forOp'. ...
FlatAffineValueConstraints * getConstraints()
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
SmallVector< AffineMap, 4 > ubs
const FlatAffineValueConstraints * getConstraints() const
SliceComputationResult computeSliceUnion(ArrayRef< Operation *> opsA, ArrayRef< Operation *> opsB, unsigned loopDepth, unsigned numCommonLoops, bool isBackwardSlice, ComputationSliceState *sliceUnion)
Computes in 'sliceUnion' the union of all slice bounds computed at 'loopDepth' between all dependent ...
void getComputationSliceState(Operation *depSourceOp, Operation *depSinkOp, FlatAffineValueConstraints *dependenceConstraints, unsigned loopDepth, bool isBackwardSlice, ComputationSliceState *sliceState)
Computes the computation slice loop bounds for one loop nest as affine maps of the other loop nest's ...
void getEnclosingAffineForAndIfOps(Operation &op, SmallVectorImpl< Operation *> *ops)
Populates 'ops' with IVs of the loops surrounding op, along with affine.if operations interleaved bet...
LogicalResult boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp, bool emitError=true)
Checks a load or store op for an out of bound access; returns failure if the access is out of bounds ...
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
std::vector< SmallVector< Value, 4 > > ubOperands
FlatAffineValueConstraints represents an extension of IntegerPolyhedron where each non-local variable...
uint64_t getSliceIterationCount(const llvm::SmallDenseMap< Operation *, uint64_t, 8 > &sliceTripCountMap)
Return the number of iterations for the slicetripCountMap provided.
enum mlir::SliceComputationResult::ResultEnum value
AffineForOp insertBackwardComputationSlice(Operation *srcOpInst, Operation *dstOpInst, unsigned dstLoopDepth, ComputationSliceState *sliceState)
Creates a clone of the computation contained in the loop nest surrounding 'srcOpInst', slices the iteration space of src loop based on slice bounds in 'sliceState', and inserts the computation slice at the beginning of the operation block of the loop at 'dstLoopDepth' in the loop nest surrounding 'dstOpInst'.
Value memref
Memref that this region corresponds to.
unsigned getNestingDepth(Operation *op)
Returns the nesting depth of this operation, i.e., the number of loops surrounding this operation...
A region of a memref's data space; this is typically constructed by analyzing load/store op's on this...
std::vector< SmallVector< Value, 4 > > lbOperands
IntegerSet simplifyIntegerSet(IntegerSet set)
Simplify the integer set by simplifying the underlying affine expressions by flattening and some simp...
Optional< int64_t > getConstantBoundOnDimSize(unsigned pos, SmallVectorImpl< int64_t > *lb=nullptr, int64_t *lbFloorDivisor=nullptr) const
A wrapper around FlatAffineValueConstraints::getConstantBoundOnDimSize().
An integer set representing a conjunction of one or more affine equalities and inequalities.