[MLIR] AffineExpr final cleanups
This CL:
1. performs the global codemod AffineXExpr->AffineXExprClass and
AffineXExprRef -> AffineXExpr;
2. simplifies function calls by removing the redundant MLIRContext parameter;
3. adds missing binary operator versions of scalar op AffineExpr where it
makes sense.
PiperOrigin-RevId: 216242674
diff --git a/lib/Analysis/LoopAnalysis.cpp b/lib/Analysis/LoopAnalysis.cpp
index 522720e..b3e3afe 100644
--- a/lib/Analysis/LoopAnalysis.cpp
+++ b/lib/Analysis/LoopAnalysis.cpp
@@ -32,7 +32,7 @@
/// Returns the trip count of the loop as an affine expression if the latter is
/// expressible as an affine expression, and nullptr otherwise. The trip count
/// expression is simplified before returning.
-AffineExprRef mlir::getTripCountExpr(const ForStmt &forStmt) {
+AffineExpr mlir::getTripCountExpr(const ForStmt &forStmt) {
// upper_bound - lower_bound + 1
int64_t loopSpan;
@@ -56,12 +56,12 @@
return nullptr;
// ub_expr - lb_expr + 1
- AffineExprRef lbExpr(lbMap->getResult(0));
- AffineExprRef ubExpr(ubMap->getResult(0));
+ AffineExpr lbExpr(lbMap->getResult(0));
+ AffineExpr ubExpr(ubMap->getResult(0));
auto loopSpanExpr = simplifyAffineExpr(
ubExpr - lbExpr + 1, std::max(lbMap->getNumDims(), ubMap->getNumDims()),
std::max(lbMap->getNumSymbols(), ubMap->getNumSymbols()));
- auto cExpr = loopSpanExpr.dyn_cast<AffineConstantExprRef>();
+ auto cExpr = loopSpanExpr.dyn_cast<AffineConstantExpr>();
if (!cExpr)
return loopSpanExpr.ceilDiv(step);
loopSpan = cExpr->getValue();
@@ -84,7 +84,7 @@
if (!tripCountExpr)
return None;
- if (auto constExpr = tripCountExpr.dyn_cast<AffineConstantExprRef>())
+ if (auto constExpr = tripCountExpr.dyn_cast<AffineConstantExpr>())
return constExpr->getValue();
return None;
@@ -99,7 +99,7 @@
if (!tripCountExpr)
return 1;
- if (auto constExpr = tripCountExpr.dyn_cast<AffineConstantExprRef>()) {
+ if (auto constExpr = tripCountExpr.dyn_cast<AffineConstantExpr>()) {
uint64_t tripCount = constExpr->getValue();
// 0 iteration loops (greatest divisor is 2^64 - 1).