Enum sway_ir::instruction::Instruction
source · [−]pub enum Instruction {
Show 17 variants
AsmBlock(AsmBlock, Vec<AsmArg>),
Branch(Block),
Call(Function, Vec<Value>),
ConditionalBranch {
cond_value: Value,
true_block: Block,
false_block: Block,
},
ExtractElement {
array: Value,
ty: Aggregate,
index_val: Value,
},
ExtractValue {
aggregate: Value,
ty: Aggregate,
indices: Vec<u64>,
},
GetPointer(Pointer),
InsertElement {
array: Value,
ty: Aggregate,
value: Value,
index_val: Value,
},
InsertValue {
aggregate: Value,
ty: Aggregate,
value: Value,
indices: Vec<u64>,
},
Load(Value),
Nop,
Phi(Vec<(Block, Value)>),
PointerCast(Value, Type),
Ret(Value, Type),
StateLoad {
load_val: Value,
key: Value,
},
StateStore {
stored_val: Value,
key: Value,
},
Store {
dst_val: Value,
stored_val: Value,
},
}
Variants
AsmBlock(AsmBlock, Vec<AsmArg>)
An opaque list of ASM instructions passed directly to codegen.
Branch(Block)
An unconditional jump.
Call(Function, Vec<Value>)
A function call with a list of arguments.
ConditionalBranch
A conditional jump with the boolean condition value and true or false destinations.
ExtractElement
Reading a specific element from an array.
ExtractValue
Reading a specific field from (nested) structs.
GetPointer(Pointer)
Return a pointer as a value.
InsertElement
Writing a specific value to an array.
InsertValue
Writing a specific value to a (nested) struct field.
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.
PointerCast(Value, Type)
A cast from one pointer type to another. Value must be either a GetPointer instruction or another PointerCast.
Ret(Value, Type)
Return from a function.
StateLoad
Read a value from a storage slot. Type of load_val
must be a Uint(64) or B256 ptr.
StateStore
Write a value to a storage slot. Key must be a B256, type of stored_val
must be a
Uint(64) or B256 ptr.
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more