@@ -1671,6 +1671,10 @@ impl AddressSpace {
16711671pub enum BackendRepr {
16721672 Scalar ( Scalar ) ,
16731673 ScalarPair ( Scalar , Scalar ) ,
1674+ ScalableVector {
1675+ element : Scalar ,
1676+ count : u64 ,
1677+ } ,
16741678 SimdVector {
16751679 element : Scalar ,
16761680 count : u64 ,
@@ -1689,6 +1693,9 @@ impl BackendRepr {
16891693 match * self {
16901694 BackendRepr :: Scalar ( _)
16911695 | BackendRepr :: ScalarPair ( ..)
1696+ // FIXME(repr_scalable): Scalable vectors are forced to be `Sized` while the
1697+ // `sized_hierarchy` feature is not yet fully implemented
1698+ | BackendRepr :: ScalableVector { .. }
16921699 | BackendRepr :: SimdVector { .. } => false ,
16931700 BackendRepr :: Memory { sized } => !sized,
16941701 }
@@ -1729,7 +1736,9 @@ impl BackendRepr {
17291736 BackendRepr :: Scalar ( s) => Some ( s. align ( cx) . abi ) ,
17301737 BackendRepr :: ScalarPair ( s1, s2) => Some ( s1. align ( cx) . max ( s2. align ( cx) ) . abi ) ,
17311738 // The align of a Vector can vary in surprising ways
1732- BackendRepr :: SimdVector { .. } | BackendRepr :: Memory { .. } => None ,
1739+ BackendRepr :: SimdVector { .. }
1740+ | BackendRepr :: Memory { .. }
1741+ | BackendRepr :: ScalableVector { .. } => None ,
17331742 }
17341743 }
17351744
@@ -1751,7 +1760,9 @@ impl BackendRepr {
17511760 Some ( size)
17521761 }
17531762 // The size of a Vector can vary in surprising ways
1754- BackendRepr :: SimdVector { .. } | BackendRepr :: Memory { .. } => None ,
1763+ BackendRepr :: SimdVector { .. }
1764+ | BackendRepr :: Memory { .. }
1765+ | BackendRepr :: ScalableVector { .. } => None ,
17551766 }
17561767 }
17571768
@@ -1766,6 +1777,9 @@ impl BackendRepr {
17661777 BackendRepr :: SimdVector { element : element. to_union ( ) , count }
17671778 }
17681779 BackendRepr :: Memory { .. } => BackendRepr :: Memory { sized : true } ,
1780+ BackendRepr :: ScalableVector { element, count } => {
1781+ BackendRepr :: ScalableVector { element : element. to_union ( ) , count }
1782+ }
17691783 }
17701784 }
17711785
@@ -2006,7 +2020,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
20062020 /// Returns `true` if this is an aggregate type (including a ScalarPair!)
20072021 pub fn is_aggregate ( & self ) -> bool {
20082022 match self . backend_repr {
2009- BackendRepr :: Scalar ( _) | BackendRepr :: SimdVector { .. } => false ,
2023+ BackendRepr :: Scalar ( _)
2024+ | BackendRepr :: SimdVector { .. }
2025+ | BackendRepr :: ScalableVector { .. } => false ,
20102026 BackendRepr :: ScalarPair ( ..) | BackendRepr :: Memory { .. } => true ,
20112027 }
20122028 }
@@ -2100,6 +2116,19 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
21002116 self . is_sized ( ) && self . size . bytes ( ) == 0 && self . align . abi . bytes ( ) == 1
21012117 }
21022118
2119+ /// Returns `true` if the size of the type is only known at runtime.
2120+ pub fn is_runtime_sized ( & self ) -> bool {
2121+ matches ! ( self . backend_repr, BackendRepr :: ScalableVector { .. } )
2122+ }
2123+
2124+ /// Returns the elements count of a scalable vector.
2125+ pub fn scalable_vector_element_count ( & self ) -> Option < u64 > {
2126+ match self . backend_repr {
2127+ BackendRepr :: ScalableVector { count, .. } => Some ( count) ,
2128+ _ => None ,
2129+ }
2130+ }
2131+
21032132 /// Returns `true` if the type is a ZST and not unsized.
21042133 ///
21052134 /// Note that this does *not* imply that the type is irrelevant for layout! It can still have
@@ -2108,6 +2137,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
21082137 match self . backend_repr {
21092138 BackendRepr :: Scalar ( _)
21102139 | BackendRepr :: ScalarPair ( ..)
2140+ | BackendRepr :: ScalableVector { .. }
21112141 | BackendRepr :: SimdVector { .. } => false ,
21122142 BackendRepr :: Memory { sized } => sized && self . size . bytes ( ) == 0 ,
21132143 }
0 commit comments