Struct sp1_core::runtime::Instruction
source · pub struct Instruction {
pub opcode: Opcode,
pub op_a: u32,
pub op_b: u32,
pub op_c: u32,
pub imm_b: bool,
pub imm_c: bool,
}Expand description
An instruction specifies an operation to execute and the operands.
Fields§
§opcode: Opcode§op_a: u32§op_b: u32§op_c: u32§imm_b: bool§imm_c: boolImplementations§
source§impl Instruction
impl Instruction
sourcepub const fn from_r_type(opcode: Opcode, dec_insn: RType) -> Self
pub const fn from_r_type(opcode: Opcode, dec_insn: RType) -> Self
Create a new instruction from an R-type instruction.
sourcepub const fn from_i_type(opcode: Opcode, dec_insn: IType) -> Self
pub const fn from_i_type(opcode: Opcode, dec_insn: IType) -> Self
Create a new instruction from an I-type instruction.
sourcepub const fn from_i_type_shamt(opcode: Opcode, dec_insn: ITypeShamt) -> Self
pub const fn from_i_type_shamt(opcode: Opcode, dec_insn: ITypeShamt) -> Self
Create a new instruction from an I-type instruction with a shamt.
sourcepub const fn from_s_type(opcode: Opcode, dec_insn: SType) -> Self
pub const fn from_s_type(opcode: Opcode, dec_insn: SType) -> Self
Create a new instruction from an S-type instruction.
sourcepub const fn from_b_type(opcode: Opcode, dec_insn: BType) -> Self
pub const fn from_b_type(opcode: Opcode, dec_insn: BType) -> Self
Create a new instruction from a B-type instruction.
sourcepub const fn is_i_type(&self) -> bool
pub const fn is_i_type(&self) -> bool
Returns whether the instruction is an I-type instruction.
source§impl Instruction
impl Instruction
sourcepub const fn new(
opcode: Opcode,
op_a: u32,
op_b: u32,
op_c: u32,
imm_b: bool,
imm_c: bool,
) -> Self
pub const fn new( opcode: Opcode, op_a: u32, op_b: u32, op_c: u32, imm_b: bool, imm_c: bool, ) -> Self
Create a new instruction.
sourcepub const fn is_alu_instruction(&self) -> bool
pub const fn is_alu_instruction(&self) -> bool
Returns if the instruction is an ALU instruction.
sourcepub fn is_ecall_instruction(&self) -> bool
pub fn is_ecall_instruction(&self) -> bool
Returns if the instruction is a ecall instruction.
sourcepub const fn is_memory_instruction(&self) -> bool
pub const fn is_memory_instruction(&self) -> bool
Returns if the instruction is a memory instruction.
sourcepub const fn is_branch_instruction(&self) -> bool
pub const fn is_branch_instruction(&self) -> bool
Returns if the instruction is a branch instruction.
sourcepub const fn is_jump_instruction(&self) -> bool
pub const fn is_jump_instruction(&self) -> bool
Returns if the instruction is a jump instruction.
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Serialize for Instruction
impl Serialize for Instruction
impl Copy for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync 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>
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 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>
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