Skip to main content

InstKind

Enum InstKind 

Source
pub enum InstKind {
Show 78 variants Add(ValueId, ValueId), Sub(ValueId, ValueId), Mul(ValueId, ValueId), Div(ValueId, ValueId), SDiv(ValueId, ValueId), Mod(ValueId, ValueId), SMod(ValueId, ValueId), Exp(ValueId, ValueId), AddMod(ValueId, ValueId, ValueId), MulMod(ValueId, ValueId, ValueId), And(ValueId, ValueId), Or(ValueId, ValueId), Xor(ValueId, ValueId), Not(ValueId), Shl(ValueId, ValueId), Shr(ValueId, ValueId), Sar(ValueId, ValueId), Byte(ValueId, ValueId), Lt(ValueId, ValueId), Gt(ValueId, ValueId), SLt(ValueId, ValueId), SGt(ValueId, ValueId), Eq(ValueId, ValueId), IsZero(ValueId), MLoad(ValueId), MStore(ValueId, ValueId), MStore8(ValueId, ValueId), MSize, MCopy(ValueId, ValueId, ValueId), SLoad(ValueId), SStore(ValueId, ValueId), TLoad(ValueId), TStore(ValueId, ValueId), CalldataLoad(ValueId), CalldataCopy(ValueId, ValueId, ValueId), CalldataSize, InternalFrameAddr(u64), CodeSize, CodeCopy(ValueId, ValueId, ValueId), ExtCodeSize(ValueId), ExtCodeCopy(ValueId, ValueId, ValueId, ValueId), ExtCodeHash(ValueId), LoadImmutable(u32), ReturnDataSize, ReturnDataCopy(ValueId, ValueId, ValueId), Caller, CallValue, Origin, GasPrice, BlockHash(ValueId), Coinbase, Timestamp, BlockNumber, PrevRandao, GasLimit, ChainId, Address, Balance(ValueId), SelfBalance, Gas, BaseFee, BlobBaseFee, BlobHash(ValueId), Keccak256(ValueId, ValueId), Call { gas: ValueId, addr: ValueId, value: ValueId, args_offset: ValueId, args_size: ValueId, ret_offset: ValueId, ret_size: ValueId, }, StaticCall { gas: ValueId, addr: ValueId, args_offset: ValueId, args_size: ValueId, ret_offset: ValueId, ret_size: ValueId, }, DelegateCall { gas: ValueId, addr: ValueId, args_offset: ValueId, args_size: ValueId, ret_offset: ValueId, ret_size: ValueId, }, InternalCall { function: FunctionId, args: Box<[ValueId]>, returns: u32, }, Create(ValueId, ValueId, ValueId), Create2(ValueId, ValueId, ValueId, ValueId), Log0(ValueId, ValueId), Log1(ValueId, ValueId, ValueId), Log2(ValueId, ValueId, ValueId, ValueId), Log3(ValueId, ValueId, ValueId, ValueId, ValueId), Log4(ValueId, ValueId, ValueId, ValueId, ValueId, ValueId), Phi(Vec<(BlockId, ValueId)>), Select(ValueId, ValueId, ValueId), SignExtend(ValueId, ValueId),
}
Expand description

The kind of an instruction.

TODO(codegen): Consider separating opcode and operands once the MIR shape stabilizes, e.g. Instruction { opcode: Opcode, operands: SmallVec<[ValueId; 4]>, ... }. That would make generic operand visitors and rewrites less variant-heavy.

Variants§

§

Add(ValueId, ValueId)

Addition: a + b

§

Sub(ValueId, ValueId)

Subtraction: a - b

§

Mul(ValueId, ValueId)

Multiplication: a * b

§

Div(ValueId, ValueId)

Unsigned division: a / b

§

SDiv(ValueId, ValueId)

Signed division: a / b

§

Mod(ValueId, ValueId)

Unsigned modulo: a % b

§

