Skip to content

Commit 3528947

Browse files
committed
Auto merge of #143924 - davidtwco:sve-infrastructure, r=workingjubilee
`rustc_scalable_vector(N)` Supercedes rust-lang/rust#118917. Initial experimental implementation of rust-lang/rfcs#3838. Introduces a `rustc_scalable_vector(N)` attribute that can be applied to types with a single `[$ty]` field (for `u{16,32,64}`, `i{16,32,64}`, `f{32,64}`, `bool`). `rustc_scalable_vector` types are lowered to scalable vectors in the codegen backend. As with any unstable feature, there will necessarily be follow-ups as we experiment and find cases that we've not considered or still need some logic to handle, but this aims to be a decent baseline to start from. See rust-lang/rust#145052 for request for a lang experiment.
2 parents 25636fb + a43e9bd commit 3528947

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

rustc_public/src/abi.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ pub enum ValueAbi {
225225
element: Scalar,
226226
count: u64,
227227
},
228+
ScalableVector {
229+
element: Scalar,
230+
count: u64,
231+
},
228232
Aggregate {
229233
/// If true, the size is exact, otherwise it's only a lower bound.
230234
sized: bool,
@@ -235,7 +239,15 @@ impl ValueAbi {
235239
/// Returns `true` if the layout corresponds to an unsized type.
236240
pub fn is_unsized(&self) -> bool {
237241
match *self {
238-
ValueAbi::Scalar(_) | ValueAbi::ScalarPair(..) | ValueAbi::Vector { .. } => false,
242+
ValueAbi::Scalar(_)
243+
| ValueAbi::ScalarPair(..)
244+
| ValueAbi::Vector { .. }
245+
// FIXME(rustc_scalable_vector): Scalable vectors are `Sized` while the
246+
// `sized_hierarchy` feature is not yet fully implemented. After `sized_hierarchy` is
247+
// fully implemented, scalable vectors will remain `Sized`, they just won't be
248+
// `const Sized` - whether `is_unsized` continues to return `false` at that point will
249+
// need to be revisited and will depend on what `is_unsized` is used for.
250+
| ValueAbi::ScalableVector { .. } => false,
239251
ValueAbi::Aggregate { sized } => !sized,
240252
}
241253
}

rustc_public/src/unstable/convert/stable/abi.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr {
256256
rustc_abi::BackendRepr::SimdVector { element, count } => {
257257
ValueAbi::Vector { element: element.stable(tables, cx), count }
258258
}
259+
rustc_abi::BackendRepr::ScalableVector { element, count } => {
260+
ValueAbi::ScalableVector { element: element.stable(tables, cx), count }
261+
}
259262
rustc_abi::BackendRepr::Memory { sized } => ValueAbi::Aggregate { sized },
260263
}
261264
}

0 commit comments

Comments
 (0)