pub struct VectorConfig<Hart>where
Hart: VectorHartConfig,{ /* private fields */ }Expand description
Vector configuration: vtype together with vl, where vl never exceeds VLMAX of vtype.
Neither vtype nor vl can be written by Zicsr instructions, they only ever change together
through vset{i}vl{i} and fault-only-first loads (which only shrink vl), so this is the
architectural state as a single value. Constructors enforce the invariant, which unsafe code
relies on to access vector register elements without bounds checks, so there must be no way
to construct an instance that violates it.
vill is represented as None in Option<VectorConfig>, vl is zero then.
Implementations§
Source§impl<Hart> VectorConfig<Hart>where
Hart: VectorHartConfig,
impl<Hart> VectorConfig<Hart>where
Hart: VectorHartConfig,
Sourcepub const fn new(vtype: Vtype<Hart>, vl: Vl) -> Option<Self>
pub const fn new(vtype: Vtype<Hart>, vl: Vl) -> Option<Self>
Create a new configuration.
Returns None if vl exceeds VLMAX of vtype.
Sourcepub const fn from_avl(vtype: Vtype<Hart>, avl: Vl) -> Self
pub const fn from_avl(vtype: Vtype<Hart>, avl: Vl) -> Self
Create a new configuration the way vset{i}vl{i} does for application vector length
avl, which is min(AVL, VLMAX).
This satisfies every constraint the specification places on vl, and with no choice left
to the implementation, vl is the same on every implementation with the same VLEN.
Sourcepub const fn from_raw<Reg>(vtype: Reg::Type, vl: Reg::Type) -> Option<Self>where
Reg: Register,
pub const fn from_raw<Reg>(vtype: Reg::Type, vl: Reg::Type) -> Option<Self>where
Reg: Register,
Decode from raw vtype and vl register values.
Returns None if vtype has vill set or is invalid otherwise, or if vl exceeds VLMAX
of vtype. The latter is not a state the architecture can get into, it is treated as
vill rather than corrected, so that whatever produced it does not go unnoticed.
Sourcepub const fn vl(self) -> BoundedVl<Hart>
pub const fn vl(self) -> BoundedVl<Hart>
vl, which never exceeds Self::vlmax() and hence VLEN
Sourcepub const fn with_vl_at_most(self, vl: Vl) -> Self
pub const fn with_vl_at_most(self, vl: Vl) -> Self
The same configuration with vl reduced to vl if it is lower than the current one, which
is what fault-only-first loads do
Trait Implementations§
Source§impl<Hart> Clone for VectorConfig<Hart>where
Hart: VectorHartConfig + Clone,
impl<Hart> Clone for VectorConfig<Hart>where
Hart: VectorHartConfig + Clone,
Source§fn clone(&self) -> VectorConfig<Hart>
fn clone(&self) -> VectorConfig<Hart>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more