[PATCH] D48651: [RFC] Pattern matching on schedule trees.
Philip Pfaffe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 27 10:13:16 PDT 2018
philip.pfaffe added a comment.
This was how my API worked:
#include "isl/isl-noexceptions.h"
#include <vector>
enum class schedule_node_type {
error = -1,
band,
context,
domain,
expansion,
extension,
filter,
leaf,
guard,
mark,
sequence,
set,
any
};
struct Matcher {
/* implicit */ Matcher(schedule_node_type T) : MatchedType(T) {}
Matcher(schedule_node_type T, Matcher &&Inner)
: MatchedType(T), InnerMatchers({Inner}) {}
template <typename... MatcherTs>
Matcher(schedule_node_type T, MatcherTs &&... Matchers)
: Matcher(T, {std::forward<MatcherTs>(Matchers)...}) {}
Matcher(schedule_node_type T, std::initializer_list<Matcher> Inner)
: MatchedType(T), InnerMatchers(Inner) {}
isl::schedule_node match();
template <typename Callable> isl::schedule_node match(Callable &&);
schedule_node_type MatchedType;
std::vector<Matcher> InnerMatchers;
};
int main() {
{
Matcher M{schedule_node_type::domain,
{schedule_node_type::sequence,
{schedule_node_type::filter, {schedule_node_type::filter}},
{schedule_node_type::filter, {schedule_node_type::filter}}}};
}
}
I prefer not using macros. With this implementation you get only one callback per full match, not per matched subtree, but I felt like this is all I needed.
Repository:
rPLO Polly
https://reviews.llvm.org/D48651
More information about the llvm-commits
mailing list