core/intrinsics/simd/scalable.rs
1//! Scalable vector compiler intrinsics.
2//!
3//! In this module, a "vector" is any `#[rustc_scalable_vector]`-annotated type.
4
5/// Numerically casts a vector, elementwise.
6///
7/// `T` and `U` must be vectors of integers or floats, and must have the same length.
8///
9/// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB.
10/// When casting integers to floats, the result is rounded.
11/// Otherwise, truncates or extends the value, maintaining the sign for signed integers.
12///
13/// # Safety
14/// Casting from integer types is always safe.
15/// Casting between two float types is also always safe.
16///
17/// Casting floats to integers truncates, following the same rules as `to_int_unchecked`.
18/// Specifically, each element must:
19/// * Not be `NaN`
20/// * Not be infinite
21/// * Be representable in the return type, after truncating off its fractional part
22#[rustc_intrinsic]
23#[rustc_nounwind]
24pub unsafe fn sve_cast<T, U>(x: T) -> U;
25
26/// Create a tuple of two vectors.
27///
28/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
29/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
30/// type `SVec`.
31///
32/// Corresponds to Clang's `__builtin_sve_svcreate2*` builtins.
33#[rustc_nounwind]
34#[rustc_intrinsic]
35pub unsafe fn sve_tuple_create2<SVec, SVecTup>(x0: SVec, x1: SVec) -> SVecTup;
36
37/// Create a tuple of three vectors.
38///
39/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
40/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
41/// type `SVec`.
42///
43/// Corresponds to Clang's `__builtin_sve_svcreate3*` builtins.
44#[rustc_intrinsic]
45#[rustc_nounwind]
46pub unsafe fn sve_tuple_create3<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec) -> SVecTup;
47
48/// Create a tuple of four vectors.
49///
50/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
51/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
52/// type `SVec`.
53///
54/// Corresponds to Clang's `__builtin_sve_svcreate4*` builtins.
55#[rustc_intrinsic]
56#[rustc_nounwind]
57pub unsafe fn sve_tuple_create4<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec, x3: SVec) -> SVecTup;
58
59/// Get one vector from a tuple of vectors.
60///
61/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
62/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
63/// type `SVec`.
64///
65/// Corresponds to Clang's `__builtin_sve_svget*` builtins.
66///
67/// # Safety
68///
69/// `IDX` must be in-bounds of the tuple.
70#[rustc_intrinsic]
71#[rustc_nounwind]
72pub unsafe fn sve_tuple_get<SVecTup, SVec, const IDX: i32>(tuple: SVecTup) -> SVec;
73
74/// Change one vector in a tuple of vectors.
75///
76/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
77/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
78/// type `SVec`.
79///
80/// Corresponds to Clang's `__builtin_sve_svset*` builtins.
81///
82/// # Safety
83///
84/// `IDX` must be in-bounds of the tuple.
85#[rustc_intrinsic]
86#[rustc_nounwind]
87pub unsafe fn sve_tuple_set<SVecTup, SVec, const IDX: i32>(tuple: SVecTup, x: SVec) -> SVecTup;