pub struct Block(pub Index);
Tuple Fields
0: Index
Implementations
Return a new block handle.
Creates a new Block belonging to function
in the context and returns its handle. label
is optional and is used only when printing the IR.
Get the parent function for this block.
Create a new InstructionIterator
to more easily append instructions to this block.
Get the label of this block. If it wasn’t given one upon creation it will be a generated label.
Add a new phi entry to this block.
This indicates that if control flow comes from from_block
then the phi instruction should
use phi_value
.
Get the value from the phi instruction which correlates to from_block
.
Returns None
if from_block
isn’t found.
pub fn update_phi_source_block(
&self,
context: &mut Context,
old_source: Block,
new_source: Block
)
pub fn update_phi_source_block(
&self,
context: &mut Context,
old_source: Block,
new_source: Block
)
Replace a block reference in the phi instruction.
Any reference to old_source
will be replace with new_source
in the list of phi values.
Get a reference to the block terminator.
Returns None
if block is empty.
Replace a value within this block.
For every instruction within the block, any reference to old_val
is replaced with
new_val
.
Remove an instruction from this block.
NOTE: We must be very careful! We mustn’t remove the phi or the terminator. Some
extra checks should probably be performed here to avoid corruption! Using Vec::remove()
is also O(n) which we may want to avoid someday.
Split the block into two.
This will create a new block and move the instructions at and following split_idx
to it.
Returns both blocks.
pub fn instruction_iter(&self, context: &Context) -> InstructionIteratorⓘNotable traits for InstructionIteratorimpl Iterator for InstructionIterator type Item = Value;
pub fn instruction_iter(&self, context: &Context) -> InstructionIteratorⓘNotable traits for InstructionIteratorimpl Iterator for InstructionIterator type Item = Value;
impl Iterator for InstructionIterator type Item = Value;
Return an instruction iterator for each instruction in this block.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Block
impl UnwindSafe for Block
Blanket Implementations
Mutably borrows from an owned value. Read more