[Mlir-commits] [mlir] ffbc08d - [mlir][affineexpr] Changing `AsmParser::parseAffineExpr` API to use ArrayRef

wren romano llvmlistbot at llvm.org
Fri Jul 7 17:21:34 PDT 2023


Author: wren romano
Date: 2023-07-07T17:21:28-07:00
New Revision: ffbc08d8908cb3e17047bd35d803f1f6f33919f3

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

LOG: [mlir][affineexpr] Changing `AsmParser::parseAffineExpr` API to use ArrayRef

The methods added by D154177 don't require the `symbolSet` parameter to be mutable nor to have the `SmallVectorImpl` type, so this commit changes them to accept `ArrayRef` instead: both for generality, and to make the non-mutation an explicit part of the API.

Reviewed By: aartbik, Peiming

Differential Revision: https://reviews.llvm.org/D154751

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpImplementation.h
    mlir/lib/AsmParser/AffineParser.cpp
    mlir/lib/AsmParser/AsmParserImpl.h
    mlir/lib/AsmParser/Parser.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index dda4f3782ea79a..81e74f38307774 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -1035,7 +1035,7 @@ class AsmParser {
   /// Parse an affine expr instance into 'expr' using the already computed
   /// mapping from symbols to affine expressions in 'symbolSet'.
   virtual ParseResult
-  parseAffineExpr(SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
+  parseAffineExpr(ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet,
                   AffineExpr &expr) = 0;
 
   /// Parse an integer set instance into 'set'.

diff  --git a/mlir/lib/AsmParser/AffineParser.cpp b/mlir/lib/AsmParser/AffineParser.cpp
index e648a1a9d00d36..ea2eea4cfc47ed 100644
--- a/mlir/lib/AsmParser/AffineParser.cpp
+++ b/mlir/lib/AsmParser/AffineParser.cpp
@@ -53,9 +53,9 @@ class AffineParser : public Parser {
   ParseResult parseAffineMapRange(unsigned numDims, unsigned numSymbols,
                                   AffineMap &result);
   ParseResult parseAffineMapOrIntegerSetInline(AffineMap &map, IntegerSet &set);
-  ParseResult parseAffineExprInline(
-      SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
-      AffineExpr &expr);
+  ParseResult
+  parseAffineExprInline(ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet,
+                        AffineExpr &expr);
   ParseResult parseIntegerSetConstraints(unsigned numDims, unsigned numSymbols,
                                          IntegerSet &result);
   ParseResult parseAffineMapOfSSAIds(AffineMap &map,
@@ -538,9 +538,8 @@ ParseResult AffineParser::parseAffineMapOrIntegerSetInline(AffineMap &map,
 
 /// Parse an affine expresion definition inline, with given symbols.
 ParseResult AffineParser::parseAffineExprInline(
-    SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
-    AffineExpr &expr) {
-  dimsAndSymbols.assign(symbolSet);
+    ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet, AffineExpr &expr) {
+  dimsAndSymbols.assign(symbolSet.begin(), symbolSet.end());
   expr = parseAffineExpr();
   return success(expr != nullptr);
 }
@@ -716,8 +715,7 @@ ParseResult Parser::parseAffineMapReference(AffineMap &map) {
   return success();
 }
 ParseResult Parser::parseAffineExprReference(
-    SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
-    AffineExpr &expr) {
+    ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet, AffineExpr &expr) {
   return AffineParser(state).parseAffineExprInline(symbolSet, expr);
 }
 ParseResult Parser::parseIntegerSetReference(IntegerSet &set) {

diff  --git a/mlir/lib/AsmParser/AsmParserImpl.h b/mlir/lib/AsmParser/AsmParserImpl.h
index ef70a7126cba85..7208198f89e22c 100644
--- a/mlir/lib/AsmParser/AsmParserImpl.h
+++ b/mlir/lib/AsmParser/AsmParserImpl.h
@@ -459,7 +459,7 @@ class AsmParserImpl : public BaseT {
   /// Parse an affine expr instance into 'expr' using the already computed
   /// mapping from symbols to affine expressions in 'symbolSet'.
   ParseResult
-  parseAffineExpr(SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
+  parseAffineExpr(ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet,
                   AffineExpr &expr) override {
     return parser.parseAffineExprReference(symbolSet, expr);
   }

diff  --git a/mlir/lib/AsmParser/Parser.h b/mlir/lib/AsmParser/Parser.h
index c856e1f1f30548..522cf004e92b54 100644
--- a/mlir/lib/AsmParser/Parser.h
+++ b/mlir/lib/AsmParser/Parser.h
@@ -300,9 +300,9 @@ class Parser {
   ParseResult parseAffineMapOrIntegerSetReference(AffineMap &map,
                                                   IntegerSet &set);
   ParseResult parseAffineMapReference(AffineMap &map);
-  ParseResult parseAffineExprReference(
-      SmallVectorImpl<std::pair<StringRef, AffineExpr>> &symbolSet,
-      AffineExpr &expr);
+  ParseResult
+  parseAffineExprReference(ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet,
+                           AffineExpr &expr);
   ParseResult parseIntegerSetReference(IntegerSet &set);
 
   /// Parse an AffineMap where the dim and symbol identifiers are SSA ids.


        


More information about the Mlir-commits mailing list