Skip to main content

VectorRegisterFile

Struct VectorRegisterFile 

Source
pub struct VectorRegisterFile<Hart>(/* private fields */)
where
    Hart: VectorHartConfig;
Expand description

Vector register file container.

ELEN of the hart configuration must be 32 or 64 bits as required by Zve* extensions, which is checked at compile time.

Implementations§

Source§

impl<Hart> VectorRegisterFile<Hart>
where Hart: VectorHartConfig,

Source

pub const fn get(&self, index: VReg) -> &[u8; _]

Get reference to a vector register

Source

pub const fn get_mut(&mut self, index: VReg) -> &mut [u8; _]

Get mutable reference to a vector register

Source

pub const fn as_bytes(&self) -> &[[u8; _]; 32]

All vector registers as one contiguous array of bytes.

Register v occupies bytes [v * VLENB, (v + 1) * VLENB) of the flattened array, so a register group is a contiguous range and its elements are at Self::element_offset().

Source

pub const fn as_bytes_mut(&mut self) -> &mut [[u8; _]; 32]

All vector registers as one contiguous mutable array of bytes, see Self::as_bytes()

Source

pub const fn element_offset<W>(base_reg: VReg, elem_i: u16, eew: W) -> usize
where W: Into<Eew>,

Byte offset within flattened Self::as_bytes() of element elem_i in the register group starting at base_reg, with eew-wide elements.

Element widths divide VLENB, so elements never straddle registers and a register group is one contiguous array of elements.

Source

pub const fn read(&self, group: VRegGroup<Hart>, elem_i: u16) -> Option<u64>

Read body element elem_i of group, zero-extended.

Returns None if elem_i is not below VRegGroup::vl().

Source

pub const fn write( &mut self, group: VRegGroup<Hart>, elem_i: u16, value: u64, ) -> Option<()>

Write the low bits of value into body element elem_i of group.

Returns None if elem_i is not below VRegGroup::vl().

Source

pub const fn read_up_to_vlmax( &self, group: VRegGroup<Hart>, elem_i: u16, ) -> Option<u64>

Read any element elem_i of group, including those past vl, zero-extended.

This is for instructions that index a source by data, like vrgather. Returns None if elem_i is not below VRegGroup::vlmax().

Source

pub fn copy_elements( &mut self, dst: VRegGroup<Hart>, dst_first: u16, src: VRegGroup<Hart>, src_first: u16, count: u32, ) -> bool

Copy count elements starting at src_first of src to elements starting at dst_first of dst, like memmove, so the two ranges may overlap.

Destination elements must be body elements, source elements may be any elements below VRegGroup::vlmax(), like for vslidedown. Returns false without writing anything if either range is out of bounds or the groups have different element widths.

Source

pub fn elements_bytes( &self, group: VRegGroup<Hart>, first: u16, count: u32, ) -> Option<&[u8]>

Bytes of count body elements starting at first of group.

Returns None if the range is not within VRegGroup::vl().

Source

pub fn elements_bytes_mut( &mut self, group: VRegGroup<Hart>, first: u16, count: u32, ) -> Option<&mut [u8]>

Mutable bytes of count body elements starting at first of group.

Returns None if the range is not within VRegGroup::vl().

Source

pub const fn read_first(&self, reg: VReg, eew: Eew) -> Option<u64>

Read element 0 of register reg with width eew, zero-extended.

This is the scalar operand of reductions and scalar moves, which is a single register regardless of LMUL. Returns None if eew is wider than VLEN, which never happens for an element width that doesn’t exceed ELEN.

Source

pub const fn write_first( &mut self, reg: VReg, eew: Eew, value: u64, ) -> Option<()>

Write the low bits of value into element 0 of register reg with width eew.

Returns None if eew is wider than VLEN, see Self::read_first().

Source

pub const fn read_const<const EEW: Eew>( &self, group: VRegGroup<Hart>, elem_i: u16, ) -> Option<u64>

Self::read() with the element width known at compile time, which makes the access a fixed-size load.

Returns None if EEW is not the element width of group or elem_i is not below VRegGroup::vl().

Source

pub const fn write_const<const EEW: Eew>( &mut self, group: VRegGroup<Hart>, elem_i: u16, value: u64, ) -> Option<()>

Self::write() with the element width known at compile time, which makes the access a fixed-size store.

Returns None if EEW is not the element width of group or elem_i is not below VRegGroup::vl().

Trait Implementations§

Source§

impl<Hart> Clone for VectorRegisterFile<Hart>
where Hart: VectorHartConfig + Clone,

Source§

fn clone(&self) -> VectorRegisterFile<Hart>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Hart> Copy for VectorRegisterFile<Hart>
where Hart: VectorHartConfig + Copy,

Source§

impl<Hart> Debug for VectorRegisterFile<Hart>
where Hart: VectorHartConfig + Debug,

Source§

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

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

impl<Hart> Default for VectorRegisterFile<Hart>
where Hart: VectorHartConfig,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Hart> Freeze for VectorRegisterFile<Hart>
where [[u8; _]; 32]: Freeze,

§

impl<Hart> RefUnwindSafe for VectorRegisterFile<Hart>
where [[u8; _]; 32]: RefUnwindSafe,

§

impl<Hart> Send for VectorRegisterFile<Hart>
where [[u8; _]; 32]: Send,

§

impl<Hart> Sync for VectorRegisterFile<Hart>
where [[u8; _]; 32]: Sync,

§

impl<Hart> Unpin for VectorRegisterFile<Hart>
where [[u8; _]; 32]: Unpin,

§

impl<Hart> UnsafeUnpin for VectorRegisterFile<Hart>
where [[u8; _]; 32]: UnsafeUnpin,

§

impl<Hart> UnwindSafe for VectorRegisterFile<Hart>
where [[u8; _]; 32]: UnwindSafe,

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> 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 = !

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.