pub trait QCodeMut<'str> {
type View<'v>: QCodeView<'v, 'str>
where Self: 'v,
'str: 'v;
Show 22 methods
// Required methods
fn function_mut(&mut self, id: FunctionId) -> &mut FunctionBody<'str>;
fn body(&self, id: FunctionId) -> &FunctionBody<'str>;
fn shr(&self) -> &Shared<'str>;
fn interfaces(&self) -> &Registry<FunctionId, FunctionInterface<'str>>;
fn view(&self) -> Self::View<'_>;
// Provided methods
fn instruction_mut(&mut self, id: InstructionId) -> &mut Instruction<'str> { ... }
fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock<'str> { ... }
fn block_param_mut(&mut self, id: BlockParamId) -> &mut BlockParam<'str> { ... }
fn register_body_name(
&mut self,
id: ValueId,
name: Cow<'str, str>,
old_name: Option<&str>,
) -> Result<()> { ... }
fn remove_block_param(&mut self, id: BlockParamId) { ... }
fn insert_insn_before(
&mut self,
block: BlockId,
before: InstructionId,
insn: InstructionId,
) { ... }
fn move_insn_before(&mut self, insn: InstructionId, before: InstructionId) { ... }
fn add_cfg_edge(&mut self, from: BlockId, to: BlockId) -> EdgeId { ... }
fn replace_all_uses_with(
&mut self,
old: impl Into<ValueId>,
new: impl Into<ValueId>,
) { ... }
fn remove_instruction(&mut self, id: InstructionId) { ... }
fn replace_instruction(
&mut self,
id: InstructionId,
new: impl Into<ValueId>,
) { ... }
fn remove_instructions(&mut self, dead: &FxHashSet<InstructionId>) { ... }
fn rehome_outgoing_edges(&mut self, keep: BlockId, remove: BlockId) { ... }
fn replace_instruction_mnemonic(
&mut self,
id: InstructionId,
mnemonic: Mnemonic,
) { ... }
fn unroster_block(&mut self, block: BlockId) { ... }
fn delete_block(&mut self, block: BlockId) { ... }
fn absorb_block(&mut self, keep: BlockId, other: BlockId, edge_ab: EdgeId) { ... }
}Expand description
Body-local mutation capability shared by the module host (Context) and
the checked-out pass host (BodyMut).
The primitives (function_mut, shr, interfaces, view) are the whole
per-host surface; every verb is a provided method delegating to the
FunctionBody canon through the function named by its arguments’ ids.
Required Associated Types§
Sourcetype View<'v>: QCodeView<'v, 'str>
where
Self: 'v,
'str: 'v
type View<'v>: QCodeView<'v, 'str> where Self: 'v, 'str: 'v
The host’s Copy read provider (ModuleView or BodyView).
Required Methods§
Sourcefn function_mut(&mut self, id: FunctionId) -> &mut FunctionBody<'str>
fn function_mut(&mut self, id: FunctionId) -> &mut FunctionBody<'str>
The storage of the function id (write). The checked-out host panics if
id is not its own function.
Sourcefn body(&self, id: FunctionId) -> &FunctionBody<'str>
fn body(&self, id: FunctionId) -> &FunctionBody<'str>
The storage of the function 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.
Sourcefn interfaces(&self) -> &Registry<FunctionId, FunctionInterface<'str>>
fn interfaces(&self) -> &Registry<FunctionId, FunctionInterface<'str>>
Every function’s published interface (the caller-reasoning surface).
Provided Methods§
Sourcefn instruction_mut(&mut self, id: InstructionId) -> &mut Instruction<'str>
fn instruction_mut(&mut self, id: InstructionId) -> &mut Instruction<'str>
Mutably borrows the instruction id from its owning function’s arena.
Sourcefn block_mut(&mut self, id: BlockId) -> &mut BasicBlock<'str>
fn block_mut(&mut self, id: BlockId) -> &mut BasicBlock<'str>
Mutably borrows the block id from its owning function’s arena.
Sourcefn block_param_mut(&mut self, id: BlockParamId) -> &mut BlockParam<'str>
fn block_param_mut(&mut self, id: BlockParamId) -> &mut BlockParam<'str>
Mutably borrows the block parameter id from its owning function’s arena.
Sourcefn 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<()>
Register 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.
Sourcefn remove_block_param(&mut self, id: BlockParamId)
fn remove_block_param(&mut self, id: BlockParamId)
Physically removes a block parameter and its local bookkeeping. Positional block and edge-argument rewrites belong to the caller and may complete later in the same transformation.
Sourcefn insert_insn_before(
&mut self,
block: BlockId,
before: InstructionId,
insn: InstructionId,
)
fn insert_insn_before( &mut self, block: BlockId, before: InstructionId, insn: InstructionId, )
Insert insn immediately before before in block, setting its parent.
Sourcefn move_insn_before(&mut self, insn: InstructionId, before: InstructionId)
fn move_insn_before(&mut self, insn: InstructionId, before: InstructionId)
Move 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.
Sourcefn add_cfg_edge(&mut self, from: BlockId, to: BlockId) -> EdgeId
fn add_cfg_edge(&mut self, from: BlockId, to: BlockId) -> EdgeId
Adds a directed edge in the CFG from from to to, returning its id.
Both endpoints must belong to the same function: CFG edges are strictly
intra-function (context-split ruling 2). An inter-procedural transfer is
a function-level TailCall/Call, never an edge — the lifter emits
those at construction, so no producer creates a cross-function edge. The
permanent debug_assert below is the tripwire that keeps that invariant
honest (it is the probe from 06a §10, now a keeper because the invariant
finally holds).
Sourcefn 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>, )
Replace every use of old with new across old’s owning function and
update the reverse use-map (SSA defs only; all uses are intra-function).
Sourcefn remove_instruction(&mut self, id: InstructionId)
fn remove_instruction(&mut self, id: InstructionId)
Remove instruction 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.
Sourcefn replace_instruction(&mut self, id: InstructionId, new: impl Into<ValueId>)
fn replace_instruction(&mut self, id: InstructionId, new: impl Into<ValueId>)
Replace every use of instruction id with new, then remove id —
the standard “rewrite to a cheaper value” epilogue
(replace_all_uses_with +
remove_instruction).
Sourcefn remove_instructions(&mut self, dead: &FxHashSet<InstructionId>)
fn remove_instructions(&mut self, dead: &FxHashSet<InstructionId>)
Physically removes a set of instructions after pruning their operands from the reverse-use maps, grouped per owning function. Call after removing them from their parent blocks and unlinking any CFG edges owned by terminators.
Sourcefn rehome_outgoing_edges(&mut self, keep: BlockId, remove: BlockId)
fn rehome_outgoing_edges(&mut self, keep: BlockId, remove: BlockId)
Rehome remove’s outgoing CFG edges onto keep. The direct edge and
keep’s forwarding terminator have already been removed by the caller.
Sourcefn replace_instruction_mnemonic(
&mut self,
id: InstructionId,
mnemonic: Mnemonic,
)
fn replace_instruction_mnemonic( &mut self, id: InstructionId, mnemonic: Mnemonic, )
Replace an instruction’s mnemonic in place, keeping the reverse use-map in sync. For transforms that change an instruction without changing its identity, parent block, address, or result type.
Sourcefn unroster_block(&mut self, block: BlockId)
fn unroster_block(&mut self, block: BlockId)
Drop block from its function’s ownership roster. Ownership is derived
from the storing arena (block.func); the arena slot is untouched.
Sourcefn delete_block(&mut self, block: BlockId)
fn delete_block(&mut self, block: BlockId)
Remove block from its function: unlink every incident CFG edge, remove
its instructions and params, clear ownership metadata, then drop its
payload.
Sourcefn absorb_block(&mut self, keep: BlockId, other: BlockId, edge_ab: EdgeId)
fn absorb_block(&mut self, keep: BlockId, other: BlockId, edge_ab: EdgeId)
Absorb other into keep: drop keep’s terminal branch, append
other’s instructions, rehome its outgoing edges, and remove it.
edge_ab is the direct edge keep -> other.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<'str, H: QCodeMut<'str>> QCodeMut<'str> for &mut H
A &mut to a host is itself a host, so a BaseRef<&mut Context, _>
mutation ref (whose ctx field is a reborrowable &mut Context) satisfies
the same generic bound as a by-value BodyMut host.
impl<'str, H: QCodeMut<'str>> QCodeMut<'str> for &mut H
A &mut to a host is itself a host, so a BaseRef<&mut Context, _>
mutation ref (whose ctx field is a reborrowable &mut Context) satisfies
the same generic bound as a by-value BodyMut host.