Skip to content

Commit b9586b1

Browse files
committed
Add static assert
1 parent 89ad6f9 commit b9586b1

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define MLIR_ANALYSIS_PRESBURGER_FRACTION_H
1616

1717
#include "mlir/Analysis/Presburger/MPInt.h"
18-
#include "mlir/Analysis/Presburger/Utils.h"
1918
#include "mlir/Support/MathExtras.h"
2019

2120
namespace mlir {

mlir/include/mlir/Analysis/Presburger/Matrix.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
//===----------------------------------------------------------------------===//
88
//
99
// This is a simple 2D matrix class that supports reading, writing, resizing,
10-
// swapping rows, and swapping columns.
10+
// swapping rows, and swapping columns. It can hold integers (MPInt) or rational
11+
// numbers (Fraction).
1112
//
1213
//===----------------------------------------------------------------------===//
1314

1415
#ifndef MLIR_ANALYSIS_PRESBURGER_MATRIX_H
1516
#define MLIR_ANALYSIS_PRESBURGER_MATRIX_H
1617

1718
#include "mlir/Support/LLVM.h"
19+
#include "mlir/Analysis/Presburger/Fraction.h"
20+
#include "mlir/Analysis/Presburger/Matrix.h"
1821
#include "llvm/ADT/ArrayRef.h"
1922
#include "llvm/Support/raw_ostream.h"
2023

@@ -33,6 +36,8 @@ namespace presburger {
3336
/// space in the underlying SmallVector's capacity.
3437
template<typename T>
3538
class Matrix {
39+
// This class is not intended for general use: it supports only integers and rational numbers
40+
static_assert(std::is_same_v<T,MPInt> || std::is_same_v<T,Fraction>, "T must be MPInt or Fraction.");
3641
public:
3742
Matrix() = delete;
3843

mlir/lib/Analysis/Presburger/IntegerRelation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ SymbolicLexOpt IntegerRelation::findSymbolicIntegerLexMax() const {
304304
// Get lexmax by flipping range sign in the PWMA constraints.
305305
for (auto &flippedPiece :
306306
flippedSymbolicIntegerLexMax.lexopt.getAllPieces()) {
307-
Matrix mat = flippedPiece.output.getOutputMatrix();
307+
Matrix<MPInt> mat = flippedPiece.output.getOutputMatrix();
308308
for (unsigned i = 0, e = mat.getNumRows(); i < e; i++)
309309
mat.negateRow(i);
310310
MultiAffineFunction maf(flippedPiece.output.getSpace(), mat);

mlir/lib/Analysis/Presburger/Matrix.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ template <typename T> bool Matrix<T>::hasConsistentState() const {
379379

380380
namespace mlir
381381
{
382-
namespace presburger
383-
{
384-
template class Matrix<MPInt>;
385-
template class Matrix<Fraction>;
386-
}
382+
namespace presburger
383+
{
384+
template class Matrix<MPInt>;
385+
template class Matrix<Fraction>;
386+
}
387387
}

0 commit comments

Comments
 (0)