diff options
Diffstat (limited to 'mlir/lib/Analysis/Presburger/PWMAFunction.cpp')
| -rw-r--r-- | mlir/lib/Analysis/Presburger/PWMAFunction.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp index d55962616de1..664670d506d5 100644 --- a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp +++ b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp @@ -8,7 +8,6 @@ #include "mlir/Analysis/Presburger/PWMAFunction.h" #include "mlir/Analysis/Presburger/IntegerRelation.h" -#include "mlir/Analysis/Presburger/MPInt.h" #include "mlir/Analysis/Presburger/PresburgerRelation.h" #include "mlir/Analysis/Presburger/PresburgerSpace.h" #include "mlir/Analysis/Presburger/Utils.h" @@ -41,11 +40,11 @@ void MultiAffineFunction::assertIsConsistent() const { // Return the result of subtracting the two given vectors pointwise. // The vectors must be of the same size. // e.g., [3, 4, 6] - [2, 5, 1] = [1, -1, 5]. -static SmallVector<MPInt, 8> subtractExprs(ArrayRef<MPInt> vecA, - ArrayRef<MPInt> vecB) { +static SmallVector<DynamicAPInt, 8> subtractExprs(ArrayRef<DynamicAPInt> vecA, + ArrayRef<DynamicAPInt> vecB) { assert(vecA.size() == vecB.size() && "Cannot subtract vectors of differing lengths!"); - SmallVector<MPInt, 8> result; + SmallVector<DynamicAPInt, 8> result; result.reserve(vecA.size()); for (unsigned i = 0, e = vecA.size(); i < e; ++i) result.push_back(vecA[i] - vecB[i]); @@ -67,18 +66,19 @@ void MultiAffineFunction::print(raw_ostream &os) const { output.print(os); } -SmallVector<MPInt, 8> -MultiAffineFunction::valueAt(ArrayRef<MPInt> point) const { +SmallVector<DynamicAPInt, 8> +MultiAffineFunction::valueAt(ArrayRef<DynamicAPInt> point) const { assert(point.size() == getNumDomainVars() + getNumSymbolVars() && "Point has incorrect dimensionality!"); - SmallVector<MPInt, 8> pointHomogenous{llvm::to_vector(point)}; + SmallVector<DynamicAPInt, 8> pointHomogenous{llvm::to_vector(point)}; // Get the division values at this point. - SmallVector<std::optional<MPInt>, 8> divValues = divs.divValuesAt(point); + SmallVector<std::optional<DynamicAPInt>, 8> divValues = + divs.divValuesAt(point); // The given point didn't include the values of the divs which the output is a // function of; we have computed one possible set of values and use them here. pointHomogenous.reserve(pointHomogenous.size() + divValues.size()); - for (const std::optional<MPInt> &divVal : divValues) + for (const std::optional<DynamicAPInt> &divVal : divValues) pointHomogenous.push_back(*divVal); // The matrix `output` has an affine expression in the ith row, corresponding // to the expression for the ith value in the output vector. The last column @@ -86,7 +86,8 @@ MultiAffineFunction::valueAt(ArrayRef<MPInt> point) const { // a 1 appended at the end. We can see that output * v gives the desired // output vector. pointHomogenous.emplace_back(1); - SmallVector<MPInt, 8> result = output.postMultiplyWithColumn(pointHomogenous); + SmallVector<DynamicAPInt, 8> result = + output.postMultiplyWithColumn(pointHomogenous); assert(result.size() == getNumOutputs()); return result; } @@ -138,7 +139,7 @@ void MultiAffineFunction::mergeDivs(MultiAffineFunction &other) { other.divs.insertDiv(0, nDivs); - SmallVector<MPInt, 8> div(other.divs.getNumVars() + 1); + SmallVector<DynamicAPInt, 8> div(other.divs.getNumVars() + 1); for (unsigned i = 0; i < nDivs; ++i) { // Zero fill. std::fill(div.begin(), div.end(), 0); @@ -232,7 +233,7 @@ MultiAffineFunction::getLexSet(OrderingKind comp, for (unsigned level = 0; level < funcA.getNumOutputs(); ++level) { // Create the expression `outA - outB` for this level. - SmallVector<MPInt, 8> subExpr = + SmallVector<DynamicAPInt, 8> subExpr = subtractExprs(funcA.getOutputExpr(level), funcB.getOutputExpr(level)); // TODO: Implement all comparison cases. @@ -242,14 +243,14 @@ MultiAffineFunction::getLexSet(OrderingKind comp, // outA - outB <= -1 // outA <= outB - 1 // outA < outB - levelSet.addBound(BoundType::UB, subExpr, MPInt(-1)); + levelSet.addBound(BoundType::UB, subExpr, DynamicAPInt(-1)); break; case OrderingKind::GT: // For greater than, we add a lower bound of 1: // outA - outB >= 1 // outA > outB + 1 // outA > outB - levelSet.addBound(BoundType::LB, subExpr, MPInt(1)); + levelSet.addBound(BoundType::LB, subExpr, DynamicAPInt(1)); break; case OrderingKind::GE: case OrderingKind::LE: @@ -389,7 +390,7 @@ void MultiAffineFunction::subtract(const MultiAffineFunction &other) { MultiAffineFunction copyOther = other; mergeDivs(copyOther); for (unsigned i = 0, e = getNumOutputs(); i < e; ++i) - output.addToRow(i, copyOther.getOutputExpr(i), MPInt(-1)); + output.addToRow(i, copyOther.getOutputExpr(i), DynamicAPInt(-1)); // Check consistency. assertIsConsistent(); @@ -429,14 +430,14 @@ IntegerRelation MultiAffineFunction::getAsRelation() const { // Add equalities such that the i^th range variable is equal to the i^th // output expression. - SmallVector<MPInt, 8> eq(result.getNumCols()); + SmallVector<DynamicAPInt, 8> eq(result.getNumCols()); for (unsigned i = 0, e = getNumOutputs(); i < e; ++i) { // TODO: Add functions to get VarKind offsets in output in MAF and use them // here. // The output expression does not contain range variables, while the // equality does. So, we need to copy all variables and mark all range // variables as 0 in the equality. - ArrayRef<MPInt> expr = getOutputExpr(i); + ArrayRef<DynamicAPInt> expr = getOutputExpr(i); // Copy domain variables in `expr` to domain variables in `eq`. std::copy(expr.begin(), expr.begin() + getNumDomainVars(), eq.begin()); // Fill the range variables in `eq` as zero. @@ -462,8 +463,8 @@ void PWMAFunction::removeOutputs(unsigned start, unsigned end) { piece.output.removeOutputs(start, end); } -std::optional<SmallVector<MPInt, 8>> -PWMAFunction::valueAt(ArrayRef<MPInt> point) const { +std::optional<SmallVector<DynamicAPInt, 8>> +PWMAFunction::valueAt(ArrayRef<DynamicAPInt> point) const { assert(point.size() == getNumDomainVars() + getNumSymbolVars()); for (const Piece &piece : pieces) |
