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.
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.
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.
AddShift
Shift source register left by a constant amount, add, discard overflow.
AddConst
64-bit addition by a sign-extended 32-bit constant.
Fields
dst: RegisterId
Destination register
Sub
64-bit subtraction (dst - src), discarding overflow.
Xor
64-bit XOR of two registers.
XorConst
XOR a 64-bit register with a sign-extended 32-bit constant.
Fields
dst: RegisterId
Destination register
Rotate
Rotate a 64-bit register right by a constant amount.
Fields
dst: RegisterId
Destination register
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
impl Instruction
Sourcepub(crate) fn destination(&self) -> Option<RegisterId>
pub(crate) fn destination(&self) -> Option<RegisterId>
Get this instruction’s destination register, if any.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more