Commit 445d4b31 authored by Paul's avatar Paul
Browse files

Move everything to matchers namespace

parent aab3016d
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
namespace migraph { namespace migraph {
namespace matchers {
struct matcher_context struct matcher_context
{ {
matcher_context(instruction_ref i) : last(i) {} matcher_context(instruction_ref i) : last(i) {}
...@@ -156,7 +158,7 @@ basic_matcher<predicate_matcher<P>> make_basic_pred_matcher(P p) ...@@ -156,7 +158,7 @@ basic_matcher<predicate_matcher<P>> make_basic_pred_matcher(P p)
{ \ { \
instruction_ref match(__VA_ARGS__) const; \ instruction_ref match(__VA_ARGS__) const; \
}; \ }; \
const constexpr auto name = migraph::basic_matcher<name##_m>{{}}; \ const constexpr auto name = migraph::matchers::basic_matcher<name##_m>{{}}; \
inline instruction_ref name##_m::match(__VA_ARGS__) const inline instruction_ref name##_m::match(__VA_ARGS__) const
#define MIGRAPH_PRED_MATCHER(name, ...) \ #define MIGRAPH_PRED_MATCHER(name, ...) \
...@@ -164,7 +166,7 @@ basic_matcher<predicate_matcher<P>> make_basic_pred_matcher(P p) ...@@ -164,7 +166,7 @@ basic_matcher<predicate_matcher<P>> make_basic_pred_matcher(P p)
{ \ { \
bool operator()(__VA_ARGS__) const; \ bool operator()(__VA_ARGS__) const; \
}; \ }; \
const constexpr auto name = migraph::basic_matcher<predicate_matcher<name##_m>>{{}}; \ const constexpr auto name = migraph::matchers::basic_matcher<predicate_matcher<name##_m>>{{}}; \
inline bool name##_m::operator()(__VA_ARGS__) const inline bool name##_m::operator()(__VA_ARGS__) const
struct matcher_result struct matcher_result
...@@ -184,8 +186,6 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m) ...@@ -184,8 +186,6 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m)
return result; return result;
} }
namespace matchers {
template <class... Ts> template <class... Ts>
auto all_of(Ts... ms) auto all_of(Ts... ms)
{ {
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
namespace matchers = migraph::matchers; namespace matchers = migraph::matchers;
template <class M> template <class M>
migraph::matcher_result find_match(migraph::program& p, M&& m) migraph::matchers::matcher_result find_match(migraph::program& p, M&& m)
{ {
migraph::matcher_result result; migraph::matchers::matcher_result result;
for(auto ins : migraph::iterator_for(p)) for(auto ins : migraph::iterator_for(p))
{ {
result = migraph::match_instruction(p, ins, m); result = migraph::matchers::match_instruction(p, ins, m);
if(result.result != p.end()) if(result.result != p.end())
return result; return result;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment