pub struct InstructionRef<'str, 'ctx, R = ModuleView<'ctx, 'str>> {
pub id: InstructionId,
/* private fields */
}Fields§
§id: InstructionIdImplementations§
Source§impl<'s, 'ctx: 's, 'str: 'ctx, R> InstructionRef<'str, 'ctx, R>where
R: QCodeView<'ctx, 'str>,
impl<'s, 'ctx: 's, 'str: 'ctx, R> InstructionRef<'str, 'ctx, R>where
R: QCodeView<'ctx, 'str>,
Sourcepub fn parent(&'s self) -> Option<BlockRef<'str, 'ctx, R>>
pub fn parent(&'s self) -> Option<BlockRef<'str, 'ctx, R>>
The basic block that this instruction belongs to, if any.
pub fn block(&'s self) -> Option<BlockRef<'str, 'ctx, R>>
Sourcepub fn function(&'s self) -> Option<FunctionRef<'str, 'ctx, R>>
pub fn function(&'s self) -> Option<FunctionRef<'str, 'ctx, R>>
The function that this instruction belongs to, if any.
Sourcepub fn operands(&'s self) -> SmallVec<[ValueId; 2]>
pub fn operands(&'s self) -> SmallVec<[ValueId; 2]>
The operands consumed by this instruction, as qualified ValueIds.
This is the func-qualifying, pass-facing operand accessor (stage 6a §11,
option b): it is the routing target for the insn.mnemonic().args()
call sites. Today it forwards MnemonicKind::args
verbatim; once in-body operand storage flips to LocalValueId, only this
body changes — it qualifies each local operand with the owning function
(self.id.func), which a bare &Mnemonic cannot do — so every caller
keeps seeing qualified ValueIds unchanged.
Sourcepub fn space(&'s self) -> Option<SpaceRef<'ctx>>
pub fn space(&'s self) -> Option<SpaceRef<'ctx>>
The address-space provenance for this instruction’s result, if any.
Returns Some only for instructions whose result type is a pointer to a
known memory space (e.g. StackAddress).
Sourcepub fn memory_space(&'s self) -> Option<MemorySpaceId>
pub fn memory_space(&'s self) -> Option<MemorySpaceId>
Qualified address-space provenance, including body-local temporary
spaces that cannot be represented by SpaceRef.
Sourcepub fn is_terminator(&'s self) -> bool
pub fn is_terminator(&'s self) -> bool
Is this instruction a terminator (i.e. does it end a basic block)?
Source§impl<'str, 'ctx, R> InstructionRef<'str, 'ctx, R>
impl<'str, 'ctx, R> InstructionRef<'str, 'ctx, R>
pub fn new(view: R, id: InstructionId) -> Self
pub fn id(&self) -> ValueId
Sourcepub fn as_statement(&self) -> InstructionStatement<'_, 'str, 'ctx, R>
pub fn as_statement(&self) -> InstructionStatement<'_, 'str, 'ctx, R>
Format this instruction as a string, with the mnemonic and operands.
Source§impl<'str, 'ctx> InstructionRef<'str, 'ctx>
impl<'str, 'ctx> InstructionRef<'str, 'ctx>
pub fn from_id(ctx: &'ctx Context<'str>, id: InstructionId) -> Self
Sourcepub fn from_mnemonic(
ctx: &'ctx mut Context<'str>,
func: FunctionId,
mnemonic: Mnemonic,
size: usize,
) -> Self
pub fn from_mnemonic( ctx: &'ctx mut Context<'str>, func: FunctionId, mnemonic: Mnemonic, size: usize, ) -> Self
Creates an instruction with a plain Int(size) result type, born into
func’s instruction arena. The result is detached (parent == None)
until a block appends it.
Sourcepub fn from_mnemonic_with_type(
ctx: &'ctx mut Context<'str>,
func: FunctionId,
mnemonic: Mnemonic,
type_id: TypeId,
) -> Self
pub fn from_mnemonic_with_type( ctx: &'ctx mut Context<'str>, func: FunctionId, mnemonic: Mnemonic, type_id: TypeId, ) -> Self
Creates an instruction with an explicit TypeId, born into func.
Pass a StackAddress type id when the
result is a stack-space pointer. Register-space provenance is silently
demoted to Int (pointer arithmetic on registers is not meaningful).
Sourcepub fn from_mnemonic_with_space(
ctx: &'ctx mut Context<'str>,
func: FunctionId,
mnemonic: Mnemonic,
size: usize,
_space: Option<SpaceId>,
) -> Self
pub fn from_mnemonic_with_space( ctx: &'ctx mut Context<'str>, func: FunctionId, mnemonic: Mnemonic, size: usize, _space: Option<SpaceId>, ) -> Self
Creates an instruction, deriving the result type from an optional space tag.
This is a migration shim that types the result as Int(size) regardless of
the space tag. New code should use from_mnemonic_with_type directly.
Trait Implementations§
Source§impl<'str, 'ctx, R: Clone> Clone for InstructionRef<'str, 'ctx, R>
impl<'str, 'ctx, R: Clone> Clone for InstructionRef<'str, 'ctx, R>
Source§fn clone(&self) -> InstructionRef<'str, 'ctx, R>
fn clone(&self) -> InstructionRef<'str, 'ctx, R>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more