pub(crate) struct RegisterSet(ArrayVec<RegisterId, NUM_REGISTERS>);Expand description
Identify a set of RegisterIds
This could be done compactly as a u8 bitfield for storage purposes, but in our program generator this is never stored long-term. Instead, we want something the optimizer can reason about as effectively as possible, and we want to optimize for an index() implementation that doesn’t branch. This uses a fixed-capacity array of registers in-set, always sorted.
Tuple Fields§
§0: ArrayVec<RegisterId, NUM_REGISTERS>Implementations§
Source§impl RegisterSet
impl RegisterSet
Sourcepub(crate) fn contains(&self, id: RegisterId) -> bool
pub(crate) fn contains(&self, id: RegisterId) -> bool
Test if a register is contained in the set.
Sourcepub(crate) fn from_filter<P: FnMut(RegisterId) -> bool>(predicate: P) -> Self
pub(crate) fn from_filter<P: FnMut(RegisterId) -> bool>(predicate: P) -> Self
Build a new RegisterSet from each register for which a predicate
function returns true.
Sourcepub(crate) fn index(&self, index: usize) -> RegisterId
pub(crate) fn index(&self, index: usize) -> RegisterId
Return a particular register within this set, counting from R0 to R7.
The supplied index must be less than the Self::len() of this set.
Panics if the index is out of range.
Trait Implementations§
Source§impl Clone for RegisterSet
impl Clone for RegisterSet
Source§fn clone(&self) -> RegisterSet
fn clone(&self) -> RegisterSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegisterSet
impl Debug for RegisterSet
Source§impl Default for RegisterSet
impl Default for RegisterSet
Source§fn default() -> RegisterSet
fn default() -> RegisterSet
Returns the “default value” for a type. Read more
Source§impl PartialEq for RegisterSet
impl PartialEq for RegisterSet
Source§fn eq(&self, other: &RegisterSet) -> bool
fn eq(&self, other: &RegisterSet) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for RegisterSet
impl StructuralPartialEq for RegisterSet
Auto Trait Implementations§
impl Freeze for RegisterSet
impl RefUnwindSafe for RegisterSet
impl Send for RegisterSet
impl Sync for RegisterSet
impl Unpin for RegisterSet
impl UnsafeUnpin for RegisterSet
impl UnwindSafe for RegisterSet
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
Mutably borrows from an owned value. Read more