pub struct BasicBlock<'str> {
pub params: Vec<LocalParamId>,
pub instructions: Vec<LocalInsnId>,
pub edges: HashSet<EdgeId, FxBuildHasher>,
pub address: Option<u64>,
pub extra_addresses: Vec<u64>,
/* private fields */
}Expand description
A block of instructions. This is the basic unit of code in our IR.
Fields§
§params: Vec<LocalParamId>Typed parameters declared at block entry (block-argument style).
These are NOT part of instructions; use params() to iterate them.
instructions: Vec<LocalInsnId>The ids of the instructions in this block
edges: HashSet<EdgeId, FxBuildHasher>The set of edges that this block is incident to, as bare body-local
EdgeIds (see add_cfg_edge).
Strict IR locality (ruling 2) guarantees every edge incident to a block is
stored in that block’s own function arena, so the owning FunctionId is
always the block’s own id.func — it is recovered at the point of use
rather than stored per edge (stage 6a, mirroring the stage-4 EdgeId
strip).
Uses a fixed-seed hasher (matching Context’s Graph::Hasher) so that
predecessors()/successors() iterate deterministically across runs.
address: Option<u64>The address of this block, if it corresponds to a machine address.
extra_addresses: Vec<u64>Additional addresses that map to this block (accumulated from merged blocks).
Implementations§
Source§impl<'str> BasicBlock<'str>
impl<'str> BasicBlock<'str>
Sourcepub fn instruction_ids(&self) -> &[LocalInsnId]
pub fn instruction_ids(&self) -> &[LocalInsnId]
The ids of the instructions in this block, in order (raw &BasicBlock
accessor). Routing target for the raw .instructions field reads (stage
6a §11); the field itself becomes private and localizes behind this
accessor at the storage flip.
Sourcepub fn param_ids(&self) -> &[LocalParamId]
pub fn param_ids(&self) -> &[LocalParamId]
The ids of this block’s parameters, in declaration order (raw
&BasicBlock accessor). Routing target for the raw .params field reads
(stage 6a §11).
Sourcepub fn from_id<'ctx>(
ctx: &'ctx Context<'str>,
id: BlockId,
) -> BlockRef<'str, 'ctx>
pub fn from_id<'ctx>( ctx: &'ctx Context<'str>, id: BlockId, ) -> BlockRef<'str, 'ctx>
Gets a reference to a block from its ID
Sourcepub fn from_id_mut<'ctx>(
ctx: &'ctx mut Context<'str>,
id: BlockId,
) -> BlockMutRef<'str, 'ctx>
pub fn from_id_mut<'ctx>( ctx: &'ctx mut Context<'str>, id: BlockId, ) -> BlockMutRef<'str, 'ctx>
Gets a mutable reference to a block from its ID
Sourcepub fn from_name<'ctx>(
ctx: &'ctx Context<'str>,
name: &str,
) -> Option<BlockRef<'str, 'ctx>>
pub fn from_name<'ctx>( ctx: &'ctx Context<'str>, name: &str, ) -> Option<BlockRef<'str, 'ctx>>
Gets a reference to a block by name. Block names are function-scoped, so
this scans every function’s local name table and returns the first match
(names are unique within a function, not across the program). Prefer
FunctionRef::local_named when
the owning function is known.
Sourcepub fn make<'ctx>(
ctx: &'ctx mut Context<'str>,
func: FunctionId,
) -> BlockMutRef<'str, 'ctx>
pub fn make<'ctx>( ctx: &'ctx mut Context<'str>, func: FunctionId, ) -> BlockMutRef<'str, 'ctx>
Create a new block, born into func’s block arena. Ownership is derived
from arena membership (the storing function).
Sourcepub fn clone_block_into(
ctx: &mut Context<'str>,
orig: BlockId,
target: FunctionId,
value_map: &mut HashMap<ValueId, ValueId>,
) -> BlockId
pub fn clone_block_into( ctx: &mut Context<'str>, orig: BlockId, target: FunctionId, value_map: &mut HashMap<ValueId, ValueId>, ) -> BlockId
Structurally clone the block at orig into a fresh block owned by (and
stored in) target, without remapping operands.
This is the storage-move sibling of clone_into_ctx:
where clone_into_ctx builds a semantically independent copy inside the
same function (used by the tracer), this reproduces orig verbatim in a
different function’s arenas — preserving each instruction’s exact result
TypeId and machine address, and the block’s own name — so a caller
relocating a reattributed block can then fix up the references in a single
whole-function pass. It records orig‘s params and instruction results in
value_map (old id -> new id) but leaves the new instructions’ operands and
block targets pointing at the originals; the caller remaps them once the
full map is known (so forward references between relocated blocks resolve).
Trait Implementations§
Source§impl<'str> Clone for BasicBlock<'str>
impl<'str> Clone for BasicBlock<'str>
Source§fn clone(&self) -> BasicBlock<'str>
fn clone(&self) -> BasicBlock<'str>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more