[PATCH] D77126: Add a method to build affine maps with zero or more results.

Ulysse Beaugnon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 02:42:54 PDT 2020


ulysseB created this revision.
Herald added subscribers: llvm-commits, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
ulysseB edited reviewers, added: ftynse, nicolasvasilache; removed: rriddle.
Herald added a reviewer: rriddle.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77126

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


Index: mlir/lib/IR/MLIRContext.cpp
===================================================================
--- mlir/lib/IR/MLIRContext.cpp
+++ mlir/lib/IR/MLIRContext.cpp
@@ -613,7 +613,7 @@
 
 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,
@@ -623,6 +623,11 @@
   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.
Index: mlir/include/mlir/IR/AffineMap.h
===================================================================
--- mlir/include/mlir/IR/AffineMap.h
+++ mlir/include/mlir/IR/AffineMap.h
@@ -49,9 +49,16 @@
   static AffineMap get(unsigned dimCount, unsigned symbolCount,
                        MLIRContext *context);
 
+  // Returns an affine map with `dimCount` dimensions and `symbolCount` 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. The array of results can be empty.
+  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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77126.253816.patch
Type: text/x-patch
Size: 2057 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/67d2a4e5/attachment-0001.bin>


More information about the llvm-commits mailing list