SMod(ValueId, ValueId)

Signed modulo: a % b

§

Exp(ValueId, ValueId)

Exponentiation: a ** b

§

AddMod(ValueId, ValueId, ValueId)

Add modulo: (a + b) % n

§

MulMod(ValueId, ValueId, ValueId)

Multiply modulo: (a * b) % n

§

And(ValueId, ValueId)

Bitwise AND: a & b

§

Or(ValueId, ValueId)

Bitwise OR: a | b

§

Xor(ValueId, ValueId)

Bitwise XOR: a ^ b

§

Not(ValueId)

Bitwise NOT: ~a

§

Shl(ValueId, ValueId)

Left shift: a << b

§

Shr(ValueId, ValueId)

Logical right shift: a >> b

§

Sar(ValueId, ValueId)

Arithmetic right shift: a >> b (signed)

§

Byte(ValueId, ValueId)

Extract a byte: byte(i, x)

§

Lt(ValueId, ValueId)

Less than (unsigned): a < b

§

Gt(ValueId, ValueId)

Greater than (unsigned): a > b

§

SLt(ValueId, ValueId)

Less than (signed): a < b

§

SGt(ValueId, ValueId)

Greater than (signed): a > b

§

Eq(ValueId, ValueId)

Equality: a == b

§

IsZero(ValueId)

Check if zero: a == 0

§

MLoad(ValueId)

Load from memory: mload(offset)

§

MStore(ValueId, ValueId)

Store to memory: mstore(offset, value)

§

MStore8(ValueId, ValueId)

Store a single byte: mstore8(offset, value)

§

MSize

Get memory size: msize()

§

MCopy(ValueId, ValueId, ValueId)

Copy memory: mcopy(dest, src, len)

§

SLoad(ValueId)

Load from storage: sload(slot)

§

SStore(ValueId, ValueId)

Store to storage: sstore(slot, value)

§

TLoad(ValueId)

Transient load: tload(slot)

§

TStore(ValueId, ValueId)

Transient store: tstore(slot, value)

§

CalldataLoad(ValueId)

Load from calldata: calldataload(offset)

§

CalldataCopy(ValueId, ValueId, ValueId)

Copy calldata to memory: calldatacopy(destOffset, offset, size)

§

CalldataSize

Get calldata size: calldatasize()

§

InternalFrameAddr(u64)

Address inside the current internal-call frame.

§

CodeSize

Get code size: codesize()

§

CodeCopy(ValueId, ValueId, ValueId)

Copy code to memory: codecopy(destOffset, offset, size)

§

ExtCodeSize(ValueId)

Get external code size: extcodesize(addr)

§

ExtCodeCopy(ValueId, ValueId, ValueId, ValueId)

Copy external code to memory: extcodecopy(addr, destOffset, offset, size)

§

ExtCodeHash(ValueId)

Get external code hash: extcodehash(addr)

§

LoadImmutable(u32)

Read an immutable word identified by its byte offset: loadimmutable <offset>

In runtime code this assembles to a PUSH32 placeholder that the constructor patches with the staged value before returning the runtime code. In constructor code it reads the staged scratch word instead.

§

ReturnDataSize

Get return data size: returndatasize()

§

ReturnDataCopy(ValueId, ValueId, ValueId)

Copy return data to memory: returndatacopy(destOffset, offset, size)

§

Caller

Get caller address: caller()

§

CallValue

Get call value: callvalue()

§

Origin

Get origin address: origin()

§

GasPrice

Get gas price: gasprice()

§

BlockHash(ValueId)

Get block hash: blockhash(blockNum)

§

Coinbase

Get coinbase address: coinbase()

§

Timestamp

Get block timestamp: timestamp()

§

BlockNumber

Get block number: number()

§

PrevRandao

Get previous randao: prevrandao()

§

GasLimit

Get gas limit: gaslimit()

§

ChainId

Get chain ID: chainid()

§

Address

