Enum Instr

Source
#[non_exhaustive]
pub enum Instr<Id>
where Id: SiteId,
{ Ctrl(CtrlInstr<Id>), Gfa(FieldInstr), Usonic(UsonicInstr), Reserved(ReservedInstr), }
Expand description

Complete AluVM instruction set for the Ultrasonic virtual machine, which includes the following architectures:

  • Base ALU control architecture
  • GFA256 (256-bit Galois-field arithmetics).
  • USONIC

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Ctrl(CtrlInstr<Id>)

Control flow instructions (base ALU ISA)..

§

Gfa(FieldInstr)

GFA256` (256-bit Galois-field arithmetics).

§

Usonic(UsonicInstr)

USONIC ISA.

§

Reserved(ReservedInstr)

Reserved instruction for future use in core ALU ISAs.

Trait Implementations§

Source§

impl<Id> Bytecode<Id> for Instr<Id>
where Id: SiteId,

Source§

fn op_range() -> RangeInclusive<u8>

Returns the range of instruction bytecodes covered by a set of operations.
Source§

fn opcode_byte(&self) -> u8

Returns byte representing instruction code (without its arguments).
Source§

fn code_byte_len(&self) -> u16

Returns the number of bytes used by the instruction and its arguments when serialized into the code segment.
Source§

fn external_ref(&self) -> Option<Id>

If the instruction calls or references any external program, returns a reference to it.
Source§

fn encode_operands<W>( &self, writer: &mut W, ) -> Result<(), <W as BytecodeWrite<Id>>::Error>
where W: BytecodeWrite<Id>,

Writes an instruction operands as bytecode, omitting opcode byte.
Source§

fn decode_operands<R>( reader: &mut R, opcode: u8, ) -> Result<Instr<Id>, CodeEofError>
where Instr<Id>: Sized, R: BytecodeRead<Id>,

Reads an instruction operands from bytecode, provided the opcode byte.
Source§

fn encode_instr<W>( &self, writer: &mut W, ) -> Result<(), <W as BytecodeWrite<Id>>::Error>
where W: BytecodeWrite<Id>,

Write an instruction as bytecode.
Source§

fn decode_instr<R>(reader: &mut R) -> Result<Self, CodeEofError>
where Self: Sized, R: BytecodeRead<Id>,

Reads an instruction from bytecode.
Source§

impl<Id> Clone for Instr<Id>
where Id: Clone + SiteId,

Source§

fn clone(&self) -> Instr<Id>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Id> Debug for Instr<Id>
where Id: Debug + SiteId,

Source§

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

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

impl<Id> Display for Instr<Id>
where Id: SiteId,

Source§

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

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

impl<Id> From<CtrlInstr<Id>> for Instr<Id>
where Id: SiteId,

Source§

fn from(v: CtrlInstr<Id>) -> Instr<Id>

Converts to this type from the input type.
Source§

impl<Id> From<FieldInstr> for Instr<Id>
where Id: SiteId,

Source§

fn from(v: FieldInstr) -> Instr<Id>

Converts to this type from the input type.
Source§

impl<Id> From<Instr<Id>> for Instr<Id>
where Id: SiteId,

Source§

fn from(instr: Instr<Id>) -> Instr<Id>

Converts to this type from the input type.
Source§

impl<Id> From<ReservedInstr> for Instr<Id>
where Id: SiteId,

Source§

fn from(v: ReservedInstr) -> Instr<Id>

Converts to this type from the input type.
Source§

impl<Id> From<UsonicInstr> for Instr<Id>
where Id: SiteId,

Source§

fn from(v: UsonicInstr) -> Instr<Id>

Converts to this type from the input type.
Source§

impl<Id> Hash for Instr<Id>
where Id: Hash + SiteId,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Id> Instruction<Id> for Instr<Id>
where Id: SiteId,

Source§

const ISA_EXT: &'static [&'static str]

The names of the ISA extension set these instructions cover.
Source§

type Core = UsonicCore

Extensions to the AluVM core unit provided by this instruction set.
Source§

type Context<'ctx> = VmContext<'ctx>

Context: external data which are accessible to the ISA.
Source§

fn is_goto_target(&self) -> bool

Whether the instruction can be used as a goto-target.
Source§

fn local_goto_pos(&mut self) -> GotoTarget<'_>

If an instruction is a jump operation inside the library, it should return its goto target position number.
Source§

fn remote_goto_pos(&mut self) -> Option<&mut Site<Id>>

If an instruction is a jump operation into an external library, it should return its remote target.
Source§

fn src_regs( &self, ) -> BTreeSet<<<Instr<Id> as Instruction<Id>>::Core as CoreExt>::Reg>

List of registers which value is taken into account by the instruction.
Source§

fn dst_regs( &self, ) -> BTreeSet<<<Instr<Id> as Instruction<Id>>::Core as CoreExt>::Reg>

List of registers which value may be changed by the instruction.
Source§

fn op_data_bytes(&self) -> u16

The size of the data coming as an instruction operand (i.e., except data coming from registers or read from outside the instruction operands).
Source§

fn ext_data_bytes(&self) -> u16

The size of the data read by the instruction from outside the registers (except data coming as a parameter).
Source§

fn exec( &self, site: Site<Id>, core: &mut Core<Id, <Instr<Id> as Instruction<Id>>::Core>, context: &<Instr<Id> as Instruction<Id>>::Context<'_>, ) -> ExecStep<Site<Id>>

Executes the given instruction taking all registers as input and output. Read more
Source§

fn isa_ext() -> Confined<BTreeSet<IsaId>, amplify::::collection::confinement::TinyOrdSet::{constant#0}, amplify::::collection::confinement::TinyOrdSet::{constant#1}>

Convert the set of ISA extensions from Self::ISA_EXT into a set of IsaId.
Source§

fn regs(&self) -> BTreeSet<<Self::Core as CoreExt>::Reg>

Lists all registers which are used by the instruction.
Source§

fn src_reg_bytes(&self) -> u16

The number of bytes in the source registers.
Source§

fn dst_reg_bytes(&self) -> u16

The number of bytes in the destination registers.
Source§

fn base_complexity(&self) -> u64

Computes base (non-adjusted) complexity of the instruction. Read more
Source§

fn complexity(&self) -> u64

Returns computational complexity of the instruction. Read more
Source§

impl<Id> PartialEq for Instr<Id>
where Id: PartialEq + SiteId,

Source§

fn eq(&self, other: &Instr<Id>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Id> Copy for Instr<Id>
where Id: Copy + SiteId,

Source§

impl<Id> Eq for Instr<Id>
where Id: Eq + SiteId,

Source§

impl<Id> StructuralPartialEq for Instr<Id>
where Id: SiteId,

Auto Trait Implementations§

§

impl<Id> Freeze for Instr<Id>
where Id: Freeze,

§

impl<Id> RefUnwindSafe for Instr<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for Instr<Id>
where Id: Send,

§

impl<Id> Sync for Instr<Id>
where Id: Sync,

§

impl<Id> Unpin for Instr<Id>
where Id: Unpin,

§

impl<Id> UnwindSafe for Instr<Id>
where Id: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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

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> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.