| 858 | } |
| 859 | |
| 860 | void permute(const std::vector<uint32_t>& base_words, const std::vector<OverlaySlot>& overlay_slots, std::vector<Permutation>& permutations) { |
| 861 | auto current = std::vector<uint32_t>(overlay_slots.size(), 0); |
| 862 | auto slot_options = std::vector<uint32_t>(overlay_slots.size(), 0); |
| 863 | |
| 864 | for (size_t i = 0; i < overlay_slots.size(); i++) { |
| 865 | slot_options[i] = overlay_slots[i].overlays.size(); |
| 866 | } |
| 867 | |
| 868 | do { |
| 869 | Permutation permutation = { |
| 870 | .instr_words = std::vector<uint32_t>(base_words), |
| 871 | .permutation = std::vector<uint32_t>(current) |
| 872 | }; |
| 873 | |
| 874 | for (size_t i = 0; i < overlay_slots.size(); i++) { |
| 875 | const OverlaySlot &slot = overlay_slots[i]; |
| 876 | const Overlay &overlay = slot.overlays[current[i]]; |
| 877 | |
| 878 | uint32_t word_offset = slot.offset / sizeof(uint32_t); |
| 879 | |
| 880 | size_t size_needed = word_offset + overlay.instr_words.size(); |
| 881 | if (permutation.instr_words.size() < size_needed) { |
| 882 | permutation.instr_words.reserve(size_needed); |
| 883 | } |
| 884 | |
| 885 | std::copy(overlay.instr_words.begin(), overlay.instr_words.end(), permutation.instr_words.data() + word_offset); |
| 886 | } |
| 887 | |
| 888 | permutations.push_back(permutation); |
| 889 | } while (next_permutation(slot_options, current)); |
| 890 | } |
| 891 | |
| 892 | std::string make_permutation_string(const std::vector<uint32_t> permutation) { |
| 893 | std::string str = ""; |
no test coverage detected