Skip to main content

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#[cfg(target_arch = "aarch64")]
23#[rustc_intrinsic]
24#[rustc_nounwind]
25pub unsafe fn sve_cast<T, U>(x: T) -> U;
26
27/// Create a tuple of two vectors.
28///
29/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
30/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
31/// type `SVec`.
32///
33/// Corresponds to Clang's `__builtin_sve_svcreate2*` builtins.
34#[cfg(target_arch = "aarch64")]
35#[rustc_nounwind]
36#[rustc_intrinsic]
37pub unsafe fn sve_tuple_create2<SVec, SVecTup>(x0: SVec, x1: SVec) -> SVecTup;
38
39/// Create a tuple of three vectors.
40///
41/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
42/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
43/// type `SVec`.
44///
45/// Corresponds to Clang's `__builtin_sve_svcreate3*` builtins.
46#[cfg(target_arch = "aarch64")]
47#[rustc_intrinsic]
48#[rustc_nounwind]
49pub unsafe fn sve_tuple_create3<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec) -> SVecTup;
50
51/// Create a tuple of four vectors.
52///
53/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
54/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
55/// type `SVec`.
56///
57/// Corresponds to Clang's `__builtin_sve_svcreate4*` builtins.
58#[cfg(target_arch = "aarch64")]
59#[rustc_intrinsic]
60#[rustc_nounwind]
61pub unsafe fn sve_tuple_create4<SVec, SVecTup>(x0: SVec, x1: SVec, x2: SVec, x3: SVec) -> SVecTup;
62
63/// Get one vector from a tuple of vectors.
64///
65/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
66/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
67/// type `SVec`.
68///
69/// Corresponds to Clang's `__builtin_sve_svget*` builtins.
70///
71/// # Safety
72///
73/// `IDX` must be in-bounds of the tuple.
74#[cfg(target_arch = "aarch64")]
75#[rustc_intrinsic]
76#[rustc_nounwind]
77pub unsafe fn sve_tuple_get<SVecTup, SVec, const IDX: i32>(tuple: SVecTup) -> SVec;
78
79/// Change one vector in a tuple of vectors.
80///
81/// `SVecTup` must be a scalable vector tuple (`#[rustc_scalable_vector]`) and `SVec` must be a
82/// scalable vector (`#[rustc_scalable_vector(N)]`). `SVecTup` must be a tuple of vectors of
83/// type `SVec`.
84///
85/// Corresponds to Clang's `__builtin_sve_svset*` builtins.
86///
87/// # Safety
88///
89/// `IDX` must be in-bounds of the tuple.
90#[cfg(target_arch = "aarch64")]
91#[rustc_intrinsic]
92#[rustc_nounwind]
93pub unsafe fn sve_tuple_set<SVecTup, SVec, const IDX: i32>(tuple: SVecTup, x: SVec) -> SVecTup;