diff options
| author | Uday Bondhugula <bondhugula@google.com> | 2019-01-15 14:41:56 -0800 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 15:19:41 -0700 |
| commit | 03e15e1b9f84a7bed35ff4065ad7135b571d2d65 (patch) | |
| tree | a5fad41c04d17071289216969017d2aa452e0304 /mlir/lib/IR/BuiltinOps.cpp | |
| parent | b7dbfd04ebd80577f38f4922e857ad821b908ff1 (diff) | |
| download | bcm5719-llvm-03e15e1b9f84a7bed35ff4065ad7135b571d2d65.tar.gz bcm5719-llvm-03e15e1b9f84a7bed35ff4065ad7135b571d2d65.zip | |
Minor code cleanup - NFC.
- readability changes
PiperOrigin-RevId: 229443430
Diffstat (limited to 'mlir/lib/IR/BuiltinOps.cpp')
| -rw-r--r-- | mlir/lib/IR/BuiltinOps.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/mlir/lib/IR/BuiltinOps.cpp b/mlir/lib/IR/BuiltinOps.cpp index 94fa58139af..da570f4b805 100644 --- a/mlir/lib/IR/BuiltinOps.cpp +++ b/mlir/lib/IR/BuiltinOps.cpp @@ -198,61 +198,62 @@ struct SimplifyAffineApplyState : public PatternState { } // end anonymous namespace. void mlir::canonicalizeMapAndOperands( - AffineMap &map, llvm::SmallVectorImpl<Value *> &operands) { - if (!map || operands.empty()) + AffineMap *map, llvm::SmallVectorImpl<Value *> *operands) { + if (!map || operands->empty()) return; - assert(map.getNumInputs() == operands.size() && + assert(map->getNumInputs() == operands->size() && "map inputs must match number of operands"); // Check to see what dims are used. - llvm::SmallBitVector usedDims(map.getNumDims()); - llvm::SmallBitVector usedSyms(map.getNumSymbols()); - map.walkExprs([&](AffineExpr expr) { + llvm::SmallBitVector usedDims(map->getNumDims()); + llvm::SmallBitVector usedSyms(map->getNumSymbols()); + map->walkExprs([&](AffineExpr expr) { if (auto dimExpr = expr.dyn_cast<AffineDimExpr>()) usedDims[dimExpr.getPosition()] = true; else if (auto symExpr = expr.dyn_cast<AffineSymbolExpr>()) usedSyms[symExpr.getPosition()] = true; }); - auto *context = map.getContext(); + auto *context = map->getContext(); SmallVector<Value *, 8> resultOperands; - resultOperands.reserve(operands.size()); + resultOperands.reserve(operands->size()); llvm::SmallDenseMap<Value *, AffineExpr, 8> seenDims; - SmallVector<AffineExpr, 8> dimRemapping(map.getNumDims()); + SmallVector<AffineExpr, 8> dimRemapping(map->getNumDims()); unsigned nextDim = 0; - for (unsigned i = 0, e = map.getNumDims(); i != e; ++i) { + for (unsigned i = 0, e = map->getNumDims(); i != e; ++i) { if (usedDims[i]) { - auto it = seenDims.find(operands[i]); + auto it = seenDims.find((*operands)[i]); if (it == seenDims.end()) { dimRemapping[i] = getAffineDimExpr(nextDim++, context); - resultOperands.push_back(operands[i]); - seenDims.insert(std::make_pair(operands[i], dimRemapping[i])); + resultOperands.push_back((*operands)[i]); + seenDims.insert(std::make_pair((*operands)[i], dimRemapping[i])); } else { dimRemapping[i] = it->second; } } } llvm::SmallDenseMap<Value *, AffineExpr, 8> seenSymbols; - SmallVector<AffineExpr, 8> symRemapping(map.getNumSymbols()); + SmallVector<AffineExpr, 8> symRemapping(map->getNumSymbols()); unsigned nextSym = 0; - for (unsigned i = 0, e = map.getNumSymbols(); i != e; ++i) { + for (unsigned i = 0, e = map->getNumSymbols(); i != e; ++i) { if (usedSyms[i]) { - auto it = seenSymbols.find(operands[i + map.getNumDims()]); + auto it = seenSymbols.find((*operands)[i + map->getNumDims()]); if (it == seenSymbols.end()) { symRemapping[i] = getAffineSymbolExpr(nextSym++, context); - resultOperands.push_back(operands[i + map.getNumDims()]); - seenSymbols.insert( - std::make_pair(operands[i + map.getNumDims()], symRemapping[i])); + resultOperands.push_back((*operands)[i + map->getNumDims()]); + seenSymbols.insert(std::make_pair((*operands)[i + map->getNumDims()], + symRemapping[i])); } else { symRemapping[i] = it->second; } } } - map = map.replaceDimsAndSymbols(dimRemapping, symRemapping, nextDim, nextSym); - operands = resultOperands; + *map = + map->replaceDimsAndSymbols(dimRemapping, symRemapping, nextDim, nextSym); + *operands = resultOperands; } PatternMatchResult SimplifyAffineApply::match(OperationInst *op) const { @@ -262,7 +263,7 @@ PatternMatchResult SimplifyAffineApply::match(OperationInst *op) const { AffineMap oldMap = map; SmallVector<Value *, 8> resultOperands(apply->getOperands().begin(), apply->getOperands().end()); - canonicalizeMapAndOperands(map, resultOperands); + canonicalizeMapAndOperands(&map, &resultOperands); if (map != oldMap) return matchSuccess( std::make_unique<SimplifyAffineApplyState>(map, resultOperands)); |

