[Mlir-commits] [mlir] 49af380 - Add a method to build affine maps with zero or more results.

Alex Zinenko llvmlistbot at llvm.org
Wed Apr 1 01:47:26 PDT 2020


Author: Ulysse Beaugnon
Date: 2020-04-01T10:47:18+02:00
New Revision: 49af3809423bfe03a21cad22dda0a776c04cc5af

URL: https://github.com/llvm/llvm-project/commit/49af3809423bfe03a21cad22dda0a776c04cc5af
DIFF: https://github.com/llvm/llvm-project/commit/49af3809423bfe03a21cad22dda0a776c04cc5af.diff

LOG: 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

Added: 
    

Modified: 
    mlir/include/mlir/IR/AffineMap.h
    mlir/lib/IR/MLIRContext.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index 14deb85fb2f0..1553427d19aa 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -49,9 +49,16 @@ class AffineMap {
   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);
 

diff  --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index df4ea9b7d16a..3875b57775bc 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -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.


        


More information about the Mlir-commits mailing list