Get this contract’s address: address()

§

Balance(ValueId)

Get balance: balance(addr)

§

SelfBalance

Get self balance: selfbalance()

§

Gas

Get remaining gas: gas()

§

BaseFee

Get base fee: basefee()

§

BlobBaseFee

Get blob base fee: blobbasefee()

§

BlobHash(ValueId)

Get blob hash: blobhash(index)

§

Keccak256(ValueId, ValueId)

Keccak256 hash: keccak256(offset, size)

§

Call

External call: call(gas, addr, value, argsOffset, argsSize, retOffset, retSize)

Fields

§addr: ValueId
§value: ValueId
§args_offset: ValueId
§args_size: ValueId
§ret_offset: ValueId
§ret_size: ValueId
§

StaticCall

Static call: staticcall(gas, addr, argsOffset, argsSize, retOffset, retSize)

Fields

§addr: ValueId
§args_offset: ValueId
§args_size: ValueId
§ret_offset: ValueId
§ret_size: ValueId
§

DelegateCall

Delegate call: delegatecall(gas, addr, argsOffset, argsSize, retOffset, retSize)

Fields

§addr: ValueId
§args_offset: ValueId
§args_size: ValueId
§ret_offset: ValueId
§ret_size: ValueId
§

InternalCall

Internal function call lowered to a direct jump.

Fields

§function: FunctionId
§args: Box<[ValueId]>
§returns: u32
§

Create(ValueId, ValueId, ValueId)

Create contract: create(value, offset, size)

§

Create2(ValueId, ValueId, ValueId, ValueId)

Create2 contract: create2(value, offset, size, salt)

§

Log0(ValueId, ValueId)

Log with no topics: log0(offset, size)

§

Log1(ValueId, ValueId, ValueId)

Log with 1 topic: log1(offset, size, topic1)

§

Log2(ValueId, ValueId, ValueId, ValueId)

Log with 2 topics: log2(offset, size, topic1, topic2)

§

Log3(ValueId, ValueId, ValueId, ValueId, ValueId)

Log with 3 topics: log3(offset, size, topic1, topic2, topic3)

§

Log4(ValueId, ValueId, ValueId, ValueId, ValueId, ValueId)

Log with 4 topics: log4(offset, size, topic1, topic2, topic3, topic4)

§

Phi(Vec<(BlockId, ValueId)>)

Phi node: merge values from different predecessors.

§

Select(ValueId, ValueId, ValueId)

Select: select(cond, true_val, false_val)

§

SignExtend(ValueId, ValueId)

Sign extend: signextend(b, x) - extends the sign bit from byte position b

Implementations§

Source§

impl InstKind

Source

pub fn collect_operands(&self, out: &mut SmallVec<[ValueId; 8]>)

Collects all operands of this instruction into the provided vector. This is the canonical way to get all operands for liveness analysis.

Source

pub fn operands(&self) -> SmallVec<[ValueId; 8]>

Returns the operands of this instruction.

Source

pub fn visit_operands_mut(&mut self, f: impl FnMut(&mut ValueId))

Visits every operand mutably.

Source

pub const fn may_mutate_storage(&self) -> bool

Returns true if this instruction may mutate persistent storage.

Source

pub const fn may_mutate_transient_storage(&self) -> bool

Returns true if this instruction may mutate transient storage.

Source

pub const fn may_mutate_memory(&self) -> bool

Returns true if this instruction writes or may write memory.

Source

pub const fn mnemonic(&self) -> &'static str

Returns the mnemonic for this instruction.

Source

pub const fn has_side_effects(&self) -> bool

Returns true if this instruction has side effects. Side-effect instructions must not be eliminated by DCE.

Source

pub const fn effect_kind(&self) -> EffectKind

Returns a conservative effect classification for this instruction.

Trait Implementations§

Source§

impl Clone for InstKind

Source§

fn clone(&self) -> InstKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstKind

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for InstKind

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more