Enum FieldInstr

Source
#[non_exhaustive]
pub enum FieldInstr { Test { src: RegE, }, Clr { dst: RegE, }, PutD { dst: RegE, data: fe256, }, PutZ { dst: RegE, }, PutV { dst: RegE, val: ConstVal, }, Fits { src: RegE, bits: Bits, }, Mov { dst: RegE, src: RegE, }, Eq { src1: RegE, src2: RegE, }, Neg { dst: RegE, src: RegE, }, Add { dst_src: RegE, src: RegE, }, Mul { dst_src: RegE, src: RegE, }, }
Expand description

Arithmetic instructions for finite fields.

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

Test

Tests if register contains a value and is not set to None.

Sets CO register to [Status::Ok] if a register contains a value, and to [Status::Fail] otherwise.

Doesn’t affect value in CK register.

Fields

§src: RegE
§

Clr

Clears register value by setting it to None.

Doesn’t affect values in CO and CK registers.

Fields

§dst: RegE
§

PutD

Puts value into a register, replacing previous value in it, if there was any.

Doesn’t affect values in CO and CK registers.

Fields

§dst: RegE
§data: fe256
§

PutZ

Puts zero (0) value into a register, replacing previous value in it, if there was any.

Doesn’t affect values in CO and CK registers.

Fields

§dst: RegE
§

PutV

Puts val value, which is a power of 2, into a register, replacing previous value in it, if there was any.

Doesn’t affect values in CO and CK registers.

Fields

§dst: RegE
§

Fits

Test whether a value in a register fits in the provided number of bits.

Sets CO register to [Status::Ok] if the value fits given number of bits, and to [Status::Fail] otherwise.

If src is set to None, sets both CO and CK to [Status::Fail]; otherwise leaves value in CK unchanged.

Fields

§src: RegE
§bits: Bits
§

Mov

Moves (copies) value from src to dst register, overwriting previous value in dst. If src has no value (i.e. set to None), sets dst to None. State of src register remains unaffected.

Doesn’t affect values in CO and CK registers.

Fields

§dst: RegE
§src: RegE
§

Eq

Checks whether src1 and src2 registers are equal. If both src1 and src2 registers contain no value, considers them equal.

Sets CO register to represent equivalence of the registers.

Doesn’t affect value in CK register.

Fields

§src1: RegE
§src2: RegE
§

Neg

Negate value in src using finite-field arithmetics, and put result into dst.

Doesn’t affect values in CO register.

If src is set to None, sets CK to [Status::Fail]; otherwise leaves value in CK unchanged.

Fields

§dst: RegE
§src: RegE
§

Add

Add src value to dst_src value using finite-field (modulo) arithmetics of the order, putting result to dst_src.

Doesn’t affect values in CO register.

If either src or dst_src (or both) is set to None, sets CK to [Status::Fail]; otherwise leaves value in CK unchanged.

Fields

§dst_src: RegE
§src: RegE
§

Mul

Multiply src value to dst_src value using finite-field (modulo) arithmetics of the order, putting result to dst_src.

Doesn’t affect values in CO register.

If either src or dst_src (or both) is set to None, sets CK to [Status::Fail]; otherwise leaves value in CK unchanged.

Fields

§dst_src: RegE
§src: RegE

Trait Implementations§

Source§

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

Source§

fn op_range() -> RangeInclusive<u8>

Returns 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 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 call 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<FieldInstr, CodeEofError>
where FieldInstr: 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 Clone for FieldInstr

Source§

fn clone(&self) -> FieldInstr

Returns a copy 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 Debug for FieldInstr

Source§

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

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

impl Display for FieldInstr

Source§

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

Formats the value using the given formatter. Read more
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<FieldInstr> for Instr<Id>
where Id: SiteId,

Source§

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

Converts to this type from the input type.
Source§

impl Hash for FieldInstr

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 FieldInstr
where Id: SiteId,

Source§

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

Source§

type Core = GfaCore

Source§

type Context<'ctx> = ()

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

fn is_goto_target(&self) -> bool

Source§

fn local_goto_pos(&mut self) -> Option<&mut u16>

Source§

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

Source§

fn src_regs(&self) -> BTreeSet<RegE>

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

fn dst_regs(&self) -> BTreeSet<RegE>

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 complexity(&self) -> u64

Returns computational complexity of the instruction. Read more
Source§

fn exec( &self, _: Site<Id>, core: &mut Core<Id, GfaCore>, _: &<FieldInstr 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}>

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

Source§

impl PartialEq for FieldInstr

Source§

fn eq(&self, other: &FieldInstr) -> 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 Copy for FieldInstr

Source§

impl Eq for FieldInstr

Source§

impl StructuralPartialEq for FieldInstr

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