@@ -67,12 +67,6 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro
6767#[ cfg( feature = "nightly" ) ]
6868pub use layout:: { Layout , TyAbiInterface , TyAndLayout } ;
6969
70- /// Requirements for a `StableHashingContext` to be used in this crate.
71- /// This is a hack to allow using the `HashStable_Generic` derive macro
72- /// instead of implementing everything in `rustc_middle`.
73- #[ cfg( feature = "nightly" ) ]
74- pub trait HashStableContext { }
75-
7670#[ derive( Clone , Copy , PartialEq , Eq , Default ) ]
7771#[ cfg_attr(
7872 feature = "nightly" ,
@@ -1702,6 +1696,28 @@ impl AddressSpace {
17021696 pub const ZERO : Self = AddressSpace ( 0 ) ;
17031697}
17041698
1699+ /// How many scalable vectors are in a `BackendRepr::ScalableVector`?
1700+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
1701+ #[ cfg_attr( feature = "nightly" , derive( HashStable_Generic ) ) ]
1702+ pub struct NumScalableVectors ( pub u8 ) ;
1703+
1704+ impl NumScalableVectors {
1705+ /// Returns a `NumScalableVector` for a non-tuple scalable vector (e.g. a single vector).
1706+ pub fn for_non_tuple ( ) -> Self {
1707+ NumScalableVectors ( 1 )
1708+ }
1709+
1710+ // Returns `NumScalableVectors` for values of two through eight, which are a valid number of
1711+ // fields for a tuple of scalable vectors to have. `1` is a valid value of `NumScalableVectors`
1712+ // but not for a tuple which would have a field count.
1713+ pub fn from_field_count ( count : usize ) -> Option < Self > {
1714+ match count {
1715+ 2 ..8 => Some ( NumScalableVectors ( count as u8 ) ) ,
1716+ _ => None ,
1717+ }
1718+ }
1719+ }
1720+
17051721/// The way we represent values to the backend
17061722///
17071723/// Previously this was conflated with the "ABI" a type is given, as in the platform-specific ABI.
@@ -1720,6 +1736,7 @@ pub enum BackendRepr {
17201736 SimdScalableVector {
17211737 element : Scalar ,
17221738 count : u64 ,
1739+ number_of_vectors : NumScalableVectors ,
17231740 } ,
17241741 SimdVector {
17251742 element : Scalar ,
@@ -1826,8 +1843,12 @@ impl BackendRepr {
18261843 BackendRepr :: SimdVector { element : element. to_union ( ) , count }
18271844 }
18281845 BackendRepr :: Memory { .. } => BackendRepr :: Memory { sized : true } ,
1829- BackendRepr :: SimdScalableVector { element, count } => {
1830- BackendRepr :: SimdScalableVector { element : element. to_union ( ) , count }
1846+ BackendRepr :: SimdScalableVector { element, count, number_of_vectors } => {
1847+ BackendRepr :: SimdScalableVector {
1848+ element : element. to_union ( ) ,
1849+ count,
1850+ number_of_vectors,
1851+ }
18311852 }
18321853 }
18331854 }
@@ -2167,7 +2188,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
21672188 }
21682189
21692190 /// Returns `true` if the size of the type is only known at runtime.
2170- pub fn is_runtime_sized ( & self ) -> bool {
2191+ pub fn is_scalable_vector ( & self ) -> bool {
21712192 matches ! ( self . backend_repr, BackendRepr :: SimdScalableVector { .. } )
21722193 }
21732194
0 commit comments