pub struct Block(pub Index);
Expand description

A wrapper around an ECS handle into the Context.

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.

Get the number of instructions in this block, NOT including the phi instruction.

Get the phi instruction for this block.

Get the number of predecessor blocks, i.e., blocks which branch to this one.

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.

Add PHI entries to this block from the given iterator.

Get an iterator over this block’s PHI pairs.

Get the value from the phi instruction which correlates to from_block.

Returns None if from_block isn’t found.

Remove the value in the phi instruction which correlates to from_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.

Get a mut reference to the block terminator.

Returns None if block is empty.

Return whether this block is already terminated. Checks if the final instruction, if it exists, is a terminator.

Return whether this block is already terminated specifically by a Ret instruction.

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! Ideally we use get a user/uses system implemented. Using Vec::remove() is also O(n) which we may want to avoid someday.

Replace an instruction in this block with another. Will return a ValueNotFound on error. Any use of the old instruction value will also be replaced by the new value throughout the owning function.

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.

Return an instruction iterator for each instruction in this block.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.