Struct cranelift_codegen::ir::instructions::BlockCall
source · pub struct BlockCall { /* private fields */ }
Expand description
A pair of a Block and its arguments, stored in a single EntityList internally.
NOTE: We don’t expose either value_to_block or block_to_value outside of this module because this operation is not generally safe. However, as the two share the same underlying layout, they can be stored in the same value pool.
BlockCall makes use of this shared layout by storing all of its contents (a block and its argument) in a single EntityList. This is a bit better than introducing a new entity type for the pair of a block name and the arguments entity list, as we don’t pay any indirection penalty to get to the argument values – they’re stored in-line with the block in the same list.
The BlockCall::new function guarantees this layout by requiring a block argument that’s written in as the first element of the EntityList. Any subsequent entries are always assumed to be real Values.
Implementations§
source§impl BlockCall
impl BlockCall
sourcepub fn new(block: Block, args: &[Value], pool: &mut ValueListPool) -> Self
pub fn new(block: Block, args: &[Value], pool: &mut ValueListPool) -> Self
Construct a BlockCall with the given block and arguments.
sourcepub fn block(&self, pool: &ValueListPool) -> Block
pub fn block(&self, pool: &ValueListPool) -> Block
Return the block for this BlockCall.
sourcepub fn set_block(&mut self, block: Block, pool: &mut ValueListPool)
pub fn set_block(&mut self, block: Block, pool: &mut ValueListPool)
Replace the block for this BlockCall.
sourcepub fn append_argument(&mut self, arg: Value, pool: &mut ValueListPool)
pub fn append_argument(&mut self, arg: Value, pool: &mut ValueListPool)
Append an argument to the block args.
sourcepub fn args_slice<'a>(&self, pool: &'a ValueListPool) -> &'a [Value]
pub fn args_slice<'a>(&self, pool: &'a ValueListPool) -> &'a [Value]
Return a slice for the arguments of this block.
sourcepub fn args_slice_mut<'a>(
&'a mut self,
pool: &'a mut ValueListPool
) -> &'a mut [Value]
pub fn args_slice_mut<'a>( &'a mut self, pool: &'a mut ValueListPool ) -> &'a mut [Value]
Return a slice for the arguments of this block.
sourcepub fn remove(&mut self, ix: usize, pool: &mut ValueListPool)
pub fn remove(&mut self, ix: usize, pool: &mut ValueListPool)
Remove the argument at ix from the argument list.
sourcepub fn clear(&mut self, pool: &mut ValueListPool)
pub fn clear(&mut self, pool: &mut ValueListPool)
Clear out the arguments list.
sourcepub fn extend<I>(&mut self, elements: I, pool: &mut ValueListPool)where
I: IntoIterator<Item = Value>,
pub fn extend<I>(&mut self, elements: I, pool: &mut ValueListPool)where I: IntoIterator<Item = Value>,
Appends multiple elements to the arguments.
sourcepub fn display<'a>(&self, pool: &'a ValueListPool) -> DisplayBlockCall<'a>
pub fn display<'a>(&self, pool: &'a ValueListPool) -> DisplayBlockCall<'a>
Return a value that can display this block call.