[polly] c62d9a5 - [Polly] Use subtyped isl::schedule_nodes for ScheduleTreeVisitor. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 31 18:56:01 PDT 2021


Author: Michael Kruse
Date: 2021-08-31T20:54:12-05:00
New Revision: c62d9a5ca09e22c9d08a6e2076572afc6e12a43f

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

LOG: [Polly] Use subtyped isl::schedule_nodes for ScheduleTreeVisitor. NFC.

Change pass-by-const-ref to pass-by-value as objects are recreated
due to custom up-/down-casting anwyway.

Added: 
    

Modified: 
    polly/include/polly/ScheduleTreeTransform.h
    polly/lib/Transform/ManualOptimizer.cpp
    polly/lib/Transform/ScheduleTreeTransform.cpp

Removed: 
    


################################################################################
diff  --git a/polly/include/polly/ScheduleTreeTransform.h b/polly/include/polly/ScheduleTreeTransform.h
index bdf4d77565207..5fd0d6ad4dd0c 100644
--- a/polly/include/polly/ScheduleTreeTransform.h
+++ b/polly/include/polly/ScheduleTreeTransform.h
@@ -30,81 +30,94 @@ struct ScheduleTreeVisitor {
     return *static_cast<const Derived *>(this);
   }
 
-  RetTy visit(const isl::schedule_node &Node, Args... args) {
+  RetTy visit(isl::schedule_node Node, Args... args) {
     assert(!Node.is_null());
     switch (isl_schedule_node_get_type(Node.get())) {
     case isl_schedule_node_domain:
       assert(isl_schedule_node_n_children(Node.get()) == 1);
-      return getDerived().visitDomain(Node, std::forward<Args>(args)...);
+      return getDerived().visitDomain(Node.as<isl::schedule_node_domain>(),
+                                      std::forward<Args>(args)...);
     case isl_schedule_node_band:
       assert(isl_schedule_node_n_children(Node.get()) == 1);
-      return getDerived().visitBand(Node, std::forward<Args>(args)...);
+      return getDerived().visitBand(Node.as<isl::schedule_node_band>(),
+                                    std::forward<Args>(args)...);
     case isl_schedule_node_sequence:
       assert(isl_schedule_node_n_children(Node.get()) >= 2);
-      return getDerived().visitSequence(Node, std::forward<Args>(args)...);
+      return getDerived().visitSequence(Node.as<isl::schedule_node_sequence>(),
+                                        std::forward<Args>(args)...);
     case isl_schedule_node_set:
-      return getDerived().visitSet(Node, std::forward<Args>(args)...);
+      return getDerived().visitSet(Node.as<isl::schedule_node_set>(),
+                                   std::forward<Args>(args)...);
       assert(isl_schedule_node_n_children(Node.get()) >= 2);
     case isl_schedule_node_leaf:
       assert(isl_schedule_node_n_children(Node.get()) == 0);
-      return getDerived().visitLeaf(Node, std::forward<Args>(args)...);
+      return getDerived().visitLeaf(Node.as<isl::schedule_node_leaf>(),
+                                    std::forward<Args>(args)...);
     case isl_schedule_node_mark:
       assert(isl_schedule_node_n_children(Node.get()) == 1);
-      return getDerived().visitMark(Node, std::forward<Args>(args)...);
+      return getDerived().visitMark(Node.as<isl::schedule_node_mark>(),
+                                    std::forward<Args>(args)...);
     case isl_schedule_node_extension:
       assert(isl_schedule_node_n_children(Node.get()) == 1);
-      return getDerived().visitExtension(Node, std::forward<Args>(args)...);
+      return getDerived().visitExtension(
+          Node.as<isl::schedule_node_extension>(), std::forward<Args>(args)...);
     case isl_schedule_node_filter:
       assert(isl_schedule_node_n_children(Node.get()) == 1);
-      return getDerived().visitFilter(Node, std::forward<Args>(args)...);
+      return getDerived().visitFilter(Node.as<isl::schedule_node_filter>(),
+                                      std::forward<Args>(args)...);
     default:
       llvm_unreachable("unimplemented schedule node type");
     }
   }
 
-  RetTy visitDomain(const isl::schedule_node &Domain, Args... args) {
-    return getDerived().visitSingleChild(Domain, std::forward<Args>(args)...);
+  RetTy visitDomain(isl::schedule_node_domain Domain, Args... args) {
+    return getDerived().visitSingleChild(std::move(Domain),
+                                         std::forward<Args>(args)...);
   }
 
-  RetTy visitBand(const isl::schedule_node &Band, Args... args) {
-    return getDerived().visitSingleChild(Band, std::forward<Args>(args)...);
+  RetTy visitBand(isl::schedule_node_band Band, Args... args) {
+    return getDerived().visitSingleChild(std::move(Band),
+                                         std::forward<Args>(args)...);
   }
 
-  RetTy visitSequence(const isl::schedule_node &Sequence, Args... args) {
-    return getDerived().visitMultiChild(Sequence, std::forward<Args>(args)...);
+  RetTy visitSequence(isl::schedule_node_sequence Sequence, Args... args) {
+    return getDerived().visitMultiChild(std::move(Sequence),
+                                        std::forward<Args>(args)...);
   }
 
-  RetTy visitSet(const isl::schedule_node &Set, Args... args) {
-    return getDerived().visitMultiChild(Set, std::forward<Args>(args)...);
+  RetTy visitSet(isl::schedule_node_set Set, Args... args) {
+    return getDerived().visitMultiChild(std::move(Set),
+                                        std::forward<Args>(args)...);
   }
 
-  RetTy visitLeaf(const isl::schedule_node &Leaf, Args... args) {
-    return getDerived().visitNode(Leaf, std::forward<Args>(args)...);
+  RetTy visitLeaf(isl::schedule_node_leaf Leaf, Args... args) {
+    return getDerived().visitNode(std::move(Leaf), std::forward<Args>(args)...);
   }
 
-  RetTy visitMark(const isl::schedule_node &Mark, Args... args) {
-    return getDerived().visitSingleChild(Mark, std::forward<Args>(args)...);
+  RetTy visitMark(isl::schedule_node_mark Mark, Args... args) {
+    return getDerived().visitSingleChild(std::move(Mark),
+                                         std::forward<Args>(args)...);
   }
 
-  RetTy visitExtension(const isl::schedule_node &Extension, Args... args) {
-    return getDerived().visitSingleChild(Extension,
+  RetTy visitExtension(isl::schedule_node_extension Extension, Args... args) {
+    return getDerived().visitSingleChild(std::move(Extension),
                                          std::forward<Args>(args)...);
   }
 
-  RetTy visitFilter(const isl::schedule_node &Extension, Args... args) {
-    return getDerived().visitSingleChild(Extension,
+  RetTy visitFilter(isl::schedule_node_filter Filter, Args... args) {
+    return getDerived().visitSingleChild(std::move(Filter),
                                          std::forward<Args>(args)...);
   }
 
-  RetTy visitSingleChild(const isl::schedule_node &Node, Args... args) {
-    return getDerived().visitNode(Node, std::forward<Args>(args)...);
+  RetTy visitSingleChild(isl::schedule_node Node, Args... args) {
+    return getDerived().visitNode(std::move(Node), std::forward<Args>(args)...);
   }
 
-  RetTy visitMultiChild(const isl::schedule_node &Node, Args... args) {
-    return getDerived().visitNode(Node, std::forward<Args>(args)...);
+  RetTy visitMultiChild(isl::schedule_node Node, Args... args) {
+    return getDerived().visitNode(std::move(Node), std::forward<Args>(args)...);
   }
 
-  RetTy visitNode(const isl::schedule_node &Node, Args... args) {
+  RetTy visitNode(isl::schedule_node Node, Args... args) {
     llvm_unreachable("Unimplemented other");
   }
 };
@@ -122,18 +135,18 @@ struct RecursiveScheduleTreeVisitor
   }
 
   /// When visiting an entire schedule tree, start at its root node.
-  RetTy visit(const isl::schedule &Schedule, Args... args) {
+  RetTy visit(isl::schedule Schedule, Args... args) {
     return getDerived().visit(Schedule.get_root(), std::forward<Args>(args)...);
   }
 
   // Necessary to allow overload resolution with the added visit(isl::schedule)
   // overload.
-  RetTy visit(const isl::schedule_node &Node, Args... args) {
+  RetTy visit(isl::schedule_node Node, Args... args) {
     return getBase().visit(Node, std::forward<Args>(args)...);
   }
 
   /// By default, recursively visit the child nodes.
-  RetTy visitNode(const isl::schedule_node &Node, Args... args) {
+  RetTy visitNode(isl::schedule_node Node, Args... args) {
     isl_size NumChildren = Node.n_children().release();
     for (isl_size i = 0; i < NumChildren; i += 1)
       getDerived().visit(Node.child(i), std::forward<Args>(args)...);

diff  --git a/polly/lib/Transform/ManualOptimizer.cpp b/polly/lib/Transform/ManualOptimizer.cpp
index 2622f682d7a4c..2a77f7d49ae22 100644
--- a/polly/lib/Transform/ManualOptimizer.cpp
+++ b/polly/lib/Transform/ManualOptimizer.cpp
@@ -108,7 +108,7 @@ class SearchTransformVisitor
     return Transformer.Result;
   }
 
-  void visitBand(const isl::schedule_node &Band) {
+  void visitBand(isl::schedule_node_band Band) {
     // Transform inner loops first (depth-first search).
     getBase().visitBand(Band);
     if (!Result.is_null())
@@ -153,7 +153,7 @@ class SearchTransformVisitor
     }
   }
 
-  void visitNode(const isl::schedule_node &Other) {
+  void visitNode(isl::schedule_node Other) {
     if (!Result.is_null())
       return;
     getBase().visitNode(Other);

diff  --git a/polly/lib/Transform/ScheduleTreeTransform.cpp b/polly/lib/Transform/ScheduleTreeTransform.cpp
index 3ce005e3c4b22..f8ca449744740 100644
--- a/polly/lib/Transform/ScheduleTreeTransform.cpp
+++ b/polly/lib/Transform/ScheduleTreeTransform.cpp
@@ -69,12 +69,12 @@ struct ScheduleTreeRewriter
     return *static_cast<const Derived *>(this);
   }
 
-  isl::schedule visitDomain(const isl::schedule_node &Node, Args... args) {
+  isl::schedule visitDomain(isl::schedule_node_domain Node, Args... args) {
     // Every schedule_tree already has a domain node, no need to add one.
     return getDerived().visit(Node.first_child(), std::forward<Args>(args)...);
   }
 
-  isl::schedule visitBand(const isl::schedule_node &Band, Args... args) {
+  isl::schedule visitBand(isl::schedule_node_band Band, Args... args) {
     isl::multi_union_pw_aff PartialSched =
         isl::manage(isl_schedule_node_band_get_partial_schedule(Band.get()));
     isl::schedule NewChild =
@@ -94,7 +94,7 @@ struct ScheduleTreeRewriter
     return NewNode.get_schedule();
   }
 
-  isl::schedule visitSequence(const isl::schedule_node &Sequence,
+  isl::schedule visitSequence(isl::schedule_node_sequence Sequence,
                               Args... args) {
     int NumChildren = isl_schedule_node_n_children(Sequence.get());
     isl::schedule Result =
@@ -105,7 +105,7 @@ struct ScheduleTreeRewriter
     return Result;
   }
 
-  isl::schedule visitSet(const isl::schedule_node &Set, Args... args) {
+  isl::schedule visitSet(isl::schedule_node_set Set, Args... args) {
     int NumChildren = isl_schedule_node_n_children(Set.get());
     isl::schedule Result =
         getDerived().visit(Set.child(0), std::forward<Args>(args)...);
@@ -118,7 +118,7 @@ struct ScheduleTreeRewriter
     return Result;
   }
 
-  isl::schedule visitLeaf(const isl::schedule_node &Leaf, Args... args) {
+  isl::schedule visitLeaf(isl::schedule_node_leaf Leaf, Args... args) {
     return isl::schedule::from_domain(Leaf.get_domain());
   }
 
@@ -133,7 +133,7 @@ struct ScheduleTreeRewriter
     return NewChild.insert_mark(TheMark).get_schedule();
   }
 
-  isl::schedule visitExtension(const isl::schedule_node &Extension,
+  isl::schedule visitExtension(isl::schedule_node_extension Extension,
                                Args... args) {
     isl::union_map TheExtension =
         Extension.as<isl::schedule_node_extension>().get_extension();
@@ -146,7 +146,7 @@ struct ScheduleTreeRewriter
     return NewChild.graft_before(NewExtension).get_schedule();
   }
 
-  isl::schedule visitFilter(const isl::schedule_node &Filter, Args... args) {
+  isl::schedule visitFilter(isl::schedule_node_filter Filter, Args... args) {
     isl::union_set FilterDomain =
         Filter.as<isl::schedule_node_filter>().get_filter();
     isl::schedule NewSchedule =
@@ -154,7 +154,7 @@ struct ScheduleTreeRewriter
     return NewSchedule.intersect_domain(FilterDomain);
   }
 
-  isl::schedule visitNode(const isl::schedule_node &Node, Args... args) {
+  isl::schedule visitNode(isl::schedule_node Node, Args... args) {
     llvm_unreachable("Not implemented");
   }
 };
@@ -178,7 +178,7 @@ struct ExtensionNodeRewriter
   BaseTy &getBase() { return *this; }
   const BaseTy &getBase() const { return *this; }
 
-  isl::schedule visitSchedule(const isl::schedule &Schedule) {
+  isl::schedule visitSchedule(isl::schedule Schedule) {
     isl::union_map Extensions;
     isl::schedule Result =
         visit(Schedule.get_root(), Schedule.get_domain(), Extensions);
@@ -186,7 +186,7 @@ struct ExtensionNodeRewriter
     return Result;
   }
 
-  isl::schedule visitSequence(const isl::schedule_node &Sequence,
+  isl::schedule visitSequence(isl::schedule_node_sequence Sequence,
                               const isl::union_set &Domain,
                               isl::union_map &Extensions) {
     int NumChildren = isl_schedule_node_n_children(Sequence.get());
@@ -201,7 +201,7 @@ struct ExtensionNodeRewriter
     return NewNode;
   }
 
-  isl::schedule visitSet(const isl::schedule_node &Set,
+  isl::schedule visitSet(isl::schedule_node_set Set,
                          const isl::union_set &Domain,
                          isl::union_map &Extensions) {
     int NumChildren = isl_schedule_node_n_children(Set.get());
@@ -217,14 +217,14 @@ struct ExtensionNodeRewriter
     return NewNode;
   }
 
-  isl::schedule visitLeaf(const isl::schedule_node &Leaf,
+  isl::schedule visitLeaf(isl::schedule_node_leaf Leaf,
                           const isl::union_set &Domain,
                           isl::union_map &Extensions) {
     Extensions = isl::union_map::empty(Leaf.ctx());
     return isl::schedule::from_domain(Domain);
   }
 
-  isl::schedule visitBand(const isl::schedule_node &OldNode,
+  isl::schedule visitBand(isl::schedule_node_band OldNode,
                           const isl::union_set &Domain,
                           isl::union_map &OuterExtensions) {
     isl::schedule_node OldChild = OldNode.first_child();
@@ -274,7 +274,7 @@ struct ExtensionNodeRewriter
     return NewNode.get_schedule();
   }
 
-  isl::schedule visitFilter(const isl::schedule_node &Filter,
+  isl::schedule visitFilter(isl::schedule_node_filter Filter,
                             const isl::union_set &Domain,
                             isl::union_map &Extensions) {
     isl::union_set FilterDomain =
@@ -285,7 +285,7 @@ struct ExtensionNodeRewriter
     return visit(Filter.first_child(), NewDomain, Extensions);
   }
 
-  isl::schedule visitExtension(const isl::schedule_node &Extension,
+  isl::schedule visitExtension(isl::schedule_node_extension Extension,
                                const isl::union_set &Domain,
                                isl::union_map &Extensions) {
     isl::union_map ExtDomain =
@@ -311,7 +311,7 @@ struct CollectASTBuildOptions
 
   llvm::SmallVector<isl::union_set, 8> ASTBuildOptions;
 
-  void visitBand(const isl::schedule_node &Band) {
+  void visitBand(isl::schedule_node_band Band) {
     ASTBuildOptions.push_back(
         isl::manage(isl_schedule_node_band_get_ast_build_options(Band.get())));
     return getBase().visitBand(Band);
@@ -335,7 +335,7 @@ struct ApplyASTBuildOptions
   ApplyASTBuildOptions(llvm::ArrayRef<isl::union_set> ASTBuildOptions)
       : ASTBuildOptions(ASTBuildOptions) {}
 
-  isl::schedule visitSchedule(const isl::schedule &Schedule) {
+  isl::schedule visitSchedule(isl::schedule Schedule) {
     Pos = 0;
     isl::schedule Result = visit(Schedule).get_schedule();
     assert(Pos == ASTBuildOptions.size() &&
@@ -343,10 +343,9 @@ struct ApplyASTBuildOptions
     return Result;
   }
 
-  isl::schedule_node visitBand(const isl::schedule_node &Band) {
-    isl::schedule_node Result =
-        Band.as<isl::schedule_node_band>().set_ast_build_options(
-            ASTBuildOptions[Pos]);
+  isl::schedule_node visitBand(isl::schedule_node_band Band) {
+    isl::schedule_node_band Result =
+        Band.set_ast_build_options(ASTBuildOptions[Pos]);
     Pos += 1;
     return getBase().visitBand(Result);
   }


        


More information about the llvm-commits mailing list