[PATCH] D48651: [RFC] Pattern matching on schedule trees.

Oleksandr "Alex" Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 29 03:06:59 PDT 2018


ftynse added inline comments.


================
Comment at: include/polly/ScheduleOptimizer.h:50
+
+Suggestions on how to do that? 
+
----------------
It depends on what you need exactly.  Just one node without specifying a type?  Does that mean that the node _does_ exist or _may_ exist?   Do you want to skip over multiple levels of the tree?  Do you want to skip over multiple siblings?  One can go shell-like wildcard way with `?` and `*`.  Or some flavor of regular expressions, but this quickly goes out of hand.  I'd like to see examples of what needs to be expressed before taking a decision.  My feeling after using different flavors of schedule trees is that you probably need some traversal matchers like `hasSibling` or `hasDescendant`


================
Comment at: include/polly/ScheduleOptimizer.h:53
+enum class NodeKind {
+  WildcardNode = isl_schedule_node_type::isl_schedule_node_set,
+};
----------------
`set` is actually an tricky one, because it explicitly says the order of children does not matter.  This implementation does not account for that, not sure if it should


================
Comment at: include/polly/matchers-inl.h:13
+  {
+    //TODO: Ask Alex.
+    vec.push_back(a);
----------------
about what?


================
Comment at: lib/Transform/ScheduleOptimizer.cpp:1713
+  // try different constructors for matchers. (to be removed)
+  auto MatcherObj = matchers::domain(matchers::sequence(matchers::filter(matchers::band()),matchers::filter(matchers::band())));
+  MatcherObj.printMatcher(llvm::dbgs(), MatcherObj, 2);
----------------
The idea is to use a scoped `using namespace` to make it less verbose.  Optionally, add trailing comments to tell clang-format to leave the formatting alone and reflect the tree structure.
```c++
{
  using namespace matchers;
  auto matcher =
      domain(                    // d
        sequence(              // s
          filter(                     // f
            band()),                // b
          filter(                     // f
            band())));              // b
}
```


Repository:
  rPLO Polly

https://reviews.llvm.org/D48651





More information about the llvm-commits mailing list