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.

Does not affect the value in the CK register.

Fields

§src: RegE

The source register

§

Clr

Clears register value by setting it to None.

Does not affect values in the CO and CK registers.

Fields

§dst: RegE

The destination register

§

PutD

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

Does not affect values in the CO and CK registers.

Fields

§dst: RegE

The destination register

§data: fe256

Finite field element taken from the data segment, used to initialize the register

§

PutZ

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

Does not affect values in the CO and CK registers.

Fields

§dst: RegE

The destination register

§

PutV

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

Does not affect values in the CO and CK registers.

Fields

§dst: RegE

The destination register

§val: ConstVal

A constant finite field element used to initialize the register

§

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 the 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 the CK unchanged.

Fields

§src: RegE

The source register

§bits: Bits

The maximum bit dimension which the source register value must fit into

§

Mov

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

Leaves the state of the src register unaffected.

Does not affect values in the CO and CK registers.

Fields

§dst: RegE

The destination register

§src: RegE

The source register

§

Eq

Checks whether src1 and src2 registers are equal.

Sets CO register to represent equivalence of the registers. If both src1 and src2 registers contain no value, sets CK to a failed state.

Does not affect the value in the CK register.

Fields

§src1: RegE

The first source register

§src2: RegE

The second source register

§

Neg

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

Does not affect values in the CO register.

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

Fields

§dst: RegE

The destination register

§src: RegE

The source register

§

Add

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

Does not affect values in the CO register.

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

Fields

§dst_src: RegE

The first source and the destination register

§src: RegE

The second source register

§

Mul

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

Does not affect values in the CO register.

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

Fields

§dst_src: RegE

The first source and the destination register

§src: RegE

The second source register

Implementations§

Source§

impl FieldInstr

Source

pub const START: u8 = 64u8

The initial value of the instruction op codes.

Source

pub const END: u8 = 69u8

The ending value of the instruction op codes.

Source

pub const SET: u8 = 64u8

Source

pub const TEST: u8 = 64u8

Source

pub const CLR: u8 = 64u8

Source

pub const PUTD: u8 = 64u8

Source

pub const PUTZ: u8 = 64u8

Source

pub const PUTV: u8 = 64u8

Source

pub const FITS: u8 = 64u8

Source

pub const MOV: u8 = 65u8

Source

pub const EQ: u8 = 66u8

Source

pub const NEG: u8 = 67u8

Source

pub const ADD: u8 = 68u8

Source

pub const MUL: u8 = 69u8

Trait Implementations§

Source§

impl<Id> Bytecode<Id> for FieldInstr
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<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 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 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]

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

type Core = GfaCore

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

type Context<'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<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}>

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§

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.