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

Get the i’th block arg.

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

Add a new block argument of type ty. Returns its index.

Add a block argument, asserts that arg is suitable here.

Get an iterator over this block’s args.

How many args does this block have?

Get an iterator over this block’s predecessor blocks.

Add from_block to the set of predecessors of this block.

Remove from_block from the set of predecessors of this block.

Replace a old_source with new_source as a predecessor.

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.

For a particular successor (if it indeed is one), get the parameters passed.

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.