diff options
| author | River Riddle <riverriddle@google.com> | 2019-02-01 16:42:18 -0800 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 16:06:49 -0700 |
| commit | 5052bd8582fbcfc0a4774c34141c2dd04b333613 (patch) | |
| tree | 845641f175aee8c535a4d7deb43e5c854f07add4 /mlir/lib/Analysis/AffineAnalysis.cpp | |
| parent | e0774c008fdcee1d4007ede4fde4cf7ad83cfda8 (diff) | |
| download | bcm5719-llvm-5052bd8582fbcfc0a4774c34141c2dd04b333613.tar.gz bcm5719-llvm-5052bd8582fbcfc0a4774c34141c2dd04b333613.zip | |
Define the AffineForOp and replace ForInst with it. This patch is largely mechanical, i.e. changing usages of ForInst to OpPointer<AffineForOp>. An important difference is that upon construction an AffineForOp no longer automatically creates the body and induction variable. To generate the body/iv, 'createBody' can be called on an AffineForOp with no body.
PiperOrigin-RevId: 232060516
Diffstat (limited to 'mlir/lib/Analysis/AffineAnalysis.cpp')
| -rw-r--r-- | mlir/lib/Analysis/AffineAnalysis.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 0153546a4c6..d2366f1ce81 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -21,12 +21,14 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/AffineAnalysis.h" +#include "mlir/AffineOps/AffineOps.h" #include "mlir/Analysis/AffineStructures.h" #include "mlir/Analysis/Utils.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Instructions.h" +#include "mlir/IR/IntegerSet.h" #include "mlir/StandardOps/StandardOps.h" #include "mlir/Support/MathExtras.h" #include "mlir/Support/STLExtras.h" @@ -519,7 +521,7 @@ void mlir::getReachableAffineApplyOps( State &state = worklist.back(); auto *opInst = state.value->getDefiningInst(); // Note: getDefiningInst will return nullptr if the operand is not an - // OperationInst (i.e. ForInst), which is a terminator for the search. + // OperationInst (i.e. AffineForOp), which is a terminator for the search. if (opInst == nullptr || !opInst->isa<AffineApplyOp>()) { worklist.pop_back(); continue; @@ -546,21 +548,21 @@ void mlir::getReachableAffineApplyOps( } // Builds a system of constraints with dimensional identifiers corresponding to -// the loop IVs of the forInsts appearing in that order. Any symbols founds in +// the loop IVs of the forOps appearing in that order. Any symbols founds in // the bound operands are added as symbols in the system. Returns false for the // yet unimplemented cases. // TODO(andydavis,bondhugula) Handle non-unit steps through local variables or // stride information in FlatAffineConstraints. (For eg., by using iv - lb % // step = 0 and/or by introducing a method in FlatAffineConstraints // setExprStride(ArrayRef<int64_t> expr, int64_t stride) -bool mlir::getIndexSet(ArrayRef<ForInst *> forInsts, +bool mlir::getIndexSet(MutableArrayRef<OpPointer<AffineForOp>> forOps, FlatAffineConstraints *domain) { - auto indices = extractForInductionVars(forInsts); + auto indices = extractForInductionVars(forOps); // Reset while associated Values in 'indices' to the domain. - domain->reset(forInsts.size(), /*numSymbols=*/0, /*numLocals=*/0, indices); - for (auto *forInst : forInsts) { - // Add constraints from forInst's bounds. - if (!domain->addForInstDomain(*forInst)) + domain->reset(forOps.size(), /*numSymbols=*/0, /*numLocals=*/0, indices); + for (auto forOp : forOps) { + // Add constraints from forOp's bounds. + if (!domain->addAffineForOpDomain(forOp)) return false; } return true; @@ -576,7 +578,7 @@ static bool getInstIndexSet(const Instruction *inst, FlatAffineConstraints *indexSet) { // TODO(andydavis) Extend this to gather enclosing IfInsts and consider // factoring it out into a utility function. - SmallVector<ForInst *, 4> loops; + SmallVector<OpPointer<AffineForOp>, 4> loops; getLoopIVs(*inst, &loops); return getIndexSet(loops, indexSet); } @@ -998,9 +1000,9 @@ static const Block *getCommonBlock(const MemRefAccess &srcAccess, return block; } auto *commonForValue = srcDomain.getIdValue(numCommonLoops - 1); - auto *forInst = getForInductionVarOwner(commonForValue); - assert(forInst && "commonForValue was not an induction variable"); - return forInst->getBody(); + auto forOp = getForInductionVarOwner(commonForValue); + assert(forOp && "commonForValue was not an induction variable"); + return forOp->getBody(); } // Returns true if the ancestor operation instruction of 'srcAccess' appears @@ -1195,7 +1197,7 @@ void MemRefAccess::getAccessMap(AffineValueMap *accessMap) const { // until operands of the AffineValueMap are loop IVs or symbols. // *) Build iteration domain constraints for each access. Iteration domain // constraints are pairs of inequality contraints representing the -// upper/lower loop bounds for each ForInst in the loop nest associated +// upper/lower loop bounds for each AffineForOp in the loop nest associated // with each access. // *) Build dimension and symbol position maps for each access, which map // Values from access functions and iteration domains to their position |

