Add a method to build affine maps with zero or more results.

Summary:
The commit provides a single method to build affine maps with zero or more
results. Users of mlir::AffineMap previously had to dispatch between two methods
depending on the number of results.

At the same time, this commit fixes the method for building affine map with zero
results that was previously ignoring its `symbolCount` argument.

Differential Revision: https://reviews.llvm.org/D77126
This commit is contained in:
Ulysse Beaugnon 2020-04-01 10:47:06 +02:00 committed by Alex Zinenko
parent e2d6023250
commit 49af380942
2 changed files with 13 additions and 1 deletions

View File

@ -49,9 +49,16 @@ public:
static AffineMap get(unsigned dimCount, unsigned symbolCount,
MLIRContext *context);
/// Returns an affine map with `dimCount` dimensions and `symbolCount` symbols
/// mapping to the given results. The array of results cannot be empty.
static AffineMap get(unsigned dimCount, unsigned symbolCount,
ArrayRef<AffineExpr> results);
/// Returns an affine map with `dimCount` dimensions and `symbolCount` mapping
/// to the given results, where the number of results can be zero.
static AffineMap get(unsigned dimCount, unsigned symbolCount,
ArrayRef<AffineExpr> results, MLIRContext *context);
/// Returns a single constant result affine map.
static AffineMap getConstantMap(int64_t val, MLIRContext *context);

View File

@ -630,7 +630,7 @@ AffineMap AffineMap::get(MLIRContext *context) {
AffineMap AffineMap::get(unsigned dimCount, unsigned symbolCount,
MLIRContext *context) {
return getImpl(dimCount, /*symbolCount=*/0, /*results=*/{}, context);
return getImpl(dimCount, symbolCount, /*results=*/{}, context);
}
AffineMap AffineMap::get(unsigned dimCount, unsigned symbolCount,
@ -640,6 +640,11 @@ AffineMap AffineMap::get(unsigned dimCount, unsigned symbolCount,
return getImpl(dimCount, symbolCount, results, results[0].getContext());
}
AffineMap AffineMap::get(unsigned dimCount, unsigned symbolCount,
ArrayRef<AffineExpr> results, MLIRContext *context) {
return getImpl(dimCount, symbolCount, results, context);
}
//===----------------------------------------------------------------------===//
// Integer Sets: these are allocated into the bump pointer, and are immutable.
// Unlike AffineMap's, these are uniqued only if they are small.