[PATCH] D112193: [Polly][NFC] Switch createSubstitutions and createSubstitutionsVector to use isl::ast_expr

Max Fan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 20 17:24:35 PDT 2021


InnovativeInventor updated this revision to Diff 381119.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112193/new/

https://reviews.llvm.org/D112193

Files:
  polly/include/polly/CodeGen/IslNodeBuilder.h
  polly/lib/CodeGen/IslNodeBuilder.cpp


Index: polly/lib/CodeGen/IslNodeBuilder.cpp
===================================================================
--- polly/lib/CodeGen/IslNodeBuilder.cpp
+++ polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -408,7 +408,7 @@
   isl_map *S = isl_map_from_union_map(Schedule);
 
   auto *NewAccesses = createNewAccesses(Stmt, User);
-  createSubstitutionsVector(Expr, Stmt, VLTS, IVS, IteratorID);
+  createSubstitutionsVector(isl::manage(Expr), Stmt, VLTS, IVS, IteratorID);
   VectorBlockGenerator::generate(BlockGen, *Stmt, VLTS, S, NewAccesses);
   isl_id_to_ast_expr_free(NewAccesses);
   isl_map_free(S);
@@ -927,41 +927,35 @@
   return NewAccesses.release();
 }
 
-void IslNodeBuilder::createSubstitutions(__isl_take isl_ast_expr *Expr,
-                                         ScopStmt *Stmt, LoopToScevMapT &LTS) {
-  assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op &&
+void IslNodeBuilder::createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt,
+                                         LoopToScevMapT &LTS) {
+  assert(isl_ast_expr_get_type(Expr.get()) == isl_ast_expr_op &&
          "Expression of type 'op' expected");
-  assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_call &&
+  assert(isl_ast_expr_get_op_type(Expr.get()) == isl_ast_op_call &&
          "Operation of type 'call' expected");
-  for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr) - 1; ++i) {
-    isl_ast_expr *SubExpr;
+  for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr.get()) - 1; ++i) {
     Value *V;
 
-    SubExpr = isl_ast_expr_get_op_arg(Expr, i + 1);
-    V = ExprBuilder.create(SubExpr);
+    V = ExprBuilder.create(isl_ast_expr_copy(Expr.op_arg(i + 1).get()));
     ScalarEvolution *SE = Stmt->getParent()->getSE();
     LTS[Stmt->getLoopForDimension(i)] = SE->getUnknown(V);
   }
-
-  isl_ast_expr_free(Expr);
 }
 
 void IslNodeBuilder::createSubstitutionsVector(
-    __isl_take isl_ast_expr *Expr, ScopStmt *Stmt,
-    std::vector<LoopToScevMapT> &VLTS, std::vector<Value *> &IVS,
-    __isl_take isl_id *IteratorID) {
+    isl::ast_expr Expr, ScopStmt *Stmt, std::vector<LoopToScevMapT> &VLTS,
+    std::vector<Value *> &IVS, __isl_take isl_id *IteratorID) {
   int i = 0;
 
   Value *OldValue = IDToValue[IteratorID];
   for (Value *IV : IVS) {
     IDToValue[IteratorID] = IV;
-    createSubstitutions(isl_ast_expr_copy(Expr), Stmt, VLTS[i]);
+    createSubstitutions(Expr, Stmt, VLTS[i]);
     i++;
   }
 
   IDToValue[IteratorID] = OldValue;
   isl_id_free(IteratorID);
-  isl_ast_expr_free(Expr);
 }
 
 void IslNodeBuilder::generateCopyStmt(
@@ -1011,7 +1005,7 @@
     generateCopyStmt(Stmt, NewAccesses);
     isl_ast_expr_free(Expr);
   } else {
-    createSubstitutions(Expr, Stmt, LTS);
+    createSubstitutions(isl::manage(Expr), Stmt, LTS);
 
     if (Stmt->isBlockStmt())
       BlockGen.copyStmt(*Stmt, LTS, NewAccesses);
Index: polly/include/polly/CodeGen/IslNodeBuilder.h
===================================================================
--- polly/include/polly/CodeGen/IslNodeBuilder.h
+++ polly/include/polly/CodeGen/IslNodeBuilder.h
@@ -368,9 +368,9 @@
   ///             that counts the number of times a loop is executed. For each
   ///             original loop this count, expressed in function of the new
   ///             induction variables, is added to the LTS map.
-  void createSubstitutions(__isl_take isl_ast_expr *Expr, ScopStmt *Stmt,
+  void createSubstitutions(isl::ast_expr Expr, ScopStmt *Stmt,
                            LoopToScevMapT &LTS);
-  void createSubstitutionsVector(__isl_take isl_ast_expr *Expr, ScopStmt *Stmt,
+  void createSubstitutionsVector(isl::ast_expr Expr, ScopStmt *Stmt,
                                  std::vector<LoopToScevMapT> &VLTS,
                                  std::vector<Value *> &IVS,
                                  __isl_take isl_id *IteratorID);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112193.381119.patch
Type: text/x-patch
Size: 3833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211021/dad5c529/attachment.bin>


More information about the llvm-commits mailing list