Struct zksync_vm2::Instruction

source ·
pub struct Instruction<T, W> { /* private fields */ }
Expand description

Single EraVM instruction (an opcode + Arguments).

Managing instructions is warranted for low-level tests; prefer using Programs to decode instructions from EraVM bytecodes.

Implementations§

source§

impl<T: Tracer, W: World<T>> Instruction<T, W>

Instructions for binary operations.

source

pub fn from_add( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Add instruction with the provided params.

source

pub fn from_sub( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Sub instruction with the provided params.

source

pub fn from_and( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates And instruction with the provided params.

source

pub fn from_or( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Or instruction with the provided params.

source

pub fn from_xor( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Xor instruction with the provided params.

source

pub fn from_shift_left( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates ShiftLeft instruction with the provided params.

source

pub fn from_shift_right( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates ShiftRight instruction with the provided params.

source

pub fn from_rotate_left( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates RotateLeft instruction with the provided params.

source

pub fn from_rotate_right( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates RotateRight instruction with the provided params.

source

pub fn from_mul( src1: AnySource, src2: Register2, out: AnyDestination, out2: Register2, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Mul instruction with the provided params.

source

pub fn from_div( src1: AnySource, src2: Register2, out: AnyDestination, out2: Register2, arguments: Arguments, swap: bool, set_flags: bool, ) -> Self

Creates Div instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

Context-related instructions.

source

pub fn from_this(out: Register1, arguments: Arguments) -> Self

Creates a This instruction with the provided params.

source

pub fn from_caller(out: Register1, arguments: Arguments) -> Self

Creates a Caller instruction with the provided params.

source

pub fn from_code_address(out: Register1, arguments: Arguments) -> Self

Creates a CodeAddress instruction with the provided params.

source

pub fn from_ergs_left(out: Register1, arguments: Arguments) -> Self

Creates an ErgsLeft instruction with the provided params.

source

pub fn from_context_u128(out: Register1, arguments: Arguments) -> Self

Creates a ContextU128 instruction with the provided params.

source

pub fn from_context_sp(out: Register1, arguments: Arguments) -> Self

Creates an SP instruction with the provided params.

source

pub fn from_context_meta(out: Register1, arguments: Arguments) -> Self

Creates a ContextMeta instruction with the provided params.

source

pub fn from_set_context_u128(src: Register1, arguments: Arguments) -> Self

Creates a SetContextU128 instruction with the provided params.

source

pub fn from_increment_tx_number(arguments: Arguments) -> Self

Creates an IncrementTxNumber instruction with the provided params.

source

pub fn from_aux_mutating(arguments: Arguments) -> Self

Creates an AuxMutating0 instruction with the provided params.

source§

impl<T: Tracer, W: World<T>> Instruction<T, W>

source

pub fn from_decommit( abi: Register1, burn: Register2, out: Register1, arguments: Arguments, ) -> Self

Creates a Decommit instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_event( key: Register1, value: Register2, is_first: bool, arguments: Arguments, ) -> Self

Creates an Event instruction with the provided params.

source

pub fn from_l2_to_l1_message( key: Register1, value: Register2, is_service: bool, arguments: Arguments, ) -> Self

Creates an L2ToL1Message instruction with the provided params.

source§

impl<T: Tracer, W: World<T>> Instruction<T, W>

source

pub fn from_far_call<M: TypeLevelCallingMode>( src1: Register1, src2: Register2, error_handler: Immediate1, is_static: bool, is_shard: bool, arguments: Arguments, ) -> Self

Creates a FarCall instruction with the provided mode and params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_heap_read( src: RegisterOrImmediate, out: Register1, incremented_out: Option<Register2>, arguments: Arguments, ) -> Self

Creates a HeapRead instruction with the provided params.

source

pub fn from_aux_heap_read( src: RegisterOrImmediate, out: Register1, incremented_out: Option<Register2>, arguments: Arguments, ) -> Self

Creates an AuxHeapRead instruction with the provided params.

source

pub fn from_heap_write( src1: RegisterOrImmediate, src2: Register2, incremented_out: Option<Register1>, arguments: Arguments, should_hook: bool, ) -> Self

Creates a HeapWrite instruction with the provided params.

source

pub fn from_aux_heap_store( src1: RegisterOrImmediate, src2: Register2, incremented_out: Option<Register1>, arguments: Arguments, ) -> Self

Creates an AuxHeapWrite instruction with the provided params.

source

pub fn from_pointer_read( src: Register1, out: Register1, incremented_out: Option<Register2>, arguments: Arguments, ) -> Self

Creates an PointerRead instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_jump( source: AnySource, destination: Register1, arguments: Arguments, ) -> Self

Creates a Jump instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_near_call( gas: Register1, destination: Immediate1, error_handler: Immediate2, arguments: Arguments, ) -> Self

Creates a NearCall instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_nop( pop: AdvanceStackPointer, push: AdvanceStackPointer, arguments: Arguments, ) -> Self

Creates a Nop instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

Pointer-related instructions.

source

pub fn from_pointer_add( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, ) -> Self

Creates a PointerAdd instruction with the provided params.

source

pub fn from_pointer_sub( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, ) -> Self

Creates a PointerSub instruction with the provided params.

source

pub fn from_pointer_pack( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, ) -> Self

Creates a PointerPack instruction with the provided params.

source

pub fn from_pointer_shrink( src1: AnySource, src2: Register2, out: AnyDestination, arguments: Arguments, swap: bool, ) -> Self

Creates a PointerShrink instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

source

pub fn from_precompile_call( abi: Register1, burn: Register2, out: Register1, arguments: Arguments, ) -> Self

Creates a PrecompileCall instruction with the provided params.

source§

impl<T: Tracer, W> Instruction<T, W>

Variations of Ret instructions.

source

pub fn from_ret( src1: Register1, label: Option<Immediate1>, arguments: Arguments, ) -> Self

Creates a normal Ret instruction with the provided params.

source

pub fn from_revert( src1: Register1, label: Option<Immediate1>, arguments: Arguments, ) -> Self

Creates a revert Ret instruction with the provided params.

source

pub fn from_panic(label: Option<Immediate1>, arguments: Arguments) -> Self

Creates a panic Ret instruction with the provided params.

source

pub const fn from_invalid() -> Self

Creates a invalid instruction that will panic by draining all gas.

source§

impl<T: Tracer, W: World<T>> Instruction<T, W>

source

pub fn from_storage_write( src1: Register1, src2: Register2, arguments: Arguments, ) -> Self

Creates a StorageWrite instruction with the provided params.

source

pub fn from_transient_storage_write( src1: Register1, src2: Register2, arguments: Arguments, ) -> Self

Creates a TransientStorageWrite instruction with the provided params.

source

pub fn from_storage_read( src: Register1, dst: Register1, arguments: Arguments, ) -> Self

Creates a StorageRead instruction with the provided params.

source

pub fn from_transient_storage_read( src: Register1, dst: Register1, arguments: Arguments, ) -> Self

Creates a TransientStorageRead instruction with the provided params.

Trait Implementations§

source§

impl<T, W> Debug for Instruction<T, W>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, W> Freeze for Instruction<T, W>

§

impl<T, W> RefUnwindSafe for Instruction<T, W>

§

impl<T, W> Send for Instruction<T, W>

§

impl<T, W> Sync for Instruction<T, W>

§

impl<T, W> Unpin for Instruction<T, W>

§

impl<T, W> UnwindSafe for Instruction<T, W>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V