Skip to content

Commit ea5256e

Browse files
committed
Make compatible with fraction patch
1 parent dfd4e7c commit ea5256e

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

mlir/include/mlir/Analysis/Presburger/Fraction.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This is a simple class to represent fractions. It supports arithmetic,
9+
// This is a simple class to represent fractions. It supports multiplication,
1010
// comparison, floor, and ceiling operations.
1111
//
1212
//===----------------------------------------------------------------------===//
@@ -30,15 +30,15 @@ struct Fraction {
3030
Fraction() = default;
3131

3232
/// Construct a Fraction from a numerator and denominator.
33-
Fraction(const MPInt &oNum, const MPInt &oDen = MPInt(1)) : num(oNum), den(oDen) {
33+
Fraction(const MPInt &oNum, const MPInt &oDen) : num(oNum), den(oDen) {
3434
if (den < 0) {
3535
num = -num;
3636
den = -den;
3737
}
3838
}
3939
/// Overloads for passing literals.
40-
Fraction(const MPInt &num, int64_t den = 1) : Fraction(num, MPInt(den)) {}
41-
Fraction(int64_t num, const MPInt &den = MPInt(1)) : Fraction(MPInt(num), den) {}
40+
Fraction(const MPInt &num, int64_t den) : Fraction(num, MPInt(den)) {}
41+
Fraction(int64_t num, const MPInt &den) : Fraction(MPInt(num), den) {}
4242
Fraction(int64_t num, int64_t den) : Fraction(MPInt(num), MPInt(den)) {}
4343

4444
// Return the value of the fraction as an integer. This should only be called
@@ -48,10 +48,6 @@ struct Fraction {
4848
return num / den;
4949
}
5050

51-
llvm::raw_ostream &print(llvm::raw_ostream &os) const {
52-
return os << "(" << num << "/" << den << ")";
53-
}
54-
5551
/// The numerator and denominator, respectively. The denominator is always
5652
/// positive.
5753
MPInt num{0}, den{1};
@@ -164,23 +160,6 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
164160
return os;
165161
}
166162

167-
inline Fraction operator/(const Fraction &x, const Fraction &y) {
168-
return Fraction(x.num * y.den, x.den * y.num);
169-
}
170-
171-
inline Fraction operator+(const Fraction &x, const Fraction &y) {
172-
return Fraction(x.num * y.den + x.den * y.num, x.den * y.den);
173-
}
174-
175-
inline Fraction operator-(const Fraction &x, const Fraction &y) {
176-
return Fraction(x.num * y.den - x.den * y.num, x.den * y.den);
177-
}
178-
179-
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
180-
x.print(os);
181-
return os;
182-
}
183-
184163
} // namespace presburger
185164
} // namespace mlir
186165

mlir/lib/Analysis/Presburger/Matrix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ template <typename T> void Matrix<T>::addToRow(unsigned row, ArrayRef<T> rowVec,
202202
if (scale == 0)
203203
return;
204204
for (unsigned col = 0; col < nColumns; ++col)
205-
at(row, col) = at(row, col) + scale * rowVec[col];
205+
at(row, col) += scale * rowVec[col];
206206
}
207207

208208
template <typename T> void Matrix<T>::addToColumn(unsigned sourceColumn, unsigned targetColumn,
209209
const T &scale) {
210210
if (scale == 0)
211211
return;
212212
for (unsigned row = 0, e = getNumRows(); row < e; ++row)
213-
at(row, targetColumn) = at(row, targetColumn) + scale * at(row, sourceColumn);
213+
at(row, targetColumn) += scale * at(row, sourceColumn);
214214
}
215215

216216
template <typename T> void Matrix<T>::negateColumn(unsigned column) {
@@ -237,7 +237,7 @@ template <typename T> SmallVector<T, 8> Matrix<T>::preMultiplyWithRow(ArrayRef<T
237237
SmallVector<T, 8> result(getNumColumns(), T(0));
238238
for (unsigned col = 0, e = getNumColumns(); col < e; ++col)
239239
for (unsigned i = 0, e = getNumRows(); i < e; ++i)
240-
result[col] = result[col] + rowVec[i] * at(i, col);
240+
result[col] += rowVec[i] * at(i, col);
241241
return result;
242242
}
243243

@@ -249,7 +249,7 @@ Matrix<T>::postMultiplyWithColumn(ArrayRef<T> colVec) const {
249249
SmallVector<T, 8> result(getNumRows(), T(0));
250250
for (unsigned row = 0, e = getNumRows(); row < e; row++)
251251
for (unsigned i = 0, e = getNumColumns(); i < e; i++)
252-
result[row] = result[row] + at(row, i) * colVec[i];
252+
result[row] += at(row, i) * colVec[i];
253253
return result;
254254
}
255255

0 commit comments

Comments
 (0)