[MLIR][Presburger] Cleanup getMaybeValues in FACV

This patch cleans up multiple getMaybeValue functions to take an IdKind instead
of special functions.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D125617
This commit is contained in:
Groverkss 2022-05-18 09:44:14 +05:30
parent 862b5a5233
commit e00cbbec06
3 changed files with 10 additions and 15 deletions

View File

@ -431,16 +431,11 @@ public:
return {values.data(), values.size()};
}
inline ArrayRef<Optional<Value>> getMaybeDimValues() const {
return {values.data(), getNumDimIds()};
}
inline ArrayRef<Optional<Value>> getMaybeSymbolValues() const {
return {values.data() + getNumDimIds(), getNumSymbolIds()};
}
inline ArrayRef<Optional<Value>> getMaybeDimAndSymbolValues() const {
return {values.data(), getNumDimIds() + getNumSymbolIds()};
inline ArrayRef<Optional<Value>>
getMaybeValues(presburger::IdKind kind) const {
assert(kind != IdKind::Local &&
"Local identifiers do not have any value attached to them.");
return {values.data() + getIdKindOffset(kind), getNumIdKind(kind)};
}
/// Sets the Value associated with the pos^th identifier.

View File

@ -1666,8 +1666,8 @@ void FlatAffineRelation::compose(const FlatAffineRelation &other) {
convertToLocal(IdKind::SetDim, getNumDomainDims() - removeDims,
getNumDomainDims());
auto thisMaybeValues = getMaybeDimValues();
auto relMaybeValues = rel.getMaybeDimValues();
auto thisMaybeValues = getMaybeValues(IdKind::SetDim);
auto relMaybeValues = rel.getMaybeValues(IdKind::SetDim);
// Add and match domain of `rel` to domain of `this`.
for (unsigned i = 0, e = rel.getNumDomainDims(); i < e; ++i)

View File

@ -43,8 +43,8 @@ static LogicalResult alignAndAddBound(FlatAffineValueConstraints &constraints,
unsigned pos, AffineMap map,
ValueRange operands) {
SmallVector<Value> dims, syms, newSyms;
unpackOptionalValues(constraints.getMaybeDimValues(), dims);
unpackOptionalValues(constraints.getMaybeSymbolValues(), syms);
unpackOptionalValues(constraints.getMaybeValues(IdKind::SetDim), dims);
unpackOptionalValues(constraints.getMaybeValues(IdKind::Symbol), syms);
AffineMap alignedMap =
alignAffineMapWithValues(map, operands, dims, syms, &newSyms);
@ -182,7 +182,7 @@ canonicalizeMinMaxOp(RewriterBase &rewriter, Operation *op, AffineMap map,
// Lower and upper bound of `op` are equal. Replace `minOp` with its bound.
AffineMap newMap = alignedBoundMap;
SmallVector<Value> newOperands;
unpackOptionalValues(constraints.getMaybeDimAndSymbolValues(), newOperands);
unpackOptionalValues(constraints.getMaybeValues(), newOperands);
// If dims/symbols have known constant values, use those in order to simplify
// the affine map further.
for (int64_t i = 0, e = constraints.getNumIds(); i < e; ++i) {