#[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
| Variants | Category |
|---|---|
Load, Store | Memory access |
Branch, CBranch, BranchInd, Switch, Call, CallInd, Return, ReturnValue, BadInsn | Control flow (terminators) |
Unop | Unary integer/float/bool operations |
Binop | Binary integer/float/bool operations |
Zext, Sext, Range, IntToFloat, FloatToInt, FloatToFloat | Type casts and bit extraction |
IsFloatNaN, PopCount, LzCount, Carry, SCarry, SBorrow | Bit/flag operations |
PCodeOp | User-defined or architecture-specific operation |
Intrinsic | Pure named intrinsic function (e.g. rol, ror) |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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
impl Mnemonic
Sourcepub fn minted_callee_slot(&self) -> Option<u32>
pub fn minted_callee_slot(&self) -> Option<u32>
The unresolved direct-callee slot carried by this mnemonic, if any.
Sourcepub fn resolve_minted_callee(&mut self, slot: u32, real: FunctionId) -> bool
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.
pub fn opcode(&self) -> &'static str
pub fn is_terminator(&self) -> bool
Sourcepub fn has_side_effects(&self) -> bool
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.
Sourcepub fn call_target(&self) -> Option<FunctionId>
pub fn call_target(&self) -> Option<FunctionId>
Sourcepub fn target_blocks(&self) -> SmallVec<[LocalBlockId; 2]>
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).
pub fn args(&self) -> SmallVec<[LocalValueId; 2]>
Sourcepub fn replace_value(&mut self, old: LocalValueId, new: LocalValueId)
pub fn replace_value(&mut self, old: LocalValueId, new: LocalValueId)
Replace every occurrence of old with new in this instruction’s operands.