Remove `inst` from the layout.
(&mut self, inst: Inst)
| 493 | |
| 494 | /// Remove `inst` from the layout. |
| 495 | pub fn remove_inst(&mut self, inst: Inst) { |
| 496 | let block = self.inst_block(inst).expect("Instruction already removed."); |
| 497 | // Clear the `inst` node and extract links. |
| 498 | let prev; |
| 499 | let next; |
| 500 | { |
| 501 | let n = &mut self.insts[inst]; |
| 502 | prev = n.prev; |
| 503 | next = n.next; |
| 504 | n.block = None.into(); |
| 505 | n.prev = None.into(); |
| 506 | n.next = None.into(); |
| 507 | } |
| 508 | // Fix up links to `inst`. |
| 509 | match prev.expand() { |
| 510 | None => self.blocks[block].first_inst = next, |
| 511 | Some(p) => self.insts[p].next = next, |
| 512 | } |
| 513 | match next.expand() { |
| 514 | None => self.blocks[block].last_inst = prev, |
| 515 | Some(n) => self.insts[n].prev = prev, |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /// Iterate over the instructions in `block` in layout order. |
| 520 | pub fn block_insts(&self, block: Block) -> Insts<'_> { |