Skip to main content

InstructionRef

Struct InstructionRef 

Source
pub struct InstructionRef<'str, 'ctx, R = ModuleView<'ctx, 'str>> {
    pub id: InstructionId,
    /* private fields */
}

Fields§

§id: InstructionId

Implementations§

Source§

impl<'s, 'ctx: 's, 'str: 'ctx, R> InstructionRef<'str, 'ctx, R>
where R: QCodeView<'ctx, 'str>,

Source

pub fn name(&'s self) -> Option<&'ctx str>

The name of this instruction’s output value

Source

pub fn type_id(&'s self) -> TypeId

The TypeId of this instruction’s result value.

Source

pub fn size(&'s self) -> usize

The size in bytes of the instruction’s output value

Source

pub fn parent(&'s self) -> Option<BlockRef<'str, 'ctx, R>>

The basic block that this instruction belongs to, if any.

Source

pub fn block(&'s self) -> Option<BlockRef<'str, 'ctx, R>>

Source

pub fn function(&'s self) -> Option<FunctionRef<'str, 'ctx, R>>

The function that this instruction belongs to, if any.

Source

pub fn mnemonic(&'s self) -> &'ctx Mnemonic

The mnemonic of the instruction

Source

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.

Source

pub fn address(&'s self) -> Option<u64>

The address of the corresponding instruction

Source

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).

Source

pub fn memory_space(&'s self) -> Option<MemorySpaceId>

Qualified address-space provenance, including body-local temporary spaces that cannot be represented by SpaceRef.

Source

pub fn opcode(&'s self) -> &'static str

The opcode for this instruction

Source

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>

Source

pub fn new(view: R, id: InstructionId) -> Self

Source

pub fn id(&self) -> ValueId

Source

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>

Source

pub fn from_id(ctx: &'ctx Context<'str>, id: InstructionId) -> Self

Source

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.

Source

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).

Source

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>

Source§

fn clone(&self) -> InstructionRef<'str, 'ctx, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'str, 'ctx, R: Copy> Copy for InstructionRef<'str, 'ctx, R>

Source§

impl<'str: 'ctx, 'ctx, R> Display for InstructionRef<'str, 'ctx, R>
where R: QCodeView<'ctx, 'str>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'str, 'ctx, R> From<InstructionRef<'str, 'ctx, R>> for ValueRef<'str, 'ctx, R>

Source§

fn from(insn_ref: InstructionRef<'str, 'ctx, R>) -> Self

Converts to this type from the input type.
Source§

impl<'str: 'ctx, 'ctx, R> Named for InstructionRef<'str, 'ctx, R>
where R: QCodeView<'ctx, 'str>,

Source§

fn name(&self) -> Option<&str>

Source§

impl<'str: 'ctx, 'ctx, R> Value<'str, 'ctx> for InstructionRef<'str, 'ctx, R>
where R: QCodeView<'ctx, 'str>,

Source§

fn id(&self) -> ValueId

The context-unique identifier for this value.
Source§

fn size(&self) -> usize

The size of this value’s output in bytes, or 0 for non-data values (terminators, blocks, functions).
Source§

impl<'s, 'ctx: 's, 'str: 'ctx> WithCtx<'s, 'ctx, 'str> for InstructionRef<'str, 'ctx>

Source§

fn ctx(&'s self) -> &'ctx Context<'str>

Auto Trait Implementations§

§

impl<'str, 'ctx, R> Freeze for InstructionRef<'str, 'ctx, R>
where R: Freeze,

§

impl<'str, 'ctx, R> RefUnwindSafe for InstructionRef<'str, 'ctx, R>
where R: RefUnwindSafe,

§

impl<'str, 'ctx, R> Send for InstructionRef<'str, 'ctx, R>
where R: Send,

§

impl<'str, 'ctx, R> Sync for InstructionRef<'str, 'ctx, R>
where R: Sync,

§

impl<'str, 'ctx, R> Unpin for InstructionRef<'str, 'ctx, R>
where R: Unpin,

§

impl<'str, 'ctx, R> UnsafeUnpin for InstructionRef<'str, 'ctx, R>
where R: UnsafeUnpin,

§

impl<'str, 'ctx, R> UnwindSafe for InstructionRef<'str, 'ctx, R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.