| 86 | } |
| 87 | |
| 88 | fn apply_rewrite_rules(rewrite_rules: &FxHashMap<Word, Word>, blocks: &mut [Block]) { |
| 89 | let apply = |inst: &mut Instruction| { |
| 90 | if let Some(ref mut id) = &mut inst.result_id { |
| 91 | if let Some(&rewrite) = rewrite_rules.get(id) { |
| 92 | *id = rewrite; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if let Some(ref mut id) = &mut inst.result_type { |
| 97 | if let Some(&rewrite) = rewrite_rules.get(id) { |
| 98 | *id = rewrite; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | inst.operands.iter_mut().for_each(|op| { |
| 103 | if let Some(id) = op.id_ref_any_mut() { |
| 104 | if let Some(&rewrite) = rewrite_rules.get(id) { |
| 105 | *id = rewrite; |
| 106 | } |
| 107 | } |
| 108 | }); |
| 109 | }; |
| 110 | for block in blocks { |
| 111 | for inst in &mut block.label { |
| 112 | apply(inst); |
| 113 | } |
| 114 | for inst in &mut block.instructions { |
| 115 | apply(inst); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | fn get_names(module: &Module) -> FxHashMap<Word, &str> { |
| 121 | let entry_names = module |