| 7 | use std::mem::take; |
| 8 | |
| 9 | pub fn shift_ids(module: &mut Module, add: u32) { |
| 10 | module.all_inst_iter_mut().for_each(|inst| { |
| 11 | if let Some(ref mut result_id) = &mut inst.result_id { |
| 12 | *result_id += add; |
| 13 | } |
| 14 | |
| 15 | if let Some(ref mut result_type) = &mut inst.result_type { |
| 16 | *result_type += add; |
| 17 | } |
| 18 | |
| 19 | inst.operands.iter_mut().for_each(|op| { |
| 20 | if let Some(w) = op.id_ref_any_mut() { |
| 21 | *w += add; |
| 22 | } |
| 23 | }); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | /// spir-v requires basic blocks to be ordered so that if A dominates B, A appears before B (except |
| 28 | /// in the case of backedges). Reverse post-order is a good ordering that satisfies this condition |