Return set of all instructions that are connected to both start and end nodes (inclusive)
| 693 | |
| 694 | // Return set of all instructions that are connected to both start and end nodes (inclusive) |
| 695 | std::unordered_set<instruction_ref> |
| 696 | find_instructions_between(instruction_ref start, instruction_ref end, const_module_ref m) |
| 697 | { |
| 698 | assert(reaches(start, end, m)); |
| 699 | std::unordered_set<instruction_ref> result; |
| 700 | std::unordered_set<instruction_ref> inss; |
| 701 | |
| 702 | fix<void>([&](auto self, auto ins) { |
| 703 | if(not m->has_instruction(ins)) |
| 704 | return; |
| 705 | if(ins->inputs().empty()) |
| 706 | return; |
| 707 | if(not inss.insert(ins).second) |
| 708 | return; |
| 709 | if(ins == start) |
| 710 | return; |
| 711 | for(auto input : ins->inputs()) |
| 712 | self(input); |
| 713 | })(end); |
| 714 | |
| 715 | fix<void>([&](auto self, auto ins) { |
| 716 | if(ins == end) |
| 717 | return; |
| 718 | if(ins != start and not contains(inss, ins)) |
| 719 | return; |
| 720 | if(not result.insert(ins).second) |
| 721 | return; |
| 722 | for(auto output : ins->outputs()) |
| 723 | self(output); |
| 724 | })(start); |
| 725 | result.insert(end); |
| 726 | return result; |
| 727 | } |
| 728 | |
| 729 | } // namespace MIGRAPHX_INLINE_NS |
| 730 | } // namespace migraphx |
no test coverage detected