[Mlir-commits] [mlir] 91153e0 - [mlir][NFC] remove stray decl of toAffineExpr, rename for readability
River Riddle
llvmlistbot at llvm.org
Fri Mar 6 22:39:25 PST 2020
Author: Uday Bondhugula
Date: 2020-03-06T22:38:47-08:00
New Revision: 91153e0624bdccb62f061ff9d9cce66f849efc28
URL: https://github.com/llvm/llvm-project/commit/91153e0624bdccb62f061ff9d9cce66f849efc28
DIFF: https://github.com/llvm/llvm-project/commit/91153e0624bdccb62f061ff9d9cce66f849efc28.diff
LOG: [mlir][NFC] remove stray decl of toAffineExpr, rename for readability
Summary:
- remove stray toAffineExpr decl in affine analysis (name duplicate of
mlir::toAffineExpr)
- rename mlir::toAffineExpr for better readability
- related NFC changes
Signed-off-by: Uday Bondhugula <uday at polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D75694
Added:
Modified:
mlir/include/mlir/Analysis/AffineStructures.h
mlir/include/mlir/IR/AffineExpr.h
mlir/lib/Analysis/AffineStructures.cpp
mlir/lib/IR/AffineExpr.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h
index 7a8be6b46b49..8f63ba2ddc25 100644
--- a/mlir/include/mlir/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Analysis/AffineStructures.h
@@ -256,8 +256,6 @@ class FlatAffineConstraints {
getNumCols());
}
- AffineExpr toAffineExpr(unsigned idx, MLIRContext *context);
-
/// Adds constraints (lower and upper bounds) for the specified 'affine.for'
/// operation's Value using IR information stored in its bound maps. The
/// right identifier is first looked up using forOp's Value. Asserts if the
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index 5de9957b2cab..21318114d4ca 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -214,9 +214,10 @@ AffineExpr getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs,
/// products expression, 'localExprs' is expected to have the AffineExpr
/// for it, and is substituted into. The ArrayRef 'eq' is expected to be in the
/// format [dims, symbols, locals, constant term].
-AffineExpr toAffineExpr(ArrayRef<int64_t> eq, unsigned numDims,
- unsigned numSymbols, ArrayRef<AffineExpr> localExprs,
- MLIRContext *context);
+AffineExpr getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
+ unsigned numDims, unsigned numSymbols,
+ ArrayRef<AffineExpr> localExprs,
+ MLIRContext *context);
raw_ostream &operator<<(raw_ostream &os, AffineExpr &expr);
diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp
index c4e21b83d527..a5e0205d25cf 100644
--- a/mlir/lib/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Analysis/AffineStructures.cpp
@@ -1400,7 +1400,8 @@ std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound(
// - 1.
addCoeffs(ineq, lb);
std::transform(lb.begin(), lb.end(), lb.begin(), std::negate<int64_t>());
- auto expr = mlir::toAffineExpr(lb, dimCount, symCount, localExprs, context);
+ auto expr =
+ getAffineExprFromFlatForm(lb, dimCount, symCount, localExprs, context);
exprs.push_back(expr);
}
auto lbMap =
@@ -1413,7 +1414,8 @@ std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound(
auto ineq = getInequality(idx);
// Extract the upper bound (in terms of other coeff's + const).
addCoeffs(ineq, ub);
- auto expr = mlir::toAffineExpr(ub, dimCount, symCount, localExprs, context);
+ auto expr =
+ getAffineExprFromFlatForm(ub, dimCount, symCount, localExprs, context);
// Upper bound is exclusive.
exprs.push_back(expr + 1);
}
diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp
index 6009818a6dda..921538b4edc3 100644
--- a/mlir/lib/IR/AffineExpr.cpp
+++ b/mlir/lib/IR/AffineExpr.cpp
@@ -588,39 +588,39 @@ raw_ostream &mlir::operator<<(raw_ostream &os, AffineExpr &expr) {
/// Constructs an affine expression from a flat ArrayRef. If there are local
/// identifiers (neither dimensional nor symbolic) that appear in the sum of
-/// products expression, 'localExprs' is expected to have the AffineExpr
-/// for it, and is substituted into. The ArrayRef 'eq' is expected to be in the
-/// format [dims, symbols, locals, constant term].
-AffineExpr mlir::toAffineExpr(ArrayRef<int64_t> eq, unsigned numDims,
- unsigned numSymbols,
- ArrayRef<AffineExpr> localExprs,
- MLIRContext *context) {
- // Assert expected numLocals = eq.size() - numDims - numSymbols - 1
- assert(eq.size() - numDims - numSymbols - 1 == localExprs.size() &&
+/// products expression, `localExprs` is expected to have the AffineExpr
+/// for it, and is substituted into. The ArrayRef `flatExprs` is expected to be
+/// in the format [dims, symbols, locals, constant term].
+AffineExpr mlir::getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
+ unsigned numDims,
+ unsigned numSymbols,
+ ArrayRef<AffineExpr> localExprs,
+ MLIRContext *context) {
+ // Assert expected numLocals = flatExprs.size() - numDims - numSymbols - 1.
+ assert(flatExprs.size() - numDims - numSymbols - 1 == localExprs.size() &&
"unexpected number of local expressions");
auto expr = getAffineConstantExpr(0, context);
// Dimensions and symbols.
for (unsigned j = 0; j < numDims + numSymbols; j++) {
- if (eq[j] == 0) {
+ if (flatExprs[j] == 0)
continue;
- }
auto id = j < numDims ? getAffineDimExpr(j, context)
: getAffineSymbolExpr(j - numDims, context);
- expr = expr + id * eq[j];
+ expr = expr + id * flatExprs[j];
}
// Local identifiers.
- for (unsigned j = numDims + numSymbols, e = eq.size() - 1; j < e; j++) {
- if (eq[j] == 0) {
+ for (unsigned j = numDims + numSymbols, e = flatExprs.size() - 1; j < e;
+ j++) {
+ if (flatExprs[j] == 0)
continue;
- }
- auto term = localExprs[j - numDims - numSymbols] * eq[j];
+ auto term = localExprs[j - numDims - numSymbols] * flatExprs[j];
expr = expr + term;
}
// Constant term.
- int64_t constTerm = eq[eq.size() - 1];
+ int64_t constTerm = flatExprs[flatExprs.size() - 1];
if (constTerm != 0)
expr = expr + constTerm;
return expr;
@@ -703,8 +703,8 @@ void SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
// Construct the AffineExpr form of the floordiv to store in localExprs.
MLIRContext *context = expr.getContext();
- auto dividendExpr =
- toAffineExpr(floorDividend, numDims, numSymbols, localExprs, context);
+ auto dividendExpr = getAffineExprFromFlatForm(
+ floorDividend, numDims, numSymbols, localExprs, context);
auto divisorExpr = getAffineConstantExpr(floorDivisor, context);
auto floorDivExpr = dividendExpr.floorDiv(divisorExpr);
int loc;
@@ -787,7 +787,8 @@ void SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
// quantifier to express its result, i.e., expr1 div expr2 is replaced
// by a new identifier, q.
MLIRContext *context = expr.getContext();
- auto a = toAffineExpr(lhs, numDims, numSymbols, localExprs, context);
+ auto a =
+ getAffineExprFromFlatForm(lhs, numDims, numSymbols, localExprs, context);
auto b = getAffineConstantExpr(divisor, context);
int loc;
@@ -846,8 +847,9 @@ AffineExpr mlir::simplifyAffineExpr(AffineExpr expr, unsigned numDims,
SimpleAffineExprFlattener flattener(numDims, numSymbols);
flattener.walkPostOrder(expr);
ArrayRef<int64_t> flattenedExpr = flattener.operandExprStack.back();
- auto simplifiedExpr = toAffineExpr(flattenedExpr, numDims, numSymbols,
- flattener.localExprs, expr.getContext());
+ auto simplifiedExpr =
+ getAffineExprFromFlatForm(flattenedExpr, numDims, numSymbols,
+ flattener.localExprs, expr.getContext());
flattener.operandExprStack.pop_back();
assert(flattener.operandExprStack.empty());
More information about the Mlir-commits
mailing list