pub struct BodyMut<'a, 'str> {
pub fun: &'a mut FunctionBody<'str>,
pub shared: &'a Shared<'str>,
pub interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>,
}Expand description
A single function borrowed &mut in place from Context.bodies[id] for
exclusive mutation (its interface stays in Context.interfaces[id],
reachable read-only through interfaces).
Out of scope (and asserted against on construction): a function with reattributed blocks — a roster block stored in, or parented to, a different function. Those functions go through the sequential (module) path.
Fields§
§fun: &'a mut FunctionBody<'str>The module’s shared IR state, read-only. A checked-out function pass
reaches shared data (types, literals, spaces, registers) immutably; it
mints types/literals through the interners’ &self paths, and mints no
varnodes/temp-spaces (only the V1 argpromote pass does, and it runs on
the module path). Holds no &Context — bodies are out of reach by
construction (context-split stage 5b-ii Pin B).
interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>Every function’s published interface (never checked out): the caller-reasoning surface a pass may consult about its callees.
Implementations§
Source§impl<'a, 'str> BodyMut<'a, 'str>
impl<'a, 'str> BodyMut<'a, 'str>
Sourcepub fn new(
fun: &'a mut FunctionBody<'str>,
shared: &'a Shared<'str>,
interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>,
) -> Self
pub fn new( fun: &'a mut FunctionBody<'str>, shared: &'a Shared<'str>, interfaces: &'a Registry<FunctionId, FunctionInterface<'str>>, ) -> Self
Wrap fun over the module’s shared state and interface registry. Block
ownership is now derived from the storing arena (a rostered block lives in
fun’s own arena by construction), so there is no reattribution state left
to scan for here.
Sourcepub fn from_ctx(fun: &'a mut FunctionBody<'str>, ctx: &'a Context<'str>) -> Self
pub fn from_ctx(fun: &'a mut FunctionBody<'str>, ctx: &'a Context<'str>) -> Self
Wrap fun (checked out under id) over a whole module &Context — the
module/test-scope convenience constructor (narrows to the shared state +
interface registry).
Source§impl<'a, 'str> BodyMut<'a, 'str>
The verb + read surface of a checked-out function pass, delegating to the
owned FunctionBody’s inherent verbs and self.shared. The module-scope twin of
each verb is an inherent method on Context; the
primitives below (function{,_mut}/shared/view, and the no-op
call-site cache) are the checked-out specializations.
impl<'a, 'str> BodyMut<'a, 'str>
The verb + read surface of a checked-out function pass, delegating to the
owned FunctionBody’s inherent verbs and self.shared. The module-scope twin of
each verb is an inherent method on Context; the
primitives below (function{,_mut}/shared/view, and the no-op
call-site cache) are the checked-out specializations.
Sourcepub fn function_mut(&mut self, f: FunctionId) -> &mut FunctionBody<'str>
pub fn function_mut(&mut self, f: FunctionId) -> &mut FunctionBody<'str>
The owned function’s storage (write). Panics if f is not this function.
Sourcepub fn function(&self, f: FunctionId) -> &FunctionBody<'str>
pub fn function(&self, f: FunctionId) -> &FunctionBody<'str>
The owned function’s storage (read).
Sourcepub fn view(&self) -> BodyView<'_, 'str>
pub fn view(&self) -> BodyView<'_, 'str>
The static immutable provider for shared reads over this pass body.
Sourcepub fn block_ref(&self, id: BlockId) -> BlockRef<'str, '_, BodyView<'_, 'str>>
pub fn block_ref(&self, id: BlockId) -> BlockRef<'str, '_, BodyView<'_, 'str>>
A read BlockRef over id, body-routed.
Sourcepub fn insn_ref(
&self,
id: InstructionId,
) -> InstructionRef<'str, '_, BodyView<'_, 'str>>
pub fn insn_ref( &self, id: InstructionId, ) -> InstructionRef<'str, '_, BodyView<'_, 'str>>
A read InstructionRef over id.
Sourcepub fn param_ref(
&self,
id: BlockParamId,
) -> BlockParamRef<'str, '_, BodyView<'_, 'str>>
pub fn param_ref( &self, id: BlockParamId, ) -> BlockParamRef<'str, '_, BodyView<'_, 'str>>
A read BlockParamRef over id.
Sourcepub fn function_ref(
&self,
id: FunctionId,
) -> FunctionRef<'str, '_, BodyView<'_, 'str>>
pub fn function_ref( &self, id: FunctionId, ) -> FunctionRef<'str, '_, BodyView<'_, 'str>>
A read FunctionRef over id.
pub fn push_edge(&mut self, edge: EdgeData) -> EdgeId
pub fn push_insn(&mut self, insn: Instruction<'str>) -> InstructionId
pub fn push_block(&mut self, block: BasicBlock<'str>) -> BlockId
pub fn make_block(&mut self) -> BlockId
pub fn push_block_param(&mut self, param: BlockParam<'str>) -> BlockParamId
pub fn push_mnemonic( &mut self, mnemonic: Mnemonic, size: usize, ) -> InstructionId
pub fn push_mnemonic_with_type( &mut self, mnemonic: Mnemonic, type_id: TypeId, ) -> InstructionId
Sourcepub fn remove_cfg_edge(&mut self, edge_id: EdgeId)
pub fn remove_cfg_edge(&mut self, edge_id: EdgeId)
Remove CFG edge edge_id (unqualified; EdgeId is body-local). The
module-path twin is the function-qualified
Context::remove_cfg_edge.
pub fn register_local_name( &mut self, id: ValueId, name: Cow<'str, str>, old_name: Option<&str>, ) -> Result<()>
Trait Implementations§
Source§impl<'a, 'str> QCodeMut<'str> for BodyMut<'a, 'str>
impl<'a, 'str> QCodeMut<'str> for BodyMut<'a, 'str>
Source§fn function_mut(&mut self, id: FunctionId) -> &mut FunctionBody<'str>
fn function_mut(&mut self, id: FunctionId) -> &mut FunctionBody<'str>
id (write). The checked-out host panics if
id is not its own function.Source§fn body(&self, id: FunctionId) -> &FunctionBody<'str>
fn body(&self, id: FunctionId) -> &FunctionBody<'str>
id (read), tied to &self. The
borrow-friendly read primitive for host-generic ref code: a fully
generic H cannot prove 'str outlives a view GAT
borrow, but a plain &self-tied borrow needs no such proof.Source§fn interfaces(&self) -> &Registry<FunctionId, FunctionInterface<'str>>
fn interfaces(&self) -> &Registry<FunctionId, FunctionInterface<'str>>
Source§fn instruction_mut(&mut self, id: InstructionId) -> &mut Instruction<'str>
fn instruction_mut(&mut self, id: InstructionId) -> &mut Instruction<'str>
id from its owning function’s arena.Source§fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock<'str>
fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock<'str>
id from its owning function’s arena.Source§fn block_param_mut(&mut self, id: BlockParamId) -> &mut BlockParam<'str>
fn block_param_mut(&mut self, id: BlockParamId) -> &mut BlockParam<'str>
id from its owning function’s arena.Source§fn register_body_name(
&mut self,
id: ValueId,
name: Cow<'str, str>,
old_name: Option<&str>,
) -> Result<()>
fn register_body_name( &mut self, id: ValueId, name: Cow<'str, str>, old_name: Option<&str>, ) -> Result<()>
name for the function-scoped id (block/instruction/param/
Temp) in its owning function’s local name table. Panics on a
global-scoped id — shared-name registration is a module-only operation
outside this trait’s body-local contract. Errors only on a duplicate
name.Source§fn remove_block_param(&mut self, id: BlockParamId)
fn remove_block_param(&mut self, id: BlockParamId)
Source§fn insert_insn_before(
&mut self,
block: BlockId,
before: InstructionId,
insn: InstructionId,
)
fn insert_insn_before( &mut self, block: BlockId, before: InstructionId, insn: InstructionId, )
insn immediately before before in block, setting its parent.Source§fn move_insn_before(&mut self, insn: InstructionId, before: InstructionId)
fn move_insn_before(&mut self, insn: InstructionId, before: InstructionId)
insn immediately before the arbitrary live instruction before,
preserving the moved instruction’s stable ID. Both instructions must
belong to the same function; the destination block is inferred from the
anchor.Source§fn replace_all_uses_with(
&mut self,
old: impl Into<ValueId>,
new: impl Into<ValueId>,
)
fn replace_all_uses_with( &mut self, old: impl Into<ValueId>, new: impl Into<ValueId>, )
old with new across old’s owning function and
update the reverse use-map (SSA defs only; all uses are intra-function).Source§fn remove_instruction(&mut self, id: InstructionId)
fn remove_instruction(&mut self, id: InstructionId)
id from its block, unlink its outgoing CFG edges if
a terminator, clear its name, prune its operand use-lists, and
physically drop its payload.Source§fn replace_instruction(&mut self, id: InstructionId, new: impl Into<ValueId>)
fn replace_instruction(&mut self, id: InstructionId, new: impl Into<ValueId>)
id with new, then remove id —
the standard “rewrite to a cheaper value” epilogue
(replace_all_uses_with +
remove_instruction).Source§fn remove_instructions(&mut self, dead: &FxHashSet<InstructionId>)
fn remove_instructions(&mut self, dead: &FxHashSet<InstructionId>)
Source§fn rehome_outgoing_edges(&mut self, keep: BlockId, remove: BlockId)
fn rehome_outgoing_edges(&mut self, keep: BlockId, remove: BlockId)
remove’s outgoing CFG edges onto keep. The direct edge and
keep’s forwarding terminator have already been removed by the caller.Source§fn replace_instruction_mnemonic(
&mut self,
id: InstructionId,
mnemonic: Mnemonic,
)
fn replace_instruction_mnemonic( &mut self, id: InstructionId, mnemonic: Mnemonic, )
Source§fn unroster_block(&mut self, block: BlockId)
fn unroster_block(&mut self, block: BlockId)
block from its function’s ownership roster. Ownership is derived
from the storing arena (block.func); the arena slot is untouched.Source§fn delete_block(&mut self, block: BlockId)
fn delete_block(&mut self, block: BlockId)
block from its function: unlink every incident CFG edge, remove
its instructions and params, clear ownership metadata, then drop its
payload.