Skip to main content

Operation

Enum Operation 

Source
pub enum Operation {
Show 21 variants Alloca { size_bytes: Option<u64>, }, Global { obj: ObjId, }, HeapAlloc { kind: HeapAllocKind, }, Load, Store, Gep { field_path: FieldPath, }, Memcpy, Memset, Br { target: BlockId, }, CondBr { then_target: BlockId, else_target: BlockId, }, Switch { default: BlockId, cases: Vec<(i64, BlockId)>, }, Ret, Unreachable, Phi { incoming: Vec<(BlockId, ValueId)>, }, Select, CallDirect { callee: FunctionId, }, CallIndirect { expected_signature: Option<TypeId>, }, Cast { kind: CastKind, target_bits: Option<u8>, }, BinaryOp { kind: BinaryOp, }, Copy, Freeze,
}
Expand description

AIR operation kind.

This is a flat enum for easy pattern matching. Additional metadata is carried in optional fields where needed.

Variants§

§

Alloca

Stack allocation. Result is a pointer to allocated memory.

The size_bytes field contains the allocation size when known statically. For fixed-size allocas like int x[10], this is the total size in bytes. For variable-length arrays (VLAs), this is None.

Fields

§size_bytes: Option<u64>

Size of allocation in bytes, if known statically.

§

Global

Global variable/constant reference.

Fields

§obj: ObjId

The global object being referenced.

§

HeapAlloc

Heap allocation (malloc, new, etc.).

Fields

§kind: HeapAllocKind

Kind of heap allocation (e.g., Malloc, New, Calloc).

§

Load

Load from memory. Operand[0] is the pointer.

§

Store

Store to memory. Operand[0] is value, operand[1] is pointer.

§

Gep

Get element pointer. Computes address offset. Operand[0] is base pointer, remaining operands are indices.

Fields

§field_path: FieldPath

Field path for struct/array traversal.

§

Memcpy

Memory copy. Operand[0] is dest, operand[1] is src, operand[2] is size.

§

Memset

Memory set. Operand[0] is dest, operand[1] is value, operand[2] is size.

§

Br

Unconditional branch.

Fields

§target: BlockId

Target block.

§

CondBr

Conditional branch. Operand[0] is the condition.

Fields

§then_target: BlockId

Target if condition is true.

§else_target: BlockId

Target if condition is false.

§

Switch

Switch statement. Operand[0] is the discriminant.

Fields

§default: BlockId

Default target if no case matches.

§cases: Vec<(i64, BlockId)>

(value, target) pairs.

§

Ret

Return from function. Operand[0] is return value if present.

§

Unreachable

Unreachable code marker.

§

Phi

Phi node for SSA. Merges values from predecessor blocks.

Fields

§incoming: Vec<(BlockId, ValueId)>

(predecessor block, value from that block) pairs.

§

Select

Select (ternary). Operand[0] is condition, operand[1] is true value, operand[2] is false value.

§

CallDirect

Direct function call. Operands are arguments.

Fields

§callee: FunctionId

The function being called.

§

CallIndirect

Indirect function call through pointer. The last operand is the function pointer; all preceding operands are arguments (callee-LAST convention).

Fields

§expected_signature: Option<TypeId>

Expected function signature at this call site, if known. Used for type-based call graph pruning.

§

Cast

Type cast. Operand[0] is the value to cast.

Fields

§kind: CastKind

Kind of cast.

§target_bits: Option<u8>

Target type bit-width (e.g., 8 for trunc i64 to i8). None for backward compatibility with older AIR JSON.

§

BinaryOp

Binary operation. Operand[0] and operand[1] are the operands.

Fields

§kind: BinaryOp

Kind of binary operation.

§

Copy

Copy/move value (identity operation, used for clarity in IR).

§

Freeze

Freeze undefined value to determinate but unknown value.

Trait Implementations§

Source§

impl Clone for Operation

Source§

fn clone(&self) -> Operation

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Operation

Source§

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

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

impl<'de> Deserialize<'de> for Operation

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 PartialEq for Operation

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Operation

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 Operation

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,