Skip to main content

Mnemonic

Enum Mnemonic 

Source
#[non_exhaustive]
pub enum Mnemonic {
Show 35 variants Load(Load), Store(Store), Branch(Branch), CBranch(CBranch), BranchInd(BranchInd), Switch(Switch), Call(Call), TailCall(TailCall), Apply(Apply), CallInd(CallInd), Return(Return), ReturnValue(ReturnValue), BadInsn(BadInsn), Unop(Unary), Binop(Binary), Range(Range), IntToFloat(IntToFloat), FloatToFloat(FloatToFloat), FloatToInt(FloatToInt), Zext(Zext), Sext(Sext), IsFloatNaN(IsFloatNaN), PopCount(PopCount), LzCount(LzCount), Carry(Carry), SCarry(SCarry), SBorrow(SBorrow), Assert(Assert), PCodeOp(PCodeOp), Intrinsic(IntrinsicApp), Tuple(Tuple), Extract(Extract), Gep(Gep), Map(Map), Scan(Scan),
}
Expand description

The operation performed by an Instruction.

Mnemonic is a closed enum over all supported IR operations. It is #[non_exhaustive] so that new operations can be added without requiring downstream crates to update exhaustive match arms.

§Categories

VariantsCategory
Load, StoreMemory access
Branch, CBranch, BranchInd, Switch, Call, CallInd, Return, ReturnValue, BadInsnControl flow (terminators)
UnopUnary integer/float/bool operations
BinopBinary integer/float/bool operations
Zext, Sext, Range, IntToFloat, FloatToInt, FloatToFloatType casts and bit extraction
IsFloatNaN, PopCount, LzCount, Carry, SCarry, SBorrowBit/flag operations
PCodeOpUser-defined or architecture-specific operation
IntrinsicPure named intrinsic function (e.g. rol, ror)

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Load(Load)

Load a value from a memory space.

§

Store(Store)

Store a value to a memory space.

§

Branch(Branch)

Unconditional direct branch to a static target block.

§

CBranch(CBranch)

Conditional branch: taken when the condition operand is non-zero.

§

BranchInd(BranchInd)

Unconditional indirect branch to a dynamically-computed address.

§

Switch(Switch)

Multi-way dispatch on an integer scrutinee — a resolved jump table.

§

Call(Call)

Direct call to a known function.

§

TailCall(TailCall)

Tail call: a function-level transfer of control to another function’s entry (thunk / tail jump). Carries a FunctionId, never a foreign block — see TailCall.

§

Apply(Apply)

Value-level application of a pure lambda function.

§

CallInd(CallInd)

Indirect call through a computed function pointer.

§

Return(Return)

Return from the current function.

§

ReturnValue(ReturnValue)

Value return from a lambda function.

§

BadInsn(BadInsn)

Bytes that do not decode to a valid instruction. A terminator with no successors (see BadInsn).

§

Unop(Unary)

A unary integer, float, or boolean operation.

§

Binop(Binary)

A binary integer, float, or boolean operation.

§

Range(Range)

Extract a contiguous byte range from a value.

§

IntToFloat(IntToFloat)

Convert an integer to a floating-point value.

§

FloatToFloat(FloatToFloat)

Convert a floating-point value to a different float width.

§

FloatToInt(FloatToInt)

Convert a floating-point value to an integer (truncate toward zero).

§

Zext(Zext)

Zero-extend a value to a wider integer.

§

Sext(Sext)

Sign-extend a value to a wider integer.

§

IsFloatNaN(IsFloatNaN)

Test whether a floating-point value is NaN.

§

PopCount(PopCount)

Count the number of set bits (population count / Hamming weight).

§

LzCount(LzCount)

Count leading zero bits.

§

Carry(Carry)

Unsigned addition carry-out flag.

§

SCarry(SCarry)

Signed addition carry-out (overflow) flag.

§

SBorrow(SBorrow)

Signed subtraction borrow flag.

§

Assert(Assert)

Assert when resolving an execution trace

§

PCodeOp(PCodeOp)

A user-defined or architecture-specific p-code operation.

§

Intrinsic(IntrinsicApp)

A pure named intrinsic function (e.g. rol, ror). Categorically pure: no memory or observable side effects.

§

Tuple(Tuple)

Build an aggregate (tuple) value from ordered fields.

§

Extract(Extract)

Project a single field out of an aggregate value.

§

Gep(Gep)

Compute the address of a struct field (typed, named pointer arithmetic).

§

Map(Map)

Total element-wise map over an array value (a projectable loop).

§

Scan(Scan)

Total left-scan (prefix fold) over an array value: a projectable loop whose per-element write depends on the previous iteration’s result.

Implementations§

Source§

impl Mnemonic

Source

pub fn minted_callee_slot(&self) -> Option<u32>

The unresolved direct-callee slot carried by this mnemonic, if any.

Source

pub fn resolve_minted_callee(&mut self, slot: u32, real: FunctionId) -> bool

Resolve one pass-local direct-callee placeholder to its installed function ID. Returns whether this mnemonic contained that placeholder.

Source

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

Source

pub fn is_terminator(&self) -> bool

Source

pub fn has_side_effects(&self) -> bool

Whether an instruction must be kept even if its result has no users: it writes memory, transfers control, calls, asserts, or invokes an opaque p-code op. This is the single source of truth shared by DCE (which must not delete these) and the emitter (which must always print them); keep the two in agreement by routing both through here.

Source

pub fn call_target(&self) -> Option<FunctionId>

The callee of a direct Call or body of a Map, or None (including indirect CallInd calls, whose target is not statically known). Used to maintain the reverse call graph.

Source

pub fn target_blocks(&self) -> SmallVec<[LocalBlockId; 2]>

The statically-known CFG target blocks this mnemonic branches to — the Branch target and both CBranch arms — as bare body-local indices. Empty for non-branch or indirect terminators (a BranchInd resolves to computed addresses, not a static block). Strict IR locality (context-split ruling 2) guarantees each target lives in this terminator’s own arena, so a caller with the owning function in hand recovers the full BlockId via BlockId::new(func, local).

Source

pub fn args(&self) -> SmallVec<[LocalValueId; 2]>

Source

pub fn replace_value(&mut self, old: LocalValueId, new: LocalValueId)

Replace every occurrence of old with new in this instruction’s operands.

Trait Implementations§

Source§

impl Clone for Mnemonic

Source§

fn clone(&self) -> Mnemonic

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 Debug for Mnemonic

Source§

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

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

impl<'de> Deserialize<'de> for Mnemonic

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Mnemonic

Source§

impl Hash for Mnemonic

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Mnemonic

Source§

fn eq(&self, other: &Mnemonic) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Mnemonic

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Mnemonic

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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