Author: Uday Bondhugula Date: 2021-09-23T08:19:19+05:30 New Revision: 81fe64da18fa4d4c9252b2ddd646f6623e1d1704
URL: https://github.com/llvm/llvm-project/commit/81fe64da18fa4d4c9252b2ddd646f6623e1d1704 DIFF: https://github.com/llvm/llvm-project/commit/81fe64da18fa4d4c9252b2ddd646f6623e1d1704.diff LOG: [MLIR] Add AffineMap::isPureAffine Signed-off-by: Uday Bondhugula <Uday Bondhugula u...@polymagelabs.com> Added: Modified: mlir/include/mlir/IR/AffineMap.h mlir/lib/IR/AffineMap.cpp Removed: ################################################################################ diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index 906c53db4b32..f1f00acd8022 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -81,6 +81,11 @@ class AffineMap { static AffineMap getPermutationMap(ArrayRef<unsigned> permutation, MLIRContext *context); + /// Returns true if all of this map's result expressions are pure affine, + /// i.e., multiplication, floordiv, ceildiv, and mod is only allowed w.r.t + /// constants. + bool isPureAffine() const; + /// Returns a vector of AffineMaps; each with as many results as /// `exprs.size()`, as many dims as the largest dim in `exprs` and as many /// symbols as the largest symbol in `exprs`. diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 9c6f25d3c53e..0989d821655d 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -344,6 +344,12 @@ unsigned AffineMap::getPermutedPosition(unsigned input) const { llvm_unreachable("incorrect permutation request"); } +bool AffineMap::isPureAffine() const { + return llvm::all_of(getResults(), [](AffineExpr expr) { + return expr.isPureAffine(); + }); +} + /// Folds the results of the application of an affine map on the provided /// operands to a constant if possible. Returns false if the folding happens, /// true otherwise. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits