| 181 | } |
| 182 | |
| 183 | target_assignments program::get_target_assignments(const std::vector<target>& targets, |
| 184 | assignment_options options) |
| 185 | { |
| 186 | const auto m = options.metric; |
| 187 | |
| 188 | target_assignments p; |
| 189 | |
| 190 | const auto* mod = get_main_module(); |
| 191 | std::vector<std::pair<target, supported_segments>> target_subgraphs; |
| 192 | target_subgraphs.reserve(targets.size()); |
| 193 | std::transform(targets.begin(), |
| 194 | targets.end(), |
| 195 | std::back_inserter(target_subgraphs), |
| 196 | [&](const auto& t) { return std::make_pair(t, t.find_supported(mod, m)); }); |
| 197 | |
| 198 | for(const auto ins : iterator_for(*mod)) |
| 199 | { |
| 200 | if(contains(p, ins)) |
| 201 | { |
| 202 | continue; |
| 203 | } |
| 204 | |
| 205 | for(const auto& [target, subgraph] : target_subgraphs) |
| 206 | { |
| 207 | // can't pass a structured binding into lambda in C++17 so create a variable for it |
| 208 | const auto& t = target; |
| 209 | for(const auto& segment : subgraph) |
| 210 | { |
| 211 | const auto& instructions = segment.instructions; |
| 212 | if(not contains(instructions, ins)) |
| 213 | { |
| 214 | continue; |
| 215 | } |
| 216 | std::transform(instructions.begin(), |
| 217 | instructions.end(), |
| 218 | std::inserter(p, p.end()), |
| 219 | [&](auto instr) { return std::make_pair(instr, t.name()); }); |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | return p; |
| 224 | } |
| 225 | |
| 226 | bool program::is_compiled() const { return not this->impl->contexts.empty(); } |
| 227 |
no test coverage detected