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.
Global
Global variable/constant reference.
HeapAlloc
Heap allocation (malloc, new, etc.).
Fields
kind: HeapAllocKindKind 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.
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.
CondBr
Conditional branch. Operand[0] is the condition.
Fields
Switch
Switch statement. Operand[0] is the discriminant.
Fields
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.
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: FunctionIdThe 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
Cast
Type cast. Operand[0] is the value to cast.
Fields
BinaryOp
Binary operation. Operand[0] and operand[1] are the operands.
Copy
Copy/move value (identity operation, used for clarity in IR).
Freeze
Freeze undefined value to determinate but unknown value.