Enum Instruction

Source
pub(crate) enum Instruction {
    Mul {
        dst: RegisterId,
        src: RegisterId,
    },
    UMulH {
        dst: RegisterId,
        src: RegisterId,
    },
    SMulH {
        dst: RegisterId,
        src: RegisterId,
    },
    AddShift {
        dst: RegisterId,
        src: RegisterId,
        left_shift: u8,
    },
    AddConst {
        dst: RegisterId,
        src: i32,
    },
    Sub {
        dst: RegisterId,
        src: RegisterId,
    },
    Xor {
        dst: RegisterId,
        src: RegisterId,
    },
    XorConst {
        dst: RegisterId,
        src: i32,
    },
    Rotate {
        dst: RegisterId,
        right_rotate: u8,
    },
    Target,
    Branch {
        mask: u32,
    },
}
Expand description

Define the HashX virtual instruction set

Variants§

§

Mul

64-bit multiply of two registers, discarding overflow.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§

UMulH

Unsigned 64x64 to 128-bit multiply, saving only the upper half.

Result is written to dst, and the low 32 bits are saved for the next Branch test.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§

SMulH

Signed 64x64 to 128-bit multiply, saving only the upper half.

Result is written to dst, and the low 32 bits are saved for the next Branch test.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§

AddShift

Shift source register left by a constant amount, add, discard overflow.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§left_shift: u8

Number of bits to left shift by (0..=3 only)

§

AddConst

64-bit addition by a sign-extended 32-bit constant.

Fields

§dst: RegisterId

Destination register

§src: i32

Source immediate, sign-extended from 32-bit to 64-bit

§

Sub

64-bit subtraction (dst - src), discarding overflow.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§

Xor

64-bit XOR of two registers.

Fields

§dst: RegisterId

Destination register

§src: RegisterId

Source register

§

XorConst

XOR a 64-bit register with a sign-extended 32-bit constant.

Fields

§dst: RegisterId

Destination register

§src: i32

Source immediate, sign-extended from 32-bit to 64-bit

§

Rotate

Rotate a 64-bit register right by a constant amount.

Fields

§dst: RegisterId

Destination register

§right_rotate: u8

Number of bits to rotate right by (0..=63 only)

§

Target

Become the target for the next taken branch, if any.

§

Branch

One-shot conditional branch to the last Target.

Fields

§mask: u32

32-bit branch condition mask

This is tested against the last UMulH/SMulH result. (The low 32 bits of the instruction result, which itself is the upper 64 bits of the multiplication result.)

If (result & mask) is zero and no branches have been previously taken, we jump back to the Target and remember not to take any future branches. A well formed program will always have a Target prior to any Branch.

Implementations§

Source§

impl Instruction

Source

pub(crate) fn opcode(&self) -> Opcode

Get this instruction’s Opcode.

Source

pub(crate) fn destination(&self) -> Option<RegisterId>

Get this instruction’s destination register, if any.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

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 Instruction

Source§

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

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

impl PartialEq for Instruction

Source§

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

Source§

impl StructuralPartialEq for Instruction

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