Skip to content

Commit 00f3410

Browse files
committed
[MLIR][Presburger] add atConstraint to index into combined constraint matrix
1 parent 87f4e80 commit 00f3410

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mlir/include/mlir/Analysis/Presburger/IntegerRelation.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class IntegerRelation {
196196
inline DynamicAPInt atIneq(unsigned i, unsigned j) const {
197197
return inequalities(i, j);
198198
}
199+
199200
/// The same, but casts to int64_t. This is unsafe and will assert-fail if the
200201
/// value does not fit in an int64_t.
201202
inline int64_t atIneq64(unsigned i, unsigned j) const {
@@ -209,6 +210,19 @@ class IntegerRelation {
209210
return getNumInequalities() + getNumEqualities();
210211
}
211212

213+
// Unified indexing into the constraints. Index into the inequalities
214+
// if i < getNumInequalities() and into the equalities otherwise.
215+
inline DynamicAPInt atConstraint(unsigned i, unsigned j) const {
216+
assert(i < getNumConstraints());
217+
unsigned numIneqs = getNumInequalities();
218+
return i < numIneqs ? atIneq(i, j) : atEq(i - numIneqs, j);
219+
}
220+
inline DynamicAPInt &atConstraint(unsigned i, unsigned j) {
221+
assert(i < getNumConstraints());
222+
unsigned numIneqs = getNumInequalities();
223+
return i < numIneqs ? atIneq(i, j) : atEq(i - numIneqs, j);
224+
}
225+
212226
unsigned getNumDomainVars() const { return space.getNumDomainVars(); }
213227
unsigned getNumRangeVars() const { return space.getNumRangeVars(); }
214228
unsigned getNumSymbolVars() const { return space.getNumSymbolVars(); }

0 commit comments

Comments
 (0)