[MLIR] Cleanup AffineExpr
This CL introduces a series of cleanups for AffineExpr value types:
1. to make it clear that the value types should be used, the pointer
AffineExpr types are put in the detail namespace. Unfortunately, since the
value type operator-> only forwards to the underlying pointer type, we
still
need to expose this in the include file for now;
2. AffineExprKind is ok to use, it thus comes out of detail and thus of
AffineExpr
3. getAffineDimExpr, getAffineSymbolExpr, getAffineConstantExpr are
similarly
extracted as free functions and their naming is mande consistent across
Builder, MLContext and AffineExpr
4. AffineBinaryOpEx::simplify functions are made into static free
functions.
In particular it is moved away from AffineMap.cpp where it does not belong
5. operator AffineExprType is made explicit
6. uses the binary operators everywhere possible
7. drops the pointer usage everywhere outside of AffineExpr.cpp,
MLIRContext.cpp and AsmPrinter.cpp
PiperOrigin-RevId: 216207212
diff --git a/lib/Analysis/LoopAnalysis.cpp b/lib/Analysis/LoopAnalysis.cpp
index 0b50494..522720e 100644
--- a/lib/Analysis/LoopAnalysis.cpp
+++ b/lib/Analysis/LoopAnalysis.cpp
@@ -63,7 +63,7 @@
std::max(lbMap->getNumSymbols(), ubMap->getNumSymbols()));
auto cExpr = loopSpanExpr.dyn_cast<AffineConstantExprRef>();
if (!cExpr)
- return AffineBinaryOpExpr::getCeilDiv(loopSpanExpr, step, context);
+ return loopSpanExpr.ceilDiv(step);
loopSpan = cExpr->getValue();
}
@@ -71,8 +71,8 @@
if (loopSpan < 0)
return 0;
- return AffineConstantExpr::get(static_cast<uint64_t>(ceilDiv(loopSpan, step)),
- context);
+ return getAffineConstantExpr(static_cast<uint64_t>(ceilDiv(loopSpan, step)),
+ context);
}
/// Returns the trip count of the loop if it's a constant, None otherwise. This