11struct MatchBaseVisitor;
12struct ConstMatchBaseVisitor;
17 virtual void accept(MatchBaseVisitor &v) = 0;
18 virtual void accept(ConstMatchBaseVisitor &v)
const = 0;
24#define DECLARE(CLASS) \
26namespace interpreter { struct CLASS; } \
27template<> struct Match<interpreter::CLASS>; \
29namespace interpreter { \
31struct CLASS : PhysicalOperator<CLASS, m::CLASS> \
33 static void execute(const Match<CLASS>&, setup_t, pipeline_t, teardown_t) { M_unreachable("not implemented"); } \
34 static double cost(const Match<CLASS>&) { return 1.0; } \
36 adapt_post_conditions(const Match<CLASS>&, std::vector<std::reference_wrapper<const ConditionSet>>&&) { \
37 return ConditionSet();
\
44struct Match<interpreter::CLASS> : interpreter::MatchBase \
47 std::vector<unsharable_shared_ptr<const interpreter::MatchBase>> children; \
49 Match(const CLASS *op, std::vector<unsharable_shared_ptr<const m::MatchBase>> &&children) \
51 , children([&children](){ \
52 std::vector<unsharable_shared_ptr<const interpreter::MatchBase>> res; \
53 for (auto &c : children) \
54 res.push_back(as<const interpreter::MatchBase>(std::move(c))); \
59 void execute(setup_t, pipeline_t, teardown_t) const override { \
60 M_unreachable("must not be called since `Interpreter` uses former visitor pattern on logical operators for " \
64 const Operator & get_matched_root() const override { return op; } \
66 void accept(interpreter::MatchBaseVisitor &v) override; \
67 void accept(interpreter::ConstMatchBaseVisitor &v) const override; \
70 void print(std::ostream &out, unsigned level) const override { \
71 indent(out, level) << "interpreter::" << #CLASS << " (cumulative cost " << cost() << ')'; \
72 for (auto &child : children) \
73 child->print(out, level + 1); \
81namespace interpreter {
83#define MAKE_INTERPRETER_MATCH_(OP) m::Match<m::interpreter::OP>
84#define M_INTERPRETER_MATCH_LIST(X) M_TRANSFORM_X_MACRO(X, M_OPERATOR_LIST, MAKE_INTERPRETER_MATCH_)
93 using super = std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>;
98 using super::operator();
99#define DECLARE(CLASS) \
100 void operator()(Const<CLASS> &M) override { for (auto &c : M.children) (*this)(*c); }
110 using super = std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>;
121 using super = std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>;
#define M_INTERPRETER_MATCH_LIST(X)
#define M_OPERATOR_LIST(X)
#define M_DECLARE_VISITOR(VISITOR_NAME, BASE_CLASS, CLASS_LIST)
Defines a visitor VISITOR_NAME to visit the class hierarchy rooted in BASE_CLASS and with subclasses ...
#define M_MAKE_STL_VISITABLE(VISITOR, BASE_CLASS, CLASS_LIST)
Defines a function visit() to make the class hierarchy STL-style visitable with VISITOR.
The physical optimizer interface.
An abstract MatchBase for the Interpreter backend.
virtual void accept(ConstMatchBaseVisitor &v) const =0
virtual void accept(MatchBaseVisitor &v)=0
std::conditional_t< C, ConstMatchBaseVisitor, MatchBaseVisitor > super
void operator()(Const< MatchBase > &)
typename super::template Const< T > Const
virtual ~ThePostOrderMatchBaseVisitor()
typename super::template Const< T > Const
std::conditional_t< C, ConstMatchBaseVisitor, MatchBaseVisitor > super
virtual ~ThePreOrderMatchBaseVisitor()
void operator()(Const< MatchBase > &)
A generic base class for implementing recursive interpreter::MatchBase visitors.
typename super::template Const< T > Const
std::conditional_t< C, ConstMatchBaseVisitor, MatchBaseVisitor > super
virtual ~TheRecursiveMatchBaseVisitorBase()