diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -90,7 +90,7 @@ MLIRContext *getContext() const; - explicit operator bool() { return map != nullptr; } + explicit operator bool() const { return map != nullptr; } bool operator==(AffineMap other) const { return other.map == map; } bool operator!=(AffineMap other) const { return !(other.map == map); } @@ -220,31 +220,31 @@ /// map2: `(d0)[s0] -> (d0 + s0, d0 - s0)` /// map1.compose(map2): /// `(d0)[s0, s1, s2] -> (d0 + s1 + s2 + 1, d0 - s0 - s2 - 1)` - AffineMap compose(AffineMap map); + AffineMap compose(AffineMap map) const; /// Applies composition by the dims of `this` to the integer `values` and /// returns the resulting values. `this` must be symbol-less. - SmallVector compose(ArrayRef values); + SmallVector compose(ArrayRef values) const; /// Returns true if the AffineMap represents a subset (i.e. a projection) of a /// symbol-less permutation map. - bool isProjectedPermutation(); + bool isProjectedPermutation() const; /// Returns true if the AffineMap represents a symbol-less permutation map. - bool isPermutation(); + bool isPermutation() const; /// Returns the map consisting of the `resultPos` subset. - AffineMap getSubMap(ArrayRef resultPos); + AffineMap getSubMap(ArrayRef resultPos) const; /// Returns the map consisting of the most major `numResults` results. /// Returns the null AffineMap if `numResults` == 0. /// Returns `*this` if `numResults` >= `this->getNumResults()`. - AffineMap getMajorSubMap(unsigned numResults); + AffineMap getMajorSubMap(unsigned numResults) const; /// Returns the map consisting of the most minor `numResults` results. /// Returns the null AffineMap if `numResults` == 0. /// Returns `*this` if `numResults` >= `this->getNumResults()`. - AffineMap getMinorSubMap(unsigned numResults); + AffineMap getMinorSubMap(unsigned numResults) const; friend ::llvm::hash_code hash_value(AffineMap arg); diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -334,7 +334,7 @@ return AffineMap::get(numResultDims, numResultSyms, newResults, getContext()); } -AffineMap AffineMap::compose(AffineMap map) { +AffineMap AffineMap::compose(AffineMap map) const { assert(getNumDims() == map.getNumResults() && "Number of results mismatch"); // Prepare `map` by concatenating the symbols and rewriting its exprs. unsigned numDims = map.getNumDims(); @@ -358,7 +358,7 @@ return AffineMap::get(numDims, numSymbols, exprs, map.getContext()); } -SmallVector AffineMap::compose(ArrayRef values) { +SmallVector AffineMap::compose(ArrayRef values) const { assert(getNumSymbols() == 0 && "Expected symbol-less map"); SmallVector exprs; exprs.reserve(values.size()); @@ -373,7 +373,7 @@ return res; } -bool AffineMap::isProjectedPermutation() { +bool AffineMap::isProjectedPermutation() const { if (getNumSymbols() > 0) return false; SmallVector seen(getNumInputs(), false); @@ -389,13 +389,13 @@ return true; } -bool AffineMap::isPermutation() { +bool AffineMap::isPermutation() const { if (getNumDims() != getNumResults()) return false; return isProjectedPermutation(); } -AffineMap AffineMap::getSubMap(ArrayRef resultPos) { +AffineMap AffineMap::getSubMap(ArrayRef resultPos) const { SmallVector exprs; exprs.reserve(resultPos.size()); for (auto idx : resultPos) @@ -403,7 +403,7 @@ return AffineMap::get(getNumDims(), getNumSymbols(), exprs, getContext()); } -AffineMap AffineMap::getMajorSubMap(unsigned numResults) { +AffineMap AffineMap::getMajorSubMap(unsigned numResults) const { if (numResults == 0) return AffineMap(); if (numResults > getNumResults()) @@ -411,7 +411,7 @@ return getSubMap(llvm::to_vector<4>(llvm::seq(0, numResults))); } -AffineMap AffineMap::getMinorSubMap(unsigned numResults) { +AffineMap AffineMap::getMinorSubMap(unsigned numResults) const { if (numResults == 0) return AffineMap(); if (numResults > getNumResults())