pub struct DetachedMut<'a, 'str> {
pub body: &'a mut FunctionBody<'str>,
pub shared: &'a Shared<'str>,
pub interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>,
}Expand description
The exclusive mutation host for a detached (minted, not-yet-installed) function body. See the module docs: all verbs are body-local.
Fields§
§body: &'a mut FunctionBody<'str>The detached body being built (no registry identity until install).
The module’s shared IR state, read-only (types/literals minted through the
interners’ &self paths).
interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>Every function’s published interface (never checked out).
Implementations§
Source§impl<'a, 'str> DetachedMut<'a, 'str>
impl<'a, 'str> DetachedMut<'a, 'str>
Sourcepub fn new(
body: &'a mut FunctionBody<'str>,
shared: &'a Shared<'str>,
interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>,
) -> Self
pub fn new( body: &'a mut FunctionBody<'str>, shared: &'a Shared<'str>, interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>, ) -> Self
Wrap body over the module’s shared state and interface registry.
Sourcepub fn make_block(&mut self) -> LocalBlockId
pub fn make_block(&mut self) -> LocalBlockId
Mint a fresh empty block into the detached body.
Sourcepub fn set_root(&mut self, root: LocalBlockId)
pub fn set_root(&mut self, root: LocalBlockId)
Set the detached body’s entry block.
Sourcepub fn block(&self, block: LocalBlockId) -> &BasicBlock<'str>
pub fn block(&self, block: LocalBlockId) -> &BasicBlock<'str>
A read of block block’s payload (params/instructions/edges).
Sourcepub fn add_cfg_edge(&mut self, from: LocalBlockId, to: LocalBlockId) -> EdgeId
pub fn add_cfg_edge(&mut self, from: LocalBlockId, to: LocalBlockId) -> EdgeId
Add a directed CFG edge from -> to.
Sourcepub fn push_mnemonic_with_type(
&mut self,
mnemonic: Mnemonic,
type_id: TypeId,
) -> LocalInsnId
pub fn push_mnemonic_with_type( &mut self, mnemonic: Mnemonic, type_id: TypeId, ) -> LocalInsnId
Mint an instruction with mnemonic and an explicit result type_id.
Sourcepub fn append_insn(&mut self, block: LocalBlockId, insn: LocalInsnId)
pub fn append_insn(&mut self, block: LocalBlockId, insn: LocalInsnId)
Append an already-minted instruction to the end of block.
Sourcepub fn push_block_param(
&mut self,
block: LocalBlockId,
param: BlockParam<'str>,
) -> LocalParamId
pub fn push_block_param( &mut self, block: LocalBlockId, param: BlockParam<'str>, ) -> LocalParamId
Declare a block parameter, wiring it into block’s parameter list.
Sourcepub fn replace_instruction_mnemonic(
&mut self,
insn: LocalInsnId,
mnemonic: Mnemonic,
)
pub fn replace_instruction_mnemonic( &mut self, insn: LocalInsnId, mnemonic: Mnemonic, )
Replace instruction insn’s mnemonic in place, keeping reverse-uses synced.
Sourcepub fn mnemonic(&self, insn: LocalInsnId) -> &Mnemonic
pub fn mnemonic(&self, insn: LocalInsnId) -> &Mnemonic
Instruction insn’s mnemonic (read).
Sourcepub fn type_of(&self, id: LocalValueId) -> TypeId
pub fn type_of(&self, id: LocalValueId) -> TypeId
The result type of a body-local operand.
Sourcepub fn rename_block(
&mut self,
block: LocalBlockId,
name: Cow<'str, str>,
) -> Result<()>
pub fn rename_block( &mut self, block: LocalBlockId, name: Cow<'str, str>, ) -> Result<()>
Set and register block’s name in the body’s local name table.
Sourcepub fn builder(&mut self, block: LocalBlockId) -> Builder<'str, '_>
pub fn builder(&mut self, block: LocalBlockId) -> Builder<'str, '_>
A builder positioned at block, driving the id-less local push surface.