Append `inst` to the end of `block`.
(&mut self, inst: Inst, block: Block)
| 427 | |
| 428 | /// Append `inst` to the end of `block`. |
| 429 | pub fn append_inst(&mut self, inst: Inst, block: Block) { |
| 430 | debug_assert_eq!(self.inst_block(inst), None); |
| 431 | debug_assert!( |
| 432 | self.is_block_inserted(block), |
| 433 | "Cannot append instructions to block not in layout" |
| 434 | ); |
| 435 | { |
| 436 | let block_node = &mut self.blocks[block]; |
| 437 | { |
| 438 | let inst_node = &mut self.insts[inst]; |
| 439 | inst_node.block = block.into(); |
| 440 | inst_node.prev = block_node.last_inst; |
| 441 | debug_assert!(inst_node.next.is_none()); |
| 442 | } |
| 443 | if block_node.first_inst.is_none() { |
| 444 | block_node.first_inst = inst.into(); |
| 445 | } else { |
| 446 | self.insts[block_node.last_inst.unwrap()].next = inst.into(); |
| 447 | } |
| 448 | block_node.last_inst = inst.into(); |
| 449 | } |
| 450 | self.assign_inst_seq(inst); |
| 451 | } |
| 452 | |
| 453 | /// Fetch a block's first instruction. |
| 454 | pub fn first_inst(&self, block: Block) -> Option<Inst> { |