Enum sway_ir::instruction::Instruction
source · [−]pub enum Instruction {
Show 26 variants
AddrOf(Value),
AsmBlock(AsmBlock, Vec<AsmArg>),
BitCast(Value, Type),
Branch(Block),
Call(Function, Vec<Value>),
Cmp(Predicate, Value, Value),
ConditionalBranch {
cond_value: Value,
true_block: Block,
false_block: Block,
},
ContractCall {
return_type: Type,
name: String,
params: Value,
coins: Value,
asset_id: Value,
gas: Value,
},
ExtractElement {
array: Value,
ty: Aggregate,
index_val: Value,
},
ExtractValue {
aggregate: Value,
ty: Aggregate,
indices: Vec<u64>,
},
GetStorageKey,
Gtf {
index: Value,
tx_field_id: u64,
},
GetPointer {
base_ptr: Pointer,
ptr_ty: Pointer,
offset: u64,
},
InsertElement {
array: Value,
ty: Aggregate,
value: Value,
index_val: Value,
},
InsertValue {
aggregate: Value,
ty: Aggregate,
value: Value,
indices: Vec<u64>,
},
IntToPtr(Value, Type),
Load(Value),
Nop,
Phi(Vec<(Block, Value)>),
ReadRegister(Register),
Ret(Value, Type),
StateLoadQuadWord {
load_val: Value,
key: Value,
},
StateLoadWord(Value),
StateStoreQuadWord {
stored_val: Value,
key: Value,
},
StateStoreWord {
stored_val: Value,
key: Value,
},
Store {
dst_val: Value,
stored_val: Value,
},
}
Variants
AddrOf(Value)
Address of a non-copy (memory) value
AsmBlock(AsmBlock, Vec<AsmArg>)
An opaque list of ASM instructions passed directly to codegen.
BitCast(Value, Type)
Cast the type of a value without changing its actual content.
Branch(Block)
An unconditional jump.
Call(Function, Vec<Value>)
A function call with a list of arguments.
Cmp(Predicate, Value, Value)
Comparison between two values using various comparators and returning a boolean.
ConditionalBranch
A conditional jump with the boolean condition value and true or false destinations.
ContractCall
A contract call with a list of arguments
ExtractElement
Reading a specific element from an array.
ExtractValue
Reading a specific field from (nested) structs.
GetStorageKey
Generate a unique integer value
Gtf
GetPointer
Return a pointer as a value.
InsertElement
Writing a specific value to an array.
InsertValue
Writing a specific value to a (nested) struct field.
IntToPtr(Value, Type)
Re-interpret an integer value as pointer of some type
Load(Value)
Read a value from a memory pointer.
Nop
No-op, handy as a placeholder instruction.
Phi(Vec<(Block, Value)>)
Choose a value from a list depending on the preceding block.
ReadRegister(Register)
Reads a special register in the VM.
Ret(Value, Type)
Return from a function.
StateLoadQuadWord
Read a quad word from a storage slot. Type of load_val
must be a B256 ptr.
StateLoadWord(Value)
Read a single word from a storage slot.
StateStoreQuadWord
Write a value to a storage slot. Key must be a B256, type of stored_val
must be a
Uint(256) ptr.
StateStoreWord
Write a value to a storage slot. Key must be a B256, type of stored_val
must be a
Uint(64) value.
Store
Write a value to a memory pointer.
Implementations
sourceimpl Instruction
impl Instruction
sourcepub fn get_type(&self, context: &Context) -> Option<Type>
pub fn get_type(&self, context: &Context) -> Option<Type>
Some Instruction
s can return a value, but for some a return value doesn’t make sense.
Those which perform side effects such as writing to memory and also terminators such as
Ret
do not have a type.
sourcepub fn get_aggregate(&self, context: &Context) -> Option<Aggregate>
pub fn get_aggregate(&self, context: &Context) -> Option<Aggregate>
Some Instruction
s may have struct arguments. Return it if so for this instruction.
sourcepub fn replace_value(&mut self, old_val: Value, new_val: Value)
pub fn replace_value(&mut self, old_val: Value, new_val: Value)
Replace old_val
with new_val
if it is referenced by this instruction’s arguments.
Trait Implementations
sourceimpl Clone for Instruction
impl Clone for Instruction
sourcefn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more