Enum Op
pub enum Op {
Show 32 variants
Hole(u16),
Const(i8),
Not,
Crop {
num_bits: u8,
},
SignExtend {
num_bits: u8,
},
Select {
num_skip: u8,
num_take: u8,
},
Parity,
IsZero,
ByteMask,
BitMask,
TrailingZeros,
LeadingZeros,
PopCount,
SwapBytes {
num_bits: u8,
},
Add,
Sub,
Mul,
CarrylessMul,
Div,
UnsignedDiv,
Rem,
UnsignedRem,
Shl,
Shr,
And,
Or,
Xor,
CmpLt,
Rol {
num_bits: u8,
},
DepositBits,
ExtractBits,
IfZero,
}
Expand description
Operations in an expression.
Variants§
Hole(u16)
Looks up the value passed as the Nth input, and returns it.
Const(i8)
Converts the i8 to i128 and returns it.
Not
Negates all 128 bits.
Crop
Clears bits num_bits..128
SignExtend
Fills bits num_bits..128 to 0 with the value in bit num_bits
Select
Fills bits [0..num_take] with the bits in [num_skip..num_skip + num_take], clears the bits [num_take..128]
Fields
Parity
Computes NOT(XOR(bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7))
IsZero
If the argument is zero, returns 1i128. Otherwise, returns 0i128.
ByteMask
Fills bits [0..8] with bits [7, 15, 23, .., 127], clears bits [8..128].
BitMask
Sets bits [0..N], clears bits [N..128]. If N >= 128, sets all bits.
TrailingZeros
Counts the number of bits that are 0, starting from the least significant bit.
LeadingZeros
Counts the number of bits that are 0, starting from the most significant bit.
PopCount
Counts the number of ones in the value
SwapBytes
Clears bits [num_bits..128]. Then reverses the order of the lower (num_bits + 7) / 8
bytes.
Add
Computes the sum of the two arguments.
Sub
Subtracts the second argument from the first.
Mul
Multiplies the two arguments.
CarrylessMul
Performs carry-less multiplication
Div
Performs a signed 128-bit division.
UnsignedDiv
Performs an unsigned 128-bit division.
Rem
Performs a signed 128-bit division, and returns the remainder.
UnsignedRem
Performs an unsigned 128-bit division, and returns the remainder.
Shl
Shifts all the bits in the first argument left by the amount specified in the second argument. The shift amount in the second argument is masked with 0x7f.
Shr
Shifts all the bits in the first argument right by the amount specified in the second argument.
The topmost bit is copied from the previous topmost bit. So -1i128 >> x
always returns -1i128
.
The shift amount in the second argument is masked with 0x7f.
And
Computes the bitwise AND of the two arguments.
Or
Computes the bitwise OR of the two arguments.
Xor
Computes the bitwise XOR of the two arguments.
CmpLt
Performs a signed comparison on the two arguments. Returns 1i128 if the first argument is less than the second argument. Otherwise, returns 0i128.
Rol
Clears bits [num_bits..128].
Rotates the lowest num_bits
bits in the first argument to the left, by the amount specified in the second argument.
The rotation amount in the second argument is first masked with 0xFFFFFFFF.
Then the first argument is rotated by x % num_bits
.
DepositBits
Performs bit deposition with source bits from the first argument, and selector bits from the second argument. Nth bit in the source bit is copied to the result at the position of the Nth set bit in the selector.
Example: Source bits 0b00001011
and selector bits: 0b11001001
, yields: 0b10001001.
ExtractBits
Performs bit extraction with source bits from the first argument, and selector bits from the second argument. The Nth bit in the result is copied from the source bits at the position of the Nth set bit in the selector.
Example: Source bits 0b00001011
and selector bits: 0b11001001
, yields: 0b0011.
IfZero
If the first argument is 0, the second argument is returned. Otherwise, the third argument is returned.
Implementations§
§impl Op
impl Op
pub const fn const_default() -> Self
pub const fn const_default() -> Self
Returns the default operation, which is A
(first hole).
pub fn as_infix(&self) -> Option<&str>
pub fn as_infix(&self) -> Option<&str>
Returns an infix string that can be used for printing the operation.
pub fn is_commutative(&self) -> bool
pub fn is_commutative(&self) -> bool
Returns true if the operation is commutative.
pub fn is_associative(&self) -> bool
pub fn is_associative(&self) -> bool
Returns true if the operation is associative.
Trait Implementations§
§impl<'de> Deserialize<'de> for Op
impl<'de> Deserialize<'de> for Op
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
§impl JsonSchema for Op
impl JsonSchema for Op
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreimpl Copy for Op
impl Eq for Op
impl StructuralPartialEq for Op
Auto Trait Implementations§
impl Freeze for Op
impl RefUnwindSafe for Op
impl Send for Op
impl Sync for Op
impl Unpin for Op
impl UnwindSafe for Op
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more