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
StaticCall
Static call: staticcall(gas, addr, argsOffset, argsSize, retOffset, retSize)
Fields
DelegateCall
Delegate call: delegatecall(gas, addr, argsOffset, argsSize, retOffset, retSize)
Fields
InternalCall
Internal function call lowered to a direct jump.
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
impl InstKind
Sourcepub fn collect_operands(&self, out: &mut SmallVec<[ValueId; 8]>)
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.
Sourcepub fn visit_operands_mut(&mut self, f: impl FnMut(&mut ValueId))
pub fn visit_operands_mut(&mut self, f: impl FnMut(&mut ValueId))
Visits every operand mutably.
Sourcepub const fn may_mutate_storage(&self) -> bool
pub const fn may_mutate_storage(&self) -> bool
Returns true if this instruction may mutate persistent storage.
Sourcepub const fn may_mutate_transient_storage(&self) -> bool
pub const fn may_mutate_transient_storage(&self) -> bool
Returns true if this instruction may mutate transient storage.
Sourcepub const fn may_mutate_memory(&self) -> bool
pub const fn may_mutate_memory(&self) -> bool
Returns true if this instruction writes or may write memory.
Sourcepub const fn has_side_effects(&self) -> bool
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.
Sourcepub const fn effect_kind(&self) -> EffectKind
pub const fn effect_kind(&self) -> EffectKind
Returns a conservative effect classification for this instruction.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InstKind
impl RefUnwindSafe for InstKind
impl Send for InstKind
impl Sync for InstKind
impl Unpin for InstKind
impl UnsafeUnpin for InstKind
impl UnwindSafe for InstKind
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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