MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / insert_block

Method insert_block

cranelift/codegen/src/cursor.rs:593–607  ·  view source on GitHub ↗

Insert a block at the current position and switch to it. As far as possible, this method behaves as if the block header were an instruction inserted at the current position. - If the cursor is pointing at an existing instruction, *the current block is split in two and the current instruction becomes the first instruction in the inserted block. - If the cursor points at the bottom of a block, the

(&mut self, new_block: ir::Block)

Source from the content-addressed store, hash-verified

591 /// This means that it is always valid to call this method, and it always leaves the cursor in
592 /// a state that will insert instructions into the new block.
593 fn insert_block(&mut self, new_block: ir::Block) {
594 use self::CursorPosition::*;
595 match self.position() {
596 At(inst) => {
597 self.layout_mut().split_block(new_block, inst);
598 // All other cases move to `After(block)`, but in this case we'll stay `At(inst)`.
599 return;
600 }
601 Nowhere => self.layout_mut().append_block(new_block),
602 Before(block) => self.layout_mut().insert_block(new_block, block),
603 After(block) => self.layout_mut().insert_block_after(new_block, block),
604 }
605 // For everything but `At(inst)` we end up appending to the new block.
606 self.set_position(After(new_block));
607 }
608}
609
610/// Function cursor.

Callers

nothing calls this directly

Implementers 2

cursor.rscranelift/codegen/src/cursor.rs
layout.rscranelift/codegen/src/ir/layout.rs

Calls 6

split_blockMethod · 0.80
append_blockMethod · 0.80
positionMethod · 0.45
layout_mutMethod · 0.45
insert_block_afterMethod · 0.45
set_positionMethod · 0.45

Tested by

no test coverage detected