@@ -1717,6 +1717,54 @@ impl AddressSpace {
17171717 pub const ZERO : Self = AddressSpace ( 0 ) ;
17181718}
17191719
1720+ /// How many scalable vectors are in a `BackendRepr::ScalableVector`?
1721+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
1722+ #[ cfg_attr( feature = "nightly" , derive( HashStable_Generic ) ) ]
1723+ pub enum NumScalableVectors {
1724+ /// A single scalable vector
1725+ ///
1726+ /// ```rust,ignore (example)
1727+ /// #[rustc_scalable_vector(4)]
1728+ /// struct svuint32_t(i32);
1729+ /// ```
1730+ One ,
1731+ /// Tuple of two scalable vectors
1732+ ///
1733+ /// ```rust,ignore (example)
1734+ /// #[rustc_scalable_vector]
1735+ /// struct svuint32x2_t(svuint32_t, svuint32_t);
1736+ /// ```
1737+ Two ,
1738+ /// Tuple of three scalable vectors
1739+ ///
1740+ /// ```rust,ignore (example)
1741+ /// #[rustc_scalable_vector]
1742+ /// struct svuint32x3_t(svuint32_t, svuint32_t, svuint32_t);
1743+ /// ```
1744+ Three ,
1745+ /// Tuple of four scalable vectors
1746+ ///
1747+ /// ```rust,ignore (example)
1748+ /// #[rustc_scalable_vector]
1749+ /// struct svuint32x4_t(svuint32_t, svuint32_t, svuint32_t, svuint32_t);
1750+ /// ```
1751+ Four ,
1752+ }
1753+
1754+ impl NumScalableVectors {
1755+ // Returns `NumScalableVectors` for values of two, three or four, which are a valid number of
1756+ // fields for a tuple of scalable vectors to have. `1` is a valid value of `NumScalableVectors`
1757+ // but not for a tuple which would have a field count.
1758+ pub fn from_field_count ( count : usize ) -> Option < Self > {
1759+ match count {
1760+ 2 => Some ( NumScalableVectors :: Two ) ,
1761+ 3 => Some ( NumScalableVectors :: Three ) ,
1762+ 4 => Some ( NumScalableVectors :: Four ) ,
1763+ _ => None ,
1764+ }
1765+ }
1766+ }
1767+
17201768/// The way we represent values to the backend
17211769///
17221770/// Previously this was conflated with the "ABI" a type is given, as in the platform-specific ABI.
@@ -1735,6 +1783,7 @@ pub enum BackendRepr {
17351783 ScalableVector {
17361784 element : Scalar ,
17371785 count : u64 ,
1786+ number_of_vectors : NumScalableVectors ,
17381787 } ,
17391788 SimdVector {
17401789 element : Scalar ,
@@ -1841,8 +1890,12 @@ impl BackendRepr {
18411890 BackendRepr :: SimdVector { element : element. to_union ( ) , count }
18421891 }
18431892 BackendRepr :: Memory { .. } => BackendRepr :: Memory { sized : true } ,
1844- BackendRepr :: ScalableVector { element, count } => {
1845- BackendRepr :: ScalableVector { element : element. to_union ( ) , count }
1893+ BackendRepr :: ScalableVector { element, count, number_of_vectors } => {
1894+ BackendRepr :: ScalableVector {
1895+ element : element. to_union ( ) ,
1896+ count,
1897+ number_of_vectors,
1898+ }
18461899 }
18471900 }
18481901 }
@@ -2181,18 +2234,10 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
21812234 }
21822235
21832236 /// Returns `true` if the size of the type is only known at runtime.
2184- pub fn is_runtime_sized ( & self ) -> bool {
2237+ pub fn is_scalable_vector ( & self ) -> bool {
21852238 matches ! ( self . backend_repr, BackendRepr :: ScalableVector { .. } )
21862239 }
21872240
2188- /// Returns the elements count of a scalable vector.
2189- pub fn scalable_vector_element_count ( & self ) -> Option < u64 > {
2190- match self . backend_repr {
2191- BackendRepr :: ScalableVector { count, .. } => Some ( count) ,
2192- _ => None ,
2193- }
2194- }
2195-
21962241 /// Returns `true` if the type is a ZST and not unsized.
21972242 ///
21982243 /// Note that this does *not* imply that the type is irrelevant for layout! It can still have
0 commit comments