pub enum NativeInst {
Show 28 variants
LoadImm {
dst: Register,
ty: NativeType,
value: i64,
},
Add {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Sub {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Mul {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Div {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
And {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Or {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Xor {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Shl {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Shr {
dst: Register,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Cmp {
dst: Register,
cc: CondCode,
ty: NativeType,
lhs: NativeValue,
rhs: NativeValue,
},
Br {
target: BlockId,
},
CondBr {
cond: NativeValue,
then_target: BlockId,
else_target: BlockId,
},
Call {
dst: Option<Register>,
func: NativeValue,
args: Vec<NativeValue>,
ret_type: NativeType,
},
Ret {
value: Option<NativeValue>,
},
Load {
dst: Register,
ty: NativeType,
addr: NativeValue,
},
Store {
ty: NativeType,
addr: NativeValue,
value: NativeValue,
},
Alloc {
dst: Register,
size: usize,
align: usize,
},
Free {
ptr: NativeValue,
},
Phi {
dst: Register,
ty: NativeType,
incoming: Vec<(NativeValue, BlockId)>,
},
Select {
dst: Register,
ty: NativeType,
cond: NativeValue,
true_val: NativeValue,
false_val: NativeValue,
},
Copy {
dst: Register,
src: NativeValue,
},
Nop,
Comment(String),
IntToPtr {
dst: Register,
src: NativeValue,
},
PtrToInt {
dst: Register,
src: NativeValue,
},
GetElementPtr {
dst: Register,
base: NativeValue,
offset: NativeValue,
elem_size: usize,
},
Switch {
value: NativeValue,
default: BlockId,
targets: Vec<(u64, BlockId)>,
},
}Expand description
A single instruction in the native IR.
Variants§
LoadImm
Load immediate: dst = imm.
Add
Add: dst = lhs + rhs.
Sub
Subtract: dst = lhs - rhs.
Mul
Multiply: dst = lhs * rhs.
Div
Divide: dst = lhs / rhs.
And
Bitwise AND: dst = lhs & rhs.
Or
Bitwise OR: dst = lhs | rhs.
Xor
Bitwise XOR: dst = lhs ^ rhs.
Shl
Shift left: dst = lhs << rhs.
Shr
Shift right (arithmetic): dst = lhs >> rhs.
Cmp
Compare: dst = cmp(cc, lhs, rhs).
Br
Unconditional branch to a block.
CondBr
Conditional branch: if cond != 0, goto then_target, else goto else_target.
Call
Function call: dst = func(args...).
Ret
Return from function.
Fields
value: Option<NativeValue>Load
Load from memory: dst = *addr.
Store
Store to memory: *addr = value.
Alloc
Allocate stack space: dst = alloca(size, align).
Free
Free heap memory.
Fields
ptr: NativeValuePhi
Phi node (SSA): dst = phi([(val, block), ...]).
Select
Select: dst = cond ? true_val : false_val.
Copy
Copy: dst = src.
Nop
No-operation (placeholder).
Comment(String)
Comment (for debugging).
IntToPtr
Integer to pointer cast.
PtrToInt
Pointer to integer cast.
GetElementPtr
Get element pointer (pointer arithmetic).
Switch
Switch/table branch.
Implementations§
Source§impl NativeInst
impl NativeInst
Trait Implementations§
Source§impl Clone for NativeInst
impl Clone for NativeInst
Source§fn clone(&self) -> NativeInst
fn clone(&self) -> NativeInst
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more