@@ -1671,6 +1671,10 @@ impl AddressSpace {
1671
1671
pub enum BackendRepr {
1672
1672
Scalar ( Scalar ) ,
1673
1673
ScalarPair ( Scalar , Scalar ) ,
1674
+ ScalableVector {
1675
+ element : Scalar ,
1676
+ count : u64 ,
1677
+ } ,
1674
1678
SimdVector {
1675
1679
element : Scalar ,
1676
1680
count : u64 ,
@@ -1689,6 +1693,9 @@ impl BackendRepr {
1689
1693
match * self {
1690
1694
BackendRepr :: Scalar ( _)
1691
1695
| 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 { .. }
1692
1699
| BackendRepr :: SimdVector { .. } => false ,
1693
1700
BackendRepr :: Memory { sized } => !sized,
1694
1701
}
@@ -1729,7 +1736,9 @@ impl BackendRepr {
1729
1736
BackendRepr :: Scalar ( s) => Some ( s. align ( cx) . abi ) ,
1730
1737
BackendRepr :: ScalarPair ( s1, s2) => Some ( s1. align ( cx) . max ( s2. align ( cx) ) . abi ) ,
1731
1738
// 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 ,
1733
1742
}
1734
1743
}
1735
1744
@@ -1751,7 +1760,9 @@ impl BackendRepr {
1751
1760
Some ( size)
1752
1761
}
1753
1762
// 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 ,
1755
1766
}
1756
1767
}
1757
1768
@@ -1766,6 +1777,9 @@ impl BackendRepr {
1766
1777
BackendRepr :: SimdVector { element : element. to_union ( ) , count }
1767
1778
}
1768
1779
BackendRepr :: Memory { .. } => BackendRepr :: Memory { sized : true } ,
1780
+ BackendRepr :: ScalableVector { element, count } => {
1781
+ BackendRepr :: ScalableVector { element : element. to_union ( ) , count }
1782
+ }
1769
1783
}
1770
1784
}
1771
1785
@@ -2006,7 +2020,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
2006
2020
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
2007
2021
pub fn is_aggregate ( & self ) -> bool {
2008
2022
match self . backend_repr {
2009
- BackendRepr :: Scalar ( _) | BackendRepr :: SimdVector { .. } => false ,
2023
+ BackendRepr :: Scalar ( _)
2024
+ | BackendRepr :: SimdVector { .. }
2025
+ | BackendRepr :: ScalableVector { .. } => false ,
2010
2026
BackendRepr :: ScalarPair ( ..) | BackendRepr :: Memory { .. } => true ,
2011
2027
}
2012
2028
}
@@ -2100,6 +2116,19 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
2100
2116
self . is_sized ( ) && self . size . bytes ( ) == 0 && self . align . abi . bytes ( ) == 1
2101
2117
}
2102
2118
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
+
2103
2132
/// Returns `true` if the type is a ZST and not unsized.
2104
2133
///
2105
2134
/// 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> {
2108
2137
match self . backend_repr {
2109
2138
BackendRepr :: Scalar ( _)
2110
2139
| BackendRepr :: ScalarPair ( ..)
2140
+ | BackendRepr :: ScalableVector { .. }
2111
2141
| BackendRepr :: SimdVector { .. } => false ,
2112
2142
BackendRepr :: Memory { sized } => sized && self . size . bytes ( ) == 0 ,
2113
2143
}
0 commit comments