pub struct ShiftedValueIndex {
pub value_index: ValueIndex,
pub shift_seq: [Shift; 2],
}Expand description
Similar to ValueIndex, but represents a value that has been shifted.
This is used in the operands to constraints like AndConstraint.
A term carries a sequence of two shifts rather than one. The inner shift, shift_seq[0],
applies to the word first; the outer shift, shift_seq[1], applies to its result. Two shifts
express maps no single shift can: clearing the low bits and returning the rest to where they
started needs both, since no one shift both drops bits and leaves the others in place.
§Canonical form
A lone shift goes in the inner slot, so shift_seq[0].is_identity() implies
shift_seq[1].is_identity(). That splits every term into three classes:
unshifted s_1 = s_2 = 0 spelled Shift::IDENTITY twice
singly shifted s_2 = 0 != s_1 the lone shift sits inner
doubly shifted s_2 != 0 both slots carry workA doubly shifted term must not collapse: Shift::compose of the two reports
Composition::Pair, never Composition::Single (the two merge into one shift) or
Composition::Zero (the two clear every bit, so the term is identically zero).
ConstraintSystem::validate enforces both rules.
The [Shift; 2] spelling is not itself canonical as a map: per the composition derivation,
108,571 irreducible spellings denote only 74,341 distinct maps. Nothing in the reduction depends
on that normalization for correctness, and buying it back needs a table far larger than the few
dozen shifts a real constraint system uses.
Fields§
§value_index: ValueIndexThe index of this value in the input values vector.
shift_seq: [Shift; 2]The two shifts applied to the value, inner first.
Implementations§
Source§impl ShiftedValueIndex
impl ShiftedValueIndex
Sourcepub const fn new(value_index: ValueIndex, shift_seq: [Shift; 2]) -> Self
pub const fn new(value_index: ValueIndex, shift_seq: [Shift; 2]) -> Self
A value shifted by a sequence of two shifts, shift_seq[0] first.
Sourcepub const fn single(value_index: ValueIndex, shift: Shift) -> Self
pub const fn single(value_index: ValueIndex, shift: Shift) -> Self
A value shifted by one shift, which the canonical form places in the inner slot.
Sourcepub const fn is_unshifted(&self) -> bool
pub const fn is_unshifted(&self) -> bool
Whether this term leaves its word untouched.
The canonical form puts a lone shift inner, so an identity inner shift settles it.
Sourcepub const fn is_doubly_shifted(&self) -> bool
pub const fn is_doubly_shifted(&self) -> bool
Whether this term genuinely needs both shift slots.
Sourcepub const fn plain(value_index: ValueIndex) -> Self
pub const fn plain(value_index: ValueIndex) -> Self
Create a value index that just uses the specified value, unshifted.
Sourcepub const fn sll(value_index: ValueIndex, amount: usize) -> Self
pub const fn sll(value_index: ValueIndex, amount: usize) -> Self
Shift Left Logical by the given number of bits.
§Panics
Panics if the shift amount is greater than or equal to 64.
Sourcepub const fn srl(value_index: ValueIndex, amount: usize) -> Self
pub const fn srl(value_index: ValueIndex, amount: usize) -> Self
Shift Right Logical by the given number of bits.
§Panics
Panics if the shift amount is greater than or equal to 64.
Sourcepub const fn sar(value_index: ValueIndex, amount: usize) -> Self
pub const fn sar(value_index: ValueIndex, amount: usize) -> Self
Shift Right Arithmetic by the given number of bits.
This is similar to the Shift Right Logical but instead of shifting in 0 bits it will replicate the sign bit.
§Panics
Panics if the shift amount is greater than or equal to 64.
Sourcepub const fn rotr(value_index: ValueIndex, amount: usize) -> Self
pub const fn rotr(value_index: ValueIndex, amount: usize) -> Self
Rotate Right by the given number of bits.
Rotates bits to the right, with bits shifted off the right end wrapping around to the left.
§Panics
Panics if the shift amount is greater than or equal to 64.
Sourcepub const fn sll32(value_index: ValueIndex, amount: usize) -> Self
pub const fn sll32(value_index: ValueIndex, amount: usize) -> Self
Shift Left Logical on 32-bit halves by the given number of bits.
Performs independent logical left shifts on the upper and lower 32-bit halves. Only uses the lower 5 bits of the shift amount (0-31).
§Panics
Panics if the shift amount is greater than or equal to 32.
Sourcepub const fn srl32(value_index: ValueIndex, amount: usize) -> Self
pub const fn srl32(value_index: ValueIndex, amount: usize) -> Self
Shift Right Logical on 32-bit halves by the given number of bits.
Performs independent logical right shifts on the upper and lower 32-bit halves. Only uses the lower 5 bits of the shift amount (0-31).
§Panics
Panics if the shift amount is greater than or equal to 32.
Sourcepub const fn sra32(value_index: ValueIndex, amount: usize) -> Self
pub const fn sra32(value_index: ValueIndex, amount: usize) -> Self
Shift Right Arithmetic on 32-bit halves by the given number of bits.
Performs independent arithmetic right shifts on the upper and lower 32-bit halves. Sign extends each 32-bit half independently. Only uses the lower 5 bits of the shift amount (0-31).
§Panics
Panics if the shift amount is greater than or equal to 32.
Sourcepub const fn rotr32(value_index: ValueIndex, amount: usize) -> Self
pub const fn rotr32(value_index: ValueIndex, amount: usize) -> Self
Rotate Right on 32-bit halves by the given number of bits.
Performs independent rotate right operations on the upper and lower 32-bit halves. Bits shifted off the right end wrap around to the left within each 32-bit half.
§Panics
Panics if the shift amount is greater than or equal to 32.
Trait Implementations§
Source§impl Clone for ShiftedValueIndex
impl Clone for ShiftedValueIndex
Source§fn clone(&self) -> ShiftedValueIndex
fn clone(&self) -> ShiftedValueIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShiftedValueIndex
impl Debug for ShiftedValueIndex
Source§impl DeserializeBytes for ShiftedValueIndex
impl DeserializeBytes for ShiftedValueIndex
fn deserialize(read_buf: impl Buf) -> Result<Self, SerializationError>where
Self: Sized,
Source§impl Hash for ShiftedValueIndex
impl Hash for ShiftedValueIndex
Source§impl Ord for ShiftedValueIndex
impl Ord for ShiftedValueIndex
Source§fn cmp(&self, other: &ShiftedValueIndex) -> Ordering
fn cmp(&self, other: &ShiftedValueIndex) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ShiftedValueIndex
impl PartialEq for ShiftedValueIndex
Source§fn eq(&self, other: &ShiftedValueIndex) -> bool
fn eq(&self, other: &ShiftedValueIndex) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ShiftedValueIndex
impl PartialOrd for ShiftedValueIndex
Source§impl SerializeBytes for ShiftedValueIndex
impl SerializeBytes for ShiftedValueIndex
impl Copy for ShiftedValueIndex
impl Eq for ShiftedValueIndex
impl StructuralPartialEq for ShiftedValueIndex
Auto Trait Implementations§
impl Freeze for ShiftedValueIndex
impl RefUnwindSafe for ShiftedValueIndex
impl Send for ShiftedValueIndex
impl Sync for ShiftedValueIndex
impl Unpin for ShiftedValueIndex
impl UnsafeUnpin for ShiftedValueIndex
impl UnwindSafe for ShiftedValueIndex
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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