"include/vscode:/vscode.git/clone" did not exist on "cd51732690641ae0ac76f90641246214f4a95bf9"
Unverified Commit 4bce712a authored by Umang Yadav's avatar Umang Yadav Committed by GitHub
Browse files

Use matcher name for the `TRACE_MATCHES_FOR` (#2127)

parent 6f1c947f
...@@ -381,22 +381,24 @@ void find_matches_for(source_location location, Mod& mod, instruction_ref ins, M ...@@ -381,22 +381,24 @@ void find_matches_for(source_location location, Mod& mod, instruction_ref ins, M
const int trace = value_of(MIGRAPHX_TRACE_MATCHES{}); const int trace = value_of(MIGRAPHX_TRACE_MATCHES{});
const bool validate = enabled(MIGRAPHX_VALIDATE_MATCHES{}); const bool validate = enabled(MIGRAPHX_VALIDATE_MATCHES{});
const auto trace_filter = string_value_of(MIGRAPHX_TRACE_MATCHES_FOR{}); const auto trace_filter = string_value_of(MIGRAPHX_TRACE_MATCHES_FOR{});
const bool trace_for = not trace_filter.empty() and bool match = false;
(contains(std::string{location.file_name()}, trace_filter) or
contains(std::string{location.function_name()}, trace_filter));
bool match = false;
each_args( each_args(
[&](auto&& m) { [&](auto&& m) {
const auto& matcher_name = get_type_name(m);
const bool trace_for = not trace_filter.empty() and
(contains(std::string{location.file_name()}, trace_filter) or
contains(std::string{location.function_name()}, trace_filter) or
contains(matcher_name, trace_filter));
if(match) if(match)
return; return;
if(trace > 1 or trace_for) if(trace > 1 and trace_for)
std::cout << "Match: " << get_type_name(m) << std::endl; std::cout << "Match: " << matcher_name << std::endl;
auto r = match_instruction(get_module(mod), ins, m.matcher()); auto r = match_instruction(get_module(mod), ins, m.matcher());
if(r.result == get_module(mod).end()) if(r.result == get_module(mod).end())
return; return;
if(trace > 0 or trace_for) if(trace > 0 or trace_for)
{ {
std::cout << "Matched by " << get_type_name(m) << std::endl; std::cout << "Matched by " << matcher_name << std::endl;
get_module(mod).debug_print(ins); get_module(mod).debug_print(ins);
} }
// If its already invalid dont validate it again // If its already invalid dont validate it again
...@@ -407,7 +409,7 @@ void find_matches_for(source_location location, Mod& mod, instruction_ref ins, M ...@@ -407,7 +409,7 @@ void find_matches_for(source_location location, Mod& mod, instruction_ref ins, M
auto invalid = get_module(mod).validate(); auto invalid = get_module(mod).validate();
if(invalid != get_module(mod).end()) if(invalid != get_module(mod).end())
{ {
std::cout << "Invalid program from match: " << get_type_name(m) << std::endl; std::cout << "Invalid program from match: " << matcher_name << std::endl;
std::cout << "Invalid instructions: " << std::endl; std::cout << "Invalid instructions: " << std::endl;
get_module(mod).debug_print(invalid->inputs()); get_module(mod).debug_print(invalid->inputs());
get_module(mod).debug_print(invalid); get_module(mod).debug_print(invalid);
......
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