Enum sway_ir::instruction::Instruction
source · pub enum Instruction {
Show 20 variants
AsmBlock(AsmBlock, Vec<AsmArg>),
BinaryOp {
op: BinaryOpKind,
arg1: Value,
arg2: Value,
},
BitCast(Value, Type),
Branch(BranchToWithArgs),
Call(Function, Vec<Value>),
CastPtr(Value, Type),
Cmp(Predicate, Value, Value),
ConditionalBranch {
cond_value: Value,
true_block: BranchToWithArgs,
false_block: BranchToWithArgs,
},
ContractCall {
return_type: Type,
name: String,
params: Value,
coins: Value,
asset_id: Value,
gas: Value,
},
FuelVm(FuelVmInstruction),
GetLocal(LocalVar),
GetElemPtr {
base: Value,
elem_ptr_ty: Type,
indices: Vec<Value>,
},
IntToPtr(Value, Type),
Load(Value),
MemCopyBytes {
dst_val_ptr: Value,
src_val_ptr: Value,
byte_len: u64,
},
MemCopyVal {
dst_val_ptr: Value,
src_val_ptr: Value,
},
Nop,
PtrToInt(Value, Type),
Ret(Value, Type),
Store {
dst_val_ptr: Value,
stored_val: Value,
},
}
Variants§
AsmBlock(AsmBlock, Vec<AsmArg>)
An opaque list of ASM instructions passed directly to codegen.
BinaryOp
Binary arithmetic operations
BitCast(Value, Type)
Cast the type of a value without changing its actual content.
Branch(BranchToWithArgs)
An unconditional jump.
Call(Function, Vec<Value>)
A function call with a list of arguments.
CastPtr(Value, Type)
Cast a value’s type from one pointer to another.
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
FuelVm(FuelVmInstruction)
Umbrella instruction variant for FuelVM-specific instructions
GetLocal(LocalVar)
Return a local variable.
GetElemPtr
Translate a pointer from a base to a nested element in an aggregate type.
IntToPtr(Value, Type)
Re-interpret an integer value as pointer of some type
Load(Value)
Read a value from a memory pointer.
MemCopyBytes
Copy a specified number of bytes between pointers.
MemCopyVal
Copy a value from one pointer to another.
Nop
No-op, handy as a placeholder instruction.
PtrToInt(Value, Type)
Cast a pointer to an integer.
Ret(Value, Type)
Return from a function.
Store
Write a value to a memory pointer.
Implementations§
source§impl 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.
pub fn get_operands(&self) -> Vec<Value>
sourcepub fn replace_values(&mut self, replace_map: &FxHashMap<Value, Value>)
pub fn replace_values(&mut self, replace_map: &FxHashMap<Value, Value>)
Replace old_val
with new_val
if it is referenced by this instruction’s arguments.
pub fn may_have_side_effect(&self) -> bool
pub fn is_terminator(&self) -> bool
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl DebugWithContext for Instruction
impl DebugWithContext for Instruction
fn fmt_with_context<'a, 'c>( &'a self, formatter: &mut Formatter<'_>, context: &'c Context ) -> Result
fn with_context<'a, 'c>( &'a self, context: &'c Context ) -> WithContext<'a, 'c, Self>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.