diff --git a/.github/workflows/flux.yml b/.github/workflows/flux.yml index bfa3483899a83..96095ffe9e05f 100644 --- a/.github/workflows/flux.yml +++ b/.github/workflows/flux.yml @@ -8,7 +8,7 @@ on: branches: [main] env: - FLUX_VERSION: "0301038641e330c133a237d66bb95a6f214058c4" + FLUX_VERSION: "828d6086c94a1171fce81fab449ace2abc9e1540" FIXPOINT_VERSION: "nightly" jobs: diff --git a/library/alloc/src/boxed/convert.rs b/library/alloc/src/boxed/convert.rs index e208c2384a16d..bcd0dc6eea29f 100644 --- a/library/alloc/src/boxed/convert.rs +++ b/library/alloc/src/boxed/convert.rs @@ -283,13 +283,12 @@ impl TryFrom> for Box<[T; N], A> { /// Attempts to convert a `Vec` into a `Box<[T; N]>`. /// - /// Like [`Vec::into_boxed_slice`], this is in-place if `vec.capacity() == N`, - /// but will require a reallocation otherwise. + /// For allocation behavior, see [`Vec::into_boxed_slice`]. /// /// # Errors /// /// Returns the original `Vec` in the `Err` variant if - /// `boxed_slice.len()` does not equal `N`. + /// `vec.len()` does not equal `N`. /// /// # Examples /// diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index b0e9e5203edfb..1d7e6ad89a469 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -1441,7 +1441,7 @@ impl BinaryHeap { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("length", "size")] - #[rustc_const_stable(feature = "const_binary_heap_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_binary_heap_len", since = "1.101.0")] pub const fn len(&self) -> usize { self.data.len() } @@ -1466,7 +1466,7 @@ impl BinaryHeap { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_binary_heap_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_binary_heap_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index c4d9bfe777b16..17198946a3cde 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -2837,7 +2837,7 @@ impl BTreeMap { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_btree_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_btree_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.length @@ -2857,7 +2857,7 @@ impl BTreeMap { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_btree_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_btree_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 6008bcb4389ac..c74d1a12bf081 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1266,7 +1266,7 @@ impl BTreeSet { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_btree_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_btree_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.map.len() @@ -1286,7 +1286,7 @@ impl BTreeSet { /// ``` #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_btree_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_btree_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 38c1e770e6981..07d7a62a03b24 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -689,7 +689,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.head.is_none() } @@ -717,7 +717,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.len diff --git a/library/alloc/src/collections/vec_deque/drain.rs b/library/alloc/src/collections/vec_deque/drain.rs index 38d540ab08040..77821f6dcb8b9 100644 --- a/library/alloc/src/collections/vec_deque/drain.rs +++ b/library/alloc/src/collections/vec_deque/drain.rs @@ -72,6 +72,14 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> { (deque.buffer_range(a_range), deque.buffer_range(b_range)) } } + + /// Returns a reference to the underlying allocator. + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] + #[inline] + pub fn allocator(&self) -> &A { + // SAFETY: `deque` is valid for reads for the lifetime of the `Drain`. + unsafe { self.deque.as_ref().allocator() } + } } #[stable(feature = "collection_debug", since = "1.17.0")] diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 7cac57421ac5e..a97dc65916899 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -31,6 +31,13 @@ impl IntoIter { pub(super) fn into_vecdeque(self) -> VecDeque { self.inner } + + /// Returns a reference to the underlying allocator. + #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] + #[inline] + pub fn allocator(&self) -> &A { + self.inner.allocator() + } } #[stable(feature = "collection_debug", since = "1.17.0")] diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 33500405d0d22..a7b03b8ff0446 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1807,7 +1807,7 @@ impl VecDeque { /// assert_eq!(deque.len(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_vec_deque_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_vec_deque_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.len @@ -1826,7 +1826,7 @@ impl VecDeque { /// assert!(!deque.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_vec_deque_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_vec_deque_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.len == 0 } diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 334d49706dbb9..cf116509ba321 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -139,7 +139,8 @@ //! The width can also be provided dynamically by referencing another argument //! with a `$` suffix. Use `{:N$}` to reference the Nth positional argument //! (where N is an integer), or `{:name$}` to reference a named argument. The -//! referenced argument must be of type [`usize`]. +//! referenced argument must be of type [`usize`]. Currently formatting will +//! panic if the width exceeds [`u16::MAX`]. //! //! Referring to an argument with the dollar syntax does not affect the "next //! argument" counter, so it's usually a good idea to refer to arguments by diff --git a/library/alloc/src/rcs/arc.rs b/library/alloc/src/rcs/arc.rs index 59048f9785263..b76001e55ae65 100644 --- a/library/alloc/src/rcs/arc.rs +++ b/library/alloc/src/rcs/arc.rs @@ -2925,7 +2925,7 @@ impl Arc { /// /// [`get_mut_unchecked`]: Self::get_mut_unchecked #[inline] - #[stable(feature = "arc_is_unique", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "arc_is_unique", since = "1.101.0")] pub fn is_unique(this: &Self) -> bool { // lock the weak pointer count if we appear to be the sole weak pointer // holder. diff --git a/library/alloc/src/rcs/rc.rs b/library/alloc/src/rcs/rc.rs index bdf965ed076f0..1874441f3f920 100644 --- a/library/alloc/src/rcs/rc.rs +++ b/library/alloc/src/rcs/rc.rs @@ -2045,7 +2045,7 @@ impl Rc { /// /// [`get_mut_unchecked`]: Self::get_mut_unchecked #[inline] - #[stable(feature = "arc_is_unique", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "arc_is_unique", since = "1.101.0")] pub fn is_unique(this: &Self) -> bool { Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1 } diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 97aa0ae1b45f0..1e3861b3cb933 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -58,7 +58,7 @@ use core::ops::Add; use core::ops::AddAssign; use core::ops::{self, Range, RangeBounds}; use core::str::pattern::{Pattern, Utf8Pattern}; -use core::{fmt, hash, hint, ptr, slice}; +use core::{fmt, hash, ptr, slice}; #[cfg(not(no_global_oom_handling))] use crate::alloc::Allocator; @@ -1697,66 +1697,54 @@ impl String { where F: FnMut(char) -> bool, { - let len = self.len(); - if len == 0 { - // Explicit check results in better optimization - return; - } - - struct PanicGuard<'a> { + struct SetLenOnDrop<'a> { s: &'a mut String, - write: usize, + idx: usize, + del_bytes: usize, } - impl Drop for PanicGuard<'_> { + impl<'a> Drop for SetLenOnDrop<'a> { fn drop(&mut self) { - debug_assert!(self.write <= self.s.len()); - debug_assert!(str::from_utf8(&self.s.vec[..self.write]).is_ok()); + let new_len = self.idx - self.del_bytes; + debug_assert!(new_len <= self.s.len()); // SAFETY: Restore the string length to the number of bytes written so far. - unsafe { self.s.vec.set_len(self.write) } + unsafe { self.s.vec.set_len(new_len) }; } } - // Fast path: find the first character that should be removed or return early. - let mut chars = self.char_indices(); - let (mut read, write) = loop { - let Some((idx, ch)) = chars.next() else { return }; - if hint::unlikely(!f(ch)) { - break (idx + ch.len_utf8(), idx); - } - }; - drop(chars); - - // Slow path: at least one character is going to be removed. - let mut g = PanicGuard { s: self, write }; - while read < len { - // SAFETY: Use `vec`: `String`'s deref includes `write..read`, - // which may be invalid UTF-8. The vector's length is still `len`; - // `read < len`, so `read..len` is in bounds and non-empty. - // At least one character was removed, so `write < read`. - // Copies end before the next `read`, preserving unread bytes. - // `read` starts after a `char_indices` character and advances by whole - // characters, so it stays on a char boundary. The original string was valid UTF-8, - // so the unchanged, non-empty tail is valid UTF-8 and `chars().next()` returns `Some`. - let ch = unsafe { - let tail = str::from_utf8_unchecked(g.s.vec.get_unchecked(read..len)); - tail.chars().next().unwrap_unchecked() - }; + let len = self.len(); + let mut guard = SetLenOnDrop { s: self, idx: 0, del_bytes: 0 }; + + while guard.idx < len { + let ch = + // SAFETY: `guard.idx` is positive-or-zero and less that len so the `get_unchecked` + // is in bound. `self` is valid UTF-8 like string and the returned slice starts at + // a unicode code point so the `Chars` always return one character. + unsafe { guard.s.get_unchecked(guard.idx..len).chars().next().unwrap_unchecked() }; let ch_len = ch.len_utf8(); - if f(ch) { - // SAFETY: `read` is on a char boundary, as guaranteed above; `g.write` is - // within bounds because it is always behind `read`. - unsafe { - let ptr = g.s.vec.as_mut_ptr(); - ptr::copy(ptr.add(read), ptr.add(g.write), ch_len); - } - g.write += ch_len; + + if !f(ch) { + guard.del_bytes += ch_len; + } else if guard.del_bytes > 0 { + // SAFETY: `guard.idx` is in bound and `guard.del_bytes` represent the number of + // bytes that are erased from the string so the resulting `guard.idx - + // guard.del_bytes` always represent a valid unicode code point. + // + // `guard.del_bytes` >= `ch.len_utf8()`, so taking a slice with `ch.len_utf8()` len + // is safe. + ch.encode_utf8(unsafe { + crate::slice::from_raw_parts_mut( + guard.s.as_mut_ptr().add(guard.idx - guard.del_bytes), + ch.len_utf8(), + ) + }); } - read += ch_len; + + // Point idx to the next char + guard.idx += ch_len; } - // All bytes processed; commit the final length by dropping the guard. - drop(g); + drop(guard); } /// Inserts a character into this `String` at byte position `idx`. @@ -1795,9 +1783,8 @@ impl String { let ch_len = ch.len_utf8(); self.reserve(ch_len); - // SAFETY: Move the bytes starting from `idx` to their new location `ch_len` - // bytes ahead. This is safe because sufficient capacity was reserved, and `idx` - // is a char boundary. + // Move the bytes starting from `idx` to their new location `ch_len` bytes ahead. + // SAFETY: Sufficient capacity was reserved, and `idx` is a char boundary. unsafe { ptr::copy( self.vec.as_ptr().add(idx), @@ -1806,13 +1793,15 @@ impl String { ); } - // SAFETY: Encode the character into the vacated region if `idx != len`, + // Encode the character into the vacated region if `idx != len`, // or into the uninitialized spare capacity otherwise. + // SAFETY: `idx + ch_len` is in bounds in either case, and `idx` is a char boundary. unsafe { core::char::encode_utf8_raw_unchecked(ch as u32, self.vec.as_mut_ptr().add(idx)); } - // SAFETY: Update the length to include the newly added bytes. + // Update the length to include the newly added bytes. + // SAFETY: We just wrote to all locations in the range `idx..len + ch_len`. unsafe { self.vec.set_len(len + ch_len); } @@ -1852,21 +1841,21 @@ impl String { let amt = string.len(); self.reserve(amt); - // SAFETY: Move the bytes starting from `idx` to their new location `amt` bytes - // ahead. This is safe because sufficient capacity was just reserved, and `idx` - // is a char boundary. + // Move the bytes starting from `idx` to their new location `amt` bytes ahead. + // SAFETY: Sufficient capacity was just reserved, and `idx` is a char boundary. unsafe { ptr::copy(self.vec.as_ptr().add(idx), self.vec.as_mut_ptr().add(idx + amt), len - idx); } - // SAFETY: Copy the new string slice into the vacated region if `idx != len`, - // or into the uninitialized spare capacity otherwise. The borrow checker - // ensures that the source and destination do not overlap. + // Copy the new string slice into the vacated region if `idx != len`, + // or into the uninitialized spare capacity otherwise. + // SAFETY: The borrow checker ensures that the source and destination do not overlap. unsafe { ptr::copy_nonoverlapping(string.as_ptr(), self.vec.as_mut_ptr().add(idx), amt); } - // SAFETY: Update the length to include the newly added bytes. + // Update the length to include the newly added bytes. + // SAFETY: We just wrote to all locations in the range `idx..len + amt`. unsafe { self.vec.set_len(len + amt); } @@ -2107,7 +2096,7 @@ impl String { /// [`char`]: prim@char #[inline] #[must_use = "`self` will be dropped if the result is not used"] - #[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "string_into_chars", since = "1.101.0")] pub fn into_chars(self) -> IntoChars { IntoChars { bytes: self.into_bytes().into_iter() } } @@ -3619,12 +3608,12 @@ impl fmt::Write for String { /// [`into_chars`]: String::into_chars #[cfg_attr(not(no_global_oom_handling), derive(Clone))] #[must_use = "iterators are lazy and do nothing unless consumed"] -#[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "string_into_chars", since = "1.101.0")] pub struct IntoChars { bytes: vec::IntoIter, } -#[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "string_into_chars", since = "1.101.0")] impl fmt::Debug for IntoChars { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoChars").field(&self.as_str()).finish() @@ -3646,7 +3635,7 @@ impl IntoChars { /// chars.next(); /// assert_eq!(chars.as_str(), ""); /// ``` - #[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "string_into_chars", since = "1.101.0")] #[must_use] #[inline] pub fn as_str(&self) -> &str { @@ -3667,7 +3656,7 @@ impl IntoChars { /// assert_eq!(chars.into_string(), "ef"); /// ``` #[cfg(not(no_global_oom_handling))] - #[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "string_into_chars", since = "1.101.0")] #[inline] pub fn into_string(self) -> String { // SAFETY: `bytes` are kept in UTF-8 form, only removing whole `char`s at a time. @@ -3680,7 +3669,7 @@ impl IntoChars { } } -#[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "string_into_chars", since = "1.101.0")] impl Iterator for IntoChars { type Item = char; @@ -3714,7 +3703,7 @@ impl Iterator for IntoChars { } } -#[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "string_into_chars", since = "1.101.0")] impl DoubleEndedIterator for IntoChars { #[inline] fn next_back(&mut self) -> Option { @@ -3731,7 +3720,7 @@ impl DoubleEndedIterator for IntoChars { } } -#[stable(feature = "string_into_chars", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "string_into_chars", since = "1.101.0")] impl FusedIterator for IntoChars {} /// A draining iterator for `String`. diff --git a/library/alloc/src/vec/drain.rs b/library/alloc/src/vec/drain.rs index a4059db012c63..d96226addd36a 100644 --- a/library/alloc/src/vec/drain.rs +++ b/library/alloc/src/vec/drain.rs @@ -59,7 +59,6 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> { /// Returns a reference to the underlying allocator. #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] - #[must_use] #[inline] pub fn allocator(&self) -> &A { // SAFETY: `vec` is valid for reads. diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index d15c110215df7..176a394908ac5 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -50,7 +50,7 @@ macro non_null { #[rustc_insignificant_dtor] pub struct IntoIter< T, - #[stable(feature = "vec_into_iter_allocator", since = "CURRENT_RUSTC_VERSION")] A: Allocator = Global, + #[stable(feature = "vec_into_iter_allocator", since = "1.101.0")] A: Allocator = Global, > { pub(super) buf: NonNull, pub(super) phantom: PhantomData, @@ -116,7 +116,7 @@ impl IntoIter { } /// Returns a reference to the underlying allocator. - #[stable(feature = "vec_into_iter_allocator", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_into_iter_allocator", since = "1.101.0")] #[inline] pub fn allocator(&self) -> &A { &self.alloc diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 6e47260efe214..1bdec5a74c9e6 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1619,8 +1619,14 @@ impl Vec { /// Converts the vector into a boxed slice. /// - /// This conversion is in-place if `vec.len() == vec.capacity()`. Otherwise excess capacity - /// is discarded by reallocating before doing the conversion. + /// This conversion is in-place if `vec.len() == vec.capacity()`. + /// + /// Before doing the conversion, this method adjusts the vector's allocation as + /// needed so that, if a backing allocation is present, the layout of the returned + /// slice [*fits*] that allocation. Thus, the vector's former capacity is not needed + /// to determine a layout suitable for deallocation. + /// + /// [*fits*]: crate::alloc::Allocator#memory-fitting /// /// # Examples /// @@ -1630,7 +1636,7 @@ impl Vec { /// let slice = v.into_boxed_slice(); /// ``` /// - /// Any excess capacity is removed: + /// The vector's spare capacity is not retained: /// /// ``` /// let mut vec = Vec::with_capacity(10); @@ -1654,7 +1660,7 @@ impl Vec { } /// Converts the Vec into a boxed array. This conversion will discard any spare capacity, - /// if there is any, see [`Vec::shrink_to_fit`]. + /// if there is any, see [`Vec::into_boxed_slice`]. /// If you merely wish for a reference to an array, use [`as_array`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_array). /// /// # Errors @@ -2351,7 +2357,7 @@ impl Vec { /// assert_eq!(v.try_remove(0), Some(1)); /// assert_eq!(v.try_remove(2), None); /// ``` - #[stable(feature = "vec_try_remove", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_try_remove", since = "1.101.0")] #[rustc_confusables("delete", "take", "remove")] pub fn try_remove(&mut self, index: usize) -> Option { let len = self.len(); @@ -3601,7 +3607,61 @@ where { } +impl Vec { + /// Create a new `Vec` that contains `elem` `n` times. + /// + /// This method requires `T` to implement [`Clone`], + /// in order to be able to clone the passed value. + /// + /// If `n` is zero, the vector will not allocate. + /// + /// # Panics + /// + /// Panics if `size_of::() * n` exceeds `isize::MAX` bytes. + /// + /// # Examples + /// + /// ``` + /// #![feature(vec_repeat)] + /// let vec = Vec::repeat(0, 3); + /// assert_eq!(vec, [0; 3]); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "vec_repeat", issue = "164215")] + #[inline] + pub fn repeat(elem: T, n: usize) -> Self { + ::from_elem(elem, n, Global) + } +} + impl Vec { + /// Create a new `Vec` with the provided allocator that contains `elem` `n` times. + /// + /// This method requires `T` to implement [`Clone`], + /// in order to be able to clone the passed value. + /// + /// If `n` is zero, the vector will not allocate. + /// + /// # Panics + /// + /// Panics if `size_of::() * n` exceeds `isize::MAX` bytes. + /// + /// # Examples + /// + /// ``` + /// #![feature(vec_repeat)] + /// use std::alloc::System; + /// + /// let vec = Vec::repeat_in(0, 3, System); + /// assert_eq!(vec, [0; 3]); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "vec_repeat", issue = "164215")] + #[inline] + pub fn repeat_in(elem: T, n: usize, alloc: A) -> Self { + ::from_elem(elem, n, alloc) + } + /// Resizes the `Vec` in-place so that `len` is equal to `new_len`. /// /// If `new_len` is greater than `len`, the `Vec` is extended by the @@ -3836,32 +3896,24 @@ const fn dedup_simd_chunk_size() -> Option { if size == 8 { None } else { Some(SIMD_WIDTH) } } - all(target_arch = "aarch64", target_feature = "neon") => { + all(target_arch = "aarch64", target_feature = "neon") => Some(SIMD_WIDTH), + + all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse4.1") => { Some(SIMD_WIDTH) } - all( - any(target_arch = "x86", target_arch = "x86_64"), - target_feature = "sse4.1" - ) => Some(SIMD_WIDTH), - - all( - any(target_arch = "x86", target_arch = "x86_64"), - target_feature = "sse2" - ) => { + all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2") => { // Packed 64-bit integer lane equality is only available on sse4.1 if size == 8 { None } else { Some(SIMD_WIDTH) } } - all( - any(target_arch = "riscv32", target_arch = "riscv64"), - target_feature = "v" - ) => Some(SIMD_WIDTH), + all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "v") => { + Some(SIMD_WIDTH) + } - all( - any(target_arch = "loongarch32", target_arch = "loongarch64"), - target_feature = "lsx" - ) => Some(SIMD_WIDTH), + all(any(target_arch = "loongarch32", target_arch = "loongarch64"), target_feature = "lsx") => { + Some(SIMD_WIDTH) + } _ => None, }; @@ -3951,24 +4003,21 @@ fn find_first_duplicate(v: &[T], chunk_size: usize) -> Option(elem: T, n: usize) -> Vec { vec![elem; n] } +// This function is required because it ensures the `vec_from_elem` diagnostic +// item is emitted, which is consumed by Clippy to detect calls to +// `vec![elem; n]`. We cannot add the item to `Vec::repeat` because then we +// would end up confusing Clippy. #[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[unstable(feature = "liballoc_internals", issue = "none")] #[rustc_diagnostic_item = "vec_from_elem"] pub fn from_elem_global(elem: T, n: usize) -> Vec { - ::from_elem(elem, n, Global) -} - -#[doc(hidden)] -#[cfg(not(no_global_oom_handling))] -#[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] -pub fn from_elem_in(elem: T, n: usize, alloc: A) -> Vec { - ::from_elem(elem, n, alloc) + Vec::repeat(elem, n) } #[cfg(not(no_global_oom_handling))] @@ -4703,7 +4752,6 @@ where } } -// note: test pulls in std, which causes errors here #[stable(feature = "vec_from_box", since = "1.18.0")] impl From> for Vec { /// Converts a boxed slice into a vector by transferring ownership of @@ -4720,28 +4768,18 @@ impl From> for Vec { } } -// note: test pulls in std, which causes errors here #[cfg(not(no_global_oom_handling))] #[stable(feature = "box_from_vec", since = "1.20.0")] impl From> for Box<[T], A> { /// Converts a vector into a boxed slice. /// - /// This conversion is in-place if `vec.len() == vec.capacity()`. Otherwise, excess capacity - /// is discarded by reallocating before doing the conversion. + /// This is equivalent to [`Vec::into_boxed_slice`]. /// /// # Examples /// /// ``` /// assert_eq!(Box::from(vec![1, 2, 3]), vec![1, 2, 3].into_boxed_slice()); /// ``` - /// - /// Any excess capacity is removed: - /// ``` - /// let mut vec = Vec::with_capacity(10); - /// vec.extend([1, 2, 3]); - /// - /// assert_eq!(Box::from(vec), vec![1, 2, 3].into_boxed_slice()); - /// ``` fn from(v: Vec) -> Self { v.into_boxed_slice() } diff --git a/library/alloctests/tests/c_str_alloc_error.rs b/library/alloctests/tests/c_str_alloc_error.rs index 1e7d54d75b332..fc5721695836f 100644 --- a/library/alloctests/tests/c_str_alloc_error.rs +++ b/library/alloctests/tests/c_str_alloc_error.rs @@ -15,20 +15,22 @@ #![feature(alloc_error_hook)] use std::alloc::{GlobalAlloc, Layout, System, set_alloc_error_hook}; +use std::cell::Cell; use std::ffi::CString; use std::panic::{AssertUnwindSafe, catch_unwind}; -use std::sync::atomic::{AtomicBool, Ordering}; // Once armed, the first allocation of 8 bytes or more fails and disarms, so the // reallocation inside `clone_into`'s grow path fails while the runtime's own // smaller allocations keep succeeding. struct OneShotFailingAlloc; -static ARMED: AtomicBool = AtomicBool::new(false); +thread_local! { + static ARMED: Cell = const { Cell::new(false) }; +} unsafe impl GlobalAlloc for OneShotFailingAlloc { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - if layout.size() >= 8 && ARMED.swap(false, Ordering::SeqCst) { + if layout.size() >= 8 && ARMED.replace(false) { return core::ptr::null_mut(); } unsafe { System.alloc(layout) } @@ -39,7 +41,7 @@ unsafe impl GlobalAlloc for OneShotFailingAlloc { } unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { - if new_size >= 8 && ARMED.swap(false, Ordering::SeqCst) { + if new_size >= 8 && ARMED.replace(false) { return core::ptr::null_mut(); } unsafe { System.realloc(ptr, layout, new_size) } @@ -59,11 +61,11 @@ fn clone_into_alloc_failure_leaves_target_valid() { let src = CString::new("a fairly long value").unwrap(); let mut target = CString::new("x").unwrap(); - ARMED.store(true, Ordering::SeqCst); + ARMED.set(true); // Under Miri the failing allocator is honored, so this reallocation unwinds; in a // normal build the allocator can't intercept it and `clone_into` just succeeds. let res = catch_unwind(AssertUnwindSafe(|| src.as_c_str().clone_into(&mut target))); - ARMED.store(false, Ordering::SeqCst); + ARMED.set(false); if cfg!(miri) { assert!(res.is_err(), "clone_into should have unwound on the alloc failure"); diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 3a5d101543075..f7a9b3b12423a 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -754,7 +754,7 @@ impl CStr { /// let cstr = c"Hello, world!"; /// println!("{}", cstr.display()); /// ``` - #[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "cstr_display", since = "1.101.0")] #[must_use = "this does not display the `CStr`; \ it returns an object that can be displayed"] #[inline] @@ -986,19 +986,19 @@ impl FusedIterator for Bytes<'_> {} /// /// [`Display`]: fmt::Display /// [`format!`]: ../../../std/macro.format.html -#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "cstr_display", since = "1.101.0")] pub struct Display<'a> { c_str: &'a CStr, } -#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "cstr_display", since = "1.101.0")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.c_str, f) } } -#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "cstr_display", since = "1.101.0")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(crate::byte_str::ByteStr::from_bytes(self.c_str.to_bytes()), f) diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index 74213005b566d..aed7adb6292ef 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -39,8 +39,12 @@ use crate::marker::PhantomCovariantLifetime; // derive `Copy`. However, in the future we might want to support a target where `va_copy` // allocates, or otherwise violates the requirements of `Copy`. Therefore `VaList` is only `Clone`. crate::cfg_select! { - all(target_arch = "aarch64", not(target_vendor = "apple"), not(target_os = "uefi"), not(windows)) => - { + all( + target_arch = "aarch64", + not(target_vendor = "apple"), + not(target_os = "uefi"), + not(windows) + ) => { /// AArch64 ABI implementation of a `va_list`. /// /// See the [AArch64 Procedure Call Standard] for more details. diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index 20ce752dd7c41..1b335a9426add 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -209,7 +209,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> { /// r#"Bar { bar: 0x0000000a, another: "Hello World" }"#, /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn field_with( &mut self, name: &str, @@ -426,7 +426,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> { /// r#"Foo(0x0000000a, "Hello World")"#, /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn field_with( &mut self, value_fmt: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, @@ -652,7 +652,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> { /// "{[10, 11], {12, 13}}", /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn entry_with( &mut self, entry_fmt: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, @@ -867,7 +867,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> { /// "[[10, 11], {12, 13}]", /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn entry_with( &mut self, entry_fmt: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, @@ -1158,7 +1158,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// r#"{entry A: 0x0000000a, entry B: 0x0000000b}"#, /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn key_with( &mut self, key_fmt: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, @@ -1256,7 +1256,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// r#"{entry A: 0x0000000a, entry B: 0x0000000b}"#, /// ); /// ``` - #[stable(feature = "debug_closure_helpers", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "debug_closure_helpers", since = "1.101.0")] pub fn value_with( &mut self, value_fmt: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, diff --git a/library/core/src/fmt/num_buffer.rs b/library/core/src/fmt/num_buffer.rs index 62089e30a06e2..ec135cf044749 100644 --- a/library/core/src/fmt/num_buffer.rs +++ b/library/core/src/fmt/num_buffer.rs @@ -85,7 +85,7 @@ impl NumBuffer { } } -#[stable(feature = "num_buffer_default", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "num_buffer_default", since = "1.101.0")] impl Default for NumBuffer { fn default() -> Self { Self::new() diff --git a/library/core/src/intrinsics/bounds.rs b/library/core/src/intrinsics/bounds.rs index 87d00ece91bc0..1a7f5d5e8c5af 100644 --- a/library/core/src/intrinsics/bounds.rs +++ b/library/core/src/intrinsics/bounds.rs @@ -45,67 +45,48 @@ impl ChangePointee for *const T { /// # Safety /// Must actually *be* such a type. pub unsafe trait FloatPrimitive: - Sized + Copy + core::ops::Mul + core::ops::Add + Sized + Copy + PartialOrd + core::ops::Mul + core::ops::Add { - type UInt: const core::ops::BitOr - + const core::ops::BitAnd - + const core::ops::Not; + type UInt: core::ops::BitOr + + core::ops::BitAnd + + core::ops::Not; const SIGN_MASK: Self::UInt; fn to_bits(self) -> Self::UInt; fn from_bits(bits: Self::UInt) -> Self; + fn is_nan(self) -> bool; + fn is_sign_positive(self) -> bool; + fn is_sign_negative(self) -> bool; } -unsafe impl FloatPrimitive for f16 { - type UInt = u16; - const SIGN_MASK: Self::UInt = f16::SIGN_MASK; - #[inline] - fn to_bits(self) -> Self::UInt { - f16::to_bits(self) - } - #[inline] - fn from_bits(bits: Self::UInt) -> Self { - f16::from_bits(bits) - } -} - -unsafe impl FloatPrimitive for f32 { - type UInt = u32; - const SIGN_MASK: Self::UInt = f32::SIGN_MASK; - #[inline] - fn to_bits(self) -> Self::UInt { - f32::to_bits(self) - } - #[inline] - fn from_bits(bits: Self::UInt) -> Self { - f32::from_bits(bits) - } -} - -unsafe impl FloatPrimitive for f64 { - type UInt = u64; - const SIGN_MASK: Self::UInt = f64::SIGN_MASK; - #[inline] - fn to_bits(self) -> Self::UInt { - f64::to_bits(self) - } - #[inline] - fn from_bits(bits: Self::UInt) -> Self { - f64::from_bits(bits) - } -} - -unsafe impl FloatPrimitive for f128 { - type UInt = u128; - const SIGN_MASK: Self::UInt = f128::SIGN_MASK; - #[inline] - fn to_bits(self) -> Self::UInt { - f128::to_bits(self) - } - #[inline] - fn from_bits(bits: Self::UInt) -> Self { - f128::from_bits(bits) - } -} +macro_rules! impl_float_primitive { + ($($float:ident => $bits:ident),+) => {$( + unsafe impl FloatPrimitive for $float { + type UInt = $bits; + const SIGN_MASK: Self::UInt = $float::SIGN_MASK; + #[inline] + fn to_bits(self) -> Self::UInt { + $float::to_bits(self) + } + #[inline] + fn from_bits(bits: Self::UInt) -> Self { + $float::from_bits(bits) + } + #[inline] + fn is_nan(self) -> bool { + $float::is_nan(self) + } + #[inline] + fn is_sign_positive(self) -> bool { + $float::is_sign_positive(self) + } + #[inline] + fn is_sign_negative(self) -> bool { + $float::is_sign_negative(self) + } + } + )+}; +} +impl_float_primitive!(f16 => u16, f32 => u32, f64 => u64, f128 => u128); /// Built-in integer types (i8, i16, .., i128, isize, u8, u16, .., u128, usize). /// diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 38bfa12e6b778..c69e706b9c0ec 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3131,7 +3131,7 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize); // #[cfg_attr(kani, kani::modifies(crate::ptr::slice_from_raw_parts(dst, count)))] pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize); -/// Returns the minimum of two `f16` values, ignoring NaN. +/// Returns the minimum of two floating-point values, ignoring NaN. /// /// This behaves like IEEE 754-2019 minimumNumber, *except* that it does not order signed /// zeros deterministically. In particular: @@ -3144,60 +3144,13 @@ pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize); /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// -/// The stabilized version of this intrinsic is [`f16::min`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn minimum_number_nsz_f16(x: f16, y: f16) -> f16 { - if x.is_nan() || y <= x { - y - } else { - // Either y > x or y is a NaN. - x - } -} - -/// Returns the minimum of two `f32` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 minimumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f32::min`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn minimum_number_nsz_f32(x: f32, y: f32) -> f32 { - if x.is_nan() || y <= x { - y - } else { - // Either y > x or y is a NaN. - x - } -} - -/// Returns the minimum of two `f64` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 minimumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f64::min`]. +/// The stabilized versions of this intrinsic are available on the float primitives via the +/// `min` method. For example, [`f32::min`]. #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -pub const fn minimum_number_nsz_f64(x: f64, y: f64) -> f64 { +#[rustc_do_not_const_check] +pub const fn minimum_number_nsz(x: T, y: T) -> T { if x.is_nan() || y <= x { y } else { @@ -3206,9 +3159,9 @@ pub const fn minimum_number_nsz_f64(x: f64, y: f64) -> f64 { } } -/// Returns the minimum of two `f128` values, ignoring NaN. +/// Returns the maximum of two floating-point values, ignoring NaN. /// -/// This behaves like IEEE 754-2019 minimumNumber, *except* that it does not order signed +/// This behaves like IEEE 754-2019 maximumNumber, *except* that it does not order signed /// zeros deterministically. In particular: /// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If /// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` @@ -3219,94 +3172,22 @@ pub const fn minimum_number_nsz_f64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// -/// The stabilized version of this intrinsic is [`f128::min`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn minimum_number_nsz_f128(x: f128, y: f128) -> f128 { - if x.is_nan() || y <= x { - y - } else { - // Either y > x or y is a NaN. - x - } -} - -/// Returns the minimum of two `f16` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 minimum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn minimumf16(x: f16, y: f16) -> f16 { - if x < y { - x - } else if y < x { - y - } else if x == y { - if x.is_sign_negative() && y.is_sign_positive() { x } else { y } - } else { - // At least one input is NaN. Use `+` to perform NaN propagation and quieting. - x + y - } -} - -/// Returns the minimum of two `f32` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 minimum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. +/// The stabilized versions of this intrinsic are available on the float primitives via the +/// `max` method. For example, [`f32::max`]. #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -pub const fn minimumf32(x: f32, y: f32) -> f32 { - if x < y { - x - } else if y < x { +#[rustc_do_not_const_check] +pub const fn maximum_number_nsz(x: T, y: T) -> T { + if x.is_nan() || y >= x { y - } else if x == y { - if x.is_sign_negative() && y.is_sign_positive() { x } else { y } } else { - // At least one input is NaN. Use `+` to perform NaN propagation and quieting. - x + y - } -} - -/// Returns the minimum of two `f64` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 minimum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn minimumf64(x: f64, y: f64) -> f64 { - if x < y { + // Either y < x or y is a NaN. x - } else if y < x { - y - } else if x == y { - if x.is_sign_negative() && y.is_sign_positive() { x } else { y } - } else { - // At least one input is NaN. Use `+` to perform NaN propagation and quieting. - x + y } } -/// Returns the minimum of two `f128` values, propagating NaN. +/// Returns the minimum of two floating-point values, propagating NaN. /// /// This behaves like IEEE 754-2019 minimum. In particular: /// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. @@ -3317,8 +3198,10 @@ pub const fn minimumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] +#[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -pub const fn minimumf128(x: f128, y: f128) -> f128 { +#[rustc_do_not_const_check] +pub const fn minimum(x: T, y: T) -> T { if x < y { x } else if y < x { @@ -3331,179 +3214,7 @@ pub const fn minimumf128(x: f128, y: f128) -> f128 { } } -/// Returns the maximum of two `f16` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 maximumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f16::max`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximum_number_nsz_f16(x: f16, y: f16) -> f16 { - if x.is_nan() || y >= x { - y - } else { - // Either y < x or y is a NaN. - x - } -} - -/// Returns the maximum of two `f32` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 maximumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f32::max`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximum_number_nsz_f32(x: f32, y: f32) -> f32 { - if x.is_nan() || y >= x { - y - } else { - // Either y < x or y is a NaN. - x - } -} - -/// Returns the maximum of two `f64` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 maximumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f64::max`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximum_number_nsz_f64(x: f64, y: f64) -> f64 { - if x.is_nan() || y >= x { - y - } else { - // Either y < x or y is a NaN. - x - } -} - -/// Returns the maximum of two `f128` values, ignoring NaN. -/// -/// This behaves like IEEE 754-2019 maximumNumber, *except* that it does not order signed -/// zeros deterministically. In particular: -/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If -/// both arguments are NaN, returns NaN. If the inputs compare equal (such as for the case of `+0.0` -/// and `-0.0`), either input may be returned non-deterministically. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -/// -/// The stabilized version of this intrinsic is [`f128::max`]. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximum_number_nsz_f128(x: f128, y: f128) -> f128 { - if x.is_nan() || y >= x { - y - } else { - // Either y < x or y is a NaN. - x - } -} - -/// Returns the maximum of two `f16` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 maximum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximumf16(x: f16, y: f16) -> f16 { - if x > y { - x - } else if y > x { - y - } else if x == y { - if x.is_sign_positive() && y.is_sign_negative() { x } else { y } - } else { - x + y - } -} - -/// Returns the maximum of two `f32` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 maximum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximumf32(x: f32, y: f32) -> f32 { - if x > y { - x - } else if y > x { - y - } else if x == y { - if x.is_sign_positive() && y.is_sign_negative() { x } else { y } - } else { - x + y - } -} - -/// Returns the maximum of two `f64` values, propagating NaN. -/// -/// This behaves like IEEE 754-2019 maximum. In particular: -/// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. -/// For this operation, -0.0 is considered to be strictly less than +0.0. -/// -/// Note that, unlike most intrinsics, this is safe to call; -/// it does not require an `unsafe` block. -/// Therefore, implementations must not require the user to uphold -/// any safety invariants. -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn maximumf64(x: f64, y: f64) -> f64 { - if x > y { - x - } else if y > x { - y - } else if x == y { - if x.is_sign_positive() && y.is_sign_negative() { x } else { y } - } else { - x + y - } -} - -/// Returns the maximum of two `f128` values, propagating NaN. +/// Returns the maximum of two floating-point values, propagating NaN. /// /// This behaves like IEEE 754-2019 maximum. In particular: /// If one of the arguments is NaN, then a NaN is returned using the usual NaN propagation rules. @@ -3514,8 +3225,10 @@ pub const fn maximumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] +#[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -pub const fn maximumf128(x: f128, y: f128) -> f128 { +#[rustc_do_not_const_check] +pub const fn maximum(x: T, y: T) -> T { if x > y { x } else if y > x { @@ -3523,6 +3236,7 @@ pub const fn maximumf128(x: f128, y: f128) -> f128 { } else if x == y { if x.is_sign_positive() && y.is_sign_negative() { x } else { y } } else { + // At least one input is NaN. Use `+` to perform NaN propagation and quieting. x + y } } @@ -3540,47 +3254,18 @@ pub const fn fabs(x: T) -> T { T::from_bits(x.to_bits() & !T::SIGN_MASK) } -/// Copies the sign from `y` to `x` for `f16` values. -/// -/// The stabilized version of this intrinsic is -/// [`f16::copysign`](../../std/primitive.f16.html#method.copysign) -#[inline] -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn copysignf16(x: f16, y: f16) -> f16 { - f16::from_bits((x.to_bits() & !f16::SIGN_MASK) | (y.to_bits() & f16::SIGN_MASK)) -} - -/// Copies the sign from `y` to `x` for `f32` values. -/// -/// The stabilized version of this intrinsic is -/// [`f32::copysign`](../../std/primitive.f32.html#method.copysign) -#[inline] -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn copysignf32(x: f32, y: f32) -> f32 { - f32::from_bits((x.to_bits() & !f32::SIGN_MASK) | (y.to_bits() & f32::SIGN_MASK)) -} -/// Copies the sign from `y` to `x` for `f64` values. +/// Copies the sign from `y` to `x` for floating-point values. /// -/// The stabilized version of this intrinsic is -/// [`f64::copysign`](../../std/primitive.f64.html#method.copysign) -#[inline] -#[rustc_nounwind] -#[rustc_intrinsic] -pub const fn copysignf64(x: f64, y: f64) -> f64 { - f64::from_bits((x.to_bits() & !f64::SIGN_MASK) | (y.to_bits() & f64::SIGN_MASK)) -} - -/// Copies the sign from `y` to `x` for `f128` values. -/// -/// The stabilized version of this intrinsic is -/// [`f128::copysign`](../../std/primitive.f128.html#method.copysign) +/// The stabilized versions of this intrinsic are available on the float +/// primitives via the `copysign` method. For example, [`f32::copysign`]. #[inline] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -pub const fn copysignf128(x: f128, y: f128) -> f128 { - f128::from_bits((x.to_bits() & !f128::SIGN_MASK) | (y.to_bits() & f128::SIGN_MASK)) +#[rustc_do_not_const_check] +#[miri::intrinsic_fallback_is_spec] +pub const fn copysign(x: T, y: T) -> T { + T::from_bits((x.to_bits() & !T::SIGN_MASK) | (y.to_bits() & T::SIGN_MASK)) } /// Generates the LLVM body for the automatic differentiation of `f` using Enzyme, diff --git a/library/core/src/intrinsics/reflection.rs b/library/core/src/intrinsics/reflection.rs index 46830b05b14bc..0054cd32cdc03 100644 --- a/library/core/src/intrinsics/reflection.rs +++ b/library/core/src/intrinsics/reflection.rs @@ -108,6 +108,16 @@ pub fn type_id_variants(_id: crate::any::TypeId) -> usize; #[rustc_comptime] pub fn type_id_variant_name(_base: crate::any::TypeId, _variant_index: usize) -> &'static str; +/// Returns the reflection attributes given a the variant represented by the base `TypeId` and variant_idx. +/// +/// The more user-friendly version of this intrinsic is [`core::mem::type_info::VariantId::reflected_attrs`]. +#[rustc_intrinsic] +#[rustc_comptime] +pub fn type_id_variant_reflected_attrs( + _base: crate::any::TypeId, + _variant_index: usize, +) -> &'static [&'static str]; + /// Returns true when the variant represented by the base `TypeId` and variant_idx is non /// exhaustive. /// @@ -173,3 +183,10 @@ pub fn type_id_points_mutably(_id: crate::any::TypeId) -> bool; #[rustc_intrinsic] #[rustc_comptime] pub fn type_id_function_ptr(_type_id: crate::any::TypeId) -> Option; + +/// Returns the reflection attributes given a `TypeId` which represents a structure, enumeration, union or `FieldId`. +/// +/// The more user-friendly version of this intrinsic is [`core::any::TypeId::reflected_attrs`]. +#[rustc_intrinsic] +#[rustc_comptime] +pub fn type_id_reflected_attrs(_type_id: crate::any::TypeId) -> &'static [&'static str]; diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 496e649db2a08..c122e71115cbb 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -88,6 +88,7 @@ #![feature(asm_experimental_arch)] #![feature(byte_str_internals)] #![feature(cfg_target_has_reliable_f16_f128)] +#![feature(cfg_target_has_reliable_f16b)] #![feature(const_cmp)] #![feature(const_destruct)] #![feature(const_eval_select)] @@ -98,7 +99,7 @@ #![feature(io_const_error)] #![feature(offset_of_enum)] #![feature(panic_internals)] -#![feature(pattern_type_macro)] +#![feature(pattern_types)] #![feature(ub_checks)] // tidy-alphabetical-end // @@ -146,7 +147,6 @@ #![feature(must_not_suspend)] #![feature(negative_impls)] #![feature(no_core)] -#![feature(pattern_types)] #![feature(pin_macro_internals)] #![feature(prelude_import)] #![feature(register_tool)] @@ -319,7 +319,7 @@ pub mod option; pub mod os; pub mod panic; pub mod panicking; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] pub mod pat; pub mod pin; #[unstable(feature = "abort_immediate", issue = "154601")] @@ -356,7 +356,7 @@ mod bool; mod escape; mod tuple; mod unit; -#[unstable(feature = "view_type_macro", issue = "155938")] +#[unstable(feature = "view_types", issue = "155938")] pub mod view; #[stable(feature = "core_primitive", since = "1.43.0")] diff --git a/library/core/src/mem/type_info.rs b/library/core/src/mem/type_info.rs index 71a9627c24f9c..1ad39e3c2f3ac 100644 --- a/library/core/src/mem/type_info.rs +++ b/library/core/src/mem/type_info.rs @@ -656,6 +656,29 @@ impl TypeId { pub fn function_ptr(self) -> Option { intrinsics::reflection::type_id_function_ptr(self) } + + /// Given given a `TypeId`, which represents a structure, enum or union returns a list of attributes. + /// Only the attributes of tools marked as `reflect` are returned, all other attributes are excluded. + /// The attributes are in a string representation. + /// + /// ``` + /// #![feature(type_info)] + /// #![feature(register_tool)] + /// #![register_tool(foo(reflect))] + /// # use std::any::TypeId; + /// + /// #[foo::a(1, false)] + /// #[foo::bar=123] + /// struct A; + /// + /// assert_eq!(const { TypeId::of::().reflected_attrs() }, ["#[foo::a(1, false)]", "#[foo::bar = 123]"]); + /// ``` + #[unstable(feature = "type_info", issue = "146922")] + #[rustc_const_unstable(feature = "type_info", issue = "146922")] + #[rustc_comptime] + pub fn reflected_attrs(self) -> &'static [&'static str] { + intrinsics::reflection::type_id_reflected_attrs(self) + } } /// Variant representing type ID. Representing a variant of an enum. @@ -705,6 +728,32 @@ impl VariantId { pub fn non_exhaustive(self) -> bool { intrinsics::reflection::type_id_variant_non_exhaustive(self.base, self.variant) } + + /// Given given a `VariantId` returns a list of attributes. + /// Only the attributes of tools marked as `reflect` are returned, all other attributes are excluded. + /// The attributes are in a string representation. + /// + /// ``` + /// #![feature(type_info)] + /// #![feature(register_tool)] + /// #![register_tool(foo(reflect))] + /// # use std::any::TypeId; + /// + /// enum A { + /// #[foo::a(1, false)] + /// #[foo::bar=123] + /// VarA, + /// VarB, + /// } + /// + /// assert_eq!(const { TypeId::of::().variant(0).reflected_attrs() }, &["#[foo::a(1, false)]", "#[foo::bar = 123]"]); + /// ``` + #[unstable(feature = "type_info", issue = "146922")] + #[rustc_const_unstable(feature = "type_info", issue = "146922")] + #[rustc_comptime] + pub fn reflected_attrs(self) -> &'static [&'static str] { + intrinsics::reflection::type_id_variant_reflected_attrs(self.base, self.variant) + } } /// Field representing type ID. Representing a field of a struct, tuple or enum variant. @@ -788,4 +837,29 @@ impl FieldId { pub fn offset(self) -> usize { intrinsics::field_representing_type_offset(self.frt_type_id) } + + /// Given given a `FieldId` returns a list of attributes. + /// Only the attributes of tools marked as `reflect` are returned, all other attributes are excluded. + /// The attributes are in a string representation. + /// + /// ``` + /// #![feature(type_info)] + /// #![feature(register_tool)] + /// #![register_tool(foo(reflect))] + /// # use std::any::TypeId; + /// + /// struct A { + /// #[foo::a(1, false)] + /// #[foo::bar=123] + /// first: u8, + /// } + /// + /// assert_eq!(const { TypeId::of::().field(0, 0).reflected_attrs() }, &["#[foo::a(1, false)]", "#[foo::bar = 123]"]); + /// ``` + #[unstable(feature = "type_info", issue = "146922")] + #[rustc_const_unstable(feature = "type_info", issue = "146922")] + #[rustc_comptime] + pub fn reflected_attrs(self) -> &'static [&'static str] { + intrinsics::reflection::type_id_reflected_attrs(self.frt_type_id) + } } diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 841c9b239822e..4f7d144aefb74 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -626,7 +626,7 @@ impl f128 { #[rustc_const_unstable(feature = "f128", issue = "116909")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn max(self, other: f128) -> f128 { - intrinsics::maximum_number_nsz_f128(self, other) + intrinsics::maximum_number_nsz(self, other) } /// Returns the minimum of the two numbers, ignoring NaN. @@ -657,7 +657,7 @@ impl f128 { #[rustc_const_unstable(feature = "f128", issue = "116909")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn min(self, other: f128) -> f128 { - intrinsics::minimum_number_nsz_f128(self, other) + intrinsics::minimum_number_nsz(self, other) } /// Returns the maximum of the two numbers, propagating NaN. @@ -686,10 +686,11 @@ impl f128 { /// ``` #[inline] #[unstable(feature = "f128", issue = "116909")] + #[rustc_const_unstable(feature = "f128", issue = "116909")] // #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn maximum(self, other: f128) -> f128 { - intrinsics::maximumf128(self, other) + intrinsics::maximum(self, other) } /// Returns the minimum of the two numbers, propagating NaN. @@ -718,10 +719,11 @@ impl f128 { /// ``` #[inline] #[unstable(feature = "f128", issue = "116909")] + #[rustc_const_unstable(feature = "f128", issue = "116909")] // #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn minimum(self, other: f128) -> f128 { - intrinsics::minimumf128(self, other) + intrinsics::minimum(self, other) } /// Calculates the midpoint (average) between `self` and `rhs`. @@ -1449,7 +1451,7 @@ impl f128 { #[rustc_const_unstable(feature = "f128", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub const fn copysign(self, sign: f128) -> f128 { - intrinsics::copysignf128(self, sign) + intrinsics::copysign(self, sign) } /// Float addition that allows optimizations based on algebraic rules. diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index b67c46422b447..131894dbc516a 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -620,7 +620,7 @@ impl f16 { #[rustc_const_unstable(feature = "f16", issue = "116909")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn max(self, other: f16) -> f16 { - intrinsics::maximum_number_nsz_f16(self, other) + intrinsics::maximum_number_nsz(self, other) } /// Returns the minimum of the two numbers, ignoring NaN. @@ -651,7 +651,7 @@ impl f16 { #[rustc_const_unstable(feature = "f16", issue = "116909")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn min(self, other: f16) -> f16 { - intrinsics::minimum_number_nsz_f16(self, other) + intrinsics::minimum_number_nsz(self, other) } /// Returns the maximum of the two numbers, propagating NaN. @@ -680,10 +680,11 @@ impl f16 { /// ``` #[inline] #[unstable(feature = "f16", issue = "116909")] + #[rustc_const_unstable(feature = "f16", issue = "116909")] // #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn maximum(self, other: f16) -> f16 { - intrinsics::maximumf16(self, other) + intrinsics::maximum(self, other) } /// Returns the minimum of the two numbers, propagating NaN. @@ -712,10 +713,11 @@ impl f16 { /// ``` #[inline] #[unstable(feature = "f16", issue = "116909")] + #[rustc_const_unstable(feature = "f16", issue = "116909")] // #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[must_use = "this returns the result of the comparison, without modifying either input"] pub const fn minimum(self, other: f16) -> f16 { - intrinsics::minimumf16(self, other) + intrinsics::minimum(self, other) } /// Calculates the midpoint (average) between `self` and `rhs`. @@ -1432,7 +1434,7 @@ impl f16 { #[rustc_const_unstable(feature = "f16", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub const fn copysign(self, sign: f16) -> f16 { - intrinsics::copysignf16(self, sign) + intrinsics::copysign(self, sign) } /// Float addition that allows optimizations based on algebraic rules. diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 0a935f35f1778..0f3c1f6adc931 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -838,7 +838,7 @@ impl f32 { #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn max(self, other: f32) -> f32 { - intrinsics::maximum_number_nsz_f32(self, other) + intrinsics::maximum_number_nsz(self, other) } /// Returns the minimum of the two numbers, ignoring NaN. @@ -865,7 +865,7 @@ impl f32 { #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn min(self, other: f32) -> f32 { - intrinsics::minimum_number_nsz_f32(self, other) + intrinsics::minimum_number_nsz(self, other) } /// Returns the maximum of the two numbers, propagating NaN. @@ -890,9 +890,10 @@ impl f32 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] + #[rustc_const_unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] pub const fn maximum(self, other: f32) -> f32 { - intrinsics::maximumf32(self, other) + intrinsics::maximum(self, other) } /// Returns the minimum of the two numbers, propagating NaN. @@ -917,9 +918,10 @@ impl f32 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] + #[rustc_const_unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] pub const fn minimum(self, other: f32) -> f32 { - intrinsics::minimumf32(self, other) + intrinsics::minimum(self, other) } /// Calculates the midpoint (average) between `self` and `rhs`. @@ -1606,7 +1608,7 @@ impl f32 { #[stable(feature = "copysign", since = "1.35.0")] #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] pub const fn copysign(self, sign: f32) -> f32 { - intrinsics::copysignf32(self, sign) + intrinsics::copysign(self, sign) } /// Float addition that allows optimizations based on algebraic rules. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index fefb5cc7b337e..387d0002ade09 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -839,7 +839,7 @@ impl f64 { #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn max(self, other: f64) -> f64 { - intrinsics::maximum_number_nsz_f64(self, other) + intrinsics::maximum_number_nsz(self, other) } /// Returns the minimum of the two numbers, ignoring NaN. @@ -866,7 +866,7 @@ impl f64 { #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn min(self, other: f64) -> f64 { - intrinsics::minimum_number_nsz_f64(self, other) + intrinsics::minimum_number_nsz(self, other) } /// Returns the maximum of the two numbers, propagating NaN. @@ -891,9 +891,10 @@ impl f64 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] + #[rustc_const_unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] pub const fn maximum(self, other: f64) -> f64 { - intrinsics::maximumf64(self, other) + intrinsics::maximum(self, other) } /// Returns the minimum of the two numbers, propagating NaN. @@ -918,9 +919,10 @@ impl f64 { /// ``` #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] + #[rustc_const_unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] pub const fn minimum(self, other: f64) -> f64 { - intrinsics::minimumf64(self, other) + intrinsics::minimum(self, other) } /// Calculates the midpoint (average) between `self` and `rhs`. @@ -1585,7 +1587,7 @@ impl f64 { #[rustc_const_stable(feature = "const_float_methods", since = "1.85.0")] #[inline] pub const fn copysign(self, sign: f64) -> f64 { - intrinsics::copysignf64(self, sign) + intrinsics::copysign(self, sign) } /// Float addition that allows optimizations based on algebraic rules. diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index c53239ad48838..0d32e34e8dfb5 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -1736,17 +1736,13 @@ macro_rules! from_str_int_impl { /// # Examples /// /// ``` - /// #![feature(int_from_ascii)] - /// #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_ascii_bytes(b\"+10\"), Ok(10));")] /// ``` /// Trailing space returns error: /// ``` - /// # #![feature(int_from_ascii)] - /// # #[doc = concat!("assert!(", stringify!($int_ty), "::from_ascii_bytes(b\"1 \").is_err());")] /// ``` - #[unstable(feature = "int_from_ascii", issue = "134821")] + #[stable(feature = "int_from_ascii", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[inline] pub const fn from_ascii_bytes(src: T) -> Result<$int_ty, ParseIntError> @@ -1784,17 +1780,13 @@ macro_rules! from_str_int_impl { /// # Examples /// /// ``` - /// #![feature(int_from_ascii)] - /// #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_ascii_bytes_radix(b\"A\", 16), Ok(10));")] /// ``` /// Trailing space returns error: /// ``` - /// # #![feature(int_from_ascii)] - /// # #[doc = concat!("assert!(", stringify!($int_ty), "::from_ascii_bytes_radix(b\"1 \", 10).is_err());")] /// ``` - #[unstable(feature = "int_from_ascii", issue = "134821")] + #[stable(feature = "int_from_ascii", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[inline] pub const fn from_ascii_bytes_radix(src: T, radix: u32) -> Result<$int_ty, ParseIntError> diff --git a/library/core/src/num/niche_types.rs b/library/core/src/num/niche_types.rs index 4e0488450c6e5..3d4e9c26dc19a 100644 --- a/library/core/src/num/niche_types.rs +++ b/library/core/src/num/niche_types.rs @@ -5,9 +5,10 @@ )] use crate::cmp::Ordering; +use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::marker::StructuralPartialEq; -use crate::{fmt, pattern_type}; +use crate::pat::pattern_type; macro_rules! define_valid_range_type { ($( diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 59c30b7ed8222..6ac187bd9dda6 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -309,7 +309,7 @@ where } } -#[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "more_from_nonzero", since = "1.101.0")] impl<'a, T> From<&'a NonZero> for &'a T where T: ZeroablePrimitive, @@ -322,7 +322,7 @@ where // FIXME: see library/std/tests/slice-from-array-issue-113238.rs /* -#[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "more_from_nonzero", since = "1.101.0")] impl<'a, T> From<&'a [NonZero]> for &'a [T] where T: ZeroablePrimitive, @@ -347,7 +347,7 @@ where } */ -#[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "more_from_nonzero", since = "1.101.0")] impl From<[NonZero; N]> for [T; N] where T: ZeroablePrimitive, @@ -362,7 +362,7 @@ where macro_rules! impl_ref_try_from { ($($t:ty),* $(,)?) => { $( - #[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "more_from_nonzero", since = "1.101.0")] impl<'a> TryFrom<&'a $t> for &'a NonZero<$t> { type Error = TryFromIntError; @@ -391,7 +391,7 @@ impl_ref_try_from! { char, } -#[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "more_from_nonzero", since = "1.101.0")] impl<'a, T> TryFrom<&'a [T]> for &'a [NonZero] where T: ZeroablePrimitive, @@ -404,7 +404,7 @@ where } } -#[stable(feature = "more_from_nonzero", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "more_from_nonzero", since = "1.101.0")] impl TryFrom<[T; N]> for [NonZero; N] where T: ZeroablePrimitive, @@ -1624,8 +1624,6 @@ macro_rules! nonzero_integer { /// # Examples /// /// ``` - /// #![feature(int_from_ascii)] - /// /// # use std::num::NonZero; /// # /// # fn main() { test().unwrap(); } @@ -1638,13 +1636,11 @@ macro_rules! nonzero_integer { /// Trailing space returns error: /// /// ``` - /// #![feature(int_from_ascii)] - /// /// # use std::num::NonZero; /// # #[doc = concat!("assert!(NonZero::<", stringify!($Int), ">::from_ascii_bytes(b\"1 \").is_err());")] /// ``` - #[unstable(feature = "int_from_ascii", issue = "134821")] + #[stable(feature = "int_from_ascii", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[inline] pub const fn from_ascii_bytes(src: T) -> Result @@ -1683,8 +1679,6 @@ macro_rules! nonzero_integer { /// # Examples /// /// ``` - /// #![feature(int_from_ascii)] - /// /// # use std::num::NonZero; /// # /// # fn main() { test().unwrap(); } @@ -1697,13 +1691,11 @@ macro_rules! nonzero_integer { /// Trailing space returns error: /// /// ``` - /// #![feature(int_from_ascii)] - /// /// # use std::num::NonZero; /// # #[doc = concat!("assert!(NonZero::<", stringify!($Int), ">::from_ascii_bytes_radix(b\"1 \", 10).is_err());")] /// ``` - #[unstable(feature = "int_from_ascii", issue = "134821")] + #[stable(feature = "int_from_ascii", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[inline] pub const fn from_ascii_bytes_radix(src: T, radix: u32) -> Result diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 94cc44ddefa74..f08a6c020faa6 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -632,8 +632,8 @@ macro_rules! uint_impl { /// # } /// # #[cfg(not(overflow_checks))] panic!("fulfill should_panic"); /// ``` - #[rustc_const_stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] - #[stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "funnel_shifts", since = "1.101.0")] + #[stable(feature = "funnel_shifts", since = "1.101.0")] #[must_use = "this returns the result of the operation, without modifying the original"] #[inline(always)] #[rustc_inherit_overflow_checks] @@ -699,8 +699,8 @@ macro_rules! uint_impl { /// # } /// # #[cfg(not(overflow_checks))] panic!("fulfill should_panic"); /// ``` - #[rustc_const_stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] - #[stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "funnel_shifts", since = "1.101.0")] + #[stable(feature = "funnel_shifts", since = "1.101.0")] #[must_use = "this returns the result of the operation, without modifying the original"] #[inline(always)] #[rustc_inherit_overflow_checks] @@ -723,8 +723,8 @@ macro_rules! uint_impl { #[doc = concat!("`", stringify!($SelfT) , "::BITS`,")] /// i.e. when [`funnel_shl`](Self::funnel_shl) would panic. /// - #[rustc_const_stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] - #[stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "funnel_shifts", since = "1.101.0")] + #[stable(feature = "funnel_shifts", since = "1.101.0")] #[rustc_allow_const_fn_unstable(const_trait_impl)] #[must_use = "this returns the result of the operation, without modifying the original"] #[inline(always)] @@ -750,8 +750,8 @@ macro_rules! uint_impl { #[doc = concat!("`", stringify!($SelfT) , "::BITS`,")] /// i.e. when [`funnel_shr`](Self::funnel_shr) would panic. /// - #[rustc_const_stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] - #[stable(feature = "funnel_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "funnel_shifts", since = "1.101.0")] + #[stable(feature = "funnel_shifts", since = "1.101.0")] #[rustc_allow_const_fn_unstable(const_trait_impl)] #[must_use = "this returns the result of the operation, without modifying the original"] #[inline(always)] diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index 276b75c53cc38..d5dea51d3efda 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -325,30 +325,38 @@ unsafe extern "C" { pub type Code; } -/// A common trait implemented by all function pointers. +/// A common trait implemented by all function pointers and function definition types #[unstable(feature = "fn_static", issue = "148768")] -#[lang = "fn_ptr_trait"] -#[fundamental] +#[lang = "fn_addr_trait"] #[rustc_deny_explicit_impl] #[rustc_dyn_incompatible_trait] -pub trait FnPtr: Copy { +pub unsafe trait FnAddr: Copy { /// Returns the address of the function pointer. #[unstable(feature = "fn_static", issue = "148768")] + #[lang = "fn_addr_addr_fn"] fn addr(self) -> usize { self.as_ptr().addr().get() } /// Returns the function pointer as a [`NonNull`]. #[unstable(feature = "fn_static", issue = "148768")] - #[lang = "fn_ptr_as_ptr"] + #[lang = "fn_addr_as_ptr"] fn as_ptr(self) -> NonNull; +} +/// A common trait implemented by all function pointers. +#[unstable(feature = "fn_static", issue = "148768")] +#[lang = "fn_ptr_trait"] +#[fundamental] +#[rustc_deny_explicit_impl] +#[rustc_dyn_incompatible_trait] +pub unsafe trait FnPtr: FnAddr { /// Constructs a function pointer from a `NonNull` pointer. /// /// # Safety /// /// The function pointer must have been obtained - /// from an [`FnPtr::as_ptr`] call from a function + /// from an [`FnAddr::as_ptr`] call from a function /// pointer type that is ABI compatible. #[unstable(feature = "fn_static", issue = "148768")] #[lang = "fn_ptr_from_ptr"] diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs index 9b5915a901aaa..5443c1ed4147a 100644 --- a/library/core/src/ops/mod.rs +++ b/library/core/src/ops/mod.rs @@ -177,7 +177,7 @@ pub use self::deref::{Deref, DerefMut}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::drop::Drop; #[unstable(feature = "fn_static", issue = "148768")] -pub use self::function::{Code, FnPtr}; +pub use self::function::{Code, FnAddr, FnPtr}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::function::{Fn, FnMut, FnOnce}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/pat.rs b/library/core/src/pat.rs index 84a1c94370123..c319eecd61bb6 100644 --- a/library/core/src/pat.rs +++ b/library/core/src/pat.rs @@ -7,13 +7,11 @@ use crate::ops::{CoerceUnsized, DispatchFromDyn}; /// ```ignore (cannot test this from within core yet) /// type Positive = std::pat::pattern_type!(i32 is 1..); /// ``` -#[macro_export] -#[rustc_builtin_macro(pattern_type)] -#[unstable(feature = "pattern_type_macro", issue = "123646")] -macro_rules! pattern_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +#[unstable(feature = "pattern_types", issue = "123646")] +#[diagnostic::opaque] +pub macro pattern_type($( $arg:tt )*) { + k#pattern_type($( $arg )*) } // Flux defs are module-scoped; import `char_to_int` from `flux_info`. diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index f68d3e614c53f..d21fa351f5bce 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -104,9 +104,9 @@ pub use crate::const_format_args; #[doc(no_inline)] pub use crate::log_syntax; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] #[doc(no_inline)] -pub use crate::pattern_type; +pub use crate::pat::pattern_type; #[unstable( feature = "trace_macros", diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index e313b53ada906..fcad6777ab580 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -69,7 +69,7 @@ impl *const T { /// assert!(aligned.try_cast_aligned::().is_some()); /// assert!(unaligned.try_cast_aligned::().is_none()); /// ``` - #[stable(feature = "pointer_try_cast_aligned", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "pointer_try_cast_aligned", since = "1.101.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1542,8 +1542,8 @@ impl *const T { /// } /// ``` #[inline] - #[stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "ptr_cast_slice", since = "1.101.0")] + #[rustc_const_stable(feature = "ptr_cast_slice", since = "1.101.0")] pub const fn cast_slice(self, len: usize) -> *const [T] { slice_from_raw_parts(self, len) } diff --git a/library/core/src/ptr/docs/is_null.md b/library/core/src/ptr/docs/is_null.md index 7368ab9b57630..074ecde056221 100644 --- a/library/core/src/ptr/docs/is_null.md +++ b/library/core/src/ptr/docs/is_null.md @@ -1,10 +1,12 @@ Returns `true` if the pointer is null. -Note that unsized types have many possible null pointers, as only the -raw data pointer is considered, not their length, vtable, etc. +Note that, for [wide] pointers, only the address of the pointee is considered, +ignoring the metadata (such as a slice's length or a trait object's vtable). Therefore, two pointers that are null may still not compare equal to each other. +[wide]: core::ptr#thin-and-wide-pointers + # Panics during const evaluation If this method is used during const evaluation, and `self` is a pointer diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs index 1eeadf1217b5f..1a0e71dc349ca 100644 --- a/library/core/src/ptr/metadata.rs +++ b/library/core/src/ptr/metadata.rs @@ -101,7 +101,7 @@ pub const fn metadata(ptr: *const T) -> ::Metadat ptr_metadata(ptr) } -/// Forms a (possibly-wide) raw pointer from a data pointer and metadata. +/// Forms a (possibly-[wide]) raw pointer from a data pointer and metadata. /// /// This function is safe but the returned pointer is not necessarily safe to dereference. /// For slices, see the documentation of [`slice::from_raw_parts`] for safety requirements. @@ -111,6 +111,7 @@ pub const fn metadata(ptr: *const T) -> ::Metadat /// a thin pointer can always be obtained by casting `*const T` to `*const ()`. /// /// [`slice::from_raw_parts`]: crate::slice::from_raw_parts +/// [wide]: core::ptr#thin-and-wide-pointers #[unstable(feature = "ptr_metadata", issue = "81513")] #[inline] pub const fn from_raw_parts( diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 8ef3322e00d8e..9220ac5ab6cb3 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -166,6 +166,20 @@ //! //! [`null()`]: null //! +//! # Thin and wide pointers +//! +//! Some pointers can also carry additional metadata alongside the address of the pointee. These are called +//! **wide pointers** (or **fat pointers**). +//! Pointers that only store the address of the pointee are instead called **thin pointers**, every +//! pointer to a sized type is guaranteed to be thin. +//! +//! Currently, wide pointers are twice as big as the size of a thin pointer, +//! however, this could be changed in the future. +//! +//! Wide pointers are commonly used when working with [`DSTs`]. +//! +//! [`DSTs`]: https://doc.rust-lang.org/reference/dynamically-sized-types.html +//! //! # Provenance //! //! Pointers are not *simply* an "integer" or "address". For instance, it's uncontroversial @@ -2585,7 +2599,7 @@ pub fn eq(a: *const T, b: *const T) -> bool { } /// Compares the *addresses* of the two pointers for equality, -/// ignoring any metadata in fat pointers. +/// ignoring any metadata in [wide](core::ptr#thin-and-wide-pointers) pointers. /// /// If the arguments are thin pointers of the same type, /// then this is the same as [`eq`]. diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index d0b9f1438bb74..7660587334613 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -52,7 +52,7 @@ impl *mut T { /// assert!(aligned.try_cast_aligned::().is_some()); /// assert!(unaligned.try_cast_aligned::().is_none()); /// ``` - #[stable(feature = "pointer_try_cast_aligned", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "pointer_try_cast_aligned", since = "1.101.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1848,8 +1848,8 @@ impl *mut T { /// } /// ``` #[inline] - #[stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "ptr_cast_slice", since = "1.101.0")] + #[rustc_const_stable(feature = "ptr_cast_slice", since = "1.101.0")] pub const fn cast_slice(self, len: usize) -> *mut [T] { slice_from_raw_parts_mut(self, len) } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 9db2a2f89ae18..18423d066699e 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -84,7 +84,7 @@ use crate::{fmt, hash, intrinsics, mem, ptr}; // Flux cannot lower the pattern-type field; treat the struct as opaque. #[cfg_attr(flux, flux::opaque)] pub struct NonNull<#[rustc_assert_variance(covariant)] T: PointeeSized> { - pointer: crate::pattern_type!(*const T is !null), + pointer: crate::pat::pattern_type!(*const T is !null), } /// `NonNull` pointers are not `Send` because the data they reference may be aliased. @@ -578,7 +578,7 @@ impl NonNull { /// assert!(aligned.try_cast_aligned::().is_some()); /// assert!(unaligned.try_cast_aligned::().is_none()); /// ``` - #[stable(feature = "pointer_try_cast_aligned", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "pointer_try_cast_aligned", since = "1.101.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1601,8 +1601,8 @@ impl NonNull { /// but `let slice = NonNull::from(&x[..]);` would be a better way to write code like this.) #[inline] #[must_use] - #[stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "ptr_cast_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "ptr_cast_slice", since = "1.101.0")] + #[rustc_const_stable(feature = "ptr_cast_slice", since = "1.101.0")] pub const fn cast_slice(self, len: usize) -> NonNull<[T]> { NonNull::slice_from_raw_parts(self, len) } diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 255c93bd8109c..33695d16145ba 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1350,7 +1350,7 @@ impl Result { /// let s: String = only_good_news().into_ok(); /// println!("{s}"); /// ``` - #[stable(feature = "unwrap_infallible", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unwrap_infallible", since = "1.101.0")] #[inline] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] @@ -1384,7 +1384,7 @@ impl Result { /// let error: String = only_bad_news().into_err(); /// println!("{error}"); /// ``` - #[stable(feature = "unwrap_infallible", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unwrap_infallible", since = "1.101.0")] #[inline] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 75e6017f1ceb3..13f6a07ec8422 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2572,7 +2572,7 @@ impl [T] { /// ))); /// assert_eq!(s.split_once(|&x| x == 0), None); /// ``` - #[stable(feature = "slice_split_once", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "slice_split_once", since = "1.101.0")] #[inline] pub fn split_once(&self, pred: F) -> Option<(&[T], &[T])> where @@ -2600,7 +2600,7 @@ impl [T] { /// ))); /// assert_eq!(s.rsplit_once(|&x| x == 0), None); /// ``` - #[stable(feature = "slice_split_once", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "slice_split_once", since = "1.101.0")] #[inline] pub fn rsplit_once(&self, pred: F) -> Option<(&[T], &[T])> where diff --git a/library/core/src/slice/sort/stable/tiny.rs b/library/core/src/slice/sort/stable/tiny.rs index 071ab8e107fe3..1778cbe9c6d9c 100644 --- a/library/core/src/slice/sort/stable/tiny.rs +++ b/library/core/src/slice/sort/stable/tiny.rs @@ -1,4 +1,4 @@ -//! Binary-size optimized mergesort inspired by https://github.com/voultapher/tiny-sort-rs. +//! Binary-size optimized mergesort inspired by . use crate::mem::MaybeUninit; use crate::ptr; diff --git a/library/core/src/sync/mod.rs b/library/core/src/sync/mod.rs index bd85bffcf192a..e73bbec700410 100644 --- a/library/core/src/sync/mod.rs +++ b/library/core/src/sync/mod.rs @@ -4,5 +4,5 @@ pub mod atomic; mod sync_view; -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] pub use sync_view::SyncView; diff --git a/library/core/src/sync/sync_view.rs b/library/core/src/sync/sync_view.rs index 5c1e24125cf74..274891b4f125b 100644 --- a/library/core/src/sync/sync_view.rs +++ b/library/core/src/sync/sync_view.rs @@ -89,7 +89,7 @@ use core::task::{Context, Poll}; /// for any value. This is a parallel with the fact that /// `&` and `&mut` references together can be thought of as a _compile-time_ /// version of a read-write lock. -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[doc(alias = "SyncWrapper")] #[doc(alias = "SyncCell")] #[doc(alias = "Unique")] @@ -103,10 +103,10 @@ pub struct SyncView { } // See `SyncView`'s docs for justification. -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] unsafe impl Sync for SyncView {} -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_default", issue = "143894")] const impl Default for SyncView where @@ -118,7 +118,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl fmt::Debug for SyncView { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.debug_struct("SyncView").finish_non_exhaustive() @@ -127,8 +127,8 @@ impl fmt::Debug for SyncView { impl SyncView { /// Wrap a value in an `SyncView` - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[must_use] #[inline] pub const fn new(t: T) -> Self { @@ -136,8 +136,8 @@ impl SyncView { } /// Unwrap the value contained in the `SyncView` - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_allow_const_fn_unstable(const_precise_live_drops)] #[must_use] #[inline] @@ -153,8 +153,8 @@ impl SyncView { /// value, which means _unpinned_ `SyncView`s can produce _unpinned_ /// access to the underlying value, but _pinned_ `SyncView`s only /// produce _pinned_ access to the underlying value. - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[must_use] #[inline] pub const fn as_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> { @@ -166,8 +166,8 @@ impl SyncView { /// Build a _mutable_ reference to an `SyncView` from /// a _mutable_ reference to a `T`. This allows you to skip /// building an `SyncView` with [`SyncView::new`]. - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[must_use] #[inline] pub const fn from_mut(r: &'_ mut T) -> &'_ mut SyncView { @@ -178,8 +178,8 @@ impl SyncView { /// Build a _pinned mutable_ reference to an `SyncView` from /// a _pinned mutable_ reference to a `T`. This allows you to skip /// building an `SyncView` with [`SyncView::new`]. - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[must_use] #[inline] pub const fn from_pin_mut(r: Pin<&'_ mut T>) -> Pin<&'_ mut SyncView> { @@ -196,8 +196,8 @@ impl SyncView { /// value, which means _unpinned_ `SyncView`s can produce _unpinned_ /// access to the underlying value, but _pinned_ `SyncView`s only /// produce _pinned_ access to the underlying value. - #[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "exclusive_wrapper", since = "1.101.0")] + #[rustc_const_stable(feature = "exclusive_wrapper", since = "1.101.0")] #[must_use] #[inline] pub const fn as_pin_ref(self: Pin<&Self>) -> Pin<&T> { @@ -207,7 +207,7 @@ impl SyncView { } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl From for SyncView { #[inline] @@ -216,7 +216,7 @@ const impl From for SyncView { } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")] const impl FnOnce for SyncView where @@ -230,7 +230,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")] const impl FnMut for SyncView where @@ -242,7 +242,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_trait_impl", issue = "143874")] const impl Fn for SyncView where @@ -254,7 +254,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl AsyncFnOnce for SyncView where F: AsyncFnOnce, @@ -269,7 +269,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl AsyncFnMut for SyncView where F: AsyncFnMut, @@ -285,7 +285,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl AsyncFn for SyncView where F: Sync + AsyncFn, @@ -296,7 +296,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl Future for SyncView where T: Future + ?Sized, @@ -323,7 +323,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsRef for SyncView where @@ -336,7 +336,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsMut for SyncView where @@ -349,7 +349,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] const impl Clone for SyncView where @@ -366,10 +366,10 @@ where #[rustc_const_unstable(feature = "const_clone", issue = "142757")] const unsafe impl TrivialClone for SyncView where T: Sync + [const] TrivialClone {} -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl Copy for SyncView where T: Sync + Copy {} -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialEq> for SyncView where @@ -382,14 +382,14 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl StructuralPartialEq for SyncView where T: Sync + StructuralPartialEq + ?Sized {} -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Eq for SyncView where T: Sync + [const] Eq + ?Sized {} -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] impl Hash for SyncView where T: Sync + Hash + ?Sized, @@ -400,7 +400,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialOrd> for SyncView where @@ -413,7 +413,7 @@ where } } -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Ord for SyncView where diff --git a/library/core/src/view.rs b/library/core/src/view.rs index 68eca3f3598d2..c68382b2effc9 100644 --- a/library/core/src/view.rs +++ b/library/core/src/view.rs @@ -2,7 +2,7 @@ /// Creates a view type. /// ``` -/// #![feature(view_types, view_type_macro)] +/// #![feature(view_types)] // /// struct Foo { /// bar: usize, @@ -11,11 +11,9 @@ /// /// type FooBar = std::view::view_type!(Foo.{ bar }); /// ``` -#[macro_export] -#[rustc_builtin_macro(view_type)] -#[unstable(feature = "view_type_macro", issue = "155938")] -macro_rules! view_type { - ($($arg:tt)*) => { - /* compiler built-in */ - }; +#[allow_internal_unstable(internal_syntax)] +#[unstable(feature = "view_types", issue = "155938")] +#[diagnostic::opaque] +pub macro view_type($($arg:tt)*) { + k#view_type($($arg)*) } diff --git a/library/coretests/benches/ascii.rs b/library/coretests/benches/ascii.rs index 64bdc7fed118f..940ec0f75892d 100644 --- a/library/coretests/benches/ascii.rs +++ b/library/coretests/benches/ascii.rs @@ -50,7 +50,7 @@ macro_rules! benches { fn $name(bencher: &mut Bencher) { bencher.bytes = $input.len() as u64; bencher.iter(|| { - let mut vec = $input.as_bytes().to_vec(); + let mut vec = black_box($input).as_bytes().to_vec(); { let $arg = &mut vec[..]; black_box($body); diff --git a/library/coretests/benches/lib.rs b/library/coretests/benches/lib.rs index 4815c3e44e1a1..ad507f3fddac5 100644 --- a/library/coretests/benches/lib.rs +++ b/library/coretests/benches/lib.rs @@ -1,5 +1,5 @@ // wasm*-unknown-unknown does not support benches (no time). -#![cfg(all(target_family = "wasm", target_os = "unknown"))] +#![cfg(not(all(target_family = "wasm", target_os = "unknown")))] // This is marked as `test = true` and hence picked up by `./x miri`, but that would be too slow. #![cfg(not(miri))] #![feature(flt2dec)] diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index c9c07fe817cac..3e79c88a116e3 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -74,7 +74,6 @@ #![feature(get_set_bit)] #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] -#![feature(int_from_ascii)] #![feature(int_roundings)] #![feature(integer_casts)] #![feature(io_slice_as_bytes)] @@ -107,6 +106,7 @@ #![feature(portable_simd)] #![feature(ptr_metadata)] #![feature(raw_os_error_ty)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(signed_bigint_helpers)] #![feature(slice_from_ptr_range)] @@ -140,6 +140,7 @@ #![allow(internal_features)] #![deny(implicit_provenance_casts)] #![deny(unsafe_op_in_unsafe_fn)] +#![register_tool(reflective_tool(reflect))] // to allow testing of attribute reflection in `mem/type_info.rs` /// Version of `assert_matches` that ignores fancy runtime printing in const context and uses structural equality. macro_rules! assert_eq_const_safe { diff --git a/library/coretests/tests/mem/type_info.rs b/library/coretests/tests/mem/type_info.rs index 865b6a269afff..76e2adad18f1c 100644 --- a/library/coretests/tests/mem/type_info.rs +++ b/library/coretests/tests/mem/type_info.rs @@ -57,8 +57,12 @@ fn test_tuples() { #[test] fn test_structs() { const { + #[reflective_tool::TestStruct] struct TestStruct { + #[reflective_tool::first(1)] + #[reflective_tool::first(2)] first: u8, + #[reflective_tool::second] second: u16, reference: &'static u16, } @@ -66,14 +70,20 @@ fn test_structs() { let ty_id = TypeId::of::(); assert!(!ty_id.non_exhaustive()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &["#[reflective_tool::TestStruct]"]); assert!(ty_id.variants() == 1); assert!(ty_id.fields(0) == 3); assert!(ty_id.field(0, 0).type_id() == TypeId::of::()); assert!(ty_id.field(0, 0).offset() == offset_of!(TestStruct, first)); assert!(ty_id.field(0, 0).name() == "first"); + assert!( + ty_id.field(0, 0).reflected_attrs() + == &["#[reflective_tool::first(1)]", "#[reflective_tool::first(2)]"] + ); assert!(ty_id.field(0, 1).type_id() == TypeId::of::()); assert!(ty_id.field(0, 1).offset() == offset_of!(TestStruct, second)); assert!(ty_id.field(0, 1).name() == "second"); + assert!(ty_id.field(0, 1).reflected_attrs() == &["#[reflective_tool::second]"]); assert!(ty_id.field(0, 2).type_id() == TypeId::of::<&u16>()); assert!(ty_id.field(0, 2).offset() == offset_of!(TestStruct, reference)); assert!(ty_id.field(0, 2).name() == "reference"); @@ -102,6 +112,7 @@ fn test_structs() { } const { + #[reflective_tool::a] struct Generics<'a, T, const C: u64> { a: &'a T, } @@ -109,6 +120,7 @@ fn test_structs() { let ty_id = TypeId::of::>(); assert!(ty_id.fields(0) == 1); assert!(ty_id.generics().len() == 3); + assert!(ty_id.reflected_attrs() == &["#[reflective_tool::a]"]); let Generic::Lifetime(_) = ty_id.generics()[0] else { panic!() }; let Generic::Type(GenericType { ty: generic_ty, .. }) = ty_id.generics()[1] else { @@ -123,8 +135,11 @@ fn test_structs() { #[test] fn test_unions() { const { + #[reflective_tool::a] union TestUnion { + #[reflective_tool::first] first: i16, + #[reflective_tool::second] second: u16, } @@ -132,13 +147,17 @@ fn test_unions() { assert!(ty_id.size() == Some(size_of::())); assert!(ty_id.variants() == 1); assert!(ty_id.fields(0) == 2); + assert!(ty_id.reflected_attrs() == &["#[reflective_tool::a]"]); assert!(ty_id.field(0, 0).name() == "first"); assert!(ty_id.field(0, 0).type_id() == TypeId::of::()); + assert!(ty_id.field(0, 0).reflected_attrs() == &["#[reflective_tool::first]"]); assert!(ty_id.field(0, 1).name() == "second"); assert!(ty_id.field(0, 1).type_id() == TypeId::of::()); + assert!(ty_id.field(0, 1).reflected_attrs() == &["#[reflective_tool::second]"]); } const { + #[reflective_tool::a] union Generics<'a, T: Copy, const C: u64> { a: T, z: &'a (), @@ -146,6 +165,7 @@ fn test_unions() { let ty_id = TypeId::of::>(); assert!(ty_id.fields(0) == 2); + assert!(ty_id.reflected_attrs() == &["#[reflective_tool::a]"]); assert!(ty_id.field(0, 1).offset() == offset_of!(Generics<'static, i32, 1_u64>, a)); assert!(ty_id.field(0, 1).offset() == offset_of!(Generics<'static, i32, 1_u64>, z)); @@ -163,12 +183,17 @@ fn test_unions() { #[test] fn test_enums() { const { + #[reflective_tool::a] enum E { + #[reflective_tool::some] Some(u32), + #[reflective_tool::none] None, + #[reflective_tool::foomp] #[non_exhaustive] Foomp { a: (), + #[reflective_tool::b] b: &'static str, }, } @@ -176,23 +201,28 @@ fn test_enums() { let ty_id = TypeId::of::(); assert!(!ty_id.non_exhaustive()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &["#[reflective_tool::a]"]); assert!(ty_id.variants() == 3); assert!(ty_id.variant(0).name() == "Some"); + assert!(ty_id.variant(0).reflected_attrs() == &["#[reflective_tool::some]"]); assert!(!ty_id.variant(0).non_exhaustive()); assert!(ty_id.fields(0) == 1); assert!(ty_id.field(0, 0).type_id() == TypeId::of::()); assert!(ty_id.variant(1).name() == "None"); + assert!(ty_id.variant(1).reflected_attrs() == &["#[reflective_tool::none]"]); assert!(!ty_id.variant(1).non_exhaustive()); assert!(ty_id.fields(1) == 0); assert!(ty_id.variant(2).name() == "Foomp"); + assert!(ty_id.variant(2).reflected_attrs() == &["#[reflective_tool::foomp]"]); assert!(ty_id.variant(2).non_exhaustive()); assert!(ty_id.fields(2) == 2); assert!(ty_id.field(2, 0).type_id() == TypeId::of::<()>()); assert!(ty_id.field(2, 1).type_id() == TypeId::of::<&str>()); assert!(ty_id.field(2, 1).name() == "b"); + assert!(ty_id.field(2, 1).reflected_attrs() == &["#[reflective_tool::b]"]); assert!(ty_id.generics().is_empty()); } @@ -224,45 +254,53 @@ fn test_primitives() { let Type { kind: Bool, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Char, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Int, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.is_signed()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Int, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.is_signed()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Int, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(!ty_id.is_signed()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Int, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(!ty_id.is_signed()); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Float, .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.size() == Some(size_of::())); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); let Type { kind: Str(_ty), .. } = (const { Type::of::() }) else { panic!() }; let ty_id = TypeId::of::(); assert!(ty_id.size() == None); + assert!(ty_id.reflected_attrs() == &[""; 0]); assert!(ty_id.variants() == 1); } } diff --git a/library/hashbrown/.github/workflows/release-plz.yml b/library/hashbrown/.github/workflows/release-plz.yml new file mode 100644 index 0000000000000..7d93403f23861 --- /dev/null +++ b/library/hashbrown/.github/workflows/release-plz.yml @@ -0,0 +1,60 @@ +name: Release-plz + +on: + push: + branches: + - main + +permissions: {} + +jobs: + + # Release unpublished packages. + release-plz-release: + name: Release-plz release + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'rust-lang' }} + environment: publish + permissions: + contents: write # Required by `release-plz/action` to push tags and create releases. + id-token: write # Required by `release-plz/action` to obtain an OIDC token. + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Install Rust toolchain + run: rustup install stable && rustup default stable + - name: Run release-plz + uses: release-plz/action@f67a7e724bdad4a0f6875f186060a0ca2770d76c # v0.5.147 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Create a PR with the new versions and changelog, preparing the next release. + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'rust-lang' }} + permissions: + contents: write # Required by `release-plz/action` to push to the pull request branch. + pull-requests: write # Required by `release-plz/action` to create and update pull requests. + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + fetch-depth: 0 + persist-credentials: false + - name: Install Rust toolchain + run: rustup install stable && rustup default stable + - name: Run release-plz + uses: release-plz/action@f67a7e724bdad4a0f6875f186060a0ca2770d76c # v0.5.147 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/library/hashbrown/.github/workflows/rust.yml b/library/hashbrown/.github/workflows/rust.yml new file mode 100644 index 0000000000000..f5dcba7cc8e5c --- /dev/null +++ b/library/hashbrown/.github/workflows/rust.yml @@ -0,0 +1,128 @@ +name: Rust + +on: + pull_request: + merge_group: + +permissions: {} + +jobs: + miri: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + persist-credentials: false + - env: + TARGET: x86_64-unknown-linux-gnu + run: ci/miri.sh + + rustfmt_clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + persist-credentials: false + - name: Install taplo + run: curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo + - env: + TARGET: i586-unknown-linux-gnu + CHANNEL: nightly + run: ci/tools.sh + + basics: + runs-on: ubuntu-latest + needs: + - miri + - rustfmt_clippy + steps: + - run: exit 0 + + test: + runs-on: ${{ matrix.os }} + needs: basics + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + persist-credentials: false + - run: rustup install ${TOOLCHAIN} && rustup default ${TOOLCHAIN} + shell: bash + env: + TOOLCHAIN: ${{ matrix.channel }} + - env: + TARGET: ${{ matrix.target }} + CHANNEL: ${{ matrix.channel }} + run: ci/run.sh + strategy: + matrix: + os: [ubuntu-latest] + target: [ + x86_64-unknown-linux-gnu, + i686-unknown-linux-gnu, + i586-unknown-linux-gnu, + armv7-unknown-linux-gnueabihf, + aarch64-unknown-linux-gnu, + thumbv6m-none-eabi, + # Disabled due to issues with cross-rs + #x86_64-pc-windows-gnu, + ] + channel: [1.85.0, nightly] + include: + - os: macos-latest + target: aarch64-apple-darwin + channel: nightly + - os: windows-latest + target: x86_64-pc-windows-msvc + channel: nightly + - os: macos-latest + target: aarch64-apple-darwin + channel: 1.85.0 + - os: windows-latest + target: x86_64-pc-windows-msvc + channel: 1.85.0 + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + channel: beta + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + channel: stable + - os: ubuntu-latest + target: loongarch64-unknown-linux-gnu + channel: nightly + + msrv: + runs-on: ubuntu-latest + needs: basics + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + persist-credentials: false + - run: cargo install cargo-msrv + - run: cargo msrv --workspace verify + + dep_of_std: + runs-on: ubuntu-latest + needs: basics + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + persist-credentials: false + - run: rustup install nightly && rustup default nightly + - run: | + RUSTFLAGS="-Zforce-unstable-if-unmarked" cargo +nightly build --features rustc-dep-of-std + + + conclusion: + needs: [test, msrv, dep_of_std] + # !cancelled() executes the job regardless of whether the previous jobs passed, failed or get skipped. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + - name: Conclusion + run: | + # Print the dependent jobs to see them in the CI log + jq -C <<< "${JSON_NEEDS}" + # Check if all jobs that we depend on (in the needs array) were successful. + jq --exit-status 'all(.result == "success")' <<< "${JSON_NEEDS}" + env: + JSON_NEEDS: ${{ toJson(needs) }} diff --git a/library/hashbrown/.gitignore b/library/hashbrown/.gitignore new file mode 100644 index 0000000000000..693699042b1a8 --- /dev/null +++ b/library/hashbrown/.gitignore @@ -0,0 +1,3 @@ +/target +**/*.rs.bk +Cargo.lock diff --git a/library/hashbrown/CHANGELOG.md b/library/hashbrown/CHANGELOG.md new file mode 100644 index 0000000000000..30865f958a7d8 --- /dev/null +++ b/library/hashbrown/CHANGELOG.md @@ -0,0 +1,675 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.17.1](https://github.com/rust-lang/hashbrown/compare/v0.17.0...v0.17.1) - 2026-04-20 + +### Added + +- Added `HashMap::rustc_try_insert` (#722) + +## [0.17.0](https://github.com/rust-lang/hashbrown/compare/v0.16.1...v0.17.0) - 2026-04-06 + +### Added + +- Added `hash_table::OccupiedEntry::replace_entry_with` (#669) +- Added `hash_map::{OccupiedEntry::into_entry, VacantEntryRef::insert_entry_with_key}` (#670) +- Added `hash_table::UnsafeIter` (#667) +- Added `iter` methods to various `HashTable` iterators (#667) +- Added `HashMap::{replace_key,replace_key_unchecked,insert_with_key_unchecked}` (#681) +- Added `into_map` methods to all `HashMap` entry types (#686) +- Added `into_table` methods to all `HashTable` entry types (#686) +- Added `#[must_use]` to constructors (#697) +- `TryReserveError` now implements `Error` (#698) + +### Changed + +- Changed `EntryRef` to use `ToOwned` (#670) +- Bumped MSRV to 1.85 (2024 edition) (#676) + +### Fixed + +- `HashTable:clone_from` now forwards to `RawTable::clone_from` instead of using the default implementation (#668) +- Fixed potential UB in `RawTableInner::fallible_with_capacity` (#692) +- Fixed incorrect length if a hasher panics during rehash (#710) + +## [0.16.1](https://github.com/rust-lang/hashbrown/compare/v0.16.0...v0.16.1) - 2025-11-20 + +### Added + +- Added `HashTable` methods related to the raw bucket index (#657) +- Added `VacantEntryRef::insert_with_key` (#579) + +### Changed + +- Removed specialization for `Copy` types (#662) +- The `get_many_mut` family of methods have been renamed to `get_disjoint_mut` + to match the standard library. The old names are still present for now, but + deprecated. (#648) +- Recognize and use over-sized allocations when using custom allocators. (#523) +- Depend on `serde_core` instead of `serde`. (#649) +- Optimized `collect` on rayon parallel iterators. (#652) + +## [0.16.0](https://github.com/rust-lang/hashbrown/compare/v0.15.5...v0.16.0) - 2025-08-28 + +### Changed + +- Bump foldhash, the default hasher, to 0.2.0. +- Replaced `DefaultHashBuilder` with a newtype wrapper around `foldhash` instead + of re-exporting it directly. + +## [0.15.5](https://github.com/rust-lang/hashbrown/compare/v0.15.4...v0.15.5) - 2025-08-07 + +### Added + +- Added `Entry::or_default_entry` and `Entry::or_insert_entry`. + +### Changed + +- Re-implemented likely/unlikely with `#[cold]` + +## [0.15.4](https://github.com/rust-lang/hashbrown/compare/v0.15.3...v0.15.4) - 2025-06-05 + +### Changed + +- Removed optional dependency on compiler-builtins. This only affects building as part of `std`. + +## [0.15.3](https://github.com/rust-lang/hashbrown/compare/v0.15.2...v0.15.3) - 2025-04-29 + +### Added + +- SIMD implementation for LoongArch (#592, requires nightly) + +### Changed + +- Optimized insertion path by avoiding an unnecessary `match_empty` (#607) +- Increased minimum table size for small types (#615) +- Dropped FnMut trait bounds from `ExtractIf` data structures (#616) +- Relaxed constraint in `hash_map::EntryRef` insertion methods `K: From<&Q>` to &Q: `Into` (#611) +- Added allocator template argument for `rustc_iter` (#605) +- The `allocator-api2/nightly` feature is no longer enabled by `hashbrown/nightly` (#606) + +## [v0.15.2] - 2024-11-14 + +### Added + +- Marked `const fn` constructors as `rustc_const_stable_indirect` when built as + part of the standard library. (#586) + +## [v0.15.1] - 2024-11-03 + +This release removes the `borsh` feature introduced in 0.15.0 because it was +found to be incorrectly implemented. Users should use the `hashbrown` feature of +the `borsh` crate instead which provides the same trait implementations. + +## ~~[v0.15.0] - 2024-10-01~~ + +This release was _yanked_ due to a broken implementation of the `borsh` feature. + +This update contains breaking changes that remove the `raw` API with the hope of +centralising on the `HashTable` API in the future. You can follow the discussion +and progress in #545 to discuss features you think should be added to this API +that were previously only possible on the `raw` API. + +### Added + +- Added `borsh` feature with `BorshSerialize` and `BorshDeserialize` impls. (#525) +- Added `Assign` impls for `HashSet` operators. (#529) +- Added `Default` impls for iterator types. (#542) +- Added `HashTable::iter_hash{,_mut}` methods. (#549) +- Added `Hash{Table,Map,Set}::allocation_size` methods. (#553) +- Implemented `Debug` and `FusedIterator` for all `HashTable` iterators. (#561) +- Specialized `Iterator::fold` for all `HashTable` iterators. (#561) + +### Changed + +- Changed `hash_set::VacantEntry::insert` to return `OccupiedEntry`. (#495) +- Improved`hash_set::Difference::size_hint` lower-bound. (#530) +- Improved `HashSet::is_disjoint` performance. (#531) +- `equivalent` feature is now enabled by default. (#532) +- `HashSet` operators now return a set with the same allocator. (#529) +- Changed the default hasher to foldhash. (#563) +- `ahash` feature has been renamed to `default-hasher`. (#533) +- Entry API has been reworked and several methods have been renamed. (#535) +- `Hash{Map,Set}::insert_unique_unchecked` is now unsafe. (#556) +- The signature of `get_many_mut` and related methods was changed. (#562) + +### Fixed + +* Fixed typos, stray backticks in docs. (#558, #560) + +### Removed + +- Raw entry API is now under `raw-entry` feature, to be eventually removed. (#534, #555) +- Raw table API has been made private and the `raw` feature is removed; + in the future, all code should be using the `HashTable` API instead. (#531, #546) +- `rykv` feature was removed; this is now provided by the `rykv` crate instead. (#554) +- `HashSet::get_or_insert_owned` was removed in favor of `get_or_insert_with`. (#555) + +## [v0.14.5] - 2024-04-28 + +### Fixed + +- Fixed index calculation in panic guard of `clone_from_impl`. (#511) + +## ~~[v0.14.4] - 2024-03-19~~ + +This release was _yanked_ due to a breaking change. + +## [v0.14.3] - 2023-11-26 + +### Added + +- Specialized `fold` implementation of iterators. (#480) + +### Fixed + +- Avoid using unstable `ptr::invalid_mut` on nightly. (#481) + +## [v0.14.2] - 2023-10-19 + +### Added + +- `HashTable` type which provides a low-level but safe API with explicit hashing. (#466) + +### Fixed + +- Disabled the use of NEON instructions on big-endian ARM. (#475) +- Disabled the use of NEON instructions on Miri. (#476) + +## [v0.14.1] - 2023-09-28 + +### Added + +- Allow serializing `HashMap`s that use a custom allocator. (#449) + +### Changed + +- Use the `Equivalent` trait from the `equivalent` crate. (#442) +- Slightly improved performance of table resizing. (#451) +- Relaxed MSRV to 1.63.0. (#457) +- Removed `Clone` requirement from custom allocators. (#468) + +### Fixed + +- Fixed custom allocators being leaked in some situations. (#439, #465) + +## [v0.14.0] - 2023-06-01 + +### Added + +- Support for `allocator-api2` crate + for interfacing with custom allocators on stable. (#417) +- Optimized implementation for ARM using NEON instructions. (#430) +- Support for rkyv serialization. (#432) +- `Equivalent` trait to look up values without `Borrow`. (#345) +- `Hash{Map,Set}::raw_table_mut` is added which returns a mutable reference. (#404) +- Fast path for `clear` on empty tables. (#428) + +### Changed + +- Optimized insertion to only perform a single lookup. (#277) +- `DrainFilter` (`drain_filter`) has been renamed to `ExtractIf` and no longer drops remaining + elements when the iterator is dropped. #(374) +- Bumped MSRV to 1.64.0. (#431) +- `{Map,Set}::raw_table` now returns an immutable reference. (#404) +- `VacantEntry` and `OccupiedEntry` now use the default hasher if none is + specified in generics. (#389) +- `RawTable::data_start` now returns a `NonNull` to match `RawTable::data_end`. (#387) +- `RawIter::{reflect_insert, reflect_remove}` are now unsafe. (#429) +- `RawTable::find_potential` is renamed to `find_or_find_insert_slot` and returns an `InsertSlot`. (#429) +- `RawTable::remove` now also returns an `InsertSlot`. (#429) +- `InsertSlot` can be used to insert an element with `RawTable::insert_in_slot`. (#429) +- `RawIterHash` no longer has a lifetime tied to that of the `RawTable`. (#427) +- The trait bounds of `HashSet::raw_table` have been relaxed to not require `Eq + Hash`. (#423) +- `EntryRef::and_replace_entry_with` and `OccupiedEntryRef::replace_entry_with` + were changed to give a `&K` instead of a `&Q` to the closure. + +### Removed + +- Support for `bumpalo` as an allocator with custom wrapper. + Use `allocator-api2` feature in `bumpalo` to use it as an allocator + for `hashbrown` collections. (#417) + +## [v0.13.2] - 2023-01-12 + +### Fixed + +- Added `#[inline(always)]` to `find_inner`. (#375) +- Fixed `RawTable::allocation_info` for empty tables. (#376) + +## [v0.13.1] - 2022-11-10 + +### Added + +- Added `Equivalent` trait to customize key lookups. (#350) +- Added support for 16-bit targets. (#368) +- Added `RawTable::allocation_info` which provides information about the memory + usage of a table. (#371) + +### Changed + +- Bumped MSRV to 1.61.0. +- Upgraded to `ahash` 0.8. (#357) +- Make `with_hasher_in` const. (#355) +- The following methods have been removed from the `RawTable` API in favor of + safer alternatives: + - `RawTable::erase_no_drop` => Use `RawTable::erase` or `RawTable::remove` instead. + - `Bucket::read` => Use `RawTable::remove` instead. + - `Bucket::drop` => Use `RawTable::erase` instead. + - `Bucket::write` => Use `Bucket::as_mut` instead. + +### Fixed + +- Ensure that `HashMap` allocations don't exceed `isize::MAX`. (#362) +- Fixed issue with field retagging in scopeguard. (#359) + +## [v0.12.3] - 2022-07-17 + +### Fixed + +- Fixed double-drop in `RawTable::clone_from`. (#348) + +## [v0.12.2] - 2022-07-09 + +### Added + +- Added `Entry` API for `HashSet`. (#342) +- Added `Extend<&'a (K, V)> for HashMap`. (#340) +- Added length-based short-circuiting for hash table iteration. (#338) +- Added a function to access the `RawTable` of a `HashMap`. (#335) + +### Changed + +- Edited `do_alloc` to reduce LLVM IR generated. (#341) + +## [v0.12.1] - 2022-05-02 + +### Fixed + +- Fixed underflow in `RawIterRange::size_hint`. (#325) +- Fixed the implementation of `Debug` for `ValuesMut` and `IntoValues`. (#325) + +## [v0.12.0] - 2022-01-17 + +### Added + +- Added `From<[T; N]>` and `From<[(K, V); N]>` for `HashSet` and `HashMap` respectively. (#297) +- Added an `allocator()` getter to HashMap and HashSet. (#257) +- Added `insert_unique_unchecked` to `HashMap` and `HashSet`. (#293) +- Added `into_keys` and `into_values` to HashMap. (#295) +- Implement `From` on `HashSet` and `HashMap`. (#298) +- Added `entry_ref` API to `HashMap`. (#201) + +### Changed + +- Bumped minimum Rust version to 1.56.1 and edition to 2021. +- Use u64 for the GroupWord on WebAssembly. (#271) +- Optimized `find`. (#279) +- Made rehashing and resizing less generic to reduce compilation time. (#282) +- Inlined small functions. (#283) +- Use `BuildHasher::hash_one` when `feature = "nightly"` is enabled. (#292) +- Relaxed the bounds on `Debug` for `HashSet`. (#296) +- Rename `get_each_mut` to `get_many_mut` and align API with the stdlib. (#291) +- Don't hash the key when searching in an empty table. (#305) + +### Fixed + +- Guard against allocations exceeding isize::MAX. (#268) +- Made `RawTable::insert_no_grow` unsafe. (#254) +- Inline `static_empty`. (#280) +- Fixed trait bounds on Send/Sync impls. (#303) + +## [v0.11.2] - 2021-03-25 + +### Fixed + +- Added missing allocator type parameter to `HashMap`'s and `HashSet`'s `Clone` impls. (#252) + +## [v0.11.1] - 2021-03-20 + +### Fixed + +- Added missing `pub` modifier to `BumpWrapper`. (#251) + +## [v0.11.0] - 2021-03-14 + +### Added +- Added safe `try_insert_no_grow` method to `RawTable`. (#229) +- Added support for `bumpalo` as an allocator without the `nightly` feature. (#231) +- Implemented `Default` for `RawTable`. (#237) +- Added new safe methods `RawTable::get_each_mut`, `HashMap::get_each_mut`, and + `HashMap::get_each_key_value_mut`. (#239) +- Added `From>` for `HashSet`. (#235) +- Added `try_insert` method to `HashMap`. (#247) + +### Changed +- The minimum Rust version has been bumped to 1.49.0. (#230) +- Significantly improved compilation times by reducing the amount of generated IR. (#205) + +### Removed +- We no longer re-export the unstable allocator items from the standard library, nor the stable shims approximating the same. (#227) +- Removed hasher specialization support from `aHash`, which was resulting in inconsistent hashes being generated for a key. (#248) + +### Fixed +- Fixed union length comparison. (#228) + +## ~~[v0.10.0] - 2021-01-16~~ + +This release was _yanked_ due to inconsistent hashes being generated with the `nightly` feature. (#248) + +### Changed +- Parametrized `RawTable`, `HashSet` and `HashMap` over an allocator. (#133) +- Improved branch prediction hints on stable. (#209) +- Optimized hashing of primitive types with AHash using specialization. (#207) +- Only instantiate `RawTable`'s reserve functions once per key-value. (#204) + +## [v0.9.1] - 2020-09-28 + +### Added +- Added safe methods to `RawTable` (#202): + - `get`: `find` and `as_ref` + - `get_mut`: `find` and `as_mut` + - `insert_entry`: `insert` and `as_mut` + - `remove_entry`: `find` and `remove` + - `erase_entry`: `find` and `erase` + +### Changed +- Removed `from_key_hashed_nocheck`'s `Q: Hash`. (#200) +- Made `RawTable::drain` safe. (#201) + +## [v0.9.0] - 2020-09-03 + +### Fixed +- `drain_filter` now removes and yields items that do match the predicate, + rather than items that don't. This is a **breaking change** to match the + behavior of the `drain_filter` methods in `std`. (#187) + +### Added +- Added `replace_entry_with` to `OccupiedEntry`, and `and_replace_entry_with` to `Entry`. (#190) +- Implemented `FusedIterator` and `size_hint` for `DrainFilter`. (#188) + +### Changed +- The minimum Rust version has been bumped to 1.36 (due to `crossbeam` dependency). (#193) +- Updated `ahash` dependency to 0.4. (#198) +- `HashMap::with_hasher` and `HashSet::with_hasher` are now `const fn`. (#195) +- Removed `T: Hash + Eq` and `S: BuildHasher` bounds on `HashSet::new`, + `with_capacity`, `with_hasher`, and `with_capacity_and_hasher`. (#185) + +## [v0.8.2] - 2020-08-08 + +### Changed +- Avoid closures to improve compile times. (#183) +- Do not iterate to drop if empty. (#182) + +## [v0.8.1] - 2020-07-16 + +### Added +- Added `erase` and `remove` to `RawTable`. (#171) +- Added `try_with_capacity` to `RawTable`. (#174) +- Added methods that allow re-using a `RawIter` for `RawDrain`, + `RawIntoIter`, and `RawParIter`. (#175) +- Added `reflect_remove` and `reflect_insert` to `RawIter`. (#175) +- Added a `drain_filter` function to `HashSet`. (#179) + +### Changed +- Deprecated `RawTable::erase_no_drop` in favor of `erase` and `remove`. (#176) +- `insert_no_grow` is now exposed under the `"raw"` feature. (#180) + +## [v0.8.0] - 2020-06-18 + +### Fixed +- Marked `RawTable::par_iter` as `unsafe`. (#157) + +### Changed +- Reduced the size of `HashMap`. (#159) +- No longer create tables with a capacity of 1 element. (#162) +- Removed `K: Eq + Hash` bounds on `retain`. (#163) +- Pulled in `HashMap` changes from rust-lang/rust (#164): + - `extend_one` support on nightly. + - `CollectionAllocErr` renamed to `TryReserveError`. + - Added `HashSet::get_or_insert_owned`. + - `Default` for `HashSet` no longer requires `T: Eq + Hash` and `S: BuildHasher`. + +## [v0.7.2] - 2020-04-27 + +### Added +- Added `or_insert_with_key` to `Entry`. (#152) + +### Fixed +- Partially reverted `Clone` optimization which was unsound. (#154) + +### Changed +- Disabled use of `const-random` by default, which prevented reproducible builds. (#155) +- Optimized `repeat` function. (#150) +- Use `NonNull` for buckets, which improves codegen for iterators. (#148) + +## [v0.7.1] - 2020-03-16 + +### Added +- Added `HashMap::get_key_value_mut`. (#145) + +### Changed +- Optimized `Clone` implementation. (#146) + +## [v0.7.0] - 2020-01-31 + +### Added +- Added a `drain_filter` function to `HashMap`. (#135) + +### Changed +- Updated `ahash` dependency to 0.3. (#141) +- Optimized set union and intersection. (#130) +- `raw_entry` can now be used without requiring `S: BuildHasher`. (#123) +- `RawTable::bucket_index` can now be used under the `raw` feature. (#128) + +## [v0.6.3] - 2019-10-31 + +### Added +- Added an `ahash-compile-time-rng` feature (enabled by default) which allows disabling the + `compile-time-rng` feature in `ahash` to work around a Cargo bug. (#125) + +## [v0.6.2] - 2019-10-23 + +### Added +- Added an `inline-more` feature (enabled by default) which allows choosing a tradeoff between + runtime performance and compilation time. (#119) + +## [v0.6.1] - 2019-10-04 + +### Added +- Added `Entry::insert` and `RawEntryMut::insert`. (#118) + +### Changed +- `Group::static_empty` was changed from a `const` to a `static` (#116). + +## [v0.6.0] - 2019-08-13 + +### Fixed +- Fixed AHash accidentally depending on `std`. (#110) + +### Changed +- The minimum Rust version has been bumped to 1.32 (due to `rand` dependency). + +## ~~[v0.5.1] - 2019-08-04~~ + +This release was _yanked_ due to a breaking change for users of `no-default-features`. + +### Added +- The experimental and unsafe `RawTable` API is available under the "raw" feature. (#108) +- Added entry-like methods for `HashSet`. (#98) + +### Changed +- Changed the default hasher from FxHash to AHash. (#97) +- `hashbrown` is now fully `no_std` on recent Rust versions (1.36+). (#96) + +### Fixed +- We now avoid growing the table during insertions when it wasn't necessary. (#106) +- `RawOccupiedEntryMut` now properly implements `Send` and `Sync`. (#100) +- Relaxed `lazy_static` version. (#92) + +## [v0.5.0] - 2019-06-12 + +### Fixed +- Resize with a more conservative amount of space after deletions. (#86) + +### Changed +- Exposed the Layout of the failed allocation in CollectionAllocErr::AllocErr. (#89) + +## [v0.4.0] - 2019-05-30 + +### Fixed +- Fixed `Send` trait bounds on `IterMut` not matching the libstd one. (#82) + +## [v0.3.1] - 2019-05-30 + +### Fixed +- Fixed incorrect use of slice in unsafe code. (#80) + +## [v0.3.0] - 2019-04-23 + +### Changed +- Changed shrink_to to not panic if min_capacity < capacity. (#67) + +### Fixed +- Worked around emscripten bug emscripten-core/emscripten-fastcomp#258. (#66) + +## [v0.2.2] - 2019-04-16 + +### Fixed +- Inlined non-nightly lowest_set_bit_nonzero. (#64) +- Fixed build on latest nightly. (#65) + +## [v0.2.1] - 2019-04-14 + +### Changed +- Use for_each in map Extend and FromIterator. (#58) +- Improved worst-case performance of HashSet.is_subset. (#61) + +### Fixed +- Removed incorrect debug_assert. (#60) + +## [v0.2.0] - 2019-03-31 + +### Changed +- The code has been updated to Rust 2018 edition. This means that the minimum + Rust version has been bumped to 1.31 (2018 edition). + +### Added +- Added `insert_with_hasher` to the raw_entry API to allow `K: !(Hash + Eq)`. (#54) +- Added support for using hashbrown as the hash table implementation in libstd. (#46) + +### Fixed +- Fixed cargo build with minimal-versions. (#45) +- Fixed `#[may_dangle]` attributes to match the libstd `HashMap`. (#46) +- ZST keys and values are now handled properly. (#46) + +## [v0.1.8] - 2019-01-14 + +### Added +- Rayon parallel iterator support (#37) +- `raw_entry` support (#31) +- `#[may_dangle]` on nightly (#31) +- `try_reserve` support (#31) + +### Fixed +- Fixed variance on `IterMut`. (#31) + +## [v0.1.7] - 2018-12-05 + +### Fixed +- Fixed non-SSE version of convert_special_to_empty_and_full_to_deleted. (#32) +- Fixed overflow in rehash_in_place. (#33) + +## [v0.1.6] - 2018-11-17 + +### Fixed +- Fixed compile error on nightly. (#29) + +## [v0.1.5] - 2018-11-08 + +### Fixed +- Fixed subtraction overflow in generic::Group::match_byte. (#28) + +## [v0.1.4] - 2018-11-04 + +### Fixed +- Fixed a bug in the `erase_no_drop` implementation. (#26) + +## [v0.1.3] - 2018-11-01 + +### Added +- Serde support. (#14) + +### Fixed +- Make the compiler inline functions more aggressively. (#20) + +## [v0.1.2] - 2018-10-31 + +### Fixed +- `clear` segfaults when called on an empty table. (#13) + +## [v0.1.1] - 2018-10-30 + +### Fixed +- `erase_no_drop` optimization not triggering in the SSE2 implementation. (#3) +- Missing `Send` and `Sync` for hash map and iterator types. (#7) +- Bug when inserting into a table smaller than the group width. (#5) + +## v0.1.0 - 2018-10-29 + +- Initial release + +[Unreleased]: https://github.com/rust-lang/hashbrown/compare/v0.15.2...HEAD +[v0.15.2]: https://github.com/rust-lang/hashbrown/compare/v0.15.1...v0.15.2 +[v0.15.1]: https://github.com/rust-lang/hashbrown/compare/v0.15.0...v0.15.1 +[v0.15.0]: https://github.com/rust-lang/hashbrown/compare/v0.14.5...v0.15.0 +[v0.14.5]: https://github.com/rust-lang/hashbrown/compare/v0.14.4...v0.14.5 +[v0.14.4]: https://github.com/rust-lang/hashbrown/compare/v0.14.3...v0.14.4 +[v0.14.3]: https://github.com/rust-lang/hashbrown/compare/v0.14.2...v0.14.3 +[v0.14.2]: https://github.com/rust-lang/hashbrown/compare/v0.14.1...v0.14.2 +[v0.14.1]: https://github.com/rust-lang/hashbrown/compare/v0.14.0...v0.14.1 +[v0.14.0]: https://github.com/rust-lang/hashbrown/compare/v0.13.2...v0.14.0 +[v0.13.2]: https://github.com/rust-lang/hashbrown/compare/v0.13.1...v0.13.2 +[v0.13.1]: https://github.com/rust-lang/hashbrown/compare/v0.12.3...v0.13.1 +[v0.12.3]: https://github.com/rust-lang/hashbrown/compare/v0.12.2...v0.12.3 +[v0.12.2]: https://github.com/rust-lang/hashbrown/compare/v0.12.1...v0.12.2 +[v0.12.1]: https://github.com/rust-lang/hashbrown/compare/v0.12.0...v0.12.1 +[v0.12.0]: https://github.com/rust-lang/hashbrown/compare/v0.11.2...v0.12.0 +[v0.11.2]: https://github.com/rust-lang/hashbrown/compare/v0.11.1...v0.11.2 +[v0.11.1]: https://github.com/rust-lang/hashbrown/compare/v0.11.0...v0.11.1 +[v0.11.0]: https://github.com/rust-lang/hashbrown/compare/v0.10.0...v0.11.0 +[v0.10.0]: https://github.com/rust-lang/hashbrown/compare/v0.9.1...v0.10.0 +[v0.9.1]: https://github.com/rust-lang/hashbrown/compare/v0.9.0...v0.9.1 +[v0.9.0]: https://github.com/rust-lang/hashbrown/compare/v0.8.2...v0.9.0 +[v0.8.2]: https://github.com/rust-lang/hashbrown/compare/v0.8.1...v0.8.2 +[v0.8.1]: https://github.com/rust-lang/hashbrown/compare/v0.8.0...v0.8.1 +[v0.8.0]: https://github.com/rust-lang/hashbrown/compare/v0.7.2...v0.8.0 +[v0.7.2]: https://github.com/rust-lang/hashbrown/compare/v0.7.1...v0.7.2 +[v0.7.1]: https://github.com/rust-lang/hashbrown/compare/v0.7.0...v0.7.1 +[v0.7.0]: https://github.com/rust-lang/hashbrown/compare/v0.6.3...v0.7.0 +[v0.6.3]: https://github.com/rust-lang/hashbrown/compare/v0.6.2...v0.6.3 +[v0.6.2]: https://github.com/rust-lang/hashbrown/compare/v0.6.1...v0.6.2 +[v0.6.1]: https://github.com/rust-lang/hashbrown/compare/v0.6.0...v0.6.1 +[v0.6.0]: https://github.com/rust-lang/hashbrown/compare/v0.5.1...v0.6.0 +[v0.5.1]: https://github.com/rust-lang/hashbrown/compare/v0.5.0...v0.5.1 +[v0.5.0]: https://github.com/rust-lang/hashbrown/compare/v0.4.0...v0.5.0 +[v0.4.0]: https://github.com/rust-lang/hashbrown/compare/v0.3.1...v0.4.0 +[v0.3.1]: https://github.com/rust-lang/hashbrown/compare/v0.3.0...v0.3.1 +[v0.3.0]: https://github.com/rust-lang/hashbrown/compare/v0.2.2...v0.3.0 +[v0.2.2]: https://github.com/rust-lang/hashbrown/compare/v0.2.1...v0.2.2 +[v0.2.1]: https://github.com/rust-lang/hashbrown/compare/v0.2.0...v0.2.1 +[v0.2.0]: https://github.com/rust-lang/hashbrown/compare/v0.1.8...v0.2.0 +[v0.1.8]: https://github.com/rust-lang/hashbrown/compare/v0.1.7...v0.1.8 +[v0.1.7]: https://github.com/rust-lang/hashbrown/compare/v0.1.6...v0.1.7 +[v0.1.6]: https://github.com/rust-lang/hashbrown/compare/v0.1.5...v0.1.6 +[v0.1.5]: https://github.com/rust-lang/hashbrown/compare/v0.1.4...v0.1.5 +[v0.1.4]: https://github.com/rust-lang/hashbrown/compare/v0.1.3...v0.1.4 +[v0.1.3]: https://github.com/rust-lang/hashbrown/compare/v0.1.2...v0.1.3 +[v0.1.2]: https://github.com/rust-lang/hashbrown/compare/v0.1.1...v0.1.2 +[v0.1.1]: https://github.com/rust-lang/hashbrown/compare/v0.1.0...v0.1.1 diff --git a/library/hashbrown/Cargo.toml b/library/hashbrown/Cargo.toml new file mode 100644 index 0000000000000..27102c228e4ab --- /dev/null +++ b/library/hashbrown/Cargo.toml @@ -0,0 +1,129 @@ +[package] +name = "hashbrown" +version = "0.17.1" +description = "A Rust port of Google's SwissTable hash map" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/hashbrown" +readme = "README.md" +keywords = ["hash", "no_std", "hashmap", "swisstable"] +categories = ["data-structures", "no-std"] +exclude = [".github", "/ci/*"] +edition = "2024" + +# Make sure to sync this MSRV in the README badge and CI workflows +rust-version = "1.85.0" +autobenches = false + +[lints.rust] +missing_docs = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" + +# rust_2018_idioms +bare_trait_objects = "warn" +elided_lifetimes_in_paths = "warn" +ellipsis_inclusive_range_patterns = "warn" +explicit_outlives_requirements = "warn" +unused_extern_crates = "warn" + +[lints.clippy] +doc_markdown = "allow" +manual_map = "allow" +missing_errors_doc = "allow" +missing_safety_doc = "allow" +module_name_repetitions = "allow" +must_use_candidate = "allow" +option_if_let_else = "allow" + +borrow_as_ptr = "warn" +elidable_lifetime_names = "warn" +manual_assert = "warn" +manual_assert_eq = "warn" +manual_let_else = "warn" +needless_continue = "warn" +ptr_as_ptr = "warn" +ptr_cast_constness = "warn" +redundant_else = "warn" +ref_as_ptr = "warn" +semicolon_if_nothing_returned = "warn" +str_to_string = "warn" + +[dependencies] +# For the default hasher +foldhash = { version = "0.2.0", default-features = false, optional = true } + +# For external trait impls +rayon = { version = "1.9.0", optional = true } +serde_core = { version = "1.0.221", default-features = false, optional = true } + +# When built as part of libstd +core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" } +alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" } + +# Support for allocators that use allocator-api2 +allocator-api2 = { version = "0.2.9", optional = true, default-features = false, features = [ + "alloc", +] } + +# Equivalent trait which can be shared with other hash table implementations. +# NB: this is a public dependency because `Equivalent` is re-exported! +equivalent = { version = "1.0", optional = true, default-features = false } + +# serde v1.0.220 is the first version that released with `serde_core`. +# This is required to avoid conflict with other `serde` users which may require an older version. +[target.'cfg(any())'.dependencies] +serde = { version = "1.0.220", default-features = false, optional = true } + +[dev-dependencies] +rand = { version = "0.9.0", features = ["small_rng"] } +rayon = "1.2" +fnv = "1.0.7" +serde_test = "1.0" +bumpalo = { version = "3.13.0", features = ["allocator-api2"] } +criterion = { version = "0.7", features = ["html_reports"] } + +[target.'cfg(unix)'.dev-dependencies] +libc = "0.2.155" + +[features] +default = [ + "default-hasher", + "inline-more", + "allocator-api2", + "equivalent", + "raw-entry", +] + +# Enables use of nightly features. This is only guaranteed to work on the latest +# version of nightly Rust. +nightly = ["foldhash?/nightly", "bumpalo/allocator_api"] + +# Enables the RustcEntry API used to provide the standard library's Entry API. +rustc-internal-api = [] + +# Internal feature used when building as part of the standard library. +rustc-dep-of-std = ["nightly", "core", "alloc", "rustc-internal-api"] + +# Enables serde support. +serde = ["dep:serde_core", "dep:serde"] + +# Enables the deprecated RawEntry API. +raw-entry = [] + +# Provides a default hasher. Currently this is foldhash but this is subject to +# change in the future. Note that the default hasher does *not* provide HashDoS +# resistance, unlike the one in the standard library. +default-hasher = ["dep:foldhash"] + +# Enables usage of `#[inline]` on far more functions than by default in this +# crate. This may lead to a performance increase but often comes at a compile +# time cost. +inline-more = [] + +[[bench]] +name = "bench" +harness = false + +[package.metadata.docs.rs] +features = ["nightly", "rayon", "serde", "raw-entry"] +rustdoc-args = ["--generate-link-to-definition"] diff --git a/library/hashbrown/Cross.toml b/library/hashbrown/Cross.toml new file mode 100644 index 0000000000000..de63570324676 --- /dev/null +++ b/library/hashbrown/Cross.toml @@ -0,0 +1,3 @@ +# FIXME: Drop this config when cross is updated to support loongarch64-linux-gnu +[target.loongarch64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/loongarch64-unknown-linux-gnu:edge" diff --git a/library/hashbrown/LICENSE-APACHE b/library/hashbrown/LICENSE-APACHE new file mode 100644 index 0000000000000..16fe87b06e802 --- /dev/null +++ b/library/hashbrown/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/library/hashbrown/LICENSE-MIT b/library/hashbrown/LICENSE-MIT new file mode 100644 index 0000000000000..5afc2a7b0acab --- /dev/null +++ b/library/hashbrown/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 Amanieu d'Antras + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/library/hashbrown/README.md b/library/hashbrown/README.md new file mode 100644 index 0000000000000..ce19947e4b9cf --- /dev/null +++ b/library/hashbrown/README.md @@ -0,0 +1,91 @@ +# hashbrown + +[![Build Status](https://github.com/rust-lang/hashbrown/actions/workflows/rust.yml/badge.svg)](https://github.com/rust-lang/hashbrown/actions) +[![crates.io](https://img.shields.io/crates/v/hashbrown.svg)](https://crates.io/crates/hashbrown) +[![Documentation](https://docs.rs/hashbrown/badge.svg)](https://docs.rs/hashbrown) +[![Rust](https://img.shields.io/badge/rust-1.85.0%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/hashbrown) + +This crate is a Rust port of Google's high-performance [SwissTable] hash map, +adapted to make it a drop-in replacement for Rust's standard `HashMap` and +`HashSet` types. + +The original C++ version of SwissTable can be found [here], and this +[CppCon talk] gives an overview of how the algorithm works. + +Since Rust 1.36, the Rust standard library has adopted this implementation for +`HashMap`, using its own default hasher (see +[`std::hash::DefaultHasher`](https://doc.rust-lang.org/std/hash/struct.DefaultHasher.html)). +However you may still want to use this crate instead since it works in +environments without `std`, such as embedded systems and kernels. + +[SwissTable]: https://abseil.io/blog/20180927-swisstables +[here]: https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/raw_hash_set.h +[CppCon talk]: https://www.youtube.com/watch?v=ncHmEUmJZf4 + +## [Change log](CHANGELOG.md) + +## Features + +- Drop-in replacement for the standard library `HashMap` and `HashSet` types. +- Uses [foldhash](https://github.com/orlp/foldhash) as the default hasher, which + is much faster than SipHash. However, foldhash does *not provide the same + level of HashDoS resistance* as SipHash, so if that is important to you, you + might want to consider using a different hasher. +- Around 2x faster than the previous standard library `HashMap`. +- Lower memory usage: only 1 byte of overhead per entry instead of 8. +- Compatible with `#[no_std]` (but requires a global allocator with the `alloc` + crate). +- Empty hash maps do not allocate any memory. +- SIMD lookups to scan multiple hash entries in parallel. + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +hashbrown = "0.17" +``` + +Then: + +```rust +use hashbrown::HashMap; + +let mut map = HashMap::new(); +map.insert(1, "one"); +``` + +## Flags + +This crate has the following Cargo features: + +- `nightly`: Enables nightly-only features including: `#[may_dangle]`. +- `serde`: Enables serde serialization support. +- `rayon`: Enables rayon parallel iterator support. +- `equivalent`: Allows comparisons to be customized with the `Equivalent` trait. + (enabled by default) +- `raw-entry`: Enables access to the deprecated `RawEntry` API. +- `inline-more`: Adds inline hints to most functions, improving run-time + performance at the cost of compilation time. (enabled by default) +- `default-hasher`: Compiles with foldhash as default hasher. (enabled by + default) +- `allocator-api2`: Enables support for allocators that support + `allocator-api2`. (enabled by default) + +## License + +Licensed under either of: + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + https://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + https://opensource.org/license/mit) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/library/hashbrown/benches/bench.rs b/library/hashbrown/benches/bench.rs new file mode 100644 index 0000000000000..7103f68bf9a49 --- /dev/null +++ b/library/hashbrown/benches/bench.rs @@ -0,0 +1,17 @@ +#![expect(missing_docs)] // criterion_group! generates a public bench entrypoint + +use criterion::{criterion_group, criterion_main}; + +mod general_ops; +mod insert_unique_unchecked; +mod set_ops; +mod with_capacity; + +criterion_group!( + benches, + general_ops::register_benches, + insert_unique_unchecked::register_benches, + set_ops::register_benches, + with_capacity::register_benches +); +criterion_main!(benches); diff --git a/library/hashbrown/benches/general_ops.rs b/library/hashbrown/benches/general_ops.rs new file mode 100644 index 0000000000000..bbf680e4f2c70 --- /dev/null +++ b/library/hashbrown/benches/general_ops.rs @@ -0,0 +1,425 @@ +//! This benchmark suite contains some benchmarks along a set of dimensions: +//! * Hasher: std default (SipHash) and crate default (foldhash). +//! * Int key distribution: low bit heavy, top bit heavy, and random. +//! * Task: basic functionality: insert, insert_erase, lookup, lookup_fail, iter +use criterion::Criterion; +use hashbrown::DefaultHashBuilder; +use hashbrown::{HashMap, HashSet}; +use std::{ + hash::RandomState, + hint::black_box, + sync::atomic::{self, AtomicUsize}, +}; + +const SIZE: usize = 1000; +const OP_COUNT: usize = 500; + +// The default hashmap when using this crate directly. +type FoldHashMap = HashMap; +// This uses the hashmap from this crate with the default hasher of the stdlib. +type StdHashMap = HashMap; + +// A random key iterator. +#[derive(Clone, Copy)] +struct RandomKeys { + state: usize, +} + +impl RandomKeys { + fn new() -> Self { + Self { state: 0 } + } +} + +impl Iterator for RandomKeys { + type Item = usize; + + fn next(&mut self) -> Option { + // Add 1 then multiply by some 32 bit prime. + self.state = self.state.wrapping_add(1).wrapping_mul(3_787_392_781); + Some(self.state) + } +} + +// Just an arbitrary side effect to make the maps not shortcircuit to the non-dropping path +// when dropping maps/entries (most real world usages likely have drop in the key or value) +static SIDE_EFFECT: AtomicUsize = AtomicUsize::new(0); + +#[derive(Clone)] +struct DropType(usize); + +impl Drop for DropType { + fn drop(&mut self) { + SIDE_EFFECT.fetch_add(self.0, atomic::Ordering::SeqCst); + } +} + +fn observe_side_effect() { + black_box(SIDE_EFFECT.load(atomic::Ordering::SeqCst)); +} + +macro_rules! bench_suite { + ($c:ident, $bench_macro:ident, $bench_foldhash_serial:ident, $bench_std_serial:ident, + $bench_foldhash_highbits:ident, $bench_std_highbits:ident, + $bench_foldhash_random:ident, $bench_std_random:ident) => { + $bench_macro!($c, $bench_foldhash_serial, FoldHashMap, 0..); + $bench_macro!($c, $bench_std_serial, StdHashMap, 0..); + $bench_macro!( + $c, + $bench_foldhash_highbits, + FoldHashMap, + (0..).map(usize::swap_bytes) + ); + $bench_macro!( + $c, + $bench_std_highbits, + StdHashMap, + (0..).map(usize::swap_bytes) + ); + $bench_macro!($c, $bench_foldhash_random, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $bench_std_random, StdHashMap, RandomKeys::new()); + }; +} + +macro_rules! bench_suite_2 { + ($c:ident, $bench_macro:ident, + $name0:ident, $size0:literal, $name1:ident, $size1:literal, + $name2:ident, $size2:literal, $name3:ident, $size3:literal, + $name4:ident, $size4:literal, $name5:ident, $size5:literal, + $name6:ident, $size6:literal, $name7:ident, $size7:literal) => { + $bench_macro!($c, $name0, $size0, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name1, $size1, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name2, $size2, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name3, $size3, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name4, $size4, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name5, $size5, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name6, $size6, FoldHashMap, RandomKeys::new()); + $bench_macro!($c, $name7, $size7, FoldHashMap, RandomKeys::new()); + }; +} + +macro_rules! bench_insert { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::with_capacity_and_hasher(SIZE, Default::default()); + b.iter(|| { + m.clear(); + for i in ($keydist).take(SIZE) { + m.insert(i, (DropType(i), [i; 20])); + } + black_box(&mut m); + }); + }); + observe_side_effect(); + }}; +} + +macro_rules! bench_grow_insert { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + b.iter(|| { + let mut m = $maptype::default(); + for i in ($keydist).take(SIZE) { + m.insert(i, DropType(i)); + } + black_box(&mut m); + }); + }); + }}; +} + +macro_rules! bench_insert_erase { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut base = $maptype::default(); + for i in ($keydist).take(SIZE) { + base.insert(i, DropType(i)); + } + let skip = $keydist.skip(SIZE); + b.iter(|| { + let mut m = base.clone(); + let mut add_iter = skip.clone(); + let mut remove_iter = $keydist; + // While keeping the size constant, + // replace the first keydist with the second. + for (add, remove) in (&mut add_iter).zip(&mut remove_iter).take(SIZE) { + m.insert(add, DropType(add)); + black_box(m.remove(&remove)); + } + black_box(m); + }); + }); + observe_side_effect(); + }}; +} + +macro_rules! bench_lookup { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::default(); + for i in ($keydist).take(SIZE) { + m.insert(i, DropType(i)); + } + + b.iter(|| { + for i in ($keydist).take(SIZE) { + black_box(m.get(&i)); + } + }); + }); + observe_side_effect(); + }}; +} + +macro_rules! bench_lookup_fail { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::default(); + let mut iter = $keydist; + for i in (&mut iter).take(SIZE) { + m.insert(i, DropType(i)); + } + + b.iter(|| { + for i in (&mut iter).take(SIZE) { + black_box(m.get(&i)); + } + }); + }); + }}; +} + +macro_rules! bench_lookup_load_factor { + ($c:ident, $name:ident, $size:literal, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::default(); + for i in ($keydist).take($size) { + m.insert(i, DropType(i)); + } + + b.iter(|| { + for i in ($keydist).take(OP_COUNT) { + black_box(m.get(&i)); + } + }); + }); + }}; +} + +macro_rules! bench_lookup_fail_load_factor { + ($c:ident, $name:ident, $size:literal, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::default(); + let mut iter = $keydist; + for i in (&mut iter).take($size) { + m.insert(i, DropType(i)); + } + + b.iter(|| { + for i in (&mut iter).take(OP_COUNT) { + black_box(m.get(&i)); + } + }); + }); + }}; +} + +macro_rules! bench_iter { + ($c:ident, $name:ident, $maptype:ident, $keydist:expr) => {{ + $c.bench_function(stringify!($name), |b| { + let mut m = $maptype::default(); + for i in ($keydist).take(SIZE) { + m.insert(i, DropType(i)); + } + + b.iter(|| { + for i in &m { + black_box(i); + } + }); + }); + }}; +} + +pub(crate) fn register_benches(c: &mut Criterion) { + bench_suite!( + c, + bench_insert, + insert_foldhash_serial, + insert_std_serial, + insert_foldhash_highbits, + insert_std_highbits, + insert_foldhash_random, + insert_std_random + ); + + bench_suite!( + c, + bench_grow_insert, + grow_insert_foldhash_serial, + grow_insert_std_serial, + grow_insert_foldhash_highbits, + grow_insert_std_highbits, + grow_insert_foldhash_random, + grow_insert_std_random + ); + + bench_suite!( + c, + bench_insert_erase, + insert_erase_foldhash_serial, + insert_erase_std_serial, + insert_erase_foldhash_highbits, + insert_erase_std_highbits, + insert_erase_foldhash_random, + insert_erase_std_random + ); + + bench_suite!( + c, + bench_lookup, + lookup_foldhash_serial, + lookup_std_serial, + lookup_foldhash_highbits, + lookup_std_highbits, + lookup_foldhash_random, + lookup_std_random + ); + + bench_suite!( + c, + bench_lookup_fail, + lookup_fail_foldhash_serial, + lookup_fail_std_serial, + lookup_fail_foldhash_highbits, + lookup_fail_std_highbits, + lookup_fail_foldhash_random, + lookup_fail_std_random + ); + + bench_suite_2!( + c, + bench_lookup_load_factor, + loadfactor_lookup_14500, + 14500, + loadfactor_lookup_16500, + 16500, + loadfactor_lookup_18500, + 18500, + loadfactor_lookup_20500, + 20500, + loadfactor_lookup_22500, + 22500, + loadfactor_lookup_24500, + 24500, + loadfactor_lookup_26500, + 26500, + loadfactor_lookup_28500, + 28500 + ); + + bench_suite_2!( + c, + bench_lookup_fail_load_factor, + loadfactor_lookup_fail_14500, + 14500, + loadfactor_lookup_fail_16500, + 16500, + loadfactor_lookup_fail_18500, + 18500, + loadfactor_lookup_fail_20500, + 20500, + loadfactor_lookup_fail_22500, + 22500, + loadfactor_lookup_fail_24500, + 24500, + loadfactor_lookup_fail_26500, + 26500, + loadfactor_lookup_fail_28500, + 28500 + ); + + bench_suite!( + c, + bench_iter, + iter_foldhash_serial, + iter_std_serial, + iter_foldhash_highbits, + iter_std_highbits, + iter_foldhash_random, + iter_std_random + ); + + c.bench_function("clone_small", |b| { + let mut m = HashMap::new(); + for i in 0..10 { + m.insert(i, DropType(i)); + } + + b.iter(|| { + black_box(m.clone()); + }); + }); + + c.bench_function("clone_from_small", |b| { + let mut m = HashMap::new(); + let mut other = HashMap::new(); + for i in 0..10 { + m.insert(i, DropType(i)); + } + + b.iter(|| { + other.clone_from(&m); + black_box(&mut other); + }); + }); + + c.bench_function("clone_large", |b| { + let mut m = HashMap::new(); + for i in 0..1000 { + m.insert(i, DropType(i)); + } + + b.iter(|| { + black_box(m.clone()); + }); + }); + + c.bench_function("clone_from_large", |b| { + let mut m = HashMap::new(); + let mut other = HashMap::new(); + for i in 0..1000 { + m.insert(i, DropType(i)); + } + + b.iter(|| { + other.clone_from(&m); + black_box(&mut other); + }); + }); + + c.bench_function("rehash_in_place", |b| { + b.iter(|| { + let mut set = HashSet::new(); + + // Each loop triggers one rehash + for _ in 0..10 { + for i in 0..223 { + set.insert(i); + } + + assert_eq!( + set.capacity(), + 224, + "The set must be at or close to capacity to trigger a re hashing" + ); + + for i in 100..1400 { + set.remove(&(i - 100)); + set.insert(i); + } + set.clear(); + } + }); + }); +} diff --git a/library/hashbrown/benches/insert_unique_unchecked.rs b/library/hashbrown/benches/insert_unique_unchecked.rs new file mode 100644 index 0000000000000..402a218201f52 --- /dev/null +++ b/library/hashbrown/benches/insert_unique_unchecked.rs @@ -0,0 +1,32 @@ +//! Compare `insert` and `insert_unique_unchecked` operations performance. +use criterion::Criterion; +use hashbrown::HashMap; +use std::hint::black_box; + +pub(crate) fn register_benches(c: &mut Criterion) { + let keys: Vec = (0..1000).map(|i| format!("xxxx{i}yyyy")).collect(); + + c.bench_function("insert", |b| { + let mut m = HashMap::with_capacity(1000); + b.iter(|| { + m.clear(); + for k in &keys { + m.insert(k, k); + } + black_box(m.len()) + }); + }); + + c.bench_function("insert_unique_unchecked", |b| { + let mut m = HashMap::with_capacity(1000); + b.iter(|| { + m.clear(); + for k in &keys { + unsafe { + m.insert_unique_unchecked(k, k); + } + } + black_box(m.len()) + }); + }); +} diff --git a/library/hashbrown/benches/set_ops.rs b/library/hashbrown/benches/set_ops.rs new file mode 100644 index 0000000000000..6826688d95761 --- /dev/null +++ b/library/hashbrown/benches/set_ops.rs @@ -0,0 +1,91 @@ +//! This file contains benchmarks for the ops traits implemented by HashSet. +//! Each test is intended to have a defined larger and smaller set, +//! but using a larger size for the "small" set works just as well. +//! +//! Each assigning test is done in the configuration that is faster. Cheating, I know. +//! The exception to this is Sub, because there the result differs. So I made two benchmarks for Sub. +use criterion::Criterion; +use hashbrown::HashSet; + +/// The number of items to generate for the larger of the sets. +const LARGE_SET_SIZE: usize = 1000; + +/// The number of items to generate for the smaller of the sets. +const SMALL_SET_SIZE: usize = 100; + +/// The number of keys present in both sets. +const OVERLAP: usize = + [LARGE_SET_SIZE, SMALL_SET_SIZE][(LARGE_SET_SIZE < SMALL_SET_SIZE) as usize] / 2; + +/// Creates a set containing end - start unique string elements. +fn create_set(start: usize, end: usize) -> HashSet { + (start..end).map(|nr| format!("key{nr}")).collect() +} + +pub(crate) fn register_benches(c: &mut Criterion) { + let large_set = create_set(0, LARGE_SET_SIZE); + let small_set = create_set( + LARGE_SET_SIZE - OVERLAP, + LARGE_SET_SIZE + SMALL_SET_SIZE - OVERLAP, + ); + + c.bench_function("set_ops_bit_or", |b| { + b.iter(|| &large_set | &small_set); + }); + + c.bench_function("set_ops_bit_and", |b| { + b.iter(|| &large_set & &small_set); + }); + + c.bench_function("set_ops_bit_xor", |b| { + b.iter(|| &large_set ^ &small_set); + }); + + c.bench_function("set_ops_sub_large_small", |b| { + b.iter(|| &large_set - &small_set); + }); + + c.bench_function("set_ops_sub_small_large", |b| { + b.iter(|| &small_set - &large_set); + }); + + c.bench_function("set_ops_bit_or_assign", |b| { + b.iter(|| { + let mut set = large_set.clone(); + set |= &small_set; + set + }); + }); + + c.bench_function("set_ops_bit_and_assign", |b| { + b.iter(|| { + let mut set = small_set.clone(); + set &= &large_set; + set + }); + }); + + c.bench_function("set_ops_bit_xor_assign", |b| { + b.iter(|| { + let mut set = large_set.clone(); + set ^= &small_set; + set + }); + }); + + c.bench_function("set_ops_sub_assign_large_small", |b| { + b.iter(|| { + let mut set = large_set.clone(); + set -= &small_set; + set + }); + }); + + c.bench_function("set_ops_sub_assign_small_large", |b| { + b.iter(|| { + let mut set = small_set.clone(); + set -= &large_set; + set + }); + }); +} diff --git a/library/hashbrown/benches/with_capacity.rs b/library/hashbrown/benches/with_capacity.rs new file mode 100644 index 0000000000000..c1299244225df --- /dev/null +++ b/library/hashbrown/benches/with_capacity.rs @@ -0,0 +1,36 @@ +use criterion::Criterion; +use hashbrown::HashMap; +use std::hint::black_box; + +type Map = HashMap; + +macro_rules! bench_with_capacity { + ($c:ident, $name:ident, $cap:expr) => { + $c.bench_function(stringify!($name), |b| { + b.iter(|| { + // Construct a new empty map with a given capacity and return it to avoid + // being optimized away. Dropping it measures allocation + minimal setup. + let m: Map = Map::with_capacity($cap); + black_box(m) + }); + }); + }; +} + +pub(crate) fn register_benches(c: &mut Criterion) { + bench_with_capacity!(c, with_capacity_000000, 0); + bench_with_capacity!(c, with_capacity_000001, 1); + bench_with_capacity!(c, with_capacity_000003, 3); + bench_with_capacity!(c, with_capacity_000007, 7); + bench_with_capacity!(c, with_capacity_000008, 8); + bench_with_capacity!(c, with_capacity_000016, 16); + bench_with_capacity!(c, with_capacity_000032, 32); + bench_with_capacity!(c, with_capacity_000064, 64); + bench_with_capacity!(c, with_capacity_000128, 128); + bench_with_capacity!(c, with_capacity_000256, 256); + bench_with_capacity!(c, with_capacity_000512, 512); + bench_with_capacity!(c, with_capacity_001024, 1024); + bench_with_capacity!(c, with_capacity_004096, 4096); + bench_with_capacity!(c, with_capacity_016384, 16384); + bench_with_capacity!(c, with_capacity_065536, 65536); +} diff --git a/library/hashbrown/ci/miri.sh b/library/hashbrown/ci/miri.sh new file mode 100755 index 0000000000000..463bab3da06bd --- /dev/null +++ b/library/hashbrown/ci/miri.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -ex + +export CARGO_NET_RETRY=5 +export CARGO_NET_TIMEOUT=10 + +rustup toolchain install nightly --component miri +rustup override set nightly +cargo miri setup + +TARGETS=( + # SSE impl + --target x86_64-unknown-linux-gnu + # NEON impl + --target aarch64-unknown-linux-gnu + # generic impl + --target riscv64a23-unknown-linux-gnu +) +MIRIFLAGS="$MIRIFLAGS -Zmiri-strict-provenance" cargo miri test --features nightly "${TARGETS[@]}" diff --git a/library/hashbrown/ci/run.sh b/library/hashbrown/ci/run.sh new file mode 100755 index 0000000000000..47eaf237fd7af --- /dev/null +++ b/library/hashbrown/ci/run.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env sh + +set -ex + +: "${TARGET?The TARGET environment variable must be set.}" + +case "${TARGET}" in + x86_64-unknown-linux-gnu|x86_64-apple-darwin|aarch64-apple-darwin|x86_64-pc-windows-msvc) + CROSS=0 + NO_STD=0 + ;; + thumbv6m-none-eabi|loongarch64-unknown-linux-gnu) + CROSS=1 + NO_STD=1 + ;; + *) + CROSS=1 + NO_STD=0 + ;; +esac + +CARGO=cargo +if [ "${CROSS}" = "1" ]; then + export CARGO_NET_RETRY=5 + export CARGO_NET_TIMEOUT=10 + + cargo install --locked cross + CARGO=cross +fi + +if [ "${NO_STD}" = "1" ]; then + # Unfortunately serde currently doesn't work without std due to a cargo bug. + FEATURES="rustc-internal-api" + OP="build" +else + FEATURES="rustc-internal-api,serde,rayon" + OP="test" +fi + +if [ "${CHANNEL}" = "nightly" ]; then + FEATURES="${FEATURES},nightly" + export RUSTFLAGS="$RUSTFLAGS -D warnings" +fi + +# Make sure we can compile without the default hasher +"${CARGO}" -vv build --target="${TARGET}" --no-default-features +"${CARGO}" -vv build --target="${TARGET}" --release --no-default-features + +"${CARGO}" -vv ${OP} --target="${TARGET}" +"${CARGO}" -vv ${OP} --target="${TARGET}" --features "${FEATURES}" + +"${CARGO}" -vv ${OP} --target="${TARGET}" --release +"${CARGO}" -vv ${OP} --target="${TARGET}" --release --features "${FEATURES}" diff --git a/library/hashbrown/ci/tools.sh b/library/hashbrown/ci/tools.sh new file mode 100755 index 0000000000000..3320bfb7b0c2c --- /dev/null +++ b/library/hashbrown/ci/tools.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +set -ex + +retry() { + result=0 + count=1 + max=5 + while [ "$count" -le 3 ]; do + [ "$result" -ne 0 ] && { + printf "\nRetrying, %d of %d\n" $count $max >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$((count + 1)) + sleep 1 + done + + [ "$count" -gt 3 ] && { + printf "\nFailed %d times.\n" $max >&2 + } + + return $result +} + + +if rustc --version | grep --quiet nightly ; then + export RUSTDOCFLAGS="-Zunstable-options --check" +fi + +cargo doc --no-deps --features serde,rayon + +if retry rustup component add rustfmt ; then + cargo fmt --all -- --check +fi + +if retry rustup component add clippy ; then + # we want all targets that have dedicated SIMD implementations, + # plus one that uses the generic implementation, + # since we can't lint cfg-disabled code + TARGETS=() + + # associative array of cfgs from rustc + declare -A CFG + for cfg in $(rustc --print cfg); do + # bash is very upset about quotes and equal signs in keys + cfg="${cfg//\"/}" + cfg="${cfg//=/_}" + printf "\n%s\n" "$cfg" >&2 + CFG["$cfg"]=1 + done + + HOST_IS_GENERIC=1 + + # SSE2 + if (( CFG[target_feature_sse2] && (CFG[target_arch_x86] || CFG[target_arch_x86_64]) )); then + printf "\nHost target supports SSE2\n" >&2 + TARGETS+=(--target "$(rustc --print host-tuple)") + HOST_IS_GENERIC=0 + elif retry rustup target add x86_64-unknown-linux-gnu; then + printf "\nTesting x86_64-unknown-linux-gnu\n" >&2 + TARGETS+=(--target x86_64-unknown-linux-gnu) + fi + + # NEON + if (( CFG[target_arch_aarch64] && CFG[target_feature_neon] && CFG[target_endian_little] )); then + printf "\nHost target supports NEON\n" >&2 + TARGETS+=(--target "$(rustc --print host-tuple)") + HOST_IS_GENERIC=0 + elif retry rustup target add aarch64-unknown-linux-gnu; then + printf "\nTesting aarch64-unknown-linux-gnu\n" >&2 + TARGETS+=(--target aarch64-unknown-linux-gnu) + fi + + # LSX + if (( CFG[target_arch_loongarch64] && CFG[target_feature_lsx] )); then + printf "\nHost target supports LSX\n" >&2 + TARGETS+=(--target "$(rustc --print host-tuple)") + HOST_IS_GENERIC=0 + elif retry rustup target add loongarch64-unknown-linux-gnu; then + printf "\nTesting loongarch64-unknown-linux-gnu\n" >&2 + TARGETS+=(--target loongarch64-unknown-linux-gnu) + fi + + # Generic + if (( HOST_IS_GENERIC )); then + printf "\nHost target support is generic\n" >&2 + TARGETS+=(--target "$(rustc --print host-tuple)") + elif retry rustup target add i586-unknown-linux-gnu; then + printf "\nTesting i586-unknown-linux-gnu\n" >&2 + TARGETS+=(--target i586-unknown-linux-gnu) + fi + + cargo clippy --all --tests --features serde,rayon "${TARGETS[@]}" -- -D warnings + + # check nightly too + if rustc --version | grep --quiet nightly ; then + cargo +nightly clippy --all-targets --features serde,rayon,nightly "${TARGETS[@]}" -- -D warnings + fi +fi + +if command -v taplo ; then + taplo fmt --check --diff +fi + +if command -v shellcheck ; then + shellcheck --version + shellcheck ci/*.sh +fi diff --git a/library/hashbrown/clippy.toml b/library/hashbrown/clippy.toml new file mode 100644 index 0000000000000..10719990a748a --- /dev/null +++ b/library/hashbrown/clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["CppCon", "SwissTable", "SipHash", "HashDoS"] diff --git a/library/hashbrown/josh-sync.toml b/library/hashbrown/josh-sync.toml new file mode 100644 index 0000000000000..cca715c3e7b47 --- /dev/null +++ b/library/hashbrown/josh-sync.toml @@ -0,0 +1,5 @@ +org = "rust-lang" +repo = "hashbrown" +path = "library/hashbrown" +filter-version = 2 +pull-mode = "Latest" diff --git a/library/hashbrown/rust-version b/library/hashbrown/rust-version new file mode 100644 index 0000000000000..ee3984eb20906 --- /dev/null +++ b/library/hashbrown/rust-version @@ -0,0 +1 @@ +34228cf7f5bdd08d320dedf008b8995dd3e743e2 diff --git a/library/hashbrown/src/alloc.rs b/library/hashbrown/src/alloc.rs new file mode 100644 index 0000000000000..59c3eb4c5f227 --- /dev/null +++ b/library/hashbrown/src/alloc.rs @@ -0,0 +1,104 @@ +#[cfg(test)] +pub(crate) use self::inner::AllocError; +pub(crate) use self::inner::{Allocator, Global, do_alloc}; + +// Nightly-case. +// Use unstable `allocator_api` feature. +// This is compatible with `allocator-api2` which can be enabled or not. +// This is used when building for `std`. +#[cfg(feature = "nightly")] +mod inner { + use core::alloc::Layout; + use core::ptr::NonNull; + #[cfg(test)] + pub(crate) use stdalloc::alloc::AllocError; + pub(crate) use stdalloc::alloc::{Allocator, Global}; + + pub(crate) fn do_alloc(alloc: &A, layout: Layout) -> Result, ()> { + match alloc.allocate(layout) { + Ok(ptr) => Ok(ptr), + Err(_) => Err(()), + } + } +} + +// Basic non-nightly case. +// This uses `allocator-api2` enabled by default. +// If any crate enables "nightly" in `allocator-api2`, +// this will be equivalent to the nightly case, +// since `allocator_api2::alloc::Allocator` would be re-export of +// `core::alloc::Allocator`. +#[cfg(all(not(feature = "nightly"), feature = "allocator-api2"))] +mod inner { + #[cfg(test)] + pub(crate) use allocator_api2::alloc::AllocError; + pub(crate) use allocator_api2::alloc::{Allocator, Global}; + use core::alloc::Layout; + use core::ptr::NonNull; + + pub(crate) fn do_alloc(alloc: &A, layout: Layout) -> Result, ()> { + match alloc.allocate(layout) { + Ok(ptr) => Ok(ptr), + Err(_) => Err(()), + } + } +} + +// No-defaults case. +// When building with default-features turned off and +// neither `nightly` nor `allocator-api2` is enabled, +// this will be used. +// Making it impossible to use any custom allocator with collections defined +// in this crate. +// Any crate in build-tree can enable `allocator-api2`, +// or `nightly` without disturbing users that don't want to use it. +#[cfg(not(any(feature = "nightly", feature = "allocator-api2")))] +mod inner { + use core::alloc::Layout; + use core::ptr::NonNull; + use stdalloc::alloc::{alloc, dealloc}; + + #[expect(clippy::missing_safety_doc)] // not exposed outside of this crate + pub unsafe trait Allocator { + fn allocate(&self, layout: Layout) -> Result, ()>; + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout); + } + + #[derive(Copy, Clone)] + pub struct Global; + + unsafe impl Allocator for Global { + #[inline] + fn allocate(&self, layout: Layout) -> Result, ()> { + match unsafe { NonNull::new(alloc(layout)) } { + Some(data) => { + // SAFETY: this is NonNull::slice_from_raw_parts. + Ok(unsafe { + NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut( + data.as_ptr(), + layout.size(), + )) + }) + } + None => Err(()), + } + } + #[inline] + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + unsafe { + dealloc(ptr.as_ptr(), layout); + } + } + } + + impl Default for Global { + #[inline] + fn default() -> Self { + Global + } + } + + pub(crate) fn do_alloc(alloc: &A, layout: Layout) -> Result, ()> { + alloc.allocate(layout) + } +} diff --git a/library/hashbrown/src/control/bitmask.rs b/library/hashbrown/src/control/bitmask.rs new file mode 100644 index 0000000000000..72283126cfd5d --- /dev/null +++ b/library/hashbrown/src/control/bitmask.rs @@ -0,0 +1,107 @@ +use super::group::{BITMASK_ITER_MASK, BITMASK_STRIDE, BitMaskWord, NonZeroBitMaskWord}; + +/// A bit mask which contains the result of a `Match` operation on a `Group` and +/// allows iterating through them. +/// +/// The bit mask is arranged so that low-order bits represent lower memory +/// addresses for group match results. +/// +/// For implementation reasons, the bits in the set may be sparsely packed with +/// groups of 8 bits representing one element. If any of these bits are non-zero +/// then this element is considered to true in the mask. If this is the +/// case, `BITMASK_STRIDE` will be 8 to indicate a divide-by-8 should be +/// performed on counts/indices to normalize this difference. `BITMASK_MASK` is +/// similarly a mask of all the actually-used bits. +/// +/// To iterate over a bit mask, it must be converted to a form where only 1 bit +/// is set per element. This is done by applying `BITMASK_ITER_MASK` on the +/// mask bits. +#[derive(Copy, Clone)] +pub(crate) struct BitMask(pub(crate) BitMaskWord); + +#[expect(clippy::use_self)] +impl BitMask { + /// Returns a new `BitMask` with the lowest bit removed. + #[inline] + #[must_use] + fn remove_lowest_bit(self) -> Self { + BitMask(self.0 & (self.0 - 1)) + } + + /// Returns whether the `BitMask` has at least one set bit. + #[inline] + pub(crate) fn any_bit_set(self) -> bool { + self.0 != 0 + } + + /// Returns the first set bit in the `BitMask`, if there is one. + #[inline] + pub(crate) fn lowest_set_bit(self) -> Option { + if let Some(nonzero) = NonZeroBitMaskWord::new(self.0) { + Some(Self::nonzero_trailing_zeros(nonzero)) + } else { + None + } + } + + /// Returns the number of trailing zeroes in the `BitMask`. + #[inline] + pub(crate) fn trailing_zeros(self) -> usize { + // ARM doesn't have a trailing_zeroes instruction, and instead uses + // reverse_bits (RBIT) + leading_zeroes (CLZ). However older ARM + // versions (pre-ARMv7) don't have RBIT and need to emulate it + // instead. Since we only have 1 bit set in each byte on ARM, we can + // use swap_bytes (REV) + leading_zeroes instead. + if cfg!(target_arch = "arm") && BITMASK_STRIDE % 8 == 0 { + self.0.swap_bytes().leading_zeros() as usize / BITMASK_STRIDE + } else { + self.0.trailing_zeros() as usize / BITMASK_STRIDE + } + } + + /// Same as above but takes a `NonZeroBitMaskWord`. + #[inline] + fn nonzero_trailing_zeros(nonzero: NonZeroBitMaskWord) -> usize { + if cfg!(target_arch = "arm") && BITMASK_STRIDE % 8 == 0 { + // SAFETY: A byte-swapped non-zero value is still non-zero. + let swapped = unsafe { NonZeroBitMaskWord::new_unchecked(nonzero.get().swap_bytes()) }; + swapped.leading_zeros() as usize / BITMASK_STRIDE + } else { + nonzero.trailing_zeros() as usize / BITMASK_STRIDE + } + } + + /// Returns the number of leading zeroes in the `BitMask`. + #[inline] + pub(crate) fn leading_zeros(self) -> usize { + self.0.leading_zeros() as usize / BITMASK_STRIDE + } +} + +impl IntoIterator for BitMask { + type Item = usize; + type IntoIter = BitMaskIter; + + #[inline] + fn into_iter(self) -> BitMaskIter { + // A BitMask only requires each element (group of bits) to be non-zero. + // However for iteration we need each element to only contain 1 bit. + BitMaskIter(BitMask(self.0 & BITMASK_ITER_MASK)) + } +} + +/// Iterator over the contents of a `BitMask`, returning the indices of set +/// bits. +#[derive(Clone)] +pub(crate) struct BitMaskIter(pub(crate) BitMask); + +impl Iterator for BitMaskIter { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + let bit = self.0.lowest_set_bit()?; + self.0 = self.0.remove_lowest_bit(); + Some(bit) + } +} diff --git a/library/hashbrown/src/control/group/generic.rs b/library/hashbrown/src/control/group/generic.rs new file mode 100644 index 0000000000000..da7042d775972 --- /dev/null +++ b/library/hashbrown/src/control/group/generic.rs @@ -0,0 +1,153 @@ +use super::super::{BitMask, Tag}; +use core::ptr; + +// Use the native word size as the group size. Using a 64-bit group size on +// a 32-bit architecture will just end up being more expensive because +// shifts and multiplies will need to be emulated. + +cfg_select! { + any( + target_pointer_width = "64", + target_arch = "aarch64", + target_arch = "x86_64", + target_arch = "wasm32", + ) => { + type GroupWord = u64; + type NonZeroGroupWord = core::num::NonZeroU64; + } + _ => { + type GroupWord = u32; + type NonZeroGroupWord = core::num::NonZeroU32; + } +} + +pub(crate) type BitMaskWord = GroupWord; +pub(crate) type NonZeroBitMaskWord = NonZeroGroupWord; +pub(crate) const BITMASK_STRIDE: usize = 8; +// We only care about the highest bit of each tag for the mask. +const BITMASK_MASK: BitMaskWord = u64::from_ne_bytes([Tag::DELETED.0; 8]) as GroupWord; +pub(crate) const BITMASK_ITER_MASK: BitMaskWord = !0; + +/// Helper function to replicate a tag across a `GroupWord`. +#[inline] +fn repeat(tag: Tag) -> GroupWord { + GroupWord::from_ne_bytes([tag.0; Group::WIDTH]) +} + +/// Abstraction over a group of control tags which can be scanned in +/// parallel. +/// +/// This implementation uses a word-sized integer. +#[derive(Copy, Clone)] +pub(crate) struct Group(GroupWord); + +// We perform all operations in the native endianness, and convert to +// little-endian just before creating a BitMask. The can potentially +// enable the compiler to eliminate unnecessary byte swaps if we are +// only checking whether a BitMask is empty. +#[expect(clippy::use_self)] +impl Group { + /// Number of bytes in the group. + pub(crate) const WIDTH: usize = size_of::(); + + /// Returns a full group of empty tags, suitable for use as the initial + /// value for an empty hash table. + /// + /// This is guaranteed to be aligned to the group size. + #[inline] + pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + #[repr(C)] + struct AlignedTags { + _align: [Group; 0], + tags: [Tag; Group::WIDTH], + } + const ALIGNED_TAGS: AlignedTags = AlignedTags { + _align: [], + tags: [Tag::EMPTY; Group::WIDTH], + }; + &ALIGNED_TAGS.tags + } + + /// Loads a group of tags starting at the given address. + #[inline] + pub(crate) unsafe fn load(ptr: *const Tag) -> Self { + unsafe { Group(ptr::read_unaligned(ptr.cast())) } + } + + /// Loads a group of tags starting at the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn load_aligned(ptr: *const Tag) -> Self { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { Group(ptr::read(ptr.cast())) } + } + + /// Stores the group of tags to the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn store_aligned(self, ptr: *mut Tag) { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { + ptr::write(ptr.cast(), self.0); + } + } + + /// Returns a `BitMask` indicating all tags in the group which *may* + /// have the given value. + /// + /// This function may return a false positive in certain cases where + /// the tag in the group differs from the searched value only in its + /// lowest bit. This is fine because: + /// - This never happens for `EMPTY` and `DELETED`, only full entries. + /// - The check for key equality will catch these. + /// - This only happens if there is at least 1 true match. + /// - The chance of this happening is very low (< 1% chance per tag). + #[inline] + pub(crate) fn match_tag(self, tag: Tag) -> BitMask { + // This algorithm is derived from + // https://graphics.stanford.edu/~seander/bithacks.html##ValueInWord + let cmp = self.0 ^ repeat(tag); + BitMask((cmp.wrapping_sub(repeat(Tag(0x01))) & !cmp & repeat(Tag::DELETED)).to_le()) + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY`. + #[inline] + pub(crate) fn match_empty(self) -> BitMask { + // If the high bit is set, then the tag must be either: + // 1111_1111 (EMPTY) or 1000_0000 (DELETED). + // So we can just check if the top two bits are 1 by ANDing them. + BitMask((self.0 & (self.0 << 1) & repeat(Tag::DELETED)).to_le()) + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY` or `DELETED`. + #[inline] + pub(crate) fn match_empty_or_deleted(self) -> BitMask { + // A tag is EMPTY or DELETED iff the high bit is set + BitMask((self.0 & repeat(Tag::DELETED)).to_le()) + } + + /// Returns a `BitMask` indicating all tags in the group which are full. + #[inline] + pub(crate) fn match_full(self) -> BitMask { + BitMask(self.match_empty_or_deleted().0 ^ BITMASK_MASK) + } + + /// Performs the following transformation on all tags in the group: + /// - `EMPTY => EMPTY` + /// - `DELETED => EMPTY` + /// - `FULL => DELETED` + #[inline] + pub(crate) fn convert_special_to_empty_and_full_to_deleted(self) -> Self { + // Map high_bit = 1 (EMPTY or DELETED) to 1111_1111 + // and high_bit = 0 (FULL) to 1000_0000 + // + // Here's this logic expanded to concrete values: + // let full = 1000_0000 (true) or 0000_0000 (false) + // !1000_0000 + 1 = 0111_1111 + 1 = 1000_0000 (no carry) + // !0000_0000 + 0 = 1111_1111 + 0 = 1111_1111 (no carry) + let full = !self.0 & repeat(Tag::DELETED); + Group(!full + (full >> 7)) + } +} diff --git a/library/hashbrown/src/control/group/lsx.rs b/library/hashbrown/src/control/group/lsx.rs new file mode 100644 index 0000000000000..64f4a41f02f05 --- /dev/null +++ b/library/hashbrown/src/control/group/lsx.rs @@ -0,0 +1,123 @@ +use super::super::{BitMask, Tag}; +use core::num::NonZeroU16; + +use core::arch::loongarch64::*; + +pub(crate) type BitMaskWord = u16; +pub(crate) type NonZeroBitMaskWord = NonZeroU16; +pub(crate) const BITMASK_STRIDE: usize = 1; +pub(crate) const BITMASK_ITER_MASK: BitMaskWord = !0; + +/// Abstraction over a group of control tags which can be scanned in +/// parallel. +/// +/// This implementation uses a 128-bit LSX value. +#[derive(Copy, Clone)] +pub(crate) struct Group(m128i); + +// FIXME: https://github.com/rust-lang/rust-clippy/issues/3859 +#[expect(clippy::use_self)] +impl Group { + /// Number of bytes in the group. + pub(crate) const WIDTH: usize = size_of::(); + + /// Returns a full group of empty tags, suitable for use as the initial + /// value for an empty hash table. + /// + /// This is guaranteed to be aligned to the group size. + #[inline] + pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + #[repr(C)] + struct AlignedTags { + _align: [Group; 0], + tags: [Tag; Group::WIDTH], + } + const ALIGNED_TAGS: AlignedTags = AlignedTags { + _align: [], + tags: [Tag::EMPTY; Group::WIDTH], + }; + &ALIGNED_TAGS.tags + } + + /// Loads a group of tags starting at the given address. + #[inline] + pub(crate) unsafe fn load(ptr: *const Tag) -> Self { + unsafe { Group(lsx_vld::<0>(ptr.cast())) } + } + + /// Loads a group of tags starting at the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn load_aligned(ptr: *const Tag) -> Self { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { Group(lsx_vld::<0>(ptr.cast())) } + } + + /// Stores the group of tags to the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn store_aligned(self, ptr: *mut Tag) { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { + lsx_vst::<0>(self.0, ptr.cast()); + } + } + + /// Returns a `BitMask` indicating all tags in the group which have + /// the given value. + #[inline] + pub(crate) fn match_tag(self, tag: Tag) -> BitMask { + unsafe { + let cmp = lsx_vseq_b(self.0, lsx_vreplgr2vr_b(tag.0 as i32)); + BitMask(lsx_vpickve2gr_hu::<0>(lsx_vmskltz_b(cmp)) as u16) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY`. + #[inline] + pub(crate) fn match_empty(self) -> BitMask { + unsafe { + let cmp = lsx_vseqi_b::<{ Tag::EMPTY.0 as i8 as i32 }>(self.0); + BitMask(lsx_vpickve2gr_hu::<0>(lsx_vmskltz_b(cmp)) as u16) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY` or `DELETED`. + #[inline] + pub(crate) fn match_empty_or_deleted(self) -> BitMask { + unsafe { + // A tag is EMPTY or DELETED iff the high bit is set + BitMask(lsx_vpickve2gr_hu::<0>(lsx_vmskltz_b(self.0)) as u16) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are full. + #[inline] + pub(crate) fn match_full(&self) -> BitMask { + unsafe { + // A tag is EMPTY or DELETED iff the high bit is set + BitMask(lsx_vpickve2gr_hu::<0>(lsx_vmskgez_b(self.0)) as u16) + } + } + + /// Performs the following transformation on all tags in the group: + /// - `EMPTY => EMPTY` + /// - `DELETED => EMPTY` + /// - `FULL => DELETED` + #[inline] + pub(crate) fn convert_special_to_empty_and_full_to_deleted(self) -> Self { + // Map high_bit = 1 (EMPTY or DELETED) to 1111_1111 + // and high_bit = 0 (FULL) to 1000_0000 + // + // Here's this logic expanded to concrete values: + // let special = 0 > tag = 1111_1111 (true) or 0000_0000 (false) + // 1111_1111 | 1000_0000 = 1111_1111 + // 0000_0000 | 1000_0000 = 1000_0000 + unsafe { + let special = lsx_vslti_b::<0>(self.0); + Group(lsx_vori_b::<{ Tag::DELETED.0 as u32 }>(special)) + } + } +} diff --git a/library/hashbrown/src/control/group/mod.rs b/library/hashbrown/src/control/group/mod.rs new file mode 100644 index 0000000000000..0efc243feb2ee --- /dev/null +++ b/library/hashbrown/src/control/group/mod.rs @@ -0,0 +1,50 @@ +// TESTING NOTE: +// +// Because this module uses `cfg(..)` to select an implementation, it will not +// be linted without being run on targets that actually load each of these +// modules. Be sure to edit `ci/tools.sh` to add in the necessary cfgs if you +// change these, so that your implementation gets properly linted. + +cfg_select! { + // Use the SSE2 implementation if possible: it allows us to scan 16 buckets + // at once instead of 8. We don't bother with AVX since it would require + // runtime dispatch and wouldn't gain us much anyways: the probability of + // finding a match drops off drastically after the first few buckets. + // + // I attempted an implementation on ARM using NEON instructions, but it + // turns out that most NEON instructions have multi-cycle latency, which in + // the end outweighs any gains over the generic implementation. + all( + target_feature = "sse2", + any(target_arch = "x86", target_arch = "x86_64"), + ) => { + mod sse2; + use sse2 as imp; + } + all( + target_arch = "aarch64", + target_feature = "neon", + // NEON intrinsics are currently broken on big-endian targets. + // See https://github.com/rust-lang/stdarch/issues/1484. + target_endian = "little", + ) => { + mod neon; + use neon as imp; + } + all( + feature = "nightly", + target_arch = "loongarch64", + target_feature = "lsx", + not(miri), // Miri does not support lsx + ) => { + mod lsx; + use lsx as imp; + } + + _ => { + mod generic; + use generic as imp; + } +} +pub(crate) use self::imp::Group; +pub(super) use self::imp::{BITMASK_ITER_MASK, BITMASK_STRIDE, BitMaskWord, NonZeroBitMaskWord}; diff --git a/library/hashbrown/src/control/group/neon.rs b/library/hashbrown/src/control/group/neon.rs new file mode 100644 index 0000000000000..f97c1a5df4fa2 --- /dev/null +++ b/library/hashbrown/src/control/group/neon.rs @@ -0,0 +1,118 @@ +use super::super::{BitMask, Tag}; +use core::arch::aarch64 as neon; +use core::num::NonZeroU64; + +pub(crate) type BitMaskWord = u64; +pub(crate) type NonZeroBitMaskWord = NonZeroU64; +pub(crate) const BITMASK_STRIDE: usize = 8; +pub(crate) const BITMASK_ITER_MASK: BitMaskWord = 0x8080_8080_8080_8080; + +/// Abstraction over a group of control tags which can be scanned in +/// parallel. +/// +/// This implementation uses a 64-bit NEON value. +#[derive(Copy, Clone)] +pub(crate) struct Group(neon::uint8x8_t); + +#[expect(clippy::use_self)] +impl Group { + /// Number of bytes in the group. + pub(crate) const WIDTH: usize = size_of::(); + + /// Returns a full group of empty tags, suitable for use as the initial + /// value for an empty hash table. + /// + /// This is guaranteed to be aligned to the group size. + #[inline] + pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + #[repr(C)] + struct AlignedTags { + _align: [Group; 0], + tags: [Tag; Group::WIDTH], + } + const ALIGNED_TAGS: AlignedTags = AlignedTags { + _align: [], + tags: [Tag::EMPTY; Group::WIDTH], + }; + &ALIGNED_TAGS.tags + } + + /// Loads a group of tags starting at the given address. + #[inline] + pub(crate) unsafe fn load(ptr: *const Tag) -> Self { + unsafe { Group(neon::vld1_u8(ptr.cast())) } + } + + /// Loads a group of tags starting at the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn load_aligned(ptr: *const Tag) -> Self { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { Group(neon::vld1_u8(ptr.cast())) } + } + + /// Stores the group of tags to the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn store_aligned(self, ptr: *mut Tag) { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { + neon::vst1_u8(ptr.cast(), self.0); + } + } + + /// Returns a `BitMask` indicating all tags in the group which *may* + /// have the given value. + #[inline] + pub(crate) fn match_tag(self, tag: Tag) -> BitMask { + unsafe { + let cmp = neon::vceq_u8(self.0, neon::vdup_n_u8(tag.0)); + BitMask(neon::vget_lane_u64(neon::vreinterpret_u64_u8(cmp), 0)) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY`. + #[inline] + pub(crate) fn match_empty(self) -> BitMask { + self.match_tag(Tag::EMPTY) + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY` or `DELETED`. + #[inline] + pub(crate) fn match_empty_or_deleted(self) -> BitMask { + unsafe { + let cmp = neon::vcltz_s8(neon::vreinterpret_s8_u8(self.0)); + BitMask(neon::vget_lane_u64(neon::vreinterpret_u64_u8(cmp), 0)) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are full. + #[inline] + pub(crate) fn match_full(self) -> BitMask { + unsafe { + let cmp = neon::vcgez_s8(neon::vreinterpret_s8_u8(self.0)); + BitMask(neon::vget_lane_u64(neon::vreinterpret_u64_u8(cmp), 0)) + } + } + + /// Performs the following transformation on all tags in the group: + /// - `EMPTY => EMPTY` + /// - `DELETED => EMPTY` + /// - `FULL => DELETED` + #[inline] + pub(crate) fn convert_special_to_empty_and_full_to_deleted(self) -> Self { + // Map high_bit = 1 (EMPTY or DELETED) to 1111_1111 + // and high_bit = 0 (FULL) to 1000_0000 + // + // Here's this logic expanded to concrete values: + // let special = 0 > tag = 1111_1111 (true) or 0000_0000 (false) + // 1111_1111 | 1000_0000 = 1111_1111 + // 0000_0000 | 1000_0000 = 1000_0000 + unsafe { + let special = neon::vcltz_s8(neon::vreinterpret_s8_u8(self.0)); + Group(neon::vorr_u8(special, neon::vdup_n_u8(0x80))) + } + } +} diff --git a/library/hashbrown/src/control/group/sse2.rs b/library/hashbrown/src/control/group/sse2.rs new file mode 100644 index 0000000000000..c502d780d8015 --- /dev/null +++ b/library/hashbrown/src/control/group/sse2.rs @@ -0,0 +1,142 @@ +use super::super::{BitMask, Tag}; +use core::num::NonZeroU16; + +#[cfg(target_arch = "x86")] +use core::arch::x86; +#[cfg(target_arch = "x86_64")] +use core::arch::x86_64 as x86; + +pub(crate) type BitMaskWord = u16; +pub(crate) type NonZeroBitMaskWord = NonZeroU16; +pub(crate) const BITMASK_STRIDE: usize = 1; +pub(crate) const BITMASK_ITER_MASK: BitMaskWord = !0; + +/// Abstraction over a group of control tags which can be scanned in +/// parallel. +/// +/// This implementation uses a 128-bit SSE value. +#[derive(Copy, Clone)] +pub(crate) struct Group(x86::__m128i); + +// FIXME: https://github.com/rust-lang/rust-clippy/issues/3859 +#[expect(clippy::use_self)] +impl Group { + /// Number of bytes in the group. + pub(crate) const WIDTH: usize = size_of::(); + + /// Returns a full group of empty tags, suitable for use as the initial + /// value for an empty hash table. + /// + /// This is guaranteed to be aligned to the group size. + #[inline] + pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] { + #[repr(C)] + struct AlignedTags { + _align: [Group; 0], + tags: [Tag; Group::WIDTH], + } + const ALIGNED_TAGS: AlignedTags = AlignedTags { + _align: [], + tags: [Tag::EMPTY; Group::WIDTH], + }; + &ALIGNED_TAGS.tags + } + + /// Loads a group of tags starting at the given address. + #[inline] + pub(crate) unsafe fn load(ptr: *const Tag) -> Self { + unsafe { Group(x86::_mm_loadu_si128(ptr.cast())) } + } + + /// Loads a group of tags starting at the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn load_aligned(ptr: *const Tag) -> Self { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { Group(x86::_mm_load_si128(ptr.cast())) } + } + + /// Stores the group of tags to the given address, which must be + /// aligned to `align_of::()`. + #[inline] + pub(crate) unsafe fn store_aligned(self, ptr: *mut Tag) { + debug_assert_eq!(ptr.align_offset(align_of::()), 0); + unsafe { + x86::_mm_store_si128(ptr.cast(), self.0); + } + } + + /// Returns a `BitMask` indicating all tags in the group which have + /// the given value. + #[inline] + pub(crate) fn match_tag(self, tag: Tag) -> BitMask { + #[expect( + clippy::cast_possible_wrap, // tag.0: Tag as i8 + // tag: i32 as u16 + // note: _mm_movemask_epi8 returns a 16-bit mask in a i32, the + // upper 16-bits of the i32 are zeroed: + clippy::cast_sign_loss, + clippy::cast_possible_truncation + )] + unsafe { + let cmp = x86::_mm_cmpeq_epi8(self.0, x86::_mm_set1_epi8(tag.0 as i8)); + BitMask(x86::_mm_movemask_epi8(cmp) as u16) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY`. + #[inline] + pub(crate) fn match_empty(self) -> BitMask { + self.match_tag(Tag::EMPTY) + } + + /// Returns a `BitMask` indicating all tags in the group which are + /// `EMPTY` or `DELETED`. + #[inline] + pub(crate) fn match_empty_or_deleted(self) -> BitMask { + #[expect( + // tag: i32 as u16 + // note: _mm_movemask_epi8 returns a 16-bit mask in a i32, the + // upper 16-bits of the i32 are zeroed: + clippy::cast_sign_loss, + clippy::cast_possible_truncation + )] + unsafe { + // A tag is EMPTY or DELETED iff the high bit is set + BitMask(x86::_mm_movemask_epi8(self.0) as u16) + } + } + + /// Returns a `BitMask` indicating all tags in the group which are full. + #[inline] + pub(crate) fn match_full(&self) -> BitMask { + BitMask(!self.match_empty_or_deleted().0) + } + + /// Performs the following transformation on all tags in the group: + /// - `EMPTY => EMPTY` + /// - `DELETED => EMPTY` + /// - `FULL => DELETED` + #[inline] + pub(crate) fn convert_special_to_empty_and_full_to_deleted(self) -> Self { + // Map high_bit = 1 (EMPTY or DELETED) to 1111_1111 + // and high_bit = 0 (FULL) to 1000_0000 + // + // Here's this logic expanded to concrete values: + // let special = 0 > tag = 1111_1111 (true) or 0000_0000 (false) + // 1111_1111 | 1000_0000 = 1111_1111 + // 0000_0000 | 1000_0000 = 1000_0000 + #[expect( + clippy::cast_possible_wrap, // tag: Tag::DELETED.0 as i8 + )] + unsafe { + let zero = x86::_mm_setzero_si128(); + let special = x86::_mm_cmpgt_epi8(zero, self.0); + Group(x86::_mm_or_si128( + special, + x86::_mm_set1_epi8(Tag::DELETED.0 as i8), + )) + } + } +} diff --git a/library/hashbrown/src/control/mod.rs b/library/hashbrown/src/control/mod.rs new file mode 100644 index 0000000000000..62ef8bfcc9bcc --- /dev/null +++ b/library/hashbrown/src/control/mod.rs @@ -0,0 +1,10 @@ +mod bitmask; +mod group; +mod tag; + +use self::bitmask::BitMask; +pub(crate) use self::{ + bitmask::BitMaskIter, + group::Group, + tag::{Tag, TagSliceExt}, +}; diff --git a/library/hashbrown/src/control/tag.rs b/library/hashbrown/src/control/tag.rs new file mode 100644 index 0000000000000..d40fb2c60a891 --- /dev/null +++ b/library/hashbrown/src/control/tag.rs @@ -0,0 +1,82 @@ +use core::{fmt, mem}; + +/// Single tag in a control group. +#[derive(Copy, Clone, PartialEq, Eq)] +#[repr(transparent)] +pub(crate) struct Tag(pub(super) u8); +impl Tag { + /// Control tag value for an empty bucket. + pub(crate) const EMPTY: Tag = Tag(0b1111_1111); + + /// Control tag value for a deleted bucket. + pub(crate) const DELETED: Tag = Tag(0b1000_0000); + + /// Checks whether a control tag represents a full bucket (top bit is clear). + #[inline] + pub(crate) const fn is_full(self) -> bool { + self.0 & 0x80 == 0 + } + + /// Checks whether a control tag represents a special value (top bit is set). + #[inline] + pub(crate) const fn is_special(self) -> bool { + self.0 & 0x80 != 0 + } + + /// Checks whether a special control value is EMPTY (just check 1 bit). + #[inline] + pub(crate) const fn special_is_empty(self) -> bool { + debug_assert!(self.is_special()); + self.0 & 0x01 != 0 + } + + /// Creates a control tag representing a full bucket with the given hash. + #[inline] + pub(crate) const fn full(hash: u64) -> Tag { + // Constant for function that grabs the top 7 bits of the hash. + const MIN_HASH_LEN: usize = if size_of::() < size_of::() { + size_of::() + } else { + size_of::() + }; + + // Grab the top 7 bits of the hash. While the hash is normally a full 64-bit + // value, some hash functions (such as FxHash) produce a usize result + // instead, which means that the top 32 bits are 0 on 32-bit platforms. + // So we use MIN_HASH_LEN constant to handle this. + let top7 = hash >> (MIN_HASH_LEN * 8 - 7); + Tag((top7 & 0x7f) as u8) // truncation + } +} +impl fmt::Debug for Tag { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.is_special() { + if self.special_is_empty() { + f.pad("EMPTY") + } else { + f.pad("DELETED") + } + } else { + f.debug_tuple("full").field(&(self.0 & 0x7F)).finish() + } + } +} + +/// Extension trait for slices of tags. +pub(crate) trait TagSliceExt { + /// Fills the control with the given tag. + fn fill_tag(&mut self, tag: Tag); + + /// Clears out the control. + #[inline] + fn fill_empty(&mut self) { + self.fill_tag(Tag::EMPTY); + } +} +impl TagSliceExt for [mem::MaybeUninit] { + #[inline] + fn fill_tag(&mut self, tag: Tag) { + // SAFETY: We have access to the entire slice, so, we can write to the entire slice. + unsafe { self.as_mut_ptr().write_bytes(tag.0, self.len()) } + } +} diff --git a/library/hashbrown/src/external_trait_impls/mod.rs b/library/hashbrown/src/external_trait_impls/mod.rs new file mode 100644 index 0000000000000..ef497836cb989 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/mod.rs @@ -0,0 +1,4 @@ +#[cfg(feature = "rayon")] +pub(crate) mod rayon; +#[cfg(feature = "serde")] +mod serde; diff --git a/library/hashbrown/src/external_trait_impls/rayon/helpers.rs b/library/hashbrown/src/external_trait_impls/rayon/helpers.rs new file mode 100644 index 0000000000000..b8fb43a37af3b --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/helpers.rs @@ -0,0 +1,13 @@ +use stdalloc::collections::LinkedList; +use stdalloc::vec::Vec; + +use rayon::iter::{IntoParallelIterator, ParallelIterator}; + +/// Helper for collecting parallel iterators to an intermediary +#[expect(clippy::linkedlist)] // yes, we need linked list here for efficient appending! +pub(super) fn collect(iter: I) -> (LinkedList>, usize) { + let list = iter.into_par_iter().collect_vec_list(); + + let len = list.iter().map(Vec::len).sum(); + (list, len) +} diff --git a/library/hashbrown/src/external_trait_impls/rayon/map.rs b/library/hashbrown/src/external_trait_impls/rayon/map.rs new file mode 100644 index 0000000000000..1a33c5ff308e4 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/map.rs @@ -0,0 +1,713 @@ +//! Rayon extensions for `HashMap`. + +use super::raw::{RawIntoParIter, RawParDrain, RawParIter}; +use crate::HashMap; +use crate::alloc::{Allocator, Global}; +use core::fmt; +use core::hash::{BuildHasher, Hash}; +use core::marker::PhantomData; +use rayon::iter::plumbing::UnindexedConsumer; +use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, ParallelIterator}; + +/// Parallel iterator over shared references to entries in a map. +/// +/// This iterator is created by the [`par_iter`] method on [`HashMap`] +/// (provided by the [`IntoParallelRefIterator`] trait). +/// See its documentation for more. +/// +/// [`par_iter`]: rayon::iter::IntoParallelRefIterator::par_iter +/// [`IntoParallelRefIterator`]: rayon::iter::IntoParallelRefIterator +pub struct ParIter<'a, K, V> { + inner: RawParIter<(K, V)>, + marker: PhantomData<(&'a K, &'a V)>, +} + +impl<'a, K: Sync, V: Sync> ParallelIterator for ParIter<'a, K, V> { + type Item = (&'a K, &'a V); + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { + let r = x.as_ref(); + (&r.0, &r.1) + }) + .drive_unindexed(consumer) + } +} + +impl Clone for ParIter<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for ParIter<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let iter = unsafe { self.inner.iter() }.map(|x| unsafe { + let r = x.as_ref(); + (&r.0, &r.1) + }); + f.debug_list().entries(iter).finish() + } +} + +/// Parallel iterator over shared references to keys in a map. +/// +/// This iterator is created by the [`par_keys`] method on [`HashMap`]. +/// See its documentation for more. +/// +/// [`par_keys`]: HashMap::par_keys +pub struct ParKeys<'a, K, V> { + inner: RawParIter<(K, V)>, + marker: PhantomData<(&'a K, &'a V)>, +} + +impl<'a, K: Sync, V: Sync> ParallelIterator for ParKeys<'a, K, V> { + type Item = &'a K; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { &x.as_ref().0 }) + .drive_unindexed(consumer) + } +} + +impl Clone for ParKeys<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for ParKeys<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let iter = unsafe { self.inner.iter() }.map(|x| unsafe { &x.as_ref().0 }); + f.debug_list().entries(iter).finish() + } +} + +/// Parallel iterator over shared references to values in a map. +/// +/// This iterator is created by the [`par_values`] method on [`HashMap`]. +/// See its documentation for more. +/// +/// [`par_values`]: HashMap::par_values +pub struct ParValues<'a, K, V> { + inner: RawParIter<(K, V)>, + marker: PhantomData<(&'a K, &'a V)>, +} + +impl<'a, K: Sync, V: Sync> ParallelIterator for ParValues<'a, K, V> { + type Item = &'a V; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { &x.as_ref().1 }) + .drive_unindexed(consumer) + } +} + +impl Clone for ParValues<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for ParValues<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let iter = unsafe { self.inner.iter() }.map(|x| unsafe { &x.as_ref().1 }); + f.debug_list().entries(iter).finish() + } +} + +/// Parallel iterator over mutable references to entries in a map. +/// +/// This iterator is created by the [`par_iter_mut`] method on [`HashMap`] +/// (provided by the [`IntoParallelRefMutIterator`] trait). +/// See its documentation for more. +/// +/// [`par_iter_mut`]: rayon::iter::IntoParallelRefMutIterator::par_iter_mut +/// [`IntoParallelRefMutIterator`]: rayon::iter::IntoParallelRefMutIterator +pub struct ParIterMut<'a, K, V> { + inner: RawParIter<(K, V)>, + marker: PhantomData<(&'a K, &'a mut V)>, +} + +impl<'a, K: Sync, V: Send> ParallelIterator for ParIterMut<'a, K, V> { + type Item = (&'a K, &'a mut V); + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { + let r = x.as_mut(); + (&r.0, &mut r.1) + }) + .drive_unindexed(consumer) + } +} + +impl fmt::Debug for ParIterMut<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: self.inner.clone(), + marker: PhantomData, + } + .fmt(f) + } +} + +/// Parallel iterator over mutable references to values in a map. +/// +/// This iterator is created by the [`par_values_mut`] method on [`HashMap`]. +/// See its documentation for more. +/// +/// [`par_values_mut`]: HashMap::par_values_mut +pub struct ParValuesMut<'a, K, V> { + inner: RawParIter<(K, V)>, + marker: PhantomData<(&'a K, &'a mut V)>, +} + +impl<'a, K: Sync, V: Send> ParallelIterator for ParValuesMut<'a, K, V> { + type Item = &'a mut V; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { &mut x.as_mut().1 }) + .drive_unindexed(consumer) + } +} + +impl fmt::Debug for ParValuesMut<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParValues { + inner: self.inner.clone(), + marker: PhantomData, + } + .fmt(f) + } +} + +/// Parallel iterator over entries of a consumed map. +/// +/// This iterator is created by the [`into_par_iter`] method on [`HashMap`] +/// (provided by the [`IntoParallelIterator`] trait). +/// See its documentation for more. +/// +/// [`into_par_iter`]: HashMap::into_par_iter +pub struct IntoParIter { + inner: RawIntoParIter<(K, V), A>, +} + +impl ParallelIterator for IntoParIter { + type Item = (K, V); + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.drive_unindexed(consumer) + } +} + +impl fmt::Debug for IntoParIter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: unsafe { self.inner.par_iter() }, + marker: PhantomData, + } + .fmt(f) + } +} + +/// Parallel draining iterator over entries of a map. +/// +/// This iterator is created by the [`par_drain`] method on [`HashMap`]. +/// See its documentation for more. +/// +/// [`par_drain`]: HashMap::par_drain +pub struct ParDrain<'a, K, V, A: Allocator = Global> { + inner: RawParDrain<'a, (K, V), A>, +} + +impl ParallelIterator for ParDrain<'_, K, V, A> { + type Item = (K, V); + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.drive_unindexed(consumer) + } +} + +impl fmt::Debug for ParDrain<'_, K, V, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: unsafe { self.inner.par_iter() }, + marker: PhantomData, + } + .fmt(f) + } +} + +impl HashMap { + /// Visits (potentially in parallel) immutably borrowed keys in an arbitrary order. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_keys(&self) -> ParKeys<'_, K, V> { + ParKeys { + inner: unsafe { self.table.par_iter() }, + marker: PhantomData, + } + } + + /// Visits (potentially in parallel) immutably borrowed values in an arbitrary order. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_values(&self) -> ParValues<'_, K, V> { + ParValues { + inner: unsafe { self.table.par_iter() }, + marker: PhantomData, + } + } +} + +impl HashMap { + /// Visits (potentially in parallel) mutably borrowed values in an arbitrary order. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_values_mut(&mut self) -> ParValuesMut<'_, K, V> { + ParValuesMut { + inner: unsafe { self.table.par_iter() }, + marker: PhantomData, + } + } + + /// Consumes (potentially in parallel) all values in an arbitrary order, + /// while preserving the map's allocated memory for reuse. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_drain(&mut self) -> ParDrain<'_, K, V, A> { + ParDrain { + inner: self.table.par_drain(), + } + } +} + +impl HashMap +where + K: Eq + Hash + Sync, + V: PartialEq + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + /// Returns `true` if the map is equal to another, + /// i.e. both maps contain the same keys mapped to the same values. + /// + /// This method runs in a potentially parallel fashion. + pub fn par_eq(&self, other: &Self) -> bool { + self.len() == other.len() + && self + .into_par_iter() + .all(|(key, value)| other.get(key).is_some_and(|v| *value == *v)) + } +} + +impl IntoParallelIterator for HashMap { + type Item = (K, V); + type Iter = IntoParIter; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + IntoParIter { + inner: self.table.into_par_iter(), + } + } +} + +impl<'a, K: Sync, V: Sync, S, A: Allocator> IntoParallelIterator for &'a HashMap { + type Item = (&'a K, &'a V); + type Iter = ParIter<'a, K, V>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + ParIter { + inner: unsafe { self.table.par_iter() }, + marker: PhantomData, + } + } +} + +impl<'a, K: Sync, V: Send, S, A: Allocator> IntoParallelIterator for &'a mut HashMap { + type Item = (&'a K, &'a mut V); + type Iter = ParIterMut<'a, K, V>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + ParIterMut { + inner: unsafe { self.table.par_iter() }, + marker: PhantomData, + } + } +} + +/// Collect (key, value) pairs from a parallel iterator into a +/// hashmap. If multiple pairs correspond to the same key, then the +/// ones produced earlier in the parallel iterator will be +/// overwritten, just as with a sequential iterator. +impl FromParallelIterator<(K, V)> for HashMap +where + K: Eq + Hash + Send, + V: Send, + S: BuildHasher + Default, +{ + fn from_par_iter

(par_iter: P) -> Self + where + P: IntoParallelIterator, + { + let mut map = HashMap::default(); + map.par_extend(par_iter); + map + } +} + +/// Extend a hash map with items from a parallel iterator. +impl ParallelExtend<(K, V)> for HashMap +where + K: Eq + Hash + Send, + V: Send, + S: BuildHasher, + A: Allocator, +{ + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator, + { + extend(self, par_iter); + } +} + +/// Extend a hash map with copied items from a parallel iterator. +impl<'a, K, V, S, A> ParallelExtend<(&'a K, &'a V)> for HashMap +where + K: Copy + Eq + Hash + Sync, + V: Copy + Sync, + S: BuildHasher, + A: Allocator, +{ + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator, + { + extend(self, par_iter); + } +} + +// This is equal to the normal `HashMap` -- no custom advantage. +fn extend(map: &mut HashMap, par_iter: I) +where + K: Eq + Hash, + S: BuildHasher, + I: IntoParallelIterator, + A: Allocator, + HashMap: Extend, +{ + let (list, len) = super::helpers::collect(par_iter); + + // Keys may be already present or show multiple times in the iterator. + // Reserve the entire length if the map is empty. + // Otherwise reserve half the length (rounded up), so the map + // will only resize twice in the worst case. + let reserve = if map.is_empty() { len } else { len.div_ceil(2) }; + map.reserve(reserve); + for vec in list { + map.extend(vec); + } +} + +#[cfg(test)] +mod test_par_map { + use core::hash::{Hash, Hasher}; + use core::sync::atomic::{AtomicUsize, Ordering}; + use stdalloc::vec::Vec; + + use rayon::prelude::*; + + use crate::HashMap; + + struct Droppable<'a> { + k: usize, + counter: &'a AtomicUsize, + } + + impl Droppable<'_> { + fn new(k: usize, counter: &AtomicUsize) -> Droppable<'_> { + counter.fetch_add(1, Ordering::Relaxed); + + Droppable { k, counter } + } + } + + impl Drop for Droppable<'_> { + fn drop(&mut self) { + self.counter.fetch_sub(1, Ordering::Relaxed); + } + } + + impl Clone for Droppable<'_> { + fn clone(&self) -> Self { + Droppable::new(self.k, self.counter) + } + } + + impl Hash for Droppable<'_> { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.k.hash(state); + } + } + + impl PartialEq for Droppable<'_> { + fn eq(&self, other: &Self) -> bool { + self.k == other.k + } + } + + impl Eq for Droppable<'_> {} + + #[test] + fn test_into_iter_drops() { + let key = AtomicUsize::new(0); + let value = AtomicUsize::new(0); + + let hm = { + let mut hm = HashMap::new(); + + assert_eq!(key.load(Ordering::Relaxed), 0); + assert_eq!(value.load(Ordering::Relaxed), 0); + + for i in 0..100 { + let d1 = Droppable::new(i, &key); + let d2 = Droppable::new(i + 100, &value); + hm.insert(d1, d2); + } + + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + hm + }; + + // By the way, ensure that cloning doesn't screw up the dropping. + drop(hm.clone()); + + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + // Ensure that dropping the iterator does not leak anything. + drop(hm.clone().into_par_iter()); + + { + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + // retain only half + let _v: Vec<_> = hm.into_par_iter().filter(|(key, _)| key.k < 50).collect(); + + assert_eq!(key.load(Ordering::Relaxed), 50); + assert_eq!(value.load(Ordering::Relaxed), 50); + }; + + assert_eq!(key.load(Ordering::Relaxed), 0); + assert_eq!(value.load(Ordering::Relaxed), 0); + } + + #[test] + fn test_drain_drops() { + let key = AtomicUsize::new(0); + let value = AtomicUsize::new(0); + + let mut hm = { + let mut hm = HashMap::new(); + + assert_eq!(key.load(Ordering::Relaxed), 0); + assert_eq!(value.load(Ordering::Relaxed), 0); + + for i in 0..100 { + let d1 = Droppable::new(i, &key); + let d2 = Droppable::new(i + 100, &value); + hm.insert(d1, d2); + } + + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + hm + }; + + // By the way, ensure that cloning doesn't screw up the dropping. + drop(hm.clone()); + + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + // Ensure that dropping the drain iterator does not leak anything. + drop(hm.clone().par_drain()); + + { + assert_eq!(key.load(Ordering::Relaxed), 100); + assert_eq!(value.load(Ordering::Relaxed), 100); + + // retain only half + let _v: Vec<_> = hm.drain().filter(|(key, _)| key.k < 50).collect(); + assert!(hm.is_empty()); + + assert_eq!(key.load(Ordering::Relaxed), 50); + assert_eq!(value.load(Ordering::Relaxed), 50); + }; + + assert_eq!(key.load(Ordering::Relaxed), 0); + assert_eq!(value.load(Ordering::Relaxed), 0); + } + + #[test] + fn test_empty_iter() { + let mut m: HashMap = HashMap::new(); + assert_eq!(m.par_drain().count(), 0); + assert_eq!(m.par_keys().count(), 0); + assert_eq!(m.par_values().count(), 0); + assert_eq!(m.par_values_mut().count(), 0); + assert_eq!(m.par_iter().count(), 0); + assert_eq!(m.par_iter_mut().count(), 0); + assert_eq!(m.len(), 0); + assert!(m.is_empty()); + assert_eq!(m.into_par_iter().count(), 0); + } + + #[test] + fn test_iterate() { + let mut m = HashMap::with_capacity(4); + for i in 0..32 { + assert!(m.insert(i, i * 2).is_none()); + } + assert_eq!(m.len(), 32); + + let observed = AtomicUsize::new(0); + + m.par_iter().for_each(|(k, v)| { + assert_eq!(*v, *k * 2); + observed.fetch_or(1 << *k, Ordering::Relaxed); + }); + assert_eq!(observed.into_inner(), 0xFFFF_FFFF); + } + + #[test] + fn test_keys() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_par_iter().collect(); + let keys: Vec<_> = map.par_keys().cloned().collect(); + assert_eq!(keys.len(), 3); + assert!(keys.contains(&1)); + assert!(keys.contains(&2)); + assert!(keys.contains(&3)); + } + + #[test] + fn test_values() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_par_iter().collect(); + let values: Vec<_> = map.par_values().cloned().collect(); + assert_eq!(values.len(), 3); + assert!(values.contains(&'a')); + assert!(values.contains(&'b')); + assert!(values.contains(&'c')); + } + + #[test] + fn test_values_mut() { + let vec = vec![(1, 1), (2, 2), (3, 3)]; + let mut map: HashMap<_, _> = vec.into_par_iter().collect(); + map.par_values_mut().for_each(|value| *value *= 2); + let values: Vec<_> = map.par_values().cloned().collect(); + assert_eq!(values.len(), 3); + assert!(values.contains(&2)); + assert!(values.contains(&4)); + assert!(values.contains(&6)); + } + + #[test] + fn test_eq() { + let mut m1 = HashMap::new(); + m1.insert(1, 2); + m1.insert(2, 3); + m1.insert(3, 4); + + let mut m2 = HashMap::new(); + m2.insert(1, 2); + m2.insert(2, 3); + + assert!(!m1.par_eq(&m2)); + + m2.insert(3, 4); + + assert!(m1.par_eq(&m2)); + } + + #[test] + fn test_from_iter() { + let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let map: HashMap<_, _> = xs.par_iter().cloned().collect(); + + for &(k, v) in &xs { + assert_eq!(map.get(&k), Some(&v)); + } + } + + #[test] + fn test_extend_ref() { + let mut a = HashMap::new(); + a.insert(1, "one"); + let mut b = HashMap::new(); + b.insert(2, "two"); + b.insert(3, "three"); + + a.par_extend(&b); + + assert_eq!(a.len(), 3); + assert_eq!(a[&1], "one"); + assert_eq!(a[&2], "two"); + assert_eq!(a[&3], "three"); + } +} diff --git a/library/hashbrown/src/external_trait_impls/rayon/mod.rs b/library/hashbrown/src/external_trait_impls/rayon/mod.rs new file mode 100644 index 0000000000000..61ca69b61d7f2 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/mod.rs @@ -0,0 +1,5 @@ +mod helpers; +pub(crate) mod map; +pub(crate) mod raw; +pub(crate) mod set; +pub(crate) mod table; diff --git a/library/hashbrown/src/external_trait_impls/rayon/raw.rs b/library/hashbrown/src/external_trait_impls/rayon/raw.rs new file mode 100644 index 0000000000000..b8fc069d02531 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/raw.rs @@ -0,0 +1,232 @@ +use crate::alloc::{Allocator, Global}; +use crate::raw::{Bucket, RawIter, RawIterRange, RawTable}; +use crate::scopeguard::guard; +use core::marker::PhantomData; +use core::mem; +use core::ptr::NonNull; +use rayon::iter::{ + ParallelIterator, + plumbing::{self, Folder, UnindexedConsumer, UnindexedProducer}, +}; + +/// Parallel iterator which returns a raw pointer to every full bucket in the table. +pub(crate) struct RawParIter { + iter: RawIterRange, +} + +impl RawParIter { + #[cfg_attr(feature = "inline-more", inline)] + pub(super) unsafe fn iter(&self) -> RawIterRange { + self.iter.clone() + } +} + +impl Clone for RawParIter { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + iter: self.iter.clone(), + } + } +} + +impl From> for RawParIter { + fn from(it: RawIter) -> Self { + RawParIter { iter: it.iter } + } +} + +impl ParallelIterator for RawParIter { + type Item = Bucket; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let producer = ParIterProducer { iter: self.iter }; + plumbing::bridge_unindexed(producer, consumer) + } +} + +/// Producer which returns a `Bucket` for every element. +struct ParIterProducer { + iter: RawIterRange, +} + +impl UnindexedProducer for ParIterProducer { + type Item = Bucket; + + #[cfg_attr(feature = "inline-more", inline)] + fn split(self) -> (Self, Option) { + let (left, right) = self.iter.split(); + let left = ParIterProducer { iter: left }; + let right = right.map(|right| ParIterProducer { iter: right }); + (left, right) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold_with(self, folder: F) -> F + where + F: Folder, + { + folder.consume_iter(self.iter) + } +} + +/// Parallel iterator which consumes a table and returns elements. +pub(crate) struct RawIntoParIter { + table: RawTable, +} + +impl RawIntoParIter { + #[cfg_attr(feature = "inline-more", inline)] + pub(super) unsafe fn par_iter(&self) -> RawParIter { + unsafe { self.table.par_iter() } + } +} + +impl ParallelIterator for RawIntoParIter { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let iter = unsafe { self.table.iter().iter }; + let _guard = guard(self.table.into_allocation(), |alloc| { + if let Some((ptr, layout, ref alloc)) = *alloc { + unsafe { + alloc.deallocate(ptr, layout); + } + } + }); + let producer = ParDrainProducer { iter }; + plumbing::bridge_unindexed(producer, consumer) + } +} + +/// Parallel iterator which consumes elements without freeing the table storage. +pub(crate) struct RawParDrain<'a, T, A: Allocator = Global> { + // We don't use a &'a mut RawTable because we want RawParDrain to be + // covariant over T. + table: NonNull>, + marker: PhantomData<&'a RawTable>, +} + +unsafe impl Send for RawParDrain<'_, T, A> {} + +impl RawParDrain<'_, T, A> { + #[cfg_attr(feature = "inline-more", inline)] + pub(super) unsafe fn par_iter(&self) -> RawParIter { + unsafe { self.table.as_ref().par_iter() } + } +} + +impl ParallelIterator for RawParDrain<'_, T, A> { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let _guard = guard(self.table, |table| unsafe { + table.as_mut().clear_no_drop(); + }); + let iter = unsafe { self.table.as_ref().iter().iter }; + mem::forget(self); + let producer = ParDrainProducer { iter }; + plumbing::bridge_unindexed(producer, consumer) + } +} + +impl Drop for RawParDrain<'_, T, A> { + fn drop(&mut self) { + // If drive_unindexed is not called then simply clear the table. + unsafe { + self.table.as_mut().clear(); + } + } +} + +/// Producer which will consume all elements in the range, even if it is dropped +/// halfway through. +struct ParDrainProducer { + iter: RawIterRange, +} + +impl UnindexedProducer for ParDrainProducer { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn split(self) -> (Self, Option) { + let (left, right) = self.iter.clone().split(); + mem::forget(self); + let left = ParDrainProducer { iter: left }; + let right = right.map(|right| ParDrainProducer { iter: right }); + (left, right) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold_with(mut self, mut folder: F) -> F + where + F: Folder, + { + // Make sure to modify the iterator in-place so that any remaining + // elements are processed in our Drop impl. + for item in &mut self.iter { + folder = folder.consume(unsafe { item.read() }); + if folder.full() { + return folder; + } + } + + // If we processed all elements then we don't need to run the drop. + mem::forget(self); + folder + } +} + +impl Drop for ParDrainProducer { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + // Drop all remaining elements + if mem::needs_drop::() { + for item in &mut self.iter { + unsafe { + item.drop(); + } + } + } + } +} + +impl RawTable { + /// Returns a parallel iterator over the elements in a `RawTable`. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn par_iter(&self) -> RawParIter { + unsafe { + RawParIter { + iter: self.iter().iter, + } + } + } + + /// Returns a parallel iterator over the elements in a `RawTable`. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn into_par_iter(self) -> RawIntoParIter { + RawIntoParIter { table: self } + } + + /// Returns a parallel iterator which consumes all elements of a `RawTable` + /// without freeing its memory allocation. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn par_drain(&mut self) -> RawParDrain<'_, T, A> { + RawParDrain { + table: NonNull::from(self), + marker: PhantomData, + } + } +} diff --git a/library/hashbrown/src/external_trait_impls/rayon/set.rs b/library/hashbrown/src/external_trait_impls/rayon/set.rs new file mode 100644 index 0000000000000..205d2e0b10042 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/set.rs @@ -0,0 +1,652 @@ +//! Rayon extensions for `HashSet`. + +use super::map; +use crate::HashSet; +use crate::alloc::{Allocator, Global}; +use core::hash::{BuildHasher, Hash}; +use rayon::iter::plumbing::UnindexedConsumer; +use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelExtend, ParallelIterator}; + +/// Parallel iterator over elements of a consumed set. +/// +/// This iterator is created by the [`into_par_iter`] method on [`HashSet`] +/// (provided by the [`IntoParallelIterator`] trait). +/// See its documentation for more. +/// +/// [`into_par_iter`]: rayon::iter::IntoParallelIterator::into_par_iter +/// [`IntoParallelIterator`]: rayon::iter::IntoParallelIterator +pub struct IntoParIter { + inner: map::IntoParIter, +} + +impl ParallelIterator for IntoParIter { + type Item = T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.map(|(k, _)| k).drive_unindexed(consumer) + } +} + +/// Parallel draining iterator over entries of a set. +/// +/// This iterator is created by the [`par_drain`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`par_drain`]: HashSet::par_drain +pub struct ParDrain<'a, T, A: Allocator = Global> { + inner: map::ParDrain<'a, T, (), A>, +} + +impl ParallelIterator for ParDrain<'_, T, A> { + type Item = T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.map(|(k, _)| k).drive_unindexed(consumer) + } +} + +/// Parallel iterator over shared references to elements in a set. +/// +/// This iterator is created by the [`par_iter`] method on [`HashSet`] +/// (provided by the [`IntoParallelRefIterator`] trait). +/// See its documentation for more. +/// +/// [`par_iter`]: rayon::iter::IntoParallelRefIterator::par_iter +/// [`IntoParallelRefIterator`]: rayon::iter::IntoParallelRefIterator +pub struct ParIter<'a, T> { + inner: map::ParKeys<'a, T, ()>, +} + +impl<'a, T: Sync> ParallelIterator for ParIter<'a, T> { + type Item = &'a T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.drive_unindexed(consumer) + } +} + +/// Parallel iterator over shared references to elements in the difference of +/// sets. +/// +/// This iterator is created by the [`par_difference`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`par_difference`]: HashSet::par_difference +pub struct ParDifference<'a, T, S, A: Allocator = Global> { + a: &'a HashSet, + b: &'a HashSet, +} + +impl<'a, T, S, A> ParallelIterator for ParDifference<'a, T, S, A> +where + T: Eq + Hash + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + type Item = &'a T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.a + .into_par_iter() + .filter(|&x| !self.b.contains(x)) + .drive_unindexed(consumer) + } +} + +/// Parallel iterator over shared references to elements in the symmetric +/// difference of sets. +/// +/// This iterator is created by the [`par_symmetric_difference`] method on +/// [`HashSet`]. +/// See its documentation for more. +/// +/// [`par_symmetric_difference`]: HashSet::par_symmetric_difference +pub struct ParSymmetricDifference<'a, T, S, A: Allocator = Global> { + a: &'a HashSet, + b: &'a HashSet, +} + +impl<'a, T, S, A> ParallelIterator for ParSymmetricDifference<'a, T, S, A> +where + T: Eq + Hash + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + type Item = &'a T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.a + .par_difference(self.b) + .chain(self.b.par_difference(self.a)) + .drive_unindexed(consumer) + } +} + +/// Parallel iterator over shared references to elements in the intersection of +/// sets. +/// +/// This iterator is created by the [`par_intersection`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`par_intersection`]: HashSet::par_intersection +pub struct ParIntersection<'a, T, S, A: Allocator = Global> { + a: &'a HashSet, + b: &'a HashSet, +} + +impl<'a, T, S, A> ParallelIterator for ParIntersection<'a, T, S, A> +where + T: Eq + Hash + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + type Item = &'a T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.a + .into_par_iter() + .filter(|&x| self.b.contains(x)) + .drive_unindexed(consumer) + } +} + +/// Parallel iterator over shared references to elements in the union of sets. +/// +/// This iterator is created by the [`par_union`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`par_union`]: HashSet::par_union +pub struct ParUnion<'a, T, S, A: Allocator = Global> { + a: &'a HashSet, + b: &'a HashSet, +} + +impl<'a, T, S, A> ParallelIterator for ParUnion<'a, T, S, A> +where + T: Eq + Hash + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + type Item = &'a T; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + // We'll iterate one set in full, and only the remaining difference from the other. + // Use the smaller set for the difference in order to reduce hash lookups. + let (smaller, larger) = if self.a.len() <= self.b.len() { + (self.a, self.b) + } else { + (self.b, self.a) + }; + larger + .into_par_iter() + .chain(smaller.par_difference(larger)) + .drive_unindexed(consumer) + } +} + +impl HashSet +where + T: Eq + Hash + Sync, + S: BuildHasher + Sync, + A: Allocator + Sync, +{ + /// Visits (potentially in parallel) the values representing the union, + /// i.e. all the values in `self` or `other`, without duplicates. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_union<'a>(&'a self, other: &'a Self) -> ParUnion<'a, T, S, A> { + ParUnion { a: self, b: other } + } + + /// Visits (potentially in parallel) the values representing the difference, + /// i.e. the values that are in `self` but not in `other`. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_difference<'a>(&'a self, other: &'a Self) -> ParDifference<'a, T, S, A> { + ParDifference { a: self, b: other } + } + + /// Visits (potentially in parallel) the values representing the symmetric + /// difference, i.e. the values that are in `self` or in `other` but not in both. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_symmetric_difference<'a>( + &'a self, + other: &'a Self, + ) -> ParSymmetricDifference<'a, T, S, A> { + ParSymmetricDifference { a: self, b: other } + } + + /// Visits (potentially in parallel) the values representing the + /// intersection, i.e. the values that are both in `self` and `other`. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_intersection<'a>(&'a self, other: &'a Self) -> ParIntersection<'a, T, S, A> { + ParIntersection { a: self, b: other } + } + + /// Returns `true` if `self` has no elements in common with `other`. + /// This is equivalent to checking for an empty intersection. + /// + /// This method runs in a potentially parallel fashion. + pub fn par_is_disjoint(&self, other: &Self) -> bool { + self.into_par_iter().all(|x| !other.contains(x)) + } + + /// Returns `true` if the set is a subset of another, + /// i.e. `other` contains at least all the values in `self`. + /// + /// This method runs in a potentially parallel fashion. + pub fn par_is_subset(&self, other: &Self) -> bool { + if self.len() <= other.len() { + self.into_par_iter().all(|x| other.contains(x)) + } else { + false + } + } + + /// Returns `true` if the set is a superset of another, + /// i.e. `self` contains at least all the values in `other`. + /// + /// This method runs in a potentially parallel fashion. + pub fn par_is_superset(&self, other: &Self) -> bool { + other.par_is_subset(self) + } + + /// Returns `true` if the set is equal to another, + /// i.e. both sets contain the same values. + /// + /// This method runs in a potentially parallel fashion. + pub fn par_eq(&self, other: &Self) -> bool { + self.len() == other.len() && self.par_is_subset(other) + } +} + +impl HashSet +where + T: Eq + Hash + Send, + A: Allocator + Send, +{ + /// Consumes (potentially in parallel) all values in an arbitrary order, + /// while preserving the set's allocated memory for reuse. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_drain(&mut self) -> ParDrain<'_, T, A> { + ParDrain { + inner: self.map.par_drain(), + } + } +} + +impl IntoParallelIterator for HashSet { + type Item = T; + type Iter = IntoParIter; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + IntoParIter { + inner: self.map.into_par_iter(), + } + } +} + +impl<'a, T: Sync, S, A: Allocator> IntoParallelIterator for &'a HashSet { + type Item = &'a T; + type Iter = ParIter<'a, T>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + ParIter { + inner: self.map.par_keys(), + } + } +} + +/// Collect values from a parallel iterator into a hashset. +impl FromParallelIterator for HashSet +where + T: Eq + Hash + Send, + S: BuildHasher + Default, +{ + fn from_par_iter

(par_iter: P) -> Self + where + P: IntoParallelIterator, + { + let mut set = HashSet::default(); + set.par_extend(par_iter); + set + } +} + +/// Extend a hash set with items from a parallel iterator. +impl ParallelExtend for HashSet +where + T: Eq + Hash + Send, + S: BuildHasher, +{ + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator, + { + extend(self, par_iter); + } +} + +/// Extend a hash set with copied items from a parallel iterator. +impl<'a, T, S> ParallelExtend<&'a T> for HashSet +where + T: 'a + Copy + Eq + Hash + Sync, + S: BuildHasher, +{ + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator, + { + extend(self, par_iter); + } +} + +// This is equal to the normal `HashSet` -- no custom advantage. +fn extend(set: &mut HashSet, par_iter: I) +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, + I: IntoParallelIterator, + HashSet: Extend, +{ + let (list, len) = super::helpers::collect(par_iter); + + // Values may be already present or show multiple times in the iterator. + // Reserve the entire length if the set is empty. + // Otherwise reserve half the length (rounded up), so the set + // will only resize twice in the worst case. + let reserve = if set.is_empty() { len } else { len.div_ceil(2) }; + set.reserve(reserve); + for vec in list { + set.extend(vec); + } +} + +#[cfg(test)] +mod test_par_set { + use core::sync::atomic::{AtomicUsize, Ordering}; + use stdalloc::vec::Vec; + + use rayon::prelude::*; + + use crate::HashSet; + + #[test] + fn test_disjoint() { + let mut xs = HashSet::new(); + let mut ys = HashSet::new(); + assert!(xs.par_is_disjoint(&ys)); + assert!(ys.par_is_disjoint(&xs)); + assert!(xs.insert(5)); + assert!(ys.insert(11)); + assert!(xs.par_is_disjoint(&ys)); + assert!(ys.par_is_disjoint(&xs)); + assert!(xs.insert(7)); + assert!(xs.insert(19)); + assert!(xs.insert(4)); + assert!(ys.insert(2)); + assert!(ys.insert(-11)); + assert!(xs.par_is_disjoint(&ys)); + assert!(ys.par_is_disjoint(&xs)); + assert!(ys.insert(7)); + assert!(!xs.par_is_disjoint(&ys)); + assert!(!ys.par_is_disjoint(&xs)); + } + + #[test] + fn test_subset_and_superset() { + let mut a = HashSet::new(); + assert!(a.insert(0)); + assert!(a.insert(5)); + assert!(a.insert(11)); + assert!(a.insert(7)); + + let mut b = HashSet::new(); + assert!(b.insert(0)); + assert!(b.insert(7)); + assert!(b.insert(19)); + assert!(b.insert(250)); + assert!(b.insert(11)); + assert!(b.insert(200)); + + assert!(!a.par_is_subset(&b)); + assert!(!a.par_is_superset(&b)); + assert!(!b.par_is_subset(&a)); + assert!(!b.par_is_superset(&a)); + + assert!(b.insert(5)); + + assert!(a.par_is_subset(&b)); + assert!(!a.par_is_superset(&b)); + assert!(!b.par_is_subset(&a)); + assert!(b.par_is_superset(&a)); + } + + #[test] + fn test_iterate() { + let mut a = HashSet::new(); + for i in 0..32 { + assert!(a.insert(i)); + } + let observed = AtomicUsize::new(0); + a.par_iter().for_each(|k| { + observed.fetch_or(1 << *k, Ordering::Relaxed); + }); + assert_eq!(observed.into_inner(), 0xFFFF_FFFF); + } + + #[test] + fn test_intersection() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(11)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(77)); + assert!(a.insert(103)); + assert!(a.insert(5)); + assert!(a.insert(-5)); + + assert!(b.insert(2)); + assert!(b.insert(11)); + assert!(b.insert(77)); + assert!(b.insert(-9)); + assert!(b.insert(-42)); + assert!(b.insert(5)); + assert!(b.insert(3)); + + let expected = [3, 5, 11, 77]; + let i = a + .par_intersection(&b) + .map(|x| { + assert!(expected.contains(x)); + 1 + }) + .sum::(); + assert_eq!(i, expected.len()); + } + + #[test] + fn test_difference() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + + assert!(b.insert(3)); + assert!(b.insert(9)); + + let expected = [1, 5, 11]; + let i = a + .par_difference(&b) + .map(|x| { + assert!(expected.contains(x)); + 1 + }) + .sum::(); + assert_eq!(i, expected.len()); + } + + #[test] + fn test_symmetric_difference() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + + assert!(b.insert(-2)); + assert!(b.insert(3)); + assert!(b.insert(9)); + assert!(b.insert(14)); + assert!(b.insert(22)); + + let expected = [-2, 1, 5, 11, 14, 22]; + let i = a + .par_symmetric_difference(&b) + .map(|x| { + assert!(expected.contains(x)); + 1 + }) + .sum::(); + assert_eq!(i, expected.len()); + } + + #[test] + fn test_union() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + assert!(a.insert(16)); + assert!(a.insert(19)); + assert!(a.insert(24)); + + assert!(b.insert(-2)); + assert!(b.insert(1)); + assert!(b.insert(5)); + assert!(b.insert(9)); + assert!(b.insert(13)); + assert!(b.insert(19)); + + let expected = [-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]; + let i = a + .par_union(&b) + .map(|x| { + assert!(expected.contains(x)); + 1 + }) + .sum::(); + assert_eq!(i, expected.len()); + } + + #[test] + fn test_from_iter() { + let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let set: HashSet<_> = xs.par_iter().cloned().collect(); + + for x in &xs { + assert!(set.contains(x)); + } + } + + #[test] + fn test_move_iter() { + let hs = { + let mut hs = HashSet::new(); + + hs.insert('a'); + hs.insert('b'); + + hs + }; + + let v = hs.into_par_iter().collect::>(); + assert!(v == ['a', 'b'] || v == ['b', 'a']); + } + + #[test] + fn test_eq() { + // These constants once happened to expose a bug in insert(). + // I'm keeping them around to prevent a regression. + let mut s1 = HashSet::new(); + + s1.insert(1); + s1.insert(2); + s1.insert(3); + + let mut s2 = HashSet::new(); + + s2.insert(1); + s2.insert(2); + + assert!(!s1.par_eq(&s2)); + + s2.insert(3); + + assert!(s1.par_eq(&s2)); + } + + #[test] + fn test_extend_ref() { + let mut a = HashSet::new(); + a.insert(1); + + a.par_extend(&[2, 3, 4][..]); + + assert_eq!(a.len(), 4); + assert!(a.contains(&1)); + assert!(a.contains(&2)); + assert!(a.contains(&3)); + assert!(a.contains(&4)); + + let mut b = HashSet::new(); + b.insert(5); + b.insert(6); + + a.par_extend(&b); + + assert_eq!(a.len(), 6); + assert!(a.contains(&1)); + assert!(a.contains(&2)); + assert!(a.contains(&3)); + assert!(a.contains(&4)); + assert!(a.contains(&5)); + assert!(a.contains(&6)); + } +} diff --git a/library/hashbrown/src/external_trait_impls/rayon/table.rs b/library/hashbrown/src/external_trait_impls/rayon/table.rs new file mode 100644 index 0000000000000..20298f40e4c3d --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/rayon/table.rs @@ -0,0 +1,245 @@ +//! Rayon extensions for `HashTable`. + +use super::raw::{RawIntoParIter, RawParDrain, RawParIter}; +use crate::HashTable; +use crate::alloc::{Allocator, Global}; +use core::fmt; +use core::marker::PhantomData; +use rayon::iter::plumbing::UnindexedConsumer; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; + +/// Parallel iterator over shared references to entries in a map. +/// +/// This iterator is created by the [`par_iter`] method on [`HashTable`] +/// (provided by the [`IntoParallelRefIterator`] trait). +/// See its documentation for more. +/// +/// [`par_iter`]: rayon::iter::IntoParallelRefIterator::par_iter +/// [`IntoParallelRefIterator`]: rayon::iter::IntoParallelRefIterator +pub struct ParIter<'a, T> { + inner: RawParIter, + marker: PhantomData<&'a T>, +} + +impl<'a, T: Sync> ParallelIterator for ParIter<'a, T> { + type Item = &'a T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { x.as_ref() }) + .drive_unindexed(consumer) + } +} + +impl Clone for ParIter<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for ParIter<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let iter = unsafe { self.inner.iter() }.map(|x| unsafe { x.as_ref() }); + f.debug_list().entries(iter).finish() + } +} + +/// Parallel iterator over mutable references to entries in a map. +/// +/// This iterator is created by the [`par_iter_mut`] method on [`HashTable`] +/// (provided by the [`IntoParallelRefMutIterator`] trait). +/// See its documentation for more. +/// +/// [`par_iter_mut`]: rayon::iter::IntoParallelRefMutIterator::par_iter_mut +/// [`IntoParallelRefMutIterator`]: rayon::iter::IntoParallelRefMutIterator +pub struct ParIterMut<'a, T> { + inner: RawParIter, + marker: PhantomData<&'a mut T>, +} + +impl<'a, T: Send> ParallelIterator for ParIterMut<'a, T> { + type Item = &'a mut T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner + .map(|x| unsafe { x.as_mut() }) + .drive_unindexed(consumer) + } +} + +impl fmt::Debug for ParIterMut<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: self.inner.clone(), + marker: PhantomData, + } + .fmt(f) + } +} + +/// Parallel iterator over entries of a consumed map. +/// +/// This iterator is created by the [`into_par_iter`] method on [`HashTable`] +/// (provided by the [`IntoParallelIterator`] trait). +/// See its documentation for more. +/// +/// [`into_par_iter`]: rayon::iter::IntoParallelIterator::into_par_iter +/// [`IntoParallelIterator`]: rayon::iter::IntoParallelIterator +pub struct IntoParIter { + inner: RawIntoParIter, +} + +impl ParallelIterator for IntoParIter { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.drive_unindexed(consumer) + } +} + +impl fmt::Debug for IntoParIter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: unsafe { self.inner.par_iter() }, + marker: PhantomData, + } + .fmt(f) + } +} + +/// Parallel draining iterator over entries of a map. +/// +/// This iterator is created by the [`par_drain`] method on [`HashTable`]. +/// See its documentation for more. +/// +/// [`par_drain`]: HashTable::par_drain +pub struct ParDrain<'a, T, A: Allocator = Global> { + inner: RawParDrain<'a, T, A>, +} + +impl ParallelIterator for ParDrain<'_, T, A> { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + self.inner.drive_unindexed(consumer) + } +} + +impl fmt::Debug for ParDrain<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ParIter { + inner: unsafe { self.inner.par_iter() }, + marker: PhantomData, + } + .fmt(f) + } +} + +impl HashTable { + /// Consumes (potentially in parallel) all values in an arbitrary order, + /// while preserving the map's allocated memory for reuse. + #[cfg_attr(feature = "inline-more", inline)] + pub fn par_drain(&mut self) -> ParDrain<'_, T, A> { + ParDrain { + inner: self.raw.par_drain(), + } + } +} + +impl IntoParallelIterator for HashTable { + type Item = T; + type Iter = IntoParIter; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + IntoParIter { + inner: self.raw.into_par_iter(), + } + } +} + +impl<'a, T: Sync, A: Allocator> IntoParallelIterator for &'a HashTable { + type Item = &'a T; + type Iter = ParIter<'a, T>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + ParIter { + inner: unsafe { self.raw.par_iter() }, + marker: PhantomData, + } + } +} + +impl<'a, T: Send, A: Allocator> IntoParallelIterator for &'a mut HashTable { + type Item = &'a mut T; + type Iter = ParIterMut<'a, T>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_par_iter(self) -> Self::Iter { + ParIterMut { + inner: unsafe { self.raw.par_iter() }, + marker: PhantomData, + } + } +} + +#[cfg(test)] +mod test_par_table { + use core::sync::atomic::{AtomicUsize, Ordering}; + use stdalloc::vec::Vec; + + use rayon::prelude::*; + + use crate::{DefaultHashBuilder, hash_map::make_hash, hash_table::HashTable}; + + #[test] + fn test_iterate() { + let hasher = DefaultHashBuilder::default(); + let mut a = HashTable::new(); + for i in 0..32 { + a.insert_unique(make_hash(&hasher, &i), i, |x| make_hash(&hasher, x)); + } + let observed = AtomicUsize::new(0); + a.par_iter().for_each(|k| { + observed.fetch_or(1 << *k, Ordering::Relaxed); + }); + assert_eq!(observed.into_inner(), 0xFFFF_FFFF); + } + + #[test] + fn test_move_iter() { + let hasher = DefaultHashBuilder::default(); + let hs = { + let mut hs = HashTable::new(); + + hs.insert_unique(make_hash(&hasher, &'a'), 'a', |x| make_hash(&hasher, x)); + hs.insert_unique(make_hash(&hasher, &'b'), 'b', |x| make_hash(&hasher, x)); + + hs + }; + + let v = hs.into_par_iter().collect::>(); + assert!(v == ['a', 'b'] || v == ['b', 'a']); + } +} diff --git a/library/hashbrown/src/external_trait_impls/serde.rs b/library/hashbrown/src/external_trait_impls/serde.rs new file mode 100644 index 0000000000000..f55eee4859020 --- /dev/null +++ b/library/hashbrown/src/external_trait_impls/serde.rs @@ -0,0 +1,219 @@ +mod size_hint { + use core::cmp; + + /// This presumably exists to prevent denial of service attacks. + /// + /// Original discussion: https://github.com/serde-rs/serde/issues/1114. + #[cfg_attr(feature = "inline-more", inline)] + pub(super) fn cautious(hint: Option) -> usize { + cmp::min(hint.unwrap_or(0), 4096) + } +} + +mod map { + use crate::alloc::Allocator; + use core::fmt; + use core::hash::{BuildHasher, Hash}; + use core::marker::PhantomData; + use serde_core::de::{Deserialize, Deserializer, MapAccess, Visitor}; + use serde_core::ser::{Serialize, Serializer}; + + use crate::HashMap; + + use super::size_hint; + + impl Serialize for HashMap + where + K: Serialize + Eq + Hash, + V: Serialize, + H: BuildHasher, + A: Allocator, + { + #[cfg_attr(feature = "inline-more", inline)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.collect_map(self) + } + } + + impl<'de, K, V, S, A> Deserialize<'de> for HashMap + where + K: Deserialize<'de> + Eq + Hash, + V: Deserialize<'de>, + S: BuildHasher + Default, + A: Allocator + Default, + { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MapVisitor + where + A: Allocator, + { + marker: PhantomData>, + } + + impl<'de, K, V, S, A> Visitor<'de> for MapVisitor + where + K: Deserialize<'de> + Eq + Hash, + V: Deserialize<'de>, + S: BuildHasher + Default, + A: Allocator + Default, + { + type Value = HashMap; + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("a map") + } + + #[cfg_attr(feature = "inline-more", inline)] + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'de>, + { + let mut values = HashMap::with_capacity_and_hasher_in( + size_hint::cautious(map.size_hint()), + S::default(), + A::default(), + ); + + while let Some((key, value)) = map.next_entry()? { + values.insert(key, value); + } + + Ok(values) + } + } + + let visitor = MapVisitor { + marker: PhantomData, + }; + deserializer.deserialize_map(visitor) + } + } +} + +mod set { + use crate::alloc::Allocator; + use core::fmt; + use core::hash::{BuildHasher, Hash}; + use core::marker::PhantomData; + use serde_core::de::{Deserialize, Deserializer, SeqAccess, Visitor}; + use serde_core::ser::{Serialize, Serializer}; + + use crate::HashSet; + + use super::size_hint; + + impl Serialize for HashSet + where + T: Serialize + Eq + Hash, + H: BuildHasher, + A: Allocator, + { + #[cfg_attr(feature = "inline-more", inline)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.collect_seq(self) + } + } + + impl<'de, T, S, A> Deserialize<'de> for HashSet + where + T: Deserialize<'de> + Eq + Hash, + S: BuildHasher + Default, + A: Allocator + Default, + { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SeqVisitor + where + A: Allocator, + { + marker: PhantomData>, + } + + impl<'de, T, S, A> Visitor<'de> for SeqVisitor + where + T: Deserialize<'de> + Eq + Hash, + S: BuildHasher + Default, + A: Allocator + Default, + { + type Value = HashSet; + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("a sequence") + } + + #[cfg_attr(feature = "inline-more", inline)] + fn visit_seq(self, mut seq: M) -> Result + where + M: SeqAccess<'de>, + { + let mut values = HashSet::with_capacity_and_hasher_in( + size_hint::cautious(seq.size_hint()), + S::default(), + A::default(), + ); + + while let Some(value) = seq.next_element()? { + values.insert(value); + } + + Ok(values) + } + } + + let visitor = SeqVisitor { + marker: PhantomData, + }; + deserializer.deserialize_seq(visitor) + } + + fn deserialize_in_place(deserializer: D, place: &mut Self) -> Result<(), D::Error> + where + D: Deserializer<'de>, + { + struct SeqInPlaceVisitor<'a, T, S, A>(&'a mut HashSet) + where + A: Allocator; + + impl<'de, T, S, A> Visitor<'de> for SeqInPlaceVisitor<'_, T, S, A> + where + T: Deserialize<'de> + Eq + Hash, + S: BuildHasher + Default, + A: Allocator, + { + type Value = (); + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("a sequence") + } + + #[cfg_attr(feature = "inline-more", inline)] + fn visit_seq(self, mut seq: M) -> Result + where + M: SeqAccess<'de>, + { + self.0.clear(); + self.0.reserve(size_hint::cautious(seq.size_hint())); + + while let Some(value) = seq.next_element()? { + self.0.insert(value); + } + + Ok(()) + } + } + + deserializer.deserialize_seq(SeqInPlaceVisitor(place)) + } + } +} diff --git a/library/hashbrown/src/hasher.rs b/library/hashbrown/src/hasher.rs new file mode 100644 index 0000000000000..7ec8aa16dc189 --- /dev/null +++ b/library/hashbrown/src/hasher.rs @@ -0,0 +1,77 @@ +#[cfg(feature = "default-hasher")] +use { + core::hash::{BuildHasher, Hasher}, + foldhash::fast::RandomState, +}; + +/// Default hash builder for the `S` type parameter of +/// [`HashMap`](crate::HashMap) and [`HashSet`](crate::HashSet). +/// +/// This only implements `BuildHasher` when the "default-hasher" crate feature +/// is enabled; otherwise it just serves as a placeholder, and a custom `S` type +/// must be used to have a fully functional `HashMap` or `HashSet`. +#[derive(Clone, Debug, Default)] +pub struct DefaultHashBuilder { + #[cfg(feature = "default-hasher")] + inner: RandomState, +} + +#[cfg(feature = "default-hasher")] +impl BuildHasher for DefaultHashBuilder { + type Hasher = DefaultHasher; + + #[inline(always)] + fn build_hasher(&self) -> Self::Hasher { + DefaultHasher { + inner: self.inner.build_hasher(), + } + } +} + +/// Default hasher for [`HashMap`](crate::HashMap) and [`HashSet`](crate::HashSet). +#[cfg(feature = "default-hasher")] +#[derive(Clone)] +pub struct DefaultHasher { + inner: ::Hasher, +} + +#[cfg(feature = "default-hasher")] +macro_rules! forward_writes { + ($( $write:ident ( $ty:ty ) , )*) => {$( + #[inline(always)] + fn $write(&mut self, arg: $ty) { + self.inner.$write(arg); + } + )*} +} + +#[cfg(feature = "default-hasher")] +impl Hasher for DefaultHasher { + forward_writes! { + write(&[u8]), + write_u8(u8), + write_u16(u16), + write_u32(u32), + write_u64(u64), + write_u128(u128), + write_usize(usize), + write_i8(i8), + write_i16(i16), + write_i32(i32), + write_i64(i64), + write_i128(i128), + write_isize(isize), + } + + // feature(hasher_prefixfree_extras) + #[cfg(feature = "nightly")] + forward_writes! { + write_length_prefix(usize), + write_str(&str), + } + + #[inline(always)] + fn finish(&self) -> u64 { + self.inner.finish() + } +} diff --git a/library/hashbrown/src/lib.rs b/library/hashbrown/src/lib.rs new file mode 100644 index 0000000000000..f167667b25ed6 --- /dev/null +++ b/library/hashbrown/src/lib.rs @@ -0,0 +1,184 @@ +//! This crate is a Rust port of Google's high-performance [SwissTable] hash +//! map, adapted to make it a drop-in replacement for Rust's standard `HashMap` +//! and `HashSet` types. +//! +//! The original C++ version of [SwissTable] can be found [here], and this +//! [CppCon talk] gives an overview of how the algorithm works. +//! +//! [SwissTable]: https://abseil.io/blog/20180927-swisstables +//! [here]: https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/raw_hash_set.h +//! [CppCon talk]: https://www.youtube.com/watch?v=ncHmEUmJZf4 + +#![cfg_attr(not(doc), no_std)] +#![cfg_attr( + feature = "nightly", + feature( + core_intrinsics, + dropck_eyepatch, + min_specialization, + trivial_clone, + extend_one, + strict_provenance_lints + ) +)] +#![cfg_attr(feature = "nightly", warn(implicit_provenance_casts))] +#![cfg_attr(feature = "rustc-dep-of-std", feature(rustc_attrs))] +#![cfg_attr(feature = "nightly", expect(internal_features))] +#![cfg_attr( + all(feature = "nightly", feature = "default-hasher"), + feature(hasher_prefixfree_extras) +)] + +#[cfg(test)] +#[macro_use] +extern crate std; + +#[cfg_attr(test, macro_use)] +#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] +extern crate alloc as stdalloc; + +#[doc = include_str!("../README.md")] +#[cfg(doctest)] +pub struct ReadmeDoctests; + +#[macro_use] +mod macros; + +mod alloc; +mod control; +mod hasher; +mod raw; +mod util; + +mod external_trait_impls; +mod map; +#[cfg(feature = "raw-entry")] +mod raw_entry; +#[cfg(feature = "rustc-internal-api")] +mod rustc_entry; +mod scopeguard; +mod set; +mod table; + +pub use crate::hasher::DefaultHashBuilder; +#[cfg(feature = "default-hasher")] +pub use crate::hasher::DefaultHasher; + +pub mod hash_map { + //! A hash map implemented with quadratic probing and SIMD lookup. + pub use crate::map::*; + + #[cfg(feature = "rustc-internal-api")] + pub use crate::rustc_entry::*; + + #[cfg(feature = "rayon")] + /// [rayon]-based parallel iterator types for hash maps. + /// You will rarely need to interact with it directly unless you have need + /// to name one of the iterator types. + /// + /// [rayon]: ::rayon + pub mod rayon { + pub use crate::external_trait_impls::rayon::map::*; + } +} +pub mod hash_set { + //! A hash set implemented as a `HashMap` where the value is `()`. + pub use crate::set::*; + + #[cfg(feature = "rayon")] + /// [rayon]-based parallel iterator types for hash sets. + /// You will rarely need to interact with it directly unless you have need + /// to name one of the iterator types. + /// + /// [rayon]: ::rayon + pub mod rayon { + pub use crate::external_trait_impls::rayon::set::*; + } +} +pub mod hash_table { + //! A hash table implemented with quadratic probing and SIMD lookup. + pub use crate::table::*; + + #[cfg(feature = "rayon")] + /// [rayon]-based parallel iterator types for hash tables. + /// You will rarely need to interact with it directly unless you have need + /// to name one of the iterator types. + /// + /// [rayon]: ::rayon + pub mod rayon { + pub use crate::external_trait_impls::rayon::table::*; + } +} + +pub use crate::map::HashMap; +pub use crate::set::HashSet; +pub use crate::table::HashTable; + +#[cfg(feature = "equivalent")] +pub use equivalent::Equivalent; + +// This is only used as a fallback when building as part of `std`. +#[cfg(not(feature = "equivalent"))] +/// Key equivalence trait. +/// +/// This trait defines the function used to compare the input value with the +/// map keys (or set values) during a lookup operation such as [`HashMap::get`] +/// or [`HashSet::contains`]. +/// It is provided with a blanket implementation based on the +/// [`Borrow`](core::borrow::Borrow) trait. +/// +/// # Correctness +/// +/// Equivalent values must hash to the same value. +pub trait Equivalent { + /// Checks if this value is equivalent to the given key. + /// + /// Returns `true` if both values are equivalent, and `false` otherwise. + /// + /// # Correctness + /// + /// When this function returns `true`, both `self` and `key` must hash to + /// the same value. + fn equivalent(&self, key: &K) -> bool; +} + +#[cfg(not(feature = "equivalent"))] +impl Equivalent for Q +where + Q: Eq, + K: core::borrow::Borrow, +{ + fn equivalent(&self, key: &K) -> bool { + self == key.borrow() + } +} + +/// The error type for `try_reserve` methods. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum TryReserveError { + /// Error due to the computed capacity exceeding the collection's maximum + /// (usually `isize::MAX` bytes). + CapacityOverflow, + + /// The memory allocator returned an error + AllocError { + /// The layout of the allocation request that failed. + layout: core::alloc::Layout, + }, +} + +// matches stdalloc::collections::TryReserveError +impl core::fmt::Display for TryReserveError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str("memory allocation failed")?; + let reason = match self { + TryReserveError::CapacityOverflow => { + " because the computed capacity exceeded the collection's maximum" + } + TryReserveError::AllocError { .. } => " because the memory allocator returned an error", + }; + f.write_str(reason) + } +} + +impl core::error::Error for TryReserveError {} diff --git a/library/hashbrown/src/macros.rs b/library/hashbrown/src/macros.rs new file mode 100644 index 0000000000000..2d92112ee300d --- /dev/null +++ b/library/hashbrown/src/macros.rs @@ -0,0 +1,42 @@ +// FIXME: remove once we bump MSRV >= 1.95.0 +// Originally by @folkertdev on Zulip: +// https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/compiler-builtins.20msrv.20policy.3F/near/606320965 +/// Fallback `cfg_select!` on older Rust. +/// +/// Requires braces around output, but works for items and expressions. +#[cfg(not(feature = "nightly"))] +#[macro_export] +macro_rules! cfg_select { + ({ $($tt:tt)* }) => {{ + $crate::cfg_select! { $($tt)* } + }}; + (_ => { $($output:tt)* }) => { + $($output)* + }; + ( + $cfg:meta => $output:tt + $($( $rest:tt )+)? + ) => { + #[cfg($cfg)] + $crate::cfg_select! { _ => $output } + $( + #[cfg(not($cfg))] + $crate::cfg_select! { $($rest)+ } + )? + } +} + +// Helper macro for specialization. This also helps avoid parse errors if the +// default fn syntax for specialization changes in the future. +#[cfg(feature = "nightly")] +macro_rules! default_fn { + (#[$($a:tt)*] $($tt:tt)*) => { + #[$($a)*] default $($tt)* + } +} +#[cfg(not(feature = "nightly"))] +macro_rules! default_fn { + ($($tt:tt)*) => { + $($tt)* + } +} diff --git a/library/hashbrown/src/map.rs b/library/hashbrown/src/map.rs new file mode 100644 index 0000000000000..95c15c18b47ab --- /dev/null +++ b/library/hashbrown/src/map.rs @@ -0,0 +1,7046 @@ +use crate::alloc::{Allocator, Global}; +use crate::raw::{Bucket, RawDrain, RawExtractIf, RawIntoIter, RawIter, RawTable}; +use crate::{DefaultHashBuilder, Equivalent, TryReserveError}; +use core::borrow::Borrow; +use core::fmt::{self, Debug}; +use core::hash::{BuildHasher, Hash}; +use core::iter::FusedIterator; +use core::marker::PhantomData; +use core::mem; +use core::ops::Index; +use stdalloc::borrow::ToOwned; + +#[cfg(feature = "raw-entry")] +pub use crate::raw_entry::*; + +/// A hash map implemented with quadratic probing and SIMD lookup. +/// +/// The default hashing algorithm is currently [`foldhash`], though this is +/// subject to change at any point in the future. This hash function is very +/// fast for all types of keys, but this algorithm will typically *not* protect +/// against attacks such as HashDoS. +/// +/// The hashing algorithm can be replaced on a per-`HashMap` basis using the +/// [`default`], [`with_hasher`], and [`with_capacity_and_hasher`] methods. Many +/// alternative algorithms are available on crates.io, such as the [`fnv`] crate. +/// +/// It is required that the keys implement the [`Eq`] and [`Hash`] traits, although +/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`. +/// If you implement these yourself, it is important that the following +/// property holds: +/// +/// ```text +/// k1 == k2 -> hash(k1) == hash(k2) +/// ``` +/// +/// In other words, if two keys are equal, their hashes must be equal. +/// +/// It is a logic error for a key to be modified in such a way that the key's +/// hash, as determined by the [`Hash`] trait, or its equality, as determined by +/// the [`Eq`] trait, changes while it is in the map. This is normally only +/// possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code. +/// +/// It is also a logic error for the [`Hash`] implementation of a key to panic. +/// This is generally only possible if the trait is implemented manually. If a +/// panic does occur then the contents of the `HashMap` may become corrupted and +/// some items may be dropped from the table. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// // Type inference lets us omit an explicit type signature (which +/// // would be `HashMap` in this example). +/// let mut book_reviews = HashMap::new(); +/// +/// // Review some books. +/// book_reviews.insert( +/// "Adventures of Huckleberry Finn".to_string(), +/// "My favorite book.".to_string(), +/// ); +/// book_reviews.insert( +/// "Grimms' Fairy Tales".to_string(), +/// "Masterpiece.".to_string(), +/// ); +/// book_reviews.insert( +/// "Pride and Prejudice".to_string(), +/// "Very enjoyable.".to_string(), +/// ); +/// book_reviews.insert( +/// "The Adventures of Sherlock Holmes".to_string(), +/// "Eye lyked it alot.".to_string(), +/// ); +/// +/// // Check for a specific one. +/// // When collections store owned values (String), they can still be +/// // queried using references (&str). +/// if !book_reviews.contains_key("Les Misérables") { +/// println!("We've got {} reviews, but Les Misérables ain't one.", +/// book_reviews.len()); +/// } +/// +/// // oops, this review has a lot of spelling mistakes, let's delete it. +/// book_reviews.remove("The Adventures of Sherlock Holmes"); +/// +/// // Look up the values associated with some keys. +/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"]; +/// for &book in &to_find { +/// match book_reviews.get(book) { +/// Some(review) => println!("{}: {}", book, review), +/// None => println!("{} is unreviewed.", book) +/// } +/// } +/// +/// // Look up the value for a key (will panic if the key is not found). +/// println!("Review for Jane: {}", book_reviews["Pride and Prejudice"]); +/// +/// // Iterate over everything. +/// for (book, review) in &book_reviews { +/// println!("{}: \"{}\"", book, review); +/// } +/// ``` +/// +/// `HashMap` also implements an [`Entry API`](#method.entry), which allows +/// for more complex methods of getting, setting, updating and removing keys and +/// their values: +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// // type inference lets us omit an explicit type signature (which +/// // would be `HashMap<&str, u8>` in this example). +/// let mut player_stats = HashMap::new(); +/// +/// fn random_stat_buff() -> u8 { +/// // could actually return some random value here - let's just return +/// // some fixed value for now +/// 42 +/// } +/// +/// // insert a key only if it doesn't already exist +/// player_stats.entry("health").or_insert(100); +/// +/// // insert a key using a function that provides a new value only if it +/// // doesn't already exist +/// player_stats.entry("defence").or_insert_with(random_stat_buff); +/// +/// // update a key, guarding against the key possibly not being set +/// let stat = player_stats.entry("attack").or_insert(100); +/// *stat += random_stat_buff(); +/// ``` +/// +/// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`]. +/// We must also derive [`PartialEq`]. +/// +/// [`RefCell`]: std::cell::RefCell +/// [`Cell`]: std::cell::Cell +/// [`default`]: Default::default +/// [`with_hasher`]: HashMap::with_hasher +/// [`with_capacity_and_hasher`]: HashMap::with_capacity_and_hasher +/// [`fnv`]: https://crates.io/crates/fnv +/// [`foldhash`]: https://crates.io/crates/foldhash +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// #[derive(Hash, Eq, PartialEq, Debug)] +/// struct Viking { +/// name: String, +/// country: String, +/// } +/// +/// impl Viking { +/// /// Creates a new Viking. +/// fn new(name: &str, country: &str) -> Viking { +/// Viking { name: name.to_string(), country: country.to_string() } +/// } +/// } +/// +/// // Use a HashMap to store the vikings' health points. +/// let mut vikings = HashMap::new(); +/// +/// vikings.insert(Viking::new("Einar", "Norway"), 25); +/// vikings.insert(Viking::new("Olaf", "Denmark"), 24); +/// vikings.insert(Viking::new("Harald", "Iceland"), 12); +/// +/// // Use derived implementation to print the status of the vikings. +/// for (viking, health) in &vikings { +/// println!("{:?} has {} hp", viking, health); +/// } +/// ``` +/// +/// A `HashMap` with fixed list of elements can be initialized from an array: +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let timber_resources: HashMap<&str, i32> = [("Norway", 100), ("Denmark", 50), ("Iceland", 10)] +/// .into_iter().collect(); +/// // use the values stored in map +/// ``` +pub struct HashMap { + pub(crate) hash_builder: S, + pub(crate) table: RawTable<(K, V), A>, +} + +impl Clone for HashMap { + fn clone(&self) -> Self { + HashMap { + hash_builder: self.hash_builder.clone(), + table: self.table.clone(), + } + } + + fn clone_from(&mut self, source: &Self) { + self.table.clone_from(&source.table); + + // Update hash_builder only if we successfully cloned all elements. + self.hash_builder.clone_from(&source.hash_builder); + } +} + +/// Ensures that a single closure type across uses of this which, in turn prevents multiple +/// instances of any functions like `RawTable::reserve` from being generated +#[cfg_attr(feature = "inline-more", inline)] +pub(crate) fn make_hasher(hash_builder: &S) -> impl Fn(&(Q, V)) -> u64 + '_ +where + Q: Hash, + S: BuildHasher, +{ + move |val| make_hash::(hash_builder, &val.0) +} + +/// Ensures that a single closure type across uses of this which, in turn prevents multiple +/// instances of any functions like `RawTable::reserve` from being generated +#[cfg_attr(feature = "inline-more", inline)] +pub(crate) fn equivalent_key(k: &Q) -> impl Fn(&(K, V)) -> bool + '_ +where + Q: Equivalent + ?Sized, +{ + move |x| k.equivalent(&x.0) +} + +/// Ensures that a single closure type across uses of this which, in turn prevents multiple +/// instances of any functions like `RawTable::reserve` from being generated +#[cfg_attr(feature = "inline-more", inline)] +#[cfg(feature = "raw-entry")] +pub(crate) fn equivalent(k: &Q) -> impl Fn(&K) -> bool + '_ +where + Q: Equivalent + ?Sized, +{ + move |x| k.equivalent(x) +} + +#[cfg_attr(feature = "inline-more", inline)] +pub(crate) fn make_hash(hash_builder: &S, val: &Q) -> u64 +where + Q: Hash + ?Sized, + S: BuildHasher, +{ + hash_builder.hash_one(val) +} + +#[cfg(feature = "default-hasher")] +impl HashMap { + /// Creates an empty `HashMap`. + /// + /// The hash map is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`], for example with + /// [`with_hasher`](HashMap::with_hasher) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let mut map: HashMap<&str, i32> = HashMap::new(); + /// assert_eq!(map.len(), 0); + /// assert_eq!(map.capacity(), 0); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn new() -> Self { + Self::default() + } + + /// Creates an empty `HashMap` with the specified capacity. + /// + /// The hash map will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash map will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`], for example with + /// [`with_capacity_and_hasher`](HashMap::with_capacity_and_hasher) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let mut map: HashMap<&str, i32> = HashMap::with_capacity(10); + /// assert_eq!(map.len(), 0); + /// assert!(map.capacity() >= 10); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity(capacity: usize) -> Self { + Self::with_capacity_and_hasher(capacity, DefaultHashBuilder::default()) + } +} + +#[cfg(feature = "default-hasher")] +impl HashMap { + /// Creates an empty `HashMap` using the given allocator. + /// + /// The hash map is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`], for example with + /// [`with_hasher_in`](HashMap::with_hasher_in) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use bumpalo::Bump; + /// + /// let bump = Bump::new(); + /// let mut map = HashMap::new_in(&bump); + /// + /// // The created HashMap holds none elements + /// assert_eq!(map.len(), 0); + /// + /// // The created HashMap also doesn't allocate memory + /// assert_eq!(map.capacity(), 0); + /// + /// // Now we insert element inside created HashMap + /// map.insert("One", 1); + /// // We can see that the HashMap holds 1 element + /// assert_eq!(map.len(), 1); + /// // And it also allocates some capacity + /// assert!(map.capacity() > 1); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn new_in(alloc: A) -> Self { + Self::with_hasher_in(DefaultHashBuilder::default(), alloc) + } + + /// Creates an empty `HashMap` with the specified capacity using the given allocator. + /// + /// The hash map will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash map will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`], for example with + /// [`with_capacity_and_hasher_in`](HashMap::with_capacity_and_hasher_in) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use bumpalo::Bump; + /// + /// let bump = Bump::new(); + /// let mut map = HashMap::with_capacity_in(5, &bump); + /// + /// // The created HashMap holds none elements + /// assert_eq!(map.len(), 0); + /// // But it can hold at least 5 elements without reallocating + /// let empty_map_capacity = map.capacity(); + /// assert!(empty_map_capacity >= 5); + /// + /// // Now we insert some 5 elements inside created HashMap + /// map.insert("One", 1); + /// map.insert("Two", 2); + /// map.insert("Three", 3); + /// map.insert("Four", 4); + /// map.insert("Five", 5); + /// + /// // We can see that the HashMap holds 5 elements + /// assert_eq!(map.len(), 5); + /// // But its capacity isn't changed + /// assert_eq!(map.capacity(), empty_map_capacity) + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { + Self::with_capacity_and_hasher_in(capacity, DefaultHashBuilder::default(), alloc) + } +} + +impl HashMap { + /// Creates an empty `HashMap` which will use the given hash builder to hash + /// keys. + /// + /// The hash map is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashMap` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut map = HashMap::with_hasher(s); + /// assert_eq!(map.len(), 0); + /// assert_eq!(map.capacity(), 0); + /// + /// map.insert(1, 2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub const fn with_hasher(hash_builder: S) -> Self { + Self { + hash_builder, + table: RawTable::new(), + } + } + + /// Creates an empty `HashMap` with the specified capacity, using `hash_builder` + /// to hash the keys. + /// + /// The hash map will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash map will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashMap` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut map = HashMap::with_capacity_and_hasher(10, s); + /// assert_eq!(map.len(), 0); + /// assert!(map.capacity() >= 10); + /// + /// map.insert(1, 2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self { + Self { + hash_builder, + table: RawTable::with_capacity(capacity), + } + } +} + +impl HashMap { + /// Returns a reference to the underlying allocator. + #[inline] + pub fn allocator(&self) -> &A { + self.table.allocator() + } + + /// Creates an empty `HashMap` which will use the given hash builder to hash + /// keys. It will be allocated with the given allocator. + /// + /// The hash map is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`]. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut map = HashMap::with_hasher(s); + /// map.insert(1, 2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub const fn with_hasher_in(hash_builder: S, alloc: A) -> Self { + Self { + hash_builder, + table: RawTable::new_in(alloc), + } + } + + /// Creates an empty `HashMap` with the specified capacity, using `hash_builder` + /// to hash the keys. It will be allocated with the given allocator. + /// + /// The hash map will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash map will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashMap` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashMap`]. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut map = HashMap::with_capacity_and_hasher(10, s); + /// map.insert(1, 2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_and_hasher_in(capacity: usize, hash_builder: S, alloc: A) -> Self { + Self { + hash_builder, + table: RawTable::with_capacity_in(capacity, alloc), + } + } + + /// Returns a reference to the map's [`BuildHasher`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::DefaultHashBuilder; + /// + /// let hasher = DefaultHashBuilder::default(); + /// let map: HashMap = HashMap::with_hasher(hasher); + /// let hasher: &DefaultHashBuilder = map.hasher(); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn hasher(&self) -> &S { + &self.hash_builder + } + + /// Returns the number of elements the map can hold without reallocating. + /// + /// This number is a lower bound; the `HashMap` might be able to hold + /// more, but is guaranteed to be able to hold at least this many. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let map: HashMap = HashMap::with_capacity(100); + /// assert_eq!(map.len(), 0); + /// assert!(map.capacity() >= 100); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn capacity(&self) -> usize { + self.table.capacity() + } + + /// An iterator visiting all keys in arbitrary order. + /// The iterator element type is `&'a K`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// assert_eq!(map.len(), 3); + /// let mut vec: Vec<&str> = Vec::new(); + /// + /// for key in map.keys() { + /// println!("{}", key); + /// vec.push(*key); + /// } + /// + /// // The `Keys` iterator produces keys in arbitrary order, so the + /// // keys must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, ["a", "b", "c"]); + /// + /// assert_eq!(map.len(), 3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn keys(&self) -> Keys<'_, K, V> { + Keys { inner: self.iter() } + } + + /// An iterator visiting all values in arbitrary order. + /// The iterator element type is `&'a V`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// assert_eq!(map.len(), 3); + /// let mut vec: Vec = Vec::new(); + /// + /// for val in map.values() { + /// println!("{}", val); + /// vec.push(*val); + /// } + /// + /// // The `Values` iterator produces values in arbitrary order, so the + /// // values must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [1, 2, 3]); + /// + /// assert_eq!(map.len(), 3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn values(&self) -> Values<'_, K, V> { + Values { inner: self.iter() } + } + + /// An iterator visiting all values mutably in arbitrary order. + /// The iterator element type is `&'a mut V`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// + /// for val in map.values_mut() { + /// *val = *val + 10; + /// } + /// + /// assert_eq!(map.len(), 3); + /// let mut vec: Vec = Vec::new(); + /// + /// for val in map.values() { + /// println!("{}", val); + /// vec.push(*val); + /// } + /// + /// // The `Values` iterator produces values in arbitrary order, so the + /// // values must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [11, 12, 13]); + /// + /// assert_eq!(map.len(), 3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> { + ValuesMut { + inner: self.iter_mut(), + } + } + + /// An iterator visiting all key-value pairs in arbitrary order. + /// The iterator element type is `(&'a K, &'a V)`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// assert_eq!(map.len(), 3); + /// let mut vec: Vec<(&str, i32)> = Vec::new(); + /// + /// for (key, val) in map.iter() { + /// println!("key: {} val: {}", key, val); + /// vec.push((*key, *val)); + /// } + /// + /// // The `Iter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [("a", 1), ("b", 2), ("c", 3)]); + /// + /// assert_eq!(map.len(), 3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, K, V> { + // Here we tie the lifetime of self to the iter. + unsafe { + Iter { + inner: self.table.iter(), + marker: PhantomData, + } + } + } + + /// An iterator visiting all key-value pairs in arbitrary order, + /// with mutable references to the values. + /// The iterator element type is `(&'a K, &'a mut V)`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// + /// // Update all values + /// for (_, val) in map.iter_mut() { + /// *val *= 2; + /// } + /// + /// assert_eq!(map.len(), 3); + /// let mut vec: Vec<(&str, i32)> = Vec::new(); + /// + /// for (key, val) in &map { + /// println!("key: {} val: {}", key, val); + /// vec.push((*key, *val)); + /// } + /// + /// // The `Iter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [("a", 2), ("b", 4), ("c", 6)]); + /// + /// assert_eq!(map.len(), 3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { + // Here we tie the lifetime of self to the iter. + unsafe { + IterMut { + inner: self.table.iter(), + marker: PhantomData, + } + } + } + + #[cfg(test)] + #[cfg_attr(feature = "inline-more", inline)] + fn raw_capacity(&self) -> usize { + self.table.num_buckets() + } + + /// Returns the number of elements in the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut a = HashMap::new(); + /// assert_eq!(a.len(), 0); + /// a.insert(1, "a"); + /// assert_eq!(a.len(), 1); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn len(&self) -> usize { + self.table.len() + } + + /// Returns `true` if the map contains no elements. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut a = HashMap::new(); + /// assert!(a.is_empty()); + /// a.insert(1, "a"); + /// assert!(!a.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Clears the map, returning all key-value pairs as an iterator. Keeps the + /// allocated memory for reuse. + /// + /// If the returned iterator is dropped before being fully consumed, it + /// drops the remaining key-value pairs. The returned iterator keeps a + /// mutable borrow on the vector to optimize its implementation. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut a = HashMap::new(); + /// a.insert(1, "a"); + /// a.insert(2, "b"); + /// let capacity_before_drain = a.capacity(); + /// + /// for (k, v) in a.drain().take(1) { + /// assert!(k == 1 || k == 2); + /// assert!(v == "a" || v == "b"); + /// } + /// + /// // As we can see, the map is empty and contains no element. + /// assert!(a.is_empty() && a.len() == 0); + /// // But map capacity is equal to old one. + /// assert_eq!(a.capacity(), capacity_before_drain); + /// + /// let mut a = HashMap::new(); + /// a.insert(1, "a"); + /// a.insert(2, "b"); + /// + /// { // Iterator is dropped without being consumed. + /// let d = a.drain(); + /// } + /// + /// // But the map is empty even if we do not use Drain iterator. + /// assert!(a.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn drain(&mut self) -> Drain<'_, K, V, A> { + Drain { + inner: self.table.drain(), + } + } + + /// Retains only the elements specified by the predicate. Keeps the + /// allocated memory for reuse. + /// + /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// The elements are visited in unsorted (and unspecified) order. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = (0..8).map(|x|(x, x*10)).collect(); + /// assert_eq!(map.len(), 8); + /// + /// map.retain(|&k, _| k % 2 == 0); + /// + /// // We can see, that the number of elements inside map is changed. + /// assert_eq!(map.len(), 4); + /// + /// let mut vec: Vec<(i32, i32)> = map.iter().map(|(&k, &v)| (k, v)).collect(); + /// vec.sort_unstable(); + /// assert_eq!(vec, [(0, 0), (2, 20), (4, 40), (6, 60)]); + /// ``` + pub fn retain(&mut self, mut f: F) + where + F: FnMut(&K, &mut V) -> bool, + { + // Here we only use `iter` as a temporary, preventing use-after-free + unsafe { + for item in self.table.iter() { + let &mut (ref key, ref mut value) = item.as_mut(); + if !f(key, value) { + self.table.erase(item); + } + } + } + } + + /// Drains elements which are true under the given predicate, + /// and returns an iterator over the removed items. + /// + /// In other words, move all pairs `(k, v)` such that `f(&k, &mut v)` returns `true` out + /// into another iterator. + /// + /// Note that `extract_if` lets you mutate every value in the filter closure, regardless of + /// whether you choose to keep or remove it. + /// + /// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating + /// or the iteration short-circuits, then the remaining elements will be retained. + /// Use [`retain()`] with a negated predicate if you do not need the returned iterator. + /// + /// Keeps the allocated memory for reuse. + /// + /// [`retain()`]: HashMap::retain + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = (0..8).map(|x| (x, x)).collect(); + /// + /// let drained: HashMap = map.extract_if(|k, _v| k % 2 == 0).collect(); + /// + /// let mut evens = drained.keys().cloned().collect::>(); + /// let mut odds = map.keys().cloned().collect::>(); + /// evens.sort(); + /// odds.sort(); + /// + /// assert_eq!(evens, vec![0, 2, 4, 6]); + /// assert_eq!(odds, vec![1, 3, 5, 7]); + /// + /// let mut map: HashMap = (0..8).map(|x| (x, x)).collect(); + /// + /// { // Iterator is dropped without being consumed. + /// let d = map.extract_if(|k, _v| k % 2 != 0); + /// } + /// + /// // ExtractIf was not exhausted, therefore no elements were drained. + /// assert_eq!(map.len(), 8); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn extract_if(&mut self, f: F) -> ExtractIf<'_, K, V, F, A> + where + F: FnMut(&K, &mut V) -> bool, + { + ExtractIf { + f, + inner: RawExtractIf { + iter: unsafe { self.table.iter() }, + table: &mut self.table, + }, + } + } + + /// Clears the map, removing all key-value pairs. Keeps the allocated memory + /// for reuse. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut a = HashMap::new(); + /// a.insert(1, "a"); + /// let capacity_before_clear = a.capacity(); + /// + /// a.clear(); + /// + /// // Map is empty. + /// assert!(a.is_empty()); + /// // But map capacity is equal to old one. + /// assert_eq!(a.capacity(), capacity_before_clear); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn clear(&mut self) { + self.table.clear(); + } + + /// Creates a consuming iterator visiting all the keys in arbitrary order. + /// The map cannot be used after calling this. + /// The iterator element type is `K`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// + /// let mut vec: Vec<&str> = map.into_keys().collect(); + /// + /// // The `IntoKeys` iterator produces keys in arbitrary order, so the + /// // keys must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, ["a", "b", "c"]); + /// ``` + #[inline] + pub fn into_keys(self) -> IntoKeys { + IntoKeys { + inner: self.into_iter(), + } + } + + /// Creates a consuming iterator visiting all the values in arbitrary order. + /// The map cannot be used after calling this. + /// The iterator element type is `V`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert("a", 1); + /// map.insert("b", 2); + /// map.insert("c", 3); + /// + /// let mut vec: Vec = map.into_values().collect(); + /// + /// // The `IntoValues` iterator produces values in arbitrary order, so + /// // the values must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [1, 2, 3]); + /// ``` + #[inline] + pub fn into_values(self) -> IntoValues { + IntoValues { + inner: self.into_iter(), + } + } +} + +impl HashMap +where + K: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + /// Reserves capacity for at least `additional` more elements to be inserted + /// in the `HashMap`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// # Panics + /// + /// Panics if the new capacity exceeds [`isize::MAX`] bytes and [`abort`] the program + /// in case of allocation error. Use [`try_reserve`](HashMap::try_reserve) instead + /// if you want to handle memory allocation failure. + /// + /// [`abort`]: stdalloc::alloc::handle_alloc_error + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let mut map: HashMap<&str, i32> = HashMap::new(); + /// // Map is empty and doesn't allocate memory + /// assert_eq!(map.capacity(), 0); + /// + /// map.reserve(10); + /// + /// // And now map can hold at least 10 elements + /// assert!(map.capacity() >= 10); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn reserve(&mut self, additional: usize) { + self.table + .reserve(additional, make_hasher::<_, V, S>(&self.hash_builder)); + } + + /// Tries to reserve capacity for at least `additional` more elements to be inserted + /// in the given `HashMap`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// # Errors + /// + /// If the capacity overflows, or the allocator reports a failure, then an error + /// is returned. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, isize> = HashMap::new(); + /// // Map is empty and doesn't allocate memory + /// assert_eq!(map.capacity(), 0); + /// + /// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?"); + /// + /// // And now map can hold at least 10 elements + /// assert!(map.capacity() >= 10); + /// ``` + /// If the capacity overflows, or the allocator reports a failure, then an error + /// is returned: + /// ``` + /// # fn test() { + /// use hashbrown::HashMap; + /// use hashbrown::TryReserveError; + /// let mut map: HashMap = HashMap::new(); + /// + /// match map.try_reserve(usize::MAX) { + /// Err(error) => match error { + /// TryReserveError::CapacityOverflow => {} + /// _ => panic!("TryReserveError::AllocError ?"), + /// }, + /// _ => panic!(), + /// } + /// # } + /// # fn main() { + /// # #[cfg(not(miri))] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { + self.table + .try_reserve(additional, make_hasher::<_, V, S>(&self.hash_builder)) + } + + /// Shrinks the capacity of the map as much as possible. It will drop + /// down as much as possible while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::with_capacity(100); + /// map.insert(1, 2); + /// map.insert(3, 4); + /// assert!(map.capacity() >= 100); + /// map.shrink_to_fit(); + /// assert!(map.capacity() >= 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn shrink_to_fit(&mut self) { + self.table + .shrink_to(0, make_hasher::<_, V, S>(&self.hash_builder)); + } + + /// Shrinks the capacity of the map with a lower limit. It will drop + /// down no lower than the supplied limit while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// This function does nothing if the current capacity is smaller than the + /// supplied minimum capacity. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::with_capacity(100); + /// map.insert(1, 2); + /// map.insert(3, 4); + /// assert!(map.capacity() >= 100); + /// map.shrink_to(10); + /// assert!(map.capacity() >= 10); + /// map.shrink_to(0); + /// assert!(map.capacity() >= 2); + /// map.shrink_to(10); + /// assert!(map.capacity() >= 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn shrink_to(&mut self, min_capacity: usize) { + self.table + .shrink_to(min_capacity, make_hasher::<_, V, S>(&self.hash_builder)); + } + + /// Gets the given key's corresponding entry in the map for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut letters = HashMap::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// let counter = letters.entry(ch).or_insert(0); + /// *counter += 1; + /// } + /// + /// assert_eq!(letters[&'s'], 2); + /// assert_eq!(letters[&'t'], 3); + /// assert_eq!(letters[&'u'], 1); + /// assert_eq!(letters.get(&'y'), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S, A> { + let hash = make_hash::(&self.hash_builder, &key); + if let Some(elem) = self.table.find(hash, equivalent_key(&key)) { + Entry::Occupied(OccupiedEntry { + hash, + elem, + table: self, + }) + } else { + Entry::Vacant(VacantEntry { + hash, + key, + table: self, + }) + } + } + + /// Gets the given key's corresponding entry by reference in the map for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut words: HashMap = HashMap::new(); + /// let source = ["poneyland", "horseyland", "poneyland", "poneyland"]; + /// for (i, &s) in source.iter().enumerate() { + /// let counter = words.entry_ref(s).or_insert(0); + /// *counter += 1; + /// } + /// + /// assert_eq!(words["poneyland"], 3); + /// assert_eq!(words["horseyland"], 1); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn entry_ref<'a, 'b, Q>(&'a mut self, key: &'b Q) -> EntryRef<'a, 'b, K, Q, V, S, A> + where + Q: Hash + Equivalent + ?Sized, + { + let hash = make_hash::(&self.hash_builder, key); + if let Some(elem) = self.table.find(hash, equivalent_key(key)) { + EntryRef::Occupied(OccupiedEntry { + hash, + elem, + table: self, + }) + } else { + EntryRef::Vacant(VacantEntryRef { + hash, + key, + table: self, + }) + } + } + + /// Returns a reference to the value corresponding to the key. + /// + /// The key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, "a"); + /// assert_eq!(map.get(&1), Some(&"a")); + /// assert_eq!(map.get(&2), None); + /// ``` + #[inline] + pub fn get(&self, k: &Q) -> Option<&V> + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + if self.table.is_empty() { + None + } else { + let hash = make_hash::(&self.hash_builder, k); + match self.table.get(hash, equivalent_key(k)) { + Some((_, v)) => Some(v), + None => None, + } + } + } + + /// Returns the key-value pair corresponding to the supplied key. + /// + /// The supplied key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, "a"); + /// assert_eq!(map.get_key_value(&1), Some((&1, &"a"))); + /// assert_eq!(map.get_key_value(&2), None); + /// ``` + #[inline] + pub fn get_key_value(&self, k: &Q) -> Option<(&K, &V)> + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + if self.table.is_empty() { + None + } else { + let hash = make_hash::(&self.hash_builder, k); + match self.table.get(hash, equivalent_key(k)) { + Some((key, value)) => Some((key, value)), + None => None, + } + } + } + + /// Returns the key-value pair corresponding to the supplied key, with a mutable reference to value. + /// + /// The supplied key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, "a"); + /// let (k, v) = map.get_key_value_mut(&1).unwrap(); + /// assert_eq!(k, &1); + /// assert_eq!(v, &mut "a"); + /// *v = "b"; + /// assert_eq!(map.get_key_value_mut(&1), Some((&1, &mut "b"))); + /// assert_eq!(map.get_key_value_mut(&2), None); + /// ``` + #[inline] + pub fn get_key_value_mut(&mut self, k: &Q) -> Option<(&K, &mut V)> + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + if self.table.is_empty() { + None + } else { + let hash = make_hash::(&self.hash_builder, k); + match self.table.get_mut(hash, equivalent_key(k)) { + Some(&mut (ref key, ref mut value)) => Some((key, value)), + None => None, + } + } + } + + /// Returns `true` if the map contains a value for the specified key. + /// + /// The key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, "a"); + /// assert_eq!(map.contains_key(&1), true); + /// assert_eq!(map.contains_key(&2), false); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn contains_key(&self, k: &Q) -> bool + where + Q: Hash + Equivalent + ?Sized, + { + if self.table.is_empty() { + false + } else { + let hash = make_hash::(&self.hash_builder, k); + self.table.get(hash, equivalent_key(k)).is_some() + } + } + + /// Returns a mutable reference to the value corresponding to the key. + /// + /// The key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, "a"); + /// if let Some(x) = map.get_mut(&1) { + /// *x = "b"; + /// } + /// assert_eq!(map[&1], "b"); + /// + /// assert_eq!(map.get_mut(&2), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_mut(&mut self, k: &Q) -> Option<&mut V> + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + if self.table.is_empty() { + None + } else { + let hash = make_hash::(&self.hash_builder, k); + match self.table.get_mut(hash, equivalent_key(k)) { + Some(&mut (_, ref mut v)) => Some(v), + None => None, + } + } + } + + /// Attempts to get mutable references to `N` values in the map at once. + /// + /// Returns an array of length `N` with the results of each query. For soundness, at most one + /// mutable reference will be returned to any value. `None` will be used if the key is missing. + /// + /// # Panics + /// + /// Panics if any keys are overlapping. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Bodleian Library".to_string(), 1602); + /// libraries.insert("Athenæum".to_string(), 1807); + /// libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); + /// libraries.insert("Library of Congress".to_string(), 1800); + /// + /// // Get Athenæum and Bodleian Library + /// let [Some(a), Some(b)] = libraries.get_disjoint_mut([ + /// "Athenæum", + /// "Bodleian Library", + /// ]) else { panic!() }; + /// + /// // Assert values of Athenæum and Library of Congress + /// let got = libraries.get_disjoint_mut([ + /// "Athenæum", + /// "Library of Congress", + /// ]); + /// assert_eq!( + /// got, + /// [ + /// Some(&mut 1807), + /// Some(&mut 1800), + /// ], + /// ); + /// + /// // Missing keys result in None + /// let got = libraries.get_disjoint_mut([ + /// "Athenæum", + /// "New York Public Library", + /// ]); + /// assert_eq!( + /// got, + /// [ + /// Some(&mut 1807), + /// None + /// ] + /// ); + /// ``` + /// + /// ```should_panic + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Athenæum".to_string(), 1807); + /// + /// // Duplicate keys panic! + /// let got = libraries.get_disjoint_mut([ + /// "Athenæum", + /// "Athenæum", + /// ]); + /// ``` + pub fn get_disjoint_mut(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N] + where + Q: Hash + Equivalent + ?Sized, + { + self.get_disjoint_mut_inner(ks) + .map(|res| res.map(|(_, v)| v)) + } + + /// Attempts to get mutable references to `N` values in the map at once. + #[deprecated(note = "use `get_disjoint_mut` instead")] + pub fn get_many_mut(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N] + where + Q: Hash + Equivalent + ?Sized, + { + self.get_disjoint_mut(ks) + } + + /// Attempts to get mutable references to `N` values in the map at once, without validating that + /// the values are unique. + /// + /// Returns an array of length `N` with the results of each query. `None` will be used if + /// the key is missing. + /// + /// For a safe alternative see [`get_disjoint_mut`](`HashMap::get_disjoint_mut`). + /// + /// # Safety + /// + /// Calling this method with overlapping keys is *[undefined behavior]* even if the resulting + /// references are not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Bodleian Library".to_string(), 1602); + /// libraries.insert("Athenæum".to_string(), 1807); + /// libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); + /// libraries.insert("Library of Congress".to_string(), 1800); + /// + /// // SAFETY: The keys do not overlap. + /// let [Some(a), Some(b)] = (unsafe { libraries.get_disjoint_unchecked_mut([ + /// "Athenæum", + /// "Bodleian Library", + /// ]) }) else { panic!() }; + /// + /// // SAFETY: The keys do not overlap. + /// let got = unsafe { libraries.get_disjoint_unchecked_mut([ + /// "Athenæum", + /// "Library of Congress", + /// ]) }; + /// assert_eq!( + /// got, + /// [ + /// Some(&mut 1807), + /// Some(&mut 1800), + /// ], + /// ); + /// + /// // SAFETY: The keys do not overlap. + /// let got = unsafe { libraries.get_disjoint_unchecked_mut([ + /// "Athenæum", + /// "New York Public Library", + /// ]) }; + /// // Missing keys result in None + /// assert_eq!(got, [Some(&mut 1807), None]); + /// ``` + pub unsafe fn get_disjoint_unchecked_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<&'_ mut V>; N] + where + Q: Hash + Equivalent + ?Sized, + { + unsafe { + self.get_disjoint_unchecked_mut_inner(ks) + .map(|res| res.map(|(_, v)| v)) + } + } + + /// Attempts to get mutable references to `N` values in the map at once, without validating that + /// the values are unique. + #[deprecated(note = "use `get_disjoint_unchecked_mut` instead")] + pub unsafe fn get_many_unchecked_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<&'_ mut V>; N] + where + Q: Hash + Equivalent + ?Sized, + { + unsafe { self.get_disjoint_unchecked_mut(ks) } + } + + /// Attempts to get mutable references to `N` values in the map at once, with immutable + /// references to the corresponding keys. + /// + /// Returns an array of length `N` with the results of each query. For soundness, at most one + /// mutable reference will be returned to any value. `None` will be used if the key is missing. + /// + /// # Panics + /// + /// Panics if any keys are overlapping. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Bodleian Library".to_string(), 1602); + /// libraries.insert("Athenæum".to_string(), 1807); + /// libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); + /// libraries.insert("Library of Congress".to_string(), 1800); + /// + /// let got = libraries.get_disjoint_key_value_mut([ + /// "Bodleian Library", + /// "Herzogin-Anna-Amalia-Bibliothek", + /// ]); + /// assert_eq!( + /// got, + /// [ + /// Some((&"Bodleian Library".to_string(), &mut 1602)), + /// Some((&"Herzogin-Anna-Amalia-Bibliothek".to_string(), &mut 1691)), + /// ], + /// ); + /// // Missing keys result in None + /// let got = libraries.get_disjoint_key_value_mut([ + /// "Bodleian Library", + /// "Gewandhaus", + /// ]); + /// assert_eq!(got, [Some((&"Bodleian Library".to_string(), &mut 1602)), None]); + /// ``` + /// + /// ```should_panic + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Bodleian Library".to_string(), 1602); + /// libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); + /// + /// // Duplicate keys result in panic! + /// let got = libraries.get_disjoint_key_value_mut([ + /// "Bodleian Library", + /// "Herzogin-Anna-Amalia-Bibliothek", + /// "Herzogin-Anna-Amalia-Bibliothek", + /// ]); + /// ``` + pub fn get_disjoint_key_value_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<(&'_ K, &'_ mut V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + self.get_disjoint_mut_inner(ks) + .map(|res| res.map(|(k, v)| (&*k, v))) + } + + /// Attempts to get mutable references to `N` values in the map at once, with immutable + /// references to the corresponding keys. + #[deprecated(note = "use `get_disjoint_key_value_mut` instead")] + pub fn get_many_key_value_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<(&'_ K, &'_ mut V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + self.get_disjoint_key_value_mut(ks) + } + + /// Attempts to get mutable references to `N` values in the map at once, with immutable + /// references to the corresponding keys, without validating that the values are unique. + /// + /// Returns an array of length `N` with the results of each query. `None` will be returned if + /// any of the keys are missing. + /// + /// For a safe alternative see [`get_disjoint_key_value_mut`](`HashMap::get_disjoint_key_value_mut`). + /// + /// # Safety + /// + /// Calling this method with overlapping keys is *[undefined behavior]* even if the resulting + /// references are not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut libraries = HashMap::new(); + /// libraries.insert("Bodleian Library".to_string(), 1602); + /// libraries.insert("Athenæum".to_string(), 1807); + /// libraries.insert("Herzogin-Anna-Amalia-Bibliothek".to_string(), 1691); + /// libraries.insert("Library of Congress".to_string(), 1800); + /// + /// let got = libraries.get_disjoint_key_value_mut([ + /// "Bodleian Library", + /// "Herzogin-Anna-Amalia-Bibliothek", + /// ]); + /// assert_eq!( + /// got, + /// [ + /// Some((&"Bodleian Library".to_string(), &mut 1602)), + /// Some((&"Herzogin-Anna-Amalia-Bibliothek".to_string(), &mut 1691)), + /// ], + /// ); + /// // Missing keys result in None + /// let got = libraries.get_disjoint_key_value_mut([ + /// "Bodleian Library", + /// "Gewandhaus", + /// ]); + /// assert_eq!( + /// got, + /// [ + /// Some((&"Bodleian Library".to_string(), &mut 1602)), + /// None, + /// ], + /// ); + /// ``` + pub unsafe fn get_disjoint_key_value_unchecked_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<(&'_ K, &'_ mut V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + unsafe { + self.get_disjoint_unchecked_mut_inner(ks) + .map(|res| res.map(|(k, v)| (&*k, v))) + } + } + + /// Attempts to get mutable references to `N` values in the map at once, with immutable + /// references to the corresponding keys, without validating that the values are unique. + #[deprecated(note = "use `get_disjoint_key_value_unchecked_mut` instead")] + pub unsafe fn get_many_key_value_unchecked_mut( + &mut self, + ks: [&Q; N], + ) -> [Option<(&'_ K, &'_ mut V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + unsafe { self.get_disjoint_key_value_unchecked_mut(ks) } + } + + fn get_disjoint_mut_inner( + &mut self, + ks: [&Q; N], + ) -> [Option<&'_ mut (K, V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + let hashes = self.build_hashes_inner(ks); + self.table + .get_disjoint_mut(hashes, |i, (k, _)| ks[i].equivalent(k)) + } + + unsafe fn get_disjoint_unchecked_mut_inner( + &mut self, + ks: [&Q; N], + ) -> [Option<&'_ mut (K, V)>; N] + where + Q: Hash + Equivalent + ?Sized, + { + unsafe { + let hashes = self.build_hashes_inner(ks); + self.table + .get_disjoint_unchecked_mut(hashes, |i, (k, _)| ks[i].equivalent(k)) + } + } + + fn build_hashes_inner(&self, ks: [&Q; N]) -> [u64; N] + where + Q: Hash + Equivalent + ?Sized, + { + let mut hashes = [0_u64; N]; + for i in 0..N { + hashes[i] = make_hash::(&self.hash_builder, ks[i]); + } + hashes + } + + /// Inserts a key-value pair into the map. + /// + /// If the map did not have this key present, [`None`] is returned. + /// + /// If the map did have this key present, the value is updated, and the old + /// value is returned. The key is not updated, though; this matters for + /// types that can be `==` without being identical. See the [`std::collections`] + /// module-level documentation for more. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// assert_eq!(map.insert(37, "a"), None); + /// assert_eq!(map.is_empty(), false); + /// + /// map.insert(37, "b"); + /// assert_eq!(map.insert(37, "c"), Some("b")); + /// assert_eq!(map[&37], "c"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(&mut self, k: K, v: V) -> Option { + let hash = make_hash(&self.hash_builder, &k); + let equivalent = equivalent_key(&k); + let hasher = make_hasher(&self.hash_builder); + match self + .table + .find_or_find_insert_index(hash, equivalent, hasher) + { + Ok(bucket) => Some(mem::replace(unsafe { &mut bucket.as_mut().1 }, v)), + Err(index) => { + unsafe { + self.table.insert_at_index(hash, index, (k, v)); + } + None + } + } + } + + /// Insert a key-value pair into the map without checking + /// if the key already exists in the map. + /// + /// This operation is faster than regular insert, because it does not perform + /// lookup before insertion. + /// + /// This operation is useful during initial population of the map. + /// For example, when constructing a map from another map, we know + /// that keys are unique. + /// + /// Returns a reference to the key and value just inserted. + /// + /// # Safety + /// + /// This operation is safe if a key does not exist in the map. + /// + /// However, if a key exists in the map already, the behavior is unspecified: + /// this operation may panic, loop forever, or any following operation with the map + /// may panic, loop forever or return arbitrary result. + /// + /// That said, this operation (and following operations) are guaranteed to + /// not violate memory safety. + /// + /// However this operation is still unsafe because the resulting `HashMap` + /// may be passed to unsafe code which does expect the map to behave + /// correctly, and would cause unsoundness as a result. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map1 = HashMap::new(); + /// assert_eq!(map1.insert(1, "a"), None); + /// assert_eq!(map1.insert(2, "b"), None); + /// assert_eq!(map1.insert(3, "c"), None); + /// assert_eq!(map1.len(), 3); + /// + /// let mut map2 = HashMap::new(); + /// + /// for (key, value) in map1.into_iter() { + /// unsafe { + /// map2.insert_unique_unchecked(key, value); + /// } + /// } + /// + /// let (key, value) = unsafe { map2.insert_unique_unchecked(4, "d") }; + /// assert_eq!(key, &4); + /// assert_eq!(value, &mut "d"); + /// *value = "e"; + /// + /// assert_eq!(map2[&1], "a"); + /// assert_eq!(map2[&2], "b"); + /// assert_eq!(map2[&3], "c"); + /// assert_eq!(map2[&4], "e"); + /// assert_eq!(map2.len(), 4); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub unsafe fn insert_unique_unchecked(&mut self, k: K, v: V) -> (&K, &mut V) { + let hash = make_hash::(&self.hash_builder, &k); + let bucket = self + .table + .insert(hash, (k, v), make_hasher::<_, V, S>(&self.hash_builder)); + let (k_ref, v_ref) = unsafe { bucket.as_mut() }; + (k_ref, v_ref) + } + + /// Tries to insert a key-value pair into the map, and returns + /// a mutable reference to the value in the entry. + /// + /// # Errors + /// + /// If the map already had this key present, nothing is updated, and + /// an error containing the occupied entry and the value is returned. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::OccupiedError; + /// + /// let mut map = HashMap::new(); + /// assert_eq!(map.try_insert(37, "a").unwrap(), &"a"); + /// + /// match map.try_insert(37, "b") { + /// Err(OccupiedError { entry, value }) => { + /// assert_eq!(entry.key(), &37); + /// assert_eq!(entry.get(), &"a"); + /// assert_eq!(value, "b"); + /// } + /// _ => panic!() + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn try_insert( + &mut self, + key: K, + value: V, + ) -> Result<&mut V, OccupiedError<'_, K, V, S, A>> { + match self.entry(key) { + Entry::Occupied(entry) => Err(OccupiedError { entry, value }), + Entry::Vacant(entry) => Ok(entry.insert(value)), + } + } + + /// Removes a key from the map, returning the value at the key if the key + /// was previously in the map. Keeps the allocated memory for reuse. + /// + /// The key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// // The map is empty + /// assert!(map.is_empty() && map.capacity() == 0); + /// + /// map.insert(1, "a"); + /// + /// assert_eq!(map.remove(&1), Some("a")); + /// assert_eq!(map.remove(&1), None); + /// + /// // Now map holds none elements + /// assert!(map.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(&mut self, k: &Q) -> Option + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + match self.remove_entry(k) { + Some((_, v)) => Some(v), + None => None, + } + } + + /// Removes a key from the map, returning the stored key and value if the + /// key was previously in the map. Keeps the allocated memory for reuse. + /// + /// The key may be any borrowed form of the map's key type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the key type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// // The map is empty + /// assert!(map.is_empty() && map.capacity() == 0); + /// + /// map.insert(1, "a"); + /// + /// assert_eq!(map.remove_entry(&1), Some((1, "a"))); + /// assert_eq!(map.remove(&1), None); + /// + /// // Now map hold none elements + /// assert!(map.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove_entry(&mut self, k: &Q) -> Option<(K, V)> + where + Q: Hash + Equivalent + ?Sized, + { + let hash = make_hash::(&self.hash_builder, k); + self.table.remove_entry(hash, equivalent_key(k)) + } + + /// Returns the total amount of memory allocated internally by the hash + /// set, in bytes. + /// + /// The returned number is informational only. It is intended to be + /// primarily used for memory profiling. + #[inline] + pub fn allocation_size(&self) -> usize { + self.table.allocation_size() + } +} + +impl PartialEq for HashMap +where + K: Eq + Hash, + V: PartialEq, + S: BuildHasher, + A: Allocator, +{ + fn eq(&self, other: &Self) -> bool { + if self.len() != other.len() { + return false; + } + + self.iter() + .all(|(key, value)| other.get(key).is_some_and(|v| *value == *v)) + } +} + +impl Eq for HashMap +where + K: Eq + Hash, + V: Eq, + S: BuildHasher, + A: Allocator, +{ +} + +impl Debug for HashMap +where + K: Debug, + V: Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_map().entries(self.iter()).finish() + } +} + +impl Default for HashMap +where + S: Default, + A: Default + Allocator, +{ + /// Creates an empty `HashMap`, with the `Default` value for the hasher and allocator. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use std::hash::RandomState; + /// + /// // You can specify all types of HashMap, including hasher and allocator. + /// // Created map is empty and don't allocate memory + /// let map: HashMap = Default::default(); + /// assert_eq!(map.capacity(), 0); + /// let map: HashMap = HashMap::default(); + /// assert_eq!(map.capacity(), 0); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self::with_hasher_in(Default::default(), Default::default()) + } +} + +impl Index<&Q> for HashMap +where + K: Eq + Hash, + Q: Hash + Equivalent + ?Sized, + S: BuildHasher, + A: Allocator, +{ + type Output = V; + + /// Returns a reference to the value corresponding to the supplied key. + /// + /// # Panics + /// + /// Panics if the key is not present in the `HashMap`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let map: HashMap<_, _> = [("a", "One"), ("b", "Two")].into(); + /// + /// assert_eq!(map[&"a"], "One"); + /// assert_eq!(map[&"b"], "Two"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn index(&self, key: &Q) -> &V { + self.get(key).expect("no entry found for key") + } +} + +// The default hasher is used to match the std implementation signature +#[cfg(feature = "default-hasher")] +impl From<[(K, V); N]> for HashMap +where + K: Eq + Hash, + A: Default + Allocator, +{ + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let map1 = HashMap::from([(1, 2), (3, 4)]); + /// let map2: HashMap<_, _> = [(1, 2), (3, 4)].into(); + /// assert_eq!(map1, map2); + /// ``` + fn from(arr: [(K, V); N]) -> Self { + arr.into_iter().collect() + } +} + +/// An iterator over the entries of a `HashMap` in arbitrary order. +/// The iterator element type is `(&'a K, &'a V)`. +/// +/// This `struct` is created by the [`iter`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`iter`]: HashMap::iter +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut iter = map.iter(); +/// let mut vec = vec![iter.next(), iter.next(), iter.next()]; +/// +/// // The `Iter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some((&1, &"a")), Some((&2, &"b")), Some((&3, &"c"))]); +/// +/// // It is fused iterator +/// assert_eq!(iter.next(), None); +/// assert_eq!(iter.next(), None); +/// ``` +pub struct Iter<'a, K, V> { + inner: RawIter<(K, V)>, + marker: PhantomData<(&'a K, &'a V)>, +} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl Clone for Iter<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for Iter<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// A mutable iterator over the entries of a `HashMap` in arbitrary order. +/// The iterator element type is `(&'a K, &'a mut V)`. +/// +/// This `struct` is created by the [`iter_mut`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`iter_mut`]: HashMap::iter_mut +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let mut map: HashMap<_, _> = [(1, "One".to_owned()), (2, "Two".into())].into(); +/// +/// let mut iter = map.iter_mut(); +/// iter.next().map(|(_, v)| v.push_str(" Mississippi")); +/// iter.next().map(|(_, v)| v.push_str(" Mississippi")); +/// +/// // It is fused iterator +/// assert_eq!(iter.next(), None); +/// assert_eq!(iter.next(), None); +/// +/// assert_eq!(map.get(&1).unwrap(), &"One Mississippi".to_owned()); +/// assert_eq!(map.get(&2).unwrap(), &"Two Mississippi".to_owned()); +/// ``` +pub struct IterMut<'a, K, V> { + inner: RawIter<(K, V)>, + // To ensure invariance with respect to V + marker: PhantomData<(&'a K, &'a mut V)>, +} + +// We override the default Send impl which has K: Sync instead of K: Send. Both +// are correct, but this one is more general since it allows keys which +// implement Send but not Sync. +unsafe impl Send for IterMut<'_, K, V> {} + +impl IterMut<'_, K, V> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub(super) fn iter(&self) -> Iter<'_, K, V> { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +/// An owning iterator over the entries of a `HashMap` in arbitrary order. +/// The iterator element type is `(K, V)`. +/// +/// This `struct` is created by the [`into_iter`] method on [`HashMap`] +/// (provided by the [`IntoIterator`] trait). See its documentation for more. +/// The map cannot be used after calling that method. +/// +/// [`into_iter`]: HashMap::into_iter +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut iter = map.into_iter(); +/// let mut vec = vec![iter.next(), iter.next(), iter.next()]; +/// +/// // The `IntoIter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some((1, "a")), Some((2, "b")), Some((3, "c"))]); +/// +/// // It is fused iterator +/// assert_eq!(iter.next(), None); +/// assert_eq!(iter.next(), None); +/// ``` +pub struct IntoIter { + inner: RawIntoIter<(K, V), A>, +} + +impl IntoIter { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub(super) fn iter(&self) -> Iter<'_, K, V> { + Iter { + inner: self.inner.iter(), + marker: PhantomData, + } + } +} + +/// An owning iterator over the keys of a `HashMap` in arbitrary order. +/// The iterator element type is `K`. +/// +/// This `struct` is created by the [`into_keys`] method on [`HashMap`]. +/// See its documentation for more. +/// The map cannot be used after calling that method. +/// +/// [`into_keys`]: HashMap::into_keys +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut keys = map.into_keys(); +/// let mut vec = vec![keys.next(), keys.next(), keys.next()]; +/// +/// // The `IntoKeys` iterator produces keys in arbitrary order, so the +/// // keys must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some(1), Some(2), Some(3)]); +/// +/// // It is fused iterator +/// assert_eq!(keys.next(), None); +/// assert_eq!(keys.next(), None); +/// ``` +pub struct IntoKeys { + inner: IntoIter, +} + +impl Default for IntoKeys { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl Iterator for IntoKeys { + type Item = K; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next().map(|(k, _)| k) + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[inline] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, (k, _)| f(acc, k)) + } +} + +impl ExactSizeIterator for IntoKeys { + #[inline] + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for IntoKeys {} + +impl fmt::Debug for IntoKeys { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries(self.inner.iter().map(|(k, _)| k)) + .finish() + } +} + +/// An owning iterator over the values of a `HashMap` in arbitrary order. +/// The iterator element type is `V`. +/// +/// This `struct` is created by the [`into_values`] method on [`HashMap`]. +/// See its documentation for more. The map cannot be used after calling that method. +/// +/// [`into_values`]: HashMap::into_values +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut values = map.into_values(); +/// let mut vec = vec![values.next(), values.next(), values.next()]; +/// +/// // The `IntoValues` iterator produces values in arbitrary order, so +/// // the values must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some("a"), Some("b"), Some("c")]); +/// +/// // It is fused iterator +/// assert_eq!(values.next(), None); +/// assert_eq!(values.next(), None); +/// ``` +pub struct IntoValues { + inner: IntoIter, +} + +impl Default for IntoValues { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl Iterator for IntoValues { + type Item = V; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next().map(|(_, v)| v) + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[inline] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, (_, v)| f(acc, v)) + } +} + +impl ExactSizeIterator for IntoValues { + #[inline] + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for IntoValues {} + +impl fmt::Debug for IntoValues { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries(self.inner.iter().map(|(_, v)| v)) + .finish() + } +} + +/// An iterator over the keys of a `HashMap` in arbitrary order. +/// The iterator element type is `&'a K`. +/// +/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`keys`]: HashMap::keys +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut keys = map.keys(); +/// let mut vec = vec![keys.next(), keys.next(), keys.next()]; +/// +/// // The `Keys` iterator produces keys in arbitrary order, so the +/// // keys must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some(&1), Some(&2), Some(&3)]); +/// +/// // It is fused iterator +/// assert_eq!(keys.next(), None); +/// assert_eq!(keys.next(), None); +/// ``` +pub struct Keys<'a, K, V> { + inner: Iter<'a, K, V>, +} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl Clone for Keys<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Keys { + inner: self.inner.clone(), + } + } +} + +impl fmt::Debug for Keys<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// An iterator over the values of a `HashMap` in arbitrary order. +/// The iterator element type is `&'a V`. +/// +/// This `struct` is created by the [`values`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`values`]: HashMap::values +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut values = map.values(); +/// let mut vec = vec![values.next(), values.next(), values.next()]; +/// +/// // The `Values` iterator produces values in arbitrary order, so the +/// // values must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some(&"a"), Some(&"b"), Some(&"c")]); +/// +/// // It is fused iterator +/// assert_eq!(values.next(), None); +/// assert_eq!(values.next(), None); +/// ``` +pub struct Values<'a, K, V> { + inner: Iter<'a, K, V>, +} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl Clone for Values<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Values { + inner: self.inner.clone(), + } + } +} + +impl fmt::Debug for Values<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// A draining iterator over the entries of a `HashMap` in arbitrary +/// order. The iterator element type is `(K, V)`. +/// +/// This `struct` is created by the [`drain`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`drain`]: HashMap::drain +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let mut map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut drain_iter = map.drain(); +/// let mut vec = vec![drain_iter.next(), drain_iter.next(), drain_iter.next()]; +/// +/// // The `Drain` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some((1, "a")), Some((2, "b")), Some((3, "c"))]); +/// +/// // It is fused iterator +/// assert_eq!(drain_iter.next(), None); +/// assert_eq!(drain_iter.next(), None); +/// ``` +pub struct Drain<'a, K, V, A: Allocator = Global> { + inner: RawDrain<'a, (K, V), A>, +} + +impl Drain<'_, K, V, A> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub(super) fn iter(&self) -> Iter<'_, K, V> { + Iter { + inner: self.inner.iter(), + marker: PhantomData, + } + } +} + +/// A draining iterator over entries of a `HashMap` which don't satisfy the predicate +/// `f(&k, &mut v)` in arbitrary order. The iterator element type is `(K, V)`. +/// +/// This `struct` is created by the [`extract_if`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`extract_if`]: HashMap::extract_if +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let mut map: HashMap = [(1, "a"), (2, "b"), (3, "c")].into(); +/// +/// let mut extract_if = map.extract_if(|k, _v| k % 2 != 0); +/// let mut vec = vec![extract_if.next(), extract_if.next()]; +/// +/// // The `ExtractIf` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [Some((1, "a")),Some((3, "c"))]); +/// +/// // It is fused iterator +/// assert_eq!(extract_if.next(), None); +/// assert_eq!(extract_if.next(), None); +/// drop(extract_if); +/// +/// assert_eq!(map.len(), 1); +/// ``` +#[must_use = "Iterators are lazy unless consumed"] +pub struct ExtractIf<'a, K, V, F, A: Allocator = Global> { + f: F, + inner: RawExtractIf<'a, (K, V), A>, +} + +impl Iterator for ExtractIf<'_, K, V, F, A> +where + F: FnMut(&K, &mut V) -> bool, + A: Allocator, +{ + type Item = (K, V); + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + self.inner.next(|&mut (ref k, ref mut v)| (self.f)(k, v)) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, self.inner.iter.size_hint().1) + } +} + +impl FusedIterator for ExtractIf<'_, K, V, F, A> +where + F: FnMut(&K, &mut V) -> bool, + A: Allocator, +{ +} + +/// A mutable iterator over the values of a `HashMap` in arbitrary order. +/// The iterator element type is `&'a mut V`. +/// +/// This `struct` is created by the [`values_mut`] method on [`HashMap`]. See its +/// documentation for more. +/// +/// [`values_mut`]: HashMap::values_mut +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashMap; +/// +/// let mut map: HashMap<_, _> = [(1, "One".to_owned()), (2, "Two".into())].into(); +/// +/// let mut values = map.values_mut(); +/// values.next().map(|v| v.push_str(" Mississippi")); +/// values.next().map(|v| v.push_str(" Mississippi")); +/// +/// // It is fused iterator +/// assert_eq!(values.next(), None); +/// assert_eq!(values.next(), None); +/// +/// assert_eq!(map.get(&1).unwrap(), &"One Mississippi".to_owned()); +/// assert_eq!(map.get(&2).unwrap(), &"Two Mississippi".to_owned()); +/// ``` +pub struct ValuesMut<'a, K, V> { + inner: IterMut<'a, K, V>, +} + +/// A view into a single entry in a map, which may either be vacant or occupied. +/// +/// This `enum` is constructed from the [`entry`] method on [`HashMap`]. +/// +/// [`entry`]: HashMap::entry +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{Entry, HashMap, OccupiedEntry}; +/// +/// let mut map = HashMap::new(); +/// map.extend([("a", 10), ("b", 20), ("c", 30)]); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (insert) +/// let entry: Entry<_, _, _> = map.entry("a"); +/// let _raw_o: OccupiedEntry<_, _, _> = entry.insert(1); +/// assert_eq!(map.len(), 3); +/// // Nonexistent key (insert) +/// map.entry("d").insert(4); +/// +/// // Existing key (or_insert) +/// let v = map.entry("b").or_insert(2); +/// assert_eq!(std::mem::replace(v, 2), 20); +/// // Nonexistent key (or_insert) +/// map.entry("e").or_insert(5); +/// +/// // Existing key (or_insert_with) +/// let v = map.entry("c").or_insert_with(|| 3); +/// assert_eq!(std::mem::replace(v, 3), 30); +/// // Nonexistent key (or_insert_with) +/// map.entry("f").or_insert_with(|| 6); +/// +/// println!("Our HashMap: {:?}", map); +/// +/// let mut vec: Vec<_> = map.iter().map(|(&k, &v)| (k, v)).collect(); +/// // The `Iter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [("a", 1), ("b", 2), ("c", 3), ("d", 4), ("e", 5), ("f", 6)]); +/// ``` +pub enum Entry<'a, K, V, S, A = Global> +where + A: Allocator, +{ + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// let mut map: HashMap<_, _> = [("a", 100), ("b", 200)].into(); + /// + /// match map.entry("a") { + /// Entry::Vacant(_) => unreachable!(), + /// Entry::Occupied(_) => { } + /// } + /// ``` + Occupied(OccupiedEntry<'a, K, V, S, A>), + + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// let mut map: HashMap<&str, i32> = HashMap::new(); + /// + /// match map.entry("a") { + /// Entry::Occupied(_) => unreachable!(), + /// Entry::Vacant(_) => { } + /// } + /// ``` + Vacant(VacantEntry<'a, K, V, S, A>), +} + +impl Debug for Entry<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Entry::Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), + Entry::Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(), + } + } +} + +/// A view into an occupied entry in a [`HashMap`]. +/// It is part of the [`Entry`] and [`EntryRef`] enums. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{Entry, HashMap, OccupiedEntry}; +/// +/// let mut map = HashMap::new(); +/// map.extend([("a", 10), ("b", 20), ("c", 30)]); +/// +/// let _entry_o: OccupiedEntry<_, _, _> = map.entry("a").insert(100); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (insert and update) +/// match map.entry("a") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(mut view) => { +/// assert_eq!(view.get(), &100); +/// let v = view.get_mut(); +/// *v *= 10; +/// assert_eq!(view.insert(1111), 1000); +/// } +/// } +/// +/// assert_eq!(map[&"a"], 1111); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (take) +/// match map.entry("c") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.remove_entry(), ("c", 30)); +/// } +/// } +/// assert_eq!(map.get(&"c"), None); +/// assert_eq!(map.len(), 2); +/// ``` +pub struct OccupiedEntry<'a, K, V, S = DefaultHashBuilder, A: Allocator = Global> { + hash: u64, + elem: Bucket<(K, V)>, + table: &'a mut HashMap, +} + +unsafe impl Send for OccupiedEntry<'_, K, V, S, A> +where + K: Send, + V: Send, + S: Send, + A: Send + Allocator, +{ +} +unsafe impl Sync for OccupiedEntry<'_, K, V, S, A> +where + K: Sync, + V: Sync, + S: Sync, + A: Sync + Allocator, +{ +} + +impl Debug for OccupiedEntry<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedEntry") + .field("key", self.key()) + .field("value", self.get()) + .finish() + } +} + +/// A view into a vacant entry in a `HashMap`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{Entry, HashMap, VacantEntry}; +/// +/// let mut map = HashMap::<&str, i32>::new(); +/// +/// let entry_v: VacantEntry<_, _, _> = match map.entry("a") { +/// Entry::Vacant(view) => view, +/// Entry::Occupied(_) => unreachable!(), +/// }; +/// entry_v.insert(10); +/// assert!(map[&"a"] == 10 && map.len() == 1); +/// +/// // Nonexistent key (insert and update) +/// match map.entry("b") { +/// Entry::Occupied(_) => unreachable!(), +/// Entry::Vacant(view) => { +/// let value = view.insert(2); +/// assert_eq!(*value, 2); +/// *value = 20; +/// } +/// } +/// assert!(map[&"b"] == 20 && map.len() == 2); +/// ``` +pub struct VacantEntry<'a, K, V, S = DefaultHashBuilder, A: Allocator = Global> { + hash: u64, + key: K, + table: &'a mut HashMap, +} + +impl Debug for VacantEntry<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("VacantEntry").field(self.key()).finish() + } +} + +/// A view into a single entry in a map, which may either be vacant or occupied, +/// with any borrowed form of the map's key type. +/// +/// +/// This `enum` is constructed from the [`entry_ref`] method on [`HashMap`]. +/// +/// [`Hash`] and [`Eq`] on the borrowed form of the map's key type *must* match those +/// for the key type. It also require that key may be constructed from the borrowed +/// form through the [`ToOwned`] trait. +/// +/// [`entry_ref`]: HashMap::entry_ref +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{EntryRef, HashMap, OccupiedEntry}; +/// +/// let mut map = HashMap::new(); +/// map.extend([("a".to_owned(), 10), ("b".into(), 20), ("c".into(), 30)]); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (insert) +/// let key = String::from("a"); +/// let entry: EntryRef<_, _, _, _> = map.entry_ref(&key); +/// let _raw_o: OccupiedEntry<_, _, _, _> = entry.insert(1); +/// assert_eq!(map.len(), 3); +/// // Nonexistent key (insert) +/// map.entry_ref("d").insert(4); +/// +/// // Existing key (or_insert) +/// let v = map.entry_ref("b").or_insert(2); +/// assert_eq!(std::mem::replace(v, 2), 20); +/// // Nonexistent key (or_insert) +/// map.entry_ref("e").or_insert(5); +/// +/// // Existing key (or_insert_with) +/// let v = map.entry_ref("c").or_insert_with(|| 3); +/// assert_eq!(std::mem::replace(v, 3), 30); +/// // Nonexistent key (or_insert_with) +/// map.entry_ref("f").or_insert_with(|| 6); +/// +/// println!("Our HashMap: {:?}", map); +/// +/// for (key, value) in ["a", "b", "c", "d", "e", "f"].into_iter().zip(1..=6) { +/// assert_eq!(map[key], value) +/// } +/// assert_eq!(map.len(), 6); +/// ``` +pub enum EntryRef<'a, 'b, K, Q: ?Sized, V, S, A = Global> +where + A: Allocator, +{ + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{EntryRef, HashMap}; + /// let mut map: HashMap<_, _> = [("a".to_owned(), 100), ("b".into(), 200)].into(); + /// + /// match map.entry_ref("a") { + /// EntryRef::Vacant(_) => unreachable!(), + /// EntryRef::Occupied(_) => { } + /// } + /// ``` + Occupied(OccupiedEntry<'a, K, V, S, A>), + + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{EntryRef, HashMap}; + /// let mut map: HashMap = HashMap::new(); + /// + /// match map.entry_ref("a") { + /// EntryRef::Occupied(_) => unreachable!(), + /// EntryRef::Vacant(_) => { } + /// } + /// ``` + Vacant(VacantEntryRef<'a, 'b, K, Q, V, S, A>), +} + +impl Debug for EntryRef<'_, '_, K, Q, V, S, A> +where + K: Debug + Borrow, + Q: Debug + ?Sized, + V: Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + EntryRef::Vacant(ref v) => f.debug_tuple("EntryRef").field(v).finish(), + EntryRef::Occupied(ref o) => f.debug_tuple("EntryRef").field(o).finish(), + } + } +} + +/// A view into a vacant entry in a `HashMap`. +/// It is part of the [`EntryRef`] enum. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{EntryRef, HashMap, VacantEntryRef}; +/// +/// let mut map = HashMap::::new(); +/// +/// let entry_v: VacantEntryRef<_, _, _, _> = match map.entry_ref("a") { +/// EntryRef::Vacant(view) => view, +/// EntryRef::Occupied(_) => unreachable!(), +/// }; +/// entry_v.insert(10); +/// assert!(map["a"] == 10 && map.len() == 1); +/// +/// // Nonexistent key (insert and update) +/// match map.entry_ref("b") { +/// EntryRef::Occupied(_) => unreachable!(), +/// EntryRef::Vacant(view) => { +/// let value = view.insert(2); +/// assert_eq!(*value, 2); +/// *value = 20; +/// } +/// } +/// assert!(map["b"] == 20 && map.len() == 2); +/// ``` +pub struct VacantEntryRef<'map, 'key, K, Q: ?Sized, V, S, A: Allocator = Global> { + hash: u64, + key: &'key Q, + table: &'map mut HashMap, +} + +impl Debug for VacantEntryRef<'_, '_, K, Q, V, S, A> +where + K: Borrow, + Q: Debug + ?Sized, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("VacantEntryRef").field(&self.key()).finish() + } +} + +/// The error returned by [`try_insert`](HashMap::try_insert) when the key already exists. +/// +/// Contains the occupied entry, and the value that was not inserted. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{HashMap, OccupiedError}; +/// +/// let mut map: HashMap<_, _> = [("a", 10), ("b", 20)].into(); +/// +/// // try_insert method returns mutable reference to the value if keys are vacant, +/// // but if the map did have key present, nothing is updated, and the provided +/// // value is returned inside `Err(_)` variant +/// match map.try_insert("a", 100) { +/// Err(OccupiedError { mut entry, value }) => { +/// assert_eq!(entry.key(), &"a"); +/// assert_eq!(value, 100); +/// assert_eq!(entry.insert(100), 10) +/// } +/// _ => unreachable!(), +/// } +/// assert_eq!(map[&"a"], 100); +/// ``` +pub struct OccupiedError<'a, K, V, S, A: Allocator = Global> { + /// The entry in the map that was already occupied. + pub entry: OccupiedEntry<'a, K, V, S, A>, + /// The value which was not inserted, because the entry was already occupied. + pub value: V, +} + +impl Debug for OccupiedError<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedError") + .field("key", self.entry.key()) + .field("old_value", self.entry.get()) + .field("new_value", &self.value) + .finish() + } +} + +impl fmt::Display for OccupiedError<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "failed to insert {:?}, key {:?} already exists with value {:?}", + self.value, + self.entry.key(), + self.entry.get(), + ) + } +} + +impl<'a, K, V, S, A: Allocator> IntoIterator for &'a HashMap { + type Item = (&'a K, &'a V); + type IntoIter = Iter<'a, K, V>; + + /// Creates an iterator over the entries of a `HashMap` in arbitrary order. + /// The iterator element type is `(&'a K, &'a V)`. + /// + /// Return the same `Iter` struct as by the [`iter`] method on [`HashMap`]. + /// + /// [`iter`]: HashMap::iter + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let map_one: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].into(); + /// let mut map_two = HashMap::new(); + /// + /// for (key, value) in &map_one { + /// println!("Key: {}, Value: {}", key, value); + /// map_two.insert(*key, *value); + /// } + /// + /// assert_eq!(map_one, map_two); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> Iter<'a, K, V> { + self.iter() + } +} + +impl<'a, K, V, S, A: Allocator> IntoIterator for &'a mut HashMap { + type Item = (&'a K, &'a mut V); + type IntoIter = IterMut<'a, K, V>; + + /// Creates an iterator over the entries of a `HashMap` in arbitrary order + /// with mutable references to the values. The iterator element type is + /// `(&'a K, &'a mut V)`. + /// + /// Return the same `IterMut` struct as by the [`iter_mut`] method on + /// [`HashMap`]. + /// + /// [`iter_mut`]: HashMap::iter_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// let mut map: HashMap<_, _> = [("a", 1), ("b", 2), ("c", 3)].into(); + /// + /// for (key, value) in &mut map { + /// println!("Key: {}, Value: {}", key, value); + /// *value *= 2; + /// } + /// + /// let mut vec = map.iter().collect::>(); + /// // The `Iter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [(&"a", &2), (&"b", &4), (&"c", &6)]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> IterMut<'a, K, V> { + self.iter_mut() + } +} + +impl IntoIterator for HashMap { + type Item = (K, V); + type IntoIter = IntoIter; + + /// Creates a consuming iterator, that is, one that moves each key-value + /// pair out of the map in arbitrary order. The map cannot be used after + /// calling this. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let map: HashMap<_, _> = [("a", 1), ("b", 2), ("c", 3)].into(); + /// + /// // Not possible with .iter() + /// let mut vec: Vec<(&str, i32)> = map.into_iter().collect(); + /// // The `IntoIter` iterator produces items in arbitrary order, so + /// // the items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [("a", 1), ("b", 2), ("c", 3)]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> IntoIter { + IntoIter { + inner: self.table.into_iter(), + } + } +} + +impl Default for Iter<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} +impl<'a, K, V> Iterator for Iter<'a, K, V> { + type Item = (&'a K, &'a V); + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<(&'a K, &'a V)> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(x) => unsafe { + let r = x.as_ref(); + Some((&r.0, &r.1)) + }, + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, x| unsafe { + let (k, v) = x.as_ref(); + f(acc, (k, v)) + }) + } +} +impl ExactSizeIterator for Iter<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for Iter<'_, K, V> {} + +impl Default for IterMut<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} +impl<'a, K, V> Iterator for IterMut<'a, K, V> { + type Item = (&'a K, &'a mut V); + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<(&'a K, &'a mut V)> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(x) => unsafe { + let r = x.as_mut(); + Some((&r.0, &mut r.1)) + }, + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, x| unsafe { + let (k, v) = x.as_mut(); + f(acc, (k, v)) + }) + } +} +impl ExactSizeIterator for IterMut<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for IterMut<'_, K, V> {} + +impl fmt::Debug for IterMut<'_, K, V> +where + K: fmt::Debug, + V: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl Iterator for IntoIter { + type Item = (K, V); + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<(K, V)> { + self.inner.next() + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, f) + } +} +impl ExactSizeIterator for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for IntoIter {} + +impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +impl Default for Keys<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl<'a, K, V> Iterator for Keys<'a, K, V> { + type Item = &'a K; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a K> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some((k, _)) => Some(k), + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, (k, _)| f(acc, k)) + } +} +impl ExactSizeIterator for Keys<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for Keys<'_, K, V> {} + +impl Default for Values<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl<'a, K, V> Iterator for Values<'a, K, V> { + type Item = &'a V; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a V> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some((_, v)) => Some(v), + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, (_, v)| f(acc, v)) + } +} +impl ExactSizeIterator for Values<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for Values<'_, K, V> {} + +impl Default for ValuesMut<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} +impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { + type Item = &'a mut V; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a mut V> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some((_, v)) => Some(v), + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, (_, v)| f(acc, v)) + } +} +impl ExactSizeIterator for ValuesMut<'_, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for ValuesMut<'_, K, V> {} + +impl fmt::Debug for ValuesMut<'_, K, V> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries(self.inner.iter().map(|(_, val)| val)) + .finish() + } +} + +impl Iterator for Drain<'_, K, V, A> { + type Item = (K, V); + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<(K, V)> { + self.inner.next() + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, f) + } +} +impl ExactSizeIterator for Drain<'_, K, V, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.inner.len() + } +} +impl FusedIterator for Drain<'_, K, V, A> {} + +impl fmt::Debug for Drain<'_, K, V, A> +where + K: fmt::Debug, + V: fmt::Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +impl<'a, K, V, S, A: Allocator> Entry<'a, K, V, S, A> { + /// Sets the value of the entry, and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let entry = map.entry("horseyland").insert(37); + /// + /// assert_eq!(entry.key(), &"horseyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, value: V) -> OccupiedEntry<'a, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(mut entry) => { + entry.insert(value); + entry + } + Entry::Vacant(entry) => entry.insert_entry(value), + } + } + + /// Ensures a value is in the entry by inserting the default if empty, and returns + /// a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// // nonexistent key + /// map.entry("poneyland").or_insert(3); + /// assert_eq!(map["poneyland"], 3); + /// + /// // existing key + /// *map.entry("poneyland").or_insert(10) *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert(self, default: V) -> &'a mut V + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => entry.insert(default), + } + } + + /// Ensures a value is in the entry by inserting the default if empty, + /// and returns an [`OccupiedEntry`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// // nonexistent key + /// let entry = map.entry("poneyland").or_insert_entry(3); + /// assert_eq!(entry.key(), &"poneyland"); + /// assert_eq!(entry.get(), &3); + /// + /// // existing key + /// let mut entry = map.entry("poneyland").or_insert_entry(10); + /// assert_eq!(entry.key(), &"poneyland"); + /// assert_eq!(entry.get(), &3); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_entry(self, default: V) -> OccupiedEntry<'a, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry, + Entry::Vacant(entry) => entry.insert_entry(default), + } + } + + /// Ensures a value is in the entry by inserting the result of the default function if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// // nonexistent key + /// map.entry("poneyland").or_insert_with(|| 3); + /// assert_eq!(map["poneyland"], 3); + /// + /// // existing key + /// *map.entry("poneyland").or_insert_with(|| 10) *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with V>(self, default: F) -> &'a mut V + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => entry.insert(default()), + } + } + + /// Ensures a value is in the entry by inserting, if empty, the result of the default function. + /// This method allows for generating key-derived values for insertion by providing the default + /// function a reference to the key that was moved during the `.entry(key)` method call. + /// + /// The reference to the moved key is provided so that cloning or copying the key is + /// unnecessary, unlike with `.or_insert_with(|| ... )`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, usize> = HashMap::new(); + /// + /// // nonexistent key + /// map.entry("poneyland").or_insert_with_key(|key| key.chars().count()); + /// assert_eq!(map["poneyland"], 9); + /// + /// // existing key + /// *map.entry("poneyland").or_insert_with_key(|key| key.chars().count() * 10) *= 2; + /// assert_eq!(map["poneyland"], 18); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with_key V>(self, default: F) -> &'a mut V + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => { + let value = default(entry.key()); + entry.insert(value) + } + } + } + + /// Returns a reference to this entry's key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(3); + /// // existing key + /// assert_eq!(map.entry("poneyland").key(), &"poneyland"); + /// // nonexistent key + /// assert_eq!(map.entry("horseland").key(), &"horseland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + match *self { + Entry::Occupied(ref entry) => entry.key(), + Entry::Vacant(ref entry) => entry.key(), + } + } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// map.entry("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 42); + /// + /// map.entry("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 43); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_modify(self, f: F) -> Self + where + F: FnOnce(&mut V), + { + match self { + Entry::Occupied(mut entry) => { + f(entry.get_mut()); + Entry::Occupied(entry) + } + Entry::Vacant(entry) => Entry::Vacant(entry), + } + } + + /// Provides shared access to the key and owned access to the value of + /// an occupied entry and allows to replace or remove it based on the + /// value of the returned option. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// let entry = map + /// .entry("poneyland") + /// .and_replace_entry_with(|_k, _v| panic!()); + /// + /// match entry { + /// Entry::Vacant(e) => { + /// assert_eq!(e.key(), &"poneyland"); + /// } + /// Entry::Occupied(_) => panic!(), + /// } + /// + /// map.insert("poneyland", 42); + /// + /// let entry = map + /// .entry("poneyland") + /// .and_replace_entry_with(|k, v| { + /// assert_eq!(k, &"poneyland"); + /// assert_eq!(v, 42); + /// Some(v + 1) + /// }); + /// + /// match entry { + /// Entry::Occupied(e) => { + /// assert_eq!(e.key(), &"poneyland"); + /// assert_eq!(e.get(), &43); + /// } + /// Entry::Vacant(_) => panic!(), + /// } + /// + /// assert_eq!(map["poneyland"], 43); + /// + /// let entry = map + /// .entry("poneyland") + /// .and_replace_entry_with(|_k, _v| None); + /// + /// match entry { + /// Entry::Vacant(e) => assert_eq!(e.key(), &"poneyland"), + /// Entry::Occupied(_) => panic!(), + /// } + /// + /// assert!(!map.contains_key("poneyland")); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_replace_entry_with(self, f: F) -> Self + where + F: FnOnce(&K, V) -> Option, + { + match self { + Entry::Occupied(entry) => entry.replace_entry_with(f), + Entry::Vacant(_) => self, + } + } + + /// Converts the `Entry` into a mutable reference to the underlying map. + pub fn into_map(self) -> &'a mut HashMap { + match self { + Entry::Occupied(entry) => entry.table, + Entry::Vacant(entry) => entry.table, + } + } +} + +impl<'a, K, V: Default, S, A: Allocator> Entry<'a, K, V, S, A> { + /// Ensures a value is in the entry by inserting the default value if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, Option> = HashMap::new(); + /// + /// // nonexistent key + /// map.entry("poneyland").or_default(); + /// assert_eq!(map["poneyland"], None); + /// + /// map.insert("horseland", Some(3)); + /// + /// // existing key + /// assert_eq!(map.entry("horseland").or_default(), &mut Some(3)); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_default(self) -> &'a mut V + where + K: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => entry.insert(Default::default()), + } + } +} + +impl<'a, K, V, S, A: Allocator> OccupiedEntry<'a, K, V, S, A> { + /// Gets a reference to the key in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// match map.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(entry) => assert_eq!(entry.key(), &"poneyland"), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + unsafe { &self.elem.as_ref().0 } + } + + /// Replaces the key in the entry with a new one. + /// + /// # Panics + /// + /// This method panics if `key` is not equivalent to the key in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// let old_key = "poneyland"; + /// let new_key = Box::leak(old_key.to_owned().into_boxed_str()); + /// map.entry(old_key).or_insert(12); + /// match map.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(mut entry) => { + /// let replaced = entry.replace_key(new_key); + /// assert!(std::ptr::eq(replaced, old_key)); + /// assert!(std::ptr::eq(*entry.key(), new_key)); + /// }, + /// } + /// + /// # // appease miri; no memory leaks here! + /// # drop(map); + /// # unsafe { + /// # Box::from_raw(new_key); + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn replace_key(&mut self, key: K) -> K + where + K: Equivalent, + { + assert!( + self.key().equivalent(&key), + "replaced key is not equivalent to the one in the entry" + ); + + // SAFETY: We verified that the keys were equivalent. + unsafe { self.replace_key_unchecked(key) } + } + + /// Replaces the key in the entry with a new one, without checking the + /// equivalence of the key. + /// + /// # Safety + /// + /// This operation is safe if you replace the key with an equivalent one. + /// + /// Additionally, this operation (and following operations) are guaranteed + /// to not violate memory safety. + /// + /// However this operation is still unsafe because the resulting `HashMap` + /// may be passed to unsafe code which does expect the map to behave + /// correctly. If the map has keys at unexpected positions inside it, + /// future operations may panic, loop forever, or return unexpected results, + /// potentially violating memory safety. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// let old_key = "poneyland"; + /// let new_key = Box::leak(old_key.to_owned().into_boxed_str()); + /// map.entry(old_key).or_insert(12); + /// match map.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(mut entry) => { + /// let replaced = unsafe { entry.replace_key_unchecked(new_key) }; + /// assert!(std::ptr::eq(replaced, old_key)); + /// assert!(std::ptr::eq(*entry.key(), new_key)); + /// }, + /// } + /// + /// # // appease miri; no memory leaks here! + /// # drop(map); + /// # unsafe { + /// # Box::from_raw(new_key); + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub unsafe fn replace_key_unchecked(&mut self, key: K) -> K { + mem::replace(unsafe { &mut self.elem.as_mut().0 }, key) + } + + /// Take the ownership of the key and value from the map. + /// Keeps the allocated memory for reuse. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// // The map is empty + /// assert!(map.is_empty() && map.capacity() == 0); + /// + /// map.entry("poneyland").or_insert(12); + /// + /// if let Entry::Occupied(o) = map.entry("poneyland") { + /// // We delete the entry from the map. + /// assert_eq!(o.remove_entry(), ("poneyland", 12)); + /// } + /// + /// assert_eq!(map.contains_key("poneyland"), false); + /// // Now map hold none elements + /// assert!(map.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove_entry(self) -> (K, V) { + unsafe { self.table.table.remove(self.elem).0 } + } + + /// Gets a reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// match map.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(entry) => assert_eq!(entry.get(), &12), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &V { + unsafe { &self.elem.as_ref().1 } + } + + /// Gets a mutable reference to the value in the entry. + /// + /// If you need a reference to the `OccupiedEntry` which may outlive the + /// destruction of the `Entry` value, see [`into_mut`]. + /// + /// [`into_mut`]: #method.into_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// assert_eq!(map["poneyland"], 12); + /// if let Entry::Occupied(mut o) = map.entry("poneyland") { + /// *o.get_mut() += 10; + /// assert_eq!(*o.get(), 22); + /// + /// // We can use the same Entry multiple times. + /// *o.get_mut() += 2; + /// } + /// + /// assert_eq!(map["poneyland"], 24); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_mut(&mut self) -> &mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the value in the entry + /// with a lifetime bound to the map itself. + /// + /// If you need multiple references to the `OccupiedEntry`, see [`get_mut`]. + /// + /// [`get_mut`]: #method.get_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// assert_eq!(map["poneyland"], 12); + /// + /// let value: &mut u32; + /// match map.entry("poneyland") { + /// Entry::Occupied(entry) => value = entry.into_mut(), + /// Entry::Vacant(_) => panic!(), + /// } + /// *value += 10; + /// + /// assert_eq!(map["poneyland"], 22); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_mut(self) -> &'a mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Converts the `OccupiedEntry` into a reference to the key and a + /// mutable reference to the value in the entry with a lifetime bound to the + /// map itself. + /// + /// If you need multiple references to the `OccupiedEntry`, see [`key`] and + /// [`get_mut`]. + /// + /// [`key`]: Self::key + /// [`get_mut`]: Self::get_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// assert_eq!(map["poneyland"], 12); + /// + /// let key_val: (&&str, &mut u32); + /// match map.entry("poneyland") { + /// Entry::Occupied(entry) => key_val = entry.into_entry(), + /// Entry::Vacant(_) => panic!(), + /// } + /// *key_val.1 += 10; + /// + /// assert_eq!(key_val, (&"poneyland", &mut 22)); + /// assert_eq!(map["poneyland"], 22); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_entry(self) -> (&'a K, &'a mut V) { + let (key, val) = unsafe { self.elem.as_mut() }; + (key, val) + } + + /// Sets the value of the entry, and returns the entry's old value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.entry("poneyland").or_insert(12); + /// + /// if let Entry::Occupied(mut o) = map.entry("poneyland") { + /// assert_eq!(o.insert(15), 12); + /// } + /// + /// assert_eq!(map["poneyland"], 15); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(&mut self, value: V) -> V { + mem::replace(self.get_mut(), value) + } + + /// Takes the value out of the entry, and returns it. + /// Keeps the allocated memory for reuse. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// // The map is empty + /// assert!(map.is_empty() && map.capacity() == 0); + /// + /// map.entry("poneyland").or_insert(12); + /// + /// if let Entry::Occupied(o) = map.entry("poneyland") { + /// assert_eq!(o.remove(), 12); + /// } + /// + /// assert_eq!(map.contains_key("poneyland"), false); + /// // Now map hold none elements + /// assert!(map.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(self) -> V { + self.remove_entry().1 + } + + /// Provides shared access to the key and owned access to the value of + /// the entry and allows to replace or remove it based on the + /// value of the returned option. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.insert("poneyland", 42); + /// + /// let entry = match map.entry("poneyland") { + /// Entry::Occupied(e) => { + /// e.replace_entry_with(|k, v| { + /// assert_eq!(k, &"poneyland"); + /// assert_eq!(v, 42); + /// Some(v + 1) + /// }) + /// } + /// Entry::Vacant(_) => panic!(), + /// }; + /// + /// match entry { + /// Entry::Occupied(e) => { + /// assert_eq!(e.key(), &"poneyland"); + /// assert_eq!(e.get(), &43); + /// } + /// Entry::Vacant(_) => panic!(), + /// } + /// + /// assert_eq!(map["poneyland"], 43); + /// + /// let entry = match map.entry("poneyland") { + /// Entry::Occupied(e) => e.replace_entry_with(|_k, _v| None), + /// Entry::Vacant(_) => panic!(), + /// }; + /// + /// match entry { + /// Entry::Vacant(e) => { + /// assert_eq!(e.key(), &"poneyland"); + /// } + /// Entry::Occupied(_) => panic!(), + /// } + /// + /// assert!(!map.contains_key("poneyland")); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn replace_entry_with(self, f: F) -> Entry<'a, K, V, S, A> + where + F: FnOnce(&K, V) -> Option, + { + unsafe { + let mut spare_key = None; + + self.table + .table + .replace_bucket_with(self.elem.clone(), |(key, value)| { + if let Some(new_value) = f(&key, value) { + Some((key, new_value)) + } else { + spare_key = Some(key); + None + } + }); + + if let Some(key) = spare_key { + Entry::Vacant(VacantEntry { + hash: self.hash, + key, + table: self.table, + }) + } else { + Entry::Occupied(self) + } + } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the underlying map. + pub fn into_map(self) -> &'a mut HashMap { + self.table + } +} + +impl<'a, K, V, S, A: Allocator> VacantEntry<'a, K, V, S, A> { + /// Gets a reference to the key that would be used when inserting a value + /// through the `VacantEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// assert_eq!(map.entry("poneyland").key(), &"poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + &self.key + } + + /// Take ownership of the key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{Entry, HashMap}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// match map.entry("poneyland") { + /// Entry::Occupied(_) => panic!(), + /// Entry::Vacant(v) => assert_eq!(v.into_key(), "poneyland"), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_key(self) -> K { + self.key + } + + /// Sets the value of the entry with the [`VacantEntry`]'s key, + /// and returns a mutable reference to it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let Entry::Vacant(o) = map.entry("poneyland") { + /// o.insert(37); + /// } + /// assert_eq!(map["poneyland"], 37); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, value: V) -> &'a mut V + where + K: Hash, + S: BuildHasher, + { + let table = &mut self.table.table; + let entry = table.insert_entry( + self.hash, + (self.key, value), + make_hasher::<_, V, S>(&self.table.hash_builder), + ); + &mut entry.1 + } + + /// Sets the value of the entry with the [`VacantEntry`]'s key, + /// and returns an [`OccupiedEntry`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::Entry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let Entry::Vacant(v) = map.entry("poneyland") { + /// let o = v.insert_entry(37); + /// assert_eq!(o.get(), &37); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + let elem = self.table.table.insert( + self.hash, + (self.key, value), + make_hasher::<_, V, S>(&self.table.hash_builder), + ); + OccupiedEntry { + hash: self.hash, + elem, + table: self.table, + } + } + + /// Converts the `VacantEntry` into a mutable reference to the underlying map. + pub fn into_map(self) -> &'a mut HashMap { + self.table + } +} + +impl<'a, K, Q: ?Sized, V, S, A: Allocator> EntryRef<'a, '_, K, Q, V, S, A> { + /// Sets the value of the entry, and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// let entry = map.entry_ref("horseyland").insert(37); + /// + /// assert_eq!(entry.key(), "horseyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, value: V) -> OccupiedEntry<'a, K, V, S, A> + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(mut entry) => { + entry.insert(value); + entry + } + EntryRef::Vacant(entry) => entry.insert_entry(value), + } + } + + /// Ensures a value is in the entry by inserting the default if empty, and returns + /// a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// + /// // nonexistent key + /// map.entry_ref("poneyland").or_insert(3); + /// assert_eq!(map["poneyland"], 3); + /// + /// // existing key + /// *map.entry_ref("poneyland").or_insert(10) *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert(self, default: V) -> &'a mut V + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(entry) => entry.into_mut(), + EntryRef::Vacant(entry) => entry.insert(default), + } + } + + /// Ensures a value is in the entry by inserting the result of the default function if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// + /// // nonexistent key + /// map.entry_ref("poneyland").or_insert_with(|| 3); + /// assert_eq!(map["poneyland"], 3); + /// + /// // existing key + /// *map.entry_ref("poneyland").or_insert_with(|| 10) *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with V>(self, default: F) -> &'a mut V + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(entry) => entry.into_mut(), + EntryRef::Vacant(entry) => entry.insert(default()), + } + } + + /// Ensures a value is in the entry by inserting, if empty, the result of the default function. + /// This method allows for generating key-derived values for insertion by providing the default + /// function an access to the borrower form of the key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// + /// // nonexistent key + /// map.entry_ref("poneyland").or_insert_with_key(|key| key.chars().count()); + /// assert_eq!(map["poneyland"], 9); + /// + /// // existing key + /// *map.entry_ref("poneyland").or_insert_with_key(|key| key.chars().count() * 10) *= 2; + /// assert_eq!(map["poneyland"], 18); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with_key V>(self, default: F) -> &'a mut V + where + K: Hash + Borrow, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(entry) => entry.into_mut(), + EntryRef::Vacant(entry) => { + let value = default(entry.key); + entry.insert(value) + } + } + } + + /// Returns a reference to this entry's key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// map.entry_ref("poneyland").or_insert(3); + /// // existing key + /// assert_eq!(map.entry_ref("poneyland").key(), "poneyland"); + /// // nonexistent key + /// assert_eq!(map.entry_ref("horseland").key(), "horseland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &Q + where + K: Borrow, + { + match *self { + EntryRef::Occupied(ref entry) => entry.key().borrow(), + EntryRef::Vacant(ref entry) => entry.key(), + } + } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// + /// map.entry_ref("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 42); + /// + /// map.entry_ref("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 43); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_modify(self, f: F) -> Self + where + F: FnOnce(&mut V), + { + match self { + EntryRef::Occupied(mut entry) => { + f(entry.get_mut()); + EntryRef::Occupied(entry) + } + EntryRef::Vacant(entry) => EntryRef::Vacant(entry), + } + } + + /// Converts the `EntryRef` into a mutable reference to the underlying map. + pub fn into_map(self) -> &'a mut HashMap { + match self { + EntryRef::Occupied(entry) => entry.table, + EntryRef::Vacant(entry) => entry.table, + } + } +} + +impl<'a, K, Q: ?Sized, V: Default, S, A: Allocator> EntryRef<'a, '_, K, Q, V, S, A> { + /// Ensures a value is in the entry by inserting the default value if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap> = HashMap::new(); + /// + /// // nonexistent key + /// map.entry_ref("poneyland").or_default(); + /// assert_eq!(map["poneyland"], None); + /// + /// map.insert("horseland".to_string(), Some(3)); + /// + /// // existing key + /// assert_eq!(map.entry_ref("horseland").or_default(), &mut Some(3)); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_default(self) -> &'a mut V + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(entry) => entry.into_mut(), + EntryRef::Vacant(entry) => entry.insert(Default::default()), + } + } + + /// Ensures a value is in the entry by inserting the default value if empty, + /// and returns an [`OccupiedEntry`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap> = HashMap::new(); + /// + /// // nonexistent key + /// let entry = map.entry_ref("poneyland").or_default_entry(); + /// assert_eq!(entry.key(), &"poneyland"); + /// assert_eq!(entry.get(), &None); + /// + /// // existing key + /// map.insert("horseland".to_string(), Some(3)); + /// let entry = map.entry_ref("horseland").or_default_entry(); + /// assert_eq!(entry.key(), &"horseland"); + /// assert_eq!(entry.get(), &Some(3)); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_default_entry(self) -> OccupiedEntry<'a, K, V, S, A> + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + match self { + EntryRef::Occupied(entry) => entry, + EntryRef::Vacant(entry) => entry.insert_entry(Default::default()), + } + } +} + +impl<'map, 'key, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'map, 'key, K, Q, V, S, A> { + /// Gets a reference to the key that would be used when inserting a value + /// through the `VacantEntryRef`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap = HashMap::new(); + /// let key: &str = "poneyland"; + /// assert_eq!(map.entry_ref(key).key(), "poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &'key Q { + self.key + } + + /// Sets the value of the entry with the `VacantEntryRef`'s key, + /// and returns a mutable reference to it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::EntryRef; + /// + /// let mut map: HashMap = HashMap::new(); + /// let key: &str = "poneyland"; + /// + /// if let EntryRef::Vacant(o) = map.entry_ref(key) { + /// o.insert(37); + /// } + /// assert_eq!(map["poneyland"], 37); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, value: V) -> &'map mut V + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + let table = &mut self.table.table; + let entry = table.insert_entry( + self.hash, + (self.key.to_owned(), value), + make_hasher::<_, V, S>(&self.table.hash_builder), + ); + &mut entry.1 + } + + /// Sets the key and value of the entry and returns a mutable reference to + /// the inserted value. + /// + /// Unlike [`VacantEntryRef::insert`], this method allows the key to be + /// explicitly specified, which is useful for key types that don't implement + /// `ToOwned`. + /// + /// # Panics + /// + /// This method panics if `key` is not equivalent to the key used to create + /// the `VacantEntryRef`. + /// + /// # Example + /// + /// ``` + /// use hashbrown::hash_map::EntryRef; + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::<(String, String), char>::new(); + /// let k = ("c".to_string(), "C".to_string()); + /// let v = match map.entry_ref(&k) { + /// // Insert cannot be used here because tuples do not implement ToOwned. + /// // However this works because we can manually clone instead. + /// EntryRef::Vacant(r) => r.insert_with_key(k.clone(), 'c'), + /// // In this branch we avoid the clone. + /// EntryRef::Occupied(r) => r.into_mut(), + /// }; + /// assert_eq!(*v, 'c'); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_with_key(self, key: K, value: V) -> &'map mut V + where + K: Hash, + Q: Equivalent, + S: BuildHasher, + { + self.insert_entry_with_key(key, value).into_mut() + } + + /// Sets the key and value of the entry and returns a mutable reference to + /// the inserted value, without checking the equivalence of the key. + /// + /// See [`insert_with_key`](Self::insert_with_key) for more information. + /// + /// # Safety + /// + /// This operation is safe if the keys are equivalent. + /// + /// Additionally, this operation (and following operations) are guaranteed + /// to not violate memory safety. + /// + /// However this operation is still unsafe because the resulting `HashMap` + /// may be passed to unsafe code which does expect the map to behave + /// correctly. If the map has keys at unexpected positions inside it, + /// future operations may panic, loop forever, or return unexpected results, + /// potentially violating memory safety. + /// + /// # Example + /// + /// ``` + /// use hashbrown::hash_map::EntryRef; + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::<(String, String), char>::new(); + /// let k = ("c".to_string(), "C".to_string()); + /// let v = match map.entry_ref(&k) { + /// // SAFETY: We trust the `Clone` implementation to return an equivalent value + /// EntryRef::Vacant(r) => unsafe { r.insert_with_key_unchecked(k.clone(), 'c') }, + /// // In this branch we avoid the clone. + /// EntryRef::Occupied(r) => r.into_mut(), + /// }; + /// assert_eq!(*v, 'c'); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub unsafe fn insert_with_key_unchecked(self, key: K, value: V) -> &'map mut V + where + K: Hash, + S: BuildHasher, + { + // SAFETY: Guaranteed by caller. + unsafe { self.insert_entry_with_key_unchecked(key, value) }.into_mut() + } + + /// Sets the value of the entry with the [`VacantEntryRef`]'s key, + /// and returns an [`OccupiedEntry`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::EntryRef; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let EntryRef::Vacant(v) = map.entry_ref(&"poneyland") { + /// let o = v.insert_entry(37); + /// assert_eq!(o.get(), &37); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_entry(self, value: V) -> OccupiedEntry<'map, K, V, S, A> + where + K: Hash, + Q: ToOwned, + S: BuildHasher, + { + let elem = self.table.table.insert( + self.hash, + (self.key.to_owned(), value), + make_hasher::<_, V, S>(&self.table.hash_builder), + ); + OccupiedEntry { + hash: self.hash, + elem, + table: self.table, + } + } + + /// Sets the key and value of the entry and returns an [`OccupiedEntry`]. + /// + /// Unlike [`VacantEntryRef::insert_entry`], this method allows the key to + /// be explicitly specified, which is useful for key types that don't + /// implement `ToOwned`. + /// + /// # Panics + /// + /// This method panics if `key` is not equivalent to the key used to create + /// the `VacantEntryRef`. + /// + /// # Example + /// + /// ``` + /// use hashbrown::hash_map::EntryRef; + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::<(String, String), char>::new(); + /// let k = ("c".to_string(), "C".to_string()); + /// let r = match map.entry_ref(&k) { + /// // Insert cannot be used here because tuples do not implement ToOwned. + /// // However this works because we can manually clone instead. + /// EntryRef::Vacant(r) => r.insert_entry_with_key(k.clone(), 'c'), + /// // In this branch we avoid the clone. + /// EntryRef::Occupied(r) => r, + /// }; + /// assert_eq!(r.get(), &'c'); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_entry_with_key(self, key: K, value: V) -> OccupiedEntry<'map, K, V, S, A> + where + K: Hash, + Q: Equivalent, + S: BuildHasher, + { + assert!( + (self.key).equivalent(&key), + "key used for Entry creation is not equivalent to the one used for insertion" + ); + // SAFETY: We checked equivalence first. + unsafe { self.insert_entry_with_key_unchecked(key, value) } + } + + /// Sets the key and value of the entry and returns an [`OccupiedEntry`], + /// without checking the equivalence of the key. + /// + /// See [`insert_entry_with_key`](Self::insert_entry_with_key) for more information. + /// + /// # Safety + /// + /// This operation is safe if the keys are equivalent. + /// + /// Additionally, this operation (and following operations) are guaranteed + /// to not violate memory safety. + /// + /// However this operation is still unsafe because the resulting `HashMap` + /// may be passed to unsafe code which does expect the map to behave + /// correctly. If the map has keys at unexpected positions inside it, + /// future operations may panic, loop forever, or return unexpected results, + /// potentially violating memory safety. + /// + /// # Example + /// + /// ``` + /// use hashbrown::hash_map::EntryRef; + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::<(String, String), char>::new(); + /// let k = ("c".to_string(), "C".to_string()); + /// let r = match map.entry_ref(&k) { + /// // SAFETY: We trust the `Clone` implementation to return an equivalent key + /// EntryRef::Vacant(r) => unsafe { r.insert_entry_with_key_unchecked(k.clone(), 'c') }, + /// // In this branch we avoid the clone. + /// EntryRef::Occupied(r) => r, + /// }; + /// assert_eq!(r.get(), &'c'); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub unsafe fn insert_entry_with_key_unchecked( + self, + key: K, + value: V, + ) -> OccupiedEntry<'map, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + let elem = self.table.table.insert( + self.hash, + (key, value), + make_hasher::<_, V, S>(&self.table.hash_builder), + ); + OccupiedEntry { + hash: self.hash, + elem, + table: self.table, + } + } + + /// Converts the `VacantEntryRef` into a mutable reference to the underlying map. + pub fn into_map(self) -> &'map mut HashMap { + self.table + } +} + +impl FromIterator<(K, V)> for HashMap +where + K: Eq + Hash, + S: BuildHasher + Default, + A: Default + Allocator, +{ + #[cfg_attr(feature = "inline-more", inline)] + fn from_iter>(iter: T) -> Self { + let iter = iter.into_iter(); + let mut map = + Self::with_capacity_and_hasher_in(iter.size_hint().0, S::default(), A::default()); + iter.for_each(|(k, v)| { + map.insert(k, v); + }); + map + } +} + +/// Inserts all new key-values from the iterator and replaces values with existing +/// keys with new values returned from the iterator. +impl Extend<(K, V)> for HashMap +where + K: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + /// Inserts all new key-values from the iterator to existing `HashMap`. + /// Replace values with existing keys with new values returned from the iterator. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, 100); + /// + /// let some_iter = [(1, 1), (2, 2)].into_iter(); + /// map.extend(some_iter); + /// // Replace values with existing keys with new values returned from the iterator. + /// // So that the map.get(&1) doesn't return Some(&100). + /// assert_eq!(map.get(&1), Some(&1)); + /// + /// let some_vec: Vec<_> = vec![(3, 3), (4, 4)]; + /// map.extend(some_vec); + /// + /// let some_arr = [(5, 5), (6, 6)]; + /// map.extend(some_arr); + /// let old_map_len = map.len(); + /// + /// // You can also extend from another HashMap + /// let mut new_map = HashMap::new(); + /// new_map.extend(map); + /// assert_eq!(new_map.len(), old_map_len); + /// + /// let mut vec: Vec<_> = new_map.into_iter().collect(); + /// // The `IntoIter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn extend>(&mut self, iter: T) { + // Keys may be already present or show multiple times in the iterator. + // Reserve the entire hint lower bound if the map is empty. + // Otherwise reserve half the hint (rounded up), so the map + // will only resize twice in the worst case. + let iter = iter.into_iter(); + let reserve = if self.is_empty() { + iter.size_hint().0 + } else { + iter.size_hint().0.div_ceil(2) + }; + self.reserve(reserve); + iter.for_each(move |(k, v)| { + self.insert(k, v); + }); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_one(&mut self, (k, v): (K, V)) { + self.insert(k, v); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_reserve(&mut self, additional: usize) { + // Keys may be already present or show multiple times in the iterator. + // Reserve the entire hint lower bound if the map is empty. + // Otherwise reserve half the hint (rounded up), so the map + // will only resize twice in the worst case. + let reserve = if self.is_empty() { + additional + } else { + additional.div_ceil(2) + }; + self.reserve(reserve); + } +} + +/// Inserts all new key-values from the iterator and replaces values with existing +/// keys with new values returned from the iterator. +impl<'a, K, V, S, A> Extend<(&'a K, &'a V)> for HashMap +where + K: Eq + Hash + Copy, + V: Copy, + S: BuildHasher, + A: Allocator, +{ + /// Inserts all new key-values from the iterator to existing `HashMap`. + /// Replace values with existing keys with new values returned from the iterator. + /// The keys and values must implement [`Copy`] trait. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, 100); + /// + /// let arr = [(1, 1), (2, 2)]; + /// let some_iter = arr.iter().map(|(k, v)| (k, v)); + /// map.extend(some_iter); + /// // Replace values with existing keys with new values returned from the iterator. + /// // So that the map.get(&1) doesn't return Some(&100). + /// assert_eq!(map.get(&1), Some(&1)); + /// + /// let some_vec: Vec<_> = vec![(3, 3), (4, 4)]; + /// map.extend(some_vec.iter().map(|(k, v)| (k, v))); + /// + /// let some_arr = [(5, 5), (6, 6)]; + /// map.extend(some_arr.iter().map(|(k, v)| (k, v))); + /// + /// // You can also extend from another HashMap + /// let mut new_map = HashMap::new(); + /// new_map.extend(&map); + /// assert_eq!(new_map, map); + /// + /// let mut vec: Vec<_> = new_map.into_iter().collect(); + /// // The `IntoIter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn extend>(&mut self, iter: T) { + self.extend(iter.into_iter().map(|(&key, &value)| (key, value))); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_one(&mut self, (k, v): (&'a K, &'a V)) { + self.insert(*k, *v); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_reserve(&mut self, additional: usize) { + Extend::<(K, V)>::extend_reserve(self, additional); + } +} + +/// Inserts all new key-values from the iterator and replaces values with existing +/// keys with new values returned from the iterator. +impl<'a, K, V, S, A> Extend<&'a (K, V)> for HashMap +where + K: Eq + Hash + Copy, + V: Copy, + S: BuildHasher, + A: Allocator, +{ + /// Inserts all new key-values from the iterator to existing `HashMap`. + /// Replace values with existing keys with new values returned from the iterator. + /// The keys and values must implement [`Copy`] trait. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.insert(1, 100); + /// + /// let arr = [(1, 1), (2, 2)]; + /// let some_iter = arr.iter(); + /// map.extend(some_iter); + /// // Replace values with existing keys with new values returned from the iterator. + /// // So that the map.get(&1) doesn't return Some(&100). + /// assert_eq!(map.get(&1), Some(&1)); + /// + /// let some_vec: Vec<_> = vec![(3, 3), (4, 4)]; + /// map.extend(&some_vec); + /// + /// let some_arr = [(5, 5), (6, 6)]; + /// map.extend(&some_arr); + /// + /// let mut vec: Vec<_> = map.into_iter().collect(); + /// // The `IntoIter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn extend>(&mut self, iter: T) { + self.extend(iter.into_iter().map(|&(key, value)| (key, value))); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_one(&mut self, &(k, v): &'a (K, V)) { + self.insert(k, v); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_reserve(&mut self, additional: usize) { + Extend::<(K, V)>::extend_reserve(self, additional); + } +} + +#[expect(dead_code)] +fn assert_covariance() { + fn map_key<'new, S: BuildHasher, A: Allocator>( + v: HashMap<&'static str, u8, S, A>, + ) -> HashMap<&'new str, u8, S, A> { + v + } + fn map_val<'new, S: BuildHasher, A: Allocator>( + v: HashMap, + ) -> HashMap { + v + } + fn iter_key<'a, 'new>(v: Iter<'a, &'static str, u8>) -> Iter<'a, &'new str, u8> { + v + } + fn iter_val<'a, 'new>(v: Iter<'a, u8, &'static str>) -> Iter<'a, u8, &'new str> { + v + } + fn into_iter_key<'new, A: Allocator>( + v: IntoIter<&'static str, u8, A>, + ) -> IntoIter<&'new str, u8, A> { + v + } + fn into_iter_val<'new, A: Allocator>( + v: IntoIter, + ) -> IntoIter { + v + } + fn keys_key<'a, 'new>(v: Keys<'a, &'static str, u8>) -> Keys<'a, &'new str, u8> { + v + } + fn keys_val<'a, 'new>(v: Keys<'a, u8, &'static str>) -> Keys<'a, u8, &'new str> { + v + } + fn values_key<'a, 'new>(v: Values<'a, &'static str, u8>) -> Values<'a, &'new str, u8> { + v + } + fn values_val<'a, 'new>(v: Values<'a, u8, &'static str>) -> Values<'a, u8, &'new str> { + v + } + fn drain<'new, A: Allocator>( + d: Drain<'static, &'static str, &'static str, A>, + ) -> Drain<'new, &'new str, &'new str, A> { + d + } +} + +#[cfg(test)] +mod test_map { + use super::DefaultHashBuilder; + use super::Entry::{Occupied, Vacant}; + use super::EntryRef; + use super::HashMap; + use crate::alloc::{AllocError, Allocator, Global}; + use core::alloc::Layout; + use core::ptr::NonNull; + use core::sync::atomic::{AtomicI8, Ordering}; + use rand::{Rng, SeedableRng, rngs::SmallRng}; + use std::borrow::ToOwned; + use std::cell::RefCell; + use std::vec::Vec; + use stdalloc::string::String; + use stdalloc::sync::Arc; + + #[test] + fn test_zero_capacities() { + type HM = HashMap; + + let m = HM::new(); + assert_eq!(m.capacity(), 0); + + let m = HM::default(); + assert_eq!(m.capacity(), 0); + + let m = HM::with_hasher(DefaultHashBuilder::default()); + assert_eq!(m.capacity(), 0); + + let m = HM::with_capacity(0); + assert_eq!(m.capacity(), 0); + + let m = HM::with_capacity_and_hasher(0, DefaultHashBuilder::default()); + assert_eq!(m.capacity(), 0); + + let mut m = HM::new(); + m.insert(1, 1); + m.insert(2, 2); + m.remove(&1); + m.remove(&2); + m.shrink_to_fit(); + assert_eq!(m.capacity(), 0); + + let mut m = HM::new(); + m.reserve(0); + assert_eq!(m.capacity(), 0); + } + + #[test] + fn test_create_capacity_zero() { + let mut m = HashMap::with_capacity(0); + + assert!(m.insert(1, 1).is_none()); + + assert!(m.contains_key(&1)); + assert!(!m.contains_key(&0)); + } + + #[test] + fn test_insert() { + let mut m = HashMap::new(); + assert_eq!(m.len(), 0); + assert!(m.insert(1, 2).is_none()); + assert_eq!(m.len(), 1); + assert!(m.insert(2, 4).is_none()); + assert_eq!(m.len(), 2); + assert_eq!(*m.get(&1).unwrap(), 2); + assert_eq!(*m.get(&2).unwrap(), 4); + } + + #[test] + fn test_clone() { + let mut m = HashMap::new(); + assert_eq!(m.len(), 0); + assert!(m.insert(1, 2).is_none()); + assert_eq!(m.len(), 1); + assert!(m.insert(2, 4).is_none()); + assert_eq!(m.len(), 2); + let m2 = m.clone(); + assert_eq!(*m2.get(&1).unwrap(), 2); + assert_eq!(*m2.get(&2).unwrap(), 4); + assert_eq!(m2.len(), 2); + } + + #[test] + fn test_clone_from() { + let mut m = HashMap::new(); + let mut m2 = HashMap::new(); + assert_eq!(m.len(), 0); + assert!(m.insert(1, 2).is_none()); + assert_eq!(m.len(), 1); + assert!(m.insert(2, 4).is_none()); + assert_eq!(m.len(), 2); + m2.clone_from(&m); + assert_eq!(*m2.get(&1).unwrap(), 2); + assert_eq!(*m2.get(&2).unwrap(), 4); + assert_eq!(m2.len(), 2); + } + + thread_local! { static DROP_VECTOR: RefCell> = const { RefCell::new(Vec::new()) } } + + #[derive(Hash, PartialEq, Eq)] + struct Droppable { + k: usize, + } + + impl Droppable { + fn new(k: usize) -> Droppable { + DROP_VECTOR.with(|slot| { + slot.borrow_mut()[k] += 1; + }); + + Droppable { k } + } + } + + impl Drop for Droppable { + fn drop(&mut self) { + DROP_VECTOR.with(|slot| { + slot.borrow_mut()[self.k] -= 1; + }); + } + } + + impl Clone for Droppable { + fn clone(&self) -> Self { + Droppable::new(self.k) + } + } + + #[test] + fn test_drops() { + DROP_VECTOR.with(|slot| { + *slot.borrow_mut() = vec![0; 200]; + }); + + { + let mut m = HashMap::new(); + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 0); + } + }); + + for i in 0..100 { + let d1 = Droppable::new(i); + let d2 = Droppable::new(i + 100); + m.insert(d1, d2); + } + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 1); + } + }); + + for i in 0..50 { + let k = Droppable::new(i); + let v = m.remove(&k); + + assert!(v.is_some()); + + DROP_VECTOR.with(|v| { + assert_eq!(v.borrow()[i], 1); + assert_eq!(v.borrow()[i + 100], 1); + }); + } + + DROP_VECTOR.with(|v| { + for i in 0..50 { + assert_eq!(v.borrow()[i], 0); + assert_eq!(v.borrow()[i + 100], 0); + } + + for i in 50..100 { + assert_eq!(v.borrow()[i], 1); + assert_eq!(v.borrow()[i + 100], 1); + } + }); + } + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 0); + } + }); + } + + #[test] + fn test_into_iter_drops() { + DROP_VECTOR.with(|v| { + *v.borrow_mut() = vec![0; 200]; + }); + + let hm = { + let mut hm = HashMap::new(); + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 0); + } + }); + + for i in 0..100 { + let d1 = Droppable::new(i); + let d2 = Droppable::new(i + 100); + hm.insert(d1, d2); + } + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 1); + } + }); + + hm + }; + + // By the way, ensure that cloning doesn't screw up the dropping. + drop(hm.clone()); + + { + let mut half = hm.into_iter().take(50); + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 1); + } + }); + + for _ in half.by_ref() {} + + DROP_VECTOR.with(|v| { + let nk = (0..100).filter(|&i| v.borrow()[i] == 1).count(); + + let nv = (0..100).filter(|&i| v.borrow()[i + 100] == 1).count(); + + assert_eq!(nk, 50); + assert_eq!(nv, 50); + }); + }; + + DROP_VECTOR.with(|v| { + for i in 0..200 { + assert_eq!(v.borrow()[i], 0); + } + }); + } + + #[test] + fn test_empty_remove() { + let mut m: HashMap = HashMap::new(); + assert_eq!(m.remove(&0), None); + } + + #[test] + fn test_empty_entry() { + let mut m: HashMap = HashMap::new(); + match m.entry(0) { + Occupied(_) => panic!(), + Vacant(_) => {} + } + assert!(*m.entry(0).or_insert(true)); + assert_eq!(m.len(), 1); + } + + #[test] + fn test_empty_entry_ref() { + let mut m: HashMap = HashMap::new(); + match m.entry_ref("poneyland") { + EntryRef::Occupied(_) => panic!(), + EntryRef::Vacant(_) => {} + } + assert!(*m.entry_ref("poneyland").or_insert(true)); + assert_eq!(m.len(), 1); + } + + #[test] + fn test_empty_iter() { + let mut m: HashMap = HashMap::new(); + assert_eq!(m.drain().next(), None); + assert_eq!(m.keys().next(), None); + assert_eq!(m.values().next(), None); + assert_eq!(m.values_mut().next(), None); + assert_eq!(m.iter().next(), None); + assert_eq!(m.iter_mut().next(), None); + assert_eq!(m.len(), 0); + assert!(m.is_empty()); + assert_eq!(m.into_iter().next(), None); + } + + #[test] + #[cfg_attr(miri, ignore)] // FIXME: takes too long + fn test_lots_of_insertions() { + let mut m = HashMap::new(); + + // Try this a few times to make sure we never screw up the hashmap's + // internal state. + for _ in 0..10 { + assert!(m.is_empty()); + + for i in 1..1001 { + assert!(m.insert(i, i).is_none()); + + for j in 1..=i { + let r = m.get(&j); + assert_eq!(r, Some(&j)); + } + + for j in i + 1..1001 { + let r = m.get(&j); + assert_eq!(r, None); + } + } + + for i in 1001..2001 { + assert!(!m.contains_key(&i)); + } + + // remove forwards + for i in 1..1001 { + assert!(m.remove(&i).is_some()); + + for j in 1..=i { + assert!(!m.contains_key(&j)); + } + + for j in i + 1..1001 { + assert!(m.contains_key(&j)); + } + } + + for i in 1..1001 { + assert!(!m.contains_key(&i)); + } + + for i in 1..1001 { + assert!(m.insert(i, i).is_none()); + } + + // remove backwards + for i in (1..1001).rev() { + assert!(m.remove(&i).is_some()); + + for j in i..1001 { + assert!(!m.contains_key(&j)); + } + + for j in 1..i { + assert!(m.contains_key(&j)); + } + } + } + } + + #[test] + fn test_find_mut() { + let mut m = HashMap::new(); + assert!(m.insert(1, 12).is_none()); + assert!(m.insert(2, 8).is_none()); + assert!(m.insert(5, 14).is_none()); + let new = 100; + match m.get_mut(&5) { + None => panic!(), + Some(x) => *x = new, + } + assert_eq!(m.get(&5), Some(&new)); + let mut hashmap: HashMap = HashMap::default(); + let key = &1; + let result = hashmap.get_mut(key); + assert!(result.is_none()); + } + + #[test] + fn test_insert_overwrite() { + let mut m = HashMap::new(); + assert!(m.insert(1, 2).is_none()); + assert_eq!(*m.get(&1).unwrap(), 2); + assert!(m.insert(1, 3).is_some()); + assert_eq!(*m.get(&1).unwrap(), 3); + } + + #[test] + fn test_insert_conflicts() { + let mut m = HashMap::with_capacity(4); + assert!(m.insert(1, 2).is_none()); + assert!(m.insert(5, 3).is_none()); + assert!(m.insert(9, 4).is_none()); + assert_eq!(*m.get(&9).unwrap(), 4); + assert_eq!(*m.get(&5).unwrap(), 3); + assert_eq!(*m.get(&1).unwrap(), 2); + } + + #[test] + fn test_conflict_remove() { + let mut m = HashMap::with_capacity(4); + assert!(m.insert(1, 2).is_none()); + assert_eq!(*m.get(&1).unwrap(), 2); + assert!(m.insert(5, 3).is_none()); + assert_eq!(*m.get(&1).unwrap(), 2); + assert_eq!(*m.get(&5).unwrap(), 3); + assert!(m.insert(9, 4).is_none()); + assert_eq!(*m.get(&1).unwrap(), 2); + assert_eq!(*m.get(&5).unwrap(), 3); + assert_eq!(*m.get(&9).unwrap(), 4); + assert!(m.remove(&1).is_some()); + assert_eq!(*m.get(&9).unwrap(), 4); + assert_eq!(*m.get(&5).unwrap(), 3); + } + + #[test] + fn test_insert_unique_unchecked() { + let mut map = HashMap::new(); + let (k1, v1) = unsafe { map.insert_unique_unchecked(10, 11) }; + assert_eq!((&10, &mut 11), (k1, v1)); + let (k2, v2) = unsafe { map.insert_unique_unchecked(20, 21) }; + assert_eq!((&20, &mut 21), (k2, v2)); + assert_eq!(Some(&11), map.get(&10)); + assert_eq!(Some(&21), map.get(&20)); + assert_eq!(None, map.get(&30)); + } + + #[test] + fn test_is_empty() { + let mut m = HashMap::with_capacity(4); + assert!(m.insert(1, 2).is_none()); + assert!(!m.is_empty()); + assert!(m.remove(&1).is_some()); + assert!(m.is_empty()); + } + + #[test] + fn test_remove() { + let mut m = HashMap::new(); + m.insert(1, 2); + assert_eq!(m.remove(&1), Some(2)); + assert_eq!(m.remove(&1), None); + } + + #[test] + fn test_remove_entry() { + let mut m = HashMap::new(); + m.insert(1, 2); + assert_eq!(m.remove_entry(&1), Some((1, 2))); + assert_eq!(m.remove(&1), None); + } + + #[test] + fn test_iterate() { + let mut m = HashMap::with_capacity(4); + for i in 0..32 { + assert!(m.insert(i, i * 2).is_none()); + } + assert_eq!(m.len(), 32); + + let mut observed: u32 = 0; + + for (k, v) in &m { + assert_eq!(*v, *k * 2); + observed |= 1 << *k; + } + assert_eq!(observed, 0xFFFF_FFFF); + } + + #[test] + fn test_keys() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_iter().collect(); + let keys: Vec<_> = map.keys().copied().collect(); + assert_eq!(keys.len(), 3); + assert!(keys.contains(&1)); + assert!(keys.contains(&2)); + assert!(keys.contains(&3)); + } + + #[test] + fn test_values() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_iter().collect(); + let values: Vec<_> = map.values().copied().collect(); + assert_eq!(values.len(), 3); + assert!(values.contains(&'a')); + assert!(values.contains(&'b')); + assert!(values.contains(&'c')); + } + + #[test] + fn test_values_mut() { + let vec = vec![(1, 1), (2, 2), (3, 3)]; + let mut map: HashMap<_, _> = vec.into_iter().collect(); + for value in map.values_mut() { + *value *= 2; + } + let values: Vec<_> = map.values().copied().collect(); + assert_eq!(values.len(), 3); + assert!(values.contains(&2)); + assert!(values.contains(&4)); + assert!(values.contains(&6)); + } + + #[test] + fn test_into_keys() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_iter().collect(); + let keys: Vec<_> = map.into_keys().collect(); + + assert_eq!(keys.len(), 3); + assert!(keys.contains(&1)); + assert!(keys.contains(&2)); + assert!(keys.contains(&3)); + } + + #[test] + fn test_into_values() { + let vec = vec![(1, 'a'), (2, 'b'), (3, 'c')]; + let map: HashMap<_, _> = vec.into_iter().collect(); + let values: Vec<_> = map.into_values().collect(); + + assert_eq!(values.len(), 3); + assert!(values.contains(&'a')); + assert!(values.contains(&'b')); + assert!(values.contains(&'c')); + } + + #[test] + fn test_find() { + let mut m = HashMap::new(); + assert!(m.get(&1).is_none()); + m.insert(1, 2); + match m.get(&1) { + None => panic!(), + Some(v) => assert_eq!(*v, 2), + } + } + + #[test] + fn test_eq() { + let mut m1 = HashMap::new(); + m1.insert(1, 2); + m1.insert(2, 3); + m1.insert(3, 4); + + let mut m2 = HashMap::new(); + m2.insert(1, 2); + m2.insert(2, 3); + + assert_ne!(m1, m2); + + m2.insert(3, 4); + + assert_eq!(m1, m2); + } + + #[test] + fn test_show() { + let mut map = HashMap::new(); + let empty: HashMap = HashMap::new(); + + map.insert(1, 2); + map.insert(3, 4); + + let map_str = format!("{map:?}"); + + assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}"); + assert_eq!(format!("{empty:?}"), "{}"); + } + + #[test] + fn test_expand() { + let mut m = HashMap::new(); + + assert_eq!(m.len(), 0); + assert!(m.is_empty()); + + let mut i = 0; + let old_raw_cap = m.raw_capacity(); + while old_raw_cap == m.raw_capacity() { + m.insert(i, i); + i += 1; + } + + assert_eq!(m.len(), i); + assert!(!m.is_empty()); + } + + #[test] + fn test_behavior_resize_policy() { + let mut m = HashMap::new(); + + assert_eq!(m.len(), 0); + assert_eq!(m.raw_capacity(), 1); + assert!(m.is_empty()); + + m.insert(0, 0); + m.remove(&0); + assert!(m.is_empty()); + let initial_raw_cap = m.raw_capacity(); + m.reserve(initial_raw_cap); + let raw_cap = m.raw_capacity(); + + assert_eq!(raw_cap, initial_raw_cap * 2); + + let mut i = 0; + for _ in 0..raw_cap * 3 / 4 { + m.insert(i, i); + i += 1; + } + // three quarters full + + assert_eq!(m.len(), i); + assert_eq!(m.raw_capacity(), raw_cap); + + for _ in 0..raw_cap / 4 { + m.insert(i, i); + i += 1; + } + // half full + + let new_raw_cap = m.raw_capacity(); + assert_eq!(new_raw_cap, raw_cap * 2); + + for _ in 0..raw_cap / 2 - 1 { + i -= 1; + m.remove(&i); + assert_eq!(m.raw_capacity(), new_raw_cap); + } + // A little more than one quarter full. + m.shrink_to_fit(); + assert_eq!(m.raw_capacity(), raw_cap); + // again, a little more than half full + for _ in 0..raw_cap / 2 { + i -= 1; + m.remove(&i); + } + m.shrink_to_fit(); + + assert_eq!(m.len(), i); + assert!(!m.is_empty()); + assert_eq!(m.raw_capacity(), initial_raw_cap); + } + + #[test] + fn test_reserve_shrink_to_fit() { + let mut m = HashMap::new(); + m.insert(0, 0); + m.remove(&0); + assert!(m.capacity() >= m.len()); + for i in 0..128 { + m.insert(i, i); + } + m.reserve(256); + + let usable_cap = m.capacity(); + for i in 128..(128 + 256) { + m.insert(i, i); + assert_eq!(m.capacity(), usable_cap); + } + + for i in 100..(128 + 256) { + assert_eq!(m.remove(&i), Some(i)); + } + m.shrink_to_fit(); + + assert_eq!(m.len(), 100); + assert!(!m.is_empty()); + assert!(m.capacity() >= m.len()); + + for i in 0..100 { + assert_eq!(m.remove(&i), Some(i)); + } + m.shrink_to_fit(); + m.insert(0, 0); + + assert_eq!(m.len(), 1); + assert!(m.capacity() >= m.len()); + assert_eq!(m.remove(&0), Some(0)); + } + + #[test] + fn test_from_iter() { + let xs = [(1, 1), (2, 2), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let map: HashMap<_, _> = xs.iter().copied().collect(); + + for &(k, v) in &xs { + assert_eq!(map.get(&k), Some(&v)); + } + + assert_eq!(map.iter().len(), xs.len() - 1); + } + + #[test] + fn test_size_hint() { + let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let map: HashMap<_, _> = xs.iter().copied().collect(); + + let mut iter = map.iter(); + + for _ in iter.by_ref().take(3) {} + + assert_eq!(iter.size_hint(), (3, Some(3))); + } + + #[test] + fn test_iter_len() { + let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let map: HashMap<_, _> = xs.iter().copied().collect(); + + let mut iter = map.iter(); + + for _ in iter.by_ref().take(3) {} + + assert_eq!(iter.len(), 3); + } + + #[test] + fn test_mut_size_hint() { + let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let mut map: HashMap<_, _> = xs.iter().copied().collect(); + + let mut iter = map.iter_mut(); + + for _ in iter.by_ref().take(3) {} + + assert_eq!(iter.size_hint(), (3, Some(3))); + } + + #[test] + fn test_iter_mut_len() { + let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + + let mut map: HashMap<_, _> = xs.iter().copied().collect(); + + let mut iter = map.iter_mut(); + + for _ in iter.by_ref().take(3) {} + + assert_eq!(iter.len(), 3); + } + + #[test] + fn test_index() { + let mut map = HashMap::new(); + + map.insert(1, 2); + map.insert(2, 1); + map.insert(3, 4); + + assert_eq!(map[&2], 1); + } + + #[test] + #[should_panic] + fn test_index_nonexistent() { + let mut map = HashMap::new(); + + map.insert(1, 2); + map.insert(2, 1); + map.insert(3, 4); + + _ = map[&4]; + } + + #[test] + fn test_entry() { + let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)]; + + let mut map: HashMap<_, _> = xs.iter().copied().collect(); + + // Existing key (insert) + match map.entry(1) { + Vacant(_) => unreachable!(), + Occupied(mut view) => { + assert_eq!(view.get(), &10); + assert_eq!(view.insert(100), 10); + } + } + assert_eq!(map.get(&1).unwrap(), &100); + assert_eq!(map.len(), 6); + + // Existing key (update) + match map.entry(2) { + Vacant(_) => unreachable!(), + Occupied(mut view) => { + let v = view.get_mut(); + let new_v = (*v) * 10; + *v = new_v; + } + } + assert_eq!(map.get(&2).unwrap(), &200); + assert_eq!(map.len(), 6); + + // Existing key (take) + match map.entry(3) { + Vacant(_) => unreachable!(), + Occupied(view) => { + assert_eq!(view.remove(), 30); + } + } + assert_eq!(map.get(&3), None); + assert_eq!(map.len(), 5); + + // Inexistent key (insert) + match map.entry(10) { + Occupied(_) => unreachable!(), + Vacant(view) => { + assert_eq!(*view.insert(1000), 1000); + } + } + assert_eq!(map.get(&10).unwrap(), &1000); + assert_eq!(map.len(), 6); + } + + #[test] + fn test_entry_ref() { + let xs = [ + ("One".to_owned(), 10), + ("Two".to_owned(), 20), + ("Three".to_owned(), 30), + ("Four".to_owned(), 40), + ("Five".to_owned(), 50), + ("Six".to_owned(), 60), + ]; + + let mut map: HashMap<_, _> = xs.iter().cloned().collect(); + + // Existing key (insert) + match map.entry_ref("One") { + EntryRef::Vacant(_) => unreachable!(), + EntryRef::Occupied(mut view) => { + assert_eq!(view.get(), &10); + assert_eq!(view.insert(100), 10); + } + } + assert_eq!(map.get("One").unwrap(), &100); + assert_eq!(map.len(), 6); + + // Existing key (update) + match map.entry_ref("Two") { + EntryRef::Vacant(_) => unreachable!(), + EntryRef::Occupied(mut view) => { + let v = view.get_mut(); + let new_v = (*v) * 10; + *v = new_v; + } + } + assert_eq!(map.get("Two").unwrap(), &200); + assert_eq!(map.len(), 6); + + // Existing key (take) + match map.entry_ref("Three") { + EntryRef::Vacant(_) => unreachable!(), + EntryRef::Occupied(view) => { + assert_eq!(view.remove(), 30); + } + } + assert_eq!(map.get("Three"), None); + assert_eq!(map.len(), 5); + + // Inexistent key (insert) + match map.entry_ref("Ten") { + EntryRef::Occupied(_) => unreachable!(), + EntryRef::Vacant(view) => { + assert_eq!(*view.insert(1000), 1000); + } + } + assert_eq!(map.get("Ten").unwrap(), &1000); + assert_eq!(map.len(), 6); + } + + #[test] + fn test_entry_take_doesnt_corrupt() { + #![expect(deprecated)] //rand + // Test for #19292 + fn check(m: &HashMap) { + for k in m.keys() { + assert!(m.contains_key(k), "{k} is in keys() but not in the map?"); + } + } + + let mut m = HashMap::new(); + + let mut rng = { + let seed = u64::from_le_bytes(*b"testseed"); + SmallRng::seed_from_u64(seed) + }; + + // Populate the map with some items. + for _ in 0..50 { + let x = rng.gen_range(-10..10); + m.insert(x, ()); + } + + for _ in 0..1000 { + let x = rng.gen_range(-10..10); + match m.entry(x) { + Vacant(_) => {} + Occupied(e) => { + e.remove(); + } + } + + check(&m); + } + } + + #[test] + fn test_entry_ref_take_doesnt_corrupt() { + #![expect(deprecated)] //rand + // Test for #19292 + fn check(m: &HashMap) { + for k in m.keys() { + assert!(m.contains_key(k), "{k} is in keys() but not in the map?"); + } + } + + let mut m = HashMap::new(); + + let mut rng = { + let seed = u64::from_le_bytes(*b"testseed"); + SmallRng::seed_from_u64(seed) + }; + + // Populate the map with some items. + for _ in 0..50 { + let mut x = std::string::String::with_capacity(1); + x.push(rng.gen_range('a'..='z')); + m.insert(x, ()); + } + + for _ in 0..1000 { + let mut x = std::string::String::with_capacity(1); + x.push(rng.gen_range('a'..='z')); + match m.entry_ref(x.as_str()) { + EntryRef::Vacant(_) => {} + EntryRef::Occupied(e) => { + e.remove(); + } + } + + check(&m); + } + } + + #[test] + fn test_extend_ref_k_ref_v() { + let mut a = HashMap::new(); + a.insert(1, "one"); + let mut b = HashMap::new(); + b.insert(2, "two"); + b.insert(3, "three"); + + a.extend(&b); + + assert_eq!(a.len(), 3); + assert_eq!(a[&1], "one"); + assert_eq!(a[&2], "two"); + assert_eq!(a[&3], "three"); + } + + #[test] + fn test_extend_ref_kv_tuple() { + use std::ops::AddAssign; + let mut a = HashMap::new(); + a.insert(0, 0); + + fn create_arr + Copy, const N: usize>(start: T, step: T) -> [(T, T); N] { + let mut outs: [(T, T); N] = [(start, start); N]; + let mut element = step; + outs.iter_mut().skip(1).for_each(|(k, v)| { + *k += element; + *v += element; + element += step; + }); + outs + } + + let for_iter: Vec<_> = (0..100).map(|i| (i, i)).collect(); + let iter = for_iter.iter(); + let vec: Vec<_> = (100..200).map(|i| (i, i)).collect(); + a.extend(iter); + a.extend(&vec); + a.extend(create_arr::(200, 1)); + + assert_eq!(a.len(), 300); + + for item in 0..300 { + assert_eq!(a[&item], item); + } + } + + #[test] + fn test_capacity_not_less_than_len() { + let mut a = HashMap::new(); + let mut item = 0; + + for _ in 0..116 { + a.insert(item, 0); + item += 1; + } + + assert!(a.capacity() > a.len()); + + let free = a.capacity() - a.len(); + for _ in 0..free { + a.insert(item, 0); + item += 1; + } + + assert_eq!(a.len(), a.capacity()); + + // Insert at capacity should cause allocation. + a.insert(item, 0); + assert!(a.capacity() > a.len()); + } + + #[test] + fn test_occupied_entry_key() { + let mut a = HashMap::new(); + let key = "hello there"; + let value = "value goes here"; + assert!(a.is_empty()); + a.insert(key, value); + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + + match a.entry(key) { + Vacant(_) => panic!(), + Occupied(e) => assert_eq!(key, *e.key()), + } + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + } + + #[test] + fn test_occupied_entry_ref_key() { + let mut a = HashMap::new(); + let key = "hello there"; + let value = "value goes here"; + assert!(a.is_empty()); + a.insert(key.to_owned(), value); + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + + match a.entry_ref(key) { + EntryRef::Vacant(_) => panic!(), + EntryRef::Occupied(e) => assert_eq!(key, e.key()), + } + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + } + + #[test] + fn test_vacant_entry_key() { + let mut a = HashMap::new(); + let key = "hello there"; + let value = "value goes here"; + + assert!(a.is_empty()); + match a.entry(key) { + Occupied(_) => panic!(), + Vacant(e) => { + assert_eq!(key, *e.key()); + e.insert(value); + } + } + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + } + + #[test] + fn test_vacant_entry_ref_key() { + let mut a: HashMap = HashMap::new(); + let key = "hello there"; + let value = "value goes here"; + + assert!(a.is_empty()); + match a.entry_ref(key) { + EntryRef::Occupied(_) => panic!(), + EntryRef::Vacant(e) => { + assert_eq!(key, e.key()); + e.insert(value); + } + } + assert_eq!(a.len(), 1); + assert_eq!(a[key], value); + } + + #[test] + fn test_occupied_entry_replace_entry_with() { + let mut a = HashMap::new(); + + let key = "a key"; + let value = "an initial value"; + let new_value = "a new value"; + + let entry = a.entry(key).insert(value).replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, value); + Some(new_value) + }); + + match entry { + Occupied(e) => { + assert_eq!(e.key(), &key); + assert_eq!(e.get(), &new_value); + } + Vacant(_) => panic!(), + } + + assert_eq!(a[key], new_value); + assert_eq!(a.len(), 1); + + let entry = match a.entry(key) { + Occupied(e) => e.replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, new_value); + None + }), + Vacant(_) => panic!(), + }; + + match entry { + Vacant(e) => assert_eq!(e.key(), &key), + Occupied(_) => panic!(), + } + + assert!(!a.contains_key(key)); + assert_eq!(a.len(), 0); + } + + #[test] + fn test_entry_and_replace_entry_with() { + let mut a = HashMap::new(); + + let key = "a key"; + let value = "an initial value"; + let new_value = "a new value"; + + let entry = a.entry(key).and_replace_entry_with(|_, _| panic!()); + + match entry { + Vacant(e) => assert_eq!(e.key(), &key), + Occupied(_) => panic!(), + } + + a.insert(key, value); + + let entry = a.entry(key).and_replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, value); + Some(new_value) + }); + + match entry { + Occupied(e) => { + assert_eq!(e.key(), &key); + assert_eq!(e.get(), &new_value); + } + Vacant(_) => panic!(), + } + + assert_eq!(a[key], new_value); + assert_eq!(a.len(), 1); + + let entry = a.entry(key).and_replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, new_value); + None + }); + + match entry { + Vacant(e) => assert_eq!(e.key(), &key), + Occupied(_) => panic!(), + } + + assert!(!a.contains_key(key)); + assert_eq!(a.len(), 0); + } + + #[test] + fn test_replace_entry_with_doesnt_corrupt() { + #![expect(deprecated)] //rand + // Test for #19292 + fn check(m: &HashMap) { + for k in m.keys() { + assert!(m.contains_key(k), "{k} is in keys() but not in the map?"); + } + } + + let mut m = HashMap::new(); + + let mut rng = { + let seed = u64::from_le_bytes(*b"testseed"); + SmallRng::seed_from_u64(seed) + }; + + // Populate the map with some items. + for _ in 0..50 { + let x = rng.gen_range(-10..10); + m.insert(x, ()); + } + + for _ in 0..1000 { + let x = rng.gen_range(-10..10); + m.entry(x).and_replace_entry_with(|_, _| None); + check(&m); + } + } + + #[test] + fn test_retain() { + let mut map: HashMap = (0..100).map(|x| (x, x * 10)).collect(); + + map.retain(|&k, _| k % 2 == 0); + assert_eq!(map.len(), 50); + assert_eq!(map[&2], 20); + assert_eq!(map[&4], 40); + assert_eq!(map[&6], 60); + } + + #[test] + fn test_extract_if() { + { + let mut map: HashMap = (0..8).map(|x| (x, x * 10)).collect(); + let drained = map.extract_if(|&k, _| k % 2 == 0); + let mut out = drained.collect::>(); + out.sort_unstable(); + assert_eq!(vec![(0, 0), (2, 20), (4, 40), (6, 60)], out); + assert_eq!(map.len(), 4); + } + { + let mut map: HashMap = (0..8).map(|x| (x, x * 10)).collect(); + map.extract_if(|&k, _| k % 2 == 0).for_each(drop); + assert_eq!(map.len(), 4); + } + } + + #[test] + #[cfg_attr(miri, ignore)] // FIXME: no OOM signalling (https://github.com/rust-lang/miri/issues/613) + fn test_try_reserve() { + use crate::TryReserveError::{AllocError, CapacityOverflow}; + + const MAX_ISIZE: usize = isize::MAX as usize; + + let mut empty_bytes: HashMap = HashMap::new(); + + if let Err(CapacityOverflow) = empty_bytes.try_reserve(usize::MAX) { + } else { + panic!("usize::MAX should trigger an overflow!"); + } + + if let Err(CapacityOverflow) = empty_bytes.try_reserve(MAX_ISIZE) { + } else { + panic!("isize::MAX should trigger an overflow!"); + } + + if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_ISIZE / 5) { + } else { + // This may succeed if there is enough free memory. Attempt to + // allocate a few more hashmaps to ensure the allocation will fail. + let mut empty_bytes2: HashMap = HashMap::new(); + let _ = empty_bytes2.try_reserve(MAX_ISIZE / 5); + let mut empty_bytes3: HashMap = HashMap::new(); + let _ = empty_bytes3.try_reserve(MAX_ISIZE / 5); + let mut empty_bytes4: HashMap = HashMap::new(); + if let Err(AllocError { .. }) = empty_bytes4.try_reserve(MAX_ISIZE / 5) { + } else { + panic!("isize::MAX / 5 should trigger an OOM!"); + } + } + } + + #[test] + fn test_const_with_hasher() { + use core::hash::BuildHasher; + use std::collections::hash_map::DefaultHasher; + + #[derive(Clone)] + struct MyHasher; + impl BuildHasher for MyHasher { + type Hasher = DefaultHasher; + + fn build_hasher(&self) -> DefaultHasher { + DefaultHasher::new() + } + } + + const EMPTY_MAP: HashMap = + HashMap::with_hasher(MyHasher); + + let mut map = EMPTY_MAP; + map.insert(17, "seventeen".to_owned()); + assert_eq!("seventeen", map[&17]); + } + + #[test] + fn test_get_disjoint_mut() { + let mut map = HashMap::new(); + map.insert("foo".to_owned(), 0); + map.insert("bar".to_owned(), 10); + map.insert("baz".to_owned(), 20); + map.insert("qux".to_owned(), 30); + + let xs = map.get_disjoint_mut(["foo", "qux"]); + assert_eq!(xs, [Some(&mut 0), Some(&mut 30)]); + + let xs = map.get_disjoint_mut(["foo", "dud"]); + assert_eq!(xs, [Some(&mut 0), None]); + + let ys = map.get_disjoint_key_value_mut(["bar", "baz"]); + assert_eq!( + ys, + [ + Some((&"bar".to_owned(), &mut 10)), + Some((&"baz".to_owned(), &mut 20)) + ], + ); + + let ys = map.get_disjoint_key_value_mut(["bar", "dip"]); + assert_eq!(ys, [Some((&"bar".to_owned(), &mut 10)), None]); + } + + #[test] + #[should_panic = "duplicate keys found"] + fn test_get_disjoint_mut_duplicate() { + let mut map = HashMap::new(); + map.insert("foo".to_owned(), 0); + + let _xs = map.get_disjoint_mut(["foo", "foo"]); + } + + #[test] + #[should_panic = "panic in drop"] + fn test_clone_from_double_drop() { + #[derive(Clone)] + struct CheckedDrop { + panic_in_drop: bool, + dropped: bool, + } + impl Drop for CheckedDrop { + fn drop(&mut self) { + if self.panic_in_drop { + self.dropped = true; + panic!("panic in drop"); + } + assert!(!self.dropped, "double drop"); + self.dropped = true; + } + } + const DISARMED: CheckedDrop = CheckedDrop { + panic_in_drop: false, + dropped: false, + }; + const ARMED: CheckedDrop = CheckedDrop { + panic_in_drop: true, + dropped: false, + }; + + let mut map1 = HashMap::new(); + map1.insert(1, DISARMED); + map1.insert(2, DISARMED); + map1.insert(3, DISARMED); + map1.insert(4, DISARMED); + + let mut map2 = HashMap::new(); + map2.insert(1, DISARMED); + map2.insert(2, ARMED); + map2.insert(3, DISARMED); + map2.insert(4, DISARMED); + + map2.clone_from(&map1); + } + + #[test] + #[should_panic = "panic in clone"] + fn test_clone_from_memory_leaks() { + use stdalloc::vec::Vec; + + struct CheckedClone { + panic_in_clone: bool, + need_drop: Vec, + } + impl Clone for CheckedClone { + fn clone(&self) -> Self { + assert!(!self.panic_in_clone, "panic in clone"); + Self { + panic_in_clone: self.panic_in_clone, + need_drop: self.need_drop.clone(), + } + } + } + let mut map1 = HashMap::new(); + map1.insert( + 1, + CheckedClone { + panic_in_clone: false, + need_drop: vec![0, 1, 2], + }, + ); + map1.insert( + 2, + CheckedClone { + panic_in_clone: false, + need_drop: vec![3, 4, 5], + }, + ); + map1.insert( + 3, + CheckedClone { + panic_in_clone: true, + need_drop: vec![6, 7, 8], + }, + ); + let _map2 = map1.clone(); + } + + struct MyAllocInner { + drop_count: Arc, + } + + #[derive(Clone)] + struct MyAlloc { + _inner: Arc, + } + + impl MyAlloc { + fn new(drop_count: Arc) -> Self { + MyAlloc { + _inner: Arc::new(MyAllocInner { drop_count }), + } + } + } + + impl Drop for MyAllocInner { + fn drop(&mut self) { + println!("MyAlloc freed."); + self.drop_count.fetch_sub(1, Ordering::SeqCst); + } + } + + unsafe impl Allocator for MyAlloc { + fn allocate(&self, layout: Layout) -> Result, AllocError> { + let g = Global; + g.allocate(layout) + } + + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + unsafe { + let g = Global; + g.deallocate(ptr, layout); + } + } + } + + #[test] + fn test_hashmap_into_iter_bug() { + let dropped: Arc = Arc::new(AtomicI8::new(1)); + + { + let mut map = HashMap::with_capacity_in(10, MyAlloc::new(dropped.clone())); + for i in 0..10 { + map.entry(i).or_insert_with(|| "i".to_owned()); + } + + for (k, v) in map { + println!("{k}, {v}"); + } + } + + // All allocator clones should already be dropped. + assert_eq!(dropped.load(Ordering::SeqCst), 0); + } + + #[test] + fn test_hashmap_into_iter_unallocated_drops_allocator() { + let dropped: Arc = Arc::new(AtomicI8::new(1)); + + { + let map: HashMap = HashMap::with_hasher_in( + DefaultHashBuilder::default(), + MyAlloc::new(dropped.clone()), + ); + + for _ in map {} + } + + // The table never allocated, but the allocator must still be dropped. + assert_eq!(dropped.load(Ordering::SeqCst), 0); + } + + #[derive(Debug)] + struct CheckedCloneDrop { + panic_in_clone: bool, + panic_in_drop: bool, + dropped: bool, + data: T, + } + + impl CheckedCloneDrop { + fn new(panic_in_clone: bool, panic_in_drop: bool, data: T) -> Self { + CheckedCloneDrop { + panic_in_clone, + panic_in_drop, + dropped: false, + data, + } + } + } + + impl Clone for CheckedCloneDrop { + fn clone(&self) -> Self { + assert!(!self.panic_in_clone, "panic in clone"); + Self { + panic_in_clone: self.panic_in_clone, + panic_in_drop: self.panic_in_drop, + dropped: self.dropped, + data: self.data.clone(), + } + } + } + + impl Drop for CheckedCloneDrop { + fn drop(&mut self) { + if self.panic_in_drop { + self.dropped = true; + panic!("panic in drop"); + } + assert!(!self.dropped, "double drop"); + self.dropped = true; + } + } + + /// Return hashmap with predefined distribution of elements. + /// All elements will be located in the same order as elements + /// returned by iterator. + /// + /// This function does not panic, but returns an error as a `String` + /// to distinguish between a test panic and an error in the input data. + fn get_test_map( + iter: I, + mut fun: impl FnMut(u64) -> T, + alloc: A, + ) -> Result, DefaultHashBuilder, A>, String> + where + I: Iterator + Clone + ExactSizeIterator, + A: Allocator, + T: PartialEq + core::fmt::Debug, + { + use crate::scopeguard::guard; + + let mut map: HashMap, _, A> = + HashMap::with_capacity_in(iter.size_hint().0, alloc); + { + let mut guard = guard(&mut map, |map| { + for (_, value) in map.iter_mut() { + value.panic_in_drop = false; + } + }); + + let mut count = 0; + // Hash and Key must be equal to each other for controlling the elements placement. + for (panic_in_clone, panic_in_drop) in iter.clone() { + if core::mem::needs_drop::() && panic_in_drop { + return Err(String::from( + "panic_in_drop can be set with a type that doesn't need to be dropped", + )); + } + guard.table.insert( + count, + ( + count, + CheckedCloneDrop::new(panic_in_clone, panic_in_drop, fun(count)), + ), + |(k, _)| *k, + ); + count += 1; + } + + // Let's check that all elements are located as we wanted + let mut check_count = 0; + for ((key, value), (panic_in_clone, panic_in_drop)) in guard.iter().zip(iter) { + if *key != check_count { + return Err(format!( + "key != check_count,\nkey: `{key}`,\ncheck_count: `{check_count}`" + )); + } + if value.dropped + || value.panic_in_clone != panic_in_clone + || value.panic_in_drop != panic_in_drop + || value.data != fun(check_count) + { + return Err(format!( + "Value is not equal to expected,\nvalue: `{:?}`,\nexpected: \ + `CheckedCloneDrop {{ panic_in_clone: {}, panic_in_drop: {}, dropped: {}, data: {:?} }}`", + value, + panic_in_clone, + panic_in_drop, + false, + fun(check_count) + )); + } + check_count += 1; + } + + if guard.len() != check_count as usize { + return Err(format!( + "map.len() != check_count,\nmap.len(): `{}`,\ncheck_count: `{}`", + guard.len(), + check_count + )); + } + + if count != check_count { + return Err(format!( + "count != check_count,\ncount: `{count}`,\ncheck_count: `{check_count}`" + )); + } + core::mem::forget(guard); + } + Ok(map) + } + + const DISARMED: bool = false; + const ARMED: bool = true; + + const ARMED_FLAGS: [bool; 8] = [ + DISARMED, DISARMED, DISARMED, ARMED, DISARMED, DISARMED, DISARMED, DISARMED, + ]; + + const DISARMED_FLAGS: [bool; 8] = [ + DISARMED, DISARMED, DISARMED, DISARMED, DISARMED, DISARMED, DISARMED, DISARMED, + ]; + + #[test] + #[should_panic = "panic in clone"] + fn test_clone_memory_leaks_and_double_drop_one() { + let dropped: Arc = Arc::new(AtomicI8::new(2)); + + { + assert_eq!(ARMED_FLAGS.len(), DISARMED_FLAGS.len()); + + let map: HashMap>, DefaultHashBuilder, MyAlloc> = + match get_test_map( + ARMED_FLAGS.into_iter().zip(DISARMED_FLAGS), + |n| vec![n], + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => panic!("{msg}"), + }; + + // Clone should normally clone a few elements, and then (when the + // clone function panics), deallocate both its own memory, memory + // of `dropped: Arc` and the memory of already cloned + // elements (Vec memory inside CheckedCloneDrop). + let _map2 = map.clone(); + } + } + + #[test] + #[should_panic = "panic in drop"] + fn test_clone_memory_leaks_and_double_drop_two() { + let dropped: Arc = Arc::new(AtomicI8::new(2)); + + { + assert_eq!(ARMED_FLAGS.len(), DISARMED_FLAGS.len()); + + let map: HashMap, DefaultHashBuilder, _> = match get_test_map( + DISARMED_FLAGS.into_iter().zip(DISARMED_FLAGS), + |n| n, + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => panic!("{msg}"), + }; + + let mut map2 = match get_test_map( + DISARMED_FLAGS.into_iter().zip(ARMED_FLAGS), + |n| n, + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => panic!("{msg}"), + }; + + // The `clone_from` should try to drop the elements of `map2` without + // double drop and leaking the allocator. Elements that have not been + // dropped leak their memory. + map2.clone_from(&map); + } + } + + /// We check that we have a working table if the clone operation from another + /// thread ended in a panic (when buckets of maps are equal to each other). + #[test] + #[cfg(panic = "unwind")] + fn test_catch_panic_clone_from_when_len_is_equal() { + use std::thread; + + let dropped: Arc = Arc::new(AtomicI8::new(2)); + + { + assert_eq!(ARMED_FLAGS.len(), DISARMED_FLAGS.len()); + + let mut map = match get_test_map( + DISARMED_FLAGS.into_iter().zip(DISARMED_FLAGS), + |n| vec![n], + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => panic!("{msg}"), + }; + + thread::scope(|s| { + let result: thread::ScopedJoinHandle<'_, String> = s.spawn(|| { + let scope_map = + match get_test_map(ARMED_FLAGS.into_iter().zip(DISARMED_FLAGS), |n| vec![n * 2], MyAlloc::new(dropped.clone())) { + Ok(map) => map, + Err(msg) => return msg, + }; + if map.table.num_buckets() != scope_map.table.num_buckets() { + return format!( + "map.table.num_buckets() != scope_map.table.num_buckets(),\nleft: `{}`,\nright: `{}`", + map.table.num_buckets(), scope_map.table.num_buckets() + ); + } + map.clone_from(&scope_map); + "We must fail the cloning!!!".to_owned() + }); + if let Ok(msg) = result.join() { + panic!("{msg}") + } + }); + + // Let's check that all iterators work fine and do not return elements + // (especially `RawIterRange`, which does not depend on the number of + // elements in the table, but looks directly at the control bytes) + // + // SAFETY: We know for sure that `RawTable` will outlive + // the returned `RawIter / RawIterRange` iterator. + assert_eq!(map.len(), 0); + assert_eq!(map.iter().count(), 0); + assert_eq!(unsafe { map.table.iter().count() }, 0); + assert_eq!(unsafe { map.table.iter().iter.count() }, 0); + + for idx in 0..map.table.num_buckets() { + let idx = idx as u64; + assert!( + map.table.find(idx, |(k, _)| *k == idx).is_none(), + "Index: {idx}" + ); + } + } + + // All allocator clones should already be dropped. + assert_eq!(dropped.load(Ordering::SeqCst), 0); + } + + /// We check that we have a working table if the clone operation from another + /// thread ended in a panic (when buckets of maps are not equal to each other). + #[test] + #[cfg(panic = "unwind")] + fn test_catch_panic_clone_from_when_len_is_not_equal() { + use std::thread; + + let dropped: Arc = Arc::new(AtomicI8::new(2)); + + { + assert_eq!(ARMED_FLAGS.len(), DISARMED_FLAGS.len()); + + let mut map = match get_test_map( + [DISARMED].into_iter().zip([DISARMED]), + |n| vec![n], + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => panic!("{msg}"), + }; + + thread::scope(|s| { + let result: thread::ScopedJoinHandle<'_, String> = s.spawn(|| { + let scope_map = match get_test_map( + ARMED_FLAGS.into_iter().zip(DISARMED_FLAGS), + |n| vec![n * 2], + MyAlloc::new(dropped.clone()), + ) { + Ok(map) => map, + Err(msg) => return msg, + }; + if map.table.num_buckets() == scope_map.table.num_buckets() { + return format!( + "map.table.num_buckets() == scope_map.table.num_buckets(): `{}`", + map.table.num_buckets() + ); + } + map.clone_from(&scope_map); + "We must fail the cloning!!!".to_owned() + }); + if let Ok(msg) = result.join() { + panic!("{msg}") + } + }); + + // Let's check that all iterators work fine and do not return elements + // (especially `RawIterRange`, which does not depend on the number of + // elements in the table, but looks directly at the control bytes) + // + // SAFETY: We know for sure that `RawTable` will outlive + // the returned `RawIter / RawIterRange` iterator. + assert_eq!(map.len(), 0); + assert_eq!(map.iter().count(), 0); + assert_eq!(unsafe { map.table.iter().count() }, 0); + assert_eq!(unsafe { map.table.iter().iter.count() }, 0); + + for idx in 0..map.table.num_buckets() { + let idx = idx as u64; + assert!( + map.table.find(idx, |(k, _)| *k == idx).is_none(), + "Index: {idx}" + ); + } + } + + // All allocator clones should already be dropped. + assert_eq!(dropped.load(Ordering::SeqCst), 0); + } + + #[test] + fn test_allocation_info() { + assert_eq!(HashMap::<(), ()>::new().allocation_size(), 0); + assert_eq!(HashMap::::new().allocation_size(), 0); + assert!(HashMap::::with_capacity(1).allocation_size() > size_of::()); + } +} + +#[cfg(all(test, unix, any(feature = "nightly", feature = "allocator-api2")))] +mod test_map_with_mmap_allocations { + use super::HashMap; + use crate::raw::prev_pow2; + use core::alloc::Layout; + use core::ptr::{NonNull, null_mut}; + + #[cfg(feature = "nightly")] + use core::alloc::{AllocError, Allocator}; + + #[cfg(all(feature = "allocator-api2", not(feature = "nightly")))] + use allocator_api2::alloc::{AllocError, Allocator}; + + /// This is not a production quality allocator, just good enough for + /// some basic tests. + #[derive(Clone, Copy, Debug)] + struct MmapAllocator { + /// Guarantee this is a power of 2. + page_size: usize, + } + + impl MmapAllocator { + fn new() -> Result { + let result = unsafe { libc::sysconf(libc::_SC_PAGESIZE) }; + if result < 1 { + return Err(AllocError); + } + + let page_size = result as usize; + if page_size.is_power_of_two() { + Ok(Self { page_size }) + } else { + Err(AllocError) + } + } + + fn fit_to_page_size(&self, n: usize) -> Result { + // If n=0, give a single page (wasteful, I know). + let n = if n == 0 { self.page_size } else { n }; + + match n & (self.page_size - 1) { + 0 => Ok(n), + rem => n.checked_add(self.page_size - rem).ok_or(AllocError), + } + } + } + + unsafe impl Allocator for MmapAllocator { + fn allocate(&self, layout: Layout) -> Result, AllocError> { + if layout.align() > self.page_size { + return Err(AllocError); + } + + let null = null_mut(); + let len = self.fit_to_page_size(layout.size())? as libc::size_t; + let prot = libc::PROT_READ | libc::PROT_WRITE; + let flags = libc::MAP_PRIVATE | libc::MAP_ANON; + let addr = unsafe { libc::mmap(null, len, prot, flags, -1, 0) }; + + // mmap returns MAP_FAILED on failure, not Null. + if addr == libc::MAP_FAILED { + return Err(AllocError); + } + + if let Some(data) = NonNull::new(addr.cast()) { + // SAFETY: this is NonNull::slice_from_raw_parts. + Ok(unsafe { + NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(data.as_ptr(), len)) + }) + } else { + // This branch shouldn't be taken in practice, but since we + // cannot return null as a valid pointer in our type system, + // we attempt to handle it. + _ = unsafe { libc::munmap(addr, len) }; + Err(AllocError) + } + } + + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + unsafe { + // If they allocated it with this layout, it must round correctly. + let size = self.fit_to_page_size(layout.size()).unwrap(); + let _result = libc::munmap(ptr.as_ptr().cast(), size); + debug_assert_eq!(0, _result); + } + } + } + + #[test] + fn test_tiny_allocation_gets_rounded_to_page_size() { + let alloc = MmapAllocator::new().unwrap(); + let mut map: HashMap = HashMap::with_capacity_in(1, alloc); + + // Size of an element plus its control byte. + let rough_bucket_size = size_of::<(usize, ())>() + 1; + + // Accounting for some misc. padding that's likely in the allocation + // due to rounding to group width, etc. + let overhead = 3 * size_of::(); + let num_buckets = (alloc.page_size - overhead) / rough_bucket_size; + // Buckets are always powers of 2. + let min_elems = prev_pow2(num_buckets); + // Real load-factor is 7/8, but this is a lower estimation, so 1/2. + let min_capacity = min_elems >> 1; + let capacity = map.capacity(); + assert!( + capacity >= min_capacity, + "failed: {capacity} >= {min_capacity}" + ); + + // Fill it up. + for i in 0..capacity { + map.insert(i, ()); + } + // Capacity should not have changed and it should be full. + assert_eq!(capacity, map.len()); + assert_eq!(capacity, map.capacity()); + + // Alright, make it grow. + map.insert(capacity, ()); + assert!( + capacity < map.capacity(), + "failed: {capacity} < {}", + map.capacity() + ); + } +} diff --git a/library/hashbrown/src/raw.rs b/library/hashbrown/src/raw.rs new file mode 100644 index 0000000000000..edf91666b137a --- /dev/null +++ b/library/hashbrown/src/raw.rs @@ -0,0 +1,4633 @@ +use crate::TryReserveError; +use crate::control::{BitMaskIter, Group, Tag, TagSliceExt}; +use crate::scopeguard::{ScopeGuard, guard}; +use crate::util::{likely, unlikely}; +use core::alloc::Layout; +use core::array; +use core::iter::FusedIterator; +use core::marker::PhantomData; +use core::mem::{self, ManuallyDrop}; +use core::ptr; +use core::ptr::NonNull; +use core::slice; +use stdalloc::alloc::handle_alloc_error; + +#[cfg(test)] +use crate::alloc::AllocError; +use crate::alloc::{Allocator, Global, do_alloc}; + +#[inline] +unsafe fn offset_from(to: *const T, from: *const T) -> usize { + unsafe { to.offset_from(from) as usize } +} + +/// Whether memory allocation errors should return an error or abort. +#[derive(Copy, Clone)] +enum Fallibility { + Fallible, + Infallible, +} + +impl Fallibility { + /// Error to return on capacity overflow. + #[cfg_attr(feature = "inline-more", inline)] + fn capacity_overflow(self) -> TryReserveError { + match self { + Fallibility::Fallible => TryReserveError::CapacityOverflow, + Fallibility::Infallible => panic!("Hash table capacity overflow"), + } + } + + /// Error to return on allocation error. + #[cfg_attr(feature = "inline-more", inline)] + fn alloc_err(self, layout: Layout) -> TryReserveError { + match self { + Fallibility::Fallible => TryReserveError::AllocError { layout }, + Fallibility::Infallible => handle_alloc_error(layout), + } + } +} + +trait SizedTypeProperties: Sized { + const IS_ZERO_SIZED: bool = size_of::() == 0; + const NEEDS_DROP: bool = mem::needs_drop::(); +} + +impl SizedTypeProperties for T {} + +/// Primary hash function, used to select the initial bucket to probe from. +#[inline] +#[expect(clippy::cast_possible_truncation)] +fn h1(hash: u64) -> usize { + // On 32-bit platforms we simply ignore the higher hash bits. + hash as usize +} + +/// Probe sequence based on triangular numbers, which is guaranteed (since our +/// table size is a power of two) to visit every group of elements exactly once. +/// +/// A triangular probe has us jump by 1 more group every time. So first we +/// jump by 1 group (meaning we just continue our linear scan), then 2 groups +/// (skipping over 1 group), then 3 groups (skipping over 2 groups), and so on. +/// +/// Proof that the probe will visit every group in the table: +/// +#[derive(Clone)] +struct ProbeSeq { + pos: usize, + stride: usize, +} + +impl ProbeSeq { + #[inline] + fn move_next(&mut self, bucket_mask: usize) { + // We should have found an empty bucket by now and ended the probe. + debug_assert!( + self.stride <= bucket_mask, + "Went past end of probe sequence" + ); + + self.stride = self.stride.wrapping_add(Group::WIDTH); + self.pos = self.pos.wrapping_add(self.stride) & bucket_mask; + } +} + +/// Returns the number of buckets needed to hold the given number of items, +/// taking the maximum load factor into account. +/// +/// Returns `None` if an overflow occurs. +/// +/// This ensures that `buckets * table_layout.size >= table_layout.ctrl_align`. +// Workaround for emscripten bug emscripten-core/emscripten-fastcomp#258 +#[cfg_attr(target_os = "emscripten", inline(never))] +#[cfg_attr(not(target_os = "emscripten"), inline)] +fn capacity_to_buckets(cap: usize, table_layout: TableLayout) -> Option { + debug_assert_ne!(cap, 0); + + // For small tables we require at least 1 empty bucket so that lookups are + // guaranteed to terminate if an element doesn't exist in the table. + if cap < 15 { + // Consider a small TableLayout like { size: 1, ctrl_align: 16 } on a + // platform with Group::WIDTH of 16 (like x86_64 with SSE2). For small + // bucket sizes, this ends up wasting quite a few bytes just to pad to + // the relatively larger ctrl_align: + // + // | capacity | buckets | bytes allocated | bytes per item | + // | -------- | ------- | --------------- | -------------- | + // | 3 | 4 | 36 | (Yikes!) 12.0 | + // | 7 | 8 | 40 | (Poor) 5.7 | + // | 14 | 16 | 48 | 3.4 | + // | 28 | 32 | 80 | 3.3 | + // + // In general, buckets * table_layout.size >= table_layout.ctrl_align + // must be true to avoid these edges. This is implemented by adjusting + // the minimum capacity upwards for small items. This code only needs + // to handle ctrl_align which are less than or equal to Group::WIDTH, + // because valid layout sizes are always a multiple of the alignment, + // so anything with alignment over the Group::WIDTH won't hit this edge + // case. + + // This is brittle, e.g. if we ever add 32 byte groups, it will select + // 3 regardless of the table_layout.size. + let min_cap = match (Group::WIDTH, table_layout.size) { + (16, 0..=1) => 14, + (16, 2..=3) | (8, 0..=1) => 7, + _ => 3, + }; + let cap = min_cap.max(cap); + // We don't bother with a table size of 2 buckets since that can only + // hold a single element. Instead, we skip directly to a 4 bucket table + // which can hold 3 elements. + let buckets = if cap < 4 { + 4 + } else if cap < 8 { + 8 + } else { + 16 + }; + ensure_bucket_bytes_at_least_ctrl_align(table_layout, buckets); + return Some(buckets); + } + + // Otherwise require 1/8 buckets to be empty (87.5% load) + // + // Be careful when modifying this, calculate_layout relies on the + // overflow check here. + let adjusted_cap = cap.checked_mul(8)? / 7; + + // Any overflows will have been caught by the checked_mul. Also, any + // rounding errors from the division above will be cleaned up by + // next_power_of_two (which can't overflow because of the previous division). + let buckets = adjusted_cap.next_power_of_two(); + ensure_bucket_bytes_at_least_ctrl_align(table_layout, buckets); + Some(buckets) +} + +// `maximum_buckets_in` relies on the property that for non-ZST `T`, any +// chosen `buckets` will satisfy `buckets * table_layout.size >= +// table_layout.ctrl_align`, so `calculate_layout_for` does not need to add +// extra padding beyond `table_layout.size * buckets`. If small-table bucket +// selection or growth policy changes, revisit `maximum_buckets_in`. +#[inline] +fn ensure_bucket_bytes_at_least_ctrl_align(table_layout: TableLayout, buckets: usize) { + if table_layout.size != 0 { + let prod = table_layout.size.saturating_mul(buckets); + debug_assert!(prod >= table_layout.ctrl_align); + } +} + +/// Returns the maximum effective capacity for the given bucket mask, taking +/// the maximum load factor into account. +#[inline] +fn bucket_mask_to_capacity(bucket_mask: usize) -> usize { + if bucket_mask < 8 { + // For tables with 1/2/4/8 buckets, we always reserve one empty slot. + // Keep in mind that the bucket mask is one less than the bucket count. + bucket_mask + } else { + // `bucket_mask` is bounded by the maximum allocation size, so it can + // never be `usize::MAX` and the `+ 1` below cannot overflow. + debug_assert!(bucket_mask != usize::MAX); + // For larger tables we reserve 12.5% of the slots as empty. + ((bucket_mask + 1) / 8) * 7 + } +} + +/// Helper which allows the max calculation for `ctrl_align` to be statically computed for each `T` +/// while keeping the rest of `calculate_layout_for` independent of `T` +#[derive(Copy, Clone)] +struct TableLayout { + size: usize, + ctrl_align: usize, +} + +impl TableLayout { + #[inline] + const fn new() -> Self { + let layout = Layout::new::(); + Self { + size: layout.size(), + ctrl_align: if layout.align() > Group::WIDTH { + layout.align() + } else { + Group::WIDTH + }, + } + } + + #[inline] + fn calculate_layout_for(self, buckets: usize) -> Option<(Layout, usize)> { + debug_assert!(buckets.is_power_of_two()); + + let TableLayout { size, ctrl_align } = self; + // Manual layout calculation since Layout methods are not yet stable. + let ctrl_offset = + size.checked_mul(buckets)?.checked_add(ctrl_align - 1)? & !(ctrl_align - 1); + let len = ctrl_offset.checked_add(buckets + Group::WIDTH)?; + + // We need an additional check to ensure that the allocation doesn't + // exceed `isize::MAX` (https://github.com/rust-lang/rust/pull/95295). + if len > isize::MAX as usize - (ctrl_align - 1) { + return None; + } + + Some(( + unsafe { Layout::from_size_align_unchecked(len, ctrl_align) }, + ctrl_offset, + )) + } +} + +/// A reference to a hash table bucket containing a `T`. +/// +/// This is usually just a pointer to the element itself. However if the element +/// is a ZST, then we instead track the index of the element in the table so +/// that `erase` works properly. +pub(crate) struct Bucket { + // Actually it is pointer to next element than element itself + // this is needed to maintain pointer arithmetic invariants + // keeping direct pointer to element introduces difficulty. + // Using `NonNull` for variance and niche layout + ptr: NonNull, +} + +// This Send impl is needed for rayon support. This is safe since Bucket is +// never exposed in a public API. +unsafe impl Send for Bucket {} + +impl Clone for Bucket { + #[inline] + fn clone(&self) -> Self { + Self { ptr: self.ptr } + } +} + +impl Bucket { + /// Creates a [`Bucket`] that contain pointer to the data. + /// The pointer calculation is performed by calculating the + /// offset from given `base` pointer (convenience for + /// `base.as_ptr().sub(index)`). + /// + /// `index` is in units of `T`; e.g., an `index` of 3 represents a pointer + /// offset of `3 * size_of::()` bytes. + /// + /// If the `T` is a ZST, then we instead track the index of the element + /// in the table so that `erase` works properly (return + /// `NonNull::new_unchecked((index + 1) as *mut T)`) + /// + /// # Safety + /// + /// If `size_of::() != 0`, then the safety rules are directly derived + /// from the safety rules for [`<*mut T>::sub`] method of `*mut T` and the safety + /// rules of [`NonNull::new_unchecked`] function. + /// + /// Thus, in order to uphold the safety contracts for the [`<*mut T>::sub`] method + /// and [`NonNull::new_unchecked`] function, as well as for the correct + /// logic of the work of this crate, the following rules are necessary and + /// sufficient: + /// + /// * the `base` pointer must not be `dangling` and must points to the + /// end of the first `value element` from the `data part` of the table, i.e. + /// must be the pointer that returned by [`RawTable::data_end`] or by + /// [`RawTableInner::data_end`]; + /// + /// * `index` must not be greater than `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` + /// must be no greater than the number returned by the function + /// [`RawTable::num_buckets`] or [`RawTableInner::num_buckets`]. + /// + /// If `size_of::() == 0`, then the only requirement is that the + /// `index` must not be greater than `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` + /// must be no greater than the number returned by the function + /// [`RawTable::num_buckets`] or [`RawTableInner::num_buckets`]. + #[inline] + unsafe fn from_base_index(base: NonNull, index: usize) -> Self { + // If size_of::() != 0 then return a pointer to an `element` in + // the data part of the table (we start counting from "0", so that + // in the expression T[last], the "last" index actually one less than the + // "buckets" number in the table, i.e. "last = RawTableInner.bucket_mask"): + // + // `from_base_index(base, 1).as_ptr()` returns a pointer that + // points here in the data part of the table + // (to the start of T1) + // | + // | `base: NonNull` must point here + // | (to the end of T0 or to the start of C0) + // v v + // [Padding], Tlast, ..., |T1|, T0, |C0, C1, ..., Clast + // ^ + // `from_base_index(base, 1)` returns a pointer + // that points here in the data part of the table + // (to the end of T1) + // + // where: T0...Tlast - our stored data; C0...Clast - control bytes + // or metadata for data. + let ptr = if T::IS_ZERO_SIZED { + // won't overflow because index must be less than length (bucket_mask) + // and bucket_mask is guaranteed to be less than `isize::MAX` + // (see TableLayout::calculate_layout_for method) + ptr::without_provenance_mut(index + 1) + } else { + unsafe { base.as_ptr().sub(index) } + }; + Self { + ptr: unsafe { NonNull::new_unchecked(ptr) }, + } + } + + /// Calculates the index of a [`Bucket`] as distance between two pointers + /// (convenience for `base.as_ptr().offset_from(self.ptr.as_ptr()) as usize`). + /// The returned value is in units of T: the distance in bytes divided by + /// [`size_of::()`]. + /// + /// If the `T` is a ZST, then we return the index of the element in + /// the table so that `erase` works properly (return `self.ptr.as_ptr() as usize - 1`). + /// + /// This function is the inverse of [`from_base_index`]. + /// + /// # Safety + /// + /// If `size_of::() != 0`, then the safety rules are directly derived + /// from the safety rules for [`<*const T>::offset_from`] method of `*const T`. + /// + /// Thus, in order to uphold the safety contracts for [`<*const T>::offset_from`] + /// method, as well as for the correct logic of the work of this crate, the + /// following rules are necessary and sufficient: + /// + /// * `base` contained pointer must not be `dangling` and must point to the + /// end of the first `element` from the `data part` of the table, i.e. + /// must be a pointer that returns by [`RawTable::data_end`] or by + /// [`RawTableInner::data_end`]; + /// + /// * `self` also must not contain dangling pointer; + /// + /// * both `self` and `base` must be created from the same [`RawTable`] + /// (or [`RawTableInner`]). + /// + /// If `size_of::() == 0`, this function is always safe. + #[inline] + unsafe fn to_base_index(&self, base: NonNull) -> usize { + // If size_of::() != 0 then return an index under which we used to store the + // `element` in the data part of the table (we start counting from "0", so + // that in the expression T[last], the "last" index actually is one less than the + // "buckets" number in the table, i.e. "last = RawTableInner.bucket_mask"). + // For example for 5th element in table calculation is performed like this: + // + // size_of::() + // | + // | `self = from_base_index(base, 5)` that returns pointer + // | that points here in the data part of the table + // | (to the end of T5) + // | | `base: NonNull` must point here + // v | (to the end of T0 or to the start of C0) + // /???\ v v + // [Padding], Tlast, ..., |T10|, ..., T5|, T4, T3, T2, T1, T0, |C0, C1, C2, C3, C4, C5, ..., C10, ..., Clast + // \__________ __________/ + // \/ + // `bucket.to_base_index(base)` = 5 + // (base.as_ptr() as usize - self.ptr.as_ptr() as usize) / size_of::() + // + // where: T0...Tlast - our stored data; C0...Clast - control bytes or metadata for data. + if T::IS_ZERO_SIZED { + // this can not be UB + self.ptr.as_ptr().addr() - 1 + } else { + unsafe { offset_from(base.as_ptr(), self.ptr.as_ptr()) } + } + } + + /// Acquires the underlying raw pointer `*mut T` to `data`. + /// + /// # Note + /// + /// If `T` is not [`Copy`], do not use `*mut T` methods that can cause calling the + /// destructor of `T` (for example the [`<*mut T>::drop_in_place`] method), because + /// for properly dropping the data we also need to clear `data` control bytes. If we + /// drop data, but do not clear `data control byte` it leads to double drop when + /// [`RawTable`] goes out of scope. + /// + /// If you modify an already initialized `value`, so [`Hash`] and [`Eq`] on the new + /// `T` value and its borrowed form *must* match those for the old `T` value, as the map + /// will not re-evaluate where the new value should go, meaning the value may become + /// "lost" if their location does not reflect their state. + #[inline] + pub(crate) fn as_ptr(&self) -> *mut T { + if T::IS_ZERO_SIZED { + // Just return an arbitrary ZST pointer which is properly aligned + // invalid pointer is good enough for ZST + ptr::without_provenance_mut(align_of::()) + } else { + unsafe { self.ptr.as_ptr().sub(1) } + } + } + + /// Acquires the underlying non-null pointer `*mut T` to `data`. + #[inline] + fn as_non_null(&self) -> NonNull { + // SAFETY: `self.ptr` is already a `NonNull` + unsafe { NonNull::new_unchecked(self.as_ptr()) } + } + + /// Create a new [`Bucket`] that is offset from the `self` by the given + /// `offset`. The pointer calculation is performed by calculating the + /// offset from `self` pointer (convenience for `self.ptr.as_ptr().sub(offset)`). + /// This function is used for iterators. + /// + /// `offset` is in units of `T`; e.g., a `offset` of 3 represents a pointer + /// offset of `3 * size_of::()` bytes. + /// + /// # Safety + /// + /// If `size_of::() != 0`, then the safety rules are directly derived + /// from the safety rules for [`<*mut T>::sub`] method of `*mut T` and safety + /// rules of [`NonNull::new_unchecked`] function. + /// + /// Thus, in order to uphold the safety contracts for [`<*mut T>::sub`] method + /// and [`NonNull::new_unchecked`] function, as well as for the correct + /// logic of the work of this crate, the following rules are necessary and + /// sufficient: + /// + /// * `self` contained pointer must not be `dangling`; + /// + /// * `self.to_base_index() + offset` must not be greater than `RawTableInner.bucket_mask`, + /// i.e. `(self.to_base_index() + offset) <= RawTableInner.bucket_mask` or, in other + /// words, `self.to_base_index() + offset + 1` must be no greater than the number returned + /// by the function [`RawTable::num_buckets`] or [`RawTableInner::num_buckets`]. + /// + /// If `size_of::() == 0`, then the only requirement is that the + /// `self.to_base_index() + offset` must not be greater than `RawTableInner.bucket_mask`, + /// i.e. `(self.to_base_index() + offset) <= RawTableInner.bucket_mask` or, in other words, + /// `self.to_base_index() + offset + 1` must be no greater than the number returned by the + /// function [`RawTable::num_buckets`] or [`RawTableInner::num_buckets`]. + #[inline] + unsafe fn next_n(&self, offset: usize) -> Self { + let ptr = if T::IS_ZERO_SIZED { + // invalid pointer is good enough for ZST + ptr::without_provenance_mut(self.ptr.as_ptr().addr() + offset) + } else { + unsafe { self.ptr.as_ptr().sub(offset) } + }; + Self { + ptr: unsafe { NonNull::new_unchecked(ptr) }, + } + } + + /// Executes the destructor (if any) of the pointed-to `data`. + /// + /// # Safety + /// + /// See [`ptr::drop_in_place`] for safety concerns. + /// + /// You should use [`RawTable::erase`] instead of this function, + /// or be careful with calling this function directly, because for + /// properly dropping the data we need also clear `data` control bytes. + /// If we drop data, but do not erase `data control byte` it leads to + /// double drop when [`RawTable`] goes out of scope. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn drop(&self) { + unsafe { + self.as_ptr().drop_in_place(); + } + } + + /// Reads the `value` from `self` without moving it. This leaves the + /// memory in `self` unchanged. + /// + /// # Safety + /// + /// See [`ptr::read`] for safety concerns. + /// + /// You should use [`RawTable::remove`] instead of this function, + /// or be careful with calling this function directly, because compiler + /// calls its destructor when the read `value` goes out of scope. It + /// can cause double dropping when [`RawTable`] goes out of scope, + /// because of not erased `data control byte`. + #[inline] + pub(crate) unsafe fn read(&self) -> T { + unsafe { self.as_ptr().read() } + } + + /// Overwrites a memory location with the given `value` without reading + /// or dropping the old value (like [`ptr::write`] function). + /// + /// # Safety + /// + /// See [`ptr::write`] for safety concerns. + /// + /// # Note + /// + /// [`Hash`] and [`Eq`] on the new `T` value and its borrowed form *must* match + /// those for the old `T` value, as the map will not re-evaluate where the new + /// value should go, meaning the value may become "lost" if their location + /// does not reflect their state. + #[inline] + pub(crate) unsafe fn write(&self, val: T) { + unsafe { + self.as_ptr().write(val); + } + } + + /// Returns a shared immutable reference to the `value`. + /// + /// # Safety + /// + /// See [`NonNull::as_ref`] for safety concerns. + #[inline] + pub(crate) unsafe fn as_ref<'a>(&self) -> &'a T { + unsafe { &*self.as_ptr() } + } + + /// Returns a unique mutable reference to the `value`. + /// + /// # Safety + /// + /// See [`NonNull::as_mut`] for safety concerns. + /// + /// # Note + /// + /// [`Hash`] and [`Eq`] on the new `T` value and its borrowed form *must* match + /// those for the old `T` value, as the map will not re-evaluate where the new + /// value should go, meaning the value may become "lost" if their location + /// does not reflect their state. + #[inline] + pub(crate) unsafe fn as_mut<'a>(&self) -> &'a mut T { + unsafe { &mut *self.as_ptr() } + } +} + +/// A raw hash table with an unsafe API. +pub(crate) struct RawTable { + table: RawTableInner, + alloc: A, + // Tell dropck that we own instances of T. + marker: PhantomData, +} + +/// Non-generic part of `RawTable` which allows functions to be instantiated only once regardless +/// of how many different key-value types are used. +struct RawTableInner { + // Mask to get an index from a hash value. The value is one less than the + // number of buckets in the table. + bucket_mask: usize, + + // [Padding], T_n, ..., T1, T0, C0, C1, ... + // ^ points here + ctrl: NonNull, + + // Number of elements that can be inserted before we need to grow the table + growth_left: usize, + + // Number of elements in the table, only really used by len() + items: usize, +} + +impl RawTable { + /// Creates a new empty hash table without allocating any memory. + /// + /// In effect this returns a table with exactly 1 bucket. However we can + /// leave the data pointer dangling since that bucket is never written to + /// due to our load factor forcing us to always have at least 1 free bucket. + #[inline] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub(crate) const fn new() -> Self { + Self { + table: RawTableInner::NEW, + alloc: Global, + marker: PhantomData, + } + } + + /// Allocates a new hash table with at least enough capacity for inserting + /// the given number of elements without reallocating. + pub(crate) fn with_capacity(capacity: usize) -> Self { + Self::with_capacity_in(capacity, Global) + } +} + +impl RawTable { + const TABLE_LAYOUT: TableLayout = TableLayout::new::(); + + /// Creates a new empty hash table without allocating any memory, using the + /// given allocator. + /// + /// In effect this returns a table with exactly 1 bucket. However we can + /// leave the data pointer dangling since that bucket is never written to + /// due to our load factor forcing us to always have at least 1 free bucket. + #[inline] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub(crate) const fn new_in(alloc: A) -> Self { + Self { + table: RawTableInner::NEW, + alloc, + marker: PhantomData, + } + } + + /// Allocates a new hash table with the given number of buckets. + /// + /// The control bytes are left uninitialized. + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn new_uninitialized( + alloc: A, + buckets: usize, + fallibility: Fallibility, + ) -> Result { + debug_assert!(buckets.is_power_of_two()); + + Ok(Self { + table: unsafe { + RawTableInner::new_uninitialized(&alloc, Self::TABLE_LAYOUT, buckets, fallibility) + }?, + alloc, + marker: PhantomData, + }) + } + + /// Allocates a new hash table using the given allocator, with at least enough capacity for + /// inserting the given number of elements without reallocating. + pub(crate) fn with_capacity_in(capacity: usize, alloc: A) -> Self { + Self { + table: RawTableInner::with_capacity(&alloc, Self::TABLE_LAYOUT, capacity), + alloc, + marker: PhantomData, + } + } + + /// Returns a reference to the underlying allocator. + #[inline] + pub(crate) fn allocator(&self) -> &A { + &self.alloc + } + + /// Returns pointer to one past last `data` element in the table as viewed from + /// the start point of the allocation. + /// + /// The caller must ensure that the `RawTable` outlives the returned [`NonNull`], + /// otherwise using it may result in [`undefined behavior`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + pub(crate) fn data_end(&self) -> NonNull { + // `self.table.ctrl.cast()` returns pointer that + // points here (to the end of `T0`) + // ∨ + // [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, CTa_0, CTa_1, ..., CTa_m + // \________ ________/ + // \/ + // `n = buckets - 1`, i.e. `RawTable::num_buckets() - 1` + // + // where: T0...T_n - our stored data; + // CT0...CT_n - control bytes or metadata for `data`. + // CTa_0...CTa_m - additional control bytes, where `m = Group::WIDTH - 1` (so that the search + // with loading `Group` bytes from the heap works properly, even if the result + // of `h1(hash) & self.bucket_mask` is equal to `self.bucket_mask`). See also + // `RawTableInner::set_ctrl` function. + // + // P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + // of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + self.table.ctrl.cast() + } + + /// Returns pointer to start of data table. + #[inline] + #[cfg(feature = "nightly")] + pub(crate) unsafe fn data_start(&self) -> NonNull { + unsafe { NonNull::new_unchecked(self.data_end().as_ptr().wrapping_sub(self.num_buckets())) } + } + + /// Returns the total amount of memory allocated internally by the hash + /// table, in bytes. + /// + /// The returned number is informational only. It is intended to be + /// primarily used for memory profiling. + #[inline] + pub(crate) fn allocation_size(&self) -> usize { + // SAFETY: We use the same `table_layout` that was used to allocate + // this table. + unsafe { self.table.allocation_size_or_zero(Self::TABLE_LAYOUT) } + } + + /// Returns the index of a bucket from a `Bucket`. + #[inline] + pub(crate) unsafe fn bucket_index(&self, bucket: &Bucket) -> usize { + unsafe { bucket.to_base_index(self.data_end()) } + } + + /// Returns a pointer to an element in the table. + /// + /// The caller must ensure that the `RawTable` outlives the returned [`Bucket`], + /// otherwise using it may result in [`undefined behavior`]. + /// + /// # Safety + /// + /// If `size_of::() != 0`, then the caller of this function must observe the + /// following safety rules: + /// + /// * The table must already be allocated; + /// + /// * The `index` must not be greater than the number returned by the [`RawTable::num_buckets`] + /// function, i.e. `(index + 1) <= self.num_buckets()`. + /// + /// It is safe to call this function with index of zero (`index == 0`) on a table that has + /// not been allocated, but using the returned [`Bucket`] results in [`undefined behavior`]. + /// + /// If `size_of::() == 0`, then the only requirement is that the `index` must + /// not be greater than the number returned by the [`RawTable::num_buckets`] function, i.e. + /// `(index + 1) <= self.num_buckets()`. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + pub(crate) unsafe fn bucket(&self, index: usize) -> Bucket { + // If size_of::() != 0 then return a pointer to the `element` in the `data part` of the table + // (we start counting from "0", so that in the expression T[n], the "n" index actually one less than + // the "buckets" number of our `RawTable`, i.e. "n = RawTable::num_buckets() - 1"): + // + // `table.bucket(3).as_ptr()` returns a pointer that points here in the `data` + // part of the `RawTable`, i.e. to the start of T3 (see `Bucket::as_ptr`) + // | + // | `base = self.data_end()` points here + // | (to the start of CT0 or to the end of T0) + // v v + // [Pad], T_n, ..., |T3|, T2, T1, T0, |CT0, CT1, CT2, CT3, ..., CT_n, CTa_0, CTa_1, ..., CTa_m + // ^ \__________ __________/ + // `table.bucket(3)` returns a pointer that points \/ + // here in the `data` part of the `RawTable` (to additional control bytes + // the end of T3) `m = Group::WIDTH - 1` + // + // where: T0...T_n - our stored data; + // CT0...CT_n - control bytes or metadata for `data`; + // CTa_0...CTa_m - additional control bytes (so that the search with loading `Group` bytes from + // the heap works properly, even if the result of `h1(hash) & self.table.bucket_mask` + // is equal to `self.table.bucket_mask`). See also `RawTableInner::set_ctrl` function. + // + // P.S. `h1(hash) & self.table.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + // of buckets is a power of two, and `self.table.bucket_mask = self.num_buckets() - 1`. + debug_assert_ne!(self.table.bucket_mask, 0); + debug_assert!(index < self.num_buckets()); + unsafe { Bucket::from_base_index(self.data_end(), index) } + } + + /// Erases an element from the table without dropping it. + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn erase_no_drop(&mut self, item: &Bucket) { + unsafe { + let index = self.bucket_index(item); + self.table.erase(index); + } + } + + /// Erases an element from the table, dropping it in place. + #[cfg_attr(feature = "inline-more", inline)] + #[expect(clippy::needless_pass_by_value)] + pub(crate) unsafe fn erase(&mut self, item: Bucket) { + unsafe { + // Erase the element from the table first since drop might panic. + self.erase_no_drop(&item); + item.drop(); + } + } + + /// Removes an element from the table, returning it. + /// + /// This also returns an index to the newly free bucket. + #[cfg_attr(feature = "inline-more", inline)] + #[expect(clippy::needless_pass_by_value)] + pub(crate) unsafe fn remove(&mut self, item: Bucket) -> (T, usize) { + unsafe { + self.erase_no_drop(&item); + (item.read(), self.bucket_index(&item)) + } + } + + /// Removes an element from the table, returning it. + /// + /// This also returns an index to the newly free bucket + /// and the former `Tag` for that bucket. + #[cfg_attr(feature = "inline-more", inline)] + #[expect(clippy::needless_pass_by_value)] + pub(crate) unsafe fn remove_tagged(&mut self, item: Bucket) -> (T, usize, Tag) { + unsafe { + let index = self.bucket_index(&item); + let tag = *self.table.ctrl(index); + self.table.erase(index); + (item.read(), index, tag) + } + } + + /// Finds and removes an element from the table, returning it. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn remove_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.find(hash, eq) { + Some(bucket) => Some(unsafe { self.remove(bucket).0 }), + None => None, + } + } + + /// Marks all table buckets as empty without dropping their contents. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn clear_no_drop(&mut self) { + self.table.clear_no_drop(); + } + + /// Removes all elements from the table without freeing the backing memory. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn clear(&mut self) { + if self.is_empty() { + // Special case empty table to avoid surprising O(capacity) time. + return; + } + // Ensure that the table is reset even if one of the drops panic + let mut self_ = guard(self, |self_| self_.clear_no_drop()); + unsafe { + // SAFETY: ScopeGuard sets to zero the `items` field of the table + // even in case of panic during the dropping of the elements so + // that there will be no double drop of the elements. + self_.table.drop_elements::(); + } + } + + /// Shrinks the table to fit `max(self.len(), min_size)` elements. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn shrink_to(&mut self, min_size: usize, hasher: impl Fn(&T) -> u64) { + // Calculate the minimal number of elements that we need to reserve + // space for. + let min_size = usize::max(self.table.items, min_size); + if min_size == 0 { + let mut old_inner = mem::replace(&mut self.table, RawTableInner::NEW); + unsafe { + // SAFETY: + // 1. We call the function only once; + // 2. We know for sure that `alloc` and `table_layout` matches the [`Allocator`] + // and [`TableLayout`] that were used to allocate this table. + // 3. If any elements' drop function panics, then there will only be a memory leak, + // because we have replaced the inner table with a new one. + old_inner.drop_inner_table::(&self.alloc, Self::TABLE_LAYOUT); + } + return; + } + + // Calculate the number of buckets that we need for this number of + // elements. If the calculation overflows then the requested bucket + // count must be larger than what we have right and nothing needs to be + // done. + let Some(min_buckets) = capacity_to_buckets(min_size, Self::TABLE_LAYOUT) else { + return; + }; + + // If we have more buckets than we need, shrink the table. + if min_buckets < self.num_buckets() { + // Fast path if the table is empty + if self.table.items == 0 { + let new_inner = + RawTableInner::with_capacity(&self.alloc, Self::TABLE_LAYOUT, min_size); + let mut old_inner = mem::replace(&mut self.table, new_inner); + unsafe { + // SAFETY: + // 1. We call the function only once; + // 2. We know for sure that `alloc` and `table_layout` matches the [`Allocator`] + // and [`TableLayout`] that were used to allocate this table. + // 3. If any elements' drop function panics, then there will only be a memory leak, + // because we have replaced the inner table with a new one. + old_inner.drop_inner_table::(&self.alloc, Self::TABLE_LAYOUT); + } + } else { + // SAFETY: + // 1. We know for sure that `min_size >= self.table.items`. + // 2. The [`RawTableInner`] must already have properly initialized control bytes since + // we will never expose RawTable::new_uninitialized in a public API. + let result = unsafe { self.resize(min_size, hasher, Fallibility::Infallible) }; + + // SAFETY: The result of calling the `resize` function cannot be an error + // because `fallibility == Fallibility::Infallible. + unsafe { result.unwrap_unchecked() }; + } + } + } + + /// Ensures that at least `additional` items can be inserted into the table + /// without reallocation. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64) { + if unlikely(additional > self.table.growth_left) { + // SAFETY: The [`RawTableInner`] must already have properly initialized control + // bytes since we will never expose RawTable::new_uninitialized in a public API. + let result = + unsafe { self.reserve_rehash(additional, hasher, Fallibility::Infallible) }; + + // SAFETY: All allocation errors will be caught inside `RawTableInner::reserve_rehash`. + unsafe { result.unwrap_unchecked() }; + } + } + + /// Tries to ensure that at least `additional` items can be inserted into + /// the table without reallocation. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn try_reserve( + &mut self, + additional: usize, + hasher: impl Fn(&T) -> u64, + ) -> Result<(), TryReserveError> { + if additional > self.table.growth_left { + // SAFETY: The [`RawTableInner`] must already have properly initialized control + // bytes since we will never expose RawTable::new_uninitialized in a public API. + unsafe { self.reserve_rehash(additional, hasher, Fallibility::Fallible) } + } else { + Ok(()) + } + } + + /// Out-of-line slow path for `reserve` and `try_reserve`. + /// + /// # Safety + /// + /// The [`RawTableInner`] must have properly initialized control bytes, + /// otherwise calling this function results in [`undefined behavior`] + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[cold] + #[inline(never)] + unsafe fn reserve_rehash( + &mut self, + additional: usize, + hasher: impl Fn(&T) -> u64, + fallibility: Fallibility, + ) -> Result<(), TryReserveError> { + unsafe { + // SAFETY: + // 1. We know for sure that `alloc` and `layout` matches the [`Allocator`] and + // [`TableLayout`] that were used to allocate this table. + // 2. The `drop` function is the actual drop function of the elements stored in + // the table. + // 3. The caller ensures that the control bytes of the `RawTableInner` + // are already initialized. + self.table.reserve_rehash_inner( + &self.alloc, + additional, + &|table, index| hasher(table.bucket::(index).as_ref()), + fallibility, + Self::TABLE_LAYOUT, + if T::NEEDS_DROP { + Some(|ptr| ptr::drop_in_place(ptr.cast::())) + } else { + None + }, + ) + } + } + + /// Allocates a new table of a different size and moves the contents of the + /// current table into it. + /// + /// # Safety + /// + /// The [`RawTableInner`] must have properly initialized control bytes, + /// otherwise calling this function results in [`undefined behavior`] + /// + /// The caller of this function must ensure that `capacity >= self.table.items` + /// otherwise: + /// + /// * If `self.table.items != 0`, calling of this function with `capacity` + /// equal to 0 (`capacity == 0`) results in [`undefined behavior`]. + /// + /// * If `self.table.items > capacity_to_buckets(capacity, Self::TABLE_LAYOUT)` + /// calling this function are never return (will loop infinitely). + /// + /// See [`RawTableInner::find_insert_index`] for more information. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + unsafe fn resize( + &mut self, + capacity: usize, + hasher: impl Fn(&T) -> u64, + fallibility: Fallibility, + ) -> Result<(), TryReserveError> { + // SAFETY: + // 1. The caller of this function guarantees that `capacity >= self.table.items`. + // 2. We know for sure that `alloc` and `layout` matches the [`Allocator`] and + // [`TableLayout`] that were used to allocate this table. + // 3. The caller ensures that the control bytes of the `RawTableInner` + // are already initialized. + unsafe { + self.table.resize_inner( + &self.alloc, + capacity, + &|table, index| hasher(table.bucket::(index).as_ref()), + fallibility, + Self::TABLE_LAYOUT, + ) + } + } + + /// Inserts a new element into the table, and returns its raw bucket. + /// + /// This does not check if the given element already exists in the table. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn insert(&mut self, hash: u64, value: T, hasher: impl Fn(&T) -> u64) -> Bucket { + unsafe { + // SAFETY: + // 1. The [`RawTableInner`] must already have properly initialized control bytes since + // we will never expose `RawTable::new_uninitialized` in a public API. + // + // 2. We reserve additional space (if necessary) right after calling this function. + let mut index = self.table.find_insert_index(hash); + + // We can avoid growing the table once we have reached our load factor if we are replacing + // a tombstone. This works since the number of EMPTY slots does not change in this case. + // + // SAFETY: The function is guaranteed to return an index in the range `0..=self.num_buckets()`. + let old_ctrl = *self.table.ctrl(index); + if unlikely(self.table.growth_left == 0 && old_ctrl.special_is_empty()) { + self.reserve(1, hasher); + // SAFETY: We know for sure that `RawTableInner` has control bytes + // initialized and that there is extra space in the table. + index = self.table.find_insert_index(hash); + } + + self.insert_at_index(hash, index, value) + } + } + + /// Inserts a new element into the table, and returns a mutable reference to it. + /// + /// This does not check if the given element already exists in the table. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn insert_entry( + &mut self, + hash: u64, + value: T, + hasher: impl Fn(&T) -> u64, + ) -> &mut T { + unsafe { self.insert(hash, value, hasher).as_mut() } + } + + /// Inserts a new element into the table, without growing the table. + /// + /// There must be enough space in the table to insert the new element. + /// + /// This does not check if the given element already exists in the table. + #[cfg_attr(feature = "inline-more", inline)] + #[cfg(feature = "rustc-internal-api")] + pub(crate) unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket { + unsafe { + let (index, old_ctrl) = self.table.prepare_insert_index(hash); + let bucket = self.table.bucket(index); + + // If we are replacing a DELETED entry then we don't need to update + // the load counter. + self.table.growth_left -= old_ctrl.special_is_empty() as usize; + + bucket.write(value); + self.table.items += 1; + bucket + } + } + + /// Temporarily removes a bucket, applying the given function to the removed + /// element and optionally put back the returned value in the same bucket. + /// + /// Returns tag for bucket if the bucket is emptied out. + /// + /// This does not check if the given bucket is actually occupied. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn replace_bucket_with(&mut self, bucket: Bucket, f: F) -> Option + where + F: FnOnce(T) -> Option, + { + unsafe { + let index = self.bucket_index(&bucket); + let old_ctrl = *self.table.ctrl(index); + debug_assert!(self.is_bucket_full(index)); + let old_growth_left = self.table.growth_left; + let item = self.remove(bucket).0; + if let Some(new_item) = f(item) { + self.table.growth_left = old_growth_left; + self.table.set_ctrl(index, old_ctrl); + self.table.items += 1; + self.bucket(index).write(new_item); + None + } else { + Some(old_ctrl) + } + } + } + + /// Searches for an element in the table. If the element is not found, + /// returns `Err` with the position of a slot where an element with the + /// same hash could be inserted. + /// + /// This function may resize the table if additional space is required for + /// inserting an element. + #[inline] + pub(crate) fn find_or_find_insert_index( + &mut self, + hash: u64, + mut eq: impl FnMut(&T) -> bool, + hasher: impl Fn(&T) -> u64, + ) -> Result, usize> { + self.reserve(1, hasher); + + unsafe { + // SAFETY: + // 1. We know for sure that there is at least one empty `bucket` in the table. + // 2. The [`RawTableInner`] must already have properly initialized control bytes since we will + // never expose `RawTable::new_uninitialized` in a public API. + // 3. The `find_or_find_insert_index_inner` function returns the `index` of only the full bucket, + // which is in the range `0..self.num_buckets()` (since there is at least one empty `bucket` in + // the table), so calling `self.bucket(index)` and `Bucket::as_ref` is safe. + match self + .table + .find_or_find_insert_index_inner(hash, &mut |index| eq(self.bucket(index).as_ref())) + { + // SAFETY: See explanation above. + Ok(index) => Ok(self.bucket(index)), + Err(index) => Err(index), + } + } + } + + /// Inserts a new element into the table at the given index with the given hash, + /// and returns its raw bucket. + /// + /// # Safety + /// + /// `index` must point to a slot previously returned by + /// `find_or_find_insert_index`, and no mutation of the table must have + /// occurred since that call. + #[inline] + pub(crate) unsafe fn insert_at_index( + &mut self, + hash: u64, + index: usize, + value: T, + ) -> Bucket { + unsafe { self.insert_tagged_at_index(Tag::full(hash), index, value) } + } + + /// Inserts a new element into the table at the given index with the given tag, + /// and returns its raw bucket. + /// + /// # Safety + /// + /// `index` must point to a slot previously returned by + /// `find_or_find_insert_index`, and no mutation of the table must have + /// occurred since that call. + #[inline] + pub(crate) unsafe fn insert_tagged_at_index( + &mut self, + tag: Tag, + index: usize, + value: T, + ) -> Bucket { + unsafe { + let old_ctrl = *self.table.ctrl(index); + self.table.record_item_insert_at(index, old_ctrl, tag); + + let bucket = self.bucket(index); + bucket.write(value); + bucket + } + } + + /// Searches for an element in the table. + #[inline] + pub(crate) fn find(&self, hash: u64, mut eq: impl FnMut(&T) -> bool) -> Option> { + unsafe { + // SAFETY: + // 1. The [`RawTableInner`] must already have properly initialized control bytes since we + // will never expose `RawTable::new_uninitialized` in a public API. + // 1. The `find_inner` function returns the `index` of only the full bucket, which is in + // the range `0..self.num_buckets()`, so calling `self.bucket(index)` and `Bucket::as_ref` + // is safe. + let result = self + .table + .find_inner(hash, &mut |index| eq(self.bucket(index).as_ref())); + + // Avoid `Option::map` because it bloats LLVM IR. + match result { + // SAFETY: See explanation above. + Some(index) => Some(self.bucket(index)), + None => None, + } + } + } + + /// Gets a reference to an element in the table. + #[inline] + pub(crate) fn get(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.find(hash, eq) { + Some(bucket) => Some(unsafe { bucket.as_ref() }), + None => None, + } + } + + /// Gets a mutable reference to an element in the table. + #[inline] + pub(crate) fn get_mut(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&mut T> { + // Avoid `Option::map` because it bloats LLVM IR. + match self.find(hash, eq) { + Some(bucket) => Some(unsafe { bucket.as_mut() }), + None => None, + } + } + + /// Gets a reference to an element in the table at the given bucket index. + #[inline] + pub(crate) fn get_bucket(&self, index: usize) -> Option<&T> { + unsafe { + if index < self.num_buckets() && self.is_bucket_full(index) { + Some(self.bucket(index).as_ref()) + } else { + None + } + } + } + + /// Gets a mutable reference to an element in the table at the given bucket index. + #[inline] + pub(crate) fn get_bucket_mut(&mut self, index: usize) -> Option<&mut T> { + unsafe { + if index < self.num_buckets() && self.is_bucket_full(index) { + Some(self.bucket(index).as_mut()) + } else { + None + } + } + } + + /// Returns a pointer to an element in the table, but only after verifying that + /// the index is in-bounds and the bucket is occupied. + #[inline] + pub(crate) fn checked_bucket(&self, index: usize) -> Option> { + unsafe { + if index < self.num_buckets() && self.is_bucket_full(index) { + Some(self.bucket(index)) + } else { + None + } + } + } + + /// Attempts to get mutable references to `N` entries in the table at once. + /// + /// Returns an array of length `N` with the results of each query. + /// + /// At most one mutable reference will be returned to any entry. `None` will be returned if any + /// of the hashes are duplicates. `None` will be returned if the hash is not found. + /// + /// The `eq` argument should be a closure such that `eq(i, k)` returns true if `k` is equal to + /// the `i`th key to be looked up. + pub(crate) fn get_disjoint_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + unsafe { + let ptrs = self.get_disjoint_mut_pointers(hashes, eq); + + for (i, cur) in ptrs.iter().enumerate() { + assert!( + !(cur.is_some() && ptrs[..i].contains(cur)), + "duplicate keys found" + ); + } + // All bucket are distinct from all previous buckets so we're clear to return the result + // of the lookup. + + ptrs.map(|ptr| ptr.map(|mut ptr| ptr.as_mut())) + } + } + + pub(crate) unsafe fn get_disjoint_unchecked_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + let ptrs = unsafe { self.get_disjoint_mut_pointers(hashes, eq) }; + ptrs.map(|ptr| ptr.map(|mut ptr| unsafe { ptr.as_mut() })) + } + + unsafe fn get_disjoint_mut_pointers( + &mut self, + hashes: [u64; N], + mut eq: impl FnMut(usize, &T) -> bool, + ) -> [Option>; N] { + array::from_fn(|i| { + self.find(hashes[i], |k| eq(i, k)) + .map(|cur| cur.as_non_null()) + }) + } + + /// Returns the number of elements the map can hold without reallocating. + /// + /// This number is a lower bound; the table might be able to hold + /// more, but is guaranteed to be able to hold at least this many. + #[inline] + pub(crate) fn capacity(&self) -> usize { + self.table.items + self.table.growth_left + } + + /// Returns the number of elements in the table. + #[inline] + pub(crate) fn len(&self) -> usize { + self.table.items + } + + /// Returns `true` if the table contains no elements. + #[inline] + pub(crate) fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the number of buckets in the table. + #[inline] + pub(crate) fn num_buckets(&self) -> usize { + self.table.bucket_mask + 1 + } + + /// Checks whether the bucket at `index` is full. + /// + /// # Safety + /// + /// The caller must ensure `index` is less than the number of buckets. + #[inline] + pub(crate) unsafe fn is_bucket_full(&self, index: usize) -> bool { + unsafe { self.table.is_bucket_full(index) } + } + + /// Returns an iterator over every element in the table. It is up to + /// the caller to ensure that the `RawTable` outlives the `RawIter`. + /// Because we cannot make the `next` method unsafe on the `RawIter` + /// struct, we have to make the `iter` method unsafe. + #[inline] + pub(crate) unsafe fn iter(&self) -> RawIter { + // SAFETY: + // 1. The caller must uphold the safety contract for `iter` method. + // 2. The [`RawTableInner`] must already have properly initialized control bytes since + // we will never expose RawTable::new_uninitialized in a public API. + unsafe { self.table.iter() } + } + + /// Returns an iterator over occupied buckets that could match a given hash. + /// + /// `RawTable` only stores 7 bits of the hash value, so this iterator may + /// return items that have a hash value different than the one provided. You + /// should always validate the returned values before using them. + /// + /// It is up to the caller to ensure that the `RawTable` outlives the + /// `RawIterHash`. Because we cannot make the `next` method unsafe on the + /// `RawIterHash` struct, we have to make the `iter_hash` method unsafe. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn iter_hash(&self, hash: u64) -> RawIterHash { + unsafe { RawIterHash::new(self, hash) } + } + + /// Returns an iterator over occupied bucket indices that could match a given hash. + /// + /// `RawTable` only stores 7 bits of the hash value, so this iterator may + /// return items that have a hash value different than the one provided. You + /// should always validate the returned values before using them. + /// + /// It is up to the caller to ensure that the `RawTable` outlives the + /// `RawIterHashIndices`. Because we cannot make the `next` method unsafe on the + /// `RawIterHashIndices` struct, we have to make the `iter_hash_buckets` method unsafe. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn iter_hash_buckets(&self, hash: u64) -> RawIterHashIndices { + unsafe { RawIterHashIndices::new(&self.table, hash) } + } + + /// Returns an iterator over full buckets indices in the table. + /// + /// See [`RawTableInner::full_buckets_indices`] for safety conditions. + #[inline(always)] + pub(crate) unsafe fn full_buckets_indices(&self) -> FullBucketsIndices { + unsafe { self.table.full_buckets_indices() } + } + + /// Returns an iterator which removes all elements from the table without + /// freeing the memory. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn drain(&mut self) -> RawDrain<'_, T, A> { + unsafe { + let iter = self.iter(); + self.drain_iter_from(iter) + } + } + + /// Returns an iterator which removes all elements from the table without + /// freeing the memory. + /// + /// Iteration starts at the provided iterator's current location. + /// + /// It is up to the caller to ensure that the iterator is valid for this + /// `RawTable` and covers all items that remain in the table. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) unsafe fn drain_iter_from(&mut self, iter: RawIter) -> RawDrain<'_, T, A> { + debug_assert_eq!(iter.len(), self.len()); + RawDrain { + iter, + table: mem::replace(&mut self.table, RawTableInner::NEW), + orig_table: NonNull::from(&mut self.table), + marker: PhantomData, + } + } + + /// Returns an iterator which consumes all elements from the table. + /// + /// Iteration starts at the provided iterator's current location. + /// + /// It is up to the caller to ensure that the iterator is valid for this + /// `RawTable` and covers all items that remain in the table. + pub(crate) unsafe fn into_iter_from(self, iter: RawIter) -> RawIntoIter { + debug_assert_eq!(iter.len(), self.len()); + + let allocation = self.into_allocation(); + RawIntoIter { + iter, + allocation, + marker: PhantomData, + } + } + + /// Converts the table into a raw allocation. The contents of the table + /// should be dropped using a `RawIter` before freeing the allocation. + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn into_allocation(self) -> Option<(NonNull, Layout, A)> { + let this = ManuallyDrop::new(self); + // SAFETY: `this` is never dropped, so ownership of the allocator is + // moved out exactly once. If the table never allocated, the allocator + // is dropped here rather than being leaked. + let alloc = unsafe { ptr::read(&raw const this.alloc) }; + if this.table.is_empty_singleton() { + None + } else { + let (layout, ctrl_offset) = { + let option = Self::TABLE_LAYOUT.calculate_layout_for(this.table.num_buckets()); + unsafe { option.unwrap_unchecked() } + }; + Some(( + unsafe { NonNull::new_unchecked(this.table.ctrl.as_ptr().sub(ctrl_offset).cast()) }, + layout, + alloc, + )) + } + } +} + +unsafe impl Send for RawTable +where + T: Send, + A: Send, +{ +} +unsafe impl Sync for RawTable +where + T: Sync, + A: Sync, +{ +} + +impl RawTableInner { + const NEW: Self = RawTableInner::new(); + + /// Creates a new empty hash table without allocating any memory. + /// + /// In effect this returns a table with exactly 1 bucket. However we can + /// leave the data pointer dangling since that bucket is never accessed + /// due to our load factor forcing us to always have at least 1 free bucket. + #[inline] + const fn new() -> Self { + Self { + // Be careful to cast the entire slice to a raw pointer. + ctrl: unsafe { + NonNull::new_unchecked(Group::static_empty().as_ptr().cast_mut().cast()) + }, + bucket_mask: 0, + items: 0, + growth_left: 0, + } + } +} + +/// Find the previous power of 2. If it's already a power of 2, it's unchanged. +/// Passing zero is undefined behavior. +pub(crate) fn prev_pow2(z: usize) -> usize { + let shift = usize::BITS as usize - 1; + 1 << (shift - (z.leading_zeros() as usize)) +} + +/// Finds the largest number of buckets that can fit in `allocation_size` +/// provided the given TableLayout. +/// +/// This relies on some invariants of `capacity_to_buckets`, so only feed in +/// an `allocation_size` calculated from `capacity_to_buckets`. +fn maximum_buckets_in( + allocation_size: usize, + table_layout: TableLayout, + group_width: usize, +) -> usize { + // Given an equation like: + // z >= x * y + x + g + // x can be maximized by doing: + // x = (z - g) / (y + 1) + // If you squint: + // x is the number of buckets + // y is the table_layout.size + // z is the size of the allocation + // g is the group width + // But this is ignoring the padding needed for ctrl_align. + // If we remember these restrictions: + // x is always a power of 2 + // Layout size for T must always be a multiple of T + // Then the alignment can be ignored if we add the constraint: + // x * y >= table_layout.ctrl_align + // This is taken care of by `capacity_to_buckets`. + // It may be helpful to understand this if you remember that: + // ctrl_offset = align(x * y, ctrl_align) + let x = (allocation_size - group_width) / (table_layout.size + 1); + prev_pow2(x) +} + +impl RawTableInner { + /// Allocates a new [`RawTableInner`] with the given number of buckets. + /// The control bytes and buckets are left uninitialized. + /// + /// # Safety + /// + /// The caller of this function must ensure that the `buckets` is power of two + /// and also initialize all control bytes of the length `self.bucket_mask + 1 + + /// Group::WIDTH` with the [`Tag::EMPTY`] bytes. + /// + /// See also [`Allocator`] API for other safety concerns. + /// + /// [`Allocator`]: stdalloc::alloc::Allocator + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn new_uninitialized( + alloc: &A, + table_layout: TableLayout, + mut buckets: usize, + fallibility: Fallibility, + ) -> Result + where + A: Allocator, + { + debug_assert!(buckets.is_power_of_two()); + + // Avoid `Option::ok_or_else` because it bloats LLVM IR. + let Some((layout, mut ctrl_offset)) = table_layout.calculate_layout_for(buckets) else { + return Err(fallibility.capacity_overflow()); + }; + + let ptr: NonNull = match do_alloc(alloc, layout) { + Ok(block) => { + // The allocator can't return a value smaller than was + // requested, so this can be != instead of >=. + if block.len() != layout.size() { + // Utilize over-sized allocations. + let x = maximum_buckets_in(block.len(), table_layout, Group::WIDTH); + debug_assert!(x >= buckets); + // Calculate the new ctrl_offset. + let (oversized_layout, oversized_ctrl_offset) = { + let option = table_layout.calculate_layout_for(x); + unsafe { option.unwrap_unchecked() } + }; + debug_assert!(oversized_layout.size() <= block.len()); + debug_assert!(oversized_ctrl_offset >= ctrl_offset); + ctrl_offset = oversized_ctrl_offset; + buckets = x; + } + + block.cast() + } + Err(_) => return Err(fallibility.alloc_err(layout)), + }; + + // SAFETY: null pointer will be caught in above check + let ctrl = unsafe { NonNull::new_unchecked(ptr.as_ptr().add(ctrl_offset)) }; + Ok(Self { + ctrl, + bucket_mask: buckets - 1, + items: 0, + growth_left: bucket_mask_to_capacity(buckets - 1), + }) + } + + /// Attempts to allocate a new [`RawTableInner`] with at least enough + /// capacity for inserting the given number of elements without reallocating. + /// + /// All the control bytes are initialized with the [`Tag::EMPTY`] bytes. + #[inline] + fn fallible_with_capacity( + alloc: &A, + table_layout: TableLayout, + capacity: usize, + fallibility: Fallibility, + ) -> Result + where + A: Allocator, + { + if capacity == 0 { + Ok(Self::NEW) + } else { + // SAFETY: We checked that we could successfully allocate the new table, and then + // initialized all control bytes with the constant `Tag::EMPTY` byte. + unsafe { + let buckets = capacity_to_buckets(capacity, table_layout) + .ok_or_else(|| fallibility.capacity_overflow())?; + + let mut result = + Self::new_uninitialized(alloc, table_layout, buckets, fallibility)?; + // SAFETY: We checked that the table is allocated and therefore the table already has + // `self.bucket_mask + 1 + Group::WIDTH` number of control bytes (see TableLayout::calculate_layout_for) + // so writing `self.num_ctrl_bytes() == bucket_mask + 1 + Group::WIDTH` bytes is safe. + result.ctrl_slice().fill_empty(); + + Ok(result) + } + } + } + + /// Allocates a new [`RawTableInner`] with at least enough capacity for inserting + /// the given number of elements without reallocating. + /// + /// Panics if the new capacity exceeds [`isize::MAX`] bytes and [`abort`] the program + /// in case of allocation error. Use [`fallible_with_capacity`] instead if you want to + /// handle memory allocation failure. + /// + /// All the control bytes are initialized with the [`Tag::EMPTY`] bytes. + /// + /// [`fallible_with_capacity`]: RawTableInner::fallible_with_capacity + /// [`abort`]: stdalloc::abort::handle_alloc_error + fn with_capacity(alloc: &A, table_layout: TableLayout, capacity: usize) -> Self + where + A: Allocator, + { + let result = + Self::fallible_with_capacity(alloc, table_layout, capacity, Fallibility::Infallible); + + // SAFETY: All allocation errors will be caught inside `RawTableInner::new_uninitialized`. + unsafe { result.unwrap_unchecked() } + } + + /// Fixes up an insertion index returned by the [`RawTableInner::find_insert_index_in_group`] method. + /// + /// In tables smaller than the group width (`self.num_buckets() < Group::WIDTH`), trailing control + /// bytes outside the range of the table are filled with [`Tag::EMPTY`] entries. These will unfortunately + /// trigger a match of [`RawTableInner::find_insert_index_in_group`] function. This is because + /// the `Some(bit)` returned by `group.match_empty_or_deleted().lowest_set_bit()` after masking + /// (`(probe_seq.pos + bit) & self.bucket_mask`) may point to a full bucket that is already occupied. + /// We detect this situation here and perform a second scan starting at the beginning of the table. + /// This second scan is guaranteed to find an empty slot (due to the load factor) before hitting the + /// trailing control bytes (containing [`Tag::EMPTY`] bytes). + /// + /// If this function is called correctly, it is guaranteed to return an index of an empty or + /// deleted bucket in the range `0..self.num_buckets()` (see `Warning` and `Safety`). + /// + /// # Warning + /// + /// The table must have at least 1 empty or deleted `bucket`, otherwise if the table is less than + /// the group width (`self.num_buckets() < Group::WIDTH`) this function returns an index outside of the + /// table indices range `0..self.num_buckets()` (`0..=self.bucket_mask`). Attempt to write data at that + /// index will cause immediate [`undefined behavior`]. + /// + /// # Safety + /// + /// The safety rules are directly derived from the safety rules for [`RawTableInner::ctrl`] method. + /// Thus, in order to uphold those safety contracts, as well as for the correct logic of the work + /// of this crate, the following rules are necessary and sufficient: + /// + /// * The [`RawTableInner`] must have properly initialized control bytes otherwise calling this + /// function results in [`undefined behavior`]. + /// + /// * This function must only be used on insertion indices found by [`RawTableInner::find_insert_index_in_group`] + /// (after the `find_insert_index_in_group` function, but before insertion into the table). + /// + /// * The `index` must not be greater than the `self.bucket_mask`, i.e. `(index + 1) <= self.num_buckets()` + /// (this one is provided by the [`RawTableInner::find_insert_index_in_group`] function). + /// + /// Calling this function with an index not provided by [`RawTableInner::find_insert_index_in_group`] + /// may result in [`undefined behavior`] even if the index satisfies the safety rules of the + /// [`RawTableInner::ctrl`] function (`index < self.bucket_mask + 1 + Group::WIDTH`). + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn fix_insert_index(&self, mut index: usize) -> usize { + // SAFETY: The caller of this function ensures that `index` is in the range `0..=self.bucket_mask`. + if unlikely(unsafe { self.is_bucket_full(index) }) { + debug_assert!(self.bucket_mask < Group::WIDTH); + // SAFETY: + // + // * Since the caller of this function ensures that the control bytes are properly + // initialized and `ptr = self.ctrl(0)` points to the start of the array of control + // bytes, therefore: `ctrl` is valid for reads, properly aligned to `Group::WIDTH` + // and points to the properly initialized control bytes (see also + // `TableLayout::calculate_layout_for` and `ptr::read`); + // + // * Because the caller of this function ensures that the index was provided by the + // `self.find_insert_index_in_group()` function, so for for tables larger than the + // group width (self.num_buckets() >= Group::WIDTH), we will never end up in the given + // branch, since `(probe_seq.pos + bit) & self.bucket_mask` in `find_insert_index_in_group` + // cannot return a full bucket index. For tables smaller than the group width, calling + // the `unwrap_unchecked` function is also safe, as the trailing control bytes outside + // the range of the table are filled with EMPTY bytes (and we know for sure that there + // is at least one FULL bucket), so this second scan either finds an empty slot (due to + // the load factor) or hits the trailing control bytes (containing EMPTY). + index = unsafe { + Group::load_aligned(self.ctrl(0)) + .match_empty_or_deleted() + .lowest_set_bit() + .unwrap_unchecked() + }; + } + index + } + + /// Finds the position to insert something in a group. + /// + /// **This may have false positives and must be fixed up with `fix_insert_index` + /// before it's used.** + /// + /// The function is guaranteed to return the index of an empty or deleted [`Bucket`] + /// in the range `0..self.num_buckets()` (`0..=self.bucket_mask`). + #[inline] + fn find_insert_index_in_group(&self, group: &Group, probe_seq: &ProbeSeq) -> Option { + let bit = group.match_empty_or_deleted().lowest_set_bit(); + + if likely(bit.is_some()) { + // This is the same as `(probe_seq.pos + bit) % self.num_buckets()` because the number + // of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + Some((probe_seq.pos + bit.unwrap()) & self.bucket_mask) + } else { + None + } + } + + /// Searches for an element in the table, or a potential slot where that element could + /// be inserted (an empty or deleted [`Bucket`] index). + /// + /// This uses dynamic dispatch to reduce the amount of code generated, but that is + /// eliminated by LLVM optimizations. + /// + /// This function does not make any changes to the `data` part of the table, or any + /// changes to the `items` or `growth_left` field of the table. + /// + /// The table must have at least 1 empty or deleted `bucket`, otherwise, if the + /// `eq: &mut dyn FnMut(usize) -> bool` function does not return `true`, this function + /// will never return (will go into an infinite loop) for tables larger than the group + /// width, or return an index outside of the table indices range if the table is less + /// than the group width. + /// + /// This function is guaranteed to provide the `eq: &mut dyn FnMut(usize) -> bool` + /// function with only `FULL` buckets' indices and return the `index` of the found + /// element (as `Ok(index)`). If the element is not found and there is at least 1 + /// empty or deleted [`Bucket`] in the table, the function is guaranteed to return + /// an index in the range `0..self.num_buckets()`, but in any case, if this function + /// returns `Err`, it will contain an index in the range `0..=self.num_buckets()`. + /// + /// # Safety + /// + /// The [`RawTableInner`] must have properly initialized control bytes otherwise calling + /// this function results in [`undefined behavior`]. + /// + /// Attempt to write data at the index returned by this function when the table is less than + /// the group width and if there was not at least one empty or deleted bucket in the table + /// will cause immediate [`undefined behavior`]. This is because in this case the function + /// will return `self.bucket_mask + 1` as an index due to the trailing [`Tag::EMPTY`] control + /// bytes outside the table range. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn find_or_find_insert_index_inner( + &self, + hash: u64, + eq: &mut dyn FnMut(usize) -> bool, + ) -> Result { + let mut insert_index = None; + + let tag_hash = Tag::full(hash); + let mut probe_seq = self.probe_seq(hash); + + loop { + // SAFETY: + // * Caller of this function ensures that the control bytes are properly initialized. + // + // * `ProbeSeq.pos` cannot be greater than `self.bucket_mask = self.num_buckets() - 1` + // of the table due to masking with `self.bucket_mask` and also because the number + // of buckets is a power of two (see `self.probe_seq` function). + // + // * Even if `ProbeSeq.pos` returns `position == self.bucket_mask`, it is safe to + // call `Group::load` due to the extended control bytes range, which is + // `self.bucket_mask + 1 + Group::WIDTH` (in fact, this means that the last control + // byte will never be read for the allocated table); + // + // * Also, even if `RawTableInner` is not already allocated, `ProbeSeq.pos` will + // always return "0" (zero), so Group::load will read unaligned `Group::static_empty()` + // bytes, which is safe (see RawTableInner::new). + let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; + + for bit in group.match_tag(tag_hash) { + let index = (probe_seq.pos + bit) & self.bucket_mask; + + if likely(eq(index)) { + return Ok(index); + } + } + + // We didn't find the element we were looking for in the group, try to get an + // insertion slot from the group if we don't have one yet. + if likely(insert_index.is_none()) { + insert_index = self.find_insert_index_in_group(&group, &probe_seq); + } + + if let Some(insert_index) = insert_index { + // Only stop the search if the group contains at least one empty element. + // Otherwise, the element that we are looking for might be in a following group. + if likely(group.match_empty().any_bit_set()) { + // We must have found a insert slot by now, since the current group contains at + // least one. For tables smaller than the group width, there will still be an + // empty element in the current (and only) group due to the load factor. + unsafe { + // SAFETY: + // * Caller of this function ensures that the control bytes are properly initialized. + // + // * We use this function with the index found by `self.find_insert_index_in_group` + return Err(self.fix_insert_index(insert_index)); + } + } + } + + probe_seq.move_next(self.bucket_mask); + } + } + + /// Searches for an empty or deleted bucket which is suitable for inserting a new + /// element and sets the hash for that slot. Returns an index of that slot and the + /// old control byte stored in the found index. + /// + /// This function does not check if the given element exists in the table. Also, + /// this function does not check if there is enough space in the table to insert + /// a new element. The caller of the function must make sure that the table has at + /// least 1 empty or deleted `bucket`, otherwise this function will never return + /// (will go into an infinite loop) for tables larger than the group width, or + /// return an index outside of the table indices range if the table is less than + /// the group width. + /// + /// If there is at least 1 empty or deleted `bucket` in the table, the function is + /// guaranteed to return an `index` in the range `0..self.num_buckets()`, but in any case, + /// if this function returns an `index` it will be in the range `0..=self.num_buckets()`. + /// + /// This function does not make any changes to the `data` parts of the table, + /// or any changes to the `items` or `growth_left` field of the table. + /// + /// # Safety + /// + /// The safety rules are directly derived from the safety rules for the + /// [`RawTableInner::set_ctrl_hash`] and [`RawTableInner::find_insert_index`] methods. + /// Thus, in order to uphold the safety contracts for that methods, as well as for + /// the correct logic of the work of this crate, you must observe the following rules + /// when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated and has properly initialized + /// control bytes otherwise calling this function results in [`undefined behavior`]. + /// + /// * The caller of this function must ensure that the "data" parts of the table + /// will have an entry in the returned index (matching the given hash) right + /// after calling this function. + /// + /// Attempt to write data at the `index` returned by this function when the table is + /// less than the group width and if there was not at least one empty or deleted bucket in + /// the table will cause immediate [`undefined behavior`]. This is because in this case the + /// function will return `self.bucket_mask + 1` as an index due to the trailing [`Tag::EMPTY`] + /// control bytes outside the table range. + /// + /// The caller must independently increase the `items` field of the table, and also, + /// if the old control byte was [`Tag::EMPTY`], then decrease the table's `growth_left` + /// field, and do not change it if the old control byte was [`Tag::DELETED`]. + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn prepare_insert_index(&mut self, hash: u64) -> (usize, Tag) { + unsafe { + // SAFETY: Caller of this function ensures that the control bytes are properly initialized. + let index: usize = self.find_insert_index(hash); + // SAFETY: + // 1. The `find_insert_index` function either returns an `index` less than or + // equal to `self.num_buckets() = self.bucket_mask + 1` of the table, or never + // returns if it cannot find an empty or deleted slot. + // 2. The caller of this function guarantees that the table has already been + // allocated + let old_ctrl = *self.ctrl(index); + self.set_ctrl_hash(index, hash); + (index, old_ctrl) + } + } + + /// Searches for an empty or deleted bucket which is suitable for inserting + /// a new element, returning the `index` for the new [`Bucket`]. + /// + /// This function does not make any changes to the `data` part of the table, or any + /// changes to the `items` or `growth_left` field of the table. + /// + /// The table must have at least 1 empty or deleted `bucket`, otherwise this function + /// will never return (will go into an infinite loop) for tables larger than the group + /// width, or return an index outside of the table indices range if the table is less + /// than the group width. + /// + /// If there is at least 1 empty or deleted `bucket` in the table, the function is + /// guaranteed to return an index in the range `0..self.num_buckets()`, but in any case, + /// it will contain an index in the range `0..=self.num_buckets()`. + /// + /// # Safety + /// + /// The [`RawTableInner`] must have properly initialized control bytes otherwise calling + /// this function results in [`undefined behavior`]. + /// + /// Attempt to write data at the index returned by this function when the table is + /// less than the group width and if there was not at least one empty or deleted bucket in + /// the table will cause immediate [`undefined behavior`]. This is because in this case the + /// function will return `self.bucket_mask + 1` as an index due to the trailing [`Tag::EMPTY`] + /// control bytes outside the table range. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn find_insert_index(&self, hash: u64) -> usize { + let mut probe_seq = self.probe_seq(hash); + loop { + // SAFETY: + // * Caller of this function ensures that the control bytes are properly initialized. + // + // * `ProbeSeq.pos` cannot be greater than `self.bucket_mask = self.num_buckets() - 1` + // of the table due to masking with `self.bucket_mask` and also because the number + // of buckets is a power of two (see `self.probe_seq` function). + // + // * Even if `ProbeSeq.pos` returns `position == self.bucket_mask`, it is safe to + // call `Group::load` due to the extended control bytes range, which is + // `self.bucket_mask + 1 + Group::WIDTH` (in fact, this means that the last control + // byte will never be read for the allocated table); + // + // * Also, even if `RawTableInner` is not already allocated, `ProbeSeq.pos` will + // always return "0" (zero), so Group::load will read unaligned `Group::static_empty()` + // bytes, which is safe (see RawTableInner::new). + let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; + + let index = self.find_insert_index_in_group(&group, &probe_seq); + if likely(index.is_some()) { + // SAFETY: + // * Caller of this function ensures that the control bytes are properly initialized. + // + // * We use this function with the slot / index found by `self.find_insert_index_in_group` + unsafe { + return self.fix_insert_index(index.unwrap_unchecked()); + } + } + probe_seq.move_next(self.bucket_mask); + } + } + + /// Searches for an element in a table, returning the `index` of the found element. + /// This uses dynamic dispatch to reduce the amount of code generated, but it is + /// eliminated by LLVM optimizations. + /// + /// This function does not make any changes to the `data` part of the table, or any + /// changes to the `items` or `growth_left` field of the table. + /// + /// The table must have at least 1 empty `bucket`, otherwise, if the + /// `eq: &mut dyn FnMut(usize) -> bool` function does not return `true`, + /// this function will also never return (will go into an infinite loop). + /// + /// This function is guaranteed to provide the `eq: &mut dyn FnMut(usize) -> bool` + /// function with only `FULL` buckets' indices and return the `index` of the found + /// element as `Some(index)`, so the index will always be in the range + /// `0..self.num_buckets()`. + /// + /// # Safety + /// + /// The [`RawTableInner`] must have properly initialized control bytes otherwise calling + /// this function results in [`undefined behavior`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline(always)] + unsafe fn find_inner(&self, hash: u64, eq: &mut dyn FnMut(usize) -> bool) -> Option { + let tag_hash = Tag::full(hash); + let mut probe_seq = self.probe_seq(hash); + + loop { + // SAFETY: + // * Caller of this function ensures that the control bytes are properly initialized. + // + // * `ProbeSeq.pos` cannot be greater than `self.bucket_mask = self.num_buckets() - 1` + // of the table due to masking with `self.bucket_mask`. + // + // * Even if `ProbeSeq.pos` returns `position == self.bucket_mask`, it is safe to + // call `Group::load` due to the extended control bytes range, which is + // `self.bucket_mask + 1 + Group::WIDTH` (in fact, this means that the last control + // byte will never be read for the allocated table); + // + // * Also, even if `RawTableInner` is not already allocated, `ProbeSeq.pos` will + // always return "0" (zero), so Group::load will read unaligned `Group::static_empty()` + // bytes, which is safe (see RawTableInner::new_in). + let group = unsafe { Group::load(self.ctrl(probe_seq.pos)) }; + + for bit in group.match_tag(tag_hash) { + // This is the same as `(probe_seq.pos + bit) % self.num_buckets()` because the number + // of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + let index = (probe_seq.pos + bit) & self.bucket_mask; + + if likely(eq(index)) { + return Some(index); + } + } + + if likely(group.match_empty().any_bit_set()) { + return None; + } + + probe_seq.move_next(self.bucket_mask); + } + } + + /// Prepares for rehashing data in place (that is, without allocating new memory). + /// Converts all full index `control bytes` to `Tag::DELETED` and all `Tag::DELETED` control + /// bytes to `Tag::EMPTY`, i.e. performs the following conversion: + /// + /// - `Tag::EMPTY` control bytes -> `Tag::EMPTY`; + /// - `Tag::DELETED` control bytes -> `Tag::EMPTY`; + /// - `FULL` control bytes -> `Tag::DELETED`. + /// + /// This function does not make any changes to the `data` parts of the table, + /// or any changes to the `items` or `growth_left` field of the table. + /// + /// # Safety + /// + /// You must observe the following safety rules when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The caller of this function must convert the `Tag::DELETED` bytes back to `FULL` + /// bytes when re-inserting them into their ideal position (which was impossible + /// to do during the first insert due to tombstones). If the caller does not do + /// this, then calling this function may result in a memory leak. + /// + /// * The [`RawTableInner`] must have properly initialized control bytes otherwise + /// calling this function results in [`undefined behavior`]. + /// + /// Calling this function on a table that has not been allocated results in + /// [`undefined behavior`]. + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn prepare_rehash_in_place(&mut self) { + // Bulk convert all full control bytes to DELETED, and all DELETED control bytes to EMPTY. + // This effectively frees up all buckets containing a DELETED entry. + // + // SAFETY: + // 1. `i` is guaranteed to be within bounds since we are iterating from zero to `buckets - 1`; + // 2. Even if `i` will be `i == self.bucket_mask`, it is safe to call `Group::load_aligned` + // due to the extended control bytes range, which is `self.bucket_mask + 1 + Group::WIDTH`; + // 3. The caller of this function guarantees that [`RawTableInner`] has already been allocated; + // 4. We can use `Group::load_aligned` and `Group::store_aligned` here since we start from 0 + // and go to the end with a step equal to `Group::WIDTH` (see TableLayout::calculate_layout_for). + unsafe { + for i in (0..self.num_buckets()).step_by(Group::WIDTH) { + let group = Group::load_aligned(self.ctrl(i)); + let group = group.convert_special_to_empty_and_full_to_deleted(); + group.store_aligned(self.ctrl(i)); + } + } + + // Fix up the trailing control bytes. See the comments in set_ctrl + // for the handling of tables smaller than the group width. + if unlikely(self.num_buckets() < Group::WIDTH) { + // SAFETY: We have `self.bucket_mask + 1 + Group::WIDTH` number of control bytes, + // so copying `self.num_buckets() == self.bucket_mask + 1` bytes with offset equal to + // `Group::WIDTH` is safe + unsafe { + self.ctrl(0) + .copy_to(self.ctrl(Group::WIDTH), self.num_buckets()); + } + } else { + // SAFETY: We have `self.bucket_mask + 1 + Group::WIDTH` number of + // control bytes,so copying `Group::WIDTH` bytes with offset equal + // to `self.num_buckets() == self.bucket_mask + 1` is safe + unsafe { + self.ctrl(0) + .copy_to(self.ctrl(self.num_buckets()), Group::WIDTH); + } + } + } + + /// Returns an iterator over every element in the table. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result + /// is [`undefined behavior`]: + /// + /// * The caller has to ensure that the `RawTableInner` outlives the + /// `RawIter`. Because we cannot make the `next` method unsafe on + /// the `RawIter` struct, we have to make the `iter` method unsafe. + /// + /// * The [`RawTableInner`] must have properly initialized control bytes. + /// + /// The type `T` must be the actual type of the elements stored in the table, + /// otherwise using the returned [`RawIter`] results in [`undefined behavior`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn iter(&self) -> RawIter { + // SAFETY: + // 1. Since the caller of this function ensures that the control bytes + // are properly initialized and `self.data_end()` points to the start + // of the array of control bytes, therefore: `ctrl` is valid for reads, + // properly aligned to `Group::WIDTH` and points to the properly initialized + // control bytes. + // 2. `data` bucket index in the table is equal to the `ctrl` index (i.e. + // equal to zero). + // 3. We pass the exact value of buckets of the table to the function. + // + // `ctrl` points here (to the start + // of the first control byte `CT0`) + // ∨ + // [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, CTa_0, CTa_1, ..., CTa_m + // \________ ________/ + // \/ + // `n = buckets - 1`, i.e. `RawTableInner::num_buckets() - 1` + // + // where: T0...T_n - our stored data; + // CT0...CT_n - control bytes or metadata for `data`. + // CTa_0...CTa_m - additional control bytes, where `m = Group::WIDTH - 1` (so that the search + // with loading `Group` bytes from the heap works properly, even if the result + // of `h1(hash) & self.bucket_mask` is equal to `self.bucket_mask`). See also + // `RawTableInner::set_ctrl` function. + // + // P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + // of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + unsafe { + let data = Bucket::from_base_index(self.data_end(), 0); + RawIter { + // SAFETY: See explanation above + iter: RawIterRange::new(self.ctrl.as_ptr(), data, self.num_buckets()), + items: self.items, + } + } + } + + /// Executes the destructors (if any) of the values stored in the table. + /// + /// # Note + /// + /// This function does not erase the control bytes of the table and does + /// not make any changes to the `items` or `growth_left` fields of the + /// table. If necessary, the caller of this function must manually set + /// up these table fields, for example using the [`clear_no_drop`] function. + /// + /// Be careful during calling this function, because drop function of + /// the elements can panic, and this can leave table in an inconsistent + /// state. + /// + /// # Safety + /// + /// The type `T` must be the actual type of the elements stored in the table, + /// otherwise calling this function may result in [`undefined behavior`]. + /// + /// If `T` is a type that should be dropped and **the table is not empty**, + /// calling this function more than once results in [`undefined behavior`]. + /// + /// If `T` is not [`Copy`], attempting to use values stored in the table after + /// calling this function may result in [`undefined behavior`]. + /// + /// It is safe to call this function on a table that has not been allocated, + /// on a table with uninitialized control bytes, and on a table with no actual + /// data but with `Full` control bytes if `self.items == 0`. + /// + /// See also [`Bucket::drop`] / [`Bucket::as_ptr`] methods, for more information + /// about of properly removing or saving `element` from / into the [`RawTable`] / + /// [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + unsafe fn drop_elements(&mut self) { + // Check that `self.items != 0`. Protects against the possibility + // of creating an iterator on an table with uninitialized control bytes. + if T::NEEDS_DROP && self.items != 0 { + // SAFETY: We know for sure that RawTableInner will outlive the + // returned `RawIter` iterator, and the caller of this function + // must uphold the safety contract for `drop_elements` method. + unsafe { + for item in self.iter::() { + // SAFETY: The caller must uphold the safety contract for + // `drop_elements` method. + item.drop(); + } + } + } + } + + /// Executes the destructors (if any) of the values stored in the table and than + /// deallocates the table. + /// + /// # Note + /// + /// Calling this function automatically makes invalid (dangling) all instances of + /// buckets ([`Bucket`]) and makes invalid (dangling) the `ctrl` field of the table. + /// + /// This function does not make any changes to the `bucket_mask`, `items` or `growth_left` + /// fields of the table. If necessary, the caller of this function must manually set + /// up these table fields. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is [`undefined behavior`]: + /// + /// * Calling this function more than once; + /// + /// * The type `T` must be the actual type of the elements stored in the table. + /// + /// * The `alloc` must be the same [`Allocator`] as the `Allocator` that was used + /// to allocate this table. + /// + /// * The `table_layout` must be the same [`TableLayout`] as the `TableLayout` that + /// was used to allocate this table. + /// + /// The caller of this function should pay attention to the possibility of the + /// elements' drop function panicking, because this: + /// + /// * May leave the table in an inconsistent state; + /// + /// * Memory is never deallocated, so a memory leak may occur. + /// + /// Attempt to use the `ctrl` field of the table (dereference) after calling this + /// function results in [`undefined behavior`]. + /// + /// It is safe to call this function on a table that has not been allocated, + /// on a table with uninitialized control bytes, and on a table with no actual + /// data but with `Full` control bytes if `self.items == 0`. + /// + /// See also [`RawTableInner::drop_elements`] or [`RawTableInner::free_buckets`] + /// for more information. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + unsafe fn drop_inner_table(&mut self, alloc: &A, table_layout: TableLayout) { + if !self.is_empty_singleton() { + // SAFETY: The caller must uphold the safety contract for `drop_inner_table` method. + unsafe { + self.drop_elements::(); + } + // SAFETY: + // 1. We have checked that our table is allocated. + // 2. The caller must uphold the safety contract for `drop_inner_table` method. + unsafe { + self.free_buckets(alloc, table_layout); + } + } + } + + /// Returns a pointer to an element in the table (convenience for + /// `Bucket::from_base_index(self.data_end::(), index)`). + /// + /// The caller must ensure that the `RawTableInner` outlives the returned [`Bucket`], + /// otherwise using it may result in [`undefined behavior`]. + /// + /// # Safety + /// + /// If `size_of::() != 0`, then the safety rules are directly derived from the + /// safety rules of the [`Bucket::from_base_index`] function. Therefore, when calling + /// this function, the following safety rules must be observed: + /// + /// * The table must already be allocated; + /// + /// * The `index` must not be greater than the number returned by the [`RawTableInner::num_buckets`] + /// function, i.e. `(index + 1) <= self.num_buckets()`. + /// + /// * The type `T` must be the actual type of the elements stored in the table, otherwise + /// using the returned [`Bucket`] may result in [`undefined behavior`]. + /// + /// It is safe to call this function with index of zero (`index == 0`) on a table that has + /// not been allocated, but using the returned [`Bucket`] results in [`undefined behavior`]. + /// + /// If `size_of::() == 0`, then the only requirement is that the `index` must + /// not be greater than the number returned by the [`RawTable::num_buckets`] function, i.e. + /// `(index + 1) <= self.num_buckets()`. + /// + /// ```none + /// If size_of::() != 0 then return a pointer to the `element` in the `data part` of the table + /// (we start counting from "0", so that in the expression T[n], the "n" index actually one less than + /// the "buckets" number of our `RawTableInner`, i.e. "n = RawTableInner::num_buckets() - 1"): + /// + /// `table.bucket(3).as_ptr()` returns a pointer that points here in the `data` + /// part of the `RawTableInner`, i.e. to the start of T3 (see [`Bucket::as_ptr`]) + /// | + /// | `base = table.data_end::()` points here + /// | (to the start of CT0 or to the end of T0) + /// v v + /// [Pad], T_n, ..., |T3|, T2, T1, T0, |CT0, CT1, CT2, CT3, ..., CT_n, CTa_0, CTa_1, ..., CTa_m + /// ^ \__________ __________/ + /// `table.bucket(3)` returns a pointer that points \/ + /// here in the `data` part of the `RawTableInner` additional control bytes + /// (to the end of T3) `m = Group::WIDTH - 1` + /// + /// where: T0...T_n - our stored data; + /// CT0...CT_n - control bytes or metadata for `data`; + /// CTa_0...CTa_m - additional control bytes (so that the search with loading `Group` bytes from + /// the heap works properly, even if the result of `h1(hash) & self.bucket_mask` + /// is equal to `self.bucket_mask`). See also `RawTableInner::set_ctrl` function. + /// + /// P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + /// of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + /// ``` + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn bucket(&self, index: usize) -> Bucket { + debug_assert_ne!(self.bucket_mask, 0); + debug_assert!(index < self.num_buckets()); + unsafe { Bucket::from_base_index(self.data_end(), index) } + } + + /// Returns a raw `*mut u8` pointer to the start of the `data` element in the table + /// (convenience for `self.data_end::().as_ptr().sub((index + 1) * size_of)`). + /// + /// The caller must ensure that the `RawTableInner` outlives the returned `*mut u8`, + /// otherwise using it may result in [`undefined behavior`]. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is [`undefined behavior`]: + /// + /// * The table must already be allocated; + /// + /// * The `index` must not be greater than the number returned by the [`RawTableInner::num_buckets`] + /// function, i.e. `(index + 1) <= self.num_buckets()`; + /// + /// * The `size_of` must be equal to the size of the elements stored in the table; + /// + /// ```none + /// If size_of::() != 0 then return a pointer to the `element` in the `data part` of the table + /// (we start counting from "0", so that in the expression T[n], the "n" index actually one less than + /// the "buckets" number of our `RawTableInner`, i.e. "n = RawTableInner::num_buckets() - 1"): + /// + /// `table.bucket_ptr(3, size_of::())` returns a pointer that points here in the + /// `data` part of the `RawTableInner`, i.e. to the start of T3 + /// | + /// | `base = table.data_end::()` points here + /// | (to the start of CT0 or to the end of T0) + /// v v + /// [Pad], T_n, ..., |T3|, T2, T1, T0, |CT0, CT1, CT2, CT3, ..., CT_n, CTa_0, CTa_1, ..., CTa_m + /// \__________ __________/ + /// \/ + /// additional control bytes + /// `m = Group::WIDTH - 1` + /// + /// where: T0...T_n - our stored data; + /// CT0...CT_n - control bytes or metadata for `data`; + /// CTa_0...CTa_m - additional control bytes (so that the search with loading `Group` bytes from + /// the heap works properly, even if the result of `h1(hash) & self.bucket_mask` + /// is equal to `self.bucket_mask`). See also `RawTableInner::set_ctrl` function. + /// + /// P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + /// of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + /// ``` + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn bucket_ptr(&self, index: usize, size_of: usize) -> *mut u8 { + debug_assert_ne!(self.bucket_mask, 0); + debug_assert!(index < self.num_buckets()); + unsafe { + let base: *mut u8 = self.data_end().as_ptr(); + base.sub((index + 1) * size_of) + } + } + + /// Returns pointer to one past last `data` element in the table as viewed from + /// the start point of the allocation (convenience for `self.ctrl.cast()`). + /// + /// This function actually returns a pointer to the end of the `data element` at + /// index "0" (zero). + /// + /// The caller must ensure that the `RawTableInner` outlives the returned [`NonNull`], + /// otherwise using it may result in [`undefined behavior`]. + /// + /// # Note + /// + /// The type `T` must be the actual type of the elements stored in the table, otherwise + /// using the returned [`NonNull`] may result in [`undefined behavior`]. + /// + /// ```none + /// `table.data_end::()` returns pointer that points here + /// (to the end of `T0`) + /// ∨ + /// [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, CTa_0, CTa_1, ..., CTa_m + /// \________ ________/ + /// \/ + /// `n = buckets - 1`, i.e. `RawTableInner::num_buckets() - 1` + /// + /// where: T0...T_n - our stored data; + /// CT0...CT_n - control bytes or metadata for `data`. + /// CTa_0...CTa_m - additional control bytes, where `m = Group::WIDTH - 1` (so that the search + /// with loading `Group` bytes from the heap works properly, even if the result + /// of `h1(hash) & self.bucket_mask` is equal to `self.bucket_mask`). See also + /// `RawTableInner::set_ctrl` function. + /// + /// P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.num_buckets()` because the number + /// of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + /// ``` + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + fn data_end(&self) -> NonNull { + self.ctrl.cast() + } + + /// Returns an iterator-like object for a probe sequence on the table. + /// + /// This iterator never terminates, but is guaranteed to visit each bucket + /// group exactly once. The loop using `probe_seq` must terminate upon + /// reaching a group containing an empty bucket. + #[inline] + fn probe_seq(&self, hash: u64) -> ProbeSeq { + ProbeSeq { + // This is the same as `hash as usize % self.num_buckets()` because the number + // of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + pos: h1(hash) & self.bucket_mask, + stride: 0, + } + } + + #[inline] + unsafe fn record_item_insert_at(&mut self, index: usize, old_ctrl: Tag, new_ctrl: Tag) { + self.growth_left -= usize::from(old_ctrl.special_is_empty()); + unsafe { + self.set_ctrl(index, new_ctrl); + } + self.items += 1; + } + + #[inline] + fn is_in_same_group(&self, i: usize, new_i: usize, hash: u64) -> bool { + let probe_seq_pos = self.probe_seq(hash).pos; + let probe_index = + |pos: usize| (pos.wrapping_sub(probe_seq_pos) & self.bucket_mask) / Group::WIDTH; + probe_index(i) == probe_index(new_i) + } + + /// Sets a control byte to the hash, and possibly also the replicated control byte at + /// the end of the array. + /// + /// This function does not make any changes to the `data` parts of the table, + /// or any changes to the `items` or `growth_left` field of the table. + /// + /// # Safety + /// + /// The safety rules are directly derived from the safety rules for [`RawTableInner::set_ctrl`] + /// method. Thus, in order to uphold the safety contracts for the method, you must observe the + /// following rules when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must + /// be no greater than the number returned by the function [`RawTableInner::num_buckets`]. + /// + /// Calling this function on a table that has not been allocated results in [`undefined behavior`]. + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn set_ctrl_hash(&mut self, index: usize, hash: u64) { + unsafe { + // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::set_ctrl_hash`] + self.set_ctrl(index, Tag::full(hash)); + } + } + + /// Replaces the hash in the control byte at the given index with the provided one, + /// and possibly also replicates the new control byte at the end of the array of control + /// bytes, returning the old control byte. + /// + /// This function does not make any changes to the `data` parts of the table, + /// or any changes to the `items` or `growth_left` field of the table. + /// + /// # Safety + /// + /// The safety rules are directly derived from the safety rules for [`RawTableInner::set_ctrl_hash`] + /// and [`RawTableInner::ctrl`] methods. Thus, in order to uphold the safety contracts for both + /// methods, you must observe the following rules when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must + /// be no greater than the number returned by the function [`RawTableInner::num_buckets`]. + /// + /// Calling this function on a table that has not been allocated results in [`undefined behavior`]. + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn replace_ctrl_hash(&mut self, index: usize, hash: u64) -> Tag { + unsafe { + // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::replace_ctrl_hash`] + let prev_ctrl = *self.ctrl(index); + self.set_ctrl_hash(index, hash); + prev_ctrl + } + } + + /// Sets a control byte, and possibly also the replicated control byte at + /// the end of the array. + /// + /// This function does not make any changes to the `data` parts of the table, + /// or any changes to the `items` or `growth_left` field of the table. + /// + /// # Safety + /// + /// You must observe the following safety rules when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must + /// be no greater than the number returned by the function [`RawTableInner::num_buckets`]. + /// + /// Calling this function on a table that has not been allocated results in [`undefined behavior`]. + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn set_ctrl(&mut self, index: usize, ctrl: Tag) { + // Replicate the first Group::WIDTH control bytes at the end of + // the array without using a branch. If the tables smaller than + // the group width (self.num_buckets() < Group::WIDTH), + // `index2 = Group::WIDTH + index`, otherwise `index2` is: + // + // - If index >= Group::WIDTH then index == index2. + // - Otherwise index2 == self.bucket_mask + 1 + index. + // + // The very last replicated control byte is never actually read because + // we mask the initial index for unaligned loads, but we write it + // anyways because it makes the set_ctrl implementation simpler. + // + // If there are fewer buckets than Group::WIDTH then this code will + // replicate the buckets at the end of the trailing group. For example + // with 2 buckets and a group size of 4, the control bytes will look + // like this: + // + // Real | Replicated + // --------------------------------------------- + // | [A] | [B] | [Tag::EMPTY] | [EMPTY] | [A] | [B] | + // --------------------------------------------- + + // This is the same as `(index.wrapping_sub(Group::WIDTH)) % self.num_buckets() + Group::WIDTH` + // because the number of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + let index2 = ((index.wrapping_sub(Group::WIDTH)) & self.bucket_mask) + Group::WIDTH; + + // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::set_ctrl`] + unsafe { + *self.ctrl(index) = ctrl; + *self.ctrl(index2) = ctrl; + } + } + + /// Returns a pointer to a control byte. + /// + /// # Safety + /// + /// For the allocated [`RawTableInner`], the result is [`Undefined Behavior`], + /// if the `index` is greater than the `self.bucket_mask + 1 + Group::WIDTH`. + /// In that case, calling this function with `index == self.bucket_mask + 1 + Group::WIDTH` + /// will return a pointer to the end of the allocated table and it is useless on its own. + /// + /// Calling this function with `index >= self.bucket_mask + 1 + Group::WIDTH` on a + /// table that has not been allocated results in [`Undefined Behavior`]. + /// + /// So to satisfy both requirements you should always follow the rule that + /// `index < self.bucket_mask + 1 + Group::WIDTH` + /// + /// Calling this function on [`RawTableInner`] that are not already allocated is safe + /// for read-only purpose. + /// + /// See also [`Bucket::as_ptr()`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`Undefined Behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn ctrl(&self, index: usize) -> *mut Tag { + debug_assert!(index < self.num_ctrl_bytes()); + // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::ctrl`] + unsafe { self.ctrl.as_ptr().add(index).cast() } + } + + /// Gets the slice of all control bytes, as possibily uninitialized tags. + fn ctrl_slice(&mut self) -> &mut [mem::MaybeUninit] { + // SAFETY: We have the correct number of control bytes. + unsafe { slice::from_raw_parts_mut(self.ctrl.as_ptr().cast(), self.num_ctrl_bytes()) } + } + + #[inline] + fn num_buckets(&self) -> usize { + self.bucket_mask + 1 + } + + /// Checks whether the bucket at `index` is full. + /// + /// # Safety + /// + /// The caller must ensure `index` is less than the number of buckets. + #[inline] + unsafe fn is_bucket_full(&self, index: usize) -> bool { + debug_assert!(index < self.num_buckets()); + unsafe { (*self.ctrl(index)).is_full() } + } + + #[inline] + fn num_ctrl_bytes(&self) -> usize { + self.bucket_mask + 1 + Group::WIDTH + } + + #[inline] + fn is_empty_singleton(&self) -> bool { + self.bucket_mask == 0 + } + + /// Attempts to allocate a new hash table with at least enough capacity + /// for inserting the given number of elements without reallocating, + /// and return it inside `ScopeGuard` to protect against panic in the hash + /// function. + /// + /// # Note + /// + /// It is recommended (but not required): + /// + /// * That the new table's `capacity` be greater than or equal to `self.items`. + /// + /// * The `alloc` is the same [`Allocator`] as the `Allocator` used + /// to allocate this table. + /// + /// * The `table_layout` is the same [`TableLayout`] as the `TableLayout` used + /// to allocate this table. + /// + /// If `table_layout` does not match the `TableLayout` that was used to allocate + /// this table, then using `mem::swap` with the `self` and the new table returned + /// by this function results in [`undefined behavior`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + fn prepare_resize<'a, A>( + &self, + alloc: &'a A, + table_layout: TableLayout, + capacity: usize, + fallibility: Fallibility, + ) -> Result, TryReserveError> + where + A: Allocator, + { + debug_assert!(self.items <= capacity); + + // Allocate and initialize the new table. + let new_table = + RawTableInner::fallible_with_capacity(alloc, table_layout, capacity, fallibility)?; + + // The hash function may panic, in which case we simply free the new + // table without dropping any elements that may have been copied into + // it. + // + // This guard is also used to free the old table on success, see + // the comment at the bottom of this function. + Ok(guard(new_table, move |self_| { + if !self_.is_empty_singleton() { + // SAFETY: + // 1. We have checked that our table is allocated. + // 2. We know for sure that the `alloc` and `table_layout` matches the + // [`Allocator`] and [`TableLayout`] used to allocate this table. + unsafe { self_.free_buckets(alloc, table_layout) }; + } + })) + } + + /// Reserves or rehashes to make room for `additional` more elements. + /// + /// This uses dynamic dispatch to reduce the amount of + /// code generated, but it is eliminated by LLVM optimizations when inlined. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is + /// [`undefined behavior`]: + /// + /// * The `alloc` must be the same [`Allocator`] as the `Allocator` used + /// to allocate this table. + /// + /// * The `layout` must be the same [`TableLayout`] as the `TableLayout` + /// used to allocate this table. + /// + /// * The `drop` function (`fn(*mut u8)`) must be the actual drop function of + /// the elements stored in the table. + /// + /// * The [`RawTableInner`] must have properly initialized control bytes. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[expect(clippy::inline_always)] + #[inline(always)] + unsafe fn reserve_rehash_inner( + &mut self, + alloc: &A, + additional: usize, + hasher: &dyn Fn(&mut Self, usize) -> u64, + fallibility: Fallibility, + layout: TableLayout, + drop: Option, + ) -> Result<(), TryReserveError> + where + A: Allocator, + { + // Avoid `Option::ok_or_else` because it bloats LLVM IR. + let Some(new_items) = self.items.checked_add(additional) else { + return Err(fallibility.capacity_overflow()); + }; + let full_capacity = bucket_mask_to_capacity(self.bucket_mask); + if new_items <= full_capacity / 2 { + // Rehash in-place without re-allocating if we have plenty of spare + // capacity that is locked up due to DELETED entries. + + // SAFETY: + // 1. We know for sure that `[`RawTableInner`]` has already been allocated + // (since new_items <= full_capacity / 2); + // 2. The caller ensures that `drop` function is the actual drop function of + // the elements stored in the table. + // 3. The caller ensures that `layout` matches the [`TableLayout`] that was + // used to allocate this table. + // 4. The caller ensures that the control bytes of the `RawTableInner` + // are already initialized. + unsafe { + self.rehash_in_place(hasher, layout.size, drop); + } + Ok(()) + } else { + // Otherwise, conservatively resize to at least the next size up + // to avoid churning deletes into frequent rehashes. + // + // SAFETY: + // 1. We know for sure that `capacity >= self.items`. + // 2. The caller ensures that `alloc` and `layout` matches the [`Allocator`] and + // [`TableLayout`] that were used to allocate this table. + // 3. The caller ensures that the control bytes of the `RawTableInner` + // are already initialized. + unsafe { + self.resize_inner( + alloc, + usize::max(new_items, full_capacity + 1), + hasher, + fallibility, + layout, + ) + } + } + } + + /// Returns an iterator over full buckets indices in the table. + /// + /// # Safety + /// + /// Behavior is undefined if any of the following conditions are violated: + /// + /// * The caller has to ensure that the `RawTableInner` outlives the + /// `FullBucketsIndices`. Because we cannot make the `next` method + /// unsafe on the `FullBucketsIndices` struct, we have to make the + /// `full_buckets_indices` method unsafe. + /// + /// * The [`RawTableInner`] must have properly initialized control bytes. + #[inline(always)] + unsafe fn full_buckets_indices(&self) -> FullBucketsIndices { + // SAFETY: + // 1. Since the caller of this function ensures that the control bytes + // are properly initialized and `self.ctrl(0)` points to the start + // of the array of control bytes, therefore: `ctrl` is valid for reads, + // properly aligned to `Group::WIDTH` and points to the properly initialized + // control bytes. + // 2. The value of `items` is equal to the amount of data (values) added + // to the table. + // + // `ctrl` points here (to the start + // of the first control byte `CT0`) + // ∨ + // [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, Group::WIDTH + // \________ ________/ + // \/ + // `n = buckets - 1`, i.e. `RawTableInner::num_buckets() - 1` + // + // where: T0...T_n - our stored data; + // CT0...CT_n - control bytes or metadata for `data`. + unsafe { + let ctrl = NonNull::new_unchecked(self.ctrl(0).cast::()); + + FullBucketsIndices { + // Load the first group + // SAFETY: See explanation above. + current_group: Group::load_aligned(ctrl.as_ptr().cast()) + .match_full() + .into_iter(), + group_first_index: 0, + ctrl, + items: self.items, + } + } + } + + /// Allocates a new table of a different size and moves the contents of the + /// current table into it. + /// + /// This uses dynamic dispatch to reduce the amount of + /// code generated, but it is eliminated by LLVM optimizations when inlined. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is + /// [`undefined behavior`]: + /// + /// * The `alloc` must be the same [`Allocator`] as the `Allocator` used + /// to allocate this table; + /// + /// * The `layout` must be the same [`TableLayout`] as the `TableLayout` + /// used to allocate this table; + /// + /// * The [`RawTableInner`] must have properly initialized control bytes. + /// + /// The caller of this function must ensure that `capacity >= self.items` + /// otherwise: + /// + /// * If `self.items != 0`, calling of this function with `capacity == 0` + /// results in [`undefined behavior`]. + /// + /// * If `capacity_to_buckets(capacity) < Group::WIDTH` and + /// `self.items > capacity_to_buckets(capacity)` calling this function + /// results in [`undefined behavior`]. + /// + /// * If `capacity_to_buckets(capacity) >= Group::WIDTH` and + /// `self.items > capacity_to_buckets(capacity)` calling this function + /// are never return (will go into an infinite loop). + /// + /// Note: It is recommended (but not required) that the new table's `capacity` + /// be greater than or equal to `self.items`. In case if `capacity <= self.items` + /// this function can never return. See [`RawTableInner::find_insert_index`] for + /// more information. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[expect(clippy::inline_always)] + #[inline(always)] + unsafe fn resize_inner( + &mut self, + alloc: &A, + capacity: usize, + hasher: &dyn Fn(&mut Self, usize) -> u64, + fallibility: Fallibility, + layout: TableLayout, + ) -> Result<(), TryReserveError> + where + A: Allocator, + { + // SAFETY: We know for sure that `alloc` and `layout` matches the [`Allocator`] and [`TableLayout`] + // that were used to allocate this table. + let mut new_table = self.prepare_resize(alloc, layout, capacity, fallibility)?; + + // SAFETY: We know for sure that RawTableInner will outlive the + // returned `FullBucketsIndices` iterator, and the caller of this + // function ensures that the control bytes are properly initialized. + unsafe { + for full_byte_index in self.full_buckets_indices() { + // This may panic. + let hash = hasher(self, full_byte_index); + + // SAFETY: + // We can use a simpler version of insert() here since: + // 1. There are no DELETED entries. + // 2. We know there is enough space in the table. + // 3. All elements are unique. + // 4. The caller of this function guarantees that `capacity > 0` + // so `new_table` must already have some allocated memory. + // 5. We set `growth_left` and `items` fields of the new table + // after the loop. + // 6. We insert into the table, at the returned index, the data + // matching the given hash immediately after calling this function. + let (new_index, _) = new_table.prepare_insert_index(hash); + + // SAFETY: + // + // * `src` is valid for reads of `layout.size` bytes, since the + // table is alive and the `full_byte_index` is guaranteed to be + // within bounds (see `FullBucketsIndices::next_impl`); + // + // * `dst` is valid for writes of `layout.size` bytes, since the + // caller ensures that `table_layout` matches the [`TableLayout`] + // that was used to allocate old table and we have the `new_index` + // returned by `prepare_insert_index`. + // + // * Both `src` and `dst` are properly aligned. + // + // * Both `src` and `dst` point to different region of memory. + ptr::copy_nonoverlapping( + self.bucket_ptr(full_byte_index, layout.size), + new_table.bucket_ptr(new_index, layout.size), + layout.size, + ); + } + } + + // The hash function didn't panic, so we can safely set the + // `growth_left` and `items` fields of the new table. + new_table.growth_left -= self.items; + new_table.items = self.items; + + // We successfully copied all elements without panicking. Now replace + // self with the new table. The old table will have its memory freed but + // the items will not be dropped (since they have been moved into the + // new table). + // SAFETY: The caller ensures that `table_layout` matches the [`TableLayout`] + // that was used to allocate this table. + mem::swap(self, &mut new_table); + + Ok(()) + } + + /// Rehashes the contents of the table in place (i.e. without changing the + /// allocation). + /// + /// If `hasher` panics then some the table's contents may be lost. + /// + /// This uses dynamic dispatch to reduce the amount of + /// code generated, but it is eliminated by LLVM optimizations when inlined. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is [`undefined behavior`]: + /// + /// * The `size_of` must be equal to the size of the elements stored in the table; + /// + /// * The `drop` function (`fn(*mut u8)`) must be the actual drop function of + /// the elements stored in the table. + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The [`RawTableInner`] must have properly initialized control bytes. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[cfg_attr(feature = "inline-more", expect(clippy::inline_always))] + #[cfg_attr(feature = "inline-more", inline(always))] + #[cfg_attr(not(feature = "inline-more"), inline)] + unsafe fn rehash_in_place( + &mut self, + hasher: &dyn Fn(&mut Self, usize) -> u64, + size_of: usize, + drop: Option, + ) { + // If the hash function panics then properly clean up any elements + // that we haven't rehashed yet. We unfortunately can't preserve the + // element since we lost their hash and have no way of recovering it + // without risking another panic. + unsafe { + self.prepare_rehash_in_place(); + } + + let mut guard = guard(self, move |self_| { + for i in 0..self_.num_buckets() { + unsafe { + // Any elements that haven't been rehashed yet have a + // DELETED tag. These need to be dropped and have their tag + // reset to EMPTY. + if *self_.ctrl(i) == Tag::DELETED { + self_.set_ctrl(i, Tag::EMPTY); + if let Some(drop) = drop { + drop(self_.bucket_ptr(i, size_of)); + } + self_.items -= 1; + } + } + } + self_.growth_left = bucket_mask_to_capacity(self_.bucket_mask) - self_.items; + }); + + // At this point, DELETED elements are elements that we haven't + // rehashed yet. Find them and re-insert them at their ideal + // position. + 'outer: for i in 0..guard.num_buckets() { + unsafe { + if *guard.ctrl(i) != Tag::DELETED { + continue; + } + } + + let i_p = unsafe { guard.bucket_ptr(i, size_of) }; + + loop { + // Hash the current item + let hash = hasher(*guard, i); + + // Search for a suitable place to put it + // + // SAFETY: Caller of this function ensures that the control bytes + // are properly initialized. + let new_i = unsafe { guard.find_insert_index(hash) }; + + // Probing works by scanning through all of the control + // bytes in groups, which may not be aligned to the group + // size. If both the new and old position fall within the + // same unaligned group, then there is no benefit in moving + // it and we can just continue to the next item. + if likely(guard.is_in_same_group(i, new_i, hash)) { + unsafe { guard.set_ctrl_hash(i, hash) }; + continue 'outer; + } + + let new_i_p = unsafe { guard.bucket_ptr(new_i, size_of) }; + + // We are moving the current item to a new position. Write + // our H2 to the control byte of the new position. + let prev_ctrl = unsafe { guard.replace_ctrl_hash(new_i, hash) }; + if prev_ctrl == Tag::EMPTY { + unsafe { guard.set_ctrl(i, Tag::EMPTY) }; + // If the target slot is empty, simply move the current + // element into the new slot and clear the old control + // byte. + unsafe { + ptr::copy_nonoverlapping(i_p, new_i_p, size_of); + } + continue 'outer; + } + + // If the target slot is occupied, swap the two elements + // and then continue processing the element that we just + // swapped into the old slot. + debug_assert_eq!(prev_ctrl, Tag::DELETED); + unsafe { + ptr::swap_nonoverlapping(i_p, new_i_p, size_of); + } + } + } + + guard.growth_left = bucket_mask_to_capacity(guard.bucket_mask) - guard.items; + + mem::forget(guard); + } + + /// Deallocates the table without dropping any entries. + /// + /// # Note + /// + /// This function must be called only after [`drop_elements`](RawTableInner::drop_elements), + /// else it can lead to leaking of memory. Also calling this function automatically + /// makes invalid (dangling) all instances of buckets ([`Bucket`]) and makes invalid + /// (dangling) the `ctrl` field of the table. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is [`Undefined Behavior`]: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * The `alloc` must be the same [`Allocator`] as the `Allocator` that was used + /// to allocate this table. + /// + /// * The `table_layout` must be the same [`TableLayout`] as the `TableLayout` that was used + /// to allocate this table. + /// + /// See also [`GlobalAlloc::dealloc`] or [`Allocator::deallocate`] for more information. + /// + /// [`Undefined Behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// [`GlobalAlloc::dealloc`]: stdalloc::alloc::GlobalAlloc::dealloc + /// [`Allocator::deallocate`]: stdalloc::alloc::Allocator::deallocate + #[inline] + unsafe fn free_buckets(&mut self, alloc: &A, table_layout: TableLayout) + where + A: Allocator, + { + unsafe { + // SAFETY: The caller must uphold the safety contract for `free_buckets` + // method. + let (ptr, layout) = self.allocation_info(table_layout); + alloc.deallocate(ptr, layout); + } + } + + /// Returns a pointer to the allocated memory and the layout that was used to + /// allocate the table. + /// + /// # Safety + /// + /// Caller of this function must observe the following safety rules: + /// + /// * The [`RawTableInner`] has already been allocated, otherwise + /// calling this function results in [`undefined behavior`] + /// + /// * The `table_layout` must be the same [`TableLayout`] as the `TableLayout` + /// that was used to allocate this table. Failure to comply with this condition + /// may result in [`undefined behavior`]. + /// + /// See also [`GlobalAlloc::dealloc`] or [`Allocator::deallocate`] for more information. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// [`GlobalAlloc::dealloc`]: stdalloc::GlobalAlloc::dealloc + /// [`Allocator::deallocate`]: stdalloc::Allocator::deallocate + #[inline] + unsafe fn allocation_info(&self, table_layout: TableLayout) -> (NonNull, Layout) { + debug_assert!( + !self.is_empty_singleton(), + "this function can only be called on non-empty tables" + ); + + let (layout, ctrl_offset) = { + let option = table_layout.calculate_layout_for(self.num_buckets()); + unsafe { option.unwrap_unchecked() } + }; + ( + // SAFETY: The caller must uphold the safety contract for `allocation_info` method. + unsafe { NonNull::new_unchecked(self.ctrl.as_ptr().sub(ctrl_offset)) }, + layout, + ) + } + + /// Returns the total amount of memory allocated internally by the hash + /// table, in bytes. + /// + /// The returned number is informational only. It is intended to be + /// primarily used for memory profiling. + /// + /// # Safety + /// + /// The `table_layout` must be the same [`TableLayout`] as the `TableLayout` + /// that was used to allocate this table. Failure to comply with this condition + /// may result in [`undefined behavior`]. + /// + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn allocation_size_or_zero(&self, table_layout: TableLayout) -> usize { + if self.is_empty_singleton() { + 0 + } else { + // SAFETY: + // 1. We have checked that our table is allocated. + // 2. The caller ensures that `table_layout` matches the [`TableLayout`] + // that was used to allocate this table. + unsafe { self.allocation_info(table_layout).1.size() } + } + } + + /// Marks all table buckets as empty without dropping their contents. + #[inline] + fn clear_no_drop(&mut self) { + if !self.is_empty_singleton() { + self.ctrl_slice().fill_empty(); + } + self.items = 0; + self.growth_left = bucket_mask_to_capacity(self.bucket_mask); + } + + /// Erases the [`Bucket`]'s control byte at the given index so that it does not + /// triggered as full, decreases the `items` of the table and, if it can be done, + /// increases `self.growth_left`. + /// + /// This function does not actually erase / drop the [`Bucket`] itself, i.e. it + /// does not make any changes to the `data` parts of the table. The caller of this + /// function must take care to properly drop the `data`, otherwise calling this + /// function may result in a memory leak. + /// + /// # Safety + /// + /// You must observe the following safety rules when calling this function: + /// + /// * The [`RawTableInner`] has already been allocated; + /// + /// * It must be the full control byte at the given position; + /// + /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e. + /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must + /// be no greater than the number returned by the function [`RawTableInner::num_buckets`]. + /// + /// Calling this function on a table that has not been allocated results in [`undefined behavior`]. + /// + /// Calling this function on a table with no elements is unspecified, but calling subsequent + /// functions is likely to result in [`undefined behavior`] due to overflow subtraction + /// (`self.items -= 1 cause overflow when self.items == 0`). + /// + /// See also [`Bucket::as_ptr`] method, for more information about of properly removing + /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`]. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline] + unsafe fn erase(&mut self, index: usize) { + unsafe { + debug_assert!(self.is_bucket_full(index)); + } + + // This is the same as `index.wrapping_sub(Group::WIDTH) % self.num_buckets()` because + // the number of buckets is a power of two, and `self.bucket_mask = self.num_buckets() - 1`. + let index_before = index.wrapping_sub(Group::WIDTH) & self.bucket_mask; + // SAFETY: + // - The caller must uphold the safety contract for `erase` method; + // - `index_before` is guaranteed to be in range due to masking with `self.bucket_mask` + let (empty_before, empty_after) = unsafe { + ( + Group::load(self.ctrl(index_before)).match_empty(), + Group::load(self.ctrl(index)).match_empty(), + ) + }; + + // Inserting and searching in the map is performed by two key functions: + // + // - The `find_insert_index` function that looks up the index of any `Tag::EMPTY` or `Tag::DELETED` + // slot in a group to be able to insert. If it doesn't find an `Tag::EMPTY` or `Tag::DELETED` + // slot immediately in the first group, it jumps to the next `Group` looking for it, + // and so on until it has gone through all the groups in the control bytes. + // + // - The `find_inner` function that looks for the index of the desired element by looking + // at all the `FULL` bytes in the group. If it did not find the element right away, and + // there is no `Tag::EMPTY` byte in the group, then this means that the `find_insert_index` + // function may have found a suitable slot in the next group. Therefore, `find_inner` + // jumps further, and if it does not find the desired element and again there is no `Tag::EMPTY` + // byte, then it jumps further, and so on. The search stops only if `find_inner` function + // finds the desired element or hits an `Tag::EMPTY` slot/byte. + // + // Accordingly, this leads to two consequences: + // + // - The map must have `Tag::EMPTY` slots (bytes); + // + // - You can't just mark the byte to be erased as `Tag::EMPTY`, because otherwise the `find_inner` + // function may stumble upon an `Tag::EMPTY` byte before finding the desired element and stop + // searching. + // + // Thus it is necessary to check all bytes after and before the erased element. If we are in + // a contiguous `Group` of `FULL` or `Tag::DELETED` bytes (the number of `FULL` or `Tag::DELETED` bytes + // before and after is greater than or equal to `Group::WIDTH`), then we must mark our byte as + // `Tag::DELETED` in order for the `find_inner` function to go further. On the other hand, if there + // is at least one `Tag::EMPTY` slot in the `Group`, then the `find_inner` function will still stumble + // upon an `Tag::EMPTY` byte, so we can safely mark our erased byte as `Tag::EMPTY` as well. + // + // Finally, since `index_before == (index.wrapping_sub(Group::WIDTH) & self.bucket_mask) == index` + // and given all of the above, tables smaller than the group width (self.num_buckets() < Group::WIDTH) + // cannot have `Tag::DELETED` bytes. + // + // Note that in this context `leading_zeros` refers to the bytes at the end of a group, while + // `trailing_zeros` refers to the bytes at the beginning of a group. + let ctrl = if empty_before.leading_zeros() + empty_after.trailing_zeros() >= Group::WIDTH { + Tag::DELETED + } else { + self.growth_left += 1; + Tag::EMPTY + }; + // SAFETY: the caller must uphold the safety contract for `erase` method. + unsafe { + self.set_ctrl(index, ctrl); + } + self.items -= 1; + } +} + +impl Clone for RawTable { + fn clone(&self) -> Self { + if self.table.is_empty_singleton() { + Self::new_in(self.alloc.clone()) + } else { + // SAFETY: This is safe as we are taking the size of an already allocated table + // and therefore capacity overflow cannot occur, `self.table.num_buckets()` is power + // of two and all allocator errors will be caught inside `RawTableInner::new_uninitialized`. + let result = unsafe { + Self::new_uninitialized( + self.alloc.clone(), + self.table.num_buckets(), + Fallibility::Infallible, + ) + }; + + // SAFETY: The result of calling the `new_uninitialized` function cannot be an error + // because `fallibility == Fallibility::Infallible. + let mut new_table = unsafe { result.unwrap_unchecked() }; + + // SAFETY: + // Cloning elements may fail (the clone function may panic). But we don't + // need to worry about uninitialized control bits, since: + // 1. The number of items (elements) in the table is zero, which means that + // the control bits will not be read by Drop function. + // 2. The `clone_from_spec` method will first copy all control bits from + // `self` (thus initializing them). But this will not affect the `Drop` + // function, since the `clone_from_spec` function sets `items` only after + // successfully cloning all elements. + unsafe { new_table.clone_from_spec(self) }; + new_table + } + } + + fn clone_from(&mut self, source: &Self) { + if source.table.is_empty_singleton() { + let mut old_inner = mem::replace(&mut self.table, RawTableInner::NEW); + unsafe { + // SAFETY: + // 1. We call the function only once; + // 2. We know for sure that `alloc` and `table_layout` matches the [`Allocator`] + // and [`TableLayout`] that were used to allocate this table. + // 3. If any elements' drop function panics, then there will only be a memory leak, + // because we have replaced the inner table with a new one. + old_inner.drop_inner_table::(&self.alloc, Self::TABLE_LAYOUT); + } + } else { + unsafe { + // Make sure that if any panics occurs, we clear the table and + // leave it in an empty state. + let mut self_ = guard(self, |self_| { + self_.clear_no_drop(); + }); + + // First, drop all our elements without clearing the control + // bytes. If this panics then the scope guard will clear the + // table, leaking any elements that were not dropped yet. + // + // This leak is unavoidable: we can't try dropping more elements + // since this could lead to another panic and abort the process. + // + // SAFETY: If something gets wrong we clear our table right after + // dropping the elements, so there is no double drop, since `items` + // will be equal to zero. + self_.table.drop_elements::(); + + // If necessary, resize our table to match the source. + if self_.num_buckets() != source.num_buckets() { + let new_inner = { + let result = RawTableInner::new_uninitialized( + &self_.alloc, + Self::TABLE_LAYOUT, + source.num_buckets(), + Fallibility::Infallible, + ); + result.unwrap_unchecked() + }; + // Replace the old inner with new uninitialized one. It's ok, since if something gets + // wrong `ScopeGuard` will initialize all control bytes and leave empty table. + let mut old_inner = mem::replace(&mut self_.table, new_inner); + if !old_inner.is_empty_singleton() { + // SAFETY: + // 1. We have checked that our table is allocated. + // 2. We know for sure that `alloc` and `table_layout` matches + // the [`Allocator`] and [`TableLayout`] that were used to allocate this table. + old_inner.free_buckets(&self_.alloc, Self::TABLE_LAYOUT); + } + } + + // Cloning elements may fail (the clone function may panic), but the `ScopeGuard` + // inside the `clone_from_impl` function will take care of that, dropping all + // cloned elements if necessary. Our `ScopeGuard` will clear the table. + self_.clone_from_spec(source); + + // Disarm the scope guard if cloning was successful. + ScopeGuard::into_inner(self_); + } + } + } +} + +/// Specialization of `clone_from` for `Copy` types +trait RawTableClone { + unsafe fn clone_from_spec(&mut self, source: &Self); +} +impl RawTableClone for RawTable { + default_fn! { + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn clone_from_spec(&mut self, source: &Self) { + unsafe { + self.clone_from_impl(source); + } + } + } +} +#[cfg(feature = "nightly")] +impl RawTableClone for RawTable { + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn clone_from_spec(&mut self, source: &Self) { + unsafe { + source + .table + .ctrl(0) + .copy_to_nonoverlapping(self.table.ctrl(0), self.table.num_ctrl_bytes()); + source + .data_start() + .as_ptr() + .copy_to_nonoverlapping(self.data_start().as_ptr(), self.table.num_buckets()); + } + + self.table.items = source.table.items; + self.table.growth_left = source.table.growth_left; + } +} + +impl RawTable { + /// Common code for `clone` and `clone_from`. Assumes: + /// - `self.num_buckets() == source.num_buckets()`. + /// - Any existing elements have been dropped. + /// - The control bytes are not initialized yet. + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn clone_from_impl(&mut self, source: &Self) { + // Copy the control bytes unchanged. We do this in a single pass + unsafe { + source + .table + .ctrl(0) + .copy_to_nonoverlapping(self.table.ctrl(0), self.table.num_ctrl_bytes()); + } + + // The cloning of elements may panic, in which case we need + // to make sure we drop only the elements that have been + // cloned so far. + let mut guard = guard((0, &mut *self), |(index, self_)| { + if T::NEEDS_DROP { + for i in 0..*index { + unsafe { + if self_.is_bucket_full(i) { + self_.bucket(i).drop(); + } + } + } + } + }); + + unsafe { + for from in source.iter() { + let index = source.bucket_index(&from); + let to = guard.1.bucket(index); + to.write(from.as_ref().clone()); + + // Update the index in case we need to unwind. + guard.0 = index + 1; + } + } + + // Successfully cloned all items, no need to clean up. + mem::forget(guard); + + self.table.items = source.table.items; + self.table.growth_left = source.table.growth_left; + } +} + +impl Default for RawTable { + #[inline] + fn default() -> Self { + Self::new_in(Default::default()) + } +} + +#[cfg(feature = "nightly")] +unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawTable { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + // SAFETY: + // 1. We call the function only once; + // 2. We know for sure that `alloc` and `table_layout` matches the [`Allocator`] + // and [`TableLayout`] that were used to allocate this table. + // 3. If the drop function of any elements fails, then only a memory leak will occur, + // and we don't care because we are inside the `Drop` function of the `RawTable`, + // so there won't be any table left in an inconsistent state. + unsafe { + self.table + .drop_inner_table::(&self.alloc, Self::TABLE_LAYOUT); + } + } +} +#[cfg(not(feature = "nightly"))] +impl Drop for RawTable { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + // SAFETY: + // 1. We call the function only once; + // 2. We know for sure that `alloc` and `table_layout` matches the [`Allocator`] + // and [`TableLayout`] that were used to allocate this table. + // 3. If the drop function of any elements fails, then only a memory leak will occur, + // and we don't care because we are inside the `Drop` function of the `RawTable`, + // so there won't be any table left in an inconsistent state. + unsafe { + self.table + .drop_inner_table::(&self.alloc, Self::TABLE_LAYOUT); + } + } +} + +impl IntoIterator for RawTable { + type Item = T; + type IntoIter = RawIntoIter; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> RawIntoIter { + unsafe { + let iter = self.iter(); + self.into_iter_from(iter) + } + } +} + +/// Iterator over a sub-range of a table. Unlike `RawIter` this iterator does +/// not track an item count. +pub(crate) struct RawIterRange { + // Mask of full buckets in the current group. Bits are cleared from this + // mask as each element is processed. + current_group: BitMaskIter, + + // Pointer to the buckets for the current group. + data: Bucket, + + // Pointer to the next group of control bytes, + // Must be aligned to the group size. + next_ctrl: *const u8, + + // Pointer one past the last control byte of this range. + end: *const u8, +} + +impl RawIterRange { + /// Returns a `RawIterRange` covering a subset of a table. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is + /// [`undefined behavior`]: + /// + /// * `ctrl` must be valid for reads, i.e. table outlives the `RawIterRange`; + /// + /// * `ctrl` must be properly aligned to the group size (`Group::WIDTH`); + /// + /// * `ctrl` must point to the array of properly initialized control bytes; + /// + /// * `data` must be the [`Bucket`] at the `ctrl` index in the table; + /// + /// * the value of `len` must be less than or equal to the number of table buckets, + /// and the returned value of `ctrl.as_ptr().add(len).offset_from(ctrl.as_ptr())` + /// must be positive. + /// + /// * The `ctrl.add(len)` pointer must be either in bounds or one + /// byte past the end of the same [allocated table]. + /// + /// * The `len` must be a power of two. + /// + /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn new(ctrl: *const u8, data: Bucket, len: usize) -> Self { + debug_assert_ne!(len, 0); + debug_assert!(ctrl.cast::().is_aligned()); + // SAFETY: The caller must uphold the safety rules for the [`RawIterRange::new`] + let end = unsafe { ctrl.add(len) }; + + // Load the first group and advance ctrl to point to the next group + // SAFETY: The caller must uphold the safety rules for the [`RawIterRange::new`] + let (current_group, next_ctrl) = unsafe { + ( + Group::load_aligned(ctrl.cast()).match_full(), + ctrl.add(Group::WIDTH), + ) + }; + + Self { + current_group: current_group.into_iter(), + data, + next_ctrl, + end, + } + } + + /// Splits a `RawIterRange` into two halves. + /// + /// Returns `None` if the remaining range is smaller than or equal to the + /// group width. + #[cfg_attr(feature = "inline-more", inline)] + #[cfg(feature = "rayon")] + pub(crate) fn split(mut self) -> (Self, Option>) { + unsafe { + if self.end <= self.next_ctrl { + // Nothing to split if the group that we are current processing + // is the last one. + (self, None) + } else { + // len is the remaining number of elements after the group that + // we are currently processing. It must be a multiple of the + // group size (small tables are caught by the check above). + let len = offset_from(self.end, self.next_ctrl); + debug_assert_eq!(len % Group::WIDTH, 0); + + // Split the remaining elements into two halves, but round the + // midpoint down in case there is an odd number of groups + // remaining. This ensures that: + // - The tail is at least 1 group long. + // - The split is roughly even considering we still have the + // current group to process. + let mid = (len / 2) & !(Group::WIDTH - 1); + + let tail = Self::new( + self.next_ctrl.add(mid), + self.data.next_n(Group::WIDTH).next_n(mid), + len - mid, + ); + debug_assert_eq!( + self.data.next_n(Group::WIDTH).next_n(mid).ptr, + tail.data.ptr + ); + debug_assert_eq!(self.end, tail.end); + self.end = self.next_ctrl.add(mid); + debug_assert_eq!(self.end.add(Group::WIDTH), tail.next_ctrl); + (self, Some(tail)) + } + } + } + + /// # Safety + /// If `DO_CHECK_PTR_RANGE` is false, caller must ensure that we never try to iterate + /// after yielding all elements. + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn next_impl(&mut self) -> Option> { + loop { + if let Some(index) = self.current_group.next() { + return Some(unsafe { self.data.next_n(index) }); + } + + if DO_CHECK_PTR_RANGE && self.next_ctrl >= self.end { + return None; + } + + // We might read past self.end up to the next group boundary, + // but this is fine because it only occurs on tables smaller + // than the group size where the trailing control bytes are all + // EMPTY. On larger tables self.end is guaranteed to be aligned + // to the group size (since tables are power-of-two sized). + unsafe { + self.current_group = Group::load_aligned(self.next_ctrl.cast()) + .match_full() + .into_iter(); + self.data = self.data.next_n(Group::WIDTH); + self.next_ctrl = self.next_ctrl.add(Group::WIDTH); + } + } + } + + /// Folds every element into an accumulator by applying an operation, + /// returning the final result. + /// + /// `fold_impl()` takes three arguments: the number of items remaining in + /// the iterator, an initial value, and a closure with two arguments: an + /// 'accumulator', and an element. The closure returns the value that the + /// accumulator should have for the next iteration. + /// + /// The initial value is the value the accumulator will have on the first call. + /// + /// After applying this closure to every element of the iterator, `fold_impl()` + /// returns the accumulator. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is + /// [`Undefined Behavior`]: + /// + /// * The [`RawTableInner`] / [`RawTable`] must be alive and not moved, + /// i.e. table outlives the `RawIterRange`; + /// + /// * The provided `n` value must match the actual number of items + /// in the table. + /// + /// [`Undefined Behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[expect(clippy::while_let_on_iterator)] + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn fold_impl(mut self, mut n: usize, mut acc: B, mut f: F) -> B + where + F: FnMut(B, Bucket) -> B, + { + loop { + while let Some(index) = self.current_group.next() { + // The returned `index` will always be in the range `0..Group::WIDTH`, + // so that calling `self.data.next_n(index)` is safe (see detailed explanation below). + debug_assert!(n != 0); + let bucket = unsafe { self.data.next_n(index) }; + acc = f(acc, bucket); + n -= 1; + } + + if n == 0 { + return acc; + } + + // SAFETY: The caller of this function ensures that: + // + // 1. The provided `n` value matches the actual number of items in the table; + // 2. The table is alive and did not moved. + // + // Taking the above into account, we always stay within the bounds, because: + // + // 1. For tables smaller than the group width (self.num_buckets() <= Group::WIDTH), + // we will never end up in the given branch, since we should have already + // yielded all the elements of the table. + // + // 2. For tables larger than the group width. The number of buckets is a + // power of two (2 ^ n), Group::WIDTH is also power of two (2 ^ k). Since + // `(2 ^ n) > (2 ^ k)`, than `(2 ^ n) % (2 ^ k) = 0`. As we start from the + // start of the array of control bytes, and never try to iterate after + // getting all the elements, the last `self.current_group` will read bytes + // from the `self.num_buckets() - Group::WIDTH` index. We know also that + // `self.current_group.next()` will always return indices within the range + // `0..Group::WIDTH`. + // + // Knowing all of the above and taking into account that we are synchronizing + // the `self.data` index with the index we used to read the `self.current_group`, + // the subsequent `self.data.next_n(index)` will always return a bucket with + // an index number less than `self.num_buckets()`. + // + // The last `self.next_ctrl`, whose index would be `self.num_buckets()`, will never + // actually be read, since we should have already yielded all the elements of + // the table. + unsafe { + self.current_group = Group::load_aligned(self.next_ctrl.cast()) + .match_full() + .into_iter(); + self.data = self.data.next_n(Group::WIDTH); + self.next_ctrl = self.next_ctrl.add(Group::WIDTH); + } + } + } +} + +// We make raw iterators unconditionally Send and Sync, and let the PhantomData +// in the actual iterator implementations determine the real Send/Sync bounds. +unsafe impl Send for RawIterRange {} +unsafe impl Sync for RawIterRange {} + +impl Clone for RawIterRange { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + data: self.data.clone(), + next_ctrl: self.next_ctrl, + current_group: self.current_group.clone(), + end: self.end, + } + } +} + +impl Iterator for RawIterRange { + type Item = Bucket; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option> { + unsafe { + // SAFETY: We set checker flag to true. + self.next_impl::() + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + // We don't have an item count, so just guess based on the range size. + let remaining_buckets = if self.end > self.next_ctrl { + unsafe { offset_from(self.end, self.next_ctrl) } + } else { + 0 + }; + + // Add a group width to include the group we are currently processing. + (0, Some(Group::WIDTH + remaining_buckets)) + } +} + +impl FusedIterator for RawIterRange {} + +/// Iterator which returns a raw pointer to every full bucket in the table. +/// +/// For maximum flexibility this iterator is not bound by a lifetime, but you +/// must observe several rules when using it: +/// - You must not free the hash table while iterating (including via growing/shrinking). +/// - It is fine to erase a bucket that has been yielded by the iterator. +/// - Erasing a bucket that has not yet been yielded by the iterator may still +/// result in the iterator yielding that bucket (unless `reflect_remove` is called). +/// - It is unspecified whether an element inserted after the iterator was +/// created will be yielded by that iterator (unless `reflect_insert` is called). +/// - The order in which the iterator yields bucket is unspecified and may +/// change in the future. +pub(crate) struct RawIter { + pub(crate) iter: RawIterRange, + items: usize, +} + +impl RawIter { + unsafe fn drop_elements(&mut self) { + unsafe { + if T::NEEDS_DROP && self.items != 0 { + for item in self { + item.drop(); + } + } + } + } +} + +impl Clone for RawIter { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + iter: self.iter.clone(), + items: self.items, + } + } +} +impl Default for RawIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + // SAFETY: Because the table is static, it always outlives the iter. + unsafe { RawTableInner::NEW.iter() } + } +} + +impl Iterator for RawIter { + type Item = Bucket; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option> { + // Inner iterator iterates over buckets + // so it can do unnecessary work if we already yielded all items. + if self.items == 0 { + return None; + } + + let nxt = unsafe { + // SAFETY: We check number of items to yield using `items` field. + self.iter.next_impl::() + }; + + debug_assert!(nxt.is_some()); + self.items -= 1; + + nxt + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (self.items, Some(self.items)) + } + + #[inline] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + unsafe { self.iter.fold_impl(self.items, init, f) } + } +} + +impl ExactSizeIterator for RawIter {} +impl FusedIterator for RawIter {} + +/// Iterator which returns an index of every full bucket in the table. +/// +/// For maximum flexibility this iterator is not bound by a lifetime, but you +/// must observe several rules when using it: +/// - You must not free the hash table while iterating (including via growing/shrinking). +/// - It is fine to erase a bucket that has been yielded by the iterator. +/// - Erasing a bucket that has not yet been yielded by the iterator may still +/// result in the iterator yielding index of that bucket. +/// - It is unspecified whether an element inserted after the iterator was +/// created will be yielded by that iterator. +/// - The order in which the iterator yields indices of the buckets is unspecified +/// and may change in the future. +#[derive(Clone)] +pub(crate) struct FullBucketsIndices { + // Mask of full buckets in the current group. Bits are cleared from this + // mask as each element is processed. + current_group: BitMaskIter, + + // Initial value of the bytes' indices of the current group (relative + // to the start of the control bytes). + group_first_index: usize, + + // Pointer to the current group of control bytes, + // Must be aligned to the group size (Group::WIDTH). + ctrl: NonNull, + + // Number of elements in the table. + items: usize, +} + +impl Default for FullBucketsIndices { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + // SAFETY: Because the table is static, it always outlives the iter. + unsafe { RawTableInner::NEW.full_buckets_indices() } + } +} + +impl FullBucketsIndices { + /// Advances the iterator and returns the next value. + /// + /// # Safety + /// + /// If any of the following conditions are violated, the result is + /// [`Undefined Behavior`]: + /// + /// * The [`RawTableInner`] / [`RawTable`] must be alive and not moved, + /// i.e. table outlives the `FullBucketsIndices`; + /// + /// * It never tries to iterate after getting all elements. + /// + /// [`Undefined Behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + #[inline(always)] + unsafe fn next_impl(&mut self) -> Option { + loop { + if let Some(index) = self.current_group.next() { + // The returned `self.group_first_index + index` will always + // be in the range `0..self.num_buckets()`. See explanation below. + return Some(self.group_first_index + index); + } + + // SAFETY: The caller of this function ensures that: + // + // 1. It never tries to iterate after getting all the elements; + // 2. The table is alive and did not moved; + // 3. The first `self.ctrl` pointed to the start of the array of control bytes. + // + // Taking the above into account, we always stay within the bounds, because: + // + // 1. For tables smaller than the group width (self.num_buckets() <= Group::WIDTH), + // we will never end up in the given branch, since we should have already + // yielded all the elements of the table. + // + // 2. For tables larger than the group width. The number of buckets is a + // power of two (2 ^ n), Group::WIDTH is also power of two (2 ^ k). Since + // `(2 ^ n) > (2 ^ k)`, than `(2 ^ n) % (2 ^ k) = 0`. As we start from the + // the start of the array of control bytes, and never try to iterate after + // getting all the elements, the last `self.ctrl` will be equal to + // the `self.num_buckets() - Group::WIDTH`, so `self.current_group.next()` + // will always contains indices within the range `0..Group::WIDTH`, + // and subsequent `self.group_first_index + index` will always return a + // number less than `self.num_buckets()`. + unsafe { + self.ctrl = NonNull::new_unchecked(self.ctrl.as_ptr().add(Group::WIDTH)); + } + + // SAFETY: See explanation above. + unsafe { + self.current_group = Group::load_aligned(self.ctrl.as_ptr().cast()) + .match_full() + .into_iter(); + self.group_first_index += Group::WIDTH; + } + } + } +} + +impl Iterator for FullBucketsIndices { + type Item = usize; + + /// Advances the iterator and returns the next value. It is up to + /// the caller to ensure that the `RawTable` outlives the `FullBucketsIndices`, + /// because we cannot make the `next` method unsafe. + #[inline(always)] + fn next(&mut self) -> Option { + // Return if we already yielded all items. + if self.items == 0 { + return None; + } + + // SAFETY: + // 1. We check number of items to yield using `items` field. + // 2. The caller ensures that the table is alive and has not moved. + let nxt = unsafe { self.next_impl() }; + + debug_assert!(nxt.is_some()); + self.items -= 1; + + nxt + } + + #[inline(always)] + fn size_hint(&self) -> (usize, Option) { + (self.items, Some(self.items)) + } +} + +impl ExactSizeIterator for FullBucketsIndices {} +impl FusedIterator for FullBucketsIndices {} + +/// Iterator which consumes a table and returns elements. +pub(crate) struct RawIntoIter { + iter: RawIter, + allocation: Option<(NonNull, Layout, A)>, + marker: PhantomData, +} + +impl RawIntoIter { + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn iter(&self) -> RawIter { + self.iter.clone() + } +} + +unsafe impl Send for RawIntoIter +where + T: Send, + A: Send, +{ +} +unsafe impl Sync for RawIntoIter +where + T: Sync, + A: Sync, +{ +} + +#[cfg(feature = "nightly")] +unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawIntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + unsafe { + // Drop all remaining elements + self.iter.drop_elements(); + + // Free the table + if let Some((ptr, layout, ref alloc)) = self.allocation { + alloc.deallocate(ptr, layout); + } + } + } +} +#[cfg(not(feature = "nightly"))] +impl Drop for RawIntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + unsafe { + // Drop all remaining elements + self.iter.drop_elements(); + + // Free the table + if let Some((ptr, layout, ref alloc)) = self.allocation { + alloc.deallocate(ptr, layout); + } + } + } +} + +impl Default for RawIntoIter { + fn default() -> Self { + Self { + iter: Default::default(), + allocation: None, + marker: PhantomData, + } + } +} +impl Iterator for RawIntoIter { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + unsafe { Some(self.iter.next()?.read()) } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +impl ExactSizeIterator for RawIntoIter {} +impl FusedIterator for RawIntoIter {} + +/// Iterator which consumes elements without freeing the table storage. +pub(crate) struct RawDrain<'a, T, A: Allocator = Global> { + iter: RawIter, + + // The table is moved into the iterator for the duration of the drain. This + // ensures that an empty table is left if the drain iterator is leaked + // without dropping. + table: RawTableInner, + orig_table: NonNull, + + // We don't use a &'a mut RawTable because we want RawDrain to be + // covariant over T. + marker: PhantomData<&'a RawTable>, +} + +impl RawDrain<'_, T, A> { + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn iter(&self) -> RawIter { + self.iter.clone() + } +} + +unsafe impl Send for RawDrain<'_, T, A> +where + T: Send, + A: Send, +{ +} +unsafe impl Sync for RawDrain<'_, T, A> +where + T: Sync, + A: Sync, +{ +} + +impl Drop for RawDrain<'_, T, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn drop(&mut self) { + unsafe { + // Drop all remaining elements. Note that this may panic. + self.iter.drop_elements(); + + // Reset the contents of the table now that all elements have been + // dropped. + self.table.clear_no_drop(); + + // Move the now empty table back to its original location. + self.orig_table + .as_ptr() + .copy_from_nonoverlapping(&raw const self.table, 1); + } + } +} + +impl Iterator for RawDrain<'_, T, A> { + type Item = T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + unsafe { + let item = self.iter.next()?; + Some(item.read()) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +impl ExactSizeIterator for RawDrain<'_, T, A> {} +impl FusedIterator for RawDrain<'_, T, A> {} + +/// Iterator over occupied buckets that could match a given hash. +/// +/// `RawTable` only stores 7 bits of the hash value, so this iterator may return +/// items that have a hash value different than the one provided. You should +/// always validate the returned values before using them. +/// +/// For maximum flexibility this iterator is not bound by a lifetime, but you +/// must observe several rules when using it: +/// - You must not free the hash table while iterating (including via growing/shrinking). +/// - It is fine to erase a bucket that has been yielded by the iterator. +/// - Erasing a bucket that has not yet been yielded by the iterator may still +/// result in the iterator yielding that bucket. +/// - It is unspecified whether an element inserted after the iterator was +/// created will be yielded by that iterator. +/// - The order in which the iterator yields buckets is unspecified and may +/// change in the future. +pub(crate) struct RawIterHash { + inner: RawIterHashIndices, + _marker: PhantomData, +} + +#[derive(Clone)] +pub(crate) struct RawIterHashIndices { + // See `RawTableInner`'s corresponding fields for details. + // We can't store a `*const RawTableInner` as it would get + // invalidated by the user calling `&mut` methods on `RawTable`. + bucket_mask: usize, + ctrl: NonNull, + + // The top 7 bits of the hash. + tag_hash: Tag, + + // The sequence of groups to probe in the search. + probe_seq: ProbeSeq, + + group: Group, + + // The elements within the group with a matching tag-hash. + bitmask: BitMaskIter, +} + +impl RawIterHash { + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn new(table: &RawTable, hash: u64) -> Self { + RawIterHash { + inner: unsafe { RawIterHashIndices::new(&table.table, hash) }, + _marker: PhantomData, + } + } +} + +impl Clone for RawIterHash { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + _marker: PhantomData, + } + } +} + +impl Default for RawIterHash { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: RawIterHashIndices::default(), + _marker: PhantomData, + } + } +} + +impl Default for RawIterHashIndices { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + // SAFETY: Because the table is static, it always outlives the iter. + unsafe { RawIterHashIndices::new(&RawTableInner::NEW, 0) } + } +} + +impl RawIterHashIndices { + #[cfg_attr(feature = "inline-more", inline)] + unsafe fn new(table: &RawTableInner, hash: u64) -> Self { + let tag_hash = Tag::full(hash); + let probe_seq = table.probe_seq(hash); + let group = unsafe { Group::load(table.ctrl(probe_seq.pos)) }; + let bitmask = group.match_tag(tag_hash).into_iter(); + + RawIterHashIndices { + bucket_mask: table.bucket_mask, + ctrl: table.ctrl, + tag_hash, + probe_seq, + group, + bitmask, + } + } +} + +impl Iterator for RawIterHash { + type Item = Bucket; + + fn next(&mut self) -> Option> { + unsafe { + match self.inner.next() { + Some(index) => { + // Can't use `RawTable::bucket` here as we don't have + // an actual `RawTable` reference to use. + debug_assert!(index <= self.inner.bucket_mask); + let bucket = Bucket::from_base_index(self.inner.ctrl.cast(), index); + Some(bucket) + } + None => None, + } + } + } +} + +impl Iterator for RawIterHashIndices { + type Item = usize; + + fn next(&mut self) -> Option { + unsafe { + loop { + if let Some(bit) = self.bitmask.next() { + let index = (self.probe_seq.pos + bit) & self.bucket_mask; + return Some(index); + } + if likely(self.group.match_empty().any_bit_set()) { + return None; + } + self.probe_seq.move_next(self.bucket_mask); + + // Can't use `RawTableInner::ctrl` here as we don't have + // an actual `RawTableInner` reference to use. + let index = self.probe_seq.pos; + debug_assert!(index < self.bucket_mask + 1 + Group::WIDTH); + let group_ctrl = self.ctrl.as_ptr().add(index).cast(); + + self.group = Group::load(group_ctrl); + self.bitmask = self.group.match_tag(self.tag_hash).into_iter(); + } + } + } +} + +pub(crate) struct RawExtractIf<'a, T, A: Allocator> { + pub iter: RawIter, + pub table: &'a mut RawTable, +} + +impl RawExtractIf<'_, T, A> { + #[cfg_attr(feature = "inline-more", inline)] + pub(crate) fn next(&mut self, mut f: F) -> Option + where + F: FnMut(&mut T) -> bool, + { + unsafe { + for item in &mut self.iter { + if f(item.as_mut()) { + return Some(self.table.remove(item).0); + } + } + } + None + } +} + +#[cfg(test)] +mod test_map { + use super::*; + + #[test] + fn test_prev_pow2() { + // Skip 0, not defined for that input. + let mut pow2: usize = 1; + while (pow2 << 1) > 0 { + let next_pow2 = pow2 << 1; + assert_eq!(pow2, prev_pow2(pow2)); + // Need to skip 2, because it's also a power of 2, so it doesn't + // return the previous power of 2. + if next_pow2 > 2 { + assert_eq!(pow2, prev_pow2(pow2 + 1)); + assert_eq!(pow2, prev_pow2(next_pow2 - 1)); + } + pow2 = next_pow2; + } + } + + #[test] + fn test_minimum_capacity_for_small_types() { + #[track_caller] + fn test_t() { + let raw_table: RawTable = RawTable::with_capacity(1); + let actual_buckets = raw_table.num_buckets(); + let min_buckets = Group::WIDTH / size_of::(); + assert!( + actual_buckets >= min_buckets, + "expected at least {min_buckets} buckets, got {actual_buckets} buckets" + ); + } + + test_t::(); + + // This is only "small" for some platforms, like x86_64 with SSE2, but + // there's no harm in running it on other platforms. + test_t::(); + } + + fn rehash_in_place(table: &mut RawTable, hasher: impl Fn(&T) -> u64) { + unsafe { + table.table.rehash_in_place( + &|table, index| hasher(table.bucket::(index).as_ref()), + size_of::(), + if mem::needs_drop::() { + Some(|ptr| ptr::drop_in_place(ptr.cast::())) + } else { + None + }, + ); + } + } + + #[test] + fn rehash() { + let mut table = RawTable::new(); + let hasher = |i: &u64| *i; + for i in 0..100 { + table.insert(i, i, hasher); + } + + for i in 0..100 { + unsafe { + assert_eq!(table.find(i, |x| *x == i).map(|b| b.read()), Some(i)); + } + assert!(table.find(i + 100, |x| *x == i + 100).is_none()); + } + + rehash_in_place(&mut table, hasher); + + for i in 0..100 { + unsafe { + assert_eq!(table.find(i, |x| *x == i).map(|b| b.read()), Some(i)); + } + assert!(table.find(i + 100, |x| *x == i + 100).is_none()); + } + } + + /// CHECKING THAT WE ARE NOT TRYING TO READ THE MEMORY OF + /// AN UNINITIALIZED TABLE DURING THE DROP + #[test] + fn test_drop_uninitialized() { + use stdalloc::vec::Vec; + + let table = unsafe { + // SAFETY: The `buckets` is power of two and we're not + // trying to actually use the returned RawTable. + RawTable::<(u64, Vec)>::new_uninitialized(Global, 8, Fallibility::Infallible) + .unwrap() + }; + drop(table); + } + + /// CHECKING THAT WE DON'T TRY TO DROP DATA IF THE `ITEMS` + /// ARE ZERO, EVEN IF WE HAVE `FULL` CONTROL BYTES. + #[test] + fn test_drop_zero_items() { + use stdalloc::vec::Vec; + unsafe { + // SAFETY: The `buckets` is power of two and we're not + // trying to actually use the returned RawTable. + let mut table = + RawTable::<(u64, Vec)>::new_uninitialized(Global, 8, Fallibility::Infallible) + .unwrap(); + + // WE SIMULATE, AS IT WERE, A FULL TABLE. + + // SAFETY: We checked that the table is allocated and therefore the table already has + // `self.bucket_mask + 1 + Group::WIDTH` number of control bytes (see TableLayout::calculate_layout_for) + // so writing `table.table.num_ctrl_bytes() == bucket_mask + 1 + Group::WIDTH` bytes is safe. + table.table.ctrl_slice().fill_empty(); + + // SAFETY: table.capacity() is guaranteed to be smaller than table.num_buckets() + table.table.ctrl(0).write_bytes(0, table.capacity()); + + // Fix up the trailing control bytes. See the comments in set_ctrl + // for the handling of tables smaller than the group width. + if table.num_buckets() < Group::WIDTH { + // SAFETY: We have `self.bucket_mask + 1 + Group::WIDTH` number of control bytes, + // so copying `self.num_buckets() == self.bucket_mask + 1` bytes with offset equal to + // `Group::WIDTH` is safe + table + .table + .ctrl(0) + .copy_to(table.table.ctrl(Group::WIDTH), table.table.num_buckets()); + } else { + // SAFETY: We have `self.bucket_mask + 1 + Group::WIDTH` number of + // control bytes,so copying `Group::WIDTH` bytes with offset equal + // to `self.num_buckets() == self.bucket_mask + 1` is safe + table + .table + .ctrl(0) + .copy_to(table.table.ctrl(table.table.num_buckets()), Group::WIDTH); + } + drop(table); + } + } + + /// CHECKING THAT WE DON'T TRY TO DROP DATA IF THE `ITEMS` + /// ARE ZERO, EVEN IF WE HAVE `FULL` CONTROL BYTES. + #[test] + #[cfg(panic = "unwind")] + fn test_catch_panic_clone_from() { + use super::{AllocError, Allocator, Global}; + use core::sync::atomic::{AtomicI8, Ordering}; + use std::thread; + use stdalloc::sync::Arc; + use stdalloc::vec::Vec; + + struct MyAllocInner { + drop_count: Arc, + } + + #[derive(Clone)] + struct MyAlloc { + _inner: Arc, + } + + impl Drop for MyAllocInner { + fn drop(&mut self) { + println!("MyAlloc freed."); + self.drop_count.fetch_sub(1, Ordering::SeqCst); + } + } + + unsafe impl Allocator for MyAlloc { + fn allocate(&self, layout: Layout) -> Result, AllocError> { + let g = Global; + g.allocate(layout) + } + + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + unsafe { + let g = Global; + g.deallocate(ptr, layout); + } + } + } + + const DISARMED: bool = false; + const ARMED: bool = true; + + struct CheckedCloneDrop { + panic_in_clone: bool, + dropped: bool, + need_drop: Vec, + } + + impl Clone for CheckedCloneDrop { + fn clone(&self) -> Self { + assert!(!self.panic_in_clone, "panic in clone"); + Self { + panic_in_clone: self.panic_in_clone, + dropped: self.dropped, + need_drop: self.need_drop.clone(), + } + } + } + + impl Drop for CheckedCloneDrop { + fn drop(&mut self) { + assert!(!self.dropped, "double drop"); + self.dropped = true; + } + } + + let dropped: Arc = Arc::new(AtomicI8::new(2)); + + let mut table = RawTable::new_in(MyAlloc { + _inner: Arc::new(MyAllocInner { + drop_count: dropped.clone(), + }), + }); + + for (idx, panic_in_clone) in core::iter::repeat_n(DISARMED, 7).enumerate() { + let idx = idx as u64; + table.insert( + idx, + ( + idx, + CheckedCloneDrop { + panic_in_clone, + dropped: false, + need_drop: vec![idx], + }, + ), + |(k, _)| *k, + ); + } + + assert_eq!(table.len(), 7); + + thread::scope(|s| { + let result = s.spawn(|| { + let armed_flags = [ + DISARMED, DISARMED, ARMED, DISARMED, DISARMED, DISARMED, DISARMED, + ]; + let mut scope_table = RawTable::new_in(MyAlloc { + _inner: Arc::new(MyAllocInner { + drop_count: dropped.clone(), + }), + }); + for (idx, &panic_in_clone) in armed_flags.iter().enumerate() { + let idx = idx as u64; + scope_table.insert( + idx, + ( + idx, + CheckedCloneDrop { + panic_in_clone, + dropped: false, + need_drop: vec![idx + 100], + }, + ), + |(k, _)| *k, + ); + } + table.clone_from(&scope_table); + }); + assert!(result.join().is_err()); + }); + + // Let's check that all iterators work fine and do not return elements + // (especially `RawIterRange`, which does not depend on the number of + // elements in the table, but looks directly at the control bytes) + // + // SAFETY: We know for sure that `RawTable` will outlive + // the returned `RawIter / RawIterRange` iterator. + assert_eq!(table.len(), 0); + assert_eq!(unsafe { table.iter().count() }, 0); + assert_eq!(unsafe { table.iter().iter.count() }, 0); + + for idx in 0..table.num_buckets() { + let idx = idx as u64; + assert!( + table.find(idx, |(k, _)| *k == idx).is_none(), + "Index: {idx}" + ); + } + + // All allocator clones should already be dropped. + assert_eq!(dropped.load(Ordering::SeqCst), 1); + } +} diff --git a/library/hashbrown/src/raw_entry.rs b/library/hashbrown/src/raw_entry.rs new file mode 100644 index 0000000000000..13b71bc3e1fbf --- /dev/null +++ b/library/hashbrown/src/raw_entry.rs @@ -0,0 +1,1729 @@ +use crate::Equivalent; +use crate::alloc::{Allocator, Global}; +use crate::map::{HashMap, equivalent, make_hash, make_hasher}; +use crate::raw::{Bucket, RawTable}; +use core::fmt::{self, Debug}; +use core::hash::{BuildHasher, Hash}; +use core::mem; + +impl HashMap { + /// Creates a raw entry builder for the `HashMap`. + /// + /// Raw entries provide the lowest level of control for searching and + /// manipulating a map. They must be manually initialized with a hash and + /// then manually searched. After this, insertions into a vacant entry + /// still require an owned key to be provided. + /// + /// Raw entries are useful for such exotic situations as: + /// + /// * Hash memoization + /// * Deferring the creation of an owned key until it is known to be required + /// * Using a search key that doesn't work with the Borrow trait + /// * Using custom comparison logic without newtype wrappers + /// + /// Because raw entries provide much more low-level control, it's much easier + /// to put the `HashMap` into an inconsistent state which, while memory-safe, + /// will cause the map to produce seemingly random results. Higher-level and + /// more foolproof APIs like `entry` should be preferred when possible. + /// + /// In particular, the hash used to initialized the raw entry must still be + /// consistent with the hash of the key that is ultimately stored in the entry. + /// This is because implementations of `HashMap` may need to recompute hashes + /// when resizing, at which point only the keys are available. + /// + /// Raw entries give mutable access to the keys. This must not be used + /// to modify how the key would compare or hash, as the map will not re-evaluate + /// where the key should go, meaning the keys may become "lost" if their + /// location does not reflect their state. For instance, if you change a key + /// so that the map now contains keys which compare equal, search may start + /// acting erratically, with two keys randomly masking each other. Implementations + /// are free to assume this doesn't happen (within the limits of memory-safety). + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map = HashMap::new(); + /// map.extend([("a", 100), ("b", 200), ("c", 300)]); + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// // Existing key (insert and update) + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => unreachable!(), + /// RawEntryMut::Occupied(mut view) => { + /// assert_eq!(view.get(), &100); + /// let v = view.get_mut(); + /// let new_v = (*v) * 10; + /// *v = new_v; + /// assert_eq!(view.insert(1111), 1000); + /// } + /// } + /// + /// assert_eq!(map[&"a"], 1111); + /// assert_eq!(map.len(), 3); + /// + /// // Existing key (take) + /// let hash = compute_hash(map.hasher(), &"c"); + /// match map.raw_entry_mut().from_key_hashed_nocheck(hash, &"c") { + /// RawEntryMut::Vacant(_) => unreachable!(), + /// RawEntryMut::Occupied(view) => { + /// assert_eq!(view.remove_entry(), ("c", 300)); + /// } + /// } + /// assert_eq!(map.raw_entry().from_key(&"c"), None); + /// assert_eq!(map.len(), 2); + /// + /// // Nonexistent key (insert and update) + /// let key = "d"; + /// let hash = compute_hash(map.hasher(), &key); + /// match map.raw_entry_mut().from_hash(hash, |q| *q == key) { + /// RawEntryMut::Occupied(_) => unreachable!(), + /// RawEntryMut::Vacant(view) => { + /// let (k, value) = view.insert("d", 4000); + /// assert_eq!((*k, *value), ("d", 4000)); + /// *value = 40000; + /// } + /// } + /// assert_eq!(map[&"d"], 40000); + /// assert_eq!(map.len(), 3); + /// + /// match map.raw_entry_mut().from_hash(hash, |q| *q == key) { + /// RawEntryMut::Vacant(_) => unreachable!(), + /// RawEntryMut::Occupied(view) => { + /// assert_eq!(view.remove_entry(), ("d", 40000)); + /// } + /// } + /// assert_eq!(map.get(&"d"), None); + /// assert_eq!(map.len(), 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S, A> { + RawEntryBuilderMut { map: self } + } + + /// Creates a raw immutable entry builder for the `HashMap`. + /// + /// Raw entries provide the lowest level of control for searching and + /// manipulating a map. They must be manually initialized with a hash and + /// then manually searched. + /// + /// This is useful for + /// * Hash memoization + /// * Using a search key that doesn't work with the Borrow trait + /// * Using custom comparison logic without newtype wrappers + /// + /// Unless you are in such a situation, higher-level and more foolproof APIs like + /// `get` should be preferred. + /// + /// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::HashMap; + /// + /// let mut map = HashMap::new(); + /// map.extend([("a", 100), ("b", 200), ("c", 300)]); + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// for k in ["a", "b", "c", "d", "e", "f"] { + /// let hash = compute_hash(map.hasher(), k); + /// let v = map.get(&k).cloned(); + /// let kv = v.as_ref().map(|v| (&k, v)); + /// + /// println!("Key: {} and value: {:?}", k, v); + /// + /// assert_eq!(map.raw_entry().from_key(&k), kv); + /// assert_eq!(map.raw_entry().from_hash(hash, |q| *q == k), kv); + /// assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash, &k), kv); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S, A> { + RawEntryBuilder { map: self } + } +} + +/// A builder for computing where in a [`HashMap`] a key-value pair would be stored. +/// +/// See the [`HashMap::raw_entry_mut`] docs for usage examples. +/// +/// [`HashMap::raw_entry_mut`]: HashMap::raw_entry_mut +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{RawEntryBuilderMut, RawEntryMut::Vacant, RawEntryMut::Occupied}; +/// use hashbrown::HashMap; +/// use core::hash::{BuildHasher, Hash}; +/// +/// let mut map = HashMap::new(); +/// map.extend([(1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16)]); +/// assert_eq!(map.len(), 6); +/// +/// fn compute_hash(hash_builder: &S, key: &K) -> u64 { +/// use core::hash::Hasher; +/// let mut state = hash_builder.build_hasher(); +/// key.hash(&mut state); +/// state.finish() +/// } +/// +/// let builder: RawEntryBuilderMut<_, _, _> = map.raw_entry_mut(); +/// +/// // Existing key +/// match builder.from_key(&6) { +/// Vacant(_) => unreachable!(), +/// Occupied(view) => assert_eq!(view.get(), &16), +/// } +/// +/// for key in 0..12 { +/// let hash = compute_hash(map.hasher(), &key); +/// let value = map.get(&key).cloned(); +/// let key_value = value.as_ref().map(|v| (&key, v)); +/// +/// println!("Key: {} and value: {:?}", key, value); +/// +/// match map.raw_entry_mut().from_key(&key) { +/// Occupied(mut o) => assert_eq!(Some(o.get_key_value()), key_value), +/// Vacant(_) => assert_eq!(value, None), +/// } +/// match map.raw_entry_mut().from_key_hashed_nocheck(hash, &key) { +/// Occupied(mut o) => assert_eq!(Some(o.get_key_value()), key_value), +/// Vacant(_) => assert_eq!(value, None), +/// } +/// match map.raw_entry_mut().from_hash(hash, |q| *q == key) { +/// Occupied(mut o) => assert_eq!(Some(o.get_key_value()), key_value), +/// Vacant(_) => assert_eq!(value, None), +/// } +/// } +/// +/// assert_eq!(map.len(), 6); +/// ``` +pub struct RawEntryBuilderMut<'a, K, V, S, A: Allocator = Global> { + map: &'a mut HashMap, +} + +/// A view into a single entry in a map, which may either be vacant or occupied. +/// +/// This is a lower-level version of [`Entry`]. +/// +/// [`Entry`]: crate::hash_map::Entry +/// +/// This `enum` is constructed through the [`raw_entry_mut`] method on [`HashMap`], +/// then calling one of the methods of that [`RawEntryBuilderMut`]. +/// +/// [`raw_entry_mut`]: HashMap::raw_entry_mut +/// +/// # Examples +/// +/// ``` +/// use core::hash::{BuildHasher, Hash}; +/// use hashbrown::hash_map::{HashMap, RawEntryMut, RawOccupiedEntryMut}; +/// +/// let mut map = HashMap::new(); +/// map.extend([('a', 1), ('b', 2), ('c', 3)]); +/// assert_eq!(map.len(), 3); +/// +/// fn compute_hash(hash_builder: &S, key: &K) -> u64 { +/// use core::hash::Hasher; +/// let mut state = hash_builder.build_hasher(); +/// key.hash(&mut state); +/// state.finish() +/// } +/// +/// // Existing key (insert) +/// let raw: RawEntryMut<_, _, _> = map.raw_entry_mut().from_key(&'a'); +/// let _raw_o: RawOccupiedEntryMut<_, _, _> = raw.insert('a', 10); +/// assert_eq!(map.len(), 3); +/// +/// // Nonexistent key (insert) +/// map.raw_entry_mut().from_key(&'d').insert('d', 40); +/// assert_eq!(map.len(), 4); +/// +/// // Existing key (or_insert) +/// let hash = compute_hash(map.hasher(), &'b'); +/// let kv = map +/// .raw_entry_mut() +/// .from_key_hashed_nocheck(hash, &'b') +/// .or_insert('b', 20); +/// assert_eq!(kv, (&mut 'b', &mut 2)); +/// *kv.1 = 20; +/// assert_eq!(map.len(), 4); +/// +/// // Nonexistent key (or_insert) +/// let hash = compute_hash(map.hasher(), &'e'); +/// let kv = map +/// .raw_entry_mut() +/// .from_key_hashed_nocheck(hash, &'e') +/// .or_insert('e', 50); +/// assert_eq!(kv, (&mut 'e', &mut 50)); +/// assert_eq!(map.len(), 5); +/// +/// // Existing key (or_insert_with) +/// let hash = compute_hash(map.hasher(), &'c'); +/// let kv = map +/// .raw_entry_mut() +/// .from_hash(hash, |q| q == &'c') +/// .or_insert_with(|| ('c', 30)); +/// assert_eq!(kv, (&mut 'c', &mut 3)); +/// *kv.1 = 30; +/// assert_eq!(map.len(), 5); +/// +/// // Nonexistent key (or_insert_with) +/// let hash = compute_hash(map.hasher(), &'f'); +/// let kv = map +/// .raw_entry_mut() +/// .from_hash(hash, |q| q == &'f') +/// .or_insert_with(|| ('f', 60)); +/// assert_eq!(kv, (&mut 'f', &mut 60)); +/// assert_eq!(map.len(), 6); +/// +/// println!("Our HashMap: {:?}", map); +/// +/// let mut vec: Vec<_> = map.iter().map(|(&k, &v)| (k, v)).collect(); +/// // The `Iter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, [('a', 10), ('b', 20), ('c', 30), ('d', 40), ('e', 50), ('f', 60)]); +/// ``` +pub enum RawEntryMut<'a, K, V, S, A: Allocator = Global> { + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::{hash_map::RawEntryMut, HashMap}; + /// let mut map: HashMap<_, _> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => unreachable!(), + /// RawEntryMut::Occupied(_) => { } + /// } + /// ``` + Occupied(RawOccupiedEntryMut<'a, K, V, S, A>), + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::{hash_map::RawEntryMut, HashMap}; + /// let mut map: HashMap<&str, i32> = HashMap::new(); + /// + /// match map.raw_entry_mut().from_key("a") { + /// RawEntryMut::Occupied(_) => unreachable!(), + /// RawEntryMut::Vacant(_) => { } + /// } + /// ``` + Vacant(RawVacantEntryMut<'a, K, V, S, A>), +} + +/// A view into an occupied entry in a `HashMap`. +/// It is part of the [`RawEntryMut`] enum. +/// +/// # Examples +/// +/// ``` +/// use core::hash::{BuildHasher, Hash}; +/// use hashbrown::hash_map::{HashMap, RawEntryMut, RawOccupiedEntryMut}; +/// +/// let mut map = HashMap::new(); +/// map.extend([("a", 10), ("b", 20), ("c", 30)]); +/// +/// fn compute_hash(hash_builder: &S, key: &K) -> u64 { +/// use core::hash::Hasher; +/// let mut state = hash_builder.build_hasher(); +/// key.hash(&mut state); +/// state.finish() +/// } +/// +/// let _raw_o: RawOccupiedEntryMut<_, _, _> = map.raw_entry_mut().from_key(&"a").insert("a", 100); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (insert and update) +/// match map.raw_entry_mut().from_key(&"a") { +/// RawEntryMut::Vacant(_) => unreachable!(), +/// RawEntryMut::Occupied(mut view) => { +/// assert_eq!(view.get(), &100); +/// let v = view.get_mut(); +/// let new_v = (*v) * 10; +/// *v = new_v; +/// assert_eq!(view.insert(1111), 1000); +/// } +/// } +/// +/// assert_eq!(map[&"a"], 1111); +/// assert_eq!(map.len(), 3); +/// +/// // Existing key (take) +/// let hash = compute_hash(map.hasher(), &"c"); +/// match map.raw_entry_mut().from_key_hashed_nocheck(hash, &"c") { +/// RawEntryMut::Vacant(_) => unreachable!(), +/// RawEntryMut::Occupied(view) => { +/// assert_eq!(view.remove_entry(), ("c", 30)); +/// } +/// } +/// assert_eq!(map.raw_entry().from_key(&"c"), None); +/// assert_eq!(map.len(), 2); +/// +/// let hash = compute_hash(map.hasher(), &"b"); +/// match map.raw_entry_mut().from_hash(hash, |q| *q == "b") { +/// RawEntryMut::Vacant(_) => unreachable!(), +/// RawEntryMut::Occupied(view) => { +/// assert_eq!(view.remove_entry(), ("b", 20)); +/// } +/// } +/// assert_eq!(map.get(&"b"), None); +/// assert_eq!(map.len(), 1); +/// ``` +pub struct RawOccupiedEntryMut<'a, K, V, S, A: Allocator = Global> { + elem: Bucket<(K, V)>, + table: &'a mut RawTable<(K, V), A>, + hash_builder: &'a S, +} + +unsafe impl Send for RawOccupiedEntryMut<'_, K, V, S, A> +where + K: Send, + V: Send, + S: Send, + A: Send + Allocator, +{ +} +unsafe impl Sync for RawOccupiedEntryMut<'_, K, V, S, A> +where + K: Sync, + V: Sync, + S: Sync, + A: Sync + Allocator, +{ +} + +/// A view into a vacant entry in a `HashMap`. +/// It is part of the [`RawEntryMut`] enum. +/// +/// # Examples +/// +/// ``` +/// use core::hash::{BuildHasher, Hash}; +/// use hashbrown::hash_map::{HashMap, RawEntryMut, RawVacantEntryMut}; +/// +/// let mut map = HashMap::<&str, i32>::new(); +/// +/// fn compute_hash(hash_builder: &S, key: &K) -> u64 { +/// use core::hash::Hasher; +/// let mut state = hash_builder.build_hasher(); +/// key.hash(&mut state); +/// state.finish() +/// } +/// +/// let raw_v: RawVacantEntryMut<_, _, _> = match map.raw_entry_mut().from_key(&"a") { +/// RawEntryMut::Vacant(view) => view, +/// RawEntryMut::Occupied(_) => unreachable!(), +/// }; +/// raw_v.insert("a", 10); +/// assert!(map[&"a"] == 10 && map.len() == 1); +/// +/// // Nonexistent key (insert and update) +/// let hash = compute_hash(map.hasher(), &"b"); +/// match map.raw_entry_mut().from_key_hashed_nocheck(hash, &"b") { +/// RawEntryMut::Occupied(_) => unreachable!(), +/// RawEntryMut::Vacant(view) => { +/// let (k, value) = view.insert("b", 2); +/// assert_eq!((*k, *value), ("b", 2)); +/// *value = 20; +/// } +/// } +/// assert!(map[&"b"] == 20 && map.len() == 2); +/// +/// let hash = compute_hash(map.hasher(), &"c"); +/// match map.raw_entry_mut().from_hash(hash, |q| *q == "c") { +/// RawEntryMut::Occupied(_) => unreachable!(), +/// RawEntryMut::Vacant(view) => { +/// assert_eq!(view.insert("c", 30), (&mut "c", &mut 30)); +/// } +/// } +/// assert!(map[&"c"] == 30 && map.len() == 3); +/// ``` +pub struct RawVacantEntryMut<'a, K, V, S, A: Allocator = Global> { + table: &'a mut RawTable<(K, V), A>, + hash_builder: &'a S, +} + +/// A builder for computing where in a [`HashMap`] a key-value pair would be stored. +/// +/// See the [`HashMap::raw_entry`] docs for usage examples. +/// +/// [`HashMap::raw_entry`]: HashMap::raw_entry +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_map::{HashMap, RawEntryBuilder}; +/// use core::hash::{BuildHasher, Hash}; +/// +/// let mut map = HashMap::new(); +/// map.extend([(1, 10), (2, 20), (3, 30)]); +/// +/// fn compute_hash(hash_builder: &S, key: &K) -> u64 { +/// use core::hash::Hasher; +/// let mut state = hash_builder.build_hasher(); +/// key.hash(&mut state); +/// state.finish() +/// } +/// +/// for k in 0..6 { +/// let hash = compute_hash(map.hasher(), &k); +/// let v = map.get(&k).cloned(); +/// let kv = v.as_ref().map(|v| (&k, v)); +/// +/// println!("Key: {} and value: {:?}", k, v); +/// let builder: RawEntryBuilder<_, _, _> = map.raw_entry(); +/// assert_eq!(builder.from_key(&k), kv); +/// assert_eq!(map.raw_entry().from_hash(hash, |q| *q == k), kv); +/// assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash, &k), kv); +/// } +/// ``` +pub struct RawEntryBuilder<'a, K, V, S, A: Allocator = Global> { + map: &'a HashMap, +} + +impl<'a, K, V, S, A: Allocator> RawEntryBuilderMut<'a, K, V, S, A> { + /// Creates a `RawEntryMut` from the given key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let key = "a"; + /// let entry: RawEntryMut<&str, u32, _> = map.raw_entry_mut().from_key(&key); + /// entry.insert(key, 100); + /// assert_eq!(map[&"a"], 100); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn from_key(self, k: &Q) -> RawEntryMut<'a, K, V, S, A> + where + S: BuildHasher, + Q: Hash + Equivalent + ?Sized, + { + let hash = make_hash::(&self.map.hash_builder, k); + self.from_key_hashed_nocheck(hash, k) + } + + /// Creates a `RawEntryMut` from the given key and its hash. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let key = "a"; + /// let hash = compute_hash(map.hasher(), &key); + /// let entry: RawEntryMut<&str, u32, _> = map.raw_entry_mut().from_key_hashed_nocheck(hash, &key); + /// entry.insert(key, 100); + /// assert_eq!(map[&"a"], 100); + /// ``` + #[inline] + pub fn from_key_hashed_nocheck(self, hash: u64, k: &Q) -> RawEntryMut<'a, K, V, S, A> + where + Q: Equivalent + ?Sized, + { + self.from_hash(hash, equivalent(k)) + } +} + +impl<'a, K, V, S, A: Allocator> RawEntryBuilderMut<'a, K, V, S, A> { + /// Creates a `RawEntryMut` from the given hash and matching function. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let key = "a"; + /// let hash = compute_hash(map.hasher(), &key); + /// let entry: RawEntryMut<&str, u32, _> = map.raw_entry_mut().from_hash(hash, |k| k == &key); + /// entry.insert(key, 100); + /// assert_eq!(map[&"a"], 100); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn from_hash(self, hash: u64, is_match: F) -> RawEntryMut<'a, K, V, S, A> + where + for<'b> F: FnMut(&'b K) -> bool, + { + self.search(hash, is_match) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn search(self, hash: u64, mut is_match: F) -> RawEntryMut<'a, K, V, S, A> + where + for<'b> F: FnMut(&'b K) -> bool, + { + match self.map.table.find(hash, |(k, _)| is_match(k)) { + Some(elem) => RawEntryMut::Occupied(RawOccupiedEntryMut { + elem, + table: &mut self.map.table, + hash_builder: &self.map.hash_builder, + }), + None => RawEntryMut::Vacant(RawVacantEntryMut { + table: &mut self.map.table, + hash_builder: &self.map.hash_builder, + }), + } + } +} + +impl<'a, K, V, S, A: Allocator> RawEntryBuilder<'a, K, V, S, A> { + /// Access an immutable entry by key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// let key = "a"; + /// assert_eq!(map.raw_entry().from_key(&key), Some((&"a", &100))); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn from_key(self, k: &Q) -> Option<(&'a K, &'a V)> + where + S: BuildHasher, + Q: Hash + Equivalent + ?Sized, + { + let hash = make_hash::(&self.map.hash_builder, k); + self.from_key_hashed_nocheck(hash, k) + } + + /// Access an immutable entry by a key and its hash. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::HashMap; + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// let map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// let key = "a"; + /// let hash = compute_hash(map.hasher(), &key); + /// assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash, &key), Some((&"a", &100))); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn from_key_hashed_nocheck(self, hash: u64, k: &Q) -> Option<(&'a K, &'a V)> + where + Q: Equivalent + ?Sized, + { + self.from_hash(hash, equivalent(k)) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn search(self, hash: u64, mut is_match: F) -> Option<(&'a K, &'a V)> + where + F: FnMut(&K) -> bool, + { + match self.map.table.get(hash, |(k, _)| is_match(k)) { + Some((key, value)) => Some((key, value)), + None => None, + } + } + + /// Access an immutable entry by hash and matching function. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::HashMap; + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// let map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// let key = "a"; + /// let hash = compute_hash(map.hasher(), &key); + /// assert_eq!(map.raw_entry().from_hash(hash, |k| k == &key), Some((&"a", &100))); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn from_hash(self, hash: u64, is_match: F) -> Option<(&'a K, &'a V)> + where + F: FnMut(&K) -> bool, + { + self.search(hash, is_match) + } +} + +impl<'a, K, V, S, A: Allocator> RawEntryMut<'a, K, V, S, A> { + /// Sets the value of the entry, and returns a `RawOccupiedEntryMut`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let entry = map.raw_entry_mut().from_key("horseyland").insert("horseyland", 37); + /// + /// assert_eq!(entry.remove_entry(), ("horseyland", 37)); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, key: K, value: V) -> RawOccupiedEntryMut<'a, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + match self { + RawEntryMut::Occupied(mut entry) => { + entry.insert(value); + entry + } + RawEntryMut::Vacant(entry) => entry.insert_entry(key, value), + } + } + + /// Ensures a value is in the entry by inserting the default if empty, and returns + /// mutable references to the key and value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 3); + /// assert_eq!(map["poneyland"], 3); + /// + /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert(self, default_key: K, default_val: V) -> (&'a mut K, &'a mut V) + where + K: Hash, + S: BuildHasher, + { + match self { + RawEntryMut::Occupied(entry) => entry.into_key_value(), + RawEntryMut::Vacant(entry) => entry.insert(default_key, default_val), + } + } + + /// Ensures a value is in the entry by inserting the result of the default function if empty, + /// and returns mutable references to the key and value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, String> = HashMap::new(); + /// + /// map.raw_entry_mut().from_key("poneyland").or_insert_with(|| { + /// ("poneyland", "hoho".to_string()) + /// }); + /// + /// assert_eq!(map["poneyland"], "hoho".to_string()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with(self, default: F) -> (&'a mut K, &'a mut V) + where + F: FnOnce() -> (K, V), + K: Hash, + S: BuildHasher, + { + match self { + RawEntryMut::Occupied(entry) => entry.into_key_value(), + RawEntryMut::Vacant(entry) => { + let (k, v) = default(); + entry.insert(k, v) + } + } + } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// map.raw_entry_mut() + /// .from_key("poneyland") + /// .and_modify(|_k, v| { *v += 1 }) + /// .or_insert("poneyland", 42); + /// assert_eq!(map["poneyland"], 42); + /// + /// map.raw_entry_mut() + /// .from_key("poneyland") + /// .and_modify(|_k, v| { *v += 1 }) + /// .or_insert("poneyland", 0); + /// assert_eq!(map["poneyland"], 43); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_modify(self, f: F) -> Self + where + F: FnOnce(&mut K, &mut V), + { + match self { + RawEntryMut::Occupied(mut entry) => { + { + let (k, v) = entry.get_key_value_mut(); + f(k, v); + } + RawEntryMut::Occupied(entry) + } + RawEntryMut::Vacant(entry) => RawEntryMut::Vacant(entry), + } + } + + /// Provides shared access to the key and owned access to the value of + /// an occupied entry and allows to replace or remove it based on the + /// value of the returned option. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RawEntryMut; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// let entry = map + /// .raw_entry_mut() + /// .from_key("poneyland") + /// .and_replace_entry_with(|_k, _v| panic!()); + /// + /// match entry { + /// RawEntryMut::Vacant(_) => {}, + /// RawEntryMut::Occupied(_) => panic!(), + /// } + /// + /// map.insert("poneyland", 42); + /// + /// let entry = map + /// .raw_entry_mut() + /// .from_key("poneyland") + /// .and_replace_entry_with(|k, v| { + /// assert_eq!(k, &"poneyland"); + /// assert_eq!(v, 42); + /// Some(v + 1) + /// }); + /// + /// match entry { + /// RawEntryMut::Occupied(e) => { + /// assert_eq!(e.key(), &"poneyland"); + /// assert_eq!(e.get(), &43); + /// }, + /// RawEntryMut::Vacant(_) => panic!(), + /// } + /// + /// assert_eq!(map["poneyland"], 43); + /// + /// let entry = map + /// .raw_entry_mut() + /// .from_key("poneyland") + /// .and_replace_entry_with(|_k, _v| None); + /// + /// match entry { + /// RawEntryMut::Vacant(_) => {}, + /// RawEntryMut::Occupied(_) => panic!(), + /// } + /// + /// assert!(!map.contains_key("poneyland")); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_replace_entry_with(self, f: F) -> Self + where + F: FnOnce(&K, V) -> Option, + { + match self { + RawEntryMut::Occupied(entry) => entry.replace_entry_with(f), + RawEntryMut::Vacant(_) => self, + } + } +} + +impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> { + /// Gets a reference to the key in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => assert_eq!(o.key(), &"a") + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + unsafe { &self.elem.as_ref().0 } + } + + /// Gets a mutable reference to the key in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// use std::rc::Rc; + /// + /// let key_one = Rc::new("a"); + /// let key_two = Rc::new("a"); + /// + /// let mut map: HashMap, u32> = HashMap::new(); + /// map.insert(key_one.clone(), 10); + /// + /// assert_eq!(map[&key_one], 10); + /// assert!(Rc::strong_count(&key_one) == 2 && Rc::strong_count(&key_two) == 1); + /// + /// match map.raw_entry_mut().from_key(&key_one) { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(mut o) => { + /// *o.key_mut() = key_two.clone(); + /// } + /// } + /// assert_eq!(map[&key_two], 10); + /// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key_mut(&mut self) -> &mut K { + unsafe { &mut self.elem.as_mut().0 } + } + + /// Converts the entry into a mutable reference to the key in the entry + /// with a lifetime bound to the map itself. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// use std::rc::Rc; + /// + /// let key_one = Rc::new("a"); + /// let key_two = Rc::new("a"); + /// + /// let mut map: HashMap, u32> = HashMap::new(); + /// map.insert(key_one.clone(), 10); + /// + /// assert_eq!(map[&key_one], 10); + /// assert!(Rc::strong_count(&key_one) == 2 && Rc::strong_count(&key_two) == 1); + /// + /// let inside_key: &mut Rc<&str>; + /// + /// match map.raw_entry_mut().from_key(&key_one) { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => inside_key = o.into_key(), + /// } + /// *inside_key = key_two.clone(); + /// + /// assert_eq!(map[&key_two], 10); + /// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_key(self) -> &'a mut K { + unsafe { &mut self.elem.as_mut().0 } + } + + /// Gets a reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => assert_eq!(o.get(), &100), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &V { + unsafe { &self.elem.as_ref().1 } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the value in the entry + /// with a lifetime bound to the map itself. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// let value: &mut u32; + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => value = o.into_mut(), + /// } + /// *value += 900; + /// + /// assert_eq!(map[&"a"], 1000); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_mut(self) -> &'a mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Gets a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(mut o) => *o.get_mut() += 900, + /// } + /// + /// assert_eq!(map[&"a"], 1000); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_mut(&mut self) -> &mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Gets a reference to the key and value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => assert_eq!(o.get_key_value(), (&"a", &100)), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_key_value(&self) -> (&K, &V) { + unsafe { + let (key, value) = self.elem.as_ref(); + (key, value) + } + } + + /// Gets a mutable reference to the key and value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// use std::rc::Rc; + /// + /// let key_one = Rc::new("a"); + /// let key_two = Rc::new("a"); + /// + /// let mut map: HashMap, u32> = HashMap::new(); + /// map.insert(key_one.clone(), 10); + /// + /// assert_eq!(map[&key_one], 10); + /// assert!(Rc::strong_count(&key_one) == 2 && Rc::strong_count(&key_two) == 1); + /// + /// match map.raw_entry_mut().from_key(&key_one) { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(mut o) => { + /// let (inside_key, inside_value) = o.get_key_value_mut(); + /// *inside_key = key_two.clone(); + /// *inside_value = 100; + /// } + /// } + /// assert_eq!(map[&key_two], 100); + /// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_key_value_mut(&mut self) -> (&mut K, &mut V) { + unsafe { + let &mut (ref mut key, ref mut value) = self.elem.as_mut(); + (key, value) + } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the key and value in the entry + /// with a lifetime bound to the map itself. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// use std::rc::Rc; + /// + /// let key_one = Rc::new("a"); + /// let key_two = Rc::new("a"); + /// + /// let mut map: HashMap, u32> = HashMap::new(); + /// map.insert(key_one.clone(), 10); + /// + /// assert_eq!(map[&key_one], 10); + /// assert!(Rc::strong_count(&key_one) == 2 && Rc::strong_count(&key_two) == 1); + /// + /// let inside_key: &mut Rc<&str>; + /// let inside_value: &mut u32; + /// match map.raw_entry_mut().from_key(&key_one) { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => { + /// let tuple = o.into_key_value(); + /// inside_key = tuple.0; + /// inside_value = tuple.1; + /// } + /// } + /// *inside_key = key_two.clone(); + /// *inside_value = 100; + /// assert_eq!(map[&key_two], 100); + /// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_key_value(self) -> (&'a mut K, &'a mut V) { + unsafe { + let &mut (ref mut key, ref mut value) = self.elem.as_mut(); + (key, value) + } + } + + /// Sets the value of the entry, and returns the entry's old value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(mut o) => assert_eq!(o.insert(1000), 100), + /// } + /// + /// assert_eq!(map[&"a"], 1000); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(&mut self, value: V) -> V { + mem::replace(self.get_mut(), value) + } + + /// Sets the value of the entry, and returns the entry's old value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// use std::rc::Rc; + /// + /// let key_one = Rc::new("a"); + /// let key_two = Rc::new("a"); + /// + /// let mut map: HashMap, u32> = HashMap::new(); + /// map.insert(key_one.clone(), 10); + /// + /// assert_eq!(map[&key_one], 10); + /// assert!(Rc::strong_count(&key_one) == 2 && Rc::strong_count(&key_two) == 1); + /// + /// match map.raw_entry_mut().from_key(&key_one) { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(mut o) => { + /// let old_key = o.insert_key(key_two.clone()); + /// assert!(Rc::ptr_eq(&old_key, &key_one)); + /// } + /// } + /// assert_eq!(map[&key_two], 10); + /// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_key(&mut self, key: K) -> K { + mem::replace(self.key_mut(), key) + } + + /// Takes the value out of the entry, and returns it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => assert_eq!(o.remove(), 100), + /// } + /// assert_eq!(map.get(&"a"), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(self) -> V { + self.remove_entry().1 + } + + /// Take the ownership of the key and value from the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => assert_eq!(o.remove_entry(), ("a", 100)), + /// } + /// assert_eq!(map.get(&"a"), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove_entry(self) -> (K, V) { + unsafe { self.table.remove(self.elem).0 } + } + + /// Provides shared access to the key and owned access to the value of + /// the entry and allows to replace or remove it based on the + /// value of the returned option. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// let raw_entry = match map.raw_entry_mut().from_key(&"a") { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => o.replace_entry_with(|k, v| { + /// assert_eq!(k, &"a"); + /// assert_eq!(v, 100); + /// Some(v + 900) + /// }), + /// }; + /// let raw_entry = match raw_entry { + /// RawEntryMut::Vacant(_) => panic!(), + /// RawEntryMut::Occupied(o) => o.replace_entry_with(|k, v| { + /// assert_eq!(k, &"a"); + /// assert_eq!(v, 1000); + /// None + /// }), + /// }; + /// match raw_entry { + /// RawEntryMut::Vacant(_) => { }, + /// RawEntryMut::Occupied(_) => panic!(), + /// }; + /// assert_eq!(map.get(&"a"), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn replace_entry_with(self, f: F) -> RawEntryMut<'a, K, V, S, A> + where + F: FnOnce(&K, V) -> Option, + { + unsafe { + let tag = self + .table + .replace_bucket_with(self.elem.clone(), |(key, value)| { + f(&key, value).map(|new_value| (key, new_value)) + }); + + if tag.is_none() { + RawEntryMut::Occupied(self) + } else { + RawEntryMut::Vacant(RawVacantEntryMut { + table: self.table, + hash_builder: self.hash_builder, + }) + } + } + } +} + +impl<'a, K, V, S, A: Allocator> RawVacantEntryMut<'a, K, V, S, A> { + /// Sets the value of the entry with the `VacantEntry`'s key, + /// and returns a mutable reference to it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// + /// match map.raw_entry_mut().from_key(&"c") { + /// RawEntryMut::Occupied(_) => panic!(), + /// RawEntryMut::Vacant(v) => assert_eq!(v.insert("c", 300), (&mut "c", &mut 300)), + /// } + /// + /// assert_eq!(map[&"c"], 300); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, key: K, value: V) -> (&'a mut K, &'a mut V) + where + K: Hash, + S: BuildHasher, + { + let hash = make_hash::(self.hash_builder, &key); + self.insert_hashed_nocheck(hash, key, value) + } + + /// Sets the value of the entry with the `VacantEntry`'s key, + /// and returns a mutable reference to it. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// fn compute_hash(hash_builder: &S, key: &K) -> u64 { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// + /// let mut map: HashMap<&str, u32> = [("a", 100), ("b", 200)].into(); + /// let key = "c"; + /// let hash = compute_hash(map.hasher(), &key); + /// + /// match map.raw_entry_mut().from_key_hashed_nocheck(hash, &key) { + /// RawEntryMut::Occupied(_) => panic!(), + /// RawEntryMut::Vacant(v) => assert_eq!( + /// v.insert_hashed_nocheck(hash, key, 300), + /// (&mut "c", &mut 300) + /// ), + /// } + /// + /// assert_eq!(map[&"c"], 300); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V) + where + K: Hash, + S: BuildHasher, + { + let &mut (ref mut k, ref mut v) = self.table.insert_entry( + hash, + (key, value), + make_hasher::<_, V, S>(self.hash_builder), + ); + (k, v) + } + + /// Set the value of an entry with a custom hasher function. + /// + /// # Examples + /// + /// ``` + /// use core::hash::{BuildHasher, Hash}; + /// use hashbrown::hash_map::{HashMap, RawEntryMut}; + /// + /// fn make_hasher(hash_builder: &S) -> impl Fn(&K) -> u64 + '_ + /// where + /// K: Hash + ?Sized, + /// S: BuildHasher, + /// { + /// move |key: &K| { + /// use core::hash::Hasher; + /// let mut state = hash_builder.build_hasher(); + /// key.hash(&mut state); + /// state.finish() + /// } + /// } + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let key = "a"; + /// let hash_builder = map.hasher().clone(); + /// let hash = make_hasher(&hash_builder)(&key); + /// + /// match map.raw_entry_mut().from_hash(hash, |q| q == &key) { + /// RawEntryMut::Occupied(_) => panic!(), + /// RawEntryMut::Vacant(v) => assert_eq!( + /// v.insert_with_hasher(hash, key, 100, make_hasher(&hash_builder)), + /// (&mut "a", &mut 100) + /// ), + /// } + /// map.extend([("b", 200), ("c", 300), ("d", 400), ("e", 500), ("f", 600)]); + /// assert_eq!(map[&"a"], 100); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_with_hasher( + self, + hash: u64, + key: K, + value: V, + hasher: H, + ) -> (&'a mut K, &'a mut V) + where + H: Fn(&K) -> u64, + { + let &mut (ref mut k, ref mut v) = self + .table + .insert_entry(hash, (key, value), |x| hasher(&x.0)); + (k, v) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn insert_entry(self, key: K, value: V) -> RawOccupiedEntryMut<'a, K, V, S, A> + where + K: Hash, + S: BuildHasher, + { + let hash = make_hash::(self.hash_builder, &key); + let elem = self.table.insert( + hash, + (key, value), + make_hasher::<_, V, S>(self.hash_builder), + ); + RawOccupiedEntryMut { + elem, + table: self.table, + hash_builder: self.hash_builder, + } + } +} + +impl Debug for RawEntryBuilderMut<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RawEntryBuilder").finish() + } +} + +impl Debug for RawEntryMut<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + RawEntryMut::Vacant(ref v) => f.debug_tuple("RawEntry").field(v).finish(), + RawEntryMut::Occupied(ref o) => f.debug_tuple("RawEntry").field(o).finish(), + } + } +} + +impl Debug for RawOccupiedEntryMut<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RawOccupiedEntryMut") + .field("key", self.key()) + .field("value", self.get()) + .finish() + } +} + +impl Debug for RawVacantEntryMut<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RawVacantEntryMut").finish() + } +} + +impl Debug for RawEntryBuilder<'_, K, V, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RawEntryBuilder").finish() + } +} + +#[cfg(test)] +mod test_map { + use super::HashMap; + use super::RawEntryMut; + + #[test] + fn test_raw_occupied_entry_replace_entry_with() { + let mut a = HashMap::new(); + + let key = "a key"; + let value = "an initial value"; + let new_value = "a new value"; + + let entry = a + .raw_entry_mut() + .from_key(&key) + .insert(key, value) + .replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, value); + Some(new_value) + }); + + match entry { + RawEntryMut::Occupied(e) => { + assert_eq!(e.key(), &key); + assert_eq!(e.get(), &new_value); + } + RawEntryMut::Vacant(_) => panic!(), + } + + assert_eq!(a[key], new_value); + assert_eq!(a.len(), 1); + + let entry = match a.raw_entry_mut().from_key(&key) { + RawEntryMut::Occupied(e) => e.replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, new_value); + None + }), + RawEntryMut::Vacant(_) => panic!(), + }; + + match entry { + RawEntryMut::Vacant(_) => {} + RawEntryMut::Occupied(_) => panic!(), + } + + assert!(!a.contains_key(key)); + assert_eq!(a.len(), 0); + } + + #[test] + fn test_raw_entry_and_replace_entry_with() { + let mut a = HashMap::new(); + + let key = "a key"; + let value = "an initial value"; + let new_value = "a new value"; + + let entry = a + .raw_entry_mut() + .from_key(&key) + .and_replace_entry_with(|_, _| panic!()); + + match entry { + RawEntryMut::Vacant(_) => {} + RawEntryMut::Occupied(_) => panic!(), + } + + a.insert(key, value); + + let entry = a + .raw_entry_mut() + .from_key(&key) + .and_replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, value); + Some(new_value) + }); + + match entry { + RawEntryMut::Occupied(e) => { + assert_eq!(e.key(), &key); + assert_eq!(e.get(), &new_value); + } + RawEntryMut::Vacant(_) => panic!(), + } + + assert_eq!(a[key], new_value); + assert_eq!(a.len(), 1); + + let entry = a + .raw_entry_mut() + .from_key(&key) + .and_replace_entry_with(|k, v| { + assert_eq!(k, &key); + assert_eq!(v, new_value); + None + }); + + match entry { + RawEntryMut::Vacant(_) => {} + RawEntryMut::Occupied(_) => panic!(), + } + + assert!(!a.contains_key(key)); + assert_eq!(a.len(), 0); + } + + #[test] + fn test_raw_entry() { + use super::RawEntryMut::{Occupied, Vacant}; + + let xs = [(1_i32, 10_i32), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)]; + + let mut map: HashMap<_, _> = xs.iter().copied().collect(); + + let compute_hash = |map: &HashMap, k: i32| -> u64 { + super::make_hash::(map.hasher(), &k) + }; + + // Existing key (insert) + match map.raw_entry_mut().from_key(&1) { + Vacant(_) => unreachable!(), + Occupied(mut view) => { + assert_eq!(view.get(), &10); + assert_eq!(view.insert(100), 10); + } + } + let hash1 = compute_hash(&map, 1); + assert_eq!(map.raw_entry().from_key(&1).unwrap(), (&1, &100)); + assert_eq!( + map.raw_entry().from_hash(hash1, |k| *k == 1).unwrap(), + (&1, &100) + ); + assert_eq!( + map.raw_entry().from_key_hashed_nocheck(hash1, &1).unwrap(), + (&1, &100) + ); + assert_eq!(map.len(), 6); + + // Existing key (update) + match map.raw_entry_mut().from_key(&2) { + Vacant(_) => unreachable!(), + Occupied(mut view) => { + let v = view.get_mut(); + let new_v = (*v) * 10; + *v = new_v; + } + } + let hash2 = compute_hash(&map, 2); + assert_eq!(map.raw_entry().from_key(&2).unwrap(), (&2, &200)); + assert_eq!( + map.raw_entry().from_hash(hash2, |k| *k == 2).unwrap(), + (&2, &200) + ); + assert_eq!( + map.raw_entry().from_key_hashed_nocheck(hash2, &2).unwrap(), + (&2, &200) + ); + assert_eq!(map.len(), 6); + + // Existing key (take) + let hash3 = compute_hash(&map, 3); + match map.raw_entry_mut().from_key_hashed_nocheck(hash3, &3) { + Vacant(_) => unreachable!(), + Occupied(view) => { + assert_eq!(view.remove_entry(), (3, 30)); + } + } + assert_eq!(map.raw_entry().from_key(&3), None); + assert_eq!(map.raw_entry().from_hash(hash3, |k| *k == 3), None); + assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash3, &3), None); + assert_eq!(map.len(), 5); + + // Nonexistent key (insert) + match map.raw_entry_mut().from_key(&10) { + Occupied(_) => unreachable!(), + Vacant(view) => { + assert_eq!(view.insert(10, 1000), (&mut 10, &mut 1000)); + } + } + assert_eq!(map.raw_entry().from_key(&10).unwrap(), (&10, &1000)); + assert_eq!(map.len(), 6); + + // Ensure all lookup methods produce equivalent results. + for k in 0..12 { + let hash = compute_hash(&map, k); + let v = map.get(&k).copied(); + let kv = v.as_ref().map(|v| (&k, v)); + + assert_eq!(map.raw_entry().from_key(&k), kv); + assert_eq!(map.raw_entry().from_hash(hash, |q| *q == k), kv); + assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash, &k), kv); + + match map.raw_entry_mut().from_key(&k) { + Occupied(o) => assert_eq!(Some(o.get_key_value()), kv), + Vacant(_) => assert_eq!(v, None), + } + match map.raw_entry_mut().from_key_hashed_nocheck(hash, &k) { + Occupied(o) => assert_eq!(Some(o.get_key_value()), kv), + Vacant(_) => assert_eq!(v, None), + } + match map.raw_entry_mut().from_hash(hash, |q| *q == k) { + Occupied(o) => assert_eq!(Some(o.get_key_value()), kv), + Vacant(_) => assert_eq!(v, None), + } + } + } + + #[test] + fn test_key_without_hash_impl() { + #[derive(Debug)] + struct IntWrapper(u64); + + let mut m: HashMap = HashMap::default(); + { + assert!(m.raw_entry().from_hash(0, |k| k.0 == 0).is_none()); + } + { + let vacant_entry = match m.raw_entry_mut().from_hash(0, |k| k.0 == 0) { + RawEntryMut::Occupied(..) => panic!("Found entry for key 0"), + RawEntryMut::Vacant(e) => e, + }; + vacant_entry.insert_with_hasher(0, IntWrapper(0), (), |k| k.0); + } + { + assert!(m.raw_entry().from_hash(0, |k| k.0 == 0).is_some()); + assert!(m.raw_entry().from_hash(1, |k| k.0 == 1).is_none()); + assert!(m.raw_entry().from_hash(2, |k| k.0 == 2).is_none()); + } + { + let vacant_entry = match m.raw_entry_mut().from_hash(1, |k| k.0 == 1) { + RawEntryMut::Occupied(..) => panic!("Found entry for key 1"), + RawEntryMut::Vacant(e) => e, + }; + vacant_entry.insert_with_hasher(1, IntWrapper(1), (), |k| k.0); + } + { + assert!(m.raw_entry().from_hash(0, |k| k.0 == 0).is_some()); + assert!(m.raw_entry().from_hash(1, |k| k.0 == 1).is_some()); + assert!(m.raw_entry().from_hash(2, |k| k.0 == 2).is_none()); + } + { + let occupied_entry = match m.raw_entry_mut().from_hash(0, |k| k.0 == 0) { + RawEntryMut::Occupied(e) => e, + RawEntryMut::Vacant(..) => panic!("Couldn't find entry for key 0"), + }; + occupied_entry.remove(); + } + assert!(m.raw_entry().from_hash(0, |k| k.0 == 0).is_none()); + assert!(m.raw_entry().from_hash(1, |k| k.0 == 1).is_some()); + assert!(m.raw_entry().from_hash(2, |k| k.0 == 2).is_none()); + } +} diff --git a/library/hashbrown/src/rustc_entry.rs b/library/hashbrown/src/rustc_entry.rs new file mode 100644 index 0000000000000..45009bb0bd9f3 --- /dev/null +++ b/library/hashbrown/src/rustc_entry.rs @@ -0,0 +1,629 @@ +use self::RustcEntry::*; +use crate::alloc::{Allocator, Global}; +use crate::map::{Drain, HashMap, IntoIter, Iter, IterMut, make_hash, make_hasher}; +use crate::raw::{Bucket, RawTable}; +use core::fmt::{self, Debug}; +use core::hash::{BuildHasher, Hash}; +use core::mem; + +impl HashMap +where + K: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + /// Gets the given key's corresponding entry in the map for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut letters = HashMap::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// let counter = letters.rustc_entry(ch).or_insert(0); + /// *counter += 1; + /// } + /// + /// assert_eq!(letters[&'s'], 2); + /// assert_eq!(letters[&'t'], 3); + /// assert_eq!(letters[&'u'], 1); + /// assert_eq!(letters.get(&'y'), None); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn rustc_entry(&mut self, key: K) -> RustcEntry<'_, K, V, A> { + let hash = make_hash(&self.hash_builder, &key); + if let Some(elem) = self.table.find(hash, |q| q.0.eq(&key)) { + RustcEntry::Occupied(RustcOccupiedEntry { + elem, + table: &mut self.table, + }) + } else { + // Ideally we would put this in VacantEntry::insert, but Entry is not + // generic over the BuildHasher and adding a generic parameter would be + // a breaking change. + self.reserve(1); + + RustcEntry::Vacant(RustcVacantEntry { + hash, + key, + table: &mut self.table, + }) + } + } + + /// Tries to insert a key-value pair into the map, and returns + /// a mutable reference to the value in the entry. + /// + /// # Errors + /// + /// If the map already had this key present, nothing is updated, and an error + /// containing the occupied entry, the key, and the value is returned. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcOccupiedError; + /// + /// let mut map = HashMap::new(); + /// assert_eq!(map.rustc_try_insert(37, "a").ok().unwrap(), &"a"); + /// + /// match map.rustc_try_insert(37, "b") { + /// Err(RustcOccupiedError { entry, key, value, .. }) => { + /// assert_eq!(entry.key(), &37); + /// assert_eq!(entry.get(), &"a"); + /// assert_eq!(key, 37); + /// assert_eq!(value, "b"); + /// } + /// _ => panic!() + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn rustc_try_insert( + &mut self, + key: K, + value: V, + ) -> Result<&mut V, RustcOccupiedError<'_, K, V, A>> { + let hash = make_hash(&self.hash_builder, &key); + if let Some(elem) = self.table.find(hash, |q| q.0.eq(&key)) { + let entry = RustcOccupiedEntry { + elem, + table: &mut self.table, + }; + Err(RustcOccupiedError { entry, key, value }) + } else { + let hasher = make_hasher(&self.hash_builder); + let entry = self.table.insert_entry(hash, (key, value), hasher); + Ok(&mut entry.1) + } + } +} + +/// The error returned by [`rustc_try_insert`](HashMap::rustc_try_insert) when the key already exists. +/// +/// Note: There are no impls for this type, because we expect the standard library will +/// immediately reconstruct these errors into its own `OccupiedError`. +#[non_exhaustive] +pub struct RustcOccupiedError<'a, K, V, A = Global> +where + A: Allocator, +{ + /// The entry in the map that was already occupied. + pub entry: RustcOccupiedEntry<'a, K, V, A>, + /// The key which was not inserted, because the entry was already occupied. + pub key: K, + /// The value which was not inserted, because the entry was already occupied. + pub value: V, +} + +/// A view into a single entry in a map, which may either be vacant or occupied. +/// +/// This `enum` is constructed from the [`rustc_entry`] method on [`HashMap`]. +/// +/// [`rustc_entry`]: HashMap::rustc_entry +pub enum RustcEntry<'a, K, V, A = Global> +where + A: Allocator, +{ + /// An occupied entry. + Occupied(RustcOccupiedEntry<'a, K, V, A>), + + /// A vacant entry. + Vacant(RustcVacantEntry<'a, K, V, A>), +} + +impl Debug for RustcEntry<'_, K, V, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), + Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(), + } + } +} + +/// A view into an occupied entry in a `HashMap`. +/// It is part of the [`RustcEntry`] enum. +pub struct RustcOccupiedEntry<'a, K, V, A = Global> +where + A: Allocator, +{ + elem: Bucket<(K, V)>, + table: &'a mut RawTable<(K, V), A>, +} + +unsafe impl Send for RustcOccupiedEntry<'_, K, V, A> +where + K: Send, + V: Send, + A: Allocator + Send, +{ +} +unsafe impl Sync for RustcOccupiedEntry<'_, K, V, A> +where + K: Sync, + V: Sync, + A: Allocator + Sync, +{ +} + +impl Debug for RustcOccupiedEntry<'_, K, V, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedEntry") + .field("key", self.key()) + .field("value", self.get()) + .finish() + } +} + +/// A view into a vacant entry in a `HashMap`. +/// It is part of the [`RustcEntry`] enum. +pub struct RustcVacantEntry<'a, K, V, A = Global> +where + A: Allocator, +{ + hash: u64, + key: K, + table: &'a mut RawTable<(K, V), A>, +} + +impl Debug for RustcVacantEntry<'_, K, V, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("VacantEntry").field(self.key()).finish() + } +} + +impl<'a, K, V, A: Allocator> RustcEntry<'a, K, V, A> { + /// Sets the value of the entry, and returns a RustcOccupiedEntry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// let entry = map.rustc_entry("horseyland").insert(37); + /// + /// assert_eq!(entry.key(), &"horseyland"); + /// ``` + pub fn insert(self, value: V) -> RustcOccupiedEntry<'a, K, V, A> { + match self { + Vacant(entry) => entry.insert_entry(value), + Occupied(mut entry) => { + entry.insert(value); + entry + } + } + } + + /// Ensures a value is in the entry by inserting the default if empty, and returns + /// a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// map.rustc_entry("poneyland").or_insert(3); + /// assert_eq!(map["poneyland"], 3); + /// + /// *map.rustc_entry("poneyland").or_insert(10) *= 2; + /// assert_eq!(map["poneyland"], 6); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert(self, default: V) -> &'a mut V + where + K: Hash, + { + match self { + Occupied(entry) => entry.into_mut(), + Vacant(entry) => entry.insert(default), + } + } + + /// Ensures a value is in the entry by inserting the result of the default function if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, String> = HashMap::new(); + /// let s = "hoho".to_string(); + /// + /// map.rustc_entry("poneyland").or_insert_with(|| s); + /// + /// assert_eq!(map["poneyland"], "hoho".to_string()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert_with V>(self, default: F) -> &'a mut V + where + K: Hash, + { + match self { + Occupied(entry) => entry.into_mut(), + Vacant(entry) => entry.insert(default()), + } + } + + /// Returns a reference to this entry's key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// assert_eq!(map.rustc_entry("poneyland").key(), &"poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + match *self { + Occupied(ref entry) => entry.key(), + Vacant(ref entry) => entry.key(), + } + } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// map.rustc_entry("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 42); + /// + /// map.rustc_entry("poneyland") + /// .and_modify(|e| { *e += 1 }) + /// .or_insert(42); + /// assert_eq!(map["poneyland"], 43); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn and_modify(self, f: F) -> Self + where + F: FnOnce(&mut V), + { + match self { + Occupied(mut entry) => { + f(entry.get_mut()); + Occupied(entry) + } + Vacant(entry) => Vacant(entry), + } + } +} + +impl<'a, K, V: Default, A: Allocator> RustcEntry<'a, K, V, A> { + /// Ensures a value is in the entry by inserting the default value if empty, + /// and returns a mutable reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// # fn main() { + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, Option> = HashMap::new(); + /// map.rustc_entry("poneyland").or_default(); + /// + /// assert_eq!(map["poneyland"], None); + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_default(self) -> &'a mut V + where + K: Hash, + { + match self { + Occupied(entry) => entry.into_mut(), + Vacant(entry) => entry.insert(Default::default()), + } + } +} + +impl<'a, K, V, A: Allocator> RustcOccupiedEntry<'a, K, V, A> { + /// Gets a reference to the key in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// assert_eq!(map.rustc_entry("poneyland").key(), &"poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + unsafe { &self.elem.as_ref().0 } + } + + /// Take the ownership of the key and value from the map. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// if let RustcEntry::Occupied(o) = map.rustc_entry("poneyland") { + /// // We delete the entry from the map. + /// o.remove_entry(); + /// } + /// + /// assert_eq!(map.contains_key("poneyland"), false); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove_entry(self) -> (K, V) { + unsafe { self.table.remove(self.elem).0 } + } + + /// Gets a reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// if let RustcEntry::Occupied(o) = map.rustc_entry("poneyland") { + /// assert_eq!(o.get(), &12); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &V { + unsafe { &self.elem.as_ref().1 } + } + + /// Gets a mutable reference to the value in the entry. + /// + /// If you need a reference to the `RustcOccupiedEntry` which may outlive the + /// destruction of the `RustcEntry` value, see [`into_mut`]. + /// + /// [`into_mut`]: #method.into_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// assert_eq!(map["poneyland"], 12); + /// if let RustcEntry::Occupied(mut o) = map.rustc_entry("poneyland") { + /// *o.get_mut() += 10; + /// assert_eq!(*o.get(), 22); + /// + /// // We can use the same RustcEntry multiple times. + /// *o.get_mut() += 2; + /// } + /// + /// assert_eq!(map["poneyland"], 24); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_mut(&mut self) -> &mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Converts the RustcOccupiedEntry into a mutable reference to the value in the entry + /// with a lifetime bound to the map itself. + /// + /// If you need multiple references to the `RustcOccupiedEntry`, see [`get_mut`]. + /// + /// [`get_mut`]: #method.get_mut + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// assert_eq!(map["poneyland"], 12); + /// if let RustcEntry::Occupied(o) = map.rustc_entry("poneyland") { + /// *o.into_mut() += 10; + /// } + /// + /// assert_eq!(map["poneyland"], 22); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_mut(self) -> &'a mut V { + unsafe { &mut self.elem.as_mut().1 } + } + + /// Sets the value of the entry, and returns the entry's old value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// if let RustcEntry::Occupied(mut o) = map.rustc_entry("poneyland") { + /// assert_eq!(o.insert(15), 12); + /// } + /// + /// assert_eq!(map["poneyland"], 15); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(&mut self, value: V) -> V { + mem::replace(self.get_mut(), value) + } + + /// Takes the value out of the entry, and returns it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// map.rustc_entry("poneyland").or_insert(12); + /// + /// if let RustcEntry::Occupied(o) = map.rustc_entry("poneyland") { + /// assert_eq!(o.remove(), 12); + /// } + /// + /// assert_eq!(map.contains_key("poneyland"), false); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(self) -> V { + self.remove_entry().1 + } +} + +impl<'a, K, V, A: Allocator> RustcVacantEntry<'a, K, V, A> { + /// Gets a reference to the key that would be used when inserting a value + /// through the `RustcVacantEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// assert_eq!(map.rustc_entry("poneyland").key(), &"poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn key(&self) -> &K { + &self.key + } + + /// Take ownership of the key. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let RustcEntry::Vacant(v) = map.rustc_entry("poneyland") { + /// v.into_key(); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_key(self) -> K { + self.key + } + + /// Sets the value of the entry with the RustcVacantEntry's key, + /// and returns a mutable reference to it. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let RustcEntry::Vacant(o) = map.rustc_entry("poneyland") { + /// o.insert(37); + /// } + /// assert_eq!(map["poneyland"], 37); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self, value: V) -> &'a mut V { + unsafe { + let bucket = self.table.insert_no_grow(self.hash, (self.key, value)); + &mut bucket.as_mut().1 + } + } + + /// Sets the value of the entry with the RustcVacantEntry's key, + /// and returns a RustcOccupiedEntry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashMap; + /// use hashbrown::hash_map::RustcEntry; + /// + /// let mut map: HashMap<&str, u32> = HashMap::new(); + /// + /// if let RustcEntry::Vacant(v) = map.rustc_entry("poneyland") { + /// let o = v.insert_entry(37); + /// assert_eq!(o.get(), &37); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert_entry(self, value: V) -> RustcOccupiedEntry<'a, K, V, A> { + let bucket = unsafe { self.table.insert_no_grow(self.hash, (self.key, value)) }; + RustcOccupiedEntry { + elem: bucket, + table: self.table, + } + } +} + +impl IterMut<'_, K, V> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn rustc_iter(&self) -> Iter<'_, K, V> { + self.iter() + } +} + +impl IntoIter { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn rustc_iter(&self) -> Iter<'_, K, V> { + self.iter() + } +} + +impl Drain<'_, K, V, A> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn rustc_iter(&self) -> Iter<'_, K, V> { + self.iter() + } +} diff --git a/library/hashbrown/src/scopeguard.rs b/library/hashbrown/src/scopeguard.rs new file mode 100644 index 0000000000000..26532b84bfd12 --- /dev/null +++ b/library/hashbrown/src/scopeguard.rs @@ -0,0 +1,72 @@ +// Extracted from the scopeguard crate +use core::{ + mem::ManuallyDrop, + ops::{Deref, DerefMut}, + ptr, +}; + +pub(crate) struct ScopeGuard +where + F: FnMut(&mut T), +{ + dropfn: F, + value: T, +} + +#[inline] +pub(crate) fn guard(value: T, dropfn: F) -> ScopeGuard +where + F: FnMut(&mut T), +{ + ScopeGuard { dropfn, value } +} + +impl ScopeGuard +where + F: FnMut(&mut T), +{ + #[inline] + pub(crate) fn into_inner(guard: Self) -> T { + // Cannot move out of Drop-implementing types, so + // ptr::read the value out of a ManuallyDrop + // Don't use mem::forget as that might invalidate value + let guard = ManuallyDrop::new(guard); + unsafe { + let value = ptr::read(&raw const guard.value); + // read the closure so that it is dropped + let _ = ptr::read(&raw const guard.dropfn); + value + } + } +} + +impl Deref for ScopeGuard +where + F: FnMut(&mut T), +{ + type Target = T; + #[inline] + fn deref(&self) -> &T { + &self.value + } +} + +impl DerefMut for ScopeGuard +where + F: FnMut(&mut T), +{ + #[inline] + fn deref_mut(&mut self) -> &mut T { + &mut self.value + } +} + +impl Drop for ScopeGuard +where + F: FnMut(&mut T), +{ + #[inline] + fn drop(&mut self) { + (self.dropfn)(&mut self.value); + } +} diff --git a/library/hashbrown/src/set.rs b/library/hashbrown/src/set.rs new file mode 100644 index 0000000000000..145c4292cce7e --- /dev/null +++ b/library/hashbrown/src/set.rs @@ -0,0 +1,3157 @@ +use crate::{Equivalent, TryReserveError}; +use core::cell::UnsafeCell; +use core::fmt; +use core::hash::{BuildHasher, Hash}; +use core::iter::{Chain, FusedIterator}; +use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign}; + +use super::map::{self, HashMap, Keys}; +use crate::DefaultHashBuilder; +use crate::alloc::{Allocator, Global}; +use crate::raw::RawExtractIf; + +// Future Optimization (FIXME!) +// ============================= +// +// Iteration over zero sized values is a noop. There is no need +// for `bucket.val` in the case of HashSet. I suppose we would need HKT +// to get rid of it properly. + +/// A hash set implemented as a `HashMap` where the value is `()`. +/// +/// As with the [`HashMap`] type, a `HashSet` requires that the elements +/// implement the [`Eq`] and [`Hash`] traits. This can frequently be achieved by +/// using `#[derive(PartialEq, Eq, Hash)]`. If you implement these yourself, +/// it is important that the following property holds: +/// +/// ```text +/// k1 == k2 -> hash(k1) == hash(k2) +/// ``` +/// +/// In other words, if two keys are equal, their hashes must be equal. +/// +/// +/// It is a logic error for an item to be modified in such a way that the +/// item's hash, as determined by the [`Hash`] trait, or its equality, as +/// determined by the [`Eq`] trait, changes while it is in the set. This is +/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or +/// unsafe code. +/// +/// It is also a logic error for the [`Hash`] implementation of a key to panic. +/// This is generally only possible if the trait is implemented manually. If a +/// panic does occur then the contents of the `HashSet` may become corrupted and +/// some items may be dropped from the table. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::HashSet; +/// // Type inference lets us omit an explicit type signature (which +/// // would be `HashSet` in this example). +/// let mut books = HashSet::new(); +/// +/// // Add some books. +/// books.insert("A Dance With Dragons".to_string()); +/// books.insert("To Kill a Mockingbird".to_string()); +/// books.insert("The Odyssey".to_string()); +/// books.insert("The Great Gatsby".to_string()); +/// +/// // Check for a specific one. +/// if !books.contains("The Winds of Winter") { +/// println!("We have {} books, but The Winds of Winter ain't one.", +/// books.len()); +/// } +/// +/// // Remove a book. +/// books.remove("The Odyssey"); +/// +/// // Iterate over everything. +/// for book in &books { +/// println!("{}", book); +/// } +/// ``` +/// +/// The easiest way to use `HashSet` with a custom type is to derive +/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`]. This will in the +/// future be implied by [`Eq`]. +/// +/// ``` +/// use hashbrown::HashSet; +/// #[derive(Hash, Eq, PartialEq, Debug)] +/// struct Viking { +/// name: String, +/// power: usize, +/// } +/// +/// let mut vikings = HashSet::new(); +/// +/// vikings.insert(Viking { name: "Einar".to_string(), power: 9 }); +/// vikings.insert(Viking { name: "Einar".to_string(), power: 9 }); +/// vikings.insert(Viking { name: "Olaf".to_string(), power: 4 }); +/// vikings.insert(Viking { name: "Harald".to_string(), power: 8 }); +/// +/// // Use derived implementation to print the vikings. +/// for x in &vikings { +/// println!("{:?}", x); +/// } +/// ``` +/// +/// A `HashSet` with fixed list of elements can be initialized from an array: +/// +/// ``` +/// use hashbrown::HashSet; +/// +/// let viking_names: HashSet<&'static str> = +/// [ "Einar", "Olaf", "Harald" ].into_iter().collect(); +/// // use the values stored in the set +/// ``` +/// +/// [`Cell`]: std::cell::Cell +/// [`RefCell`]: std::cell::RefCell +pub struct HashSet { + pub(crate) map: HashMap, +} + +impl Clone for HashSet { + fn clone(&self) -> Self { + HashSet { + map: self.map.clone(), + } + } + + fn clone_from(&mut self, source: &Self) { + self.map.clone_from(&source.map); + } +} + +#[cfg(feature = "default-hasher")] +impl HashSet { + /// Creates an empty `HashSet`. + /// + /// The hash set is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`], for example with + /// [`with_hasher`](HashSet::with_hasher) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let set: HashSet = HashSet::new(); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn new() -> Self { + Self { + map: HashMap::new(), + } + } + + /// Creates an empty `HashSet` with the specified capacity. + /// + /// The hash set will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash set will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`], for example with + /// [`with_capacity_and_hasher`](HashSet::with_capacity_and_hasher) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let set: HashSet = HashSet::with_capacity(10); + /// assert!(set.capacity() >= 10); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity(capacity: usize) -> Self { + Self { + map: HashMap::with_capacity(capacity), + } + } +} + +#[cfg(feature = "default-hasher")] +impl HashSet { + /// Creates an empty `HashSet`. + /// + /// The hash set is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`], for example with + /// [`with_hasher_in`](HashSet::with_hasher_in) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let set: HashSet = HashSet::new(); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn new_in(alloc: A) -> Self { + Self { + map: HashMap::new_in(alloc), + } + } + + /// Creates an empty `HashSet` with the specified capacity. + /// + /// The hash set will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash set will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`], for example with + /// [`with_capacity_and_hasher_in`](HashSet::with_capacity_and_hasher_in) method. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let set: HashSet = HashSet::with_capacity(10); + /// assert!(set.capacity() >= 10); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { + Self { + map: HashMap::with_capacity_in(capacity, alloc), + } + } +} + +impl HashSet { + /// Returns the number of elements the set can hold without reallocating. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let set: HashSet = HashSet::with_capacity(100); + /// assert!(set.capacity() >= 100); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn capacity(&self) -> usize { + self.map.capacity() + } + + /// An iterator visiting all elements in arbitrary order. + /// The iterator element type is `&'a T`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let mut set = HashSet::new(); + /// set.insert("a"); + /// set.insert("b"); + /// + /// // Will print in an arbitrary order. + /// for x in set.iter() { + /// println!("{}", x); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, T> { + Iter { + iter: self.map.keys(), + } + } + + /// Returns the number of elements in the set. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut v = HashSet::new(); + /// assert_eq!(v.len(), 0); + /// v.insert(1); + /// assert_eq!(v.len(), 1); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn len(&self) -> usize { + self.map.len() + } + + /// Returns `true` if the set contains no elements. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut v = HashSet::new(); + /// assert!(v.is_empty()); + /// v.insert(1); + /// assert!(!v.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn is_empty(&self) -> bool { + self.map.is_empty() + } + + /// Clears the set, returning all elements in an iterator. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// assert!(!set.is_empty()); + /// + /// // print 1, 2, 3 in an arbitrary order + /// for i in set.drain() { + /// println!("{}", i); + /// } + /// + /// assert!(set.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn drain(&mut self) -> Drain<'_, T, A> { + Drain { + iter: self.map.drain(), + } + } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let xs = [1,2,3,4,5,6]; + /// let mut set: HashSet = xs.into_iter().collect(); + /// set.retain(|&k| k % 2 == 0); + /// assert_eq!(set.len(), 3); + /// ``` + pub fn retain(&mut self, mut f: F) + where + F: FnMut(&T) -> bool, + { + self.map.retain(|k, _| f(k)); + } + + /// Drains elements which are true under the given predicate, + /// and returns an iterator over the removed items. + /// + /// In other words, move all elements `e` such that `f(&e)` returns `true` out + /// into another iterator. + /// + /// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating + /// or the iteration short-circuits, then the remaining elements will be retained. + /// Use [`retain()`] with a negated predicate if you do not need the returned iterator. + /// + /// [`retain()`]: HashSet::retain + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet = (0..8).collect(); + /// let drained: HashSet = set.extract_if(|v| v % 2 == 0).collect(); + /// + /// let mut evens = drained.into_iter().collect::>(); + /// let mut odds = set.into_iter().collect::>(); + /// evens.sort(); + /// odds.sort(); + /// + /// assert_eq!(evens, vec![0, 2, 4, 6]); + /// assert_eq!(odds, vec![1, 3, 5, 7]); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn extract_if(&mut self, f: F) -> ExtractIf<'_, T, F, A> + where + F: FnMut(&T) -> bool, + { + ExtractIf { + f, + inner: RawExtractIf { + iter: unsafe { self.map.table.iter() }, + table: &mut self.map.table, + }, + } + } + + /// Clears the set, removing all values. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut v = HashSet::new(); + /// v.insert(1); + /// v.clear(); + /// assert!(v.is_empty()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn clear(&mut self) { + self.map.clear(); + } +} + +impl HashSet { + /// Creates a new empty hash set which will use the given hasher to hash + /// keys. + /// + /// The hash set is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashSet` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut set = HashSet::with_hasher(s); + /// set.insert(2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub const fn with_hasher(hasher: S) -> Self { + Self { + map: HashMap::with_hasher(hasher), + } + } + + /// Creates an empty `HashSet` with the specified capacity, using + /// `hasher` to hash the keys. + /// + /// The hash set will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash set will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashSet` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut set = HashSet::with_capacity_and_hasher(10, s); + /// set.insert(1); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self { + Self { + map: HashMap::with_capacity_and_hasher(capacity, hasher), + } + } +} + +impl HashSet +where + A: Allocator, +{ + /// Returns a reference to the underlying allocator. + #[inline] + pub fn allocator(&self) -> &A { + self.map.allocator() + } + + /// Creates a new empty hash set which will use the given hasher to hash + /// keys. + /// + /// The hash set is initially created with a capacity of 0, so it will not + /// allocate until it is first inserted into. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashSet` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut set = HashSet::with_hasher(s); + /// set.insert(2); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + #[cfg_attr(feature = "rustc-dep-of-std", rustc_const_stable_indirect)] + pub const fn with_hasher_in(hasher: S, alloc: A) -> Self { + Self { + map: HashMap::with_hasher_in(hasher, alloc), + } + } + + /// Creates an empty `HashSet` with the specified capacity, using + /// `hasher` to hash the keys. + /// + /// The hash set will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash set will not allocate. + /// + /// # HashDoS resistance + /// + /// The `hash_builder` normally use a fixed key by default and that does + /// not allow the `HashSet` to be protected against attacks such as [`HashDoS`]. + /// Users who require HashDoS resistance should explicitly use + /// [`std::hash::RandomState`] + /// as the hasher when creating a [`HashSet`]. + /// + /// The `hash_builder` passed should implement the [`BuildHasher`] trait for + /// the `HashSet` to be useful, see its documentation for details. + /// + /// [`HashDoS`]: https://en.wikipedia.org/wiki/Collision_attack + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::DefaultHashBuilder; + /// + /// let s = DefaultHashBuilder::default(); + /// let mut set = HashSet::with_capacity_and_hasher(10, s); + /// set.insert(1); + /// ``` + #[must_use] + #[cfg_attr(feature = "inline-more", inline)] + pub fn with_capacity_and_hasher_in(capacity: usize, hasher: S, alloc: A) -> Self { + Self { + map: HashMap::with_capacity_and_hasher_in(capacity, hasher, alloc), + } + } + + /// Returns a reference to the set's [`BuildHasher`]. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::DefaultHashBuilder; + /// + /// let hasher = DefaultHashBuilder::default(); + /// let set: HashSet = HashSet::with_hasher(hasher); + /// let hasher: &DefaultHashBuilder = set.hasher(); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn hasher(&self) -> &S { + self.map.hasher() + } +} + +impl HashSet +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + /// Reserves capacity for at least `additional` more elements to be inserted + /// in the `HashSet`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// # Panics + /// + /// Panics if the new capacity exceeds [`isize::MAX`] bytes and [`abort`] the program + /// in case of allocation error. Use [`try_reserve`](HashSet::try_reserve) instead + /// if you want to handle memory allocation failure. + /// + /// [`abort`]: stdalloc::alloc::handle_alloc_error + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let mut set: HashSet = HashSet::new(); + /// set.reserve(10); + /// assert!(set.capacity() >= 10); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn reserve(&mut self, additional: usize) { + self.map.reserve(additional); + } + + /// Tries to reserve capacity for at least `additional` more elements to be inserted + /// in the given `HashSet`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// # Errors + /// + /// If the capacity overflows, or the allocator reports a failure, then an error + /// is returned. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let mut set: HashSet = HashSet::new(); + /// set.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { + self.map.try_reserve(additional) + } + + /// Shrinks the capacity of the set as much as possible. It will drop + /// down as much as possible while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set = HashSet::with_capacity(100); + /// set.insert(1); + /// set.insert(2); + /// assert!(set.capacity() >= 100); + /// set.shrink_to_fit(); + /// assert!(set.capacity() >= 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn shrink_to_fit(&mut self) { + self.map.shrink_to_fit(); + } + + /// Shrinks the capacity of the set with a lower limit. It will drop + /// down no lower than the supplied limit while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// Panics if the current capacity is smaller than the supplied + /// minimum capacity. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set = HashSet::with_capacity(100); + /// set.insert(1); + /// set.insert(2); + /// assert!(set.capacity() >= 100); + /// set.shrink_to(10); + /// assert!(set.capacity() >= 10); + /// set.shrink_to(0); + /// assert!(set.capacity() >= 2); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn shrink_to(&mut self, min_capacity: usize) { + self.map.shrink_to(min_capacity); + } + + /// Visits the values representing the difference, + /// i.e., the values that are in `self` but not in `other`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let a: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect(); + /// + /// // Can be seen as `a - b`. + /// for x in a.difference(&b) { + /// println!("{}", x); // Print 1 + /// } + /// + /// let diff: HashSet<_> = a.difference(&b).collect(); + /// assert_eq!(diff, [1].iter().collect()); + /// + /// // Note that difference is not symmetric, + /// // and `b - a` means something else: + /// let diff: HashSet<_> = b.difference(&a).collect(); + /// assert_eq!(diff, [4].iter().collect()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T, S, A> { + Difference { + iter: self.iter(), + other, + } + } + + /// Visits the values representing the symmetric difference, + /// i.e., the values that are in `self` or in `other` but not in both. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let a: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect(); + /// + /// // Print 1, 4 in arbitrary order. + /// for x in a.symmetric_difference(&b) { + /// println!("{}", x); + /// } + /// + /// let diff1: HashSet<_> = a.symmetric_difference(&b).collect(); + /// let diff2: HashSet<_> = b.symmetric_difference(&a).collect(); + /// + /// assert_eq!(diff1, diff2); + /// assert_eq!(diff1, [1, 4].iter().collect()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn symmetric_difference<'a>(&'a self, other: &'a Self) -> SymmetricDifference<'a, T, S, A> { + SymmetricDifference { + iter: self.difference(other).chain(other.difference(self)), + } + } + + /// Visits the values representing the intersection, + /// i.e., the values that are both in `self` and `other`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let a: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect(); + /// + /// // Print 2, 3 in arbitrary order. + /// for x in a.intersection(&b) { + /// println!("{}", x); + /// } + /// + /// let intersection: HashSet<_> = a.intersection(&b).collect(); + /// assert_eq!(intersection, [2, 3].iter().collect()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T, S, A> { + let (smaller, larger) = if self.len() <= other.len() { + (self, other) + } else { + (other, self) + }; + Intersection { + iter: smaller.iter(), + other: larger, + } + } + + /// Visits the values representing the union, + /// i.e., all the values in `self` or `other`, without duplicates. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let a: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect(); + /// + /// // Print 1, 2, 3, 4 in arbitrary order. + /// for x in a.union(&b) { + /// println!("{}", x); + /// } + /// + /// let union: HashSet<_> = a.union(&b).collect(); + /// assert_eq!(union, [1, 2, 3, 4].iter().collect()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T, S, A> { + // We'll iterate one set in full, and only the remaining difference from the other. + // Use the smaller set for the difference in order to reduce hash lookups. + let (smaller, larger) = if self.len() <= other.len() { + (self, other) + } else { + (other, self) + }; + Union { + iter: larger.iter().chain(smaller.difference(larger)), + } + } + + /// Returns `true` if the set contains a value. + /// + /// The value may be any borrowed form of the set's value type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the value type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let set: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// assert_eq!(set.contains(&1), true); + /// assert_eq!(set.contains(&4), false); + /// ``` + /// + #[cfg_attr(feature = "inline-more", inline)] + pub fn contains(&self, value: &Q) -> bool + where + Q: Hash + Equivalent + ?Sized, + { + self.map.contains_key(value) + } + + /// Returns a reference to the value in the set, if any, that is equal to the given value. + /// + /// The value may be any borrowed form of the set's value type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the value type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let set: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// assert_eq!(set.get(&2), Some(&2)); + /// assert_eq!(set.get(&4), None); + /// ``` + /// + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self, value: &Q) -> Option<&T> + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + match self.map.get_key_value(value) { + Some((k, _)) => Some(k), + None => None, + } + } + + /// Inserts the given `value` into the set if it is not present, then + /// returns a reference to the value in the set. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// assert_eq!(set.len(), 3); + /// assert_eq!(set.get_or_insert(2), &2); + /// assert_eq!(set.get_or_insert(100), &100); + /// assert_eq!(set.len(), 4); // 100 was inserted + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_or_insert(&mut self, value: T) -> &T { + match self.map.entry(value) { + map::Entry::Occupied(entry) => entry, + map::Entry::Vacant(entry) => entry.insert_entry(()), + } + .into_entry() + .0 + } + + /// Inserts a value computed from `f` into the set if the given `value` is + /// not present, then returns a reference to the value in the set. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet = ["cat", "dog", "horse"] + /// .iter().map(|&pet| pet.to_owned()).collect(); + /// + /// assert_eq!(set.len(), 3); + /// for &pet in &["cat", "dog", "fish"] { + /// let value = set.get_or_insert_with(pet, str::to_owned); + /// assert_eq!(value, pet); + /// } + /// assert_eq!(set.len(), 4); // a new "fish" was inserted + /// ``` + /// + /// The following example will panic because the new value doesn't match. + /// + /// ```should_panic + /// let mut set = hashbrown::HashSet::new(); + /// set.get_or_insert_with("rust", |_| String::new()); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get_or_insert_with(&mut self, value: &Q, f: F) -> &T + where + Q: Hash + Equivalent + ?Sized, + F: FnOnce(&Q) -> T, + { + match self.map.entry_ref(value) { + map::EntryRef::Occupied(entry) => entry, + map::EntryRef::Vacant(entry) => entry.insert_entry_with_key(f(value), ()), + } + .into_entry() + .0 + } + + /// Gets the given value's corresponding entry in the set for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::hash_set::Entry::*; + /// + /// let mut singles = HashSet::new(); + /// let mut dupes = HashSet::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// if let Vacant(dupe_entry) = dupes.entry(ch) { + /// // We haven't already seen a duplicate, so + /// // check if we've at least seen it once. + /// match singles.entry(ch) { + /// Vacant(single_entry) => { + /// // We found a new character for the first time. + /// single_entry.insert(); + /// } + /// Occupied(single_entry) => { + /// // We've already seen this once, "move" it to dupes. + /// single_entry.remove(); + /// dupe_entry.insert(); + /// } + /// } + /// } + /// } + /// + /// assert!(!singles.contains(&'t') && dupes.contains(&'t')); + /// assert!(singles.contains(&'u') && !dupes.contains(&'u')); + /// assert!(!singles.contains(&'v') && !dupes.contains(&'v')); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn entry(&mut self, value: T) -> Entry<'_, T, S, A> { + match self.map.entry(value) { + map::Entry::Occupied(entry) => Entry::Occupied(OccupiedEntry { inner: entry }), + map::Entry::Vacant(entry) => Entry::Vacant(VacantEntry { inner: entry }), + } + } + + /// Returns `true` if `self` has no elements in common with `other`. + /// This is equivalent to checking for an empty intersection. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let a: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let mut b = HashSet::new(); + /// + /// assert_eq!(a.is_disjoint(&b), true); + /// b.insert(4); + /// assert_eq!(a.is_disjoint(&b), true); + /// b.insert(1); + /// assert_eq!(a.is_disjoint(&b), false); + /// ``` + pub fn is_disjoint(&self, other: &Self) -> bool { + self.intersection(other).next().is_none() + } + + /// Returns `true` if the set is a subset of another, + /// i.e., `other` contains at least all the values in `self`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let sup: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// let mut set = HashSet::new(); + /// + /// assert_eq!(set.is_subset(&sup), true); + /// set.insert(2); + /// assert_eq!(set.is_subset(&sup), true); + /// set.insert(4); + /// assert_eq!(set.is_subset(&sup), false); + /// ``` + pub fn is_subset(&self, other: &Self) -> bool { + self.len() <= other.len() && self.iter().all(|v| other.contains(v)) + } + + /// Returns `true` if the set is a superset of another, + /// i.e., `self` contains at least all the values in `other`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let sub: HashSet<_> = [1, 2].into_iter().collect(); + /// let mut set = HashSet::new(); + /// + /// assert_eq!(set.is_superset(&sub), false); + /// + /// set.insert(0); + /// set.insert(1); + /// assert_eq!(set.is_superset(&sub), false); + /// + /// set.insert(2); + /// assert_eq!(set.is_superset(&sub), true); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn is_superset(&self, other: &Self) -> bool { + other.is_subset(self) + } + + /// Adds a value to the set. + /// + /// If the set did not have this value present, `true` is returned. + /// + /// If the set did have this value present, `false` is returned. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set = HashSet::new(); + /// + /// assert_eq!(set.insert(2), true); + /// assert_eq!(set.insert(2), false); + /// assert_eq!(set.len(), 1); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(&mut self, value: T) -> bool { + self.map.insert(value, ()).is_none() + } + + /// Insert a value the set without checking if the value already exists in the set. + /// + /// This operation is faster than regular insert, because it does not perform + /// lookup before insertion. + /// + /// This operation is useful during initial population of the set. + /// For example, when constructing a set from another set, we know + /// that values are unique. + /// + /// # Safety + /// + /// This operation is safe if a value does not exist in the set. + /// + /// However, if a value exists in the set already, the behavior is unspecified: + /// this operation may panic, loop forever, or any following operation with the set + /// may panic, loop forever or return arbitrary result. + /// + /// That said, this operation (and following operations) are guaranteed to + /// not violate memory safety. + /// + /// However this operation is still unsafe because the resulting `HashSet` + /// may be passed to unsafe code which does expect the set to behave + /// correctly, and would cause unsoundness as a result. + #[cfg_attr(feature = "inline-more", inline)] + pub unsafe fn insert_unique_unchecked(&mut self, value: T) -> &T { + unsafe { self.map.insert_unique_unchecked(value, ()).0 } + } + + /// Adds a value to the set, replacing the existing value, if any, that is equal to the given + /// one. Returns the replaced value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set = HashSet::new(); + /// set.insert(Vec::::new()); + /// + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 0); + /// set.replace(Vec::with_capacity(10)); + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn replace(&mut self, value: T) -> Option { + let value = UnsafeCell::new(value); + // SAFETY: We know the key is no longer accessed after the initial check. + match self.map.entry_ref(unsafe { &*value.get() }) { + map::EntryRef::Occupied(mut entry) => { + // SAFETY: We know the key will not be accessed any more, and + // that the key is equivalent to the one in the entry. + Some(unsafe { entry.replace_key_unchecked(value.into_inner()) }) + } + map::EntryRef::Vacant(entry) => { + // SAFETY: A value is equivalent to itself. + unsafe { + entry.insert_with_key_unchecked(value.into_inner(), ()); + } + None + } + } + } + + /// Removes a value from the set. Returns whether the value was + /// present in the set. + /// + /// The value may be any borrowed form of the set's value type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the value type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set = HashSet::new(); + /// + /// set.insert(2); + /// assert_eq!(set.remove(&2), true); + /// assert_eq!(set.remove(&2), false); + /// ``` + /// + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(&mut self, value: &Q) -> bool + where + Q: Hash + Equivalent + ?Sized, + { + self.map.remove(value).is_some() + } + + /// Removes and returns the value in the set, if any, that is equal to the given one. + /// + /// The value may be any borrowed form of the set's value type, but + /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for + /// the value type. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect(); + /// assert_eq!(set.take(&2), Some(2)); + /// assert_eq!(set.take(&2), None); + /// ``` + /// + #[cfg_attr(feature = "inline-more", inline)] + pub fn take(&mut self, value: &Q) -> Option + where + Q: Hash + Equivalent + ?Sized, + { + // Avoid `Option::map` because it bloats LLVM IR. + match self.map.remove_entry(value) { + Some((k, _)) => Some(k), + None => None, + } + } + + /// Returns the total amount of memory allocated internally by the hash + /// set, in bytes. + /// + /// The returned number is informational only. It is intended to be + /// primarily used for memory profiling. + #[inline] + pub fn allocation_size(&self) -> usize { + self.map.allocation_size() + } +} + +impl PartialEq for HashSet +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + fn eq(&self, other: &Self) -> bool { + if self.len() != other.len() { + return false; + } + + self.iter().all(|key| other.contains(key)) + } +} + +impl Eq for HashSet +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ +} + +impl fmt::Debug for HashSet +where + T: fmt::Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_set().entries(self.iter()).finish() + } +} + +impl From> for HashSet +where + A: Allocator, +{ + fn from(map: HashMap) -> Self { + Self { map } + } +} + +impl FromIterator for HashSet +where + T: Eq + Hash, + S: BuildHasher + Default, + A: Default + Allocator, +{ + #[cfg_attr(feature = "inline-more", inline)] + fn from_iter>(iter: I) -> Self { + let mut set = Self::with_hasher_in(Default::default(), Default::default()); + set.extend(iter); + set + } +} + +// The default hasher is used to match the std implementation signature +#[cfg(feature = "default-hasher")] +impl From<[T; N]> for HashSet +where + T: Eq + Hash, + A: Default + Allocator, +{ + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let set1 = HashSet::from([1, 2, 3, 4]); + /// let set2: HashSet<_> = [1, 2, 3, 4].into(); + /// assert_eq!(set1, set2); + /// ``` + fn from(arr: [T; N]) -> Self { + arr.into_iter().collect() + } +} + +impl Extend for HashSet +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + #[cfg_attr(feature = "inline-more", inline)] + fn extend>(&mut self, iter: I) { + self.map.extend(iter.into_iter().map(|k| (k, ()))); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_one(&mut self, k: T) { + self.map.insert(k, ()); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_reserve(&mut self, additional: usize) { + Extend::<(T, ())>::extend_reserve(&mut self.map, additional); + } +} + +impl<'a, T, S, A> Extend<&'a T> for HashSet +where + T: 'a + Eq + Hash + Copy, + S: BuildHasher, + A: Allocator, +{ + #[cfg_attr(feature = "inline-more", inline)] + fn extend>(&mut self, iter: I) { + self.extend(iter.into_iter().copied()); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_one(&mut self, k: &'a T) { + self.map.insert(*k, ()); + } + + #[inline] + #[cfg(feature = "nightly")] + fn extend_reserve(&mut self, additional: usize) { + Extend::<(T, ())>::extend_reserve(&mut self.map, additional); + } +} + +impl Default for HashSet +where + S: Default, + A: Default + Allocator, +{ + /// Creates an empty `HashSet` with the `Default` value for the hasher. + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + map: HashMap::default(), + } + } +} + +impl BitOr<&HashSet> for &HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher + Default, + A: Allocator + Default, +{ + type Output = HashSet; + + /// Returns the union of `self` and `rhs` as a new `HashSet`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// let set = &a | &b; + /// + /// let mut i = 0; + /// let expected = [1, 2, 3, 4, 5]; + /// for x in &set { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitor(self, rhs: &HashSet) -> HashSet { + self.union(rhs).cloned().collect() + } +} + +impl BitAnd<&HashSet> for &HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher + Default, + A: Allocator + Default, +{ + type Output = HashSet; + + /// Returns the intersection of `self` and `rhs` as a new `HashSet`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![2, 3, 4].into_iter().collect(); + /// + /// let set = &a & &b; + /// + /// let mut i = 0; + /// let expected = [2, 3]; + /// for x in &set { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitand(self, rhs: &HashSet) -> HashSet { + self.intersection(rhs).cloned().collect() + } +} + +impl BitXor<&HashSet> for &HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher + Default, + A: Allocator + Default, +{ + type Output = HashSet; + + /// Returns the symmetric difference of `self` and `rhs` as a new `HashSet`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// let set = &a ^ &b; + /// + /// let mut i = 0; + /// let expected = [1, 2, 4, 5]; + /// for x in &set { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitxor(self, rhs: &HashSet) -> HashSet { + self.symmetric_difference(rhs).cloned().collect() + } +} + +impl Sub<&HashSet> for &HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher + Default, + A: Allocator + Default, +{ + type Output = HashSet; + + /// Returns the difference of `self` and `rhs` as a new `HashSet`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// let set = &a - &b; + /// + /// let mut i = 0; + /// let expected = [1, 2]; + /// for x in &set { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn sub(self, rhs: &HashSet) -> HashSet { + self.difference(rhs).cloned().collect() + } +} + +impl BitOrAssign<&HashSet> for HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher, + A: Allocator, +{ + /// Modifies this set to contain the union of `self` and `rhs`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// a |= &b; + /// + /// let mut i = 0; + /// let expected = [1, 2, 3, 4, 5]; + /// for x in &a { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitor_assign(&mut self, rhs: &HashSet) { + for item in rhs { + if !self.contains(item) { + self.insert(item.clone()); + } + } + } +} + +impl BitAndAssign<&HashSet> for HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher, + A: Allocator, +{ + /// Modifies this set to contain the intersection of `self` and `rhs`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![2, 3, 4].into_iter().collect(); + /// + /// a &= &b; + /// + /// let mut i = 0; + /// let expected = [2, 3]; + /// for x in &a { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitand_assign(&mut self, rhs: &HashSet) { + self.retain(|item| rhs.contains(item)); + } +} + +impl BitXorAssign<&HashSet> for HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher, + A: Allocator, +{ + /// Modifies this set to contain the symmetric difference of `self` and `rhs`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// a ^= &b; + /// + /// let mut i = 0; + /// let expected = [1, 2, 4, 5]; + /// for x in &a { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn bitxor_assign(&mut self, rhs: &HashSet) { + for item in rhs { + match self.map.entry_ref(item) { + map::EntryRef::Occupied(entry) => { + entry.remove(); + } + map::EntryRef::Vacant(entry) => { + entry.insert(()); + } + } + } + } +} + +impl SubAssign<&HashSet> for HashSet +where + T: Eq + Hash + Clone, + S: BuildHasher, + A: Allocator, +{ + /// Modifies this set to contain the difference of `self` and `rhs`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut a: HashSet<_> = vec![1, 2, 3].into_iter().collect(); + /// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect(); + /// + /// a -= &b; + /// + /// let mut i = 0; + /// let expected = [1, 2]; + /// for x in &a { + /// assert!(expected.contains(x)); + /// i += 1; + /// } + /// assert_eq!(i, expected.len()); + /// ``` + fn sub_assign(&mut self, rhs: &HashSet) { + if rhs.len() < self.len() { + for item in rhs { + self.remove(item); + } + } else { + self.retain(|item| !rhs.contains(item)); + } + } +} + +/// An iterator over the items of a `HashSet`. +/// +/// This `struct` is created by the [`iter`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`iter`]: HashSet::iter +pub struct Iter<'a, K> { + iter: Keys<'a, K, ()>, +} + +/// An owning iterator over the items of a `HashSet`. +/// +/// This `struct` is created by the [`into_iter`] method on [`HashSet`] +/// (provided by the `IntoIterator` trait). See its documentation for more. +/// +/// [`into_iter`]: HashSet::into_iter +pub struct IntoIter { + iter: map::IntoIter, +} + +/// A draining iterator over the items of a `HashSet`. +/// +/// This `struct` is created by the [`drain`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`drain`]: HashSet::drain +pub struct Drain<'a, K, A: Allocator = Global> { + iter: map::Drain<'a, K, (), A>, +} + +/// A draining iterator over entries of a `HashSet` which don't satisfy the predicate `f`. +/// +/// This `struct` is created by the [`extract_if`] method on [`HashSet`]. See its +/// documentation for more. +/// +/// [`extract_if`]: HashSet::extract_if +#[must_use = "Iterators are lazy unless consumed"] +pub struct ExtractIf<'a, K, F, A: Allocator = Global> { + f: F, + inner: RawExtractIf<'a, (K, ()), A>, +} + +/// A lazy iterator producing elements in the intersection of `HashSet`s. +/// +/// This `struct` is created by the [`intersection`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`intersection`]: HashSet::intersection +pub struct Intersection<'a, T, S, A: Allocator = Global> { + // iterator of the first set + iter: Iter<'a, T>, + // the second set + other: &'a HashSet, +} + +/// A lazy iterator producing elements in the difference of `HashSet`s. +/// +/// This `struct` is created by the [`difference`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`difference`]: HashSet::difference +pub struct Difference<'a, T, S, A: Allocator = Global> { + // iterator of the first set + iter: Iter<'a, T>, + // the second set + other: &'a HashSet, +} + +/// A lazy iterator producing elements in the symmetric difference of `HashSet`s. +/// +/// This `struct` is created by the [`symmetric_difference`] method on +/// [`HashSet`]. See its documentation for more. +/// +/// [`symmetric_difference`]: HashSet::symmetric_difference +pub struct SymmetricDifference<'a, T, S, A: Allocator = Global> { + iter: Chain, Difference<'a, T, S, A>>, +} + +/// A lazy iterator producing elements in the union of `HashSet`s. +/// +/// This `struct` is created by the [`union`] method on [`HashSet`]. +/// See its documentation for more. +/// +/// [`union`]: HashSet::union +pub struct Union<'a, T, S, A: Allocator = Global> { + iter: Chain, Difference<'a, T, S, A>>, +} + +impl<'a, T, S, A: Allocator> IntoIterator for &'a HashSet { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +impl IntoIterator for HashSet { + type Item = T; + type IntoIter = IntoIter; + + /// Creates a consuming iterator, that is, one that moves each value out + /// of the set in arbitrary order. The set cannot be used after calling + /// this. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// let mut set = HashSet::new(); + /// set.insert("a".to_string()); + /// set.insert("b".to_string()); + /// + /// // Not possible to collect to a Vec with a regular `.iter()`. + /// let v: Vec = set.into_iter().collect(); + /// + /// // Will print in an arbitrary order. + /// for x in &v { + /// println!("{}", x); + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + fn into_iter(self) -> IntoIter { + IntoIter { + iter: self.map.into_iter(), + } + } +} + +impl Clone for Iter<'_, K> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Iter { + iter: self.iter.clone(), + } + } +} +impl Default for Iter<'_, K> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Iter { + iter: Default::default(), + } + } +} +impl<'a, K> Iterator for Iter<'a, K> { + type Item = &'a K; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a K> { + self.iter.next() + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, f) + } +} +impl ExactSizeIterator for Iter<'_, K> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.iter.len() + } +} +impl FusedIterator for Iter<'_, K> {} + +impl fmt::Debug for Iter<'_, K> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IntoIter { + iter: Default::default(), + } + } +} +impl Iterator for IntoIter { + type Item = K; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.iter.next() { + Some((k, _)) => Some(k), + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, |acc, (k, ())| f(acc, k)) + } +} +impl ExactSizeIterator for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.iter.len() + } +} +impl FusedIterator for IntoIter {} + +impl fmt::Debug for IntoIter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let entries_iter = self.iter.iter().map(|(k, _)| k); + f.debug_list().entries(entries_iter).finish() + } +} + +impl Iterator for Drain<'_, K, A> { + type Item = K; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.iter.next() { + Some((k, _)) => Some(k), + None => None, + } + } + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, |acc, (k, ())| f(acc, k)) + } +} +impl ExactSizeIterator for Drain<'_, K, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn len(&self) -> usize { + self.iter.len() + } +} +impl FusedIterator for Drain<'_, K, A> {} + +impl fmt::Debug for Drain<'_, K, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let entries_iter = self.iter.iter().map(|(k, _)| k); + f.debug_list().entries(entries_iter).finish() + } +} + +impl Iterator for ExtractIf<'_, K, F, A> +where + F: FnMut(&K) -> bool, +{ + type Item = K; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option { + self.inner + .next(|&mut (ref k, ())| (self.f)(k)) + .map(|(k, ())| k) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, self.inner.iter.size_hint().1) + } +} + +impl FusedIterator for ExtractIf<'_, K, F, A> where F: FnMut(&K) -> bool {} + +impl Clone for Intersection<'_, T, S, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Intersection { + iter: self.iter.clone(), + ..*self + } + } +} + +impl<'a, T, S, A> Iterator for Intersection<'a, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + type Item = &'a T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a T> { + loop { + let elt = self.iter.next()?; + if self.other.contains(elt) { + return Some(elt); + } + } + } + + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + let (_, upper) = self.iter.size_hint(); + (0, upper) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, |acc, elt| { + if self.other.contains(elt) { + f(acc, elt) + } else { + acc + } + }) + } +} + +impl fmt::Debug for Intersection<'_, T, S, A> +where + T: fmt::Debug + Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +impl FusedIterator for Intersection<'_, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ +} + +impl Clone for Difference<'_, T, S, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Difference { + iter: self.iter.clone(), + ..*self + } + } +} + +impl<'a, T, S, A> Iterator for Difference<'a, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + type Item = &'a T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a T> { + loop { + let elt = self.iter.next()?; + if !self.other.contains(elt) { + return Some(elt); + } + } + } + + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + let (lower, upper) = self.iter.size_hint(); + (lower.saturating_sub(self.other.len()), upper) + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, |acc, elt| { + if self.other.contains(elt) { + acc + } else { + f(acc, elt) + } + }) + } +} + +impl FusedIterator for Difference<'_, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ +} + +impl fmt::Debug for Difference<'_, T, S, A> +where + T: fmt::Debug + Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +impl Clone for SymmetricDifference<'_, T, S, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + SymmetricDifference { + iter: self.iter.clone(), + } + } +} + +impl<'a, T, S, A> Iterator for SymmetricDifference<'a, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + type Item = &'a T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a T> { + self.iter.next() + } + + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, f) + } +} + +impl FusedIterator for SymmetricDifference<'_, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ +} + +impl fmt::Debug for SymmetricDifference<'_, T, S, A> +where + T: fmt::Debug + Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +impl Clone for Union<'_, T, S, A> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Self { + Union { + iter: self.iter.clone(), + } + } +} + +impl FusedIterator for Union<'_, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ +} + +impl fmt::Debug for Union<'_, T, S, A> +where + T: fmt::Debug + Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +impl<'a, T, S, A> Iterator for Union<'a, T, S, A> +where + T: Eq + Hash, + S: BuildHasher, + A: Allocator, +{ + type Item = &'a T; + + #[cfg_attr(feature = "inline-more", inline)] + fn next(&mut self) -> Option<&'a T> { + self.iter.next() + } + + #[cfg_attr(feature = "inline-more", inline)] + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + + #[cfg_attr(feature = "inline-more", inline)] + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.iter.fold(init, f) + } +} + +/// A view into a single entry in a set, which may either be vacant or occupied. +/// +/// This `enum` is constructed from the [`entry`] method on [`HashSet`]. +/// +/// [`entry`]: HashSet::entry +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_set::{Entry, HashSet, OccupiedEntry}; +/// +/// let mut set = HashSet::new(); +/// set.extend(["a", "b", "c"]); +/// assert_eq!(set.len(), 3); +/// +/// // Existing value (insert) +/// let entry: Entry<_, _> = set.entry("a"); +/// let _raw_o: OccupiedEntry<_, _> = entry.insert(); +/// assert_eq!(set.len(), 3); +/// // Nonexistent value (insert) +/// set.entry("d").insert(); +/// +/// // Existing value (or_insert) +/// set.entry("b").or_insert(); +/// // Nonexistent value (or_insert) +/// set.entry("e").or_insert(); +/// +/// println!("Our HashSet: {:?}", set); +/// +/// let mut vec: Vec<_> = set.iter().copied().collect(); +/// // The `Iter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, ["a", "b", "c", "d", "e"]); +/// ``` +pub enum Entry<'a, T, S, A = Global> +where + A: Allocator, +{ + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_set::{Entry, HashSet}; + /// let mut set: HashSet<_> = ["a", "b"].into(); + /// + /// match set.entry("a") { + /// Entry::Vacant(_) => unreachable!(), + /// Entry::Occupied(_) => { } + /// } + /// ``` + Occupied(OccupiedEntry<'a, T, S, A>), + + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_set::{Entry, HashSet}; + /// let mut set: HashSet<&str> = HashSet::new(); + /// + /// match set.entry("a") { + /// Entry::Occupied(_) => unreachable!(), + /// Entry::Vacant(_) => { } + /// } + /// ``` + Vacant(VacantEntry<'a, T, S, A>), +} + +impl fmt::Debug for Entry<'_, T, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Entry::Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), + Entry::Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(), + } + } +} + +/// A view into an occupied entry in a `HashSet`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_set::{Entry, HashSet, OccupiedEntry}; +/// +/// let mut set = HashSet::new(); +/// set.extend(["a", "b", "c"]); +/// +/// let _entry_o: OccupiedEntry<_, _> = set.entry("a").insert(); +/// assert_eq!(set.len(), 3); +/// +/// // Existing key +/// match set.entry("a") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.get(), &"a"); +/// } +/// } +/// +/// assert_eq!(set.len(), 3); +/// +/// // Existing key (take) +/// match set.entry("c") { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.remove(), "c"); +/// } +/// } +/// assert_eq!(set.get(&"c"), None); +/// assert_eq!(set.len(), 2); +/// ``` +pub struct OccupiedEntry<'a, T, S, A: Allocator = Global> { + inner: map::OccupiedEntry<'a, T, (), S, A>, +} + +impl fmt::Debug for OccupiedEntry<'_, T, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedEntry") + .field("value", self.get()) + .finish() + } +} + +/// A view into a vacant entry in a `HashSet`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// use hashbrown::hash_set::{Entry, HashSet, VacantEntry}; +/// +/// let mut set = HashSet::<&str>::new(); +/// +/// let entry_v: VacantEntry<_, _> = match set.entry("a") { +/// Entry::Vacant(view) => view, +/// Entry::Occupied(_) => unreachable!(), +/// }; +/// entry_v.insert(); +/// assert!(set.contains("a") && set.len() == 1); +/// +/// // Nonexistent key (insert) +/// match set.entry("b") { +/// Entry::Vacant(view) => { view.insert(); }, +/// Entry::Occupied(_) => unreachable!(), +/// } +/// assert!(set.contains("b") && set.len() == 2); +/// ``` +pub struct VacantEntry<'a, T, S, A: Allocator = Global> { + inner: map::VacantEntry<'a, T, (), S, A>, +} + +impl fmt::Debug for VacantEntry<'_, T, S, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("VacantEntry").field(self.get()).finish() + } +} + +impl<'a, T, S, A: Allocator> Entry<'a, T, S, A> { + /// Sets the value of the entry, and returns an `OccupiedEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// let entry = set.entry("horseyland").insert(); + /// + /// assert_eq!(entry.get(), &"horseyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self) -> OccupiedEntry<'a, T, S, A> + where + T: Hash, + S: BuildHasher, + { + match self { + Entry::Occupied(entry) => entry, + Entry::Vacant(entry) => entry.insert(), + } + } + + /// Ensures a value is in the entry by inserting if it was vacant. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// + /// // nonexistent key + /// set.entry("poneyland").or_insert(); + /// assert!(set.contains("poneyland")); + /// + /// // existing key + /// set.entry("poneyland").or_insert(); + /// assert!(set.contains("poneyland")); + /// assert_eq!(set.len(), 1); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn or_insert(self) + where + T: Hash, + S: BuildHasher, + { + if let Entry::Vacant(entry) = self { + entry.insert(); + } + } + + /// Returns a reference to this entry's value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// set.entry("poneyland").or_insert(); + /// // existing key + /// assert_eq!(set.entry("poneyland").get(), &"poneyland"); + /// // nonexistent key + /// assert_eq!(set.entry("horseland").get(), &"horseland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &T { + match *self { + Entry::Occupied(ref entry) => entry.get(), + Entry::Vacant(ref entry) => entry.get(), + } + } +} + +impl<'a, T, S, A: Allocator> OccupiedEntry<'a, T, S, A> { + /// Gets a reference to the value in the entry. For a reference that persists beyond the + /// lifetime of the entry, see [`into_ref`](Self::into_ref). + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_set::{Entry, HashSet}; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// set.entry("poneyland").or_insert(); + /// + /// match set.entry("poneyland") { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(entry) => assert_eq!(entry.get(), &"poneyland"), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &T { + self.inner.key() + } + + /// Consumes the entry, returning a reference to the value in the [`HashSet`]. By contrast + /// with [`get`](Self::get), the reference inherits the lifetime of the parent set, so + /// will persist beyond the lifetime of the entry. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_set::{Entry, HashSet}; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// let value = set.entry("poneyland").insert().into_ref(); + /// + /// assert_eq!(&"poneyland", value); + /// ``` + /// + /// `get` used in the same context will fail to compile: + /// + /// ```compile_fail + /// # use hashbrown::hash_set::{Entry, HashSet}; + /// # let mut set: HashSet<&str> = HashSet::new(); + /// let value = set.entry("poneyland").insert().get(); + /// assert_eq!(&"poneyland", value); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_ref(self) -> &'a T { + self.inner.into_entry().0 + } + + /// Takes the value out of the entry, and returns it. + /// Keeps the allocated memory for reuse. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::hash_set::Entry; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// // The set is empty + /// assert!(set.is_empty() && set.capacity() == 0); + /// + /// set.entry("poneyland").or_insert(); + /// let capacity_before_remove = set.capacity(); + /// + /// if let Entry::Occupied(o) = set.entry("poneyland") { + /// assert_eq!(o.remove(), "poneyland"); + /// } + /// + /// assert_eq!(set.contains("poneyland"), false); + /// // Now set hold none elements but capacity is equal to the old one + /// assert!(set.len() == 0 && set.capacity() == capacity_before_remove); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(self) -> T { + self.inner.remove_entry().0 + } +} + +impl<'a, T, S, A: Allocator> VacantEntry<'a, T, S, A> { + /// Gets a reference to the value that would be used when inserting + /// through the `VacantEntry`. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// assert_eq!(set.entry("poneyland").get(), &"poneyland"); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn get(&self) -> &T { + self.inner.key() + } + + /// Take ownership of the value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::hash_set::{Entry, HashSet}; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// + /// match set.entry("poneyland") { + /// Entry::Occupied(_) => panic!(), + /// Entry::Vacant(v) => assert_eq!(v.into_value(), "poneyland"), + /// } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn into_value(self) -> T { + self.inner.into_key() + } + + /// Sets the value of the entry with the `VacantEntry`'s value. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashSet; + /// use hashbrown::hash_set::Entry; + /// + /// let mut set: HashSet<&str> = HashSet::new(); + /// + /// if let Entry::Vacant(o) = set.entry("poneyland") { + /// o.insert(); + /// } + /// assert!(set.contains("poneyland")); + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn insert(self) -> OccupiedEntry<'a, T, S, A> + where + T: Hash, + S: BuildHasher, + { + OccupiedEntry { + inner: self.inner.insert_entry(()), + } + } +} + +#[expect(dead_code)] +fn assert_covariance() { + fn set<'new, S: BuildHasher, A: Allocator>( + v: HashSet<&'static str, S, A>, + ) -> HashSet<&'new str, S, A> { + v + } + fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { + v + } + fn into_iter<'new, A: Allocator>(v: IntoIter<&'static str, A>) -> IntoIter<&'new str, A> { + v + } + fn difference<'a, 'new, A: Allocator>( + v: Difference<'a, &'static str, DefaultHashBuilder, A>, + ) -> Difference<'a, &'new str, DefaultHashBuilder, A> { + v + } + fn symmetric_difference<'a, 'new, A: Allocator>( + v: SymmetricDifference<'a, &'static str, DefaultHashBuilder, A>, + ) -> SymmetricDifference<'a, &'new str, DefaultHashBuilder, A> { + v + } + fn intersection<'a, 'new, A: Allocator>( + v: Intersection<'a, &'static str, DefaultHashBuilder, A>, + ) -> Intersection<'a, &'new str, DefaultHashBuilder, A> { + v + } + fn union<'a, 'new, A: Allocator>( + v: Union<'a, &'static str, DefaultHashBuilder, A>, + ) -> Union<'a, &'new str, DefaultHashBuilder, A> { + v + } + fn drain<'new, A: Allocator>(d: Drain<'static, &'static str, A>) -> Drain<'new, &'new str, A> { + d + } +} + +#[cfg(test)] +mod test_set { + use super::Entry::{Occupied, Vacant}; + use super::{Equivalent, HashSet}; + use crate::DefaultHashBuilder; + use crate::map::make_hash; + use std::vec::Vec; + + #[test] + fn test_zero_capacities() { + type HS = HashSet; + + let s = HS::new(); + assert_eq!(s.capacity(), 0); + + let s = HS::default(); + assert_eq!(s.capacity(), 0); + + let s = HS::with_hasher(DefaultHashBuilder::default()); + assert_eq!(s.capacity(), 0); + + let s = HS::with_capacity(0); + assert_eq!(s.capacity(), 0); + + let s = HS::with_capacity_and_hasher(0, DefaultHashBuilder::default()); + assert_eq!(s.capacity(), 0); + + let mut s = HS::new(); + s.insert(1); + s.insert(2); + s.remove(&1); + s.remove(&2); + s.shrink_to_fit(); + assert_eq!(s.capacity(), 0); + + let mut s = HS::new(); + s.reserve(0); + assert_eq!(s.capacity(), 0); + } + + #[test] + fn test_disjoint() { + let mut xs = HashSet::new(); + let mut ys = HashSet::new(); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(xs.insert(5)); + assert!(ys.insert(11)); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(xs.insert(7)); + assert!(xs.insert(19)); + assert!(xs.insert(4)); + assert!(ys.insert(2)); + assert!(ys.insert(-11)); + assert!(xs.is_disjoint(&ys)); + assert!(ys.is_disjoint(&xs)); + assert!(ys.insert(7)); + assert!(!xs.is_disjoint(&ys)); + assert!(!ys.is_disjoint(&xs)); + } + + #[test] + fn test_subset_and_superset() { + let mut a = HashSet::new(); + assert!(a.insert(0)); + assert!(a.insert(5)); + assert!(a.insert(11)); + assert!(a.insert(7)); + + let mut b = HashSet::new(); + assert!(b.insert(0)); + assert!(b.insert(7)); + assert!(b.insert(19)); + assert!(b.insert(250)); + assert!(b.insert(11)); + assert!(b.insert(200)); + + assert!(!a.is_subset(&b)); + assert!(!a.is_superset(&b)); + assert!(!b.is_subset(&a)); + assert!(!b.is_superset(&a)); + + assert!(b.insert(5)); + + assert!(a.is_subset(&b)); + assert!(!a.is_superset(&b)); + assert!(!b.is_subset(&a)); + assert!(b.is_superset(&a)); + } + + #[test] + fn test_iterate() { + let mut a = HashSet::new(); + for i in 0..32 { + assert!(a.insert(i)); + } + let mut observed: u32 = 0; + for k in &a { + observed |= 1 << *k; + } + assert_eq!(observed, 0xFFFF_FFFF); + } + + #[test] + fn test_intersection() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(11)); + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(77)); + assert!(a.insert(103)); + assert!(a.insert(5)); + assert!(a.insert(-5)); + + assert!(b.insert(2)); + assert!(b.insert(11)); + assert!(b.insert(77)); + assert!(b.insert(-9)); + assert!(b.insert(-42)); + assert!(b.insert(5)); + assert!(b.insert(3)); + + let mut i = 0; + let expected = [3, 5, 11, 77]; + for x in a.intersection(&b) { + assert!(expected.contains(x)); + i += 1; + } + assert_eq!(i, expected.len()); + } + + #[test] + fn test_difference() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + + assert!(b.insert(3)); + assert!(b.insert(9)); + + let mut i = 0; + let expected = [1, 5, 11]; + for x in a.difference(&b) { + assert!(expected.contains(x)); + i += 1; + } + assert_eq!(i, expected.len()); + } + + #[test] + fn test_symmetric_difference() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + + assert!(b.insert(-2)); + assert!(b.insert(3)); + assert!(b.insert(9)); + assert!(b.insert(14)); + assert!(b.insert(22)); + + let mut i = 0; + let expected = [-2, 1, 5, 11, 14, 22]; + for x in a.symmetric_difference(&b) { + assert!(expected.contains(x)); + i += 1; + } + assert_eq!(i, expected.len()); + } + + #[test] + fn test_sub_assign() { + let mut a: HashSet<_> = vec![1, 2, 3, 4, 5].into_iter().collect(); + let b: HashSet<_> = vec![4, 5, 6].into_iter().collect(); + + a -= &b; + + let mut i = 0; + let expected = [1, 2, 3]; + for x in &a { + assert!(expected.contains(x)); + i += 1; + } + assert_eq!(i, expected.len()); + } + + #[test] + fn test_union() { + let mut a = HashSet::new(); + let mut b = HashSet::new(); + + assert!(a.insert(1)); + assert!(a.insert(3)); + assert!(a.insert(5)); + assert!(a.insert(9)); + assert!(a.insert(11)); + assert!(a.insert(16)); + assert!(a.insert(19)); + assert!(a.insert(24)); + + assert!(b.insert(-2)); + assert!(b.insert(1)); + assert!(b.insert(5)); + assert!(b.insert(9)); + assert!(b.insert(13)); + assert!(b.insert(19)); + + let mut i = 0; + let expected = [-2, 1, 3, 5, 9, 11, 13, 16, 19, 24]; + for x in a.union(&b) { + assert!(expected.contains(x)); + i += 1; + } + assert_eq!(i, expected.len()); + } + + #[test] + fn test_from_map() { + let mut a = crate::HashMap::new(); + a.insert(1, ()); + a.insert(2, ()); + a.insert(3, ()); + a.insert(4, ()); + + let a: HashSet<_> = a.into(); + + assert_eq!(a.len(), 4); + assert!(a.contains(&1)); + assert!(a.contains(&2)); + assert!(a.contains(&3)); + assert!(a.contains(&4)); + } + + #[test] + fn test_from_iter() { + let xs = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]; + + let set: HashSet<_> = xs.iter().copied().collect(); + + for x in &xs { + assert!(set.contains(x)); + } + + assert_eq!(set.iter().len(), xs.len() - 1); + } + + #[test] + fn test_move_iter() { + let hs = { + let mut hs = HashSet::new(); + + hs.insert('a'); + hs.insert('b'); + + hs + }; + + let v = hs.into_iter().collect::>(); + assert!(v == ['a', 'b'] || v == ['b', 'a']); + } + + #[test] + fn test_eq() { + // These constants once happened to expose a bug in insert(). + // I'm keeping them around to prevent a regression. + let mut s1 = HashSet::new(); + + s1.insert(1); + s1.insert(2); + s1.insert(3); + + let mut s2 = HashSet::new(); + + s2.insert(1); + s2.insert(2); + + assert_ne!(s1, s2); + + s2.insert(3); + + assert_eq!(s1, s2); + } + + #[test] + fn test_show() { + let mut set = HashSet::new(); + let empty = HashSet::::new(); + + set.insert(1); + set.insert(2); + + let set_str = format!("{set:?}"); + + assert!(set_str == "{1, 2}" || set_str == "{2, 1}"); + assert_eq!(format!("{empty:?}"), "{}"); + } + + #[test] + fn test_trivial_drain() { + let mut s = HashSet::::new(); + for _ in s.drain() {} + assert!(s.is_empty()); + drop(s); + + let mut s = HashSet::::new(); + drop(s.drain()); + assert!(s.is_empty()); + } + + #[test] + fn test_drain() { + let mut s: HashSet<_> = (1..100).collect(); + + // try this a bunch of times to make sure we don't screw up internal state. + for _ in 0..20 { + assert_eq!(s.len(), 99); + + { + let mut last_i = 0; + let mut d = s.drain(); + for (i, x) in d.by_ref().take(50).enumerate() { + last_i = i; + assert!(x != 0); + } + assert_eq!(last_i, 49); + } + + assert!(s.is_empty(), "s should be empty!"); + + // reset to try again. + s.extend(1..100); + } + } + + #[test] + fn test_replace() { + use core::hash; + + #[derive(Debug)] + #[expect(dead_code)] + struct Foo(&'static str, i32); + + impl PartialEq for Foo { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } + } + + impl Eq for Foo {} + + impl hash::Hash for Foo { + fn hash(&self, h: &mut H) { + self.0.hash(h); + } + } + + let mut s = HashSet::new(); + assert_eq!(s.replace(Foo("a", 1)), None); + assert_eq!(s.len(), 1); + assert_eq!(s.replace(Foo("a", 2)), Some(Foo("a", 1))); + assert_eq!(s.len(), 1); + + let mut it = s.iter(); + assert_eq!(it.next(), Some(&Foo("a", 2))); + assert_eq!(it.next(), None); + } + + #[test] + fn test_extend_ref() { + let mut a = HashSet::new(); + a.insert(1); + + a.extend([2, 3, 4]); + + assert_eq!(a.len(), 4); + assert!(a.contains(&1)); + assert!(a.contains(&2)); + assert!(a.contains(&3)); + assert!(a.contains(&4)); + + let mut b = HashSet::new(); + b.insert(5); + b.insert(6); + + a.extend(&b); + + assert_eq!(a.len(), 6); + assert!(a.contains(&1)); + assert!(a.contains(&2)); + assert!(a.contains(&3)); + assert!(a.contains(&4)); + assert!(a.contains(&5)); + assert!(a.contains(&6)); + } + + #[test] + fn test_retain() { + let xs = [1, 2, 3, 4, 5, 6]; + let mut set: HashSet = xs.iter().copied().collect(); + set.retain(|&k| k % 2 == 0); + assert_eq!(set.len(), 3); + assert!(set.contains(&2)); + assert!(set.contains(&4)); + assert!(set.contains(&6)); + } + + #[test] + fn test_extract_if() { + { + let mut set: HashSet = (0..8).collect(); + let drained = set.extract_if(|&k| k % 2 == 0); + let mut out = drained.collect::>(); + out.sort_unstable(); + assert_eq!(vec![0, 2, 4, 6], out); + assert_eq!(set.len(), 4); + } + { + let mut set: HashSet = (0..8).collect(); + set.extract_if(|&k| k % 2 == 0).for_each(drop); + assert_eq!(set.len(), 4, "Removes non-matching items on drop"); + } + } + + #[test] + fn test_const_with_hasher() { + use core::hash::BuildHasher; + use std::collections::hash_map::DefaultHasher; + + #[derive(Clone)] + struct MyHasher; + impl BuildHasher for MyHasher { + type Hasher = DefaultHasher; + + fn build_hasher(&self) -> DefaultHasher { + DefaultHasher::new() + } + } + + const EMPTY_SET: HashSet = HashSet::with_hasher(MyHasher); + + let mut set = EMPTY_SET; + set.insert(19); + assert!(set.contains(&19)); + } + + #[test] + fn rehash_in_place() { + let mut set = HashSet::new(); + + for i in 0..224 { + set.insert(i); + } + + assert_eq!( + set.capacity(), + 224, + "The set must be at or close to capacity to trigger a re hashing" + ); + + for i in 100..1400 { + set.remove(&(i - 100)); + set.insert(i); + } + } + + #[test] + fn collect() { + // At the time of writing, this hits the ZST case in from_base_index + // (and without the `map`, it does not). + let mut _set: HashSet<_> = (0..3).map(|_| ()).collect(); + } + + #[test] + fn test_allocation_info() { + assert_eq!(HashSet::<()>::new().allocation_size(), 0); + assert_eq!(HashSet::::new().allocation_size(), 0); + assert!(HashSet::::with_capacity(1).allocation_size() > size_of::()); + } + + #[test] + fn duplicate_insert() { + let mut set = HashSet::new(); + set.insert(1); + set.get_or_insert_with(&1, |_| 1); + set.get_or_insert_with(&1, |_| 1); + assert!([1].iter().eq(set.iter())); + } + + #[test] + #[should_panic] + fn some_invalid_equivalent() { + use core::hash::{Hash, Hasher}; + struct Invalid { + count: u32, + other: u32, + } + + struct InvalidRef { + count: u32, + other: u32, + } + + impl PartialEq for Invalid { + fn eq(&self, other: &Self) -> bool { + self.count == other.count && self.other == other.other + } + } + impl Eq for Invalid {} + + impl Equivalent for InvalidRef { + fn equivalent(&self, key: &Invalid) -> bool { + self.count == key.count && self.other == key.other + } + } + impl Hash for Invalid { + fn hash(&self, state: &mut H) { + self.count.hash(state); + } + } + impl Hash for InvalidRef { + fn hash(&self, state: &mut H) { + self.count.hash(state); + } + } + let mut set: HashSet = HashSet::new(); + let key = InvalidRef { count: 1, other: 1 }; + let value = Invalid { count: 1, other: 2 }; + if make_hash(set.hasher(), &key) == make_hash(set.hasher(), &value) { + set.get_or_insert_with(&key, |_| value); + } + } + + #[test] + fn test_entry() { + let xs = [10, 20, 30, 40, 50, 60]; + + let mut set: HashSet<_> = xs.iter().copied().collect(); + + // Existing key (get) + assert_eq!( + &10, + match set.entry(10) { + Vacant(_) => unreachable!(), + Occupied(view) => { + assert_eq!(&10, view.get()); + view.into_ref() + } + } + ); + + // Existing key (remove) + assert_eq!( + 20, + match set.entry(20) { + Vacant(_) => unreachable!(), + Occupied(view) => view.remove(), + } + ); + + // Non-existant key (insert) + match set.entry(1000) { + Occupied(_) => unreachable!(), + Vacant(view) => { + assert_eq!(&1000, view.insert().get()); + } + } + assert_eq!(set.get(&1000), Some(&1000)); + assert_eq!(set.len(), 6); + } +} diff --git a/library/hashbrown/src/table.rs b/library/hashbrown/src/table.rs new file mode 100644 index 0000000000000..ac201bf6262d0 --- /dev/null +++ b/library/hashbrown/src/table.rs @@ -0,0 +1,3197 @@ +use core::{fmt, iter::FusedIterator, marker::PhantomData, ptr::NonNull}; + +use crate::{ + TryReserveError, + alloc::{Allocator, Global}, + control::Tag, + raw::{ + Bucket, FullBucketsIndices, RawDrain, RawExtractIf, RawIntoIter, RawIter, RawIterHash, + RawIterHashIndices, RawTable, + }, +}; + +/// Low-level hash table with explicit hashing. +/// +/// The primary use case for this type over [`HashMap`] or [`HashSet`] is to +/// support types that do not implement the [`Hash`] and [`Eq`] traits, but +/// instead require additional data not contained in the key itself to compute a +/// hash and compare two elements for equality. +/// +/// Examples of when this can be useful include: +/// - An `IndexMap` implementation where indices into a `Vec` are stored as +/// elements in a `HashTable`. Hashing and comparing the elements +/// requires indexing the associated `Vec` to get the actual value referred to +/// by the index. +/// - Avoiding re-computing a hash when it is already known. +/// - Mutating the key of an element in a way that doesn't affect its hash. +/// +/// To achieve this, `HashTable` methods that search for an element in the table +/// require a hash value and equality function to be explicitly passed in as +/// arguments. The method will then iterate over the elements with the given +/// hash and call the equality function on each of them, until a match is found. +/// +/// In most cases, a `HashTable` will not be exposed directly in an API. It will +/// instead be wrapped in a helper type which handles the work of calculating +/// hash values and comparing elements. +/// +/// Due to its low-level nature, this type provides fewer guarantees than +/// [`HashMap`] and [`HashSet`]. Specifically, the API allows you to shoot +/// yourself in the foot by having multiple elements with identical keys in the +/// table. The table itself will still function correctly and lookups will +/// arbitrarily return one of the matching elements. However you should avoid +/// doing this because it changes the runtime of hash table operations from +/// `O(1)` to `O(k)` where `k` is the number of duplicate entries. +/// +/// [`HashMap`]: super::HashMap +/// [`HashSet`]: super::HashSet +/// [`Hash`]: core::hash::Hash +pub struct HashTable +where + A: Allocator, +{ + pub(crate) raw: RawTable, +} + +impl HashTable { + /// Creates an empty `HashTable`. + /// + /// The hash table is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashTable; + /// let mut table: HashTable<&str> = HashTable::new(); + /// assert_eq!(table.len(), 0); + /// assert_eq!(table.capacity(), 0); + /// ``` + #[must_use] + pub const fn new() -> Self { + Self { + raw: RawTable::new(), + } + } + + /// Creates an empty `HashTable` with the specified capacity. + /// + /// The hash table will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash table will not allocate. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashTable; + /// let mut table: HashTable<&str> = HashTable::with_capacity(10); + /// assert_eq!(table.len(), 0); + /// assert!(table.capacity() >= 10); + /// ``` + #[must_use] + pub fn with_capacity(capacity: usize) -> Self { + Self { + raw: RawTable::with_capacity(capacity), + } + } +} + +impl HashTable +where + A: Allocator, +{ + /// Creates an empty `HashTable` using the given allocator. + /// + /// The hash table is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use bumpalo::Bump; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let bump = Bump::new(); + /// let mut table = HashTable::new_in(&bump); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// // The created HashTable holds none elements + /// assert_eq!(table.len(), 0); + /// + /// // The created HashTable also doesn't allocate memory + /// assert_eq!(table.capacity(), 0); + /// + /// // Now we insert element inside created HashTable + /// table.insert_unique(hasher(&"One"), "One", hasher); + /// // We can see that the HashTable holds 1 element + /// assert_eq!(table.len(), 1); + /// // And it also allocates some capacity + /// assert!(table.capacity() > 1); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[must_use] + pub const fn new_in(alloc: A) -> Self { + Self { + raw: RawTable::new_in(alloc), + } + } + + /// Creates an empty `HashTable` with the specified capacity using the given allocator. + /// + /// The hash table will be able to hold at least `capacity` elements without + /// reallocating. If `capacity` is 0, the hash table will not allocate. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use bumpalo::Bump; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let bump = Bump::new(); + /// let mut table = HashTable::with_capacity_in(5, &bump); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// // The created HashTable holds none elements + /// assert_eq!(table.len(), 0); + /// // But it can hold at least 5 elements without reallocating + /// let empty_map_capacity = table.capacity(); + /// assert!(empty_map_capacity >= 5); + /// + /// // Now we insert some 5 elements inside created HashTable + /// table.insert_unique(hasher(&"One"), "One", hasher); + /// table.insert_unique(hasher(&"Two"), "Two", hasher); + /// table.insert_unique(hasher(&"Three"), "Three", hasher); + /// table.insert_unique(hasher(&"Four"), "Four", hasher); + /// table.insert_unique(hasher(&"Five"), "Five", hasher); + /// + /// // We can see that the HashTable holds 5 elements + /// assert_eq!(table.len(), 5); + /// // But its capacity isn't changed + /// assert_eq!(table.capacity(), empty_map_capacity) + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[must_use] + pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { + Self { + raw: RawTable::with_capacity_in(capacity, alloc), + } + } + + /// Returns a reference to the underlying allocator. + pub fn allocator(&self) -> &A { + self.raw.allocator() + } + + /// Returns a reference to an entry in the table with the given hash and + /// which satisfies the equality function passed. + /// + /// This method will call `eq` for all entries with the given hash, but may + /// also call it for entries with a different hash. `eq` should only return + /// true for the desired entry, at which point the search is stopped. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), 1, hasher); + /// table.insert_unique(hasher(&2), 2, hasher); + /// table.insert_unique(hasher(&3), 3, hasher); + /// assert_eq!(table.find(hasher(&2), |&val| val == 2), Some(&2)); + /// assert_eq!(table.find(hasher(&4), |&val| val == 4), None); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn find(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T> { + self.raw.get(hash, eq) + } + + /// Returns a mutable reference to an entry in the table with the given hash + /// and which satisfies the equality function passed. + /// + /// This method will call `eq` for all entries with the given hash, but may + /// also call it for entries with a different hash. `eq` should only return + /// true for the desired entry, at which point the search is stopped. + /// + /// When mutating an entry, you should ensure that it still retains the same + /// hash value as when it was inserted, otherwise lookups of that entry may + /// fail to find it. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); + /// if let Some(val) = table.find_mut(hasher(&1), |val| val.0 == 1) { + /// val.1 = "b"; + /// } + /// assert_eq!(table.find(hasher(&1), |val| val.0 == 1), Some(&(1, "b"))); + /// assert_eq!(table.find(hasher(&2), |val| val.0 == 2), None); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn find_mut(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&mut T> { + self.raw.get_mut(hash, eq) + } + + /// Returns an `OccupiedEntry` for an entry in the table with the given hash + /// and which satisfies the equality function passed. + /// + /// This can be used to remove the entry from the table. Call + /// [`HashTable::entry`] instead if you wish to insert an entry if the + /// lookup fails. + /// + /// This method will call `eq` for all entries with the given hash, but may + /// also call it for entries with a different hash. `eq` should only return + /// true for the desired entry, at which point the search is stopped. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); + /// if let Ok(entry) = table.find_entry(hasher(&1), |val| val.0 == 1) { + /// entry.remove(); + /// } + /// assert_eq!(table.find(hasher(&1), |val| val.0 == 1), None); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn find_entry( + &mut self, + hash: u64, + eq: impl FnMut(&T) -> bool, + ) -> Result, AbsentEntry<'_, T, A>> { + match self.raw.find(hash, eq) { + Some(bucket) => Ok(OccupiedEntry { + bucket, + table: self, + }), + None => Err(AbsentEntry { table: self }), + } + } + + /// Returns the bucket index in the table for an entry with the given hash + /// and which satisfies the equality function passed. + /// + /// This can be used to store a borrow-free "reference" to the entry, later using + /// [`get_bucket`][Self::get_bucket], [`get_bucket_mut`][Self::get_bucket_mut], or + /// [`get_bucket_entry`][Self::get_bucket_entry] to access it again without hash probing. + /// + /// The index is only meaningful as long as the table is not resized and no entries are added + /// or removed. After such changes, it may end up pointing to a different entry or none at all. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 1), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 2), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 3), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert_eq!(table.get_bucket(index), Some(&(2, 2))); + /// + /// // Mutation would invalidate any normal reference + /// for (_key, value) in &mut table { + /// *value *= 11; + /// } + /// + /// // The index still reaches the same key with the updated value + /// assert_eq!(table.get_bucket(index), Some(&(2, 22))); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn find_bucket_index(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option { + match self.raw.find(hash, eq) { + Some(bucket) => Some(unsafe { self.raw.bucket_index(&bucket) }), + None => None, + } + } + + /// Returns an `Entry` for an entry in the table with the given hash + /// and which satisfies the equality function passed. + /// + /// This can be used to remove the entry from the table, or insert a new + /// entry with the given hash if one doesn't already exist. + /// + /// This method will call `eq` for all entries with the given hash, but may + /// also call it for entries with a different hash. `eq` should only return + /// true for the desired entry, at which point the search is stopped. + /// + /// This method may grow the table in preparation for an insertion. Call + /// [`HashTable::find_entry`] if this is undesirable. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, "a"), |val| hasher(&val.0)); + /// if let Entry::Occupied(entry) = table.entry(hasher(&1), |val| val.0 == 1, |val| hasher(&val.0)) + /// { + /// entry.remove(); + /// } + /// if let Entry::Vacant(entry) = table.entry(hasher(&2), |val| val.0 == 2, |val| hasher(&val.0)) { + /// entry.insert((2, "b")); + /// } + /// assert_eq!(table.find(hasher(&1), |val| val.0 == 1), None); + /// assert_eq!(table.find(hasher(&2), |val| val.0 == 2), Some(&(2, "b"))); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn entry( + &mut self, + hash: u64, + eq: impl FnMut(&T) -> bool, + hasher: impl Fn(&T) -> u64, + ) -> Entry<'_, T, A> { + match self.raw.find_or_find_insert_index(hash, eq, hasher) { + Ok(bucket) => Entry::Occupied(OccupiedEntry { + bucket, + table: self, + }), + Err(insert_index) => Entry::Vacant(VacantEntry { + tag: Tag::full(hash), + index: insert_index, + table: self, + }), + } + } + + /// Returns an `OccupiedEntry` for the given bucket index in the table, + /// or `AbsentEntry` if it is unoccupied or out of bounds. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// + /// assert!(table.get_bucket_entry(usize::MAX).is_err()); + /// + /// let occupied_entry = table.get_bucket_entry(index).unwrap(); + /// assert_eq!(occupied_entry.get(), &(2, 'b')); + /// assert_eq!(occupied_entry.remove().0, (2, 'b')); + /// + /// assert!(table.find(hasher(&2), |val| val.0 == 2).is_none()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn get_bucket_entry( + &mut self, + index: usize, + ) -> Result, AbsentEntry<'_, T, A>> { + match self.raw.checked_bucket(index) { + Some(bucket) => Ok(OccupiedEntry { + bucket, + table: self, + }), + None => Err(AbsentEntry { table: self }), + } + } + + /// Returns an `OccupiedEntry` for the given bucket index in the table, + /// without checking whether the index is in-bounds or occupied. + /// + /// For a safe alternative, see [`get_bucket_entry`](Self::get_bucket_entry). + /// + /// # Safety + /// + /// It is *[undefined behavior]* to call this method with an index that is + /// out-of-bounds or unoccupied, even if the resulting entry is not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert!(std::ptr::eq( + /// table.get_bucket_entry(index).unwrap().into_mut(), + /// unsafe { table.get_bucket_entry_unchecked(index).into_mut() }, + /// )); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub unsafe fn get_bucket_entry_unchecked(&mut self, index: usize) -> OccupiedEntry<'_, T, A> { + OccupiedEntry { + bucket: unsafe { self.raw.bucket(index) }, + table: self, + } + } + + /// Gets a reference to an entry in the table at the given bucket index, + /// or `None` if it is unoccupied or out of bounds. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert_eq!(table.get_bucket(index), Some(&(2, 'b'))); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn get_bucket(&self, index: usize) -> Option<&T> { + self.raw.get_bucket(index) + } + + /// Gets a reference to an entry in the table at the given bucket index, + /// without checking whether the index is in-bounds or occupied. + /// + /// For a safe alternative, see [`get_bucket`](Self::get_bucket). + /// + /// # Safety + /// + /// It is *[undefined behavior]* to call this method with an index that is + /// out-of-bounds or unoccupied, even if the resulting reference is not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert!(std::ptr::eq( + /// table.get_bucket(index).unwrap(), + /// unsafe { table.get_bucket_unchecked(index) }, + /// )); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub unsafe fn get_bucket_unchecked(&self, index: usize) -> &T { + unsafe { self.raw.bucket(index).as_ref() } + } + + /// Gets a mutable reference to an entry in the table at the given bucket index, + /// or `None` if it is unoccupied or out of bounds. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert_eq!(table.get_bucket(index), Some(&(2, 'b'))); + /// if let Some((_key, value)) = table.get_bucket_mut(index) { + /// *value = 'B'; + /// } + /// assert_eq!(table.get_bucket(index), Some(&(2, 'B'))); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn get_bucket_mut(&mut self, index: usize) -> Option<&mut T> { + self.raw.get_bucket_mut(index) + } + + /// Gets a mutable reference to an entry in the table at the given bucket index, + /// without checking whether the index is in-bounds or occupied. + /// + /// For a safe alternative, see [`get_bucket_mut`](Self::get_bucket_mut). + /// + /// # Safety + /// + /// It is *[undefined behavior]* to call this method with an index that is + /// out-of-bounds or unoccupied, even if the resulting reference is not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// let index = table.find_bucket_index(hasher(&2), |val| val.0 == 2).unwrap(); + /// assert!(std::ptr::eq( + /// table.get_bucket_mut(index).unwrap(), + /// unsafe { table.get_bucket_unchecked_mut(index) }, + /// )); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub unsafe fn get_bucket_unchecked_mut(&mut self, index: usize) -> &mut T { + unsafe { self.raw.bucket(index).as_mut() } + } + + /// Inserts an element into the `HashTable` with the given hash value, but + /// without checking whether an equivalent element already exists within the + /// table. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut v = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// v.insert_unique(hasher(&1), 1, hasher); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn insert_unique( + &mut self, + hash: u64, + value: T, + hasher: impl Fn(&T) -> u64, + ) -> OccupiedEntry<'_, T, A> { + let bucket = self.raw.insert(hash, value, hasher); + OccupiedEntry { + bucket, + table: self, + } + } + + /// Clears the table, removing all values. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut v = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// v.insert_unique(hasher(&1), 1, hasher); + /// v.clear(); + /// assert!(v.is_empty()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn clear(&mut self) { + self.raw.clear(); + } + + /// Shrinks the capacity of the table as much as possible. It will drop + /// down as much as possible while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::with_capacity(100); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), 1, hasher); + /// table.insert_unique(hasher(&2), 2, hasher); + /// assert!(table.capacity() >= 100); + /// table.shrink_to_fit(hasher); + /// assert!(table.capacity() >= 2); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn shrink_to_fit(&mut self, hasher: impl Fn(&T) -> u64) { + self.raw.shrink_to(self.len(), hasher); + } + + /// Shrinks the capacity of the table with a lower limit. It will drop + /// down no lower than the supplied limit while maintaining the internal rules + /// and possibly leaving some space in accordance with the resize policy. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// Panics if the current capacity is smaller than the supplied + /// minimum capacity. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::with_capacity(100); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), 1, hasher); + /// table.insert_unique(hasher(&2), 2, hasher); + /// assert!(table.capacity() >= 100); + /// table.shrink_to(10, hasher); + /// assert!(table.capacity() >= 10); + /// table.shrink_to(0, hasher); + /// assert!(table.capacity() >= 2); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn shrink_to(&mut self, min_capacity: usize, hasher: impl Fn(&T) -> u64) { + self.raw.shrink_to(min_capacity, hasher); + } + + /// Reserves capacity for at least `additional` more elements to be inserted + /// in the `HashTable`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// # Panics + /// + /// Panics if the new capacity exceeds [`isize::MAX`] bytes and [`abort`] the program + /// in case of allocation error. Use [`try_reserve`](HashTable::try_reserve) instead + /// if you want to handle memory allocation failure. + /// + /// [`abort`]: stdalloc::alloc::handle_alloc_error + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.reserve(10, hasher); + /// assert!(table.capacity() >= 10); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64) { + self.raw.reserve(additional, hasher); + } + + /// Tries to reserve capacity for at least `additional` more elements to be inserted + /// in the given `HashTable`. The collection may reserve more space to avoid + /// frequent reallocations. + /// + /// `hasher` is called if entries need to be moved or copied to a new table. + /// This must return the same hash value that each entry was inserted with. + /// + /// # Errors + /// + /// If the capacity overflows, or the allocator reports a failure, then an error + /// is returned. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table + /// .try_reserve(10, hasher) + /// .expect("why is the test harness OOMing on 10 bytes?"); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn try_reserve( + &mut self, + additional: usize, + hasher: impl Fn(&T) -> u64, + ) -> Result<(), TryReserveError> { + self.raw.try_reserve(additional, hasher) + } + + /// Returns the raw number of buckets allocated in the table. + /// + /// This is an upper bound on any methods that take or return a bucket index, + /// as opposed to the usable [`capacity`](Self::capacity) for entries which is + /// reduced by an unspecified load factor. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 'a'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 'b'), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 'c'), |val| hasher(&val.0)); + /// + /// // Each entry is available at some index in the bucket range. + /// let count = (0..table.num_buckets()) + /// .filter_map(|i| table.get_bucket(i)) + /// .count(); + /// assert_eq!(count, 3); + /// + /// assert_eq!(table.get_bucket(table.num_buckets()), None); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn num_buckets(&self) -> usize { + self.raw.num_buckets() + } + + /// Returns the number of elements the table can hold without reallocating. + /// + /// # Examples + /// + /// ``` + /// use hashbrown::HashTable; + /// let table: HashTable = HashTable::with_capacity(100); + /// assert!(table.capacity() >= 100); + /// ``` + pub fn capacity(&self) -> usize { + self.raw.capacity() + } + + /// Returns the number of elements in the table. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// let mut v = HashTable::new(); + /// assert_eq!(v.len(), 0); + /// v.insert_unique(hasher(&1), 1, hasher); + /// assert_eq!(v.len(), 1); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn len(&self) -> usize { + self.raw.len() + } + + /// Returns `true` if the set contains no elements. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// let mut v = HashTable::new(); + /// assert!(v.is_empty()); + /// v.insert_unique(hasher(&1), 1, hasher); + /// assert!(!v.is_empty()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn is_empty(&self) -> bool { + self.raw.is_empty() + } + + /// An iterator visiting all elements in arbitrary order. + /// The iterator element type is `&'a T`. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"a"), "a", hasher); + /// table.insert_unique(hasher(&"b"), "b", hasher); + /// + /// // Will print in an arbitrary order. + /// for x in table.iter() { + /// println!("{}", x); + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter(&self) -> Iter<'_, T> { + Iter { + inner: unsafe { self.raw.iter() }, + marker: PhantomData, + } + } + + /// An iterator visiting all elements in arbitrary order, + /// with mutable references to the elements. + /// The iterator element type is `&'a mut T`. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), 1, hasher); + /// table.insert_unique(hasher(&2), 2, hasher); + /// table.insert_unique(hasher(&3), 3, hasher); + /// + /// // Update all values + /// for val in table.iter_mut() { + /// *val *= 2; + /// } + /// + /// assert_eq!(table.len(), 3); + /// let mut vec: Vec = Vec::new(); + /// + /// for val in &table { + /// println!("val: {}", val); + /// vec.push(*val); + /// } + /// + /// // The `Iter` iterator produces items in arbitrary order, so the + /// // items must be sorted to test them against a sorted array. + /// vec.sort_unstable(); + /// assert_eq!(vec, [2, 4, 6]); + /// + /// assert_eq!(table.len(), 3); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter_mut(&mut self) -> IterMut<'_, T> { + IterMut { + inner: unsafe { self.raw.iter() }, + marker: PhantomData, + } + } + + /// An iterator visiting all elements in arbitrary order, + /// with pointers to the elements. + /// The iterator element type is `NonNull`. + /// + /// This iterator is intended for APIs where only part of the elements are + /// mutable, with the remainder being immutable. In these cases, wrapping + /// the ordinary mutable iterator is incorrect because all components of + /// the element type will be [invariant]. A correct implementation will use + /// an appropriate [`PhantomData`] marker to make the immutable parts + /// [covariant] and the mutable parts invariant. + /// + /// [invariant]: https://doc.rust-lang.org/stable/reference/subtyping.html#r-subtyping.variance.invariant + /// [covariant]: https://doc.rust-lang.org/stable/reference/subtyping.html#r-subtyping.variance.covariant + /// + /// See the documentation for [`UnsafeIter`] for more information on how + /// to correctly use this. + pub fn unsafe_iter(&mut self) -> UnsafeIter<'_, T> { + UnsafeIter { + inner: unsafe { self.raw.iter() }, + marker: PhantomData, + } + } + + /// An iterator producing the `usize` indices of all occupied buckets. + /// + /// The order in which the iterator yields indices is unspecified + /// and may change in the future. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"a"), "a", hasher); + /// table.insert_unique(hasher(&"b"), "b", hasher); + /// + /// // Will print in an arbitrary order. + /// for index in table.iter_buckets() { + /// println!("{index}: {}", table.get_bucket(index).unwrap()); + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter_buckets(&self) -> IterBuckets<'_, T> { + IterBuckets { + inner: unsafe { self.raw.full_buckets_indices() }, + marker: PhantomData, + } + } + + /// An iterator visiting all elements which may match a hash. + /// The iterator element type is `&'a T`. + /// + /// This iterator may return elements from the table that have a hash value + /// different than the one provided. You should always validate the returned + /// values before using them. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"a"), "a", hasher); + /// table.insert_unique(hasher(&"a"), "b", hasher); + /// table.insert_unique(hasher(&"b"), "c", hasher); + /// + /// // Will print "a" and "b" (and possibly "c") in an arbitrary order. + /// for x in table.iter_hash(hasher(&"a")) { + /// println!("{}", x); + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter_hash(&self, hash: u64) -> IterHash<'_, T> { + IterHash { + inner: unsafe { self.raw.iter_hash(hash) }, + marker: PhantomData, + } + } + + /// A mutable iterator visiting all elements which may match a hash. + /// The iterator element type is `&'a mut T`. + /// + /// This iterator may return elements from the table that have a hash value + /// different than the one provided. You should always validate the returned + /// values before using them. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), 2, hasher); + /// table.insert_unique(hasher(&1), 3, hasher); + /// table.insert_unique(hasher(&2), 5, hasher); + /// + /// // Update matching values + /// for val in table.iter_hash_mut(hasher(&1)) { + /// *val *= 2; + /// } + /// + /// assert_eq!(table.len(), 3); + /// let mut vec: Vec = Vec::new(); + /// + /// for val in &table { + /// println!("val: {}", val); + /// vec.push(*val); + /// } + /// + /// // The values will contain 4 and 6 and may contain either 5 or 10. + /// assert!(vec.contains(&4)); + /// assert!(vec.contains(&6)); + /// + /// assert_eq!(table.len(), 3); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter_hash_mut(&mut self, hash: u64) -> IterHashMut<'_, T> { + IterHashMut { + inner: unsafe { self.raw.iter_hash(hash) }, + marker: PhantomData, + } + } + + /// An iterator producing the `usize` indices of all buckets which may match a hash. + /// + /// This iterator may return indices from the table that have a hash value + /// different than the one provided. You should always validate the returned + /// values before using them. + /// + /// The order in which the iterator yields indices is unspecified + /// and may change in the future. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"a"), "a", hasher); + /// table.insert_unique(hasher(&"a"), "b", hasher); + /// table.insert_unique(hasher(&"b"), "c", hasher); + /// + /// // Will print the indices with "a" and "b" (and possibly "c") in an arbitrary order. + /// for index in table.iter_hash_buckets(hasher(&"a")) { + /// println!("{index}: {}", table.get_bucket(index).unwrap()); + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn iter_hash_buckets(&self, hash: u64) -> IterHashBuckets<'_, T> { + IterHashBuckets { + inner: unsafe { self.raw.iter_hash_buckets(hash) }, + marker: PhantomData, + } + } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for x in 1..=6 { + /// table.insert_unique(hasher(&x), x, hasher); + /// } + /// table.retain(|&mut x| x % 2 == 0); + /// assert_eq!(table.len(), 3); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn retain(&mut self, mut f: impl FnMut(&mut T) -> bool) { + // Here we only use `iter` as a temporary, preventing use-after-free + unsafe { + for item in self.raw.iter() { + if !f(item.as_mut()) { + self.raw.erase(item); + } + } + } + } + + /// Clears the set, returning all elements in an iterator. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for x in 1..=3 { + /// table.insert_unique(hasher(&x), x, hasher); + /// } + /// assert!(!table.is_empty()); + /// + /// // print 1, 2, 3 in an arbitrary order + /// for i in table.drain() { + /// println!("{}", i); + /// } + /// + /// assert!(table.is_empty()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn drain(&mut self) -> Drain<'_, T, A> { + Drain { + inner: self.raw.drain(), + } + } + + /// Drains elements which are true under the given predicate, + /// and returns an iterator over the removed items. + /// + /// In other words, move all elements `e` such that `f(&e)` returns `true` out + /// into another iterator. + /// + /// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating + /// or the iteration short-circuits, then the remaining elements will be retained. + /// Use [`retain()`] with a negated predicate if you do not need the returned iterator. + /// + /// [`retain()`]: HashTable::retain + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for x in 0..8 { + /// table.insert_unique(hasher(&x), x, hasher); + /// } + /// let drained: Vec = table.extract_if(|&mut v| v % 2 == 0).collect(); + /// + /// let mut evens = drained.into_iter().collect::>(); + /// let mut odds = table.into_iter().collect::>(); + /// evens.sort(); + /// odds.sort(); + /// + /// assert_eq!(evens, vec![0, 2, 4, 6]); + /// assert_eq!(odds, vec![1, 3, 5, 7]); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn extract_if(&mut self, f: F) -> ExtractIf<'_, T, F, A> + where + F: FnMut(&mut T) -> bool, + { + ExtractIf { + f, + inner: RawExtractIf { + iter: unsafe { self.raw.iter() }, + table: &mut self.raw, + }, + } + } + + /// Attempts to get mutable references to `N` values in the map at once. + /// + /// The `eq` argument should be a closure such that `eq(i, k)` returns true if `k` is equal to + /// the `i`th key to be looked up. + /// + /// Returns an array of length `N` with the results of each query. For soundness, at most one + /// mutable reference will be returned to any value. `None` will be used if the key is missing. + /// + /// # Panics + /// + /// Panics if any keys are overlapping. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for (k, v) in [ + /// ("Bodleian Library", 1602), + /// ("Athenæum", 1807), + /// ("Herzogin-Anna-Amalia-Bibliothek", 1691), + /// ("Library of Congress", 1800), + /// ] { + /// libraries.insert_unique(hasher(&k), (k, v), |(k, _)| hasher(&k)); + /// } + /// + /// let keys = ["Athenæum", "Library of Congress"]; + /// let got = libraries.get_disjoint_mut(keys.map(|k| hasher(&k)), |i, val| keys[i] == val.0); + /// assert_eq!( + /// got, + /// [Some(&mut ("Athenæum", 1807)), Some(&mut ("Library of Congress", 1800))], + /// ); + /// + /// // Missing keys result in None + /// let keys = ["Athenæum", "New York Public Library"]; + /// let got = libraries.get_disjoint_mut(keys.map(|k| hasher(&k)), |i, val| keys[i] == val.0); + /// assert_eq!(got, [Some(&mut ("Athenæum", 1807)), None]); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + /// + /// ```should_panic + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// # use hashbrown::{HashTable, DefaultHashBuilder}; + /// # use std::hash::BuildHasher; + /// + /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for (k, v) in [ + /// ("Athenæum", 1807), + /// ("Library of Congress", 1800), + /// ] { + /// libraries.insert_unique(hasher(&k), (k, v), |(k, _)| hasher(&k)); + /// } + /// + /// // Duplicate keys result in a panic! + /// let keys = ["Athenæum", "Athenæum"]; + /// let got = libraries.get_disjoint_mut(keys.map(|k| hasher(&k)), |i, val| keys[i] == val.0); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test(); + /// # #[cfg(not(feature = "nightly"))] + /// # panic!(); + /// # } + /// ``` + pub fn get_disjoint_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + self.raw.get_disjoint_mut(hashes, eq) + } + + /// Attempts to get mutable references to `N` values in the map at once. + #[deprecated(note = "use `get_disjoint_mut` instead")] + pub fn get_many_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + self.raw.get_disjoint_mut(hashes, eq) + } + + /// Attempts to get mutable references to `N` values in the map at once, without validating that + /// the values are unique. + /// + /// The `eq` argument should be a closure such that `eq(i, k)` returns true if `k` is equal to + /// the `i`th key to be looked up. + /// + /// Returns an array of length `N` with the results of each query. `None` will be returned if + /// any of the keys are missing. + /// + /// For a safe alternative see [`get_disjoint_mut`](`HashTable::get_disjoint_mut`). + /// + /// # Safety + /// + /// Calling this method with overlapping keys is *[undefined behavior]* even if the resulting + /// references are not used. + /// + /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut libraries: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for (k, v) in [ + /// ("Bodleian Library", 1602), + /// ("Athenæum", 1807), + /// ("Herzogin-Anna-Amalia-Bibliothek", 1691), + /// ("Library of Congress", 1800), + /// ] { + /// libraries.insert_unique(hasher(&k), (k, v), |(k, _)| hasher(&k)); + /// } + /// + /// let keys = ["Athenæum", "Library of Congress"]; + /// let got = libraries.get_disjoint_mut(keys.map(|k| hasher(&k)), |i, val| keys[i] == val.0); + /// assert_eq!( + /// got, + /// [Some(&mut ("Athenæum", 1807)), Some(&mut ("Library of Congress", 1800))], + /// ); + /// + /// // Missing keys result in None + /// let keys = ["Athenæum", "New York Public Library"]; + /// let got = libraries.get_disjoint_mut(keys.map(|k| hasher(&k)), |i, val| keys[i] == val.0); + /// assert_eq!(got, [Some(&mut ("Athenæum", 1807)), None]); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub unsafe fn get_disjoint_unchecked_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + unsafe { self.raw.get_disjoint_unchecked_mut(hashes, eq) } + } + + /// Attempts to get mutable references to `N` values in the map at once, without validating that + /// the values are unique. + #[deprecated(note = "use `get_disjoint_unchecked_mut` instead")] + pub unsafe fn get_many_unchecked_mut( + &mut self, + hashes: [u64; N], + eq: impl FnMut(usize, &T) -> bool, + ) -> [Option<&'_ mut T>; N] { + unsafe { self.raw.get_disjoint_unchecked_mut(hashes, eq) } + } + + /// Returns the total amount of memory allocated internally by the hash + /// table, in bytes. + /// + /// The returned number is informational only. It is intended to be + /// primarily used for memory profiling. + #[inline] + pub fn allocation_size(&self) -> usize { + self.raw.allocation_size() + } +} + +impl IntoIterator for HashTable +where + A: Allocator, +{ + type Item = T; + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter { + inner: self.raw.into_iter(), + } + } +} + +impl<'a, T, A> IntoIterator for &'a HashTable +where + A: Allocator, +{ + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +impl<'a, T, A> IntoIterator for &'a mut HashTable +where + A: Allocator, +{ + type Item = &'a mut T; + type IntoIter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } +} + +impl Default for HashTable +where + A: Allocator + Default, +{ + fn default() -> Self { + Self { + raw: Default::default(), + } + } +} + +impl Clone for HashTable +where + T: Clone, + A: Allocator + Clone, +{ + fn clone(&self) -> Self { + Self { + raw: self.raw.clone(), + } + } + + fn clone_from(&mut self, source: &Self) { + self.raw.clone_from(&source.raw); + } +} + +impl fmt::Debug for HashTable +where + T: fmt::Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_set().entries(self.iter()).finish() + } +} + +/// A view into a single entry in a table, which may either be vacant or occupied. +/// +/// This `enum` is constructed from the [`entry`] method on [`HashTable`]. +/// +/// [`entry`]: HashTable::entry +/// +/// # Examples +/// +/// ``` +/// # #[cfg(feature = "nightly")] +/// # fn test() { +/// use hashbrown::hash_table::{Entry, OccupiedEntry}; +/// use hashbrown::{HashTable, DefaultHashBuilder}; +/// use std::hash::BuildHasher; +/// +/// let mut table = HashTable::new(); +/// let hasher = DefaultHashBuilder::default(); +/// let hasher = |val: &_| hasher.hash_one(val); +/// for x in ["a", "b", "c"] { +/// table.insert_unique(hasher(&x), x, hasher); +/// } +/// assert_eq!(table.len(), 3); +/// +/// // Existing value (insert) +/// let entry: Entry<_> = table.entry(hasher(&"a"), |&x| x == "a", hasher); +/// let _raw_o: OccupiedEntry<_, _> = entry.insert("a"); +/// assert_eq!(table.len(), 3); +/// // Nonexistent value (insert) +/// table.entry(hasher(&"d"), |&x| x == "d", hasher).insert("d"); +/// +/// // Existing value (or_insert) +/// table +/// .entry(hasher(&"b"), |&x| x == "b", hasher) +/// .or_insert("b"); +/// // Nonexistent value (or_insert) +/// table +/// .entry(hasher(&"e"), |&x| x == "e", hasher) +/// .or_insert("e"); +/// +/// println!("Our HashTable: {:?}", table); +/// +/// let mut vec: Vec<_> = table.iter().copied().collect(); +/// // The `Iter` iterator produces items in arbitrary order, so the +/// // items must be sorted to test them against a sorted array. +/// vec.sort_unstable(); +/// assert_eq!(vec, ["a", "b", "c", "d", "e"]); +/// # } +/// # fn main() { +/// # #[cfg(feature = "nightly")] +/// # test() +/// # } +/// ``` +pub enum Entry<'a, T, A = Global> +where + A: Allocator, +{ + /// An occupied entry. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::{Entry, OccupiedEntry}; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// for x in ["a", "b"] { + /// table.insert_unique(hasher(&x), x, hasher); + /// } + /// + /// match table.entry(hasher(&"a"), |&x| x == "a", hasher) { + /// Entry::Vacant(_) => unreachable!(), + /// Entry::Occupied(_) => {} + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + Occupied(OccupiedEntry<'a, T, A>), + + /// A vacant entry. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::{Entry, OccupiedEntry}; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::<&str>::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// match table.entry(hasher(&"a"), |&x| x == "a", hasher) { + /// Entry::Vacant(_) => {} + /// Entry::Occupied(_) => unreachable!(), + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + Vacant(VacantEntry<'a, T, A>), +} + +impl fmt::Debug for Entry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Entry::Vacant(ref v) => f.debug_tuple("Entry").field(v).finish(), + Entry::Occupied(ref o) => f.debug_tuple("Entry").field(o).finish(), + } + } +} + +impl<'a, T, A> Entry<'a, T, A> +where + A: Allocator, +{ + /// Sets the value of the entry, replacing any existing value if there is + /// one, and returns an [`OccupiedEntry`]. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<&str> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// let entry = table + /// .entry(hasher(&"horseyland"), |&x| x == "horseyland", hasher) + /// .insert("horseyland"); + /// + /// assert_eq!(entry.get(), &"horseyland"); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn insert(self, value: T) -> OccupiedEntry<'a, T, A> { + match self { + Entry::Occupied(mut entry) => { + *entry.get_mut() = value; + entry + } + Entry::Vacant(entry) => entry.insert(value), + } + } + + /// Ensures a value is in the entry by inserting if it was vacant. + /// + /// Returns an [`OccupiedEntry`] pointing to the now-occupied entry. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<&str> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// // nonexistent key + /// table + /// .entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) + /// .or_insert("poneyland"); + /// assert!(table + /// .find(hasher(&"poneyland"), |&x| x == "poneyland") + /// .is_some()); + /// + /// // existing key + /// table + /// .entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) + /// .or_insert("poneyland"); + /// assert!(table + /// .find(hasher(&"poneyland"), |&x| x == "poneyland") + /// .is_some()); + /// assert_eq!(table.len(), 1); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn or_insert(self, default: T) -> OccupiedEntry<'a, T, A> { + match self { + Entry::Occupied(entry) => entry, + Entry::Vacant(entry) => entry.insert(default), + } + } + + /// Ensures a value is in the entry by inserting the result of the default function if empty.. + /// + /// Returns an [`OccupiedEntry`] pointing to the now-occupied entry. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// table + /// .entry(hasher("poneyland"), |x| x == "poneyland", |val| hasher(val)) + /// .or_insert_with(|| "poneyland".to_string()); + /// + /// assert!(table + /// .find(hasher(&"poneyland"), |x| x == "poneyland") + /// .is_some()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn or_insert_with(self, default: impl FnOnce() -> T) -> OccupiedEntry<'a, T, A> { + match self { + Entry::Occupied(entry) => entry, + Entry::Vacant(entry) => entry.insert(default()), + } + } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the table. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// table + /// .entry( + /// hasher(&"poneyland"), + /// |&(x, _)| x == "poneyland", + /// |(k, _)| hasher(&k), + /// ) + /// .and_modify(|(_, v)| *v += 1) + /// .or_insert(("poneyland", 42)); + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(k, _)| k == "poneyland"), + /// Some(&("poneyland", 42)) + /// ); + /// + /// table + /// .entry( + /// hasher(&"poneyland"), + /// |&(x, _)| x == "poneyland", + /// |(k, _)| hasher(&k), + /// ) + /// .and_modify(|(_, v)| *v += 1) + /// .or_insert(("poneyland", 42)); + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(k, _)| k == "poneyland"), + /// Some(&("poneyland", 43)) + /// ); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn and_modify(self, f: impl FnOnce(&mut T)) -> Self { + match self { + Entry::Occupied(mut entry) => { + f(entry.get_mut()); + Entry::Occupied(entry) + } + Entry::Vacant(entry) => Entry::Vacant(entry), + } + } + + /// Converts the `Entry` into a mutable reference to the underlying table. + pub fn into_table(self) -> &'a mut HashTable { + match self { + Entry::Occupied(entry) => entry.table, + Entry::Vacant(entry) => entry.table, + } + } +} + +/// A view into an occupied entry in a `HashTable`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// # #[cfg(feature = "nightly")] +/// # fn test() { +/// use hashbrown::hash_table::{Entry, OccupiedEntry}; +/// use hashbrown::{HashTable, DefaultHashBuilder}; +/// use std::hash::BuildHasher; +/// +/// let mut table = HashTable::new(); +/// let hasher = DefaultHashBuilder::default(); +/// let hasher = |val: &_| hasher.hash_one(val); +/// for x in ["a", "b", "c"] { +/// table.insert_unique(hasher(&x), x, hasher); +/// } +/// assert_eq!(table.len(), 3); +/// +/// let _entry_o: OccupiedEntry<_, _> = table.find_entry(hasher(&"a"), |&x| x == "a").unwrap(); +/// assert_eq!(table.len(), 3); +/// +/// // Existing key +/// match table.entry(hasher(&"a"), |&x| x == "a", hasher) { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.get(), &"a"); +/// } +/// } +/// +/// assert_eq!(table.len(), 3); +/// +/// // Existing key (take) +/// match table.entry(hasher(&"c"), |&x| x == "c", hasher) { +/// Entry::Vacant(_) => unreachable!(), +/// Entry::Occupied(view) => { +/// assert_eq!(view.remove().0, "c"); +/// } +/// } +/// assert_eq!(table.find(hasher(&"c"), |&x| x == "c"), None); +/// assert_eq!(table.len(), 2); +/// # } +/// # fn main() { +/// # #[cfg(feature = "nightly")] +/// # test() +/// # } +/// ``` +pub struct OccupiedEntry<'a, T, A = Global> +where + A: Allocator, +{ + bucket: Bucket, + table: &'a mut HashTable, +} + +unsafe impl Send for OccupiedEntry<'_, T, A> +where + T: Send, + A: Send + Allocator, +{ +} +unsafe impl Sync for OccupiedEntry<'_, T, A> +where + T: Sync, + A: Sync + Allocator, +{ +} + +impl fmt::Debug for OccupiedEntry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OccupiedEntry") + .field("value", self.get()) + .finish() + } +} + +impl<'a, T, A> OccupiedEntry<'a, T, A> +where + A: Allocator, +{ + /// Takes the value out of the entry, and returns it along with a + /// `VacantEntry` that can be used to insert another value with the same + /// hash as the one that was just removed. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<&str> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// // The table is empty + /// assert!(table.is_empty() && table.capacity() == 0); + /// + /// table.insert_unique(hasher(&"poneyland"), "poneyland", hasher); + /// let capacity_before_remove = table.capacity(); + /// + /// if let Entry::Occupied(o) = table.entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) { + /// assert_eq!(o.remove().0, "poneyland"); + /// } + /// + /// assert!(table + /// .find(hasher(&"poneyland"), |&x| x == "poneyland") + /// .is_none()); + /// // Now table hold none elements but capacity is equal to the old one + /// assert!(table.len() == 0 && table.capacity() == capacity_before_remove); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn remove(self) -> (T, VacantEntry<'a, T, A>) { + let (val, index, tag) = unsafe { self.table.raw.remove_tagged(self.bucket) }; + ( + val, + VacantEntry { + tag, + index, + table: self.table, + }, + ) + } + + /// Gets a reference to the value in the entry. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<&str> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"poneyland"), "poneyland", hasher); + /// + /// match table.entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) { + /// Entry::Vacant(_) => panic!(), + /// Entry::Occupied(entry) => assert_eq!(entry.get(), &"poneyland"), + /// } + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn get(&self) -> &T { + unsafe { self.bucket.as_ref() } + } + + /// Gets a mutable reference to the value in the entry. + /// + /// If you need a reference to the `OccupiedEntry` which may outlive the + /// destruction of the `Entry` value, see [`into_mut`]. + /// + /// [`into_mut`]: #method.into_mut + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"poneyland"), ("poneyland", 12), |(k, _)| hasher(&k)); + /// + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(x, _)| x == "poneyland",), + /// Some(&("poneyland", 12)) + /// ); + /// + /// if let Entry::Occupied(mut o) = table.entry( + /// hasher(&"poneyland"), + /// |&(x, _)| x == "poneyland", + /// |(k, _)| hasher(&k), + /// ) { + /// o.get_mut().1 += 10; + /// assert_eq!(o.get().1, 22); + /// + /// // We can use the same Entry multiple times. + /// o.get_mut().1 += 2; + /// } + /// + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(x, _)| x == "poneyland",), + /// Some(&("poneyland", 24)) + /// ); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn get_mut(&mut self) -> &mut T { + unsafe { self.bucket.as_mut() } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the value in the entry + /// with a lifetime bound to the table itself. + /// + /// If you need multiple references to the `OccupiedEntry`, see [`get_mut`]. + /// + /// [`get_mut`]: #method.get_mut + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<(&str, u32)> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&"poneyland"), ("poneyland", 12), |(k, _)| hasher(&k)); + /// + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(x, _)| x == "poneyland",), + /// Some(&("poneyland", 12)) + /// ); + /// + /// let value: &mut (&str, u32); + /// match table.entry( + /// hasher(&"poneyland"), + /// |&(x, _)| x == "poneyland", + /// |(k, _)| hasher(&k), + /// ) { + /// Entry::Occupied(entry) => value = entry.into_mut(), + /// Entry::Vacant(_) => panic!(), + /// } + /// value.1 += 10; + /// + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&(x, _)| x == "poneyland",), + /// Some(&("poneyland", 22)) + /// ); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn into_mut(self) -> &'a mut T { + unsafe { self.bucket.as_mut() } + } + + /// Converts the `OccupiedEntry` into a mutable reference to the underlying + /// table. + pub fn into_table(self) -> &'a mut HashTable { + self.table + } + + /// Returns the bucket index in the table for this entry. + /// + /// This can be used to store a borrow-free "reference" to the entry, later using + /// [`HashTable::get_bucket`], [`HashTable::get_bucket_mut`], or + /// [`HashTable::get_bucket_entry`] to access it again without hash probing. + /// + /// The index is only meaningful as long as the table is not resized and no entries are added + /// or removed. After such changes, it may end up pointing to a different entry or none at all. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// table.insert_unique(hasher(&1), (1, 1), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&2), (2, 2), |val| hasher(&val.0)); + /// table.insert_unique(hasher(&3), (3, 3), |val| hasher(&val.0)); + /// + /// let index = table + /// .entry(hasher(&2), |val| val.0 == 2, |val| hasher(&val.0)) + /// .or_insert((2, -2)) + /// .bucket_index(); + /// assert_eq!(table.get_bucket(index), Some(&(2, 2))); + /// + /// // Full mutation would invalidate any normal reference + /// for (_key, value) in &mut table { + /// *value *= 11; + /// } + /// + /// // The index still reaches the same key with the updated value + /// assert_eq!(table.get_bucket(index), Some(&(2, 22))); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + pub fn bucket_index(&self) -> usize { + unsafe { self.table.raw.bucket_index(&self.bucket) } + } + + /// Provides owned access to the value of the entry and allows to replace or + /// remove it based on the value of the returned option. + /// + /// The hash of the new item should be the same as the old item. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use hashbrown::hash_table::Entry; + /// use std::hash::BuildHasher; + /// + /// let mut table = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |(key, _): &_| hasher.hash_one(key); + /// table.insert_unique(hasher(&("poneyland", 42)), ("poneyland", 42), hasher); + /// + /// let entry = match table.entry(hasher(&("poneyland", 42)), |entry| entry.0 == "poneyland", hasher) { + /// Entry::Occupied(e) => unsafe { + /// e.replace_entry_with(|(k, v)| { + /// assert_eq!(k, "poneyland"); + /// assert_eq!(v, 42); + /// Some(("poneyland", v + 1)) + /// }) + /// } + /// Entry::Vacant(_) => panic!(), + /// }; + /// + /// match entry { + /// Entry::Occupied(e) => { + /// assert_eq!(e.get(), &("poneyland", 43)); + /// } + /// Entry::Vacant(_) => panic!(), + /// } + /// + /// let entry = match table.entry(hasher(&("poneyland", 43)), |entry| entry.0 == "poneyland", hasher) { + /// Entry::Occupied(e) => unsafe { e.replace_entry_with(|(_k, _v)| None) }, + /// Entry::Vacant(_) => panic!(), + /// }; + /// + /// match entry { + /// Entry::Vacant(e) => { + /// // nice! + /// } + /// Entry::Occupied(_) => panic!(), + /// } + /// + /// assert!(table.is_empty()); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[cfg_attr(feature = "inline-more", inline)] + pub fn replace_entry_with(self, f: F) -> Entry<'a, T, A> + where + F: FnOnce(T) -> Option, + { + unsafe { + match self.table.raw.replace_bucket_with(self.bucket.clone(), f) { + None => Entry::Occupied(self), + Some(tag) => Entry::Vacant(VacantEntry { + tag, + index: self.bucket_index(), + table: self.table, + }), + } + } + } +} + +/// A view into a vacant entry in a `HashTable`. +/// It is part of the [`Entry`] enum. +/// +/// # Examples +/// +/// ``` +/// # #[cfg(feature = "nightly")] +/// # fn test() { +/// use hashbrown::hash_table::{Entry, VacantEntry}; +/// use hashbrown::{HashTable, DefaultHashBuilder}; +/// use std::hash::BuildHasher; +/// +/// let mut table: HashTable<&str> = HashTable::new(); +/// let hasher = DefaultHashBuilder::default(); +/// let hasher = |val: &_| hasher.hash_one(val); +/// +/// let entry_v: VacantEntry<_, _> = match table.entry(hasher(&"a"), |&x| x == "a", hasher) { +/// Entry::Vacant(view) => view, +/// Entry::Occupied(_) => unreachable!(), +/// }; +/// entry_v.insert("a"); +/// assert!(table.find(hasher(&"a"), |&x| x == "a").is_some() && table.len() == 1); +/// +/// // Nonexistent key (insert) +/// match table.entry(hasher(&"b"), |&x| x == "b", hasher) { +/// Entry::Vacant(view) => { +/// view.insert("b"); +/// } +/// Entry::Occupied(_) => unreachable!(), +/// } +/// assert!(table.find(hasher(&"b"), |&x| x == "b").is_some() && table.len() == 2); +/// # } +/// # fn main() { +/// # #[cfg(feature = "nightly")] +/// # test() +/// # } +/// ``` +pub struct VacantEntry<'a, T, A = Global> +where + A: Allocator, +{ + tag: Tag, + index: usize, + table: &'a mut HashTable, +} + +impl fmt::Debug for VacantEntry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("VacantEntry") + } +} + +impl<'a, T, A> VacantEntry<'a, T, A> +where + A: Allocator, +{ + /// Inserts a new element into the table with the hash that was used to + /// obtain the `VacantEntry`. + /// + /// An `OccupiedEntry` is returned for the newly inserted element. + /// + /// # Examples + /// + /// ``` + /// # #[cfg(feature = "nightly")] + /// # fn test() { + /// use hashbrown::hash_table::Entry; + /// use hashbrown::{HashTable, DefaultHashBuilder}; + /// use std::hash::BuildHasher; + /// + /// let mut table: HashTable<&str> = HashTable::new(); + /// let hasher = DefaultHashBuilder::default(); + /// let hasher = |val: &_| hasher.hash_one(val); + /// + /// if let Entry::Vacant(o) = table.entry(hasher(&"poneyland"), |&x| x == "poneyland", hasher) { + /// o.insert("poneyland"); + /// } + /// assert_eq!( + /// table.find(hasher(&"poneyland"), |&x| x == "poneyland"), + /// Some(&"poneyland") + /// ); + /// # } + /// # fn main() { + /// # #[cfg(feature = "nightly")] + /// # test() + /// # } + /// ``` + #[inline] + pub fn insert(self, value: T) -> OccupiedEntry<'a, T, A> { + let bucket = unsafe { + self.table + .raw + .insert_tagged_at_index(self.tag, self.index, value) + }; + OccupiedEntry { + bucket, + table: self.table, + } + } + + /// Converts the `VacantEntry` into a mutable reference to the underlying + /// table. + pub fn into_table(self) -> &'a mut HashTable { + self.table + } +} + +/// Type representing the absence of an entry, as returned by [`HashTable::find_entry`] +/// and [`HashTable::get_bucket_entry`]. +/// +/// This type only exists due to [limitations] in Rust's NLL borrow checker. In +/// the future, those methods will return an `Option` and this +/// type will be removed. +/// +/// [limitations]: https://smallcultfollowing.com/babysteps/blog/2018/06/15/mir-based-borrow-check-nll-status-update/#polonius +/// +/// # Examples +/// +/// ``` +/// # #[cfg(feature = "nightly")] +/// # fn test() { +/// use hashbrown::hash_table::{AbsentEntry, Entry}; +/// use hashbrown::{HashTable, DefaultHashBuilder}; +/// use std::hash::BuildHasher; +/// +/// let mut table: HashTable<&str> = HashTable::new(); +/// let hasher = DefaultHashBuilder::default(); +/// let hasher = |val: &_| hasher.hash_one(val); +/// +/// let entry_v: AbsentEntry<_, _> = table.find_entry(hasher(&"a"), |&x| x == "a").unwrap_err(); +/// entry_v +/// .into_table() +/// .insert_unique(hasher(&"a"), "a", hasher); +/// assert!(table.find(hasher(&"a"), |&x| x == "a").is_some() && table.len() == 1); +/// +/// // Nonexistent key (insert) +/// match table.entry(hasher(&"b"), |&x| x == "b", hasher) { +/// Entry::Vacant(view) => { +/// view.insert("b"); +/// } +/// Entry::Occupied(_) => unreachable!(), +/// } +/// assert!(table.find(hasher(&"b"), |&x| x == "b").is_some() && table.len() == 2); +/// # } +/// # fn main() { +/// # #[cfg(feature = "nightly")] +/// # test() +/// # } +/// ``` +pub struct AbsentEntry<'a, T, A = Global> +where + A: Allocator, +{ + table: &'a mut HashTable, +} + +impl fmt::Debug for AbsentEntry<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("AbsentEntry") + } +} + +impl<'a, T, A> AbsentEntry<'a, T, A> +where + A: Allocator, +{ + /// Converts the `AbsentEntry` into a mutable reference to the underlying + /// table. + pub fn into_table(self) -> &'a mut HashTable { + self.table + } +} + +/// An iterator over the entries of a `HashTable` in arbitrary order. +/// The iterator element type is `&'a T`. +/// +/// This `struct` is created by the [`iter`] method on [`HashTable`]. See its +/// documentation for more. +/// +/// [`iter`]: HashTable::iter +pub struct Iter<'a, T> { + inner: RawIter, + marker: PhantomData<&'a T>, +} + +impl Default for Iter<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Iter { + inner: Default::default(), + marker: PhantomData, + } + } +} + +impl<'a, T> Iterator for Iter<'a, T> { + type Item = &'a T; + + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(bucket) => Some(unsafe { bucket.as_ref() }), + None => None, + } + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner + .fold(init, |acc, bucket| unsafe { f(acc, bucket.as_ref()) }) + } +} + +impl ExactSizeIterator for Iter<'_, T> { + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for Iter<'_, T> {} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl<'a, T> Clone for Iter<'a, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Iter<'a, T> { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for Iter<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// A mutable iterator over the entries of a `HashTable` in arbitrary order. +/// The iterator element type is `&'a mut T`. +/// +/// This `struct` is created by the [`iter_mut`] method on [`HashTable`]. See its +/// documentation for more. +/// +/// [`iter_mut`]: HashTable::iter_mut +pub struct IterMut<'a, T> { + inner: RawIter, + marker: PhantomData<&'a mut T>, +} +impl IterMut<'_, T> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, T> { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl Default for IterMut<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IterMut { + inner: Default::default(), + marker: PhantomData, + } + } +} +impl<'a, T> Iterator for IterMut<'a, T> { + type Item = &'a mut T; + + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(bucket) => Some(unsafe { bucket.as_mut() }), + None => None, + } + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner + .fold(init, |acc, bucket| unsafe { f(acc, bucket.as_mut()) }) + } +} + +impl ExactSizeIterator for IterMut<'_, T> { + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for IterMut<'_, T> {} + +impl fmt::Debug for IterMut<'_, T> +where + T: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +/// An unsafe iterator over the entries of a `HashTable` in arbitrary order. +/// The iterator element type is `NonNull`. +/// +/// This `struct` is created by the [`unsafe_iter`] method on [`HashTable`]. +/// +/// This is used for implementations of iterators with "mixed" mutability on +/// the iterated elements. For example, a mutable iterator for a map may return +/// an immutable key alongside a mutable value, even though these are both +/// stored inside the table. +/// +/// If you have no idea what any of this means, you probably should be using +/// [`IterMut`] instead, as it does not have any safety requirements. +/// +/// # Safety +/// +/// In order to correctly use this iterator, it should be wrapped in a safe +/// iterator struct with the appropriate [`PhantomData`] marker to indicate the +/// correct [variance]. +/// +/// For example, below is a simplified [`hash_map::IterMut`] implementation +/// that correctly returns a [covariant] key, and an [invariant] value: +/// +/// [variance]: https://doc.rust-lang.org/stable/reference/subtyping.html#r-subtyping.variance +/// [covariant]: https://doc.rust-lang.org/stable/reference/subtyping.html#r-subtyping.variance.covariant +/// [invariant]: https://doc.rust-lang.org/stable/reference/subtyping.html#r-subtyping.variance.invariant +/// [`hash_map::IterMut`]: crate::hash_map::IterMut +/// [`unsafe_iter`]: HashTable::unsafe_iter +/// +/// ```rust +/// use core::marker::PhantomData; +/// use hashbrown::hash_table; +/// +/// pub struct IterMut<'a, K, V> { +/// inner: hash_table::UnsafeIter<'a, (K, V)>, +/// // Covariant over keys, invariant over values +/// marker: PhantomData<(&'a K, &'a mut V)>, +/// } +/// impl<'a, K, V> Iterator for IterMut<'a, K, V> { +/// // Immutable keys, mutable values +/// type Item = (&'a K, &'a mut V); +/// +/// fn next(&mut self) -> Option { +/// // SAFETY: The lifetime of the dereferenced pointer is derived from +/// // the lifetime of its iterator, ensuring that it's always valid. +/// // Additionally, we match the mutability in `self.marker` to ensure +/// // the correct variance. +/// let &mut (ref key, ref mut val) = unsafe { self.inner.next()?.as_mut() }; +/// Some((key, val)) +/// } +/// } +/// ``` +pub struct UnsafeIter<'a, T> { + inner: RawIter, + marker: PhantomData<&'a ()>, +} +impl UnsafeIter<'_, T> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, T> { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl Default for UnsafeIter<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + UnsafeIter { + inner: Default::default(), + marker: PhantomData, + } + } +} +impl Iterator for UnsafeIter<'_, T> { + type Item = NonNull; + + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(bucket) => Some(unsafe { NonNull::new_unchecked(bucket.as_ptr()) }), + None => None, + } + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, |acc, bucket| unsafe { + f(acc, NonNull::new_unchecked(bucket.as_ptr())) + }) + } +} + +impl ExactSizeIterator for UnsafeIter<'_, T> { + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for UnsafeIter<'_, T> {} + +impl fmt::Debug for UnsafeIter<'_, T> +where + T: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +/// An iterator producing the `usize` indices of all occupied buckets, +/// within the range `0..table.num_buckets()`. +/// +/// The order in which the iterator yields indices is unspecified +/// and may change in the future. +/// +/// This `struct` is created by the [`HashTable::iter_buckets`] method. See its +/// documentation for more. +pub struct IterBuckets<'a, T> { + inner: FullBucketsIndices, + marker: PhantomData<&'a T>, +} + +impl Clone for IterBuckets<'_, T> { + #[inline] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl Default for IterBuckets<'_, T> { + #[inline] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} + +impl Iterator for IterBuckets<'_, T> { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next() + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } +} + +impl ExactSizeIterator for IterBuckets<'_, T> { + #[inline] + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for IterBuckets<'_, T> {} + +impl fmt::Debug for IterBuckets<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// An iterator over the entries of a `HashTable` that could match a given hash. +/// The iterator element type is `&'a T`. +/// +/// This `struct` is created by the [`iter_hash`] method on [`HashTable`]. See its +/// documentation for more. +/// +/// [`iter_hash`]: HashTable::iter_hash +pub struct IterHash<'a, T> { + inner: RawIterHash, + marker: PhantomData<&'a T>, +} + +impl Default for IterHash<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IterHash { + inner: Default::default(), + marker: PhantomData, + } + } +} + +impl<'a, T> Iterator for IterHash<'a, T> { + type Item = &'a T; + + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(bucket) => Some(unsafe { bucket.as_ref() }), + None => None, + } + } + + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner + .fold(init, |acc, bucket| unsafe { f(acc, bucket.as_ref()) }) + } +} + +impl FusedIterator for IterHash<'_, T> {} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl<'a, T> Clone for IterHash<'a, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> IterHash<'a, T> { + IterHash { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for IterHash<'_, T> +where + T: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// A mutable iterator over the entries of a `HashTable` that could match a given hash. +/// The iterator element type is `&'a mut T`. +/// +/// This `struct` is created by the [`iter_hash_mut`] method on [`HashTable`]. See its +/// documentation for more. +/// +/// [`iter_hash_mut`]: HashTable::iter_hash_mut +pub struct IterHashMut<'a, T> { + inner: RawIterHash, + marker: PhantomData<&'a mut T>, +} + +impl Default for IterHashMut<'_, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IterHashMut { + inner: Default::default(), + marker: PhantomData, + } + } +} + +impl<'a, T> Iterator for IterHashMut<'a, T> { + type Item = &'a mut T; + + fn next(&mut self) -> Option { + // Avoid `Option::map` because it bloats LLVM IR. + match self.inner.next() { + Some(bucket) => Some(unsafe { bucket.as_mut() }), + None => None, + } + } + + fn fold(self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner + .fold(init, |acc, bucket| unsafe { f(acc, bucket.as_mut()) }) + } +} + +impl FusedIterator for IterHashMut<'_, T> {} + +impl fmt::Debug for IterHashMut<'_, T> +where + T: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list() + .entries(IterHash { + inner: self.inner.clone(), + marker: PhantomData, + }) + .finish() + } +} + +/// An iterator producing the `usize` indices of all buckets which may match a hash. +/// +/// This `struct` is created by the [`HashTable::iter_hash_buckets`] method. See its +/// documentation for more. +pub struct IterHashBuckets<'a, T> { + inner: RawIterHashIndices, + marker: PhantomData<&'a T>, +} + +impl Clone for IterHashBuckets<'_, T> { + #[inline] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl Default for IterHashBuckets<'_, T> { + #[inline] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} + +impl Iterator for IterHashBuckets<'_, T> { + type Item = usize; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next() + } +} + +impl FusedIterator for IterHashBuckets<'_, T> {} + +impl fmt::Debug for IterHashBuckets<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + +/// An owning iterator over the entries of a `HashTable` in arbitrary order. +/// The iterator element type is `T`. +/// +/// This `struct` is created by the [`into_iter`] method on [`HashTable`] +/// (provided by the [`IntoIterator`] trait). See its documentation for more. +/// The table cannot be used after calling that method. +/// +/// [`into_iter`]: HashTable::into_iter +pub struct IntoIter +where + A: Allocator, +{ + inner: RawIntoIter, +} +impl IntoIter +where + A: Allocator, +{ + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, T> { + Iter { + inner: self.inner.iter(), + marker: PhantomData, + } + } +} + +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IntoIter { + inner: Default::default(), + } + } +} + +impl Iterator for IntoIter +where + A: Allocator, +{ + type Item = T; + + fn next(&mut self) -> Option { + self.inner.next() + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, f) + } +} + +impl ExactSizeIterator for IntoIter +where + A: Allocator, +{ + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for IntoIter where A: Allocator {} + +impl fmt::Debug for IntoIter +where + T: fmt::Debug, + A: Allocator, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +/// A draining iterator over the items of a `HashTable`. +/// +/// This `struct` is created by the [`drain`] method on [`HashTable`]. +/// See its documentation for more. +/// +/// [`drain`]: HashTable::drain +pub struct Drain<'a, T, A: Allocator = Global> { + inner: RawDrain<'a, T, A>, +} +impl Drain<'_, T, A> { + /// Returns a iterator of references over the remaining items. + #[cfg_attr(feature = "inline-more", inline)] + pub fn iter(&self) -> Iter<'_, T> { + Iter { + inner: self.inner.iter(), + marker: PhantomData, + } + } +} + +impl Iterator for Drain<'_, T, A> { + type Item = T; + + fn next(&mut self) -> Option { + self.inner.next() + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } + + fn fold(self, init: B, f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + self.inner.fold(init, f) + } +} + +impl ExactSizeIterator for Drain<'_, T, A> { + fn len(&self) -> usize { + self.inner.len() + } +} + +impl FusedIterator for Drain<'_, T, A> {} + +impl fmt::Debug for Drain<'_, T, A> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.iter()).finish() + } +} + +/// A draining iterator over entries of a `HashTable` which don't satisfy the predicate `f`. +/// +/// This `struct` is created by [`HashTable::extract_if`]. See its +/// documentation for more. +#[must_use = "Iterators are lazy unless consumed"] +pub struct ExtractIf<'a, T, F, A: Allocator = Global> { + f: F, + inner: RawExtractIf<'a, T, A>, +} + +impl Iterator for ExtractIf<'_, T, F, A> +where + F: FnMut(&mut T) -> bool, +{ + type Item = T; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next(|val| (self.f)(val)) + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, self.inner.iter.size_hint().1) + } +} + +impl FusedIterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool {} + +#[cfg(test)] +mod tests { + use super::HashTable; + + #[test] + fn test_allocation_info() { + assert_eq!(HashTable::<()>::new().allocation_size(), 0); + assert_eq!(HashTable::::new().allocation_size(), 0); + assert!(HashTable::::with_capacity(1).allocation_size() > size_of::()); + } +} diff --git a/library/hashbrown/src/util.rs b/library/hashbrown/src/util.rs new file mode 100644 index 0000000000000..4d015873bf997 --- /dev/null +++ b/library/hashbrown/src/util.rs @@ -0,0 +1,30 @@ +// FIXME: Replace with `core::hint::{likely, unlikely}` once they are stable. +#[cfg(feature = "nightly")] +pub(crate) use core::intrinsics::{likely, unlikely}; + +#[cfg(not(feature = "nightly"))] +#[inline(always)] +#[cold] +fn cold_path() {} + +#[cfg(not(feature = "nightly"))] +#[inline(always)] +pub(crate) fn likely(b: bool) -> bool { + if b { + true + } else { + cold_path(); + false + } +} + +#[cfg(not(feature = "nightly"))] +#[inline(always)] +pub(crate) fn unlikely(b: bool) -> bool { + if b { + cold_path(); + true + } else { + false + } +} diff --git a/library/hashbrown/tests/equivalent_trait.rs b/library/hashbrown/tests/equivalent_trait.rs new file mode 100644 index 0000000000000..31f0a63e2c07b --- /dev/null +++ b/library/hashbrown/tests/equivalent_trait.rs @@ -0,0 +1,55 @@ +#![expect(missing_docs)] // https://github.com/rust-lang/rust/issues/137561 + +use hashbrown::Equivalent; +use hashbrown::HashMap; + +use std::hash::Hash; + +#[derive(Debug, Hash)] +pub struct Pair(pub A, pub B); + +impl PartialEq<(A, B)> for Pair +where + C: PartialEq, + D: PartialEq, +{ + fn eq(&self, rhs: &(A, B)) -> bool { + self.0 == rhs.0 && self.1 == rhs.1 + } +} + +impl Equivalent for Pair +where + Pair: PartialEq, + A: Hash + Eq, + B: Hash + Eq, +{ + fn equivalent(&self, other: &X) -> bool { + *self == *other + } +} + +#[test] +fn test_lookup() { + let s = String::from; + let mut map = HashMap::new(); + map.insert((s("a"), s("b")), 1); + map.insert((s("a"), s("x")), 2); + + assert!(map.contains_key(&Pair("a", "b"))); + assert!(!map.contains_key(&Pair("b", "a"))); +} + +#[test] +fn test_string_str() { + let s = String::from; + let mut map = HashMap::new(); + map.insert(s("a"), 1); + map.insert(s("b"), 2); + map.insert(s("x"), 3); + map.insert(s("y"), 4); + + assert!(map.contains_key("a")); + assert!(!map.contains_key("z")); + assert_eq!(map.remove("b"), Some(2)); +} diff --git a/library/hashbrown/tests/hasher.rs b/library/hashbrown/tests/hasher.rs new file mode 100644 index 0000000000000..5b591e0c08724 --- /dev/null +++ b/library/hashbrown/tests/hasher.rs @@ -0,0 +1,65 @@ +//! Sanity check that alternate hashers work correctly. + +#![cfg(not(miri))] // FIXME: takes too long + +use hashbrown::HashSet; +use std::hash::{BuildHasher, BuildHasherDefault, Hasher}; + +fn check() { + let range = 0..1_000; + + let mut set = HashSet::::default(); + set.extend(range.clone()); + + assert!(!set.contains(&i32::MIN)); + assert!(!set.contains(&(range.start - 1))); + for i in range.clone() { + assert!(set.contains(&i)); + } + assert!(!set.contains(&range.end)); + assert!(!set.contains(&i32::MAX)); +} + +/// Use hashbrown's default hasher. +#[test] +fn default() { + check::(); +} + +/// Use std's default hasher. +#[test] +fn random_state() { + check::(); +} + +/// Use a constant 0 hash. +#[test] +fn zero() { + #[derive(Default)] + struct ZeroHasher; + + impl Hasher for ZeroHasher { + fn finish(&self) -> u64 { + 0 + } + fn write(&mut self, _: &[u8]) {} + } + + check::>(); +} + +/// Use a constant maximum hash. +#[test] +fn max() { + #[derive(Default)] + struct MaxHasher; + + impl Hasher for MaxHasher { + fn finish(&self) -> u64 { + u64::MAX + } + fn write(&mut self, _: &[u8]) {} + } + + check::>(); +} diff --git a/library/hashbrown/tests/hasher_unwind.rs b/library/hashbrown/tests/hasher_unwind.rs new file mode 100644 index 0000000000000..ce801273173b4 --- /dev/null +++ b/library/hashbrown/tests/hasher_unwind.rs @@ -0,0 +1,159 @@ +//! Repro for a caught-panic corruption path in `std::collections::HashMap`. +//! +//! The bug class is: start a multi-step internal transition, let user code +//! panic in the middle, catch the unwind, and keep using the partially updated +//! object. +//! +//! In this case the user-controlled hook is `BuildHasher::build_hasher` during +//! an in-place rehash. The table keeps its logical length after the panic, but +//! lookups can no longer find the original keys and iteration starts yielding +//! repeated garbage-like entries. + +use hashbrown::HashMap; +use std::collections::BTreeSet; +use std::{ + hash::{BuildHasher, Hash, Hasher}, + panic::{AssertUnwindSafe, catch_unwind}, + sync::Mutex, + sync::atomic::{AtomicUsize, Ordering}, +}; + +/// One-shot panic switch used to trigger the first `build_hasher` call that +/// occurs inside `reserve(1)`. +static PANIC_COUNTER: AtomicUsize = AtomicUsize::new(0); +static TEST_LOCK: Mutex<()> = Mutex::new(()); + +/// A deterministic hasher that maps everything to the same bucket group. +/// +/// This maximizes collisions and makes the in-place rehash path easy to reach +/// with a small, fixed workload. +#[derive(Default)] +struct ZeroHasher; + +impl Hasher for ZeroHasher { + fn finish(&self) -> u64 { + 0 + } + + fn write(&mut self, _bytes: &[u8]) {} +} + +/// `BuildHasher` that panics once when armed. +/// +/// Using a panicking build hook mirrors the upstream interner trigger more +/// closely than a panicking `Hash` impl. +#[derive(Clone, Default)] +struct PanicBuildHasher; + +impl BuildHasher for PanicBuildHasher { + type Hasher = ZeroHasher; + + fn build_hasher(&self) -> Self::Hasher { + assert!( + PANIC_COUNTER.fetch_sub(1, Ordering::SeqCst) != 0, + "panic in BuildHasher::build_hasher" + ); + ZeroHasher + } +} + +/// Simple integer key type so the test can verify reachability after the panic. +#[derive(Clone, Debug, Eq, PartialEq, Hash)] +struct Key(u64); + +type Map = HashMap; + +/// Fill a map until `len == capacity`. +/// +/// With the current toolchain this yields a map with `len == capacity == 224` +/// when constructed from `with_capacity_and_hasher(128, ...)`. +fn make_full_map() -> Map { + PANIC_COUNTER.store(!0, Ordering::SeqCst); + let mut map = HashMap::with_capacity_and_hasher(128, PanicBuildHasher); + for i in 0.. { + map.insert(Key(i), i); + if map.len() == map.capacity() { + return map; + } + } + unreachable!() +} + +fn panics_silently(f: impl FnOnce()) -> bool { + let previous_hook = std::panic::take_hook(); + std::panic::set_hook(Box::new(|_| {})); + let panicked = catch_unwind(AssertUnwindSafe(f)).is_err(); + std::panic::set_hook(previous_hook); + panicked +} + +fn hashmap_reserve_survives_panicking_build_hasher_inner(count: usize) { + // Phase 1: fill a colliding table, then carve out the exact tombstone + // pattern that forces `reserve(1)` down the in-place rehash path. + let mut map = make_full_map(); + let original_len = map.len(); + assert_eq!( + (map.len(), map.capacity()), + (224, 224), + "this minimized workload is tuned for the validated std/hashbrown layout" + ); + + for i in 1..114 { + assert_eq!(map.remove(&Key(i)), Some(i)); + } + assert_eq!( + map.len(), + 111, + "setup should leave the expected tombstone pattern" + ); + + // Phase 2: make `BuildHasher::build_hasher` panic during the rehash, then + // keep using the recovered map. + PANIC_COUNTER.store(count, Ordering::SeqCst); + let reserve_panicked = panics_silently(|| { + map.reserve(1); + }); + assert!( + reserve_panicked, + "the minimized workload should panic during the in-place rehash" + ); + + // Phase 3: a correct table should keep every surviving key reachable and + // should not start yielding duplicate entries. + let mut expected_visible_keys: Vec<_> = map.keys().map(|&Key(i)| i).collect(); + let visible_keys: Vec<_> = (0..original_len as u64) + .filter(|&i| map.get(&Key(i)).copied() == Some(i)) + .collect(); + expected_visible_keys.sort(); + let iter_sample: Vec<_> = map.iter().take(8).map(|(k, v)| (k.0, *v)).collect(); + let distinct_entries = iter_sample.iter().copied().collect::>(); + + assert_eq!( + map.len(), + expected_visible_keys.len(), + "the table length should stay coherent" + ); + assert_eq!( + visible_keys, expected_visible_keys, + "the surviving keys should stay reachable after the caught panic" + ); + assert_eq!( + distinct_entries.len(), + iter_sample.len(), + "the iterator sample should not contain duplicate entries after the caught panic" + ); +} + +#[test] +fn hashmap_reserve_survives_panicking_build_hasher() { + let _guard = TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()); + if cfg!(miri) { + for i in [0, 50, 110] { + hashmap_reserve_survives_panicking_build_hasher_inner(i); + } + } else { + for i in 0..111 { + hashmap_reserve_survives_panicking_build_hasher_inner(i); + } + } +} diff --git a/library/hashbrown/tests/rayon.rs b/library/hashbrown/tests/rayon.rs new file mode 100644 index 0000000000000..2b8fb257ec216 --- /dev/null +++ b/library/hashbrown/tests/rayon.rs @@ -0,0 +1,536 @@ +#![expect(missing_docs)] // https://github.com/rust-lang/rust/issues/137561 +#![cfg(feature = "rayon")] + +use hashbrown::{HashMap, HashSet}; +use rayon::iter::{ + IntoParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelExtend, + ParallelIterator, +}; +use std::sync::LazyLock; + +macro_rules! assert_eq3 { + ($e1:expr, $e2:expr, $e3:expr) => {{ + assert_eq!($e1, $e2); + assert_eq!($e1, $e3); + assert_eq!($e2, $e3); + }}; +} + +static MAP_EMPTY: LazyLock> = LazyLock::new(HashMap::new); + +static MAP: LazyLock> = LazyLock::new(|| { + let mut m = HashMap::new(); + m.insert('b', 20); + m.insert('a', 10); + m.insert('c', 30); + m.insert('e', 50); + m.insert('f', 60); + m.insert('d', 40); + m +}); + +#[test] +fn map_seq_par_equivalence_iter_empty() { + let vec_seq = MAP_EMPTY.iter().collect::>(); + let vec_par = MAP_EMPTY.par_iter().collect::>(); + + assert_eq3!(vec_seq, vec_par, []); +} + +#[test] +fn map_seq_par_equivalence_iter() { + let mut vec_seq = MAP.iter().collect::>(); + let mut vec_par = MAP.par_iter().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [ + (&'a', &10), + (&'b', &20), + (&'c', &30), + (&'d', &40), + (&'e', &50), + (&'f', &60), + ]; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn map_seq_par_equivalence_keys_empty() { + let vec_seq = MAP_EMPTY.keys().collect::>(); + let vec_par = MAP_EMPTY.par_keys().collect::>(); + + let expected: [&char; 0] = []; + + assert_eq3!(vec_seq, vec_par, expected); +} + +#[test] +fn map_seq_par_equivalence_keys() { + let mut vec_seq = MAP.keys().collect::>(); + let mut vec_par = MAP.par_keys().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [&'a', &'b', &'c', &'d', &'e', &'f']; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn map_seq_par_equivalence_values_empty() { + let vec_seq = MAP_EMPTY.values().collect::>(); + let vec_par = MAP_EMPTY.par_values().collect::>(); + + let expected: [&u32; 0] = []; + + assert_eq3!(vec_seq, vec_par, expected); +} + +#[test] +fn map_seq_par_equivalence_values() { + let mut vec_seq = MAP.values().collect::>(); + let mut vec_par = MAP.par_values().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [&10, &20, &30, &40, &50, &60]; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn map_seq_par_equivalence_iter_mut_empty() { + let mut map1 = MAP_EMPTY.clone(); + let mut map2 = MAP_EMPTY.clone(); + + let vec_seq = map1.iter_mut().collect::>(); + let vec_par = map2.par_iter_mut().collect::>(); + + assert_eq3!(vec_seq, vec_par, []); +} + +#[test] +fn map_seq_par_equivalence_iter_mut() { + let mut map1 = MAP.clone(); + let mut map2 = MAP.clone(); + + let mut vec_seq = map1.iter_mut().collect::>(); + let mut vec_par = map2.par_iter_mut().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [ + (&'a', &mut 10), + (&'b', &mut 20), + (&'c', &mut 30), + (&'d', &mut 40), + (&'e', &mut 50), + (&'f', &mut 60), + ]; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn map_seq_par_equivalence_values_mut_empty() { + let mut map1 = MAP_EMPTY.clone(); + let mut map2 = MAP_EMPTY.clone(); + + let vec_seq = map1.values_mut().collect::>(); + let vec_par = map2.par_values_mut().collect::>(); + + let expected: [&u32; 0] = []; + + assert_eq3!(vec_seq, vec_par, expected); +} + +#[test] +fn map_seq_par_equivalence_values_mut() { + let mut map1 = MAP.clone(); + let mut map2 = MAP.clone(); + + let mut vec_seq = map1.values_mut().collect::>(); + let mut vec_par = map2.par_values_mut().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [&mut 10, &mut 20, &mut 30, &mut 40, &mut 50, &mut 60]; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn map_seq_par_equivalence_into_iter_empty() { + let vec_seq = MAP_EMPTY.clone().into_iter().collect::>(); + let vec_par = MAP_EMPTY.clone().into_par_iter().collect::>(); + + assert_eq3!(vec_seq, vec_par, []); +} + +#[test] +fn map_seq_par_equivalence_into_iter() { + let mut vec_seq = MAP.clone().into_iter().collect::>(); + let mut vec_par = MAP.clone().into_par_iter().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [ + ('a', 10), + ('b', 20), + ('c', 30), + ('d', 40), + ('e', 50), + ('f', 60), + ]; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +static MAP_VEC_EMPTY: &[(char, u32)] = &[]; + +static MAP_VEC: &[(char, u32)] = &[ + ('b', 20), + ('a', 10), + ('c', 30), + ('e', 50), + ('f', 60), + ('d', 40), +]; + +#[test] +fn map_seq_par_equivalence_collect_empty() { + let map_expected = MAP_EMPTY.clone(); + let map_seq = MAP_VEC_EMPTY.iter().copied().collect::>(); + let map_par = MAP_VEC_EMPTY.par_iter().copied().collect::>(); + + assert_eq!(map_seq, map_par); + assert_eq!(map_seq, map_expected); + assert_eq!(map_par, map_expected); +} + +#[test] +fn map_seq_par_equivalence_collect() { + let map_expected = MAP.clone(); + let map_seq = MAP_VEC.iter().copied().collect::>(); + let map_par = MAP_VEC.par_iter().copied().collect::>(); + + assert_eq!(map_seq, map_par); + assert_eq!(map_seq, map_expected); + assert_eq!(map_par, map_expected); +} + +static MAP_EXISTING_EMPTY: LazyLock> = LazyLock::new(HashMap::new); + +static MAP_EXISTING: LazyLock> = LazyLock::new(|| { + let mut m = HashMap::new(); + m.insert('b', 20); + m.insert('a', 10); + m +}); + +static MAP_EXTENSION_EMPTY: &[(char, u32)] = &[]; + +static MAP_EXTENSION: &[(char, u32)] = &[('c', 30), ('e', 50), ('f', 60), ('d', 40)]; + +#[test] +fn map_seq_par_equivalence_existing_empty_extend_empty() { + let expected = HashMap::new(); + let mut map_seq = MAP_EXISTING_EMPTY.clone(); + let mut map_par = MAP_EXISTING_EMPTY.clone(); + + map_seq.extend(MAP_EXTENSION_EMPTY.iter().copied()); + map_par.par_extend(MAP_EXTENSION_EMPTY.par_iter().copied()); + + assert_eq3!(map_seq, map_par, expected); +} + +#[test] +fn map_seq_par_equivalence_existing_empty_extend() { + let expected = MAP_EXTENSION.iter().copied().collect::>(); + let mut map_seq = MAP_EXISTING_EMPTY.clone(); + let mut map_par = MAP_EXISTING_EMPTY.clone(); + + map_seq.extend(MAP_EXTENSION.iter().copied()); + map_par.par_extend(MAP_EXTENSION.par_iter().copied()); + + assert_eq3!(map_seq, map_par, expected); +} + +#[test] +fn map_seq_par_equivalence_existing_extend_empty() { + let expected = MAP_EXISTING.clone(); + let mut map_seq = MAP_EXISTING.clone(); + let mut map_par = MAP_EXISTING.clone(); + + map_seq.extend(MAP_EXTENSION_EMPTY.iter().copied()); + map_par.par_extend(MAP_EXTENSION_EMPTY.par_iter().copied()); + + assert_eq3!(map_seq, map_par, expected); +} + +#[test] +fn map_seq_par_equivalence_existing_extend() { + let expected = MAP.clone(); + let mut map_seq = MAP_EXISTING.clone(); + let mut map_par = MAP_EXISTING.clone(); + + map_seq.extend(MAP_EXTENSION.iter().copied()); + map_par.par_extend(MAP_EXTENSION.par_iter().copied()); + + assert_eq3!(map_seq, map_par, expected); +} + +static SET_EMPTY: LazyLock> = LazyLock::new(HashSet::new); + +static SET: LazyLock> = LazyLock::new(|| { + let mut s = HashSet::new(); + s.insert('b'); + s.insert('a'); + s.insert('c'); + s.insert('e'); + s.insert('f'); + s.insert('d'); + s +}); + +#[test] +fn set_seq_par_equivalence_iter_empty() { + let vec_seq = SET_EMPTY.iter().collect::>(); + let vec_par = SET_EMPTY.par_iter().collect::>(); + + let expected: [&char; 0] = []; + + assert_eq3!(vec_seq, vec_par, expected); +} + +#[test] +fn set_seq_par_equivalence_iter() { + let mut vec_seq = SET.iter().collect::>(); + let mut vec_par = SET.par_iter().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = [&'a', &'b', &'c', &'d', &'e', &'f']; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +#[test] +fn set_seq_par_equivalence_into_iter_empty() { + let vec_seq = SET_EMPTY.clone().into_iter().collect::>(); + let vec_par = SET_EMPTY.clone().into_par_iter().collect::>(); + + // Work around type inference failure introduced by rend dev-dependency. + let empty: [char; 0] = []; + assert_eq3!(vec_seq, vec_par, empty); +} + +#[test] +fn set_seq_par_equivalence_into_iter() { + let mut vec_seq = SET.clone().into_iter().collect::>(); + let mut vec_par = SET.clone().into_par_iter().collect::>(); + + assert_eq!(vec_seq, vec_par); + + // Do not depend on the exact order of values + let expected_sorted = ['a', 'b', 'c', 'd', 'e', 'f']; + + vec_seq.sort_unstable(); + vec_par.sort_unstable(); + + assert_eq3!(vec_seq, vec_par, expected_sorted); +} + +static SET_VEC_EMPTY: &[char] = &[]; + +static SET_VEC: &[char] = &['b', 'a', 'c', 'e', 'f', 'd']; + +#[test] +fn set_seq_par_equivalence_collect_empty() { + let set_expected = SET_EMPTY.clone(); + let set_seq = SET_VEC_EMPTY.iter().copied().collect::>(); + let set_par = SET_VEC_EMPTY.par_iter().copied().collect::>(); + + assert_eq!(set_seq, set_par); + assert_eq!(set_seq, set_expected); + assert_eq!(set_par, set_expected); +} + +#[test] +fn set_seq_par_equivalence_collect() { + let set_expected = SET.clone(); + let set_seq = SET_VEC.iter().copied().collect::>(); + let set_par = SET_VEC.par_iter().copied().collect::>(); + + assert_eq!(set_seq, set_par); + assert_eq!(set_seq, set_expected); + assert_eq!(set_par, set_expected); +} + +static SET_EXISTING_EMPTY: LazyLock> = LazyLock::new(HashSet::new); + +static SET_EXISTING: LazyLock> = LazyLock::new(|| { + let mut s = HashSet::new(); + s.insert('b'); + s.insert('a'); + s +}); + +static SET_EXTENSION_EMPTY: &[char] = &[]; + +static SET_EXTENSION: &[char] = &['c', 'e', 'f', 'd']; + +#[test] +fn set_seq_par_equivalence_existing_empty_extend_empty() { + let expected = HashSet::new(); + let mut set_seq = SET_EXISTING_EMPTY.clone(); + let mut set_par = SET_EXISTING_EMPTY.clone(); + + set_seq.extend(SET_EXTENSION_EMPTY.iter().copied()); + set_par.par_extend(SET_EXTENSION_EMPTY.par_iter().copied()); + + assert_eq3!(set_seq, set_par, expected); +} + +#[test] +fn set_seq_par_equivalence_existing_empty_extend() { + let expected = SET_EXTENSION.iter().copied().collect::>(); + let mut set_seq = SET_EXISTING_EMPTY.clone(); + let mut set_par = SET_EXISTING_EMPTY.clone(); + + set_seq.extend(SET_EXTENSION.iter().copied()); + set_par.par_extend(SET_EXTENSION.par_iter().copied()); + + assert_eq3!(set_seq, set_par, expected); +} + +#[test] +fn set_seq_par_equivalence_existing_extend_empty() { + let expected = SET_EXISTING.clone(); + let mut set_seq = SET_EXISTING.clone(); + let mut set_par = SET_EXISTING.clone(); + + set_seq.extend(SET_EXTENSION_EMPTY.iter().copied()); + set_par.par_extend(SET_EXTENSION_EMPTY.par_iter().copied()); + + assert_eq3!(set_seq, set_par, expected); +} + +#[test] +fn set_seq_par_equivalence_existing_extend() { + let expected = SET.clone(); + let mut set_seq = SET_EXISTING.clone(); + let mut set_par = SET_EXISTING.clone(); + + set_seq.extend(SET_EXTENSION.iter().copied()); + set_par.par_extend(SET_EXTENSION.par_iter().copied()); + + assert_eq3!(set_seq, set_par, expected); +} + +static SET_A: LazyLock> = + LazyLock::new(|| ['a', 'b', 'c', 'd'].iter().copied().collect()); + +static SET_B: LazyLock> = + LazyLock::new(|| ['a', 'b', 'e', 'f'].iter().copied().collect()); + +static SET_DIFF_AB: LazyLock> = + LazyLock::new(|| ['c', 'd'].iter().copied().collect()); + +static SET_DIFF_BA: LazyLock> = + LazyLock::new(|| ['e', 'f'].iter().copied().collect()); + +static SET_SYMM_DIFF_AB: LazyLock> = + LazyLock::new(|| ['c', 'd', 'e', 'f'].iter().copied().collect()); + +static SET_INTERSECTION_AB: LazyLock> = + LazyLock::new(|| ['a', 'b'].iter().copied().collect()); + +static SET_UNION_AB: LazyLock> = + LazyLock::new(|| ['a', 'b', 'c', 'd', 'e', 'f'].iter().copied().collect()); + +#[test] +fn set_seq_par_equivalence_difference() { + let diff_ab_seq = SET_A.difference(&*SET_B).copied().collect::>(); + let diff_ab_par = SET_A + .par_difference(&*SET_B) + .copied() + .collect::>(); + + assert_eq3!(diff_ab_seq, diff_ab_par, *SET_DIFF_AB); + + let diff_ba_seq = SET_B.difference(&*SET_A).copied().collect::>(); + let diff_ba_par = SET_B + .par_difference(&*SET_A) + .copied() + .collect::>(); + + assert_eq3!(diff_ba_seq, diff_ba_par, *SET_DIFF_BA); +} + +#[test] +fn set_seq_par_equivalence_symmetric_difference() { + let symm_diff_ab_seq = SET_A + .symmetric_difference(&*SET_B) + .copied() + .collect::>(); + let symm_diff_ab_par = SET_A + .par_symmetric_difference(&*SET_B) + .copied() + .collect::>(); + + assert_eq3!(symm_diff_ab_seq, symm_diff_ab_par, *SET_SYMM_DIFF_AB); +} + +#[test] +fn set_seq_par_equivalence_intersection() { + let intersection_ab_seq = SET_A.intersection(&*SET_B).copied().collect::>(); + let intersection_ab_par = SET_A + .par_intersection(&*SET_B) + .copied() + .collect::>(); + + assert_eq3!( + intersection_ab_seq, + intersection_ab_par, + *SET_INTERSECTION_AB + ); +} + +#[test] +fn set_seq_par_equivalence_union() { + let union_ab_seq = SET_A.union(&*SET_B).copied().collect::>(); + let union_ab_par = SET_A.par_union(&*SET_B).copied().collect::>(); + + assert_eq3!(union_ab_seq, union_ab_par, *SET_UNION_AB); +} diff --git a/library/hashbrown/tests/serde.rs b/library/hashbrown/tests/serde.rs new file mode 100644 index 0000000000000..b77f3fc14411e --- /dev/null +++ b/library/hashbrown/tests/serde.rs @@ -0,0 +1,66 @@ +#![expect(missing_docs)] // https://github.com/rust-lang/rust/issues/137561 +#![cfg(feature = "serde")] + +use core::hash::BuildHasherDefault; +use fnv::FnvHasher; +use hashbrown::{HashMap, HashSet}; +use serde_test::{Token, assert_tokens}; + +// We use FnvHash for this test because we rely on the ordering +type FnvHashMap = HashMap>; +type FnvHashSet = HashSet>; + +#[test] +fn map_serde_tokens_empty() { + let map = FnvHashMap::::default(); + + assert_tokens(&map, &[Token::Map { len: Some(0) }, Token::MapEnd]); +} + +#[test] +fn map_serde_tokens() { + let mut map = FnvHashMap::default(); + map.insert('b', 20); + map.insert('a', 10); + map.insert('c', 30); + + assert_tokens( + &map, + &[ + Token::Map { len: Some(3) }, + Token::Char('a'), + Token::I32(10), + Token::Char('c'), + Token::I32(30), + Token::Char('b'), + Token::I32(20), + Token::MapEnd, + ], + ); +} + +#[test] +fn set_serde_tokens_empty() { + let set = FnvHashSet::::default(); + + assert_tokens(&set, &[Token::Seq { len: Some(0) }, Token::SeqEnd]); +} + +#[test] +fn set_serde_tokens() { + let mut set = FnvHashSet::default(); + set.insert(20); + set.insert(10); + set.insert(30); + + assert_tokens( + &set, + &[ + Token::Seq { len: Some(3) }, + Token::I32(30), + Token::I32(20), + Token::I32(10), + Token::SeqEnd, + ], + ); +} diff --git a/library/hashbrown/tests/set.rs b/library/hashbrown/tests/set.rs new file mode 100644 index 0000000000000..2fa13c128145d --- /dev/null +++ b/library/hashbrown/tests/set.rs @@ -0,0 +1,35 @@ +#![expect(missing_docs)] // https://github.com/rust-lang/rust/issues/137561 +#![cfg(not(miri))] // FIXME: takes too long + +use hashbrown::HashSet; +use rand::{Rng, SeedableRng, distr::Alphanumeric, rngs::SmallRng}; +use std::iter; + +#[test] +fn test_hashset_insert_remove() { + let mut m: HashSet> = HashSet::new(); + let seed = u64::from_le_bytes(*b"testseed"); + + let rng = &mut SmallRng::seed_from_u64(seed); + let tx: Vec> = iter::repeat_with(|| { + rng.sample_iter(&Alphanumeric) + .take(32) + .map(char::from) + .collect() + }) + .take(4096) + .collect(); + + // more readable with explicit `true` / `false` + #[expect(clippy::bool_assert_comparison)] + for _ in 0..32 { + for x in &tx { + assert_eq!(m.contains(x), false); + assert_eq!(m.insert(x.clone()), true); + } + for (i, x) in tx.iter().enumerate() { + println!("removing {i} {x:?}"); + assert_eq!(m.remove(x), true); + } + } +} diff --git a/library/proc_macro/src/bridge/arena.rs b/library/proc_macro/src/bridge/arena.rs index baa5dac461408..13fabf7e14f13 100644 --- a/library/proc_macro/src/bridge/arena.rs +++ b/library/proc_macro/src/bridge/arena.rs @@ -42,11 +42,10 @@ impl Arena { // arenas that are used for 100s of MiBs. Note also that the chosen sizes match // the usual sizes of pages and huge pages on Linux. const PAGE: usize = 4096; - const HUGE_PAGE: usize = - cfg_select! { - any(target_pointer_width = "64", target_pointer_width = "32") => 2 * 1024 * 1024, - _ => 8192, // just make it compile for -Zbuild-std - }; + const HUGE_PAGE: usize = cfg_select! { + any(target_pointer_width = "64", target_pointer_width = "32") => 2 * 1024 * 1024, + _ => 8192, // just make it compile for -Zbuild-std + }; let mut chunks = self.chunks.borrow_mut(); let mut new_cap; diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index e35acce2fef81..1d578deddd645 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -8,7 +8,7 @@ pub use alloc::ffi::c_str::IntoStringError; pub use alloc::ffi::c_str::{CString, NulError}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ffi::c_str::CStr; -#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "cstr_display", since = "1.101.0")] pub use core::ffi::c_str::Display; #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use core::ffi::c_str::FromBytesUntilNulError; diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index bf61ab79964c4..d75107616a283 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1150,9 +1150,9 @@ impl File { self.inner.file_attr().map(Metadata) } - /// Creates a new `File` instance that shares the same underlying file handle - /// as the existing `File` instance. Reads, writes, and seeks will affect - /// both `File` instances simultaneously. + /// Creates a new `File` instance with a different OS handle referring to + /// the same underlying system resource as the existing `File` instance. + /// Reads, writes, and seeks will affect both `File` instances simultaneously. /// /// # Examples /// @@ -3918,6 +3918,11 @@ impl DirBuilder { return Ok(()); } + // For certain platforms, a path like "/tmp/foo/.", while the "/tmp" directory exists, + // the mkdir function may produce a `NotFound` error on that path instead of succeeding + // due to viewing the "foo" and "." as two separate missing components. + // See https://github.com/rust-lang/rust/issues/162243 + let path = path.components().as_path(); let ancestors = path.ancestors(); let mut uncreated_dirs = 0; diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 46ed6597c9b06..0975add4ba9da 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1404,6 +1404,14 @@ fn recursive_mkdir() { assert!(dir.is_dir()) } +#[test] +fn recursive_mkdir_with_trailing_cur_dir() { + let tmpdir = tmpdir(); + let dir = tmpdir.join("foo").join("."); + check!(fs::create_dir_all(&dir)); + assert!(dir.is_dir()) +} + #[test] fn recursive_mkdir_failure() { let tmpdir = tmpdir(); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index d2f7347208cd6..eddcb8f5c96a6 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -350,7 +350,6 @@ #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] #![feature(hint_must_use)] -#![feature(int_from_ascii)] #![feature(io_error_inprogress)] #![feature(io_error_input_output_error)] #![feature(io_error_more)] @@ -642,7 +641,7 @@ pub mod num; #[allow(unreachable_pub)] pub mod os; pub mod panic; -#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[unstable(feature = "pattern_types", issue = "123646")] pub mod pat; pub mod path; pub mod process; @@ -650,7 +649,7 @@ pub mod process; pub mod random; pub mod sync; pub mod time; -#[unstable(feature = "view_type_macro", issue = "155938")] +#[unstable(feature = "view_types", issue = "155938")] pub mod view; // Pull in `std_float` crate into std. The contents of @@ -714,6 +713,8 @@ pub mod arch { pub use std_detect::is_arm_feature_detected; #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] pub use std_detect::is_loongarch_feature_detected; + #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] + pub use std_detect::is_mips_feature_detected; #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] pub use std_detect::is_powerpc_feature_detected; #[stable(feature = "riscv_ratified", since = "1.78.0")] @@ -722,8 +723,6 @@ pub mod arch { pub use std_detect::is_s390x_feature_detected; #[stable(feature = "simd_x86", since = "1.27.0")] pub use std_detect::is_x86_feature_detected; - #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] - pub use std_detect::{is_mips_feature_detected, is_mips64_feature_detected}; } // This was stabilized in the crate root so we have to keep it there. diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 914c400fb05f1..1cbc07f4183de 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -155,7 +155,14 @@ impl UdpSocket { /// /// The function must be called with valid byte array `buf` of sufficient size to /// hold the message bytes. If a message is too long to fit in the supplied buffer, - /// excess bytes may be discarded. + /// only the bytes that fit are copied into `buf`; the excess bytes are not returned + /// by this call. The datagram itself is left in the queue in full, so a later call + /// to [`UdpSocket::recv_from`] with a large enough buffer still receives the whole + /// message. + /// + /// Whether peeking with a too-small buffer succeeds with a truncated length or + /// fails is platform-specific. For example, Windows returns an error + /// (`WSAEMSGSIZE`) in this case. /// /// Successive calls return the same data. This is accomplished by passing /// `MSG_PEEK` as a flag to the underlying `recvfrom` system call. @@ -823,7 +830,14 @@ impl UdpSocket { /// /// The function must be called with valid byte array `buf` of sufficient size to /// hold the message bytes. If a message is too long to fit in the supplied buffer, - /// excess bytes may be discarded. + /// only the bytes that fit are copied into `buf`; the excess bytes are not returned + /// by this call. The datagram itself is left in the queue in full, so a later call + /// to [`UdpSocket::recv`] with a large enough buffer still receives the whole + /// message. + /// + /// Whether peeking with a too-small buffer succeeds with a truncated length or + /// fails is platform-specific. For example, Windows returns an error + /// (`WSAEMSGSIZE`) in this case. /// /// Successive calls return the same data. This is accomplished by passing /// `MSG_PEEK` as a flag to the underlying `recv` system call. diff --git a/library/std/src/num/mod.rs b/library/std/src/num/mod.rs index 9d713ab812829..2feaae34135fe 100644 --- a/library/std/src/num/mod.rs +++ b/library/std/src/num/mod.rs @@ -24,6 +24,8 @@ pub use core::num::Wrapping; issue = "none" )] pub use core::num::ZeroablePrimitive; +#[unstable(feature = "f16b", issue = "160630")] +pub use core::num::f16b; #[stable(feature = "rust1", since = "1.0.0")] pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; #[stable(feature = "signed_nonzero", since = "1.34.0")] diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index 901263a7aa123..ce5654b5576c7 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -965,7 +965,10 @@ impl UnixDatagram { /// /// The function must be called with valid byte array `buf` of sufficient size to /// hold the message bytes. If a message is too long to fit in the supplied buffer, - /// excess bytes may be discarded. + /// only the bytes that fit are copied into `buf`; the excess bytes are not returned + /// by this call. The datagram itself is left in the queue in full, so a later call + /// to [`UnixDatagram::recv_from`] with a large enough buffer still receives the + /// whole message. /// /// Successive calls return the same data. This is accomplished by passing /// `MSG_PEEK` as a flag to the underlying `recvfrom` system call. diff --git a/library/std/src/os/windows/process.rs b/library/std/src/os/windows/process.rs index 5065026b21a46..422e5f172229d 100644 --- a/library/std/src/os/windows/process.rs +++ b/library/std/src/os/windows/process.rs @@ -398,10 +398,7 @@ pub impl(self) trait CommandExt { /// see the [Remarks][1] section of the `CreateProcessW` documentation. /// /// [1]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#remarks - #[stable( - feature = "windows_process_extensions_inherit_handles", - since = "CURRENT_RUSTC_VERSION" - )] + #[stable(feature = "windows_process_extensions_inherit_handles", since = "1.101.0")] fn inherit_handles(&mut self, inherit_handles: bool) -> &mut process::Command; } @@ -497,7 +494,7 @@ impl ChildExt for process::Child { } /// Windows-specific extensions to [`process::ExitCode`]. -#[stable(feature = "windows_process_exit_code_from", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "windows_process_exit_code_from", since = "1.101.0")] pub impl(self) trait ExitCodeExt { /// Creates a new `ExitCode` from the raw underlying `u32` return value of /// a process. @@ -505,11 +502,11 @@ pub impl(self) trait ExitCodeExt { /// The exit code should not be 259, as this conflicts with the `STILL_ACTIVE` /// macro returned from the `GetExitCodeProcess` function to signal that the /// process has yet to run to completion. - #[stable(feature = "windows_process_exit_code_from", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "windows_process_exit_code_from", since = "1.101.0")] fn from_raw(raw: u32) -> Self; } -#[stable(feature = "windows_process_exit_code_from", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "windows_process_exit_code_from", since = "1.101.0")] impl ExitCodeExt for process::ExitCode { #[rustdoc_skip_body] fn from_raw(raw: u32) -> Self { diff --git a/library/std/src/pat.rs b/library/std/src/pat.rs index aeddd84c2cb54..3d227b1903f33 100644 --- a/library/std/src/pat.rs +++ b/library/std/src/pat.rs @@ -1,3 +1,3 @@ //! Helper module for exporting the `pattern_type` macro -pub use core::pattern_type; +pub use core::pat::pattern_type; diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 996d7af400f18..cc7fab7aba9d1 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -24,6 +24,18 @@ //! waits until the process terminates, while [`spawn`] will return a [`Child`] //! that represents the spawned child process. //! +//! Spawning a command may return an error if: +//! - The command does not exist, or is not in the platform-specific PATH search list. +//! - A platform-specific limit on memory, number of processes, or number of threads is reached. +//! - The current process doesn't have enough permissions to spawn the command. +//! - A dynamic library required by the command could not be found. +//! +//! This list is not exhaustive. Other errors may occur depending on the platform. +//! +//! Note that the function will error only while attempting to spawn the child. If the child is +//! successfully spawned, any error that happens afterwards will be reported through +//! its [`ExitStatus`]. +//! //! # Handling I/O //! //! The [`stdout`], [`stdin`], and [`stderr`] of a child process can be diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index b138c1b946c92..081cad45116da 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -179,7 +179,7 @@ #![cfg_attr(rustfmt, rustfmt::skip)] // These come from `core` & `alloc` and only in one flavor: no poisoning. -#[stable(feature = "exclusive_wrapper", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "exclusive_wrapper", since = "1.101.0")] pub use core::sync::SyncView; #[stable(feature = "rust1", since = "1.0.0")] pub use core::sync::atomic; diff --git a/library/std/src/sys/alloc/windows.rs b/library/std/src/sys/alloc/windows.rs index 1d75cbd9d54f1..a62a634857d1e 100644 --- a/library/std/src/sys/alloc/windows.rs +++ b/library/std/src/sys/alloc/windows.rs @@ -145,7 +145,13 @@ unsafe fn allocate(layout: Layout, zeroed: bool) -> *mut u8 { // Create a correctly aligned pointer offset from the start of the allocated block, // and write a header before it. - let offset = layout.align() - (ptr.addr() & (layout.align() - 1)); + // SAFETY: Guaranteed by Layout::align. + // This hint is technically redundant, but currently LLVM needs this explicit hint to + // optimize out a panic path inside align_offset. + unsafe { + core::hint::assert_unchecked(layout.align().is_power_of_two()); + } + let offset = ptr.wrapping_add(1).align_offset(layout.align()) + 1; // SAFETY: `MIN_ALIGN` <= `offset` <= `layout.align()` and the size of the allocated // block is `layout.align() + layout.size()`. `aligned` will thus be a correctly aligned // pointer inside the allocated block with at least `layout.size()` bytes after it and at diff --git a/library/std/src/sys/fd/unix.rs b/library/std/src/sys/fd/unix.rs index c46ca0cd4d591..3166f8b7aacb7 100644 --- a/library/std/src/sys/fd/unix.rs +++ b/library/std/src/sys/fd/unix.rs @@ -30,8 +30,11 @@ cfg_select! { -1 } } - any(all(target_os = "linux", not(target_env = "musl")), target_os = "android", target_os = "hurd") => - { + any( + all(target_os = "linux", not(target_env = "musl")), + target_os = "android", + target_os = "hurd" + ) => { // Prefer explicit pread64 for 64-bit offset independently of libc // #[cfg(gnu_file_offset_bits64)]. use libc::{pread64, pwrite64}; @@ -68,9 +71,7 @@ pub struct FileDesc(OwnedFd); // number of bytes written (eg, writing 2^31 bytes returns (2^64 - 2^31) instead // of the correct byte count). const READ_LIMIT: usize = cfg_select! { - any(target_vendor = "apple", target_os = "nto", target_os = "qnx") => { - libc::c_int::MAX as usize - } + any(target_vendor = "apple", target_os = "nto", target_os = "qnx") => libc::c_int::MAX as usize, _ => libc::ssize_t::MAX as usize, }; diff --git a/library/std/src/sys/fs/unix/dir.rs b/library/std/src/sys/fs/unix/dir.rs index 2ac5695e3d72a..7a870024240fb 100644 --- a/library/std/src/sys/fs/unix/dir.rs +++ b/library/std/src/sys/fs/unix/dir.rs @@ -28,13 +28,12 @@ use crate::sys::helpers::run_path_with_cstr; use crate::sys::{AsInner, FromInner, IntoInner, cvt, cvt_r}; use crate::{fmt, fs, io, mem}; -const TRAVERSE_DIRECTORY: i32 = - cfg_select! { - any(target_os = "freebsd", target_os = "aix") => libc::O_EXEC, - any(target_os = "linux", target_os = "android", target_os = "l4re") => libc::O_PATH, - target_os = "illumos" => libc::O_SEARCH, - _ => libc::O_RDONLY, - }; +const TRAVERSE_DIRECTORY: i32 = cfg_select! { + any(target_os = "freebsd", target_os = "aix") => libc::O_EXEC, + any(target_os = "linux", target_os = "android", target_os = "l4re") => libc::O_PATH, + target_os = "illumos" => libc::O_SEARCH, + _ => libc::O_RDONLY, +}; pub struct Dir(pub(super) OwnedFd); diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index 77311d233fc74..a7802c1e8bf4c 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -279,12 +279,12 @@ impl OpenOptions { match (self.read, self.write, self.append) { (_, false, false) if self.truncate || self.create || self.create_new => { - Err(io::Error::new( + Err(io::const_error!( io::ErrorKind::InvalidInput, "creating or truncating a file requires write or append access", )) } - (_, _, true) if self.truncate && !self.create_new => Err(io::Error::new( + (_, _, true) if self.truncate && !self.create_new => Err(io::const_error!( io::ErrorKind::InvalidInput, "append and truncate cannot both be enabled", )), @@ -293,7 +293,7 @@ impl OpenOptions { (true, true, false) => Ok(c::GENERIC_READ | c::GENERIC_WRITE), (false, _, true) => Ok(c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA), (true, _, true) => Ok(c::GENERIC_READ | (c::FILE_GENERIC_WRITE & !c::FILE_WRITE_DATA)), - (false, false, false) => Err(io::Error::new( + (false, false, false) => Err(io::const_error!( io::ErrorKind::InvalidInput, "must specify at least one of read, write, or append access", )), diff --git a/library/std/src/sys/net/connection/socket/mod.rs b/library/std/src/sys/net/connection/socket/mod.rs index 67be140cc313c..7fbd12e325385 100644 --- a/library/std/src/sys/net/connection/socket/mod.rs +++ b/library/std/src/sys/net/connection/socket/mod.rs @@ -50,12 +50,11 @@ use netc as c; // // On Windows, the relevant syscall takes an `i32` (unlike for read/write!), // so we need to clamp to i32::MAX. -const MAX_SEND_LEN: usize = - cfg_select! { - any(target_vendor = "apple", target_os = "nto", target_os = "qnx") => c_int::MAX as usize, - target_os = "windows" => i32::MAX as usize, - _ => libc::ssize_t::MAX as usize, - }; +const MAX_SEND_LEN: usize = cfg_select! { + any(target_vendor = "apple", target_os = "nto", target_os = "qnx") => c_int::MAX as usize, + target_os = "windows" => i32::MAX as usize, + _ => libc::ssize_t::MAX as usize, +}; /// Some systems support setting the nonblocking mode upon socket creation, which /// saves a syscall. diff --git a/library/std/src/view.rs b/library/std/src/view.rs index 5806cf27c2cc8..3e0e7d1d1038a 100644 --- a/library/std/src/view.rs +++ b/library/std/src/view.rs @@ -1,3 +1,3 @@ //! Helper module for exporting the `view_types` macro. -pub use core::view_type; +pub use core::view::view_type; diff --git a/library/std/tests/pipe_subprocess.rs b/library/std/tests/pipe_subprocess.rs index 35ad327ef4f48..5cf4c3a7b5665 100644 --- a/library/std/tests/pipe_subprocess.rs +++ b/library/std/tests/pipe_subprocess.rs @@ -1,49 +1,76 @@ -fn main() { - // No `Command` on Miri, emscripten or L4Re - #[cfg(all( - not(skip_unsupported_miri_tests), - any(unix, windows), - not(any(target_os = "emscripten", target_os = "l4re")) - ))] - { - use std::io::{Read, pipe}; - use std::{env, process}; - - if env::var("I_AM_THE_CHILD").is_ok() { - child(); - } else { - parent(); - } - - fn parent() { - let me = env::current_exe().unwrap(); - // If a custom `runner` is set up for the current target, we'll be - // executing `./runner ./test`, not just `./test`. For such a case, - // use the same arguments for child to avoid executing `runner` - // without an actual executable. - let args = env::args(); - - let (rx, tx) = pipe().unwrap(); - assert!( - process::Command::new(me) - .args(args) - .env("I_AM_THE_CHILD", "1") - .stdout(tx) - .status() - .unwrap() - .success() - ); - - let mut s = String::new(); - (&rx).read_to_string(&mut s).unwrap(); - drop(rx); - assert_eq!(s, "Heloo,\n"); - - println!("Test pipe_subprocess.rs success"); - } - - fn child() { - println!("Heloo,"); - } +#![feature(test)] + +use std::io::{Read, pipe}; +use std::process::ExitCode; +use std::{env, process}; + +// We invoke the test harness manually so that the same binary can also serve as the child +// process that sits on the other end of the pipe. +extern crate test; + +// No `Command` on Miri, emscripten or L4Re +const RUN_TEST: bool = cfg!(all( + any(unix, windows), + not(any(skip_unsupported_miri_tests, target_os = "emscripten", target_os = "l4re")) +)); + +static TESTS: &[&test::TestDescAndFn] = &[&test::TestDescAndFn { + testfn: test::TestFn::StaticTestFn(pipe_subprocess), + desc: test::TestDesc { + name: test::StaticTestName("pipe_subprocess"), + ignore: !RUN_TEST, + ignore_message: None, + source_file: file!(), + start_line: 0, + start_col: 0, + end_line: 0, + end_col: 0, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, +}]; + +// The test itself, aka the parent process. +fn pipe_subprocess() -> Result<(), String> { + let me = env::current_exe().unwrap(); + // If a custom `runner` is set up for the current target, we'll be + // executing `./runner ./test`, not just `./test`. For such a case, + // use the same arguments for child to avoid executing `runner` + // without an actual executable. + let args = env::args(); + + let (rx, tx) = pipe().unwrap(); + assert!( + process::Command::new(me) + .args(args) + .env("I_AM_THE_CHILD", "1") + .stdout(tx) + .status() + .unwrap() + .success() + ); + + let mut s = String::new(); + (&rx).read_to_string(&mut s).unwrap(); + drop(rx); + assert_eq!(s, "Heloo,\n"); + + println!("Test pipe_subprocess.rs success"); + Ok(()) +} + +fn child() { + println!("Heloo,"); +} + +fn main() -> ExitCode { + if env::var("I_AM_THE_CHILD").is_ok() { + child(); + ExitCode::SUCCESS + } else { + // Go via libtest runner so test filtering and nextest work properly. + test::test_main_env_args(TESTS) } } diff --git a/library/std_detect/src/detect/arch/mips.rs b/library/std_detect/src/detect/arch/mips.rs index 9e1960eb96da5..17435c9d8f50f 100644 --- a/library/std_detect/src/detect/arch/mips.rs +++ b/library/std_detect/src/detect/arch/mips.rs @@ -2,7 +2,12 @@ features! { @TARGET: mips; - @CFG: target_arch = "mips"; + @CFG: any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + ); @MACRO_NAME: is_mips_feature_detected; @MACRO_ATTRS: /// Check for the presence of a CPU feature at runtime. diff --git a/library/std_detect/src/detect/arch/mips64.rs b/library/std_detect/src/detect/arch/mips64.rs deleted file mode 100644 index 2bb44ba6e2b39..0000000000000 --- a/library/std_detect/src/detect/arch/mips64.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Run-time feature detection on MIPS64. - -features! { - @TARGET: mips64; - @CFG: target_arch = "mips64"; - @MACRO_NAME: is_mips64_feature_detected; - @MACRO_ATTRS: - /// Check for the presence of a CPU feature at runtime. - /// - /// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`) - /// the macro expands to `true`. - #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] - @FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa"; - /// MIPS SIMD Architecture (MSA) -} diff --git a/library/std_detect/src/detect/arch/mod.rs b/library/std_detect/src/detect/arch/mod.rs index 2c0b464e32beb..7e21f2986e6a4 100644 --- a/library/std_detect/src/detect/arch/mod.rs +++ b/library/std_detect/src/detect/arch/mod.rs @@ -14,8 +14,6 @@ mod powerpc; #[macro_use] mod mips; #[macro_use] -mod mips64; -#[macro_use] mod loongarch; #[macro_use] mod s390x; @@ -41,14 +39,15 @@ cfg_select! { pub use powerpc::__is_feature_detected; pub(crate) use powerpc::Feature; } - target_arch = "mips" => { + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + ) => { pub use mips::__is_feature_detected; pub(crate) use mips::Feature; } - target_arch = "mips64" => { - pub use mips64::__is_feature_detected; - pub(crate) use mips64::Feature; - } any(target_arch = "loongarch32", target_arch = "loongarch64") => { pub use loongarch::__is_feature_detected; pub(crate) use loongarch::Feature; diff --git a/library/std_detect/src/detect/os/darwin/aarch64.rs b/library/std_detect/src/detect/os/darwin/aarch64.rs index 35009a2b147cd..bf6d4d6bfdb8e 100644 --- a/library/std_detect/src/detect/os/darwin/aarch64.rs +++ b/library/std_detect/src/detect/os/darwin/aarch64.rs @@ -36,8 +36,16 @@ pub(crate) fn detect_features() -> cache::Initializer { // Armv8.0 features not using the standard identifiers let fp = _sysctlbyname(c"hw.optional.floatingpoint"); - let asimd = _sysctlbyname(c"hw.optional.AdvSIMD") || _sysctlbyname(c"hw.optional.arm.AdvSIMD"); + let asimd = _sysctlbyname(c"hw.optional.AdvSIMD") + || _sysctlbyname(c"hw.optional.arm.AdvSIMD") + || _sysctlbyname(c"hw.optional.arm.neon"); let crc_old = _sysctlbyname(c"hw.optional.armv8_crc32"); + let lse_old = _sysctlbyname(c"hw.optional.armv8_1_atomics"); + let fp16_old = _sysctlbyname(c"hw.optional.neon_fp16"); + let fhm_old = _sysctlbyname(c"hw.optional.armv8_2_fhm"); + let sha512_old = _sysctlbyname(c"hw.optional.armv8_2_sha512"); + let sha3_old = _sysctlbyname(c"hw.optional.armv8_2_sha3"); + let fcma_old = _sysctlbyname(c"hw.optional.armv8_3_compnum"); // Armv8 and Armv9 features using the standard identifiers let aes = _sysctlbyname(c"hw.optional.arm.FEAT_AES"); @@ -50,11 +58,14 @@ pub(crate) fn detect_features() -> cache::Initializer { let dpb = _sysctlbyname(c"hw.optional.arm.FEAT_DPB"); let dpb2 = _sysctlbyname(c"hw.optional.arm.FEAT_DPB2"); let ecv = _sysctlbyname(c"hw.optional.arm.FEAT_ECV"); + let faminmax = _sysctlbyname(c"hw.optional.arm.FEAT_FAMINMAX"); let fcma = _sysctlbyname(c"hw.optional.arm.FEAT_FCMA"); let fhm = _sysctlbyname(c"hw.optional.arm.FEAT_FHM"); let flagm = _sysctlbyname(c"hw.optional.arm.FEAT_FlagM"); let flagm2 = _sysctlbyname(c"hw.optional.arm.FEAT_FlagM2"); + let fp8 = _sysctlbyname(c"hw.optional.arm.FEAT_FP8"); let fp16 = _sysctlbyname(c"hw.optional.arm.FEAT_FP16"); + let fpmr = _sysctlbyname(c"hw.optional.arm.FEAT_FPMR"); let frintts = _sysctlbyname(c"hw.optional.arm.FEAT_FRINTTS"); let hbc = _sysctlbyname(c"hw.optional.arm.FEAT_HBC"); let i8mm = _sysctlbyname(c"hw.optional.arm.FEAT_I8MM"); @@ -63,23 +74,28 @@ pub(crate) fn detect_features() -> cache::Initializer { let rcpc2 = _sysctlbyname(c"hw.optional.arm.FEAT_LRCPC2"); let lse = _sysctlbyname(c"hw.optional.arm.FEAT_LSE"); let lse2 = _sysctlbyname(c"hw.optional.arm.FEAT_LSE2"); + let lut = _sysctlbyname(c"hw.optional.arm.FEAT_LUT"); let mte = _sysctlbyname(c"hw.optional.arm.FEAT_MTE"); let mte2 = _sysctlbyname(c"hw.optional.arm.FEAT_MTE2"); let pauth = _sysctlbyname(c"hw.optional.arm.FEAT_PAuth"); + let pauth_lr = _sysctlbyname(c"hw.optional.arm.FEAT_PAuth_LR"); let pmull = _sysctlbyname(c"hw.optional.arm.FEAT_PMULL"); let rdm = _sysctlbyname(c"hw.optional.arm.FEAT_RDM"); let sb = _sysctlbyname(c"hw.optional.arm.FEAT_SB"); let sha1 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA1"); let sha256 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA256"); - let sha3 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA3"); let sha512 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA512"); + let sha3 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA3"); let sme = _sysctlbyname(c"hw.optional.arm.FEAT_SME"); let sme2 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2"); let sme2p1 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2p1"); let sme_b16b16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_B16B16"); + let sme_f8f16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F8F16"); + let sme_f8f32 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F8F32"); let sme_f16f16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F16F16"); let sme_f64f64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F64F64"); let sme_i16i64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_I16I64"); + let sme_lutv2 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_LUTv2"); let ssbs = _sysctlbyname(c"hw.optional.arm.FEAT_SSBS"); let sve_b16b16 = _sysctlbyname(c"hw.optional.arm.FEAT_SVE_B16B16"); let wfxt = _sysctlbyname(c"hw.optional.arm.FEAT_WFxT"); @@ -89,6 +105,8 @@ pub(crate) fn detect_features() -> cache::Initializer { // exist, and may potentially be exposed later. /* let afp = _sysctlbyname(c"hw.optional.arm.FEAT_AFP"); + let cpa = _sysctlbyname(c"hw.optional.arm.FEAT_CPA"); + let cpa2 = _sysctlbyname(c"hw.optional.arm.FEAT_CPA2"); let csv2 = _sysctlbyname(c"hw.optional.arm.FEAT_CSV2"); let csv3 = _sysctlbyname(c"hw.optional.arm.FEAT_CSV3"); let ebf16 = _sysctlbyname(c"hw.optional.arm.FEAT_EBF16"); @@ -131,35 +149,43 @@ pub(crate) fn detect_features() -> cache::Initializer { enable_feature(Feature::dpb, dpb); enable_feature(Feature::dpb2, dpb2); enable_feature(Feature::ecv, ecv); - enable_feature(Feature::fcma, fcma); - enable_feature(Feature::fhm, fhm); + enable_feature(Feature::faminmax, faminmax); + enable_feature(Feature::fcma, fcma_old || fcma); + enable_feature(Feature::fhm, fhm_old || fhm); enable_feature(Feature::flagm, flagm); enable_feature(Feature::flagm2, flagm2); enable_feature(Feature::fp, fp); - enable_feature(Feature::fp16, fp16); + enable_feature(Feature::fp8, fp8); + enable_feature(Feature::fp16, fp16_old || fp16); + enable_feature(Feature::fpmr, fpmr); enable_feature(Feature::frintts, frintts); enable_feature(Feature::hbc, hbc); enable_feature(Feature::i8mm, i8mm); enable_feature(Feature::jsconv, jsconv); - enable_feature(Feature::lse, lse); + enable_feature(Feature::lse, lse_old || lse); enable_feature(Feature::lse2, lse2); + enable_feature(Feature::lut, lut); enable_feature(Feature::mte, mte && mte2); enable_feature(Feature::paca, pauth); enable_feature(Feature::pacg, pauth); + enable_feature(Feature::pauth_lr, pauth_lr); enable_feature(Feature::pmull, aes && pmull); enable_feature(Feature::rcpc, rcpc); enable_feature(Feature::rcpc2, rcpc2); enable_feature(Feature::rdm, rdm); enable_feature(Feature::sb, sb); enable_feature(Feature::sha2, sha1 && sha256 && asimd); - enable_feature(Feature::sha3, sha512 && sha3 && asimd); + enable_feature(Feature::sha3, (sha512_old || sha512) && (sha3_old || sha3) && asimd); enable_feature(Feature::sme, sme); enable_feature(Feature::sme2, sme2); enable_feature(Feature::sme2p1, sme2p1); enable_feature(Feature::sme_b16b16, sme_b16b16); + enable_feature(Feature::sme_f8f16, sme_f8f16); + enable_feature(Feature::sme_f8f32, sme_f8f32); enable_feature(Feature::sme_f16f16, sme_f16f16); enable_feature(Feature::sme_f64f64, sme_f64f64); enable_feature(Feature::sme_i16i64, sme_i16i64); + enable_feature(Feature::sme_lutv2, sme_lutv2); enable_feature(Feature::ssbs, ssbs); enable_feature(Feature::sve_b16b16, sve_b16b16); enable_feature(Feature::wfxt, wfxt); diff --git a/library/std_detect/src/detect/os/linux/aarch64.rs b/library/std_detect/src/detect/os/linux/aarch64.rs index 936f06859491e..1bc5c7e1a6c47 100644 --- a/library/std_detect/src/detect/os/linux/aarch64.rs +++ b/library/std_detect/src/detect/os/linux/aarch64.rs @@ -369,7 +369,7 @@ impl AtHwcap { enable_feature(Feature::cssc, self.cssc); enable_feature(Feature::fpmr, self.fpmr); enable_feature(Feature::faminmax, self.faminmax); - let fp8 = self.f8cvt && self.faminmax && self.lut && self.bf16; + let fp8 = self.f8cvt && self.asimd; enable_feature(Feature::fp8, fp8); let fp8fma = self.f8fma && fp8; enable_feature(Feature::fp8fma, fp8fma); diff --git a/library/std_detect/src/lib.rs b/library/std_detect/src/lib.rs index d5805875ad9d6..fd76ed55bc056 100644 --- a/library/std_detect/src/lib.rs +++ b/library/std_detect/src/lib.rs @@ -8,7 +8,6 @@ //! * `aarch64`: [`is_aarch64_feature_detected`] //! * `riscv`: [`is_riscv_feature_detected`] //! * `mips`: [`is_mips_feature_detected`] -//! * `mips64`: [`is_mips64_feature_detected`] //! * `powerpc`: [`is_powerpc_feature_detected`] //! * `loongarch`: [`is_loongarch_feature_detected`] //! * `s390x`: [`is_s390x_feature_detected`] diff --git a/library/stdarch/Cargo.lock b/library/stdarch/Cargo.lock index 490161626c164..5750be2086cb6 100644 --- a/library/stdarch/Cargo.lock +++ b/library/stdarch/Cargo.lock @@ -73,7 +73,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -145,7 +145,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -213,7 +213,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.117", ] [[package]] @@ -224,7 +224,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -520,7 +520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.117", ] [[package]] @@ -745,7 +745,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -780,7 +780,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -807,7 +807,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -881,7 +881,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn", + "syn 3.0.9", ] [[package]] @@ -910,6 +910,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syscalls" version = "0.6.18" @@ -1094,7 +1105,7 @@ dependencies = [ "heck", "indexmap 2.13.1", "prettyplease", - "syn", + "syn 2.0.117", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -1110,7 +1121,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn", + "syn 2.0.117", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -1178,7 +1189,7 @@ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] diff --git a/library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 8bcd6409453c4..4607fbdceef11 100644 --- a/library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -1,10 +1,14 @@ -FROM ubuntu:25.04 # gcc-mips64-linux-gnuabi64 not available in 25.10 +FROM ubuntu:25.10 + +# gcc-mips64-linux-gnuabi64 not available by default in 25.10 +RUN echo "deb http://archive.ubuntu.com/ubuntu noble main universe" >> /etc/apt/sources.list.d/noble-copies.list RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ qemu-system-mips64 qemu-user +# Use Loongson-3A4000, a CPU with MSA support. Qemu does not define a max CPU for MIPS. ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ - CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ - OBJDUMP=mips64-linux-gnuabi64-objdump \ No newline at end of file + CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -cpu Loongson-3A4000 -L /usr/mips64-linux-gnuabi64" \ + OBJDUMP=mips64-linux-gnuabi64-objdump diff --git a/library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 9aa0ce05783c5..26c615b308257 100644 --- a/library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -1,10 +1,14 @@ -FROM ubuntu:25.04 # gcc-mips64el-linux-gnuabi64 not available in 25.10 +FROM ubuntu:25.10 + +# gcc-mips64el-linux-gnuabi64 not available by default in 25.10 +RUN echo "deb http://archive.ubuntu.com/ubuntu noble main universe" >> /etc/apt/sources.list.d/noble-copies.list RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ qemu-system-mips64el +# Use Loongson-3A4000, a CPU with MSA support. Qemu does not define a max CPU for MIPS. ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ - CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \ - OBJDUMP=mips64el-linux-gnuabi64-objdump \ No newline at end of file + CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -cpu Loongson-3A4000 -L /usr/mips64el-linux-gnuabi64" \ + OBJDUMP=mips64el-linux-gnuabi64-objdump diff --git a/library/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/library/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 82d05f0b25d1e..aff2add1a7ede 100644 --- a/library/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/library/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -9,4 +9,4 @@ ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -cpu mpc8610 -L /usr/powerpc-linux-gnu" \ CC=powerpc-linux-gnu-gcc \ OBJDUMP=powerpc-linux-gnu-objdump \ - STDARCH_TEST_SKIP_FEATURE=vsx + STDARCH_TEST_SKIP_FEATURE=vsx,power9-vector diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index 4b7a3d27ea4e2..3a926c3b9f7ba 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -43,7 +43,7 @@ INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml" case ${TARGET} in aarch64_be*) - export CFLAGS="-I${AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc/usr/include --sysroot={AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc -Wno-nonportable-vector-initialization" + export CFLAGS="-I${AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc/usr/include --sysroot=${AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc -Wno-nonportable-vector-initialization" ARCH=aarch64_be RUNTIME_RUSTFLAGS= ;; diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index 8c75df6afbe4f..71cd6558d898b 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -32,8 +32,14 @@ case ${TARGET} in ;; # Some x86_64 targets enable by default more features beyond SSE2, # which cause some instruction assertion checks to fail. + # (This does not disable tests that need more features, they get enabled based on + # what the host actually supports.) x86_64-*) - export RUSTFLAGS="${RUSTFLAGS} -C target-feature=-sse3" + # We want frame pointers to be consistent across targets. On the ios_macabi target + # we cannot turn them off, so let's turn them on everywhere. + # If we ever turn these off, a bunch of `limit(...)` clauses should be reduced to + # avoid tests becoming less strict! + export RUSTFLAGS="${RUSTFLAGS} -C target-feature=-sse3 -Cforce-frame-pointers=on" ;; #Unoptimized build uses fast-isel which breaks with msa mips-* | mipsel-*) @@ -113,7 +119,7 @@ case ${TARGET} in # cargo_test # ;; mips64*) - export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa" + export RUSTFLAGS="${RUSTFLAGS} -C target-cpu=mips64r5 -C target-feature=+msa" cargo_test ;; s390x*) diff --git a/library/stdarch/crates/assert-instr-macro/Cargo.toml b/library/stdarch/crates/assert-instr-macro/Cargo.toml index 77ee571ccbb82..a71dd0f69a6c8 100644 --- a/library/stdarch/crates/assert-instr-macro/Cargo.toml +++ b/library/stdarch/crates/assert-instr-macro/Cargo.toml @@ -11,7 +11,7 @@ test = false [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = { version = "2.0", features = ["full"] } +syn = { version = "3.0", features = ["full"] } [lints.rust] unexpected_cfgs = {level = "warn", check-cfg = ['cfg(optimized)'] } diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs index 839aae67cb2b0..63c73434e1bf1 100644 --- a/library/stdarch/crates/assert-instr-macro/src/lib.rs +++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs @@ -35,6 +35,12 @@ pub fn assert_instr( }; let instr = &invoc.instr; + let not = invoc.not; + let limit = match invoc.limit { + None => quote! { None }, + Some(l) => quote! { Some(#l) }, + }; + let name = &func.sig.ident; let maybe_allow_deprecated = if func .attrs @@ -107,6 +113,7 @@ pub fn assert_instr( let generic_ty_value = syn::TypePath { qself: qself.clone(), path: path.clone(), + attrs: Vec::new(), }; // Replace any function arguments that use generic parameters with the @@ -179,7 +186,7 @@ pub fn assert_instr( fn #assert_name() { #to_test - ::stdarch_test::assert(#shim_name as usize, stringify!(#shim_name), #instr); + ::stdarch_test::assert(#shim_name as usize, stringify!(#shim_name), #instr, &[#(#not),*], #limit); } }; @@ -192,51 +199,89 @@ pub fn assert_instr( struct Invoc { instr: String, + not: Vec, + limit: Option, args: Vec<(syn::Ident, syn::Expr)>, } +fn parse_instr(input: syn::parse::ParseStream<'_>) -> syn::Result { + use syn::{Token, ext::IdentExt}; + + let mut instr = String::new(); + while !input.is_empty() { + if let Ok(ident) = syn::Ident::parse_any(input) { + instr.push_str(&ident.to_string()); + continue; + } + if input.parse::().is_ok() { + instr.push('.'); + continue; + } + if let Ok(s) = input.parse::() { + instr.push_str(&s.value()); + continue; + } + // Some other token, must be start of the next thing. + break; + } + if instr.is_empty() { + return Err(input.error("expected an instruction")); + } + Ok(instr) +} + impl syn::parse::Parse for Invoc { fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result { - use syn::{Token, ext::IdentExt}; + use syn::{Token, parenthesized}; + + let instr = parse_instr(input)?; + let mut not = Vec::new(); + let mut limit = None; + let mut args = Vec::new(); - let mut instr = String::new(); while !input.is_empty() { - if input.parse::().is_ok() { - break; + // Parse the comma after the previous thing + if input.parse::().is_err() { + return Err(input.error("extra tokens at end")); } - if let Ok(ident) = syn::Ident::parse_any(input) { - instr.push_str(&ident.to_string()); - continue; + // Handle trailing comma. + if input.is_empty() { + break; } - if input.parse::().is_ok() { - instr.push('.'); + + // This is either `not(instr)` or `limit(n)` or `arg = val`. + // We treat `not` and `limit` as a magic identifier here. + + let name = input.parse::()?; + + if name == "not" { + let content; + parenthesized!(content in input); + let not_instr = parse_instr(&content)?; + if !content.is_empty() { + return Err(input.error("expected just an instruction in `not(...)`")); + } + not.push(not_instr); continue; } - if let Ok(s) = input.parse::() { - instr.push_str(&s.value()); + if name == "limit" { + let content; + parenthesized!(content in input); + let n = content.parse::()?; + limit = Some(n); continue; } - println!("{:?}", input.cursor().token_stream()); - return Err(input.error("expected an instruction")); - } - if instr.is_empty() { - return Err(input.error("expected an instruction before comma")); - } - let mut args = Vec::new(); - while !input.is_empty() { - let name = input.parse::()?; + input.parse::()?; let expr = input.parse::()?; args.push((name, expr)); - - if input.parse::().is_err() { - if !input.is_empty() { - return Err(input.error("extra tokens at end")); - } - break; - } } - Ok(Self { instr, args }) + Ok(Self { + instr, + not, + limit, + args, + }) } } diff --git a/library/stdarch/crates/core_arch/Cargo.toml b/library/stdarch/crates/core_arch/Cargo.toml index ee3eff825c790..e69705e004bce 100644 --- a/library/stdarch/crates/core_arch/Cargo.toml +++ b/library/stdarch/crates/core_arch/Cargo.toml @@ -25,7 +25,10 @@ stdarch-test = { version = "0.*", path = "../stdarch-test" } syscalls = { version = "0.6.18", default-features = false } [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_has_reliable_f16)'] } +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(target_has_reliable_f16b)', + 'cfg(target_has_reliable_f16)', +] } [lints.clippy] too_long_first_doc_paragraph = "allow" diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index 0f92c6dec0a9f..72f65d0d14344 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -4604,6 +4604,36 @@ pub fn vcombine_f64(a: float64x1_t, b: float64x1_t) -> float64x2_t { } } #[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopy_lane_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(nop, LANE1 = 3, LANE2 = 3))] +#[rustc_legacy_const_generics(1, 3)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub fn vcopy_lane_bf16( + a: bfloat16x4_t, + b: bfloat16x4_t, +) -> bfloat16x4_t { + unsafe { transmute(vcopy_lane_u16::(transmute(a), transmute(b))) } +} +#[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopyq_lane_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(nop, LANE1 = 7, LANE2 = 3))] +#[rustc_legacy_const_generics(1, 3)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub fn vcopyq_lane_bf16( + a: bfloat16x8_t, + b: bfloat16x4_t, +) -> bfloat16x8_t { + unsafe { transmute(vcopyq_lane_u16::(transmute(a), transmute(b))) } +} +#[doc = "Insert vector element from another vector element"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopy_lane_f32)"] #[inline] #[target_feature(enable = "neon")] @@ -4811,6 +4841,36 @@ pub fn vcopy_lane_p64( b } #[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopy_laneq_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(nop, LANE1 = 3, LANE2 = 7))] +#[rustc_legacy_const_generics(1, 3)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub fn vcopy_laneq_bf16( + a: bfloat16x4_t, + b: bfloat16x8_t, +) -> bfloat16x4_t { + unsafe { transmute(vcopy_laneq_u16::(transmute(a), transmute(b))) } +} +#[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopyq_laneq_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(nop, LANE1 = 7, LANE2 = 7))] +#[rustc_legacy_const_generics(1, 3)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub fn vcopyq_laneq_bf16( + a: bfloat16x8_t, + b: bfloat16x8_t, +) -> bfloat16x8_t { + unsafe { transmute(vcopyq_laneq_u16::(transmute(a), transmute(b))) } +} +#[doc = "Insert vector element from another vector element"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcopy_laneq_f32)"] #[inline] #[target_feature(enable = "neon")] @@ -11411,6 +11471,50 @@ pub unsafe fn vldap1q_lane_p64(ptr: *const p64, src: poly64x2_t transmute(vldap1q_lane_s64::(ptr as *mut i64, transmute(src))) } #[doc = "Lookup table read with 2-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti2, LANE = 1))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti2_lane_bf16(a: bfloat16x4_t, b: uint8x8_t) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 3); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti2.lane.v8bf16.v4bf16" + )] + fn _vluti2_lane_bf16(a: bfloat16x4_t, b: uint8x8_t, n: i32) -> bfloat16x8_t; + } + _vluti2_lane_bf16(a, b, LANE) +} +#[doc = "Lookup table read with 2-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti2, LANE = 1))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti2q_lane_bf16(a: bfloat16x8_t, b: uint8x8_t) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 3); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti2.lane.v8bf16.v8bf16" + )] + fn _vluti2q_lane_bf16(a: bfloat16x8_t, b: uint8x8_t, n: i32) -> bfloat16x8_t; + } + _vluti2q_lane_bf16(a, b, LANE) +} +#[doc = "Lookup table read with 2-bit indices"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2_lane_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -11621,6 +11725,50 @@ pub unsafe fn vluti2q_lane_s16(a: int16x8_t, b: uint8x8_t) -> i _vluti2q_lane_s16(a, b, LANE) } #[doc = "Lookup table read with 2-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti2, LANE = 1))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti2_laneq_bf16(a: bfloat16x4_t, b: uint8x16_t) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 7); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti2.laneq.v8bf16.v4bf16" + )] + fn _vluti2_laneq_bf16(a: bfloat16x4_t, b: uint8x16_t, n: i32) -> bfloat16x8_t; + } + _vluti2_laneq_bf16(a, b, LANE) +} +#[doc = "Lookup table read with 2-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2q_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti2, LANE = 1))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti2q_laneq_bf16(a: bfloat16x8_t, b: uint8x16_t) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 7); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti2.laneq.v8bf16.v8bf16" + )] + fn _vluti2q_laneq_bf16(a: bfloat16x8_t, b: uint8x16_t, n: i32) -> bfloat16x8_t; + } + _vluti2q_laneq_bf16(a, b, LANE) +} +#[doc = "Lookup table read with 2-bit indices"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti2_laneq_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -11831,6 +11979,36 @@ pub unsafe fn vluti2q_laneq_s16(a: int16x8_t, b: uint8x16_t) - _vluti2q_laneq_s16(a, b, INDEX) } #[doc = "Lookup table read with 4-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti4q_lane_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti4, LANE = 0))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti4q_lane_bf16_x2( + a: bfloat16x8x2_t, + b: uint8x8_t, +) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 1); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti4q.lane.x2.v8bf16" + )] + fn _vluti4q_lane_bf16_x2( + a0: bfloat16x8_t, + a1: bfloat16x8_t, + b: uint8x8_t, + n: i32, + ) -> bfloat16x8_t; + } + _vluti4q_lane_bf16_x2(a.0, a.1, b, LANE) +} +#[doc = "Lookup table read with 4-bit indices"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti4q_lane_f16_x2)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -11936,6 +12114,36 @@ pub unsafe fn vluti4q_lane_p8(a: poly8x16_t, b: uint8x8_t) -> p transmute(vluti4q_lane_s8::(transmute(a), b)) } #[doc = "Lookup table read with 4-bit indices"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti4q_laneq_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[target_feature(enable = "neon,lut,bf16")] +#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(luti4, LANE = 0))] +#[rustc_legacy_const_generics(2)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +pub unsafe fn vluti4q_laneq_bf16_x2( + a: bfloat16x8x2_t, + b: uint8x16_t, +) -> bfloat16x8_t { + static_assert!(LANE >= 0 && LANE <= 3); + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.vluti4q.laneq.x2.v8bf16" + )] + fn _vluti4q_laneq_bf16_x2( + a0: bfloat16x8_t, + a1: bfloat16x8_t, + b: uint8x16_t, + n: i32, + ) -> bfloat16x8_t; + } + _vluti4q_laneq_bf16_x2(a.0, a.1, b, LANE) +} +#[doc = "Lookup table read with 4-bit indices"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vluti4q_laneq_f16_x2)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -21187,6 +21395,54 @@ pub fn vrecpxh_f16(a: f16) -> f16 { unsafe { _vrecpxh_f16(a) } } #[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_f64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +#[cfg(not(target_arch = "arm64ec"))] +#[cfg_attr(test, assert_instr(nop))] +pub fn vreinterpret_bf16_f64(a: float64x1_t) -> bfloat16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_f64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +#[cfg(not(target_arch = "arm64ec"))] +#[cfg_attr(test, assert_instr(nop))] +pub fn vreinterpretq_bf16_f64(a: float64x2_t) -> bfloat16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f64_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +#[cfg(not(target_arch = "arm64ec"))] +#[cfg_attr(test, assert_instr(nop))] +pub fn vreinterpret_f64_bf16(a: bfloat16x4_t) -> float64x1_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f64_bf16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +#[cfg(not(target_arch = "arm64ec"))] +#[cfg_attr(test, assert_instr(nop))] +pub fn vreinterpretq_f64_bf16(a: bfloat16x8_t) -> float64x2_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f64_f16)"] #[inline] #[target_feature(enable = "neon")] diff --git a/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs index 75393f594ad64..1ee7d6563cafb 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs @@ -11845,7 +11845,7 @@ pub fn svlastb_u64(pg: svbool_t, op: svuint64_t) -> u64 { #[cfg_attr(test, assert_instr(ld1w))] pub unsafe fn svld1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4f32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4f32.p0")] fn _svld1_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svld1_f32(pg.sve_into(), base) @@ -11861,7 +11861,7 @@ pub unsafe fn svld1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ld1d))] pub unsafe fn svld1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2f64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2f64.p0")] fn _svld1_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svld1_f64(pg.sve_into(), base) @@ -11877,7 +11877,7 @@ pub unsafe fn svld1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ld1b))] pub unsafe fn svld1_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv16i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv16i8.p0")] fn _svld1_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svld1_s8(pg, base) @@ -11893,7 +11893,7 @@ pub unsafe fn svld1_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ld1h))] pub unsafe fn svld1_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i16.p0")] fn _svld1_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svld1_s16(pg.sve_into(), base) @@ -11909,7 +11909,7 @@ pub unsafe fn svld1_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ld1w))] pub unsafe fn svld1_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i32.p0")] fn _svld1_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svld1_s32(pg.sve_into(), base) @@ -11925,7 +11925,7 @@ pub unsafe fn svld1_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ld1d))] pub unsafe fn svld1_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i64.p0")] fn _svld1_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svld1_s64(pg.sve_into(), base) @@ -11995,7 +11995,7 @@ pub unsafe fn svld1_gather_s32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4f32.p0" )] fn _svld1_gather_s32index_f32( pg: svbool4_t, @@ -12022,7 +12022,7 @@ pub unsafe fn svld1_gather_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i32.p0" )] fn _svld1_gather_s32index_s32( pg: svbool4_t, @@ -12065,7 +12065,7 @@ pub unsafe fn svld1_gather_s64index_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2f64" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2f64.p0" )] fn _svld1_gather_s64index_f64( pg: svbool2_t, @@ -12092,7 +12092,7 @@ pub unsafe fn svld1_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i64.p0" )] fn _svld1_gather_s64index_s64( pg: svbool2_t, @@ -12135,7 +12135,7 @@ pub unsafe fn svld1_gather_u32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4f32.p0" )] fn _svld1_gather_u32index_f32( pg: svbool4_t, @@ -12162,7 +12162,7 @@ pub unsafe fn svld1_gather_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i32.p0" )] fn _svld1_gather_u32index_s32( pg: svbool4_t, @@ -12253,7 +12253,7 @@ pub unsafe fn svld1_gather_s32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4f32" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4f32.p0" )] fn _svld1_gather_s32offset_f32( pg: svbool4_t, @@ -12280,7 +12280,7 @@ pub unsafe fn svld1_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i32" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i32.p0" )] fn _svld1_gather_s32offset_s32( pg: svbool4_t, @@ -12323,7 +12323,7 @@ pub unsafe fn svld1_gather_s64offset_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2f64" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2f64.p0" )] fn _svld1_gather_s64offset_f64( pg: svbool2_t, @@ -12350,7 +12350,7 @@ pub unsafe fn svld1_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i64" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i64.p0" )] fn _svld1_gather_s64offset_s64( pg: svbool2_t, @@ -12393,7 +12393,7 @@ pub unsafe fn svld1_gather_u32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4f32" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4f32.p0" )] fn _svld1_gather_u32offset_f32( pg: svbool4_t, @@ -12420,7 +12420,7 @@ pub unsafe fn svld1_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i32" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i32.p0" )] fn _svld1_gather_u32offset_s32( pg: svbool4_t, @@ -12951,7 +12951,10 @@ pub unsafe fn svld1_vnum_u64(pg: svbool_t, base: *const u64, vnum: i64) -> svuin #[cfg_attr(test, assert_instr(ld1row))] pub unsafe fn svld1ro_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv4f32.p0" + )] fn _svld1ro_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svld1ro_f32(pg.sve_into(), base) @@ -12967,7 +12970,10 @@ pub unsafe fn svld1ro_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ld1rod))] pub unsafe fn svld1ro_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv2f64.p0" + )] fn _svld1ro_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svld1ro_f64(pg.sve_into(), base) @@ -12983,7 +12989,10 @@ pub unsafe fn svld1ro_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ld1rob))] pub unsafe fn svld1ro_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv16i8.p0" + )] fn _svld1ro_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svld1ro_s8(pg, base) @@ -12999,7 +13008,10 @@ pub unsafe fn svld1ro_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ld1roh))] pub unsafe fn svld1ro_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv8i16.p0" + )] fn _svld1ro_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svld1ro_s16(pg.sve_into(), base) @@ -13015,7 +13027,10 @@ pub unsafe fn svld1ro_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ld1row))] pub unsafe fn svld1ro_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv4i32.p0" + )] fn _svld1ro_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svld1ro_s32(pg.sve_into(), base) @@ -13031,7 +13046,10 @@ pub unsafe fn svld1ro_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ld1rod))] pub unsafe fn svld1ro_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1ro.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1ro.nxv2i64.p0" + )] fn _svld1ro_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svld1ro_s64(pg.sve_into(), base) @@ -13095,7 +13113,10 @@ pub unsafe fn svld1ro_u64(pg: svbool_t, base: *const u64) -> svuint64_t { #[cfg_attr(test, assert_instr(ld1rqw))] pub unsafe fn svld1rq_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv4f32.p0" + )] fn _svld1rq_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svld1rq_f32(pg.sve_into(), base) @@ -13111,7 +13132,10 @@ pub unsafe fn svld1rq_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ld1rqd))] pub unsafe fn svld1rq_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv2f64.p0" + )] fn _svld1rq_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svld1rq_f64(pg.sve_into(), base) @@ -13127,7 +13151,10 @@ pub unsafe fn svld1rq_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ld1rqb))] pub unsafe fn svld1rq_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv16i8.p0" + )] fn _svld1rq_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svld1rq_s8(pg, base) @@ -13143,7 +13170,10 @@ pub unsafe fn svld1rq_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ld1rqh))] pub unsafe fn svld1rq_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv8i16.p0" + )] fn _svld1rq_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svld1rq_s16(pg.sve_into(), base) @@ -13159,7 +13189,10 @@ pub unsafe fn svld1rq_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ld1rqw))] pub unsafe fn svld1rq_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv4i32.p0" + )] fn _svld1rq_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svld1rq_s32(pg.sve_into(), base) @@ -13175,7 +13208,10 @@ pub unsafe fn svld1rq_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ld1rqd))] pub unsafe fn svld1rq_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1rq.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ld1rq.nxv2i64.p0" + )] fn _svld1rq_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svld1rq_s64(pg.sve_into(), base) @@ -13245,7 +13281,7 @@ pub unsafe fn svld1sb_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i8.p0" )] fn _svld1sb_gather_s32offset_s32( pg: svbool4_t, @@ -13272,7 +13308,7 @@ pub unsafe fn svld1sh_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i16.p0" )] fn _svld1sh_gather_s32offset_s32( pg: svbool4_t, @@ -13331,7 +13367,7 @@ pub unsafe fn svld1sb_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i8.p0" )] fn _svld1sb_gather_s64offset_s64( pg: svbool2_t, @@ -13358,7 +13394,7 @@ pub unsafe fn svld1sh_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i16.p0" )] fn _svld1sh_gather_s64offset_s64( pg: svbool2_t, @@ -13385,7 +13421,7 @@ pub unsafe fn svld1sw_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i32.p0" )] fn _svld1sw_gather_s64offset_s64( pg: svbool2_t, @@ -13460,7 +13496,7 @@ pub unsafe fn svld1sb_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i8.p0" )] fn _svld1sb_gather_u32offset_s32( pg: svbool4_t, @@ -13491,7 +13527,7 @@ pub unsafe fn svld1sh_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i16.p0" )] fn _svld1sh_gather_u32offset_s32( pg: svbool4_t, @@ -14019,7 +14055,7 @@ pub unsafe fn svld1sw_gather_u64base_u64(pg: svbool_t, bases: svuint64_t) -> svu #[cfg_attr(test, assert_instr(ld1sb))] pub unsafe fn svld1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i8.p0")] fn _svld1sb_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast(_svld1sb_s16(pg.sve_into(), base)) @@ -14035,7 +14071,7 @@ pub unsafe fn svld1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { #[cfg_attr(test, assert_instr(ld1sb))] pub unsafe fn svld1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i8.p0")] fn _svld1sb_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast(_svld1sb_s32(pg.sve_into(), base)) @@ -14051,7 +14087,7 @@ pub unsafe fn svld1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { #[cfg_attr(test, assert_instr(ld1sh))] pub unsafe fn svld1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i16.p0")] fn _svld1sh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast(_svld1sh_s32(pg.sve_into(), base)) @@ -14067,7 +14103,7 @@ pub unsafe fn svld1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { #[cfg_attr(test, assert_instr(ld1sb))] pub unsafe fn svld1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i8.p0")] fn _svld1sb_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast(_svld1sb_s64(pg.sve_into(), base)) @@ -14083,7 +14119,7 @@ pub unsafe fn svld1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { #[cfg_attr(test, assert_instr(ld1sh))] pub unsafe fn svld1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i16.p0")] fn _svld1sh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast(_svld1sh_s64(pg.sve_into(), base)) @@ -14099,7 +14135,7 @@ pub unsafe fn svld1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { #[cfg_attr(test, assert_instr(ld1sw))] pub unsafe fn svld1sw_s64(pg: svbool_t, base: *const i32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i32.p0")] fn _svld1sw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast(_svld1sw_s64(pg.sve_into(), base)) @@ -14337,7 +14373,7 @@ pub unsafe fn svld1sh_gather_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i16.p0" )] fn _svld1sh_gather_s32index_s32( pg: svbool4_t, @@ -14380,7 +14416,7 @@ pub unsafe fn svld1sh_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i16.p0" )] fn _svld1sh_gather_s64index_s64( pg: svbool2_t, @@ -14407,7 +14443,7 @@ pub unsafe fn svld1sw_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i32.p0" )] fn _svld1sw_gather_s64index_s64( pg: svbool2_t, @@ -14466,7 +14502,7 @@ pub unsafe fn svld1sh_gather_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i16.p0" )] fn _svld1sh_gather_u32index_s32( pg: svbool4_t, @@ -14711,7 +14747,7 @@ pub unsafe fn svld1ub_gather_s32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i8.p0" )] fn _svld1ub_gather_s32offset_u32( pg: svbool4_t, @@ -14740,7 +14776,7 @@ pub unsafe fn svld1uh_gather_s32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.nxv4i16.p0" )] fn _svld1uh_gather_s32offset_u32( pg: svbool4_t, @@ -14817,7 +14853,7 @@ pub unsafe fn svld1ub_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i8.p0" )] fn _svld1ub_gather_s64offset_u64( pg: svbool2_t, @@ -14846,7 +14882,7 @@ pub unsafe fn svld1uh_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i16.p0" )] fn _svld1uh_gather_s64offset_u64( pg: svbool2_t, @@ -14875,7 +14911,7 @@ pub unsafe fn svld1uw_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ld1.gather.nxv2i32.p0" )] fn _svld1uw_gather_s64offset_u64( pg: svbool2_t, @@ -14936,7 +14972,7 @@ pub unsafe fn svld1ub_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i8.p0" )] fn _svld1ub_gather_u32offset_u32( pg: svbool4_t, @@ -14966,7 +15002,7 @@ pub unsafe fn svld1uh_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.nxv4i16.p0" )] fn _svld1uh_gather_u32offset_u32( pg: svbool4_t, @@ -15451,7 +15487,7 @@ pub unsafe fn svld1uw_gather_u64base_u64(pg: svbool_t, bases: svuint64_t) -> svu #[cfg_attr(test, assert_instr(ld1b))] pub unsafe fn svld1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv8i8.p0")] fn _svld1ub_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast::( @@ -15469,7 +15505,7 @@ pub unsafe fn svld1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { #[cfg_attr(test, assert_instr(ld1b))] pub unsafe fn svld1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i8.p0")] fn _svld1ub_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast::( @@ -15487,7 +15523,7 @@ pub unsafe fn svld1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { #[cfg_attr(test, assert_instr(ld1h))] pub unsafe fn svld1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv4i16.p0")] fn _svld1uh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast::( @@ -15505,7 +15541,7 @@ pub unsafe fn svld1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { #[cfg_attr(test, assert_instr(ld1b))] pub unsafe fn svld1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i8.p0")] fn _svld1ub_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast::( @@ -15523,7 +15559,7 @@ pub unsafe fn svld1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { #[cfg_attr(test, assert_instr(ld1h))] pub unsafe fn svld1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i16.p0")] fn _svld1uh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast::( @@ -15541,7 +15577,7 @@ pub unsafe fn svld1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { #[cfg_attr(test, assert_instr(ld1w))] pub unsafe fn svld1uw_s64(pg: svbool_t, base: *const u32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ld1.nxv2i32.p0")] fn _svld1uw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast::( @@ -15797,7 +15833,7 @@ pub unsafe fn svld1uh_gather_s32index_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.sxtw.index.nxv4i16.p0" )] fn _svld1uh_gather_s32index_u32( pg: svbool4_t, @@ -15858,7 +15894,7 @@ pub unsafe fn svld1uh_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i16.p0" )] fn _svld1uh_gather_s64index_u64( pg: svbool2_t, @@ -15887,7 +15923,7 @@ pub unsafe fn svld1uw_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ld1.gather.index.nxv2i32.p0" )] fn _svld1uw_gather_s64index_u64( pg: svbool2_t, @@ -15932,7 +15968,7 @@ pub unsafe fn svld1uh_gather_u32index_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ld1.gather.uxtw.index.nxv4i16.p0" )] fn _svld1uh_gather_u32index_u32( pg: svbool4_t, @@ -16124,7 +16160,7 @@ pub unsafe fn svld2_f32(pg: svbool_t, base: *const f32) -> svfloat32x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv4f32" + link_name = "llvm.aarch64.sve.ld2.sret.nxv4f32.p0" )] fn _svld2_f32(pg: svbool4_t, base: *const f32) -> svfloat32x2_t; } @@ -16143,7 +16179,7 @@ pub unsafe fn svld2_f64(pg: svbool_t, base: *const f64) -> svfloat64x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv2f64" + link_name = "llvm.aarch64.sve.ld2.sret.nxv2f64.p0" )] fn _svld2_f64(pg: svbool2_t, base: *const f64) -> svfloat64x2_t; } @@ -16162,7 +16198,7 @@ pub unsafe fn svld2_s8(pg: svbool_t, base: *const i8) -> svint8x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv16i8" + link_name = "llvm.aarch64.sve.ld2.sret.nxv16i8.p0" )] fn _svld2_s8(pg: svbool_t, base: *const i8) -> svint8x2_t; } @@ -16181,7 +16217,7 @@ pub unsafe fn svld2_s16(pg: svbool_t, base: *const i16) -> svint16x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv8i16" + link_name = "llvm.aarch64.sve.ld2.sret.nxv8i16.p0" )] fn _svld2_s16(pg: svbool8_t, base: *const i16) -> svint16x2_t; } @@ -16200,7 +16236,7 @@ pub unsafe fn svld2_s32(pg: svbool_t, base: *const i32) -> svint32x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv4i32" + link_name = "llvm.aarch64.sve.ld2.sret.nxv4i32.p0" )] fn _svld2_s32(pg: svbool4_t, base: *const i32) -> svint32x2_t; } @@ -16219,7 +16255,7 @@ pub unsafe fn svld2_s64(pg: svbool_t, base: *const i64) -> svint64x2_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld2.sret.nxv2i64" + link_name = "llvm.aarch64.sve.ld2.sret.nxv2i64.p0" )] fn _svld2_s64(pg: svbool2_t, base: *const i64) -> svint64x2_t; } @@ -16406,7 +16442,7 @@ pub unsafe fn svld3_f32(pg: svbool_t, base: *const f32) -> svfloat32x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv4f32" + link_name = "llvm.aarch64.sve.ld3.sret.nxv4f32.p0" )] fn _svld3_f32(pg: svbool4_t, base: *const f32) -> svfloat32x3_t; } @@ -16425,7 +16461,7 @@ pub unsafe fn svld3_f64(pg: svbool_t, base: *const f64) -> svfloat64x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv2f64" + link_name = "llvm.aarch64.sve.ld3.sret.nxv2f64.p0" )] fn _svld3_f64(pg: svbool2_t, base: *const f64) -> svfloat64x3_t; } @@ -16444,7 +16480,7 @@ pub unsafe fn svld3_s8(pg: svbool_t, base: *const i8) -> svint8x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv16i8" + link_name = "llvm.aarch64.sve.ld3.sret.nxv16i8.p0" )] fn _svld3_s8(pg: svbool_t, base: *const i8) -> svint8x3_t; } @@ -16463,7 +16499,7 @@ pub unsafe fn svld3_s16(pg: svbool_t, base: *const i16) -> svint16x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv8i16" + link_name = "llvm.aarch64.sve.ld3.sret.nxv8i16.p0" )] fn _svld3_s16(pg: svbool8_t, base: *const i16) -> svint16x3_t; } @@ -16482,7 +16518,7 @@ pub unsafe fn svld3_s32(pg: svbool_t, base: *const i32) -> svint32x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv4i32" + link_name = "llvm.aarch64.sve.ld3.sret.nxv4i32.p0" )] fn _svld3_s32(pg: svbool4_t, base: *const i32) -> svint32x3_t; } @@ -16501,7 +16537,7 @@ pub unsafe fn svld3_s64(pg: svbool_t, base: *const i64) -> svint64x3_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld3.sret.nxv2i64" + link_name = "llvm.aarch64.sve.ld3.sret.nxv2i64.p0" )] fn _svld3_s64(pg: svbool2_t, base: *const i64) -> svint64x3_t; } @@ -16688,7 +16724,7 @@ pub unsafe fn svld4_f32(pg: svbool_t, base: *const f32) -> svfloat32x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv4f32" + link_name = "llvm.aarch64.sve.ld4.sret.nxv4f32.p0" )] fn _svld4_f32(pg: svbool4_t, base: *const f32) -> svfloat32x4_t; } @@ -16707,7 +16743,7 @@ pub unsafe fn svld4_f64(pg: svbool_t, base: *const f64) -> svfloat64x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv2f64" + link_name = "llvm.aarch64.sve.ld4.sret.nxv2f64.p0" )] fn _svld4_f64(pg: svbool2_t, base: *const f64) -> svfloat64x4_t; } @@ -16726,7 +16762,7 @@ pub unsafe fn svld4_s8(pg: svbool_t, base: *const i8) -> svint8x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv16i8" + link_name = "llvm.aarch64.sve.ld4.sret.nxv16i8.p0" )] fn _svld4_s8(pg: svbool_t, base: *const i8) -> svint8x4_t; } @@ -16745,7 +16781,7 @@ pub unsafe fn svld4_s16(pg: svbool_t, base: *const i16) -> svint16x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv8i16" + link_name = "llvm.aarch64.sve.ld4.sret.nxv8i16.p0" )] fn _svld4_s16(pg: svbool8_t, base: *const i16) -> svint16x4_t; } @@ -16764,7 +16800,7 @@ pub unsafe fn svld4_s32(pg: svbool_t, base: *const i32) -> svint32x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv4i32" + link_name = "llvm.aarch64.sve.ld4.sret.nxv4i32.p0" )] fn _svld4_s32(pg: svbool4_t, base: *const i32) -> svint32x4_t; } @@ -16783,7 +16819,7 @@ pub unsafe fn svld4_s64(pg: svbool_t, base: *const i64) -> svint64x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ld4.sret.nxv2i64" + link_name = "llvm.aarch64.sve.ld4.sret.nxv2i64.p0" )] fn _svld4_s64(pg: svbool2_t, base: *const i64) -> svint64x4_t; } @@ -16969,7 +17005,10 @@ pub unsafe fn svld4_vnum_u64(pg: svbool_t, base: *const u64, vnum: i64) -> svuin #[cfg_attr(test, assert_instr(ldff1w))] pub unsafe fn svldff1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4f32.p0" + )] fn _svldff1_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svldff1_f32(pg.sve_into(), base) @@ -16986,7 +17025,10 @@ pub unsafe fn svldff1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ldff1d))] pub unsafe fn svldff1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2f64.p0" + )] fn _svldff1_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svldff1_f64(pg.sve_into(), base) @@ -17003,7 +17045,10 @@ pub unsafe fn svldff1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ldff1b))] pub unsafe fn svldff1_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv16i8.p0" + )] fn _svldff1_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svldff1_s8(pg, base) @@ -17020,7 +17065,10 @@ pub unsafe fn svldff1_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ldff1h))] pub unsafe fn svldff1_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv8i16.p0" + )] fn _svldff1_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svldff1_s16(pg.sve_into(), base) @@ -17037,7 +17085,10 @@ pub unsafe fn svldff1_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ldff1w))] pub unsafe fn svldff1_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4i32.p0" + )] fn _svldff1_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svldff1_s32(pg.sve_into(), base) @@ -17054,7 +17105,10 @@ pub unsafe fn svldff1_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ldff1d))] pub unsafe fn svldff1_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i64.p0" + )] fn _svldff1_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svldff1_s64(pg.sve_into(), base) @@ -17129,7 +17183,7 @@ pub unsafe fn svldff1_gather_s32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4f32.p0" )] fn _svldff1_gather_s32index_f32( pg: svbool4_t, @@ -17157,7 +17211,7 @@ pub unsafe fn svldff1_gather_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i32.p0" )] fn _svldff1_gather_s32index_s32( pg: svbool4_t, @@ -17202,7 +17256,7 @@ pub unsafe fn svldff1_gather_s64index_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2f64" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2f64.p0" )] fn _svldff1_gather_s64index_f64( pg: svbool2_t, @@ -17230,7 +17284,7 @@ pub unsafe fn svldff1_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i64.p0" )] fn _svldff1_gather_s64index_s64( pg: svbool2_t, @@ -17275,7 +17329,7 @@ pub unsafe fn svldff1_gather_u32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4f32.p0" )] fn _svldff1_gather_u32index_f32( pg: svbool4_t, @@ -17303,7 +17357,7 @@ pub unsafe fn svldff1_gather_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i32.p0" )] fn _svldff1_gather_u32index_s32( pg: svbool4_t, @@ -17399,7 +17453,7 @@ pub unsafe fn svldff1_gather_s32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4f32" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4f32.p0" )] fn _svldff1_gather_s32offset_f32( pg: svbool4_t, @@ -17427,7 +17481,7 @@ pub unsafe fn svldff1_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i32" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i32.p0" )] fn _svldff1_gather_s32offset_s32( pg: svbool4_t, @@ -17472,7 +17526,7 @@ pub unsafe fn svldff1_gather_s64offset_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2f64" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2f64.p0" )] fn _svldff1_gather_s64offset_f64( pg: svbool2_t, @@ -17500,7 +17554,7 @@ pub unsafe fn svldff1_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i64" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i64.p0" )] fn _svldff1_gather_s64offset_s64( pg: svbool2_t, @@ -17545,7 +17599,7 @@ pub unsafe fn svldff1_gather_u32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4f32" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4f32.p0" )] fn _svldff1_gather_u32offset_f32( pg: svbool4_t, @@ -17573,7 +17627,7 @@ pub unsafe fn svldff1_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i32" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i32.p0" )] fn _svldff1_gather_u32offset_s32( pg: svbool4_t, @@ -18143,7 +18197,7 @@ pub unsafe fn svldff1sb_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i8.p0" )] fn _svldff1sb_gather_s32offset_s32( pg: svbool4_t, @@ -18175,7 +18229,7 @@ pub unsafe fn svldff1sh_gather_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i16.p0" )] fn _svldff1sh_gather_s32offset_s32( pg: svbool4_t, @@ -18241,7 +18295,7 @@ pub unsafe fn svldff1sb_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i8.p0" )] fn _svldff1sb_gather_s64offset_s64( pg: svbool2_t, @@ -18273,7 +18327,7 @@ pub unsafe fn svldff1sh_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i16.p0" )] fn _svldff1sh_gather_s64offset_s64( pg: svbool2_t, @@ -18305,7 +18359,7 @@ pub unsafe fn svldff1sw_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i32.p0" )] fn _svldff1sw_gather_s64offset_s64( pg: svbool2_t, @@ -18388,7 +18442,7 @@ pub unsafe fn svldff1sb_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i8.p0" )] fn _svldff1sb_gather_u32offset_s32( pg: svbool4_t, @@ -18420,7 +18474,7 @@ pub unsafe fn svldff1sh_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i16.p0" )] fn _svldff1sh_gather_u32offset_s32( pg: svbool4_t, @@ -18977,7 +19031,10 @@ pub unsafe fn svldff1sw_gather_u64base_u64(pg: svbool_t, bases: svuint64_t) -> s #[cfg_attr(test, assert_instr(ldff1sb))] pub unsafe fn svldff1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv8i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv8i8.p0" + )] fn _svldff1sb_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast(_svldff1sb_s16(pg.sve_into(), base)) @@ -18994,7 +19051,10 @@ pub unsafe fn svldff1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { #[cfg_attr(test, assert_instr(ldff1sb))] pub unsafe fn svldff1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4i8.p0" + )] fn _svldff1sb_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast(_svldff1sb_s32(pg.sve_into(), base)) @@ -19011,7 +19071,10 @@ pub unsafe fn svldff1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { #[cfg_attr(test, assert_instr(ldff1sh))] pub unsafe fn svldff1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4i16.p0" + )] fn _svldff1sh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast(_svldff1sh_s32(pg.sve_into(), base)) @@ -19028,7 +19091,10 @@ pub unsafe fn svldff1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { #[cfg_attr(test, assert_instr(ldff1sb))] pub unsafe fn svldff1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i8.p0" + )] fn _svldff1sb_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast(_svldff1sb_s64(pg.sve_into(), base)) @@ -19045,7 +19111,10 @@ pub unsafe fn svldff1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { #[cfg_attr(test, assert_instr(ldff1sh))] pub unsafe fn svldff1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i16.p0" + )] fn _svldff1sh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast(_svldff1sh_s64(pg.sve_into(), base)) @@ -19062,7 +19131,10 @@ pub unsafe fn svldff1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { #[cfg_attr(test, assert_instr(ldff1sw))] pub unsafe fn svldff1sw_s64(pg: svbool_t, base: *const i32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i32.p0" + )] fn _svldff1sw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast(_svldff1sw_s64(pg.sve_into(), base)) @@ -19319,7 +19391,7 @@ pub unsafe fn svldff1sh_gather_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i16.p0" )] fn _svldff1sh_gather_s32index_s32( pg: svbool4_t, @@ -19364,7 +19436,7 @@ pub unsafe fn svldff1sh_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i16.p0" )] fn _svldff1sh_gather_s64index_s64( pg: svbool2_t, @@ -19392,7 +19464,7 @@ pub unsafe fn svldff1sw_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i32.p0" )] fn _svldff1sw_gather_s64index_s64( pg: svbool2_t, @@ -19454,7 +19526,7 @@ pub unsafe fn svldff1sh_gather_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i16.p0" )] fn _svldff1sh_gather_u32index_s32( pg: svbool4_t, @@ -19713,7 +19785,7 @@ pub unsafe fn svldff1ub_gather_s32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i8.p0" )] fn _svldff1ub_gather_s32offset_u32( pg: svbool4_t, @@ -19743,7 +19815,7 @@ pub unsafe fn svldff1uh_gather_s32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.nxv4i16.p0" )] fn _svldff1uh_gather_s32offset_u32( pg: svbool4_t, @@ -19824,7 +19896,7 @@ pub unsafe fn svldff1ub_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i8.p0" )] fn _svldff1ub_gather_s64offset_u64( pg: svbool2_t, @@ -19854,7 +19926,7 @@ pub unsafe fn svldff1uh_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i16.p0" )] fn _svldff1uh_gather_s64offset_u64( pg: svbool2_t, @@ -19884,7 +19956,7 @@ pub unsafe fn svldff1uw_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ldff1.gather.nxv2i32.p0" )] fn _svldff1uw_gather_s64offset_u64( pg: svbool2_t, @@ -19948,7 +20020,7 @@ pub unsafe fn svldff1ub_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i8.p0" )] fn _svldff1ub_gather_u32offset_u32( pg: svbool4_t, @@ -19979,7 +20051,7 @@ pub unsafe fn svldff1uh_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.nxv4i16.p0" )] fn _svldff1uh_gather_u32offset_u32( pg: svbool4_t, @@ -20496,7 +20568,10 @@ pub unsafe fn svldff1uw_gather_u64base_u64(pg: svbool_t, bases: svuint64_t) -> s #[cfg_attr(test, assert_instr(ldff1b))] pub unsafe fn svldff1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv8i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv8i8.p0" + )] fn _svldff1ub_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast::( @@ -20515,7 +20590,10 @@ pub unsafe fn svldff1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { #[cfg_attr(test, assert_instr(ldff1b))] pub unsafe fn svldff1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4i8.p0" + )] fn _svldff1ub_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast::( @@ -20534,7 +20612,10 @@ pub unsafe fn svldff1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { #[cfg_attr(test, assert_instr(ldff1h))] pub unsafe fn svldff1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv4i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv4i16.p0" + )] fn _svldff1uh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast::( @@ -20553,7 +20634,10 @@ pub unsafe fn svldff1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { #[cfg_attr(test, assert_instr(ldff1b))] pub unsafe fn svldff1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i8.p0" + )] fn _svldff1ub_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast::( @@ -20572,7 +20656,10 @@ pub unsafe fn svldff1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { #[cfg_attr(test, assert_instr(ldff1h))] pub unsafe fn svldff1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i16.p0" + )] fn _svldff1uh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast::( @@ -20591,7 +20678,10 @@ pub unsafe fn svldff1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { #[cfg_attr(test, assert_instr(ldff1w))] pub unsafe fn svldff1uw_s64(pg: svbool_t, base: *const u32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldff1.nxv2i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldff1.nxv2i32.p0" + )] fn _svldff1uw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast::( @@ -20867,7 +20957,7 @@ pub unsafe fn svldff1uh_gather_s32index_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.sxtw.index.nxv4i16.p0" )] fn _svldff1uh_gather_s32index_u32( pg: svbool4_t, @@ -20931,7 +21021,7 @@ pub unsafe fn svldff1uh_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i16.p0" )] fn _svldff1uh_gather_s64index_u64( pg: svbool2_t, @@ -20961,7 +21051,7 @@ pub unsafe fn svldff1uw_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ldff1.gather.index.nxv2i32.p0" )] fn _svldff1uw_gather_s64index_u64( pg: svbool2_t, @@ -21008,7 +21098,7 @@ pub unsafe fn svldff1uh_gather_u32index_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.ldff1.gather.uxtw.index.nxv4i16.p0" )] fn _svldff1uh_gather_u32index_u32( pg: svbool4_t, @@ -21209,7 +21299,10 @@ pub unsafe fn svldff1uw_gather_u64base_index_u64( #[cfg_attr(test, assert_instr(ldnf1w))] pub unsafe fn svldnf1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4f32.p0" + )] fn _svldnf1_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svldnf1_f32(pg.sve_into(), base) @@ -21226,7 +21319,10 @@ pub unsafe fn svldnf1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ldnf1d))] pub unsafe fn svldnf1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2f64.p0" + )] fn _svldnf1_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svldnf1_f64(pg.sve_into(), base) @@ -21243,7 +21339,10 @@ pub unsafe fn svldnf1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ldnf1b))] pub unsafe fn svldnf1_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv16i8.p0" + )] fn _svldnf1_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svldnf1_s8(pg, base) @@ -21260,7 +21359,10 @@ pub unsafe fn svldnf1_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ldnf1h))] pub unsafe fn svldnf1_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv8i16.p0" + )] fn _svldnf1_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svldnf1_s16(pg.sve_into(), base) @@ -21277,7 +21379,10 @@ pub unsafe fn svldnf1_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ldnf1w))] pub unsafe fn svldnf1_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4i32.p0" + )] fn _svldnf1_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svldnf1_s32(pg.sve_into(), base) @@ -21294,7 +21399,10 @@ pub unsafe fn svldnf1_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ldnf1d))] pub unsafe fn svldnf1_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i64.p0" + )] fn _svldnf1_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svldnf1_s64(pg.sve_into(), base) @@ -21493,7 +21601,10 @@ pub unsafe fn svldnf1_vnum_u64(pg: svbool_t, base: *const u64, vnum: i64) -> svu #[cfg_attr(test, assert_instr(ldnf1sb))] pub unsafe fn svldnf1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv8i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv8i8.p0" + )] fn _svldnf1sb_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast(_svldnf1sb_s16(pg.sve_into(), base)) @@ -21510,7 +21621,10 @@ pub unsafe fn svldnf1sb_s16(pg: svbool_t, base: *const i8) -> svint16_t { #[cfg_attr(test, assert_instr(ldnf1sb))] pub unsafe fn svldnf1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4i8.p0" + )] fn _svldnf1sb_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast(_svldnf1sb_s32(pg.sve_into(), base)) @@ -21527,7 +21641,10 @@ pub unsafe fn svldnf1sb_s32(pg: svbool_t, base: *const i8) -> svint32_t { #[cfg_attr(test, assert_instr(ldnf1sh))] pub unsafe fn svldnf1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4i16.p0" + )] fn _svldnf1sh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast(_svldnf1sh_s32(pg.sve_into(), base)) @@ -21544,7 +21661,10 @@ pub unsafe fn svldnf1sh_s32(pg: svbool_t, base: *const i16) -> svint32_t { #[cfg_attr(test, assert_instr(ldnf1sb))] pub unsafe fn svldnf1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i8.p0" + )] fn _svldnf1sb_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast(_svldnf1sb_s64(pg.sve_into(), base)) @@ -21561,7 +21681,10 @@ pub unsafe fn svldnf1sb_s64(pg: svbool_t, base: *const i8) -> svint64_t { #[cfg_attr(test, assert_instr(ldnf1sh))] pub unsafe fn svldnf1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i16.p0" + )] fn _svldnf1sh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast(_svldnf1sh_s64(pg.sve_into(), base)) @@ -21578,7 +21701,10 @@ pub unsafe fn svldnf1sh_s64(pg: svbool_t, base: *const i16) -> svint64_t { #[cfg_attr(test, assert_instr(ldnf1sw))] pub unsafe fn svldnf1sw_s64(pg: svbool_t, base: *const i32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i32.p0" + )] fn _svldnf1sw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast(_svldnf1sw_s64(pg.sve_into(), base)) @@ -21829,7 +21955,10 @@ pub unsafe fn svldnf1sw_vnum_u64(pg: svbool_t, base: *const i32, vnum: i64) -> s #[cfg_attr(test, assert_instr(ldnf1b))] pub unsafe fn svldnf1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv8i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv8i8.p0" + )] fn _svldnf1ub_s16(pg: svbool8_t, base: *const i8) -> nxv8i8; } crate::intrinsics::simd::simd_cast::( @@ -21848,7 +21977,10 @@ pub unsafe fn svldnf1ub_s16(pg: svbool_t, base: *const u8) -> svint16_t { #[cfg_attr(test, assert_instr(ldnf1b))] pub unsafe fn svldnf1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4i8.p0" + )] fn _svldnf1ub_s32(pg: svbool4_t, base: *const i8) -> nxv4i8; } crate::intrinsics::simd::simd_cast::( @@ -21867,7 +21999,10 @@ pub unsafe fn svldnf1ub_s32(pg: svbool_t, base: *const u8) -> svint32_t { #[cfg_attr(test, assert_instr(ldnf1h))] pub unsafe fn svldnf1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv4i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv4i16.p0" + )] fn _svldnf1uh_s32(pg: svbool4_t, base: *const i16) -> nxv4i16; } crate::intrinsics::simd::simd_cast::( @@ -21886,7 +22021,10 @@ pub unsafe fn svldnf1uh_s32(pg: svbool_t, base: *const u16) -> svint32_t { #[cfg_attr(test, assert_instr(ldnf1b))] pub unsafe fn svldnf1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i8.p0" + )] fn _svldnf1ub_s64(pg: svbool2_t, base: *const i8) -> nxv2i8; } crate::intrinsics::simd::simd_cast::( @@ -21905,7 +22043,10 @@ pub unsafe fn svldnf1ub_s64(pg: svbool_t, base: *const u8) -> svint64_t { #[cfg_attr(test, assert_instr(ldnf1h))] pub unsafe fn svldnf1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i16.p0" + )] fn _svldnf1uh_s64(pg: svbool2_t, base: *const i16) -> nxv2i16; } crate::intrinsics::simd::simd_cast::( @@ -21924,7 +22065,10 @@ pub unsafe fn svldnf1uh_s64(pg: svbool_t, base: *const u16) -> svint64_t { #[cfg_attr(test, assert_instr(ldnf1w))] pub unsafe fn svldnf1uw_s64(pg: svbool_t, base: *const u32) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnf1.nxv2i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnf1.nxv2i32.p0" + )] fn _svldnf1uw_s64(pg: svbool2_t, base: *const i32) -> nxv2i32; } crate::intrinsics::simd::simd_cast::( @@ -22177,7 +22321,10 @@ pub unsafe fn svldnf1uw_vnum_u64(pg: svbool_t, base: *const u32, vnum: i64) -> s #[cfg_attr(test, assert_instr(ldnt1w))] pub unsafe fn svldnt1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv4f32.p0" + )] fn _svldnt1_f32(pg: svbool4_t, base: *const f32) -> svfloat32_t; } _svldnt1_f32(pg.sve_into(), base) @@ -22194,7 +22341,10 @@ pub unsafe fn svldnt1_f32(pg: svbool_t, base: *const f32) -> svfloat32_t { #[cfg_attr(test, assert_instr(ldnt1d))] pub unsafe fn svldnt1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv2f64.p0" + )] fn _svldnt1_f64(pg: svbool2_t, base: *const f64) -> svfloat64_t; } _svldnt1_f64(pg.sve_into(), base) @@ -22211,7 +22361,10 @@ pub unsafe fn svldnt1_f64(pg: svbool_t, base: *const f64) -> svfloat64_t { #[cfg_attr(test, assert_instr(ldnt1b))] pub unsafe fn svldnt1_s8(pg: svbool_t, base: *const i8) -> svint8_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv16i8.p0" + )] fn _svldnt1_s8(pg: svbool_t, base: *const i8) -> svint8_t; } _svldnt1_s8(pg, base) @@ -22228,7 +22381,10 @@ pub unsafe fn svldnt1_s8(pg: svbool_t, base: *const i8) -> svint8_t { #[cfg_attr(test, assert_instr(ldnt1h))] pub unsafe fn svldnt1_s16(pg: svbool_t, base: *const i16) -> svint16_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv8i16.p0" + )] fn _svldnt1_s16(pg: svbool8_t, base: *const i16) -> svint16_t; } _svldnt1_s16(pg.sve_into(), base) @@ -22245,7 +22401,10 @@ pub unsafe fn svldnt1_s16(pg: svbool_t, base: *const i16) -> svint16_t { #[cfg_attr(test, assert_instr(ldnt1w))] pub unsafe fn svldnt1_s32(pg: svbool_t, base: *const i32) -> svint32_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv4i32.p0" + )] fn _svldnt1_s32(pg: svbool4_t, base: *const i32) -> svint32_t; } _svldnt1_s32(pg.sve_into(), base) @@ -22262,7 +22421,10 @@ pub unsafe fn svldnt1_s32(pg: svbool_t, base: *const i32) -> svint32_t { #[cfg_attr(test, assert_instr(ldnt1d))] pub unsafe fn svldnt1_s64(pg: svbool_t, base: *const i64) -> svint64_t { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.ldnt1.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.ldnt1.nxv2i64.p0" + )] fn _svldnt1_s64(pg: svbool2_t, base: *const i64) -> svint64_t; } _svldnt1_s64(pg.sve_into(), base) @@ -30931,7 +31093,7 @@ pub fn svpnext_b64(pg: svbool_t, op: svbool_t) -> svbool_t { # [cfg_attr (test , assert_instr (prfb , OP = { svprfop :: SV_PLDL1KEEP } , T = i64))] pub unsafe fn svprfb(pg: svbool_t, base: *const T) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv16i1")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv16i1.p0")] fn _svprfb(pg: svbool_t, base: *const crate::ffi::c_void, op: svprfop); } _svprfb(pg, base as *const crate::ffi::c_void, OP) @@ -30946,7 +31108,7 @@ pub unsafe fn svprfb(pg: svbool_t, base: *const T) { # [cfg_attr (test , assert_instr (prfh , OP = { svprfop :: SV_PLDL1KEEP } , T = i64))] pub unsafe fn svprfh(pg: svbool_t, base: *const T) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv8i1")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv8i1.p0")] fn _svprfh(pg: svbool8_t, base: *const crate::ffi::c_void, op: svprfop); } _svprfh(pg.sve_into(), base as *const crate::ffi::c_void, OP) @@ -30961,7 +31123,7 @@ pub unsafe fn svprfh(pg: svbool_t, base: *const T) { # [cfg_attr (test , assert_instr (prfw , OP = { svprfop :: SV_PLDL1KEEP } , T = i64))] pub unsafe fn svprfw(pg: svbool_t, base: *const T) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv4i1")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv4i1.p0")] fn _svprfw(pg: svbool4_t, base: *const crate::ffi::c_void, op: svprfop); } _svprfw(pg.sve_into(), base as *const crate::ffi::c_void, OP) @@ -30976,7 +31138,7 @@ pub unsafe fn svprfw(pg: svbool_t, base: *const T) { # [cfg_attr (test , assert_instr (prfd , OP = { svprfop :: SV_PLDL1KEEP } , T = i64))] pub unsafe fn svprfd(pg: svbool_t, base: *const T) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv2i1")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.prf.nxv2i1.p0")] fn _svprfd(pg: svbool2_t, base: *const crate::ffi::c_void, op: svprfop); } _svprfd(pg.sve_into(), base as *const crate::ffi::c_void, OP) @@ -30997,7 +31159,7 @@ pub unsafe fn svprfb_gather_s32offset( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfb.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfb.gather.sxtw.index.p0.nxv4i32" )] fn _svprfb_gather_s32offset( pg: svbool4_t, @@ -31029,7 +31191,7 @@ pub unsafe fn svprfh_gather_s32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfh.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfh.gather.sxtw.index.p0.nxv4i32" )] fn _svprfh_gather_s32index( pg: svbool4_t, @@ -31061,7 +31223,7 @@ pub unsafe fn svprfw_gather_s32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfw.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfw.gather.sxtw.index.p0.nxv4i32" )] fn _svprfw_gather_s32index( pg: svbool4_t, @@ -31093,7 +31255,7 @@ pub unsafe fn svprfd_gather_s32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfd.gather.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfd.gather.sxtw.index.p0.nxv4i32" )] fn _svprfd_gather_s32index( pg: svbool4_t, @@ -31125,7 +31287,7 @@ pub unsafe fn svprfb_gather_s64offset( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfb.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.prfb.gather.index.p0.nxv2i64" )] fn _svprfb_gather_s64offset( pg: svbool2_t, @@ -31157,7 +31319,7 @@ pub unsafe fn svprfh_gather_s64index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfh.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.prfh.gather.index.p0.nxv2i64" )] fn _svprfh_gather_s64index( pg: svbool2_t, @@ -31189,7 +31351,7 @@ pub unsafe fn svprfw_gather_s64index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfw.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.prfw.gather.index.p0.nxv2i64" )] fn _svprfw_gather_s64index( pg: svbool2_t, @@ -31221,7 +31383,7 @@ pub unsafe fn svprfd_gather_s64index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfd.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.prfd.gather.index.p0.nxv2i64" )] fn _svprfd_gather_s64index( pg: svbool2_t, @@ -31253,7 +31415,7 @@ pub unsafe fn svprfb_gather_u32offset( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfb.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfb.gather.uxtw.index.p0.nxv4i32" )] fn _svprfb_gather_u32offset( pg: svbool4_t, @@ -31285,7 +31447,7 @@ pub unsafe fn svprfh_gather_u32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfh.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfh.gather.uxtw.index.p0.nxv4i32" )] fn _svprfh_gather_u32index( pg: svbool4_t, @@ -31317,7 +31479,7 @@ pub unsafe fn svprfw_gather_u32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfw.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfw.gather.uxtw.index.p0.nxv4i32" )] fn _svprfw_gather_u32index( pg: svbool4_t, @@ -31349,7 +31511,7 @@ pub unsafe fn svprfd_gather_u32index( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.prfd.gather.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.prfd.gather.uxtw.index.p0.nxv4i32" )] fn _svprfd_gather_u32index( pg: svbool4_t, @@ -36922,7 +37084,7 @@ pub fn svsqrt_f64_z(pg: svbool_t, op: svfloat64_t) -> svfloat64_t { #[cfg_attr(test, assert_instr(st1w))] pub unsafe fn svst1_f32(pg: svbool_t, base: *mut f32, data: svfloat32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4f32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4f32.p0")] fn _svst1_f32(data: svfloat32_t, pg: svbool4_t, ptr: *mut f32); } _svst1_f32(data, pg.sve_into(), base) @@ -36938,7 +37100,7 @@ pub unsafe fn svst1_f32(pg: svbool_t, base: *mut f32, data: svfloat32_t) { #[cfg_attr(test, assert_instr(st1d))] pub unsafe fn svst1_f64(pg: svbool_t, base: *mut f64, data: svfloat64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2f64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2f64.p0")] fn _svst1_f64(data: svfloat64_t, pg: svbool2_t, ptr: *mut f64); } _svst1_f64(data, pg.sve_into(), base) @@ -36954,7 +37116,7 @@ pub unsafe fn svst1_f64(pg: svbool_t, base: *mut f64, data: svfloat64_t) { #[cfg_attr(test, assert_instr(st1b))] pub unsafe fn svst1_s8(pg: svbool_t, base: *mut i8, data: svint8_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv16i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv16i8.p0")] fn _svst1_s8(data: svint8_t, pg: svbool_t, ptr: *mut i8); } _svst1_s8(data, pg, base) @@ -36970,7 +37132,7 @@ pub unsafe fn svst1_s8(pg: svbool_t, base: *mut i8, data: svint8_t) { #[cfg_attr(test, assert_instr(st1h))] pub unsafe fn svst1_s16(pg: svbool_t, base: *mut i16, data: svint16_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv8i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv8i16.p0")] fn _svst1_s16(data: svint16_t, pg: svbool8_t, ptr: *mut i16); } _svst1_s16(data, pg.sve_into(), base) @@ -36986,7 +37148,7 @@ pub unsafe fn svst1_s16(pg: svbool_t, base: *mut i16, data: svint16_t) { #[cfg_attr(test, assert_instr(st1w))] pub unsafe fn svst1_s32(pg: svbool_t, base: *mut i32, data: svint32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i32.p0")] fn _svst1_s32(data: svint32_t, pg: svbool4_t, ptr: *mut i32); } _svst1_s32(data, pg.sve_into(), base) @@ -37002,7 +37164,7 @@ pub unsafe fn svst1_s32(pg: svbool_t, base: *mut i32, data: svint32_t) { #[cfg_attr(test, assert_instr(st1d))] pub unsafe fn svst1_s64(pg: svbool_t, base: *mut i64, data: svint64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i64.p0")] fn _svst1_s64(data: svint64_t, pg: svbool2_t, ptr: *mut i64); } _svst1_s64(data, pg.sve_into(), base) @@ -37073,7 +37235,7 @@ pub unsafe fn svst1_scatter_s32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4f32.p0" )] fn _svst1_scatter_s32index_f32( data: svfloat32_t, @@ -37102,7 +37264,7 @@ pub unsafe fn svst1_scatter_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4i32.p0" )] fn _svst1_scatter_s32index_s32( data: svint32_t, @@ -37148,7 +37310,7 @@ pub unsafe fn svst1_scatter_s64index_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2f64" + link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2f64.p0" )] fn _svst1_scatter_s64index_f64( data: svfloat64_t, @@ -37177,7 +37339,7 @@ pub unsafe fn svst1_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i64" + link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i64.p0" )] fn _svst1_scatter_s64index_s64( data: svint64_t, @@ -37223,7 +37385,7 @@ pub unsafe fn svst1_scatter_u32index_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4f32" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4f32.p0" )] fn _svst1_scatter_u32index_f32( data: svfloat32_t, @@ -37252,7 +37414,7 @@ pub unsafe fn svst1_scatter_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4i32" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4i32.p0" )] fn _svst1_scatter_u32index_s32( data: svint32_t, @@ -37349,7 +37511,7 @@ pub unsafe fn svst1_scatter_s32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4f32" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4f32.p0" )] fn _svst1_scatter_s32offset_f32( data: svfloat32_t, @@ -37378,7 +37540,7 @@ pub unsafe fn svst1_scatter_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i32" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i32.p0" )] fn _svst1_scatter_s32offset_s32( data: svint32_t, @@ -37424,7 +37586,7 @@ pub unsafe fn svst1_scatter_s64offset_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.nxv2f64" + link_name = "llvm.aarch64.sve.st1.scatter.nxv2f64.p0" )] fn _svst1_scatter_s64offset_f64( data: svfloat64_t, @@ -37453,7 +37615,7 @@ pub unsafe fn svst1_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.nxv2i64" + link_name = "llvm.aarch64.sve.st1.scatter.nxv2i64.p0" )] fn _svst1_scatter_s64offset_s64( data: svint64_t, @@ -37499,7 +37661,7 @@ pub unsafe fn svst1_scatter_u32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4f32" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4f32.p0" )] fn _svst1_scatter_u32offset_f32( data: svfloat32_t, @@ -37528,7 +37690,7 @@ pub unsafe fn svst1_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i32" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i32.p0" )] fn _svst1_scatter_u32offset_s32( data: svint32_t, @@ -38080,7 +38242,7 @@ pub unsafe fn svst1_vnum_u64(pg: svbool_t, base: *mut u64, vnum: i64, data: svui #[cfg_attr(test, assert_instr(st1b))] pub unsafe fn svst1b_s16(pg: svbool_t, base: *mut i8, data: svint16_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv8i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv8i8.p0")] fn _svst1b_s16(data: nxv8i8, pg: svbool8_t, ptr: *mut i8); } _svst1b_s16( @@ -38100,7 +38262,7 @@ pub unsafe fn svst1b_s16(pg: svbool_t, base: *mut i8, data: svint16_t) { #[cfg_attr(test, assert_instr(st1b))] pub unsafe fn svst1b_s32(pg: svbool_t, base: *mut i8, data: svint32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i8.p0")] fn _svst1b_s32(data: nxv4i8, pg: svbool4_t, ptr: *mut i8); } _svst1b_s32( @@ -38120,7 +38282,7 @@ pub unsafe fn svst1b_s32(pg: svbool_t, base: *mut i8, data: svint32_t) { #[cfg_attr(test, assert_instr(st1h))] pub unsafe fn svst1h_s32(pg: svbool_t, base: *mut i16, data: svint32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv4i16.p0")] fn _svst1h_s32(data: nxv4i16, pg: svbool4_t, ptr: *mut i16); } _svst1h_s32( @@ -38140,7 +38302,7 @@ pub unsafe fn svst1h_s32(pg: svbool_t, base: *mut i16, data: svint32_t) { #[cfg_attr(test, assert_instr(st1b))] pub unsafe fn svst1b_s64(pg: svbool_t, base: *mut i8, data: svint64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i8.p0")] fn _svst1b_s64(data: nxv2i8, pg: svbool2_t, ptr: *mut i8); } _svst1b_s64( @@ -38160,7 +38322,7 @@ pub unsafe fn svst1b_s64(pg: svbool_t, base: *mut i8, data: svint64_t) { #[cfg_attr(test, assert_instr(st1h))] pub unsafe fn svst1h_s64(pg: svbool_t, base: *mut i16, data: svint64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i16.p0")] fn _svst1h_s64(data: nxv2i16, pg: svbool2_t, ptr: *mut i16); } _svst1h_s64( @@ -38180,7 +38342,7 @@ pub unsafe fn svst1h_s64(pg: svbool_t, base: *mut i16, data: svint64_t) { #[cfg_attr(test, assert_instr(st1w))] pub unsafe fn svst1w_s64(pg: svbool_t, base: *mut i32, data: svint64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st1.nxv2i32.p0")] fn _svst1w_s64(data: nxv2i32, pg: svbool2_t, ptr: *mut i32); } _svst1w_s64( @@ -38279,7 +38441,7 @@ pub unsafe fn svst1b_scatter_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i8" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i8.p0" )] fn _svst1b_scatter_s32offset_s32( data: nxv4i8, @@ -38313,7 +38475,7 @@ pub unsafe fn svst1h_scatter_s32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i16" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.nxv4i16.p0" )] fn _svst1h_scatter_s32offset_s32( data: nxv4i16, @@ -38381,7 +38543,7 @@ pub unsafe fn svst1b_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.nxv2i8" + link_name = "llvm.aarch64.sve.st1.scatter.nxv2i8.p0" )] fn _svst1b_scatter_s64offset_s64( data: nxv2i8, @@ -38415,7 +38577,7 @@ pub unsafe fn svst1h_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.nxv2i16" + link_name = "llvm.aarch64.sve.st1.scatter.nxv2i16.p0" )] fn _svst1h_scatter_s64offset_s64( data: nxv2i16, @@ -38449,7 +38611,7 @@ pub unsafe fn svst1w_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.nxv2i32" + link_name = "llvm.aarch64.sve.st1.scatter.nxv2i32.p0" )] fn _svst1w_scatter_s64offset_s64( data: nxv2i32, @@ -38534,7 +38696,7 @@ pub unsafe fn svst1b_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i8.p0" )] fn _svst1b_scatter_u32offset_s32( data: nxv4i8, @@ -38568,7 +38730,7 @@ pub unsafe fn svst1h_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.nxv4i16.p0" )] fn _svst1h_scatter_u32offset_s32( data: nxv4i16, @@ -39277,7 +39439,7 @@ pub unsafe fn svst1h_scatter_s32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.st1.scatter.sxtw.index.nxv4i16.p0" )] fn _svst1h_scatter_s32index_s32( data: nxv4i16, @@ -39328,7 +39490,7 @@ pub unsafe fn svst1h_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i16" + link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i16.p0" )] fn _svst1h_scatter_s64index_s64( data: nxv2i16, @@ -39362,7 +39524,7 @@ pub unsafe fn svst1w_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i32" + link_name = "llvm.aarch64.sve.st1.scatter.index.nxv2i32.p0" )] fn _svst1w_scatter_s64index_s64( data: nxv2i32, @@ -39430,7 +39592,7 @@ pub unsafe fn svst1h_scatter_u32index_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4i16" + link_name = "llvm.aarch64.sve.st1.scatter.uxtw.index.nxv4i16.p0" )] fn _svst1h_scatter_u32index_s32( data: nxv4i16, @@ -39650,7 +39812,7 @@ pub unsafe fn svst1w_scatter_u64base_index_u64( #[cfg_attr(test, assert_instr(st2w))] pub unsafe fn svst2_f32(pg: svbool_t, base: *mut f32, data: svfloat32x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv4f32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv4f32.p0")] fn _svst2_f32(data0: svfloat32_t, data1: svfloat32_t, pg: svbool4_t, ptr: *mut f32); } _svst2_f32( @@ -39671,7 +39833,7 @@ pub unsafe fn svst2_f32(pg: svbool_t, base: *mut f32, data: svfloat32x2_t) { #[cfg_attr(test, assert_instr(st2d))] pub unsafe fn svst2_f64(pg: svbool_t, base: *mut f64, data: svfloat64x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv2f64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv2f64.p0")] fn _svst2_f64(data0: svfloat64_t, data1: svfloat64_t, pg: svbool2_t, ptr: *mut f64); } _svst2_f64( @@ -39692,7 +39854,7 @@ pub unsafe fn svst2_f64(pg: svbool_t, base: *mut f64, data: svfloat64x2_t) { #[cfg_attr(test, assert_instr(st2b))] pub unsafe fn svst2_s8(pg: svbool_t, base: *mut i8, data: svint8x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv16i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv16i8.p0")] fn _svst2_s8(data0: svint8_t, data1: svint8_t, pg: svbool_t, ptr: *mut i8); } _svst2_s8(svget2_s8::<0>(data), svget2_s8::<1>(data), pg, base) @@ -39708,7 +39870,7 @@ pub unsafe fn svst2_s8(pg: svbool_t, base: *mut i8, data: svint8x2_t) { #[cfg_attr(test, assert_instr(st2h))] pub unsafe fn svst2_s16(pg: svbool_t, base: *mut i16, data: svint16x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv8i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv8i16.p0")] fn _svst2_s16(data0: svint16_t, data1: svint16_t, pg: svbool8_t, ptr: *mut i16); } _svst2_s16( @@ -39729,7 +39891,7 @@ pub unsafe fn svst2_s16(pg: svbool_t, base: *mut i16, data: svint16x2_t) { #[cfg_attr(test, assert_instr(st2w))] pub unsafe fn svst2_s32(pg: svbool_t, base: *mut i32, data: svint32x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv4i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv4i32.p0")] fn _svst2_s32(data0: svint32_t, data1: svint32_t, pg: svbool4_t, ptr: *mut i32); } _svst2_s32( @@ -39750,7 +39912,7 @@ pub unsafe fn svst2_s32(pg: svbool_t, base: *mut i32, data: svint32x2_t) { #[cfg_attr(test, assert_instr(st2d))] pub unsafe fn svst2_s64(pg: svbool_t, base: *mut i64, data: svint64x2_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv2i64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st2.nxv2i64.p0")] fn _svst2_s64(data0: svint64_t, data1: svint64_t, pg: svbool2_t, ptr: *mut i64); } _svst2_s64( @@ -39939,7 +40101,7 @@ pub unsafe fn svst2_vnum_u64(pg: svbool_t, base: *mut u64, vnum: i64, data: svui #[cfg_attr(test, assert_instr(st3w))] pub unsafe fn svst3_f32(pg: svbool_t, base: *mut f32, data: svfloat32x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv4f32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv4f32.p0")] fn _svst3_f32( data0: svfloat32_t, data1: svfloat32_t, @@ -39967,7 +40129,7 @@ pub unsafe fn svst3_f32(pg: svbool_t, base: *mut f32, data: svfloat32x3_t) { #[cfg_attr(test, assert_instr(st3d))] pub unsafe fn svst3_f64(pg: svbool_t, base: *mut f64, data: svfloat64x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv2f64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv2f64.p0")] fn _svst3_f64( data0: svfloat64_t, data1: svfloat64_t, @@ -39995,7 +40157,7 @@ pub unsafe fn svst3_f64(pg: svbool_t, base: *mut f64, data: svfloat64x3_t) { #[cfg_attr(test, assert_instr(st3b))] pub unsafe fn svst3_s8(pg: svbool_t, base: *mut i8, data: svint8x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv16i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv16i8.p0")] fn _svst3_s8(data0: svint8_t, data1: svint8_t, data2: svint8_t, pg: svbool_t, ptr: *mut i8); } _svst3_s8( @@ -40017,7 +40179,7 @@ pub unsafe fn svst3_s8(pg: svbool_t, base: *mut i8, data: svint8x3_t) { #[cfg_attr(test, assert_instr(st3h))] pub unsafe fn svst3_s16(pg: svbool_t, base: *mut i16, data: svint16x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv8i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv8i16.p0")] fn _svst3_s16( data0: svint16_t, data1: svint16_t, @@ -40045,7 +40207,7 @@ pub unsafe fn svst3_s16(pg: svbool_t, base: *mut i16, data: svint16x3_t) { #[cfg_attr(test, assert_instr(st3w))] pub unsafe fn svst3_s32(pg: svbool_t, base: *mut i32, data: svint32x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv4i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv4i32.p0")] fn _svst3_s32( data0: svint32_t, data1: svint32_t, @@ -40073,7 +40235,7 @@ pub unsafe fn svst3_s32(pg: svbool_t, base: *mut i32, data: svint32x3_t) { #[cfg_attr(test, assert_instr(st3d))] pub unsafe fn svst3_s64(pg: svbool_t, base: *mut i64, data: svint64x3_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv2i64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st3.nxv2i64.p0")] fn _svst3_s64( data0: svint64_t, data1: svint64_t, @@ -40269,7 +40431,7 @@ pub unsafe fn svst3_vnum_u64(pg: svbool_t, base: *mut u64, vnum: i64, data: svui #[cfg_attr(test, assert_instr(st4w))] pub unsafe fn svst4_f32(pg: svbool_t, base: *mut f32, data: svfloat32x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv4f32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv4f32.p0")] fn _svst4_f32( data0: svfloat32_t, data1: svfloat32_t, @@ -40299,7 +40461,7 @@ pub unsafe fn svst4_f32(pg: svbool_t, base: *mut f32, data: svfloat32x4_t) { #[cfg_attr(test, assert_instr(st4d))] pub unsafe fn svst4_f64(pg: svbool_t, base: *mut f64, data: svfloat64x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv2f64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv2f64.p0")] fn _svst4_f64( data0: svfloat64_t, data1: svfloat64_t, @@ -40329,7 +40491,7 @@ pub unsafe fn svst4_f64(pg: svbool_t, base: *mut f64, data: svfloat64x4_t) { #[cfg_attr(test, assert_instr(st4b))] pub unsafe fn svst4_s8(pg: svbool_t, base: *mut i8, data: svint8x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv16i8")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv16i8.p0")] fn _svst4_s8( data0: svint8_t, data1: svint8_t, @@ -40359,7 +40521,7 @@ pub unsafe fn svst4_s8(pg: svbool_t, base: *mut i8, data: svint8x4_t) { #[cfg_attr(test, assert_instr(st4h))] pub unsafe fn svst4_s16(pg: svbool_t, base: *mut i16, data: svint16x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv8i16")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv8i16.p0")] fn _svst4_s16( data0: svint16_t, data1: svint16_t, @@ -40389,7 +40551,7 @@ pub unsafe fn svst4_s16(pg: svbool_t, base: *mut i16, data: svint16x4_t) { #[cfg_attr(test, assert_instr(st4w))] pub unsafe fn svst4_s32(pg: svbool_t, base: *mut i32, data: svint32x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv4i32")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv4i32.p0")] fn _svst4_s32( data0: svint32_t, data1: svint32_t, @@ -40419,7 +40581,7 @@ pub unsafe fn svst4_s32(pg: svbool_t, base: *mut i32, data: svint32x4_t) { #[cfg_attr(test, assert_instr(st4d))] pub unsafe fn svst4_s64(pg: svbool_t, base: *mut i64, data: svint64x4_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv2i64")] + #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.st4.nxv2i64.p0")] fn _svst4_s64( data0: svint64_t, data1: svint64_t, @@ -40618,7 +40780,10 @@ pub unsafe fn svst4_vnum_u64(pg: svbool_t, base: *mut u64, vnum: i64, data: svui #[cfg_attr(test, assert_instr(stnt1w))] pub unsafe fn svstnt1_f32(pg: svbool_t, base: *mut f32, data: svfloat32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv4f32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv4f32.p0" + )] fn _svstnt1_f32(data: svfloat32_t, pg: svbool4_t, ptr: *mut f32); } _svstnt1_f32(data, pg.sve_into(), base) @@ -40635,7 +40800,10 @@ pub unsafe fn svstnt1_f32(pg: svbool_t, base: *mut f32, data: svfloat32_t) { #[cfg_attr(test, assert_instr(stnt1d))] pub unsafe fn svstnt1_f64(pg: svbool_t, base: *mut f64, data: svfloat64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv2f64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv2f64.p0" + )] fn _svstnt1_f64(data: svfloat64_t, pg: svbool2_t, ptr: *mut f64); } _svstnt1_f64(data, pg.sve_into(), base) @@ -40652,7 +40820,10 @@ pub unsafe fn svstnt1_f64(pg: svbool_t, base: *mut f64, data: svfloat64_t) { #[cfg_attr(test, assert_instr(stnt1b))] pub unsafe fn svstnt1_s8(pg: svbool_t, base: *mut i8, data: svint8_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv16i8")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv16i8.p0" + )] fn _svstnt1_s8(data: svint8_t, pg: svbool_t, ptr: *mut i8); } _svstnt1_s8(data, pg, base) @@ -40669,7 +40840,10 @@ pub unsafe fn svstnt1_s8(pg: svbool_t, base: *mut i8, data: svint8_t) { #[cfg_attr(test, assert_instr(stnt1h))] pub unsafe fn svstnt1_s16(pg: svbool_t, base: *mut i16, data: svint16_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv8i16")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv8i16.p0" + )] fn _svstnt1_s16(data: svint16_t, pg: svbool8_t, ptr: *mut i16); } _svstnt1_s16(data, pg.sve_into(), base) @@ -40686,7 +40860,10 @@ pub unsafe fn svstnt1_s16(pg: svbool_t, base: *mut i16, data: svint16_t) { #[cfg_attr(test, assert_instr(stnt1w))] pub unsafe fn svstnt1_s32(pg: svbool_t, base: *mut i32, data: svint32_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv4i32")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv4i32.p0" + )] fn _svstnt1_s32(data: svint32_t, pg: svbool4_t, ptr: *mut i32); } _svstnt1_s32(data, pg.sve_into(), base) @@ -40703,7 +40880,10 @@ pub unsafe fn svstnt1_s32(pg: svbool_t, base: *mut i32, data: svint32_t) { #[cfg_attr(test, assert_instr(stnt1d))] pub unsafe fn svstnt1_s64(pg: svbool_t, base: *mut i64, data: svint64_t) { unsafe extern "llvm-intrinsic" { - #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.sve.stnt1.nxv2i64")] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.sve.stnt1.nxv2i64.p0" + )] fn _svstnt1_s64(data: svint64_t, pg: svbool2_t, ptr: *mut i64); } _svstnt1_s64(data, pg.sve_into(), base) diff --git a/library/stdarch/crates/core_arch/src/aarch64/sve2/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/sve2/generated.rs index 0dab039b6ecda..df151a93ff73a 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/sve2/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/sve2/generated.rs @@ -5533,7 +5533,7 @@ pub unsafe fn svldnt1_gather_s64index_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2f64" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2f64.p0" )] fn _svldnt1_gather_s64index_f64( pg: svbool2_t, @@ -5561,7 +5561,7 @@ pub unsafe fn svldnt1_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i64" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i64.p0" )] fn _svldnt1_gather_s64index_s64( pg: svbool2_t, @@ -5657,7 +5657,7 @@ pub unsafe fn svldnt1_gather_s64offset_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2f64" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2f64.p0" )] fn _svldnt1_gather_s64offset_f64( pg: svbool2_t, @@ -5685,7 +5685,7 @@ pub unsafe fn svldnt1_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i64" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i64.p0" )] fn _svldnt1_gather_s64offset_s64( pg: svbool2_t, @@ -5730,7 +5730,7 @@ pub unsafe fn svldnt1_gather_u32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4f32" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4f32.p0" )] fn _svldnt1_gather_u32offset_f32( pg: svbool4_t, @@ -5758,7 +5758,7 @@ pub unsafe fn svldnt1_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i32" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i32.p0" )] fn _svldnt1_gather_u32offset_s32( pg: svbool4_t, @@ -6198,7 +6198,7 @@ pub unsafe fn svldnt1sb_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i8.p0" )] fn _svldnt1sb_gather_s64offset_s64( pg: svbool2_t, @@ -6230,7 +6230,7 @@ pub unsafe fn svldnt1sh_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i16.p0" )] fn _svldnt1sh_gather_s64offset_s64( pg: svbool2_t, @@ -6262,7 +6262,7 @@ pub unsafe fn svldnt1sw_gather_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i32.p0" )] fn _svldnt1sw_gather_s64offset_s64( pg: svbool2_t, @@ -6345,7 +6345,7 @@ pub unsafe fn svldnt1sb_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8.p0" )] fn _svldnt1sb_gather_u32offset_s32( pg: svbool4_t, @@ -6377,7 +6377,7 @@ pub unsafe fn svldnt1sh_gather_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i16.p0" )] fn _svldnt1sh_gather_u32offset_s32( pg: svbool4_t, @@ -6940,7 +6940,7 @@ pub unsafe fn svldnt1sh_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i16.p0" )] fn _svldnt1sh_gather_s64index_s64( pg: svbool2_t, @@ -6968,7 +6968,7 @@ pub unsafe fn svldnt1sw_gather_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i32.p0" )] fn _svldnt1sw_gather_s64index_s64( pg: svbool2_t, @@ -7257,7 +7257,7 @@ pub unsafe fn svldnt1ub_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i8" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i8.p0" )] fn _svldnt1ub_gather_s64offset_u64( pg: svbool2_t, @@ -7287,7 +7287,7 @@ pub unsafe fn svldnt1uh_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i16.p0" )] fn _svldnt1uh_gather_s64offset_u64( pg: svbool2_t, @@ -7317,7 +7317,7 @@ pub unsafe fn svldnt1uw_gather_s64offset_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i32" + link_name = "llvm.aarch64.sve.ldnt1.gather.nxv2i32.p0" )] fn _svldnt1uw_gather_s64offset_u64( pg: svbool2_t, @@ -7381,7 +7381,7 @@ pub unsafe fn svldnt1ub_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8.p0" )] fn _svldnt1ub_gather_u32offset_u32( pg: svbool4_t, @@ -7412,7 +7412,7 @@ pub unsafe fn svldnt1uh_gather_u32offset_u32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i16.p0" )] fn _svldnt1uh_gather_u32offset_u32( pg: svbool4_t, @@ -7969,7 +7969,7 @@ pub unsafe fn svldnt1uh_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i16" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i16.p0" )] fn _svldnt1uh_gather_s64index_u64( pg: svbool2_t, @@ -7999,7 +7999,7 @@ pub unsafe fn svldnt1uw_gather_s64index_u64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i32" + link_name = "llvm.aarch64.sve.ldnt1.gather.index.nxv2i32.p0" )] fn _svldnt1uw_gather_s64index_u64( pg: svbool2_t, @@ -19506,7 +19506,7 @@ pub unsafe fn svstnt1_scatter_s64index_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2f64" + link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2f64.p0" )] fn _svstnt1_scatter_s64index_f64( data: svfloat64_t, @@ -19536,7 +19536,7 @@ pub unsafe fn svstnt1_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i64" + link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i64.p0" )] fn _svstnt1_scatter_s64index_s64( data: svint64_t, @@ -19638,7 +19638,7 @@ pub unsafe fn svstnt1_scatter_s64offset_f64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2f64" + link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2f64.p0" )] fn _svstnt1_scatter_s64offset_f64( data: svfloat64_t, @@ -19668,7 +19668,7 @@ pub unsafe fn svstnt1_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i64" + link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i64.p0" )] fn _svstnt1_scatter_s64offset_s64( data: svint64_t, @@ -19716,7 +19716,7 @@ pub unsafe fn svstnt1_scatter_u32offset_f32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4f32" + link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4f32.p0" )] fn _svstnt1_scatter_u32offset_f32( data: svfloat32_t, @@ -19746,7 +19746,7 @@ pub unsafe fn svstnt1_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i32" + link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i32.p0" )] fn _svstnt1_scatter_u32offset_s32( data: svint32_t, @@ -20208,7 +20208,7 @@ pub unsafe fn svstnt1b_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i8" + link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i8.p0" )] fn _svstnt1b_scatter_s64offset_s64( data: nxv2i8, @@ -20243,7 +20243,7 @@ pub unsafe fn svstnt1h_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i16" + link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i16.p0" )] fn _svstnt1h_scatter_s64offset_s64( data: nxv2i16, @@ -20278,7 +20278,7 @@ pub unsafe fn svstnt1w_scatter_s64offset_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i32" + link_name = "llvm.aarch64.sve.stnt1.scatter.nxv2i32.p0" )] fn _svstnt1w_scatter_s64offset_s64( data: nxv2i32, @@ -20367,7 +20367,7 @@ pub unsafe fn svstnt1b_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i8" + link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i8.p0" )] fn _svstnt1b_scatter_u32offset_s32( data: nxv4i8, @@ -20402,7 +20402,7 @@ pub unsafe fn svstnt1h_scatter_u32offset_s32( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i16" + link_name = "llvm.aarch64.sve.stnt1.scatter.uxtw.nxv4i16.p0" )] fn _svstnt1h_scatter_u32offset_s32( data: nxv4i16, @@ -20996,7 +20996,7 @@ pub unsafe fn svstnt1h_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i16" + link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i16.p0" )] fn _svstnt1h_scatter_s64index_s64( data: nxv2i16, @@ -21031,7 +21031,7 @@ pub unsafe fn svstnt1w_scatter_s64index_s64( unsafe extern "llvm-intrinsic" { #[cfg_attr( target_arch = "aarch64", - link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i32" + link_name = "llvm.aarch64.sve.stnt1.scatter.index.nxv2i32.p0" )] fn _svstnt1w_scatter_s64index_s64( data: nxv2i32, diff --git a/library/stdarch/crates/core_arch/src/amdgpu/mod.rs b/library/stdarch/crates/core_arch/src/amdgpu/mod.rs index 53aa142f678e9..461a4ccda3e79 100644 --- a/library/stdarch/crates/core_arch/src/amdgpu/mod.rs +++ b/library/stdarch/crates/core_arch/src/amdgpu/mod.rs @@ -702,10 +702,12 @@ pub fn s_memrealtime() -> u64 { /// Scatter data across all lanes in a wavefront. /// -/// Writes `value` to the lane `lane`. +/// Writes `value` to the lane addressed by `lane`. +/// +/// `lane` is a byte address, not a lane index: pass `n * 4` to write to lane `n`. /// /// Reading from inactive lanes returns `0`. -/// In case multiple values get written to the same `lane`, the value from the source lane with the higher index is taken. +/// In case multiple values get written to the same lane, the value from the source lane with the higher index is taken. /// #[doc = include_str!("intrinsic_is_convergent.md")] #[inline] @@ -715,7 +717,9 @@ pub unsafe fn ds_permute(lane: u32, value: u32) -> u32 { } /// Gather data across all lanes in a wavefront. /// -/// Returns the `value` given to `ds_permute` by lane `lane`. +/// Returns the `value` given to `ds_bpermute` by the lane addressed by `lane`. +/// +/// `lane` is a byte address, not a lane index: pass `n * 4` to read from lane `n`. /// /// Reading from inactive lanes returns `0`. /// diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index 237f8fb413c99..4701ffe77e112 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -3753,6 +3753,594 @@ pub fn vand_u64(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t { pub fn vandq_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { unsafe { simd_and(a, b) } } +#[doc = "BFloat16 floating-point dot product (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdot_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot) +)] +pub fn vbfdot_f32(a: float32x2_t, b: bfloat16x4_t, c: bfloat16x4_t) -> float32x2_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfdot.v2f32.v4bf16" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfdot.v2f32.v4bf16")] + fn _vbfdot_f32(a: float32x2_t, b: bfloat16x4_t, c: bfloat16x4_t) -> float32x2_t; + } + unsafe { _vbfdot_f32(a, b, c) } +} +#[doc = "BFloat16 floating-point dot product (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdotq_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot) +)] +pub fn vbfdotq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfdot.v4f32.v8bf16" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfdot.v4f32.v8bf16")] + fn _vbfdotq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { _vbfdotq_f32(a, b, c) } +} +#[doc = "BFloat16 floating-point dot product (vector, by element)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdot_lane_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot, LANE = 0) +)] +pub fn vbfdot_lane_f32( + a: float32x2_t, + b: bfloat16x4_t, + c: bfloat16x4_t, +) -> float32x2_t { + static_assert_uimm_bits!(LANE, 1); + let pairs: bfloat16x4_t = c; + unsafe { + let duped: bfloat16x4_t = transmute(vdup_lane_u32::(transmute(pairs))); + vbfdot_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point dot product (vector, by element)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdotq_lane_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot, LANE = 0) +)] +pub fn vbfdotq_lane_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x4_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 1); + let pairs: bfloat16x4_t = c; + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_lane_u32::(transmute(pairs))); + vbfdotq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point dot product (vector, by element)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdot_laneq_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot, LANE = 0) +)] +pub fn vbfdot_laneq_f32( + a: float32x2_t, + b: bfloat16x4_t, + c: bfloat16x8_t, +) -> float32x2_t { + static_assert_uimm_bits!(LANE, 2); + let pairs: bfloat16x8_t = c; + unsafe { + let duped: bfloat16x4_t = transmute(vdup_laneq_u32::(transmute(pairs))); + vbfdot_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point dot product (vector, by element)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfdotq_laneq_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdot.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfdot, LANE = 0) +)] +pub fn vbfdotq_laneq_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x8_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 2); + let pairs: bfloat16x8_t = c; + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_laneq_u32::(transmute(pairs))); + vbfdotq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlalbq_f32)"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmab.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalb) +)] +pub fn vbfmlalbq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmlalb" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmlalb")] + fn _vbfmlalbq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { _vbfmlalbq_f32(a, b, c) } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlalbq_f32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmab.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalb) +)] +pub fn vbfmlalbq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmlalb" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmlalb")] + fn _vbfmlalbq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let b: bfloat16x8_t = simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]); + let c: bfloat16x8_t = simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: float32x4_t = _vbfmlalbq_f32(a, b, c); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlalbq_lane_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmab.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalb, LANE = 0) +)] +pub fn vbfmlalbq_lane_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x4_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 2); + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_lane_u16::(transmute(c))); + vbfmlalbq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlalbq_laneq_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmab.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalb, LANE = 0) +)] +pub fn vbfmlalbq_laneq_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x8_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 3); + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_laneq_u16::(transmute(c))); + vbfmlalbq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlaltq_f32)"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmat.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalt) +)] +pub fn vbfmlaltq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmlalt" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmlalt")] + fn _vbfmlaltq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { _vbfmlaltq_f32(a, b, c) } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlaltq_f32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmat.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalt) +)] +pub fn vbfmlaltq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmlalt" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmlalt")] + fn _vbfmlaltq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let b: bfloat16x8_t = simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]); + let c: bfloat16x8_t = simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: float32x4_t = _vbfmlaltq_f32(a, b, c); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlaltq_lane_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmat.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalt, LANE = 0) +)] +pub fn vbfmlaltq_lane_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x4_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 2); + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_lane_u16::(transmute(c))); + vbfmlaltq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point widening multiply-add long (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmlaltq_laneq_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vfmat.bf16", LANE = 0))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmlalt, LANE = 0) +)] +pub fn vbfmlaltq_laneq_f32( + a: float32x4_t, + b: bfloat16x8_t, + c: bfloat16x8_t, +) -> float32x4_t { + static_assert_uimm_bits!(LANE, 3); + unsafe { + let duped: bfloat16x8_t = transmute(vdupq_laneq_u16::(transmute(c))); + vbfmlaltq_f32(a, b, duped) + } +} +#[doc = "BFloat16 floating-point matrix multiply-accumulate into 2x2 matrix"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmmlaq_f32)"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmmla.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmmla) +)] +pub fn vbfmmlaq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmmla" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmmla")] + fn _vbfmmlaq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { _vbfmmlaq_f32(a, b, c) } +} +#[doc = "BFloat16 floating-point matrix multiply-accumulate into 2x2 matrix"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbfmmlaq_f32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmmla.bf16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfmmla) +)] +pub fn vbfmmlaq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfmmla" + )] + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.bfmmla")] + fn _vbfmmlaq_f32(a: float32x4_t, b: bfloat16x8_t, c: bfloat16x8_t) -> float32x4_t; + } + unsafe { + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let b: bfloat16x8_t = simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]); + let c: bfloat16x8_t = simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: float32x4_t = _vbfmmlaq_f32(a, b, c); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + } +} #[doc = "Vector bitwise bit clear."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vbic_s16)"] #[inline] @@ -7758,6 +8346,59 @@ pub fn vcntq_p8(a: poly8x16_t) -> poly8x16_t { unsafe { transmute(vcntq_s8(transmute(a))) } } #[doc = "Join two smaller vectors into a single larger vector"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcombine_bf16)"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub fn vcombine_bf16(a: bfloat16x4_t, b: bfloat16x4_t) -> bfloat16x8_t { + unsafe { simd_shuffle!(a, b, [0, 1, 2, 3, 4, 5, 6, 7]) } +} +#[doc = "Join two smaller vectors into a single larger vector"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcombine_bf16)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub fn vcombine_bf16(a: bfloat16x4_t, b: bfloat16x4_t) -> bfloat16x8_t { + unsafe { + let a: bfloat16x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let b: bfloat16x4_t = simd_shuffle!(b, b, [3, 2, 1, 0]); + let ret_val: bfloat16x8_t = simd_shuffle!(a, b, [0, 1, 2, 3, 4, 5, 6, 7]); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) + } +} +#[doc = "Join two smaller vectors into a single larger vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcombine_f16)"] #[inline] #[cfg(target_endian = "little")] @@ -8304,6 +8945,31 @@ pub fn vcombine_p64(a: poly64x1_t, b: poly64x1_t) -> poly64x2_t { } } #[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcreate_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vcreate_bf16(a: u64) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Insert vector element from another vector element"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcreate_f16)"] #[inline] #[target_feature(enable = "neon")] @@ -8578,6 +9244,48 @@ pub fn vcreate_p16(a: u64) -> poly16x4_t { pub fn vcreate_p64(a: u64) -> poly64x1_t { unsafe { transmute(a) } } +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_bf16_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vcvt.bf16.f32"))] +pub fn vcvt_bf16_f32(a: float32x4_t) -> bfloat16x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vcvtfp2bf.v4bf16")] + fn _vcvt_bf16_f32(a: float32x4_t) -> bfloat16x4_t; + } + unsafe { _vcvt_bf16_f32(a) } +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_bf16_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(bfcvtn) +)] +pub fn vcvt_bf16_f32(a: float32x4_t) -> bfloat16x4_t { + unsafe { vget_low_bf16(vcvtq_low_bf16_f32(a)) } +} #[doc = "Floating-point convert to lower precision narrow"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_f16_f32)"] #[inline] @@ -8689,6 +9397,32 @@ pub fn vcvt_f16_u16(a: uint16x4_t) -> float16x4_t { pub fn vcvtq_f16_u16(a: uint16x8_t) -> float16x8_t { unsafe { simd_cast(a) } } +#[doc = "Shift Left Long (by element size)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_f32_bf16)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vshll.i16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(shll) +)] +pub fn vcvt_f32_bf16(a: bfloat16x4_t) -> float32x4_t { + unsafe { + let half: uint16x4_t = transmute(a); + vreinterpretq_f32_u32(vshll_n_u16::<16>(half)) + } +} #[doc = "Floating-point convert to higher precision long"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_f32_f16)"] #[inline] @@ -9584,6 +10318,371 @@ pub fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t { } unsafe { _vcvtq_u32_f32(a) } } +#[doc = "Shift Left (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtah_f32_bf16)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub fn vcvtah_f32_bf16(a: bfloat16_t) -> f32 { + f32::from_bits((a.to_bits() as u32) << 16) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (scalar)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvth_bf16_f32)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vcvtb.bf16.f32"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + not(target_env = "msvc") + ), + assert_instr(bfcvt) +)] +pub fn vcvth_bf16_f32(a: f32) -> bfloat16_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vcvtbfp2bf")] + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfcvt" + )] + fn _vcvth_bf16_f32(a: f32) -> bfloat16_t; + } + unsafe { _vcvth_bf16_f32(a) } +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_high_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + target_endian = "little" + ), + assert_instr(bfcvtn2) +)] +#[cfg_attr( + all(test, target_arch = "aarch64", target_endian = "big"), + assert_instr(bfcvtn) +)] +pub unsafe fn vcvtq_high_bf16_f32(_inactive: bfloat16x8_t, a: float32x4_t) -> bfloat16x8_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfcvtn2" + )] + fn _vcvtq_high_bf16_f32(_inactive: bfloat16x8_t, a: float32x4_t) -> bfloat16x8_t; + } + _vcvtq_high_bf16_f32(_inactive, a) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_high_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + target_endian = "little" + ), + assert_instr(bfcvtn2) +)] +#[cfg_attr( + all(test, target_arch = "aarch64", target_endian = "big"), + assert_instr(bfcvtn) +)] +pub unsafe fn vcvtq_high_bf16_f32(_inactive: bfloat16x8_t, a: float32x4_t) -> bfloat16x8_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfcvtn2" + )] + fn _vcvtq_high_bf16_f32(_inactive: bfloat16x8_t, a: float32x4_t) -> bfloat16x8_t; + } + let _inactive: bfloat16x8_t = simd_shuffle!(_inactive, _inactive, [7, 6, 5, 4, 3, 2, 1, 0]); + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let ret_val: bfloat16x8_t = _vcvtq_high_bf16_f32(_inactive, a); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_high_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vcvt.bf16.f32"))] +pub unsafe fn vcvtq_high_bf16_f32(_inactive: bfloat16x8_t, a: float32x4_t) -> bfloat16x8_t { + let b: bfloat16x4_t = simd_shuffle!(_inactive, _inactive, [0, 1, 2, 3]); + let a: int32x4_t = transmute(a); + let a: int16x8_t = transmute(a); + let a: float32x4_t = transmute(a); + let a: bfloat16x4_t = vcvt_bf16_f32(a); + let vec: bfloat16x4_t = simd_shuffle!(a, a, [0, 1, 2, 3]); + simd_shuffle!(vec, b, [0, 1, 2, 3, 4, 5, 6, 7]) +} +#[doc = "Shift Left Long (by element size)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_high_f32_bf16)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vshll.i16"))] +#[cfg_attr( + all( + test, + any(target_arch = "aarch64", target_arch = "arm64ec"), + target_endian = "little" + ), + assert_instr(shll2) +)] +#[cfg_attr( + all(test, target_arch = "aarch64", target_endian = "big"), + assert_instr(shll) +)] +pub fn vcvtq_high_f32_bf16(a: bfloat16x8_t) -> float32x4_t { + unsafe { + let half: uint16x4_t = vget_high_u16(transmute(a)); + vreinterpretq_f32_u32(vshll_n_u16::<16>(half)) + } +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_low_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vcvt.bf16.f32"))] +pub unsafe fn vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t { + let a: int32x4_t = transmute(a); + let a: int8x16_t = transmute(a); + let a: float32x4_t = transmute(a); + let vec: bfloat16x4_t = vcvt_bf16_f32(a); + let z: bfloat16x4_t = bfloat16x4_t([ + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + ]); + simd_shuffle!(z, vec, [0, 1, 2, 3, 4, 5, 6, 7]) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_low_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vcvt.bf16.f32"))] +pub unsafe fn vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t { + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let a: int32x4_t = transmute(a); + let a: int8x16_t = transmute(a); + let a: float32x4_t = transmute(a); + let vec: bfloat16x4_t = vcvt_bf16_f32(a); + let z: bfloat16x4_t = bfloat16x4_t([ + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + bfloat16_t::from_bits(0x0), + ]); + let ret_val: bfloat16x8_t = simd_shuffle!(z, vec, [0, 1, 2, 3, 4, 5, 6, 7]); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_low_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(bfcvtn) +)] +pub unsafe fn vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfcvtn" + )] + fn _vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t; + } + _vcvtq_low_bf16_f32(a) +} +#[doc = "Floating-point convert from single-precision to BFloat16 format (vector)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_low_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(bfcvtn) +)] +pub unsafe fn vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.bfcvtn" + )] + fn _vcvtq_low_bf16_f32(a: float32x4_t) -> bfloat16x8_t; + } + let a: float32x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + let ret_val: bfloat16x8_t = _vcvtq_low_bf16_f32(a); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) +} +#[doc = "Shift Left Long (by element size)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvtq_low_f32_bf16)"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vshll.i16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(shll) +)] +pub fn vcvtq_low_f32_bf16(a: bfloat16x8_t) -> float32x4_t { + unsafe { + let half: uint16x4_t = vget_low_u16(transmute(a)); + vreinterpretq_f32_u32(vshll_n_u16::<16>(half)) + } +} #[doc = "Dot product arithmetic (indexed)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdot_lane_s32)"] #[inline] @@ -10052,6 +11151,34 @@ pub fn vdotq_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x16_t) -> uint32x4_t { simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) } } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdup_lane_bf16(a: bfloat16x4_t) -> bfloat16x4_t { + static_assert_uimm_bits!(LANE, 2); + let c: uint16x4_t = vreinterpret_u16_bf16(a); + let duped: uint16x4_t = vdup_lane_u16::(c); + vreinterpret_bf16_u16(duped) +} #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_lane_f16)"] #[inline] @@ -11158,6 +12285,118 @@ pub fn vdup_lane_u64(a: uint64x1_t) -> uint64x1_t { static_assert!(N == 0); a } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdup_laneq_bf16(a: bfloat16x8_t) -> bfloat16x4_t { + static_assert_uimm_bits!(LANE, 3); + simd_shuffle!(a, a, [LANE as u32; 4]) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdup_laneq_bf16(a: bfloat16x8_t) -> bfloat16x4_t { + static_assert_uimm_bits!(LANE, 3); + let a: bfloat16x8_t = simd_shuffle!(a, a, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: bfloat16x4_t = simd_shuffle!(a, a, [LANE as u32; 4]); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdupq_laneq_bf16(a: bfloat16x8_t) -> bfloat16x8_t { + static_assert_uimm_bits!(LANE, 3); + simd_shuffle!(a, a, [LANE as u32; 8]) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdupq_laneq_bf16(a: bfloat16x8_t) -> bfloat16x8_t { + static_assert_uimm_bits!(LANE, 3); + let a: bfloat16x8_t = simd_shuffle!(a, a, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: bfloat16x8_t = simd_shuffle!(a, a, [LANE as u32; 8]); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) +} #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_laneq_f16)"] #[inline] @@ -12270,6 +13509,31 @@ pub fn vdup_laneq_u64(a: uint64x2_t) -> uint64x1_t { static_assert_uimm_bits!(N, 1); unsafe { transmute(vgetq_lane_u64::(a)) } } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_n_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vdup_n_bf16(a: bfloat16_t) -> bfloat16x4_t { + vreinterpret_bf16_u16(vdup_n_u16(a.to_bits())) +} #[doc = "Create a new vector with all lanes set to a value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_n_f16)"] #[inline] @@ -12806,6 +14070,86 @@ fn vdup_n_f32_vfp4(value: f32) -> float32x2_t { fn vdupq_n_f32_vfp4(value: f32) -> float32x4_t { float32x4_t::splat(value) } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vduph_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vduph_lane_bf16(a: bfloat16x4_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 2); + vget_lane_bf16::(a) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vduph_laneq_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vduph_laneq_bf16(a: bfloat16x8_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 3); + vgetq_lane_bf16::(a) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vdupq_lane_bf16(a: bfloat16x4_t) -> bfloat16x8_t { + static_assert_uimm_bits!(LANE, 2); + let c: uint16x4_t = vreinterpret_u16_bf16(a); + let duped: uint16x8_t = vdupq_lane_u16::(c); + vreinterpretq_bf16_u16(duped) +} #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_lane_s64)"] #[inline] @@ -13012,6 +14356,31 @@ pub fn vdupq_laneq_u64(a: uint64x2_t) -> uint64x2_t { simd_shuffle!(ret_val, ret_val, [1, 0]) } } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_n_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vdupq_n_bf16(a: bfloat16_t) -> bfloat16x8_t { + vreinterpretq_bf16_u16(vdupq_n_u16(a.to_bits())) +} #[doc = "Vector bitwise exclusive or (vector)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/veor_s8)"] #[inline] @@ -15191,6 +16560,60 @@ pub fn vfms_n_f32(a: float32x2_t, b: float32x2_t, c: f32) -> float32x2_t { pub fn vfmsq_n_f32(a: float32x4_t, b: float32x4_t, c: f32) -> float32x4_t { vfmsq_f32(a, b, vdupq_n_f32_vfp4(c)) } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_high_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vget_high_bf16(a: bfloat16x8_t) -> bfloat16x4_t { + simd_shuffle!(a, a, [4, 5, 6, 7]) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_high_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vget_high_bf16(a: bfloat16x8_t) -> bfloat16x4_t { + let a: bfloat16x8_t = simd_shuffle!(a, a, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: bfloat16x4_t = simd_shuffle!(a, a, [4, 5, 6, 7]); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) +} #[doc = "Duplicate vector element to vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_high_f16)"] #[inline] @@ -15999,6 +17422,61 @@ pub fn vget_high_u64(a: uint64x2_t) -> uint64x1_t { uint64x1_t([simd_extract!(a, 1)]) } } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vget_lane_bf16(a: bfloat16x4_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 2); + simd_extract!(a, LANE as u32) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vget_lane_bf16(a: bfloat16x4_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 2); + let a: bfloat16x4_t = simd_shuffle!(a, a, [3, 2, 1, 0]); + simd_extract!(a, LANE as u32) +} #[doc = "Duplicate vector element to scalar"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_lane_f16)"] #[inline] @@ -17045,6 +18523,31 @@ pub fn vget_lane_u64(v: uint64x1_t) -> u64 { unsafe { simd_extract!(v, 0) } } #[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_low_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vget_low_bf16(a: bfloat16x8_t) -> bfloat16x4_t { + transmute(vget_low_u64(transmute(a))) +} +#[doc = "Duplicate vector element to vector or scalar"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_low_f32)"] #[inline] #[cfg(target_endian = "little")] @@ -17524,6 +19027,61 @@ pub fn vget_low_u64(a: uint64x2_t) -> uint64x1_t { uint64x1_t([simd_extract!(a, 0)]) } } +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vgetq_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vgetq_lane_bf16(a: bfloat16x8_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 3); + simd_extract!(a, LANE as u32) +} +#[doc = "Duplicate vector element to vector or scalar"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vgetq_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vgetq_lane_bf16(a: bfloat16x8_t) -> bfloat16_t { + static_assert_uimm_bits!(LANE, 3); + let a: bfloat16x8_t = simd_shuffle!(a, a, [7, 6, 5, 4, 3, 2, 1, 0]); + simd_extract!(a, LANE as u32) +} #[doc = "Halving add"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vhadd_s8)"] #[inline] @@ -18220,6 +19778,436 @@ pub fn vhsubq_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { } unsafe { _vhsubq_u32(a, b) } } +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vld1_bf16(ptr: *const bfloat16_t) -> bfloat16x4_t { + crate::ptr::read_unaligned(ptr.cast()) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vld1q_bf16(ptr: *const bfloat16_t) -> bfloat16x8_t { + crate::ptr::read_unaligned(ptr.cast()) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x4x2_t { + transmute(vld1_u16_x2(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x4x3_t { + transmute(vld1_u16_x3(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x4x4_t { + transmute(vld1_u16_x4(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x8x2_t { + transmute(vld1q_u16_x2(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x8x3_t { + transmute(vld1q_u16_x3(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x8x4_t { + transmute(vld1q_u16_x4(ptr.cast())) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x4x2_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x2.v4bf16.p0" + )] + fn _vld1_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x4x2_t; + } + _vld1_bf16_x2(ptr) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x4x3_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x3.v4bf16.p0" + )] + fn _vld1_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x4x3_t; + } + _vld1_bf16_x3(ptr) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x4x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x4.v4bf16.p0" + )] + fn _vld1_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x4x4_t; + } + _vld1_bf16_x4(ptr) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x8x2_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x2.v8bf16.p0" + )] + fn _vld1q_bf16_x2(ptr: *const bfloat16_t) -> bfloat16x8x2_t; + } + _vld1q_bf16_x2(ptr) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x8x3_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x3.v8bf16.p0" + )] + fn _vld1q_bf16_x3(ptr: *const bfloat16_t) -> bfloat16x8x3_t; + } + _vld1q_bf16_x3(ptr) +} +#[doc = "Load multiple single-element structures to one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld1) +)] +pub unsafe fn vld1q_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x8x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld1x4.v8bf16.p0" + )] + fn _vld1q_bf16_x4(ptr: *const bfloat16_t) -> bfloat16x8x4_t; + } + _vld1q_bf16_x4(ptr) +} +#[doc = "Load one single-element structure and Replicate to all lanes (of one register)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vld1_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x4_t { + transmute(vld1_dup_u16(ptr.cast())) +} +#[doc = "Load one single-element structure and Replicate to all lanes (of one register)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vld1q_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x8_t { + transmute(vld1q_dup_u16(ptr.cast())) +} #[doc = "Load one single-element structure and replicate to all lanes of one register"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_dup_f16)"] #[doc = "## Safety"] @@ -19290,6 +21278,62 @@ pub unsafe fn vld1q_f32_x4(a: *const f32) -> float32x4x4_t { crate::ptr::read_unaligned(a.cast()) } #[doc = "Load one single-element structure to one lane of one register"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vld1_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x4_t, +) -> bfloat16x4_t { + transmute(vld1_lane_u16::(ptr.cast(), transmute(src))) +} +#[doc = "Load one single-element structure to one lane of one register"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vld1q_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x8_t, +) -> bfloat16x8_t { + transmute(vld1q_lane_u16::(ptr.cast(), transmute(src))) +} +#[doc = "Load one single-element structure to one lane of one register"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_lane_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -21751,6 +23795,486 @@ pub unsafe fn vld1q_dup_p64(ptr: *const p64) -> poly64x2_t { let x = vld1q_lane_p64::<0>(ptr, transmute(u64x2::splat(0))); simd_shuffle!(x, x, [0, 0]) } +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2_bf16(ptr: *const bfloat16_t) -> bfloat16x4x2_t { + transmute(vld2_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x2_t { + transmute(vld2q_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3_bf16(ptr: *const bfloat16_t) -> bfloat16x4x3_t { + transmute(vld3_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x3_t { + transmute(vld3q_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4_bf16(ptr: *const bfloat16_t) -> bfloat16x4x4_t { + transmute(vld4_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(target_arch = "arm")] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x4_t { + transmute(vld4q_u16(ptr.cast())) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2_bf16(ptr: *const bfloat16_t) -> bfloat16x4x2_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld2.v4bf16.p0" + )] + fn _vld2_bf16(ptr: *const bfloat16_t) -> bfloat16x4x2_t; + } + _vld2_bf16(ptr) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x2_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld2.v8bf16.p0" + )] + fn _vld2q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x2_t; + } + _vld2q_bf16(ptr) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3_bf16(ptr: *const bfloat16_t) -> bfloat16x4x3_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld3.v4bf16.p0" + )] + fn _vld3_bf16(ptr: *const bfloat16_t) -> bfloat16x4x3_t; + } + _vld3_bf16(ptr) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x3_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld3.v8bf16.p0" + )] + fn _vld3q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x3_t; + } + _vld3q_bf16(ptr) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4_bf16(ptr: *const bfloat16_t) -> bfloat16x4x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld4.v4bf16.p0" + )] + fn _vld4_bf16(ptr: *const bfloat16_t) -> bfloat16x4x4_t; + } + _vld4_bf16(ptr) +} +#[doc = "Load multiple 2-element structures to two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg(not(target_arch = "arm"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x4_t { + unsafe extern "llvm-intrinsic" { + #[cfg_attr( + any(target_arch = "aarch64", target_arch = "arm64ec"), + link_name = "llvm.aarch64.neon.ld4.v8bf16.p0" + )] + fn _vld4q_bf16(ptr: *const bfloat16_t) -> bfloat16x8x4_t; + } + _vld4q_bf16(ptr) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x4x2_t { + transmute(vld2_dup_u16(ptr.cast())) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2q_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2) +)] +pub unsafe fn vld2q_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x8x2_t { + transmute(vld2q_dup_u16(ptr.cast())) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x4x3_t { + transmute(vld3_dup_u16(ptr.cast())) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3) +)] +pub unsafe fn vld3q_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x8x3_t { + transmute(vld3q_dup_u16(ptr.cast())) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x4x4_t { + transmute(vld4_dup_u16(ptr.cast())) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_dup_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4) +)] +pub unsafe fn vld4q_dup_bf16(ptr: *const bfloat16_t) -> bfloat16x8x4_t { + transmute(vld4q_dup_u16(ptr.cast())) +} #[doc = "Load single 2-element structure and replicate to all lanes of two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_dup_f16)"] #[doc = "## Safety"] @@ -22794,6 +25318,62 @@ pub unsafe fn vld2q_s32(a: *const i32) -> int32x4x2_t { } _vld2q_s32(a as _) } +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2, LANE = 2) +)] +pub unsafe fn vld2_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x4x2_t, +) -> bfloat16x4x2_t { + transmute(vld2_lane_u16::(ptr.cast(), transmute(src))) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld2.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld2, LANE = 2) +)] +pub unsafe fn vld2q_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x8x2_t, +) -> bfloat16x8x2_t { + transmute(vld2q_lane_u16::(ptr.cast(), transmute(src))) +} #[doc = "Load multiple 2-element structures to two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld2_lane_f16)"] #[doc = "## Safety"] @@ -24699,6 +27279,62 @@ pub unsafe fn vld3q_s32(a: *const i32) -> int32x4x3_t { } _vld3q_s32(a as *const i8, 4) } +#[doc = "Load single 3-element structure to one lane of three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3, LANE = 2) +)] +pub unsafe fn vld3_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x4x3_t, +) -> bfloat16x4x3_t { + transmute(vld3_lane_u16::(ptr.cast(), transmute(src))) +} +#[doc = "Load single 3-element structure to one lane of three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld3.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld3, LANE = 2) +)] +pub unsafe fn vld3q_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x8x3_t, +) -> bfloat16x8x3_t { + transmute(vld3q_lane_u16::(ptr.cast(), transmute(src))) +} #[doc = "Load multiple 3-element structures to two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3_lane_f16)"] #[doc = "## Safety"] @@ -25908,7 +28544,7 @@ pub unsafe fn vld4_dup_f32(a: *const f32) -> float32x2x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v2f32.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v2f32.p0" )] fn _vld4_dup_f32(ptr: *const f32) -> float32x2x4_t; } @@ -25927,7 +28563,7 @@ pub unsafe fn vld4q_dup_f32(a: *const f32) -> float32x4x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v4f32.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v4f32.p0" )] fn _vld4q_dup_f32(ptr: *const f32) -> float32x4x4_t; } @@ -25946,7 +28582,7 @@ pub unsafe fn vld4_dup_s8(a: *const i8) -> int8x8x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v8i8.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v8i8.p0" )] fn _vld4_dup_s8(ptr: *const i8) -> int8x8x4_t; } @@ -25965,7 +28601,7 @@ pub unsafe fn vld4q_dup_s8(a: *const i8) -> int8x16x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v16i8.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v16i8.p0" )] fn _vld4q_dup_s8(ptr: *const i8) -> int8x16x4_t; } @@ -25984,7 +28620,7 @@ pub unsafe fn vld4_dup_s16(a: *const i16) -> int16x4x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v4i16.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v4i16.p0" )] fn _vld4_dup_s16(ptr: *const i16) -> int16x4x4_t; } @@ -26003,7 +28639,7 @@ pub unsafe fn vld4q_dup_s16(a: *const i16) -> int16x8x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v8i16.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v8i16.p0" )] fn _vld4q_dup_s16(ptr: *const i16) -> int16x8x4_t; } @@ -26022,7 +28658,7 @@ pub unsafe fn vld4_dup_s32(a: *const i32) -> int32x2x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v2i32.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v2i32.p0" )] fn _vld4_dup_s32(ptr: *const i32) -> int32x2x4_t; } @@ -26041,7 +28677,7 @@ pub unsafe fn vld4q_dup_s32(a: *const i32) -> int32x4x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v4i32.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v4i32.p0" )] fn _vld4q_dup_s32(ptr: *const i32) -> int32x4x4_t; } @@ -26060,7 +28696,7 @@ pub unsafe fn vld4_dup_s64(a: *const i64) -> int64x1x4_t { unsafe extern "llvm-intrinsic" { #[cfg_attr( any(target_arch = "aarch64", target_arch = "arm64ec"), - link_name = "llvm.aarch64.neon.ld4r.v1i64.p0.p0" + link_name = "llvm.aarch64.neon.ld4r.v1i64.p0" )] fn _vld4_dup_s64(ptr: *const i64) -> int64x1x4_t; } @@ -26650,6 +29286,62 @@ pub unsafe fn vld4q_s32(a: *const i32) -> int32x4x4_t { } _vld4q_s32(a as *const i8, 4) } +#[doc = "Load single 4-element structure and Replicate to all lanes of four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4, LANE = 2) +)] +pub unsafe fn vld4_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x4x4_t, +) -> bfloat16x4x4_t { + transmute(vld4_lane_u16::(ptr.cast(), transmute(src))) +} +#[doc = "Load single 4-element structure and Replicate to all lanes of four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld4.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(ld4, LANE = 2) +)] +pub unsafe fn vld4q_lane_bf16( + ptr: *const bfloat16_t, + src: bfloat16x8x4_t, +) -> bfloat16x8x4_t { + transmute(vld4q_lane_u16::(ptr.cast(), transmute(src))) +} #[doc = "Load multiple 4-element structures to two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4_lane_f16)"] #[doc = "## Safety"] @@ -42264,293 +44956,657 @@ pub fn vrecpsq_f32(a: float32x4_t, b: float32x4_t) -> float32x4_t { unsafe { _vrecpsq_f32(a, b) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_f16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_f16(a: float16x4_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f32_f16(a: float16x4_t) -> float32x2_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_f32(a: float32x2_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_p16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_p16(a: poly16x4_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_p64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_s8_f16(a: float16x4_t) -> int8x8_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_p64(a: poly64x1_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_p8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_p8(a: poly8x8_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_s16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_s32_f16(a: float16x4_t) -> int32x2_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_s16(a: int16x4_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s64_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_s32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_s32(a: int32x2_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_s64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_s64_f16(a: float16x4_t) -> int64x1_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_s64(a: int64x1_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_s8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_s8(a: int8x8_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_u16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_u8_f16(a: float16x4_t) -> uint8x8_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_u16(a: uint16x4_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_u32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_u32(a: uint32x2_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_u64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_u32_f16(a: float16x4_t) -> uint32x2_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_bf16_u64(a: uint64x1_t) -> bfloat16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u64_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_bf16_u8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_bf16_u8(a: uint8x8_t) -> bfloat16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_u64_f16(a: float16x4_t) -> uint64x1_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_f16_bf16(a: bfloat16x4_t) -> float16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_p8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_f32_bf16(a: bfloat16x4_t) -> float32x2_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_p16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_p8_f16(a: float16x4_t) -> poly8x8_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_p16_bf16(a: bfloat16x4_t) -> poly16x4_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_p64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_p64_bf16(a: bfloat16x4_t) -> poly64x1_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_p8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f32_f16(a: float16x8_t) -> float32x4_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_p8_bf16(a: bfloat16x4_t) -> poly8x8_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_s16_bf16(a: bfloat16x4_t) -> int16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_s8_f16(a: float16x8_t) -> int8x16_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_s32_bf16(a: bfloat16x4_t) -> int32x2_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_s64_bf16(a: bfloat16x4_t) -> int64x1_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_s32_f16(a: float16x8_t) -> int32x4_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_s8_bf16(a: bfloat16x4_t) -> int8x8_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s64_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_u16_bf16(a: bfloat16x4_t) -> uint16x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_s64_f16(a: float16x8_t) -> int64x2_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_u32_bf16(a: bfloat16x4_t) -> uint32x2_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] #[inline] -#[target_feature(enable = "neon")] -#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] +pub unsafe fn vreinterpret_u64_bf16(a: bfloat16x4_t) -> uint64x1_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr( not(target_arch = "arm"), - stable(feature = "stdarch_neon_fp16", since = "1.94.0") + unstable(feature = "stdarch_neon_bf16", issue = "164986") )] #[cfg_attr( target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] -#[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_u8_f16(a: float16x8_t) -> uint8x16_t { - unsafe { transmute(a) } +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpret_u8_bf16(a: bfloat16x4_t) -> uint8x8_t { + transmute(a) } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u32_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42568,11 +45624,11 @@ pub fn vreinterpretq_u8_f16(a: float16x8_t) -> uint8x16_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_u32_f16(a: float16x8_t) -> uint32x4_t { +pub fn vreinterpret_f32_f16(a: float16x4_t) -> float32x2_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u64_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s8_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42590,11 +45646,11 @@ pub fn vreinterpretq_u32_f16(a: float16x8_t) -> uint32x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_u64_f16(a: float16x8_t) -> uint64x2_t { +pub fn vreinterpret_s8_f16(a: float16x4_t) -> int8x8_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p8_f16)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42612,11 +45668,11 @@ pub fn vreinterpretq_u64_f16(a: float16x8_t) -> uint64x2_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_p8_f16(a: float16x8_t) -> poly8x16_t { +pub fn vreinterpret_s32_f16(a: float16x4_t) -> int32x2_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_f32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_s64_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42634,11 +45690,11 @@ pub fn vreinterpretq_p8_f16(a: float16x8_t) -> poly8x16_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_f32(a: float32x2_t) -> float16x4_t { +pub fn vreinterpret_s64_f16(a: float16x4_t) -> int64x1_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_f32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u8_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42656,11 +45712,11 @@ pub fn vreinterpret_f16_f32(a: float32x2_t) -> float16x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f16_f32(a: float32x4_t) -> float16x8_t { +pub fn vreinterpret_u8_f16(a: float16x4_t) -> uint8x8_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s8)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42678,11 +45734,11 @@ pub fn vreinterpretq_f16_f32(a: float32x4_t) -> float16x8_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_s8(a: int8x8_t) -> float16x4_t { +pub fn vreinterpret_u32_f16(a: float16x4_t) -> uint32x2_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s8)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_u64_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42700,11 +45756,11 @@ pub fn vreinterpret_f16_s8(a: int8x8_t) -> float16x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f16_s8(a: int8x16_t) -> float16x8_t { +pub fn vreinterpret_u64_f16(a: float16x4_t) -> uint64x1_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_p8_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42722,11 +45778,11 @@ pub fn vreinterpretq_f16_s8(a: int8x16_t) -> float16x8_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_s32(a: int32x2_t) -> float16x4_t { +pub fn vreinterpret_p8_f16(a: float16x4_t) -> poly8x8_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42744,11 +45800,11 @@ pub fn vreinterpret_f16_s32(a: int32x2_t) -> float16x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f16_s32(a: int32x4_t) -> float16x8_t { +pub fn vreinterpretq_f32_f16(a: float16x8_t) -> float32x4_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s64)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s8_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42766,11 +45822,11 @@ pub fn vreinterpretq_f16_s32(a: int32x4_t) -> float16x8_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_s64(a: int64x1_t) -> float16x4_t { +pub fn vreinterpretq_s8_f16(a: float16x8_t) -> int8x16_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s64)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42788,11 +45844,11 @@ pub fn vreinterpret_f16_s64(a: int64x1_t) -> float16x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f16_s64(a: int64x2_t) -> float16x8_t { +pub fn vreinterpretq_s32_f16(a: float16x8_t) -> int32x4_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_u8)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s64_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42810,11 +45866,11 @@ pub fn vreinterpretq_f16_s64(a: int64x2_t) -> float16x8_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_u8(a: uint8x8_t) -> float16x4_t { +pub fn vreinterpretq_s64_f16(a: float16x8_t) -> int64x2_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_u8)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u8_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42832,11 +45888,11 @@ pub fn vreinterpret_f16_u8(a: uint8x8_t) -> float16x4_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpretq_f16_u8(a: uint8x16_t) -> float16x8_t { +pub fn vreinterpretq_u8_f16(a: float16x8_t) -> uint8x16_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_u32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u32_f16)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -42854,11 +45910,297 @@ pub fn vreinterpretq_f16_u8(a: uint8x16_t) -> float16x8_t { unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] #[cfg(not(target_arch = "arm64ec"))] -pub fn vreinterpret_f16_u32(a: uint32x2_t) -> float16x4_t { +pub fn vreinterpretq_u32_f16(a: float16x8_t) -> uint32x4_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_u32)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u64_f16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_u64_f16(a: float16x8_t) -> uint64x2_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p8_f16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_p8_f16(a: float16x8_t) -> poly8x16_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_f32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_f32(a: float32x2_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_f32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_f16_f32(a: float32x4_t) -> float16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_s8(a: int8x8_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_f16_s8(a: int8x16_t) -> float16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_s32(a: int32x2_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_f16_s32(a: int32x4_t) -> float16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_s64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_s64(a: int64x1_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_s64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_f16_s64(a: int64x2_t) -> float16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_u8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_u8(a: uint8x8_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_u8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpretq_f16_u8(a: uint8x16_t) -> float16x8_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_u32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +#[cfg_attr( + not(target_arch = "arm"), + stable(feature = "stdarch_neon_fp16", since = "1.94.0") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg(not(target_arch = "arm64ec"))] +pub fn vreinterpret_f16_u32(a: uint32x2_t) -> float16x4_t { + unsafe { transmute(a) } +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_u32)"] #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] @@ -44072,6 +47414,706 @@ pub fn vreinterpretq_u16_p16(a: poly16x8_t) -> uint16x8_t { unsafe { transmute(a) } } #[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_f16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_f16(a: float16x8_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_f32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_f32(a: float32x4_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_p128)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_p128(a: p128) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_p16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_p16(a: poly16x8_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_p64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_p64(a: poly64x2_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_p8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_p8(a: poly8x16_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_s16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_s16(a: int16x8_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_s32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_s32(a: int32x4_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_s64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_s64(a: int64x2_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_s8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_s8(a: int8x16_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_u16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_u16(a: uint16x8_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_u32)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_u32(a: uint32x4_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_u64)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_u64(a: uint64x2_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_bf16_u8)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_bf16_u8(a: uint8x16_t) -> bfloat16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_f16_bf16(a: bfloat16x8_t) -> float16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_f32_bf16(a: bfloat16x8_t) -> float32x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p128_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_p128_bf16(a: bfloat16x8_t) -> p128 { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_p16_bf16(a: bfloat16x8_t) -> poly16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_p64_bf16(a: bfloat16x8_t) -> poly64x2_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_p8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_p8_bf16(a: bfloat16x8_t) -> poly8x16_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_s16_bf16(a: bfloat16x8_t) -> int16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_s32_bf16(a: bfloat16x8_t) -> int32x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_s64_bf16(a: bfloat16x8_t) -> int64x2_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_s8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_s8_bf16(a: bfloat16x8_t) -> int8x16_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u16_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_u16_bf16(a: bfloat16x8_t) -> uint16x8_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u32_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_u32_bf16(a: bfloat16x8_t) -> uint32x4_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u64_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_u64_bf16(a: bfloat16x8_t) -> uint64x2_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_u8_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop) +)] +pub unsafe fn vreinterpretq_u8_bf16(a: bfloat16x8_t) -> uint8x16_t { + transmute(a) +} +#[doc = "Vector reinterpret cast operation"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_p128)"] #[inline] #[target_feature(enable = "neon")] @@ -53322,6 +57364,118 @@ pub fn vrsubhn_u64(a: uint64x2_t, b: uint64x2_t) -> uint32x2_t { unsafe { transmute(vrsubhn_s64(transmute(a), transmute(b))) } } #[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vset_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vset_lane_bf16(a: bfloat16_t, v: bfloat16x4_t) -> bfloat16x4_t { + static_assert_uimm_bits!(LANE, 2); + simd_insert!(v, LANE as u32, a) +} +#[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vset_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vset_lane_bf16(a: bfloat16_t, v: bfloat16x4_t) -> bfloat16x4_t { + static_assert_uimm_bits!(LANE, 2); + let v: bfloat16x4_t = simd_shuffle!(v, v, [3, 2, 1, 0]); + let ret_val: bfloat16x4_t = simd_insert!(v, LANE as u32, a); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) +} +#[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsetq_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "little")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vsetq_lane_bf16(a: bfloat16_t, v: bfloat16x8_t) -> bfloat16x8_t { + static_assert_uimm_bits!(LANE, 3); + simd_insert!(v, LANE as u32, a) +} +#[doc = "Insert vector element from another vector element"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsetq_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vsetq_lane_bf16(a: bfloat16_t, v: bfloat16x8_t) -> bfloat16x8_t { + static_assert_uimm_bits!(LANE, 3); + let v: bfloat16x8_t = simd_shuffle!(v, v, [7, 6, 5, 4, 3, 2, 1, 0]); + let ret_val: bfloat16x8_t = simd_insert!(v, LANE as u32, a); + simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) +} +#[doc = "Insert vector element from another vector element"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vset_lane_f16)"] #[inline] #[cfg(target_endian = "little")] @@ -57733,6 +61887,206 @@ pub fn vsriq_n_p16(a: poly16x8_t, b: poly16x8_t) -> poly16x8_t { static_assert!(1 <= N && N <= 16); unsafe { transmute(vshiftrins_v8i16::(transmute(a), transmute(b))) } } +#[doc = "Store multiple single-element structures from one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(str) +)] +pub unsafe fn vst1_bf16(ptr: *mut bfloat16_t, val: bfloat16x4_t) { + crate::ptr::write_unaligned(ptr.cast(), val) +} +#[doc = "Store multiple single-element structures from one, two, three, or four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(str) +)] +pub unsafe fn vst1q_bf16(ptr: *mut bfloat16_t, val: bfloat16x8_t) { + crate::ptr::write_unaligned(ptr.cast(), val) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1_bf16_x2(ptr: *mut bfloat16_t, val: bfloat16x4x2_t) { + vst1_u16_x2(ptr.cast(), transmute(val)) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1_bf16_x3(ptr: *mut bfloat16_t, val: bfloat16x4x3_t) { + vst1_u16_x3(ptr.cast(), transmute(val)) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1_bf16_x4(ptr: *mut bfloat16_t, val: bfloat16x4x4_t) { + vst1_u16_x4(ptr.cast(), transmute(val)) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_bf16_x2)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1q_bf16_x2(ptr: *mut bfloat16_t, val: bfloat16x8x2_t) { + vst1q_u16_x2(ptr.cast(), transmute(val)) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_bf16_x3)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1q_bf16_x3(ptr: *mut bfloat16_t, val: bfloat16x8x3_t) { + vst1q_u16_x3(ptr.cast(), transmute(val)) +} +#[doc = "Load single 2-element structure and Replicate to all lanes of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_bf16_x4)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st1) +)] +pub unsafe fn vst1q_bf16_x4(ptr: *mut bfloat16_t, val: bfloat16x8x4_t) { + vst1q_u16_x4(ptr.cast(), transmute(val)) +} #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_f16)"] #[doc = "## Safety"] @@ -58561,6 +62915,56 @@ pub unsafe fn vst1q_f32_x4(a: *mut f32, b: float32x4x4_t) { } _vst1q_f32_x4(b.0, b.1, b.2, b.3, a) } +#[doc = "Store a single-element structure from one lane of one register"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vst1_lane_bf16(a: *mut bfloat16_t, v: bfloat16x4_t) { + vst1_lane_u16::(a.cast(), transmute(v)) +} +#[doc = "Store a single-element structure from one lane of one register"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 2) +)] +pub unsafe fn vst1q_lane_bf16(a: *mut bfloat16_t, v: bfloat16x8_t) { + vst1q_lane_u16::(a.cast(), transmute(v)) +} #[doc = "Store multiple single-element structures from one, two, three, or four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_lane_f16)"] #[doc = "## Safety"] @@ -61184,6 +65588,56 @@ pub unsafe fn vst1q_lane_p64(a: *mut p64, b: poly64x2_t) { crate::ptr::write_unaligned(a, simd_extract!(b, LANE as u32)) } #[doc = "Store multiple 2-element structures from two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst2_bf16(a: *mut bfloat16_t, b: bfloat16x4x2_t) { + vst2_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 2-element structures from two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst2q_bf16(a: *mut bfloat16_t, b: bfloat16x8x2_t) { + vst2q_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 2-element structures from two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -61487,6 +65941,56 @@ pub unsafe fn vst2q_s32(a: *mut i32, b: int32x4x2_t) { } _vst2q_s32(a as _, b.0, b.1, 4) } +#[doc = "Store single 2-element structure from one lane of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst2.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st2, LANE = 2) +)] +pub unsafe fn vst2_lane_bf16(a: *mut bfloat16_t, v: bfloat16x4x2_t) { + vst2_lane_u16::(a.cast(), transmute(v)) +} +#[doc = "Store single 2-element structure from one lane of two registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst2.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st2, LANE = 2) +)] +pub unsafe fn vst2q_lane_bf16(a: *mut bfloat16_t, v: bfloat16x8x2_t) { + vst2q_lane_u16::(a.cast(), transmute(v)) +} #[doc = "Store multiple 2-element structures from two registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst2_lane_f16)"] #[doc = "## Safety"] @@ -62349,6 +66853,56 @@ pub unsafe fn vst2q_p16(a: *mut p16, b: poly16x8x2_t) { vst2q_s16(transmute(a), transmute(b)) } #[doc = "Store multiple 3-element structures from three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst3_bf16(a: *mut bfloat16_t, b: bfloat16x4x3_t) { + vst3_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 3-element structures from three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst3q_bf16(a: *mut bfloat16_t, b: bfloat16x8x3_t) { + vst3q_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 3-element structures from three registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -62620,6 +67174,56 @@ pub unsafe fn vst3_s32(a: *mut i32, b: int32x2x3_t) { pub unsafe fn vst3q_s32(a: *mut i32, b: int32x4x3_t) { crate::core_arch::macros::interleaving_store!(i32, 4, 3, a, b) } +#[doc = "Store single 3-element structure from one lane of three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst3.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st3, LANE = 2) +)] +pub unsafe fn vst3_lane_bf16(a: *mut bfloat16_t, v: bfloat16x4x3_t) { + vst3_lane_u16::(a.cast(), transmute(v)) +} +#[doc = "Store single 3-element structure from one lane of three registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst3.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st3, LANE = 2) +)] +pub unsafe fn vst3q_lane_bf16(a: *mut bfloat16_t, v: bfloat16x8x3_t) { + vst3q_lane_u16::(a.cast(), transmute(v)) +} #[doc = "Store multiple 3-element structures from three registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst3_lane_f16)"] #[doc = "## Safety"] @@ -63538,6 +68142,56 @@ pub unsafe fn vst3q_p16(a: *mut p16, b: poly16x8x3_t) { vst3q_s16(transmute(a), transmute(b)) } #[doc = "Store multiple 4-element structures from four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst4_bf16(a: *mut bfloat16_t, b: bfloat16x4x4_t) { + vst4_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 4-element structures from four registers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4q_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(nop, LANE = 0) +)] +pub unsafe fn vst4q_bf16(a: *mut bfloat16_t, b: bfloat16x8x4_t) { + vst4q_u16(a.cast(), transmute(b)) +} +#[doc = "Store multiple 4-element structures from four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4_f16)"] #[doc = "## Safety"] #[doc = " * Neon intrinsic unsafe"] @@ -63904,6 +68558,56 @@ pub unsafe fn vst4_s32(a: *mut i32, b: int32x2x4_t) { pub unsafe fn vst4q_s32(a: *mut i32, b: int32x4x4_t) { crate::core_arch::macros::interleaving_store!(i32, 4, 4, a, b) } +#[doc = "Store single 4-element structure from one lane of four registerss"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst4.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st4, LANE = 2) +)] +pub unsafe fn vst4_lane_bf16(a: *mut bfloat16_t, v: bfloat16x4x4_t) { + vst4_lane_u16::(a.cast(), transmute(v)) +} +#[doc = "Store single 4-element structure from one lane of four registerss"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4q_lane_bf16)"] +#[doc = "## Safety"] +#[doc = " * Neon intrinsic unsafe"] +#[inline] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[target_feature(enable = "neon,bf16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_bf16", issue = "164986") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst4.16", LANE = 2))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(st4, LANE = 2) +)] +pub unsafe fn vst4q_lane_bf16(a: *mut bfloat16_t, v: bfloat16x8x4_t) { + vst4q_lane_u16::(a.cast(), transmute(v)) +} #[doc = "Store multiple 4-element structures from four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst4_lane_f16)"] #[doc = "## Safety"] diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs index 3af59b1dfb7cb..6d204c55dfd3d 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs @@ -48,6 +48,12 @@ pub(crate) type p16 = u16; pub(crate) type p64 = u64; pub(crate) type p128 = u128; +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[allow(non_camel_case_types)] +#[unstable(feature = "f16b", issue = "160630")] +pub(crate) type bfloat16_t = core::num::f16b; + types! { #![cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] #![cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))] @@ -113,6 +119,18 @@ types! { pub struct float16x8_t(8 x pub(crate) f16); } +#[cfg(any(target_has_reliable_f16b, doc))] +types! { + /// Arm-specific 64-bit wide vector of four packed `f16b`. + #[doc(cfg(target_has_reliable_f16b))] + stability: [unstable(feature = "f16b", issue = "160630")] + pub struct bfloat16x4_t(4 x pub(crate) bfloat16_t); + /// Arm-specific 128-bit wide vector of eight packed `f16b`. + #[doc(cfg(target_has_reliable_f16b))] + stability: [unstable(feature = "f16b", issue = "160630")] + pub struct bfloat16x8_t(8 x pub(crate) bfloat16_t); +} + /// Arm-specific type containing two `int8x8_t` vectors. #[repr(C)] #[derive(Copy, Clone, Debug)] @@ -833,6 +851,64 @@ pub struct float16x8x4_t( pub float16x8_t, ); +/// Arm-specific type containing two `bfloat16x4_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x4x2_t(pub bfloat16x4_t, pub bfloat16x4_t); + +/// Arm-specific type containing three `bfloat16x4_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x4x3_t(pub bfloat16x4_t, pub bfloat16x4_t, pub bfloat16x4_t); + +/// Arm-specific type containing four `bfloat16x4_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x4x4_t( + pub bfloat16x4_t, + pub bfloat16x4_t, + pub bfloat16x4_t, + pub bfloat16x4_t, +); + +/// Arm-specific type containing two `bfloat16x8_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x8x2_t(pub bfloat16x8_t, pub bfloat16x8_t); + +/// Arm-specific type containing three `bfloat16x8_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x8x3_t(pub bfloat16x8_t, pub bfloat16x8_t, pub bfloat16x8_t); + +/// Arm-specific type containing four `bfloat16x8_t` vectors. +#[repr(C)] +#[derive(Copy, Clone, Debug)] +#[cfg(any(target_has_reliable_f16b, doc))] +#[doc(cfg(target_has_reliable_f16b))] +#[unstable(feature = "f16b", issue = "160630")] +pub struct bfloat16x8x4_t( + pub bfloat16x8_t, + pub bfloat16x8_t, + pub bfloat16x8_t, + pub bfloat16x8_t, +); + /// Arm-specific type containing two `float32x2_t` vectors. #[repr(C)] #[derive(Copy, Clone, Debug)] diff --git a/library/stdarch/crates/core_arch/src/hexagon/scalar.rs b/library/stdarch/crates/core_arch/src/hexagon/scalar.rs index 42429a95901c4..5772fd41ef576 100644 --- a/library/stdarch/crates/core_arch/src/hexagon/scalar.rs +++ b/library/stdarch/crates/core_arch/src/hexagon/scalar.rs @@ -2021,7 +2021,6 @@ pub unsafe fn Q6_R_add_RlRl_sat(rt: i32, rs: i32) -> i32 { /// Instruction Type: ALU32_ADDI /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(add, IS16 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_RI(rs: i32) -> i32 { @@ -2089,7 +2088,6 @@ pub unsafe fn Q6_R_and_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(and, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_and_RI(rs: i32) -> i32 { @@ -2179,7 +2177,6 @@ pub unsafe fn Q6_R_combine_RlRl(rt: i32, rs: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(0, 1)] #[cfg_attr(test, assert_instr(combine, IS8 = 0, IS8_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_combine_II() -> i64 { @@ -2358,7 +2355,6 @@ pub unsafe fn Q6_R_or_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(or, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_or_RI(rs: i32) -> i32 { @@ -2602,7 +2598,6 @@ pub unsafe fn Q6_P_sub_PP(rtt: i64, rss: i64) -> i64 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(sub, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_sub_IR(rs: i32) -> i32 { @@ -2779,7 +2774,6 @@ pub unsafe fn Q6_R_equals_R(rs: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_Rh_equals_I(rx: i32) -> i32 { static_assert_uimm_bits!(IU16, 16); @@ -2791,7 +2785,6 @@ pub unsafe fn Q6_Rh_equals_I(rx: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_Rl_equals_I(rx: i32) -> i32 { static_assert_uimm_bits!(IU16, 16); @@ -2813,7 +2806,6 @@ pub unsafe fn Q6_P_equals_P(rss: i64) -> i64 { /// Instruction Type: ALU64 /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_equals_I() -> i64 { static_assert_simm_bits!(IS8, 8); @@ -2825,7 +2817,6 @@ pub unsafe fn Q6_P_equals_I() -> i64 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_equals_I() -> i32 { static_assert_simm_bits!(IS16, 16); @@ -3607,7 +3598,6 @@ pub unsafe fn Q6_P_bitsplit_RR(rs: i32, rt: i32) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(bitsplit, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_bitsplit_RI(rs: i32) -> i64 { @@ -3642,7 +3632,6 @@ pub unsafe fn Q6_p_cmpb_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmpb, IU8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmpb_eq_RI(rs: i32) -> i32 { @@ -3666,7 +3655,6 @@ pub unsafe fn Q6_p_cmpb_gt_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmpb, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmpb_gt_RI(rs: i32) -> i32 { @@ -3690,7 +3678,6 @@ pub unsafe fn Q6_p_cmpb_gtu_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmpb, IU7 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmpb_gtu_RI(rs: i32) -> i32 { @@ -3714,7 +3701,6 @@ pub unsafe fn Q6_p_cmph_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmph, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmph_eq_RI(rs: i32) -> i32 { @@ -3738,7 +3724,6 @@ pub unsafe fn Q6_p_cmph_gt_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmph, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmph_gt_RI(rs: i32) -> i32 { @@ -3762,7 +3747,6 @@ pub unsafe fn Q6_p_cmph_gtu_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmph, IU7 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmph_gtu_RI(rs: i32) -> i32 { @@ -3775,7 +3759,6 @@ pub unsafe fn Q6_p_cmph_gtu_RI(rs: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(combine, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_combine_IR(rs: i32) -> i64 { @@ -3788,7 +3771,6 @@ pub unsafe fn Q6_P_combine_IR(rs: i32) -> i64 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(combine, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_combine_RI(rs: i32) -> i64 { @@ -3801,7 +3783,6 @@ pub unsafe fn Q6_P_combine_RI(rs: i32) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cround, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_cround_RI(rs: i32) -> i32 { @@ -3869,7 +3850,6 @@ pub unsafe fn Q6_R_cmp_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_cmp_eq_RI(rs: i32) -> i32 { @@ -3892,7 +3872,6 @@ pub unsafe fn Q6_R_not_cmp_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_not_cmp_eq_RI(rs: i32) -> i32 { static_assert_simm_bits!(IS8, 8); @@ -3904,7 +3883,6 @@ pub unsafe fn Q6_R_not_cmp_eq_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(round, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_round_RI(rs: i32) -> i32 { @@ -3917,7 +3895,6 @@ pub unsafe fn Q6_R_round_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(round, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_round_RI_sat(rs: i32) -> i32 { @@ -3974,7 +3951,6 @@ pub unsafe fn Q6_p_any8_vcmpb_eq_PP(rss: i64, rtt: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpb, IU8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpb_eq_PI(rss: i64) -> i32 { @@ -3998,7 +3974,6 @@ pub unsafe fn Q6_p_vcmpb_gt_PP(rss: i64, rtt: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpb, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpb_gt_PI(rss: i64) -> i32 { @@ -4011,7 +3986,6 @@ pub unsafe fn Q6_p_vcmpb_gt_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpb, IU7 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpb_gtu_PI(rss: i64) -> i32 { @@ -4024,7 +3998,6 @@ pub unsafe fn Q6_p_vcmpb_gtu_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmph, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmph_eq_PI(rss: i64) -> i32 { @@ -4037,7 +4010,6 @@ pub unsafe fn Q6_p_vcmph_eq_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmph, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmph_gt_PI(rss: i64) -> i32 { @@ -4050,7 +4022,6 @@ pub unsafe fn Q6_p_vcmph_gt_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmph, IU7 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmph_gtu_PI(rss: i64) -> i32 { @@ -4063,7 +4034,6 @@ pub unsafe fn Q6_p_vcmph_gtu_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpw, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpw_eq_PI(rss: i64) -> i32 { @@ -4076,7 +4046,6 @@ pub unsafe fn Q6_p_vcmpw_eq_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpw, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpw_gt_PI(rss: i64) -> i32 { @@ -4089,7 +4058,6 @@ pub unsafe fn Q6_p_vcmpw_gt_PI(rss: i64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vcmpw, IU7 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_vcmpw_gtu_PI(rss: i64) -> i32 { @@ -4256,7 +4224,6 @@ pub unsafe fn Q6_p_bitsclr_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(bitsclr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_bitsclr_RI(rs: i32) -> i32 { @@ -4291,7 +4258,6 @@ pub unsafe fn Q6_p_cmp_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmp_eq_RI(rs: i32) -> i32 { @@ -4315,7 +4281,6 @@ pub unsafe fn Q6_p_cmp_eq_PP(rss: i64, rtt: i64) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmp_ge_RI(rs: i32) -> i32 { @@ -4328,7 +4293,6 @@ pub unsafe fn Q6_p_cmp_ge_RI(rs: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IU8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmp_geu_RI(rs: i32) -> i32 { @@ -4352,7 +4316,6 @@ pub unsafe fn Q6_p_cmp_gt_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmp_gt_RI(rs: i32) -> i32 { @@ -4387,7 +4350,6 @@ pub unsafe fn Q6_p_cmp_gtu_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cmp, IU9 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_cmp_gtu_RI(rs: i32) -> i32 { @@ -4455,7 +4417,6 @@ pub unsafe fn Q6_R_mux_pRR(pu: i32, rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1, 2)] #[cfg_attr(test, assert_instr(mux, IS8 = 0, IS8_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mux_pII(pu: i32) -> i32 { @@ -4469,7 +4430,6 @@ pub unsafe fn Q6_R_mux_pII(pu: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(mux, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mux_pRI(pu: i32, rs: i32) -> i32 { @@ -4482,7 +4442,6 @@ pub unsafe fn Q6_R_mux_pRI(pu: i32, rs: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(mux, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mux_pIR(pu: i32, rs: i32) -> i32 { @@ -4645,7 +4604,6 @@ pub unsafe fn Q6_p_not_cmp_gt_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_not_cmp_gt_RI(rs: i32) -> i32 { static_assert_simm_bits!(IS10, 10); @@ -4667,7 +4625,6 @@ pub unsafe fn Q6_p_not_cmp_gtu_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_not_cmp_gtu_RI(rs: i32) -> i32 { static_assert_uimm_bits!(IU9, 9); @@ -4689,7 +4646,6 @@ pub unsafe fn Q6_p_not_cmp_eq_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU32_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_not_cmp_eq_RI(rs: i32) -> i32 { static_assert_simm_bits!(IS10, 10); @@ -4732,7 +4688,6 @@ pub unsafe fn Q6_p_not_bitsclr_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_not_bitsclr_RI(rs: i32) -> i32 { static_assert_uimm_bits!(IU6, 6); @@ -5084,7 +5039,6 @@ pub unsafe fn Q6_R_convert_w2sf_R(rs: i32) -> f32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(dfclass, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_dfclass_PI(rss: f64) -> i32 { @@ -5141,7 +5095,6 @@ pub unsafe fn Q6_p_dfcmp_uo_PP(rss: f64, rtt: f64) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(dfmake, IU10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_dfmake_I_neg() -> f64 { @@ -5154,7 +5107,6 @@ pub unsafe fn Q6_P_dfmake_I_neg() -> f64 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(dfmake, IU10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_dfmake_I_pos() -> f64 { @@ -5178,7 +5130,6 @@ pub unsafe fn Q6_R_sfadd_RR(rs: f32, rt: f32) -> f32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(sfclass, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_sfclass_RI(rs: f32) -> i32 { @@ -5323,7 +5274,6 @@ pub unsafe fn Q6_R_sfmpynac_RR_lib(rx: f32, rs: f32, rt: f32) -> f32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(sfmake, IU10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_sfmake_I_neg() -> f32 { @@ -5336,7 +5286,6 @@ pub unsafe fn Q6_R_sfmake_I_neg() -> f32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(sfmake, IU10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_sfmake_I_pos() -> f32 { @@ -5404,7 +5353,6 @@ pub unsafe fn Q6_R_addacc_RR(rx: i32, rs: i32, rt: i32) -> i32 { /// Instruction Type: M /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(add, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_addacc_RI(rx: i32, rs: i32) -> i32 { @@ -5769,7 +5717,6 @@ pub unsafe fn Q6_R_mpyiacc_RR(rx: i32, rs: i32, rt: i32) -> i32 { /// Instruction Type: M /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(mpyi, IU8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mpyinac_RI(rx: i32, rs: i32) -> i32 { @@ -5782,7 +5729,6 @@ pub unsafe fn Q6_R_mpyinac_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: M /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(mpyi, IU8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mpyiacc_RI(rx: i32, rs: i32) -> i32 { @@ -7830,7 +7776,6 @@ pub unsafe fn Q6_R_addnac_RR(rx: i32, rs: i32, rt: i32) -> i32 { /// Instruction Type: M /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(add, IS8 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_addnac_RI(rx: i32, rs: i32) -> i32 { @@ -8459,7 +8404,6 @@ pub unsafe fn Q6_R_mpyacc_RR_s1_sat(rx: i32, rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(add, IU6 = 0, IU6_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_mpyi_IRI(rs: i32) -> i32 { @@ -8473,7 +8417,6 @@ pub unsafe fn Q6_R_add_mpyi_IRI(rs: i32) -> i3 /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(add, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_mpyi_RRI(ru: i32, rs: i32) -> i32 { @@ -8486,7 +8429,6 @@ pub unsafe fn Q6_R_add_mpyi_RRI(ru: i32, rs: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(add, IU6_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_mpyi_RIR(ru: i32, rs: i32) -> i32 { @@ -8499,7 +8441,6 @@ pub unsafe fn Q6_R_add_mpyi_RIR(ru: i32, rs: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(add, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_mpyi_IRR(rs: i32, rt: i32) -> i32 { @@ -8864,7 +8805,6 @@ pub unsafe fn Q6_P_vrmpybu_PP(rss: i64, rtt: i64) -> i64 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(addasl, IU3 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_addasl_RRI(rt: i32, rs: i32) -> i32 { @@ -8877,7 +8817,6 @@ pub unsafe fn Q6_R_addasl_RRI(rt: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asl_PI(rss: i64) -> i64 { @@ -8890,7 +8829,6 @@ pub unsafe fn Q6_P_asl_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_aslacc_PI(rxx: i64, rss: i64) -> i64 { @@ -8903,7 +8841,6 @@ pub unsafe fn Q6_P_aslacc_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asland_PI(rxx: i64, rss: i64) -> i64 { @@ -8916,7 +8853,6 @@ pub unsafe fn Q6_P_asland_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_aslnac_PI(rxx: i64, rss: i64) -> i64 { @@ -8929,7 +8865,6 @@ pub unsafe fn Q6_P_aslnac_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_aslor_PI(rxx: i64, rss: i64) -> i64 { @@ -8942,7 +8877,6 @@ pub unsafe fn Q6_P_aslor_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_aslxacc_PI(rxx: i64, rss: i64) -> i64 { @@ -8955,7 +8889,6 @@ pub unsafe fn Q6_P_aslxacc_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asl_RI(rs: i32) -> i32 { @@ -8968,7 +8901,6 @@ pub unsafe fn Q6_R_asl_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_aslacc_RI(rx: i32, rs: i32) -> i32 { @@ -8981,7 +8913,6 @@ pub unsafe fn Q6_R_aslacc_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asland_RI(rx: i32, rs: i32) -> i32 { @@ -8994,7 +8925,6 @@ pub unsafe fn Q6_R_asland_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_aslnac_RI(rx: i32, rs: i32) -> i32 { @@ -9007,7 +8937,6 @@ pub unsafe fn Q6_R_aslnac_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_aslor_RI(rx: i32, rs: i32) -> i32 { @@ -9020,7 +8949,6 @@ pub unsafe fn Q6_R_aslor_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asl_RI_sat(rs: i32) -> i32 { @@ -9033,7 +8961,6 @@ pub unsafe fn Q6_R_asl_RI_sat(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asl, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_aslxacc_RI(rx: i32, rs: i32) -> i32 { @@ -9046,7 +8973,6 @@ pub unsafe fn Q6_R_aslxacc_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vaslh, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vaslh_PI(rss: i64) -> i64 { @@ -9059,7 +8985,6 @@ pub unsafe fn Q6_P_vaslh_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vaslw, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vaslw_PI(rss: i64) -> i64 { @@ -9226,7 +9151,6 @@ pub unsafe fn Q6_P_vaslw_PR(rss: i64, rt: i32) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asr_PI(rss: i64) -> i64 { @@ -9239,7 +9163,6 @@ pub unsafe fn Q6_P_asr_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asracc_PI(rxx: i64, rss: i64) -> i64 { @@ -9252,7 +9175,6 @@ pub unsafe fn Q6_P_asracc_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asrand_PI(rxx: i64, rss: i64) -> i64 { @@ -9265,7 +9187,6 @@ pub unsafe fn Q6_P_asrand_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asrnac_PI(rxx: i64, rss: i64) -> i64 { @@ -9278,7 +9199,6 @@ pub unsafe fn Q6_P_asrnac_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asror_PI(rxx: i64, rss: i64) -> i64 { @@ -9291,7 +9211,6 @@ pub unsafe fn Q6_P_asror_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asr_PI_rnd(rss: i64) -> i64 { @@ -9304,7 +9223,6 @@ pub unsafe fn Q6_P_asr_PI_rnd(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asrrnd, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_asrrnd_PI(rss: i64) -> i64 { @@ -9317,7 +9235,6 @@ pub unsafe fn Q6_P_asrrnd_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asr_RI(rs: i32) -> i32 { @@ -9330,7 +9247,6 @@ pub unsafe fn Q6_R_asr_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asracc_RI(rx: i32, rs: i32) -> i32 { @@ -9343,7 +9259,6 @@ pub unsafe fn Q6_R_asracc_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asrand_RI(rx: i32, rs: i32) -> i32 { @@ -9356,7 +9271,6 @@ pub unsafe fn Q6_R_asrand_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asrnac_RI(rx: i32, rs: i32) -> i32 { @@ -9369,7 +9283,6 @@ pub unsafe fn Q6_R_asrnac_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asror_RI(rx: i32, rs: i32) -> i32 { @@ -9382,7 +9295,6 @@ pub unsafe fn Q6_R_asror_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asr_RI_rnd(rs: i32) -> i32 { @@ -9395,7 +9307,6 @@ pub unsafe fn Q6_R_asr_RI_rnd(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(asrrnd, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_asrrnd_RI(rs: i32) -> i32 { @@ -9408,7 +9319,6 @@ pub unsafe fn Q6_R_asrrnd_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrw, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_vasrw_PI(rss: i64) -> i32 { @@ -9421,7 +9331,6 @@ pub unsafe fn Q6_R_vasrw_PI(rss: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrh, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vasrh_PI(rss: i64) -> i64 { @@ -9434,7 +9343,6 @@ pub unsafe fn Q6_P_vasrh_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrw, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vasrw_PI(rss: i64) -> i64 { @@ -9711,7 +9619,6 @@ pub unsafe fn Q6_R_clb_P(rss: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(clrbit, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_clrbit_RI(rs: i32) -> i32 { @@ -9790,7 +9697,6 @@ pub unsafe fn Q6_P_deinterleave_P(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1, 2)] #[cfg_attr(test, assert_instr(extractu, IU5 = 0, IU5_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_extractu_RII(rs: i32) -> i32 { @@ -9815,7 +9721,6 @@ pub unsafe fn Q6_R_extractu_RP(rs: i32, rtt: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1, 2)] #[cfg_attr(test, assert_instr(extractu, IU6 = 0, IU6_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_extractu_PII(rss: i64) -> i64 { @@ -9840,7 +9745,6 @@ pub unsafe fn Q6_P_extractu_PP(rss: i64, rtt: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(insert, IU5 = 0, IU5_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_insert_RII(rx: i32, rs: i32) -> i32 { @@ -9865,7 +9769,6 @@ pub unsafe fn Q6_R_insert_RP(rx: i32, rs: i32, rtt: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(insert, IU6 = 0, IU6_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_insert_PII(rxx: i64, rss: i64) -> i64 { @@ -10055,7 +9958,6 @@ pub unsafe fn Q6_P_vlslw_PR(rss: i64, rt: i32) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsr_PI(rss: i64) -> i64 { @@ -10068,7 +9970,6 @@ pub unsafe fn Q6_P_lsr_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsracc_PI(rxx: i64, rss: i64) -> i64 { @@ -10081,7 +9982,6 @@ pub unsafe fn Q6_P_lsracc_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsrand_PI(rxx: i64, rss: i64) -> i64 { @@ -10094,7 +9994,6 @@ pub unsafe fn Q6_P_lsrand_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsrnac_PI(rxx: i64, rss: i64) -> i64 { @@ -10107,7 +10006,6 @@ pub unsafe fn Q6_P_lsrnac_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsror_PI(rxx: i64, rss: i64) -> i64 { @@ -10120,7 +10018,6 @@ pub unsafe fn Q6_P_lsror_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_lsrxacc_PI(rxx: i64, rss: i64) -> i64 { @@ -10133,7 +10030,6 @@ pub unsafe fn Q6_P_lsrxacc_PI(rxx: i64, rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsr_RI(rs: i32) -> i32 { @@ -10146,7 +10042,6 @@ pub unsafe fn Q6_R_lsr_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsracc_RI(rx: i32, rs: i32) -> i32 { @@ -10159,7 +10054,6 @@ pub unsafe fn Q6_R_lsracc_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsrand_RI(rx: i32, rs: i32) -> i32 { @@ -10172,7 +10066,6 @@ pub unsafe fn Q6_R_lsrand_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsrnac_RI(rx: i32, rs: i32) -> i32 { @@ -10185,7 +10078,6 @@ pub unsafe fn Q6_R_lsrnac_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsror_RI(rx: i32, rs: i32) -> i32 { @@ -10198,7 +10090,6 @@ pub unsafe fn Q6_R_lsror_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(lsr, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsrxacc_RI(rx: i32, rs: i32) -> i32 { @@ -10211,7 +10102,6 @@ pub unsafe fn Q6_R_lsrxacc_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vlsrh, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vlsrh_PI(rss: i64) -> i64 { @@ -10224,7 +10114,6 @@ pub unsafe fn Q6_P_vlsrh_PI(rss: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vlsrw, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vlsrw_PI(rss: i64) -> i64 { @@ -10402,7 +10291,6 @@ pub unsafe fn Q6_R_parity_PP(rss: i64, rtt: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(setbit, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_setbit_RI(rs: i32) -> i32 { @@ -10492,7 +10380,6 @@ pub unsafe fn Q6_R_vsathub_R(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(tableidxb, IU4 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_tableidxb_RII(rx: i32, rs: i32) -> i32 { @@ -10506,7 +10393,6 @@ pub unsafe fn Q6_R_tableidxb_RII(rx: i32, rs: i3 /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(tableidxd, IU4 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_tableidxd_RII(rx: i32, rs: i32) -> i32 { @@ -10520,7 +10406,6 @@ pub unsafe fn Q6_R_tableidxd_RII(rx: i32, rs: i3 /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(tableidxh, IU4 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_tableidxh_RII(rx: i32, rs: i32) -> i32 { @@ -10534,7 +10419,6 @@ pub unsafe fn Q6_R_tableidxh_RII(rx: i32, rs: i3 /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(2, 3)] #[cfg_attr(test, assert_instr(tableidxw, IU4 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_tableidxw_RII(rx: i32, rs: i32) -> i32 { @@ -10548,7 +10432,6 @@ pub unsafe fn Q6_R_tableidxw_RII(rx: i32, rs: i3 /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(togglebit, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_togglebit_RI(rs: i32) -> i32 { @@ -10572,7 +10455,6 @@ pub unsafe fn Q6_R_togglebit_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(tstbit, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_tstbit_RI(rs: i32) -> i32 { @@ -10596,7 +10478,6 @@ pub unsafe fn Q6_p_tstbit_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(valignb, IU3 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_valignb_PPI(rtt: i64, rss: i64) -> i64 { @@ -10785,7 +10666,6 @@ pub unsafe fn Q6_P_vsplath_R(rs: i32) -> i64 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vspliceb, IU3 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vspliceb_PPI(rss: i64, rtt: i64) -> i64 { @@ -10897,7 +10777,6 @@ pub unsafe fn Q6_P_vzxthw_R(rs: i32) -> i64 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(add, IS6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_add_RRI(rs: i32, ru: i32) -> i32 { @@ -10910,7 +10789,6 @@ pub unsafe fn Q6_R_add_add_RRI(rs: i32, ru: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(add, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_asl_IRI(rx: i32) -> i32 { @@ -10924,7 +10802,6 @@ pub unsafe fn Q6_R_add_asl_IRI(rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(add, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_lsr_IRI(rx: i32) -> i32 { @@ -10938,7 +10815,6 @@ pub unsafe fn Q6_R_add_lsr_IRI(rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(and, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_and_asl_IRI(rx: i32) -> i32 { @@ -10952,7 +10828,6 @@ pub unsafe fn Q6_R_and_asl_IRI(rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(and, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_and_lsr_IRI(rx: i32) -> i32 { @@ -10966,7 +10841,6 @@ pub unsafe fn Q6_R_and_lsr_IRI(rx: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(add, IS6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_clb_RI(rs: i32) -> i32 { @@ -10979,7 +10853,6 @@ pub unsafe fn Q6_R_add_clb_RI(rs: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(add, IS6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_clb_PI(rss: i64) -> i32 { @@ -11003,7 +10876,6 @@ pub unsafe fn Q6_R_normamt_P(rss: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1, 2)] #[cfg_attr(test, assert_instr(extract, IU5 = 0, IU5_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_extract_RII(rs: i32) -> i32 { @@ -11028,7 +10900,6 @@ pub unsafe fn Q6_R_extract_RP(rs: i32, rtt: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1, 2)] #[cfg_attr(test, assert_instr(extract, IU6 = 0, IU6_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_extract_PII(rss: i64) -> i64 { @@ -11053,7 +10924,6 @@ pub unsafe fn Q6_P_extract_PP(rss: i64, rtt: i64) -> i64 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0)] #[cfg_attr(test, assert_instr(lsl, IS6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_lsl_IR(rt: i32) -> i32 { @@ -11066,7 +10936,6 @@ pub unsafe fn Q6_R_lsl_IR(rt: i32) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_p_not_tstbit_RI(rs: i32) -> i32 { static_assert_uimm_bits!(IU5, 5); @@ -11088,7 +10957,6 @@ pub unsafe fn Q6_p_not_tstbit_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(and, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_andor_RI(rx: i32, rs: i32) -> i32 { @@ -11101,7 +10969,6 @@ pub unsafe fn Q6_R_andor_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(or, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_or_and_RRI(ru: i32, rx: i32) -> i32 { @@ -11114,7 +10981,6 @@ pub unsafe fn Q6_R_or_and_RRI(ru: i32, rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(or, IS10 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_oror_RI(rx: i32, rs: i32) -> i32 { @@ -11127,7 +10993,6 @@ pub unsafe fn Q6_R_oror_RI(rx: i32, rs: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(or, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_or_asl_IRI(rx: i32) -> i32 { @@ -11141,7 +11006,6 @@ pub unsafe fn Q6_R_or_asl_IRI(rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(or, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_or_lsr_IRI(rx: i32) -> i32 { @@ -11166,7 +11030,6 @@ pub unsafe fn Q6_R_parity_RR(rs: i32, rt: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(add, IS6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_add_sub_RIR(rs: i32, ru: i32) -> i32 { @@ -11179,7 +11042,6 @@ pub unsafe fn Q6_R_add_sub_RIR(rs: i32, ru: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(sub, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_sub_asl_IRI(rx: i32) -> i32 { @@ -11193,7 +11055,6 @@ pub unsafe fn Q6_R_sub_asl_IRI(rx: i32) -> i32 { /// Instruction Type: ALU64 /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(0, 2)] #[cfg_attr(test, assert_instr(sub, IU8 = 0, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_sub_lsr_IRI(rx: i32) -> i32 { @@ -11207,7 +11068,6 @@ pub unsafe fn Q6_R_sub_lsr_IRI(rx: i32) -> i32 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vrcrotate, IU2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vrcrotate_PRI(rss: i64, rt: i32) -> i64 { @@ -11220,7 +11080,6 @@ pub unsafe fn Q6_P_vrcrotate_PRI(rss: i64, rt: i32) -> i64 { /// Instruction Type: S_3op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vrcrotate, IU2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vrcrotateacc_PRI(rxx: i64, rss: i64, rt: i32) -> i64 { @@ -11299,7 +11158,6 @@ pub unsafe fn Q6_P_vxsubaddw_PP_sat(rss: i64, rtt: i64) -> i64 { /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrhub, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_vasrhub_PI_rnd_sat(rss: i64) -> i32 { @@ -11312,7 +11170,6 @@ pub unsafe fn Q6_R_vasrhub_PI_rnd_sat(rss: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT23 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrhub, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_vasrhub_PI_sat(rss: i64) -> i32 { @@ -11336,7 +11193,6 @@ pub unsafe fn Q6_R_popcount_P(rss: i64) -> i32 { /// Instruction Type: S_2op /// Execution Slots: SLOT0123 #[inline(always)] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vasrh, IU4 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vasrh_PI_rnd(rss: i64) -> i64 { @@ -11428,7 +11284,6 @@ pub unsafe fn Q6_l2fetch_AP(rs: i32, rtt: i64) { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_rol_PI(rss: i64) -> i64 { @@ -11443,7 +11298,6 @@ pub unsafe fn Q6_P_rol_PI(rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_rolacc_PI(rxx: i64, rss: i64) -> i64 { @@ -11458,7 +11312,6 @@ pub unsafe fn Q6_P_rolacc_PI(rxx: i64, rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_roland_PI(rxx: i64, rss: i64) -> i64 { @@ -11473,7 +11326,6 @@ pub unsafe fn Q6_P_roland_PI(rxx: i64, rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_rolnac_PI(rxx: i64, rss: i64) -> i64 { @@ -11488,7 +11340,6 @@ pub unsafe fn Q6_P_rolnac_PI(rxx: i64, rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_rolor_PI(rxx: i64, rss: i64) -> i64 { @@ -11503,7 +11354,6 @@ pub unsafe fn Q6_P_rolor_PI(rxx: i64, rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_rolxacc_PI(rxx: i64, rss: i64) -> i64 { @@ -11518,7 +11368,6 @@ pub unsafe fn Q6_P_rolxacc_PI(rxx: i64, rss: i64) -> i64 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_rol_RI(rs: i32) -> i32 { @@ -11533,7 +11382,6 @@ pub unsafe fn Q6_R_rol_RI(rs: i32) -> i32 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_rolacc_RI(rx: i32, rs: i32) -> i32 { @@ -11548,7 +11396,6 @@ pub unsafe fn Q6_R_rolacc_RI(rx: i32, rs: i32) -> i32 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_roland_RI(rx: i32, rs: i32) -> i32 { @@ -11563,7 +11410,6 @@ pub unsafe fn Q6_R_roland_RI(rx: i32, rs: i32) -> i32 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_rolnac_RI(rx: i32, rs: i32) -> i32 { @@ -11578,7 +11424,6 @@ pub unsafe fn Q6_R_rolnac_RI(rx: i32, rs: i32) -> i32 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_rolor_RI(rx: i32, rs: i32) -> i32 { @@ -11593,7 +11438,6 @@ pub unsafe fn Q6_R_rolor_RI(rx: i32, rs: i32) -> i32 { /// Requires: V60 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v60"))] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(rol, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_rolxacc_RI(rx: i32, rs: i32) -> i32 { @@ -11724,7 +11568,6 @@ pub unsafe fn Q6_R_mpyinac_RR(rx: i32, rs: i32, rt: i32) -> i32 { /// Requires: V66 #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v66"))] -#[rustc_legacy_const_generics(0, 1)] #[cfg_attr(test, assert_instr(mask, IU5 = 0, IU5_2 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_mask_II() -> i32 { @@ -11740,7 +11583,6 @@ pub unsafe fn Q6_R_mask_II() -> i32 { /// Requires: V67, Audio #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v67,audio"))] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(clip, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_R_clip_RI(rs: i32) -> i32 { @@ -11755,7 +11597,6 @@ pub unsafe fn Q6_R_clip_RI(rs: i32) -> i32 { /// Requires: V67, Audio #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v67,audio"))] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(cround, IU6 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_cround_PI(rss: i64) -> i64 { @@ -11783,7 +11624,6 @@ pub unsafe fn Q6_P_cround_PR(rss: i64, rt: i32) -> i64 { /// Requires: V67, Audio #[inline] #[cfg_attr(target_arch = "hexagon", target_feature(enable = "v67,audio"))] -#[rustc_legacy_const_generics(1)] #[cfg_attr(test, assert_instr(vclip, IU5 = 0))] #[unstable(feature = "stdarch_hexagon", issue = "151523")] pub unsafe fn Q6_P_vclip_PI(rss: i64) -> i64 { diff --git a/library/stdarch/crates/core_arch/src/lib.rs b/library/stdarch/crates/core_arch/src/lib.rs index c2357eaab5aa0..b95f92c6f9e4f 100644 --- a/library/stdarch/crates/core_arch/src/lib.rs +++ b/library/stdarch/crates/core_arch/src/lib.rs @@ -40,7 +40,9 @@ movrs_target_feature, clflushopt_target_feature, min_adt_const_params, - num_internals + num_internals, + f16b, + cfg_target_has_reliable_f16b )] #![cfg_attr( any(target_arch = "powerpc", target_arch = "powerpc64"), diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs index 75b79398bf9c7..ec1d6dc502529 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs @@ -167,14 +167,6 @@ unsafe extern "llvm-intrinsic" { fn __lasx_xvbitsel_v(a: __v32u8, b: __v32u8, c: __v32u8) -> __v32u8; #[link_name = "llvm.loongarch.lasx.xvbitseli.b"] fn __lasx_xvbitseli_b(a: __v32u8, b: __v32u8, c: u32) -> __v32u8; - #[link_name = "llvm.loongarch.lasx.xvclo.b"] - fn __lasx_xvclo_b(a: __v32i8) -> __v32i8; - #[link_name = "llvm.loongarch.lasx.xvclo.h"] - fn __lasx_xvclo_h(a: __v16i16) -> __v16i16; - #[link_name = "llvm.loongarch.lasx.xvclo.w"] - fn __lasx_xvclo_w(a: __v8i32) -> __v8i32; - #[link_name = "llvm.loongarch.lasx.xvclo.d"] - fn __lasx_xvclo_d(a: __v4i64) -> __v4i64; #[link_name = "llvm.loongarch.lasx.xvfcvt.h.s"] fn __lasx_xvfcvt_h_s(a: __v8f32, b: __v8f32) -> __v16i16; #[link_name = "llvm.loongarch.lasx.xvfcvt.s.d"] @@ -941,35 +933,35 @@ unsafe extern "llvm-intrinsic" { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrar_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrar_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrar_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrar_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrar_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrar_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrar_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrar_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrari_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsrari_b(transmute(a), IMM3)) } @@ -977,7 +969,7 @@ pub fn lasx_xvsrari_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrari_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrari_h(transmute(a), IMM4)) } @@ -985,7 +977,7 @@ pub fn lasx_xvsrari_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrari_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrari_w(transmute(a), IMM5)) } @@ -993,7 +985,7 @@ pub fn lasx_xvsrari_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrari_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrari_d(transmute(a), IMM6)) } @@ -1001,35 +993,35 @@ pub fn lasx_xvsrari_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlr_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlr_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlr_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlr_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlr_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlr_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlr_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlr_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlri_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsrlri_b(transmute(a), IMM3)) } @@ -1037,7 +1029,7 @@ pub fn lasx_xvsrlri_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlri_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrlri_h(transmute(a), IMM4)) } @@ -1045,7 +1037,7 @@ pub fn lasx_xvsrlri_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlri_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrlri_w(transmute(a), IMM5)) } @@ -1053,7 +1045,7 @@ pub fn lasx_xvsrlri_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlri_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrlri_d(transmute(a), IMM6)) } @@ -1061,7 +1053,7 @@ pub fn lasx_xvsrlri_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitclri_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvbitclri_b(transmute(a), IMM3)) } @@ -1069,7 +1061,7 @@ pub fn lasx_xvbitclri_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitclri_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvbitclri_h(transmute(a), IMM4)) } @@ -1077,7 +1069,7 @@ pub fn lasx_xvbitclri_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitclri_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvbitclri_w(transmute(a), IMM5)) } @@ -1085,7 +1077,7 @@ pub fn lasx_xvbitclri_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitclri_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvbitclri_d(transmute(a), IMM6)) } @@ -1093,7 +1085,7 @@ pub fn lasx_xvbitclri_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitseti_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvbitseti_b(transmute(a), IMM3)) } @@ -1101,7 +1093,7 @@ pub fn lasx_xvbitseti_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitseti_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvbitseti_h(transmute(a), IMM4)) } @@ -1109,7 +1101,7 @@ pub fn lasx_xvbitseti_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitseti_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvbitseti_w(transmute(a), IMM5)) } @@ -1117,7 +1109,7 @@ pub fn lasx_xvbitseti_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitseti_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvbitseti_d(transmute(a), IMM6)) } @@ -1125,7 +1117,7 @@ pub fn lasx_xvbitseti_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitrevi_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvbitrevi_b(transmute(a), IMM3)) } @@ -1133,7 +1125,7 @@ pub fn lasx_xvbitrevi_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitrevi_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvbitrevi_h(transmute(a), IMM4)) } @@ -1141,7 +1133,7 @@ pub fn lasx_xvbitrevi_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitrevi_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvbitrevi_w(transmute(a), IMM5)) } @@ -1149,7 +1141,7 @@ pub fn lasx_xvbitrevi_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitrevi_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvbitrevi_d(transmute(a), IMM6)) } @@ -1157,7 +1149,7 @@ pub fn lasx_xvbitrevi_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubi_bu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsubi_bu(transmute(a), IMM5)) } @@ -1165,7 +1157,7 @@ pub fn lasx_xvsubi_bu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubi_hu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsubi_hu(transmute(a), IMM5)) } @@ -1173,7 +1165,7 @@ pub fn lasx_xvsubi_hu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubi_wu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsubi_wu(transmute(a), IMM5)) } @@ -1181,7 +1173,7 @@ pub fn lasx_xvsubi_wu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubi_du(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsubi_du(transmute(a), IMM5)) } @@ -1189,7 +1181,7 @@ pub fn lasx_xvsubi_du(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsat_b(transmute(a), IMM3)) } @@ -1197,7 +1189,7 @@ pub fn lasx_xvsat_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsat_h(transmute(a), IMM4)) } @@ -1205,7 +1197,7 @@ pub fn lasx_xvsat_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsat_w(transmute(a), IMM5)) } @@ -1213,7 +1205,7 @@ pub fn lasx_xvsat_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsat_d(transmute(a), IMM6)) } @@ -1221,7 +1213,7 @@ pub fn lasx_xvsat_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_bu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsat_bu(transmute(a), IMM3)) } @@ -1229,7 +1221,7 @@ pub fn lasx_xvsat_bu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_hu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsat_hu(transmute(a), IMM4)) } @@ -1237,7 +1229,7 @@ pub fn lasx_xvsat_hu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_wu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsat_wu(transmute(a), IMM5)) } @@ -1245,7 +1237,7 @@ pub fn lasx_xvsat_wu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsat_du(a: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsat_du(transmute(a), IMM6)) } @@ -1253,231 +1245,231 @@ pub fn lasx_xvsat_du(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvdiv_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvdiv_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_hu_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_hu_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_wu_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_wu_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_du_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_du_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_hu_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_hu_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_wu_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_wu_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_du_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_du_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmod_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmod_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvshuf_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvshuf_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvshuf_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvshuf_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvshuf_w(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvshuf_w(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvshuf_d(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvshuf_d(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvandi_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvandi_b(transmute(a), IMM8)) } @@ -1485,7 +1477,7 @@ pub fn lasx_xvandi_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvori_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvori_b(transmute(a), IMM8)) } @@ -1493,7 +1485,7 @@ pub fn lasx_xvori_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvnori_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvnori_b(transmute(a), IMM8)) } @@ -1501,7 +1493,7 @@ pub fn lasx_xvnori_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvxori_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvxori_b(transmute(a), IMM8)) } @@ -1509,14 +1501,14 @@ pub fn lasx_xvxori_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitsel_v(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvbitsel_v(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvbitseli_b(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvbitseli_b(transmute(a), transmute(b), IMM8)) } @@ -1524,315 +1516,287 @@ pub fn lasx_xvbitseli_b(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lasx_xvclo_b(a: m256i) -> m256i { - unsafe { transmute(__lasx_xvclo_b(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lasx_xvclo_h(a: m256i) -> m256i { - unsafe { transmute(__lasx_xvclo_h(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lasx_xvclo_w(a: m256i) -> m256i { - unsafe { transmute(__lasx_xvclo_w(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lasx_xvclo_d(a: m256i) -> m256i { - unsafe { transmute(__lasx_xvclo_d(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvt_h_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcvt_h_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvt_s_d(a: m256d, b: m256d) -> m256 { unsafe { transmute(__lasx_xvfcvt_s_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmin_s(a: m256, b: m256) -> m256 { unsafe { transmute(__lasx_xvfmin_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmin_d(a: m256d, b: m256d) -> m256d { unsafe { transmute(__lasx_xvfmin_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmina_s(a: m256, b: m256) -> m256 { unsafe { transmute(__lasx_xvfmina_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmina_d(a: m256d, b: m256d) -> m256d { unsafe { transmute(__lasx_xvfmina_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmax_s(a: m256, b: m256) -> m256 { unsafe { transmute(__lasx_xvfmax_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmax_d(a: m256d, b: m256d) -> m256d { unsafe { transmute(__lasx_xvfmax_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmaxa_s(a: m256, b: m256) -> m256 { unsafe { transmute(__lasx_xvfmaxa_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfmaxa_d(a: m256d, b: m256d) -> m256d { unsafe { transmute(__lasx_xvfmaxa_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfclass_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvfclass_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfclass_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvfclass_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrecipe_s(a: m256) -> m256 { unsafe { transmute(__lasx_xvfrecipe_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrecipe_d(a: m256d) -> m256d { unsafe { transmute(__lasx_xvfrecipe_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrsqrte_s(a: m256) -> m256 { unsafe { transmute(__lasx_xvfrsqrte_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrsqrte_d(a: m256d) -> m256d { unsafe { transmute(__lasx_xvfrsqrte_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrint_s(a: m256) -> m256 { unsafe { transmute(__lasx_xvfrint_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrint_d(a: m256d) -> m256d { unsafe { transmute(__lasx_xvfrint_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvflogb_s(a: m256) -> m256 { unsafe { transmute(__lasx_xvflogb_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvflogb_d(a: m256d) -> m256d { unsafe { transmute(__lasx_xvflogb_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvth_s_h(a: m256i) -> m256 { unsafe { transmute(__lasx_xvfcvth_s_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvth_d_s(a: m256) -> m256d { unsafe { transmute(__lasx_xvfcvth_d_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvtl_s_h(a: m256i) -> m256 { unsafe { transmute(__lasx_xvfcvtl_s_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcvtl_d_s(a: m256) -> m256d { unsafe { transmute(__lasx_xvfcvtl_d_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftint_w_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftint_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftint_l_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftint_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftint_wu_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftint_wu_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftint_lu_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftint_lu_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrz_w_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrz_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrz_l_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrz_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrz_wu_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrz_wu_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrz_lu_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrz_lu_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffint_s_w(a: m256i) -> m256 { unsafe { transmute(__lasx_xvffint_s_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffint_d_l(a: m256i) -> m256d { unsafe { transmute(__lasx_xvffint_d_l(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffint_s_wu(a: m256i) -> m256 { unsafe { transmute(__lasx_xvffint_s_wu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffint_d_lu(a: m256i) -> m256d { unsafe { transmute(__lasx_xvffint_d_lu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvreplve_b(a: m256i, b: i32) -> m256i { unsafe { transmute(__lasx_xvreplve_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvreplve_h(a: m256i, b: i32) -> m256i { unsafe { transmute(__lasx_xvreplve_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvreplve_w(a: m256i, b: i32) -> m256i { unsafe { transmute(__lasx_xvreplve_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvreplve_d(a: m256i, b: i32) -> m256i { unsafe { transmute(__lasx_xvreplve_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpermi_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvpermi_w(transmute(a), transmute(b), IMM8)) } @@ -1840,7 +1804,7 @@ pub fn lasx_xvpermi_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_h_b(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsllwil_h_b(transmute(a), IMM3)) } @@ -1848,7 +1812,7 @@ pub fn lasx_xvsllwil_h_b(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_w_h(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsllwil_w_h(transmute(a), IMM4)) } @@ -1856,7 +1820,7 @@ pub fn lasx_xvsllwil_w_h(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_d_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsllwil_d_w(transmute(a), IMM5)) } @@ -1864,7 +1828,7 @@ pub fn lasx_xvsllwil_d_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_hu_bu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvsllwil_hu_bu(transmute(a), IMM3)) } @@ -1872,7 +1836,7 @@ pub fn lasx_xvsllwil_hu_bu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_wu_hu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsllwil_wu_hu(transmute(a), IMM4)) } @@ -1880,7 +1844,7 @@ pub fn lasx_xvsllwil_wu_hu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsllwil_du_wu(a: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsllwil_du_wu(transmute(a), IMM5)) } @@ -1888,217 +1852,217 @@ pub fn lasx_xvsllwil_du_wu(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsran_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsran_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsran_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsran_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsran_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsran_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_bu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_hu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssran_wu_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssran_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarn_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrarn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarn_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrarn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarn_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrarn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_bu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_hu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarn_wu_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrarn_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrln_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrln_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrln_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrln_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrln_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrln_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_bu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_hu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_wu_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrn_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlrn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrn_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlrn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrn_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsrlrn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_bu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_hu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_wu_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrstpi_b(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvfrstpi_b(transmute(a), transmute(b), IMM5)) } @@ -2106,7 +2070,7 @@ pub fn lasx_xvfrstpi_b(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrstpi_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvfrstpi_h(transmute(a), transmute(b), IMM5)) } @@ -2114,21 +2078,21 @@ pub fn lasx_xvfrstpi_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrstp_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvfrstp_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrstp_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvfrstp_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvshuf4i_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvshuf4i_d(transmute(a), transmute(b), IMM8)) } @@ -2136,7 +2100,7 @@ pub fn lasx_xvshuf4i_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextrins_b(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvextrins_b(transmute(a), transmute(b), IMM8)) } @@ -2144,7 +2108,7 @@ pub fn lasx_xvextrins_b(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextrins_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvextrins_h(transmute(a), transmute(b), IMM8)) } @@ -2152,7 +2116,7 @@ pub fn lasx_xvextrins_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextrins_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvextrins_w(transmute(a), transmute(b), IMM8)) } @@ -2160,7 +2124,7 @@ pub fn lasx_xvextrins_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextrins_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvextrins_d(transmute(a), transmute(b), IMM8)) } @@ -2168,245 +2132,245 @@ pub fn lasx_xvextrins_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmskltz_b(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmskltz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmskltz_h(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmskltz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmskltz_w(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmskltz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmskltz_d(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmskltz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsigncov_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsigncov_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsigncov_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsigncov_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsigncov_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsigncov_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsigncov_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsigncov_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrne_w_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrne_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrne_l_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrne_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrp_w_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrp_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrp_l_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrp_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrm_w_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrm_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrm_l_d(a: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrm_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftint_w_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvftint_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffint_s_l(a: m256i, b: m256i) -> m256 { unsafe { transmute(__lasx_xvffint_s_l(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrz_w_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrz_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrp_w_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrp_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrm_w_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrm_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrne_w_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvftintrne_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftinth_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftinth_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintl_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffinth_d_w(a: m256i) -> m256d { unsafe { transmute(__lasx_xvffinth_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvffintl_d_w(a: m256i) -> m256d { unsafe { transmute(__lasx_xvffintl_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrzh_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrzh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrzl_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrzl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrph_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrph_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrpl_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrpl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrmh_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrmh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrml_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrml_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrneh_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrneh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvftintrnel_l_s(a: m256) -> m256i { unsafe { transmute(__lasx_xvftintrnel_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrintrne_s(a: m256) -> m256 { unsafe { transmute(__lasx_xvfrintrne_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfrintrne_d(a: m256d) -> m256d { unsafe { transmute(__lasx_xvfrintrne_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvstelm_b(a: m256i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM4, 4); @@ -2415,7 +2379,7 @@ pub unsafe fn lasx_xvstelm_b(a: m256i, mem_a #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvstelm_h(a: m256i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM3, 3); @@ -2424,7 +2388,7 @@ pub unsafe fn lasx_xvstelm_h(a: m256i, mem_a #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvstelm_w(a: m256i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM2, 2); @@ -2433,7 +2397,7 @@ pub unsafe fn lasx_xvstelm_w(a: m256i, mem_a #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvstelm_d(a: m256i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM1, 1); @@ -2442,7 +2406,7 @@ pub unsafe fn lasx_xvstelm_d(a: m256i, mem_a #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvinsve0_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvinsve0_w(transmute(a), transmute(b), IMM3)) } @@ -2450,7 +2414,7 @@ pub fn lasx_xvinsve0_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvinsve0_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM2, 2); unsafe { transmute(__lasx_xvinsve0_d(transmute(a), transmute(b), IMM2)) } @@ -2458,7 +2422,7 @@ pub fn lasx_xvinsve0_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpickve_w(a: m256i) -> m256i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvpickve_w(transmute(a), IMM3)) } @@ -2466,7 +2430,7 @@ pub fn lasx_xvpickve_w(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpickve_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM2, 2); unsafe { transmute(__lasx_xvpickve_d(transmute(a), IMM2)) } @@ -2474,140 +2438,140 @@ pub fn lasx_xvpickve_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrn_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrlrn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_b_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_h_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrln_w_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvssrln_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextl_qu_du(a: m256i) -> m256i { unsafe { transmute(__lasx_xvextl_qu_du(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_h_b(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_h_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_w_h(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_w_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_d_w(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_w_b(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_w_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_d_h(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_d_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_d_b(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_d_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_hu_bu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_hu_bu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_wu_hu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_wu_hu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_du_wu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_du_wu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_wu_bu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_wu_bu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_du_hu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_du_hu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_vext2xv_du_bu(a: m256i) -> m256i { unsafe { transmute(__lasx_vext2xv_du_bu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpermi_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvpermi_q(transmute(a), transmute(b), IMM8)) } @@ -2615,7 +2579,7 @@ pub fn lasx_xvpermi_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpermi_d(a: m256i) -> m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lasx_xvpermi_d(transmute(a), IMM8)) } @@ -2623,14 +2587,14 @@ pub fn lasx_xvpermi_d(a: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvperm_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvperm_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvldrepl_b(mem_addr: *const i8) -> m256i { static_assert_simm_bits!(IMM_S12, 12); transmute(__lasx_xvldrepl_b(mem_addr, IMM_S12)) @@ -2638,7 +2602,7 @@ pub unsafe fn lasx_xvldrepl_b(mem_addr: *const i8) -> m256i #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvldrepl_h(mem_addr: *const i8) -> m256i { static_assert_simm_bits!(IMM_S11, 11); transmute(__lasx_xvldrepl_h(mem_addr, IMM_S11)) @@ -2646,7 +2610,7 @@ pub unsafe fn lasx_xvldrepl_h(mem_addr: *const i8) -> m256i #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvldrepl_w(mem_addr: *const i8) -> m256i { static_assert_simm_bits!(IMM_S10, 10); transmute(__lasx_xvldrepl_w(mem_addr, IMM_S10)) @@ -2654,7 +2618,7 @@ pub unsafe fn lasx_xvldrepl_w(mem_addr: *const i8) -> m256i #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lasx_xvldrepl_d(mem_addr: *const i8) -> m256i { static_assert_simm_bits!(IMM_S9, 9); transmute(__lasx_xvldrepl_d(mem_addr, IMM_S9)) @@ -2662,455 +2626,455 @@ pub unsafe fn lasx_xvldrepl_d(mem_addr: *const i8) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwev_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsubwod_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsubwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_d_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_w_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_h_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_q_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_d_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_w_hu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_h_bu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_d_wu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_w_hu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_h_bu_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_d_wu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_w_hu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_h_bu_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_d_wu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_w_hu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_h_bu_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_d_wu_w(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_w_hu_h(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_h_bu_b(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhaddw_qu_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhaddw_qu_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_q_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvhsubw_qu_du(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_qu_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_q_d(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_q_d( @@ -3123,7 +3087,7 @@ pub fn lasx_xvmaddwev_q_d(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_d_w(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_d_w( @@ -3136,7 +3100,7 @@ pub fn lasx_xvmaddwev_d_w(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_w_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_w_h( @@ -3149,7 +3113,7 @@ pub fn lasx_xvmaddwev_w_h(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_h_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_h_b( @@ -3162,7 +3126,7 @@ pub fn lasx_xvmaddwev_h_b(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_q_du(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_q_du( @@ -3175,7 +3139,7 @@ pub fn lasx_xvmaddwev_q_du(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_d_wu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_d_wu( @@ -3188,7 +3152,7 @@ pub fn lasx_xvmaddwev_d_wu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_w_hu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_w_hu( @@ -3201,7 +3165,7 @@ pub fn lasx_xvmaddwev_w_hu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_h_bu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_h_bu( @@ -3214,7 +3178,7 @@ pub fn lasx_xvmaddwev_h_bu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_q_d(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_q_d( @@ -3227,7 +3191,7 @@ pub fn lasx_xvmaddwod_q_d(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_d_w(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_d_w( @@ -3240,7 +3204,7 @@ pub fn lasx_xvmaddwod_d_w(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_w_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_w_h( @@ -3253,7 +3217,7 @@ pub fn lasx_xvmaddwod_w_h(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_h_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_h_b( @@ -3266,7 +3230,7 @@ pub fn lasx_xvmaddwod_h_b(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_q_du(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_q_du( @@ -3279,7 +3243,7 @@ pub fn lasx_xvmaddwod_q_du(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_d_wu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_d_wu( @@ -3292,7 +3256,7 @@ pub fn lasx_xvmaddwod_d_wu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_w_hu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_w_hu( @@ -3305,7 +3269,7 @@ pub fn lasx_xvmaddwod_w_hu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_h_bu(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_h_bu( @@ -3318,7 +3282,7 @@ pub fn lasx_xvmaddwod_h_bu(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_q_du_d(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_q_du_d( @@ -3331,7 +3295,7 @@ pub fn lasx_xvmaddwev_q_du_d(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_d_wu_w(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_d_wu_w( @@ -3344,7 +3308,7 @@ pub fn lasx_xvmaddwev_d_wu_w(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_w_hu_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_w_hu_h( @@ -3357,7 +3321,7 @@ pub fn lasx_xvmaddwev_w_hu_h(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwev_h_bu_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwev_h_bu_b( @@ -3370,7 +3334,7 @@ pub fn lasx_xvmaddwev_h_bu_b(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_q_du_d(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_q_du_d( @@ -3383,7 +3347,7 @@ pub fn lasx_xvmaddwod_q_du_d(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_d_wu_w(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_d_wu_w( @@ -3396,7 +3360,7 @@ pub fn lasx_xvmaddwod_d_wu_w(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_w_hu_h(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_w_hu_h( @@ -3409,7 +3373,7 @@ pub fn lasx_xvmaddwod_w_hu_h(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmaddwod_h_bu_b(a: m256i, b: m256i, c: m256i) -> m256i { unsafe { transmute(__lasx_xvmaddwod_h_bu_b( @@ -3422,126 +3386,126 @@ pub fn lasx_xvmaddwod_h_bu_b(a: m256i, b: m256i, c: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvadd_q(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvadd_q(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsub_q(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvsub_q(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwev_q_du_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwev_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvaddwod_q_du_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvaddwod_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwev_q_du_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwev_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmulwod_q_du_d(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvmulwod_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmskgez_b(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmskgez_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvmsknz_b(a: m256i) -> m256i { unsafe { transmute(__lasx_xvmsknz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_h_b(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_h_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_w_h(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_w_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_d_w(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_q_d(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_q_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_hu_bu(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_hu_bu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_wu_hu(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_wu_hu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_du_wu(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_du_wu(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvexth_qu_du(a: m256i) -> m256i { unsafe { transmute(__lasx_xvexth_qu_du(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvextl_q_d(a: m256i) -> m256i { unsafe { transmute(__lasx_xvextl_q_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrlni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3549,7 +3513,7 @@ pub fn lasx_xvsrlni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrlni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3557,7 +3521,7 @@ pub fn lasx_xvsrlni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrlni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3565,7 +3529,7 @@ pub fn lasx_xvsrlni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvsrlni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3573,7 +3537,7 @@ pub fn lasx_xvsrlni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrlrni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3581,7 +3545,7 @@ pub fn lasx_xvsrlrni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrlrni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3589,7 +3553,7 @@ pub fn lasx_xvsrlrni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrlrni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3597,7 +3561,7 @@ pub fn lasx_xvsrlrni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrlrni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvsrlrni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3605,7 +3569,7 @@ pub fn lasx_xvsrlrni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrlni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3613,7 +3577,7 @@ pub fn lasx_xvssrlni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrlni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3621,7 +3585,7 @@ pub fn lasx_xvssrlni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrlni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3629,7 +3593,7 @@ pub fn lasx_xvssrlni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrlni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3637,7 +3601,7 @@ pub fn lasx_xvssrlni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_bu_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrlni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3645,7 +3609,7 @@ pub fn lasx_xvssrlni_bu_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_hu_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrlni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3653,7 +3617,7 @@ pub fn lasx_xvssrlni_hu_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_wu_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrlni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3661,7 +3625,7 @@ pub fn lasx_xvssrlni_wu_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlni_du_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrlni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3669,7 +3633,7 @@ pub fn lasx_xvssrlni_du_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrlrni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3677,7 +3641,7 @@ pub fn lasx_xvssrlrni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrlrni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3685,7 +3649,7 @@ pub fn lasx_xvssrlrni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrlrni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3693,7 +3657,7 @@ pub fn lasx_xvssrlrni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrlrni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3701,7 +3665,7 @@ pub fn lasx_xvssrlrni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_bu_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrlrni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3709,7 +3673,7 @@ pub fn lasx_xvssrlrni_bu_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_hu_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrlrni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3717,7 +3681,7 @@ pub fn lasx_xvssrlrni_hu_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_wu_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrlrni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3725,7 +3689,7 @@ pub fn lasx_xvssrlrni_wu_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrlrni_du_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrlrni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3733,7 +3697,7 @@ pub fn lasx_xvssrlrni_du_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrani_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrani_b_h(transmute(a), transmute(b), IMM4)) } @@ -3741,7 +3705,7 @@ pub fn lasx_xvsrani_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrani_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrani_h_w(transmute(a), transmute(b), IMM5)) } @@ -3749,7 +3713,7 @@ pub fn lasx_xvsrani_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrani_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrani_w_d(transmute(a), transmute(b), IMM6)) } @@ -3757,7 +3721,7 @@ pub fn lasx_xvsrani_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrani_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvsrani_d_q(transmute(a), transmute(b), IMM7)) } @@ -3765,7 +3729,7 @@ pub fn lasx_xvsrani_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvsrarni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3773,7 +3737,7 @@ pub fn lasx_xvsrarni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvsrarni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3781,7 +3745,7 @@ pub fn lasx_xvsrarni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvsrarni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3789,7 +3753,7 @@ pub fn lasx_xvsrarni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvsrarni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvsrarni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3797,7 +3761,7 @@ pub fn lasx_xvsrarni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrani_b_h(transmute(a), transmute(b), IMM4)) } @@ -3805,7 +3769,7 @@ pub fn lasx_xvssrani_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrani_h_w(transmute(a), transmute(b), IMM5)) } @@ -3813,7 +3777,7 @@ pub fn lasx_xvssrani_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrani_w_d(transmute(a), transmute(b), IMM6)) } @@ -3821,7 +3785,7 @@ pub fn lasx_xvssrani_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrani_d_q(transmute(a), transmute(b), IMM7)) } @@ -3829,7 +3793,7 @@ pub fn lasx_xvssrani_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_bu_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrani_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3837,7 +3801,7 @@ pub fn lasx_xvssrani_bu_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_hu_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrani_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3845,7 +3809,7 @@ pub fn lasx_xvssrani_hu_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_wu_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrani_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3853,7 +3817,7 @@ pub fn lasx_xvssrani_wu_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrani_du_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrani_du_q(transmute(a), transmute(b), IMM7)) } @@ -3861,7 +3825,7 @@ pub fn lasx_xvssrani_du_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_b_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrarni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3869,7 +3833,7 @@ pub fn lasx_xvssrarni_b_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_h_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrarni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3877,7 +3841,7 @@ pub fn lasx_xvssrarni_h_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_w_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrarni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3885,7 +3849,7 @@ pub fn lasx_xvssrarni_w_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_d_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrarni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3893,7 +3857,7 @@ pub fn lasx_xvssrarni_d_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_bu_h(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lasx_xvssrarni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3901,7 +3865,7 @@ pub fn lasx_xvssrarni_bu_h(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_hu_w(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lasx_xvssrarni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3909,7 +3873,7 @@ pub fn lasx_xvssrarni_hu_w(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_wu_d(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lasx_xvssrarni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3917,7 +3881,7 @@ pub fn lasx_xvssrarni_wu_d(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvssrarni_du_q(a: m256i, b: m256i) -> m256i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lasx_xvssrarni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3925,385 +3889,385 @@ pub fn lasx_xvssrarni_du_q(a: m256i, b: m256i) -> m256i { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbnz_b(a: m256i) -> i32 { unsafe { transmute(__lasx_xbnz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbnz_d(a: m256i) -> i32 { unsafe { transmute(__lasx_xbnz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbnz_h(a: m256i) -> i32 { unsafe { transmute(__lasx_xbnz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbnz_v(a: m256i) -> i32 { unsafe { transmute(__lasx_xbnz_v(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbnz_w(a: m256i) -> i32 { unsafe { transmute(__lasx_xbnz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbz_b(a: m256i) -> i32 { unsafe { transmute(__lasx_xbz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbz_d(a: m256i) -> i32 { unsafe { transmute(__lasx_xbz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbz_h(a: m256i) -> i32 { unsafe { transmute(__lasx_xbz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbz_v(a: m256i) -> i32 { unsafe { transmute(__lasx_xbz_v(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xbz_w(a: m256i) -> i32 { unsafe { transmute(__lasx_xbz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_caf_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_caf_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_caf_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_caf_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_ceq_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_ceq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_ceq_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_ceq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cle_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cle_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cle_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cle_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_clt_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_clt_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_clt_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_clt_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cne_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cne_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cne_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cne_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cor_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cor_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cor_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cor_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cueq_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cueq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cueq_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cueq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cule_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cule_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cule_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cule_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cult_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cult_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cult_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cult_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cun_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cun_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cune_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_cune_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cune_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cune_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_cun_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_cun_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_saf_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_saf_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_saf_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_saf_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_seq_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_seq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_seq_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_seq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sle_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sle_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sle_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sle_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_slt_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_slt_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_slt_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_slt_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sne_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sne_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sne_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sne_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sor_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sor_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sor_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sor_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sueq_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sueq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sueq_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sueq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sule_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sule_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sule_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sule_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sult_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sult_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sult_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sult_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sun_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sun_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sune_d(a: m256d, b: m256d) -> m256i { unsafe { transmute(__lasx_xvfcmp_sune_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sune_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sune_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvfcmp_sun_s(a: m256, b: m256) -> m256i { unsafe { transmute(__lasx_xvfcmp_sun_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpickve_d_f(a: m256d) -> m256d { static_assert_uimm_bits!(IMM2, 2); unsafe { transmute(__lasx_xvpickve_d_f(transmute(a), IMM2)) } @@ -4311,7 +4275,7 @@ pub fn lasx_xvpickve_d_f(a: m256d) -> m256d { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_xvpickve_w_f(a: m256) -> m256 { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lasx_xvpickve_w_f(transmute(a), IMM3)) } @@ -4319,126 +4283,126 @@ pub fn lasx_xvpickve_w_f(a: m256) -> m256 { #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_cast_128_s(a: m128) -> m256 { unsafe { transmute(__lasx_cast_128_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_cast_128_d(a: m128d) -> m256d { unsafe { transmute(__lasx_cast_128_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_cast_128(a: m128i) -> m256i { unsafe { transmute(__lasx_cast_128(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_concat_128_s(a: m128, b: m128) -> m256 { unsafe { transmute(__lasx_concat_128_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_concat_128_d(a: m128d, b: m128d) -> m256d { unsafe { transmute(__lasx_concat_128_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_concat_128(a: m128i, b: m128i) -> m256i { unsafe { transmute(__lasx_concat_128(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_lo_s(a: m256) -> m128 { unsafe { transmute(__lasx_extract_128_lo_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_hi_s(a: m256) -> m128 { unsafe { transmute(__lasx_extract_128_hi_s(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_lo_d(a: m256d) -> m128d { unsafe { transmute(__lasx_extract_128_lo_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_hi_d(a: m256d) -> m128d { unsafe { transmute(__lasx_extract_128_hi_d(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_lo(a: m256i) -> m128i { unsafe { transmute(__lasx_extract_128_lo(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_extract_128_hi(a: m256i) -> m128i { unsafe { transmute(__lasx_extract_128_hi(transmute(a))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_lo_s(a: m256, b: m128) -> m256 { unsafe { transmute(__lasx_insert_128_lo_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_hi_s(a: m256, b: m128) -> m256 { unsafe { transmute(__lasx_insert_128_hi_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_lo_d(a: m256d, b: m128d) -> m256d { unsafe { transmute(__lasx_insert_128_lo_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_hi_d(a: m256d, b: m128d) -> m256d { unsafe { transmute(__lasx_insert_128_hi_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_lo(a: m256i, b: m128i) -> m256i { unsafe { transmute(__lasx_insert_128_lo(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lasx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lasx_insert_128_hi(a: m256i, b: m128i) -> m256i { unsafe { transmute(__lasx_insert_128_hi(transmute(a), transmute(b))) } } diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/mod.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/mod.rs index 22cdfa025b5d8..e0d58e21a056d 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/mod.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/mod.rs @@ -6,21 +6,21 @@ mod types; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::types::*; #[rustfmt::skip] mod generated; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::generated::*; #[rustfmt::skip] mod portable; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::portable::*; #[rustfmt::skip] diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs index fe45ed6543dfb..f1509f1718990 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs @@ -596,6 +596,10 @@ impl_vv!("lasx", lasx_xvclz_b, simd_ctlz, m256i, i8x32); impl_vv!("lasx", lasx_xvclz_h, simd_ctlz, m256i, i16x16); impl_vv!("lasx", lasx_xvclz_w, simd_ctlz, m256i, i32x8); impl_vv!("lasx", lasx_xvclz_d, simd_ctlz, m256i, i64x4); +impl_vv!("lasx", lasx_xvclo_b, simd_ext_ctlo, m256i, i8x32); +impl_vv!("lasx", lasx_xvclo_h, simd_ext_ctlo, m256i, i16x16); +impl_vv!("lasx", lasx_xvclo_w, simd_ext_ctlo, m256i, i32x8); +impl_vv!("lasx", lasx_xvclo_d, simd_ext_ctlo, m256i, i64x4); impl_vv!("lasx", lasx_xvneg_b, simd_neg, m256i, i8x32); impl_vv!("lasx", lasx_xvneg_h, simd_neg, m256i, i16x16); impl_vv!("lasx", lasx_xvneg_w, simd_neg, m256i, i32x8); diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/types.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/types.rs index 5bbf113c63097..5e287489def03 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/types.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/types.rs @@ -1,5 +1,5 @@ types! { - #![stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #![stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] /// 256-bit wide integer vector type, LoongArch-specific /// diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs index d2d065abf665a..d7dd95508aecd 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs @@ -173,14 +173,6 @@ unsafe extern "llvm-intrinsic" { fn __lsx_vbitsel_v(a: __v16u8, b: __v16u8, c: __v16u8) -> __v16u8; #[link_name = "llvm.loongarch.lsx.vbitseli.b"] fn __lsx_vbitseli_b(a: __v16u8, b: __v16u8, c: u32) -> __v16u8; - #[link_name = "llvm.loongarch.lsx.vclo.b"] - fn __lsx_vclo_b(a: __v16i8) -> __v16i8; - #[link_name = "llvm.loongarch.lsx.vclo.h"] - fn __lsx_vclo_h(a: __v8i16) -> __v8i16; - #[link_name = "llvm.loongarch.lsx.vclo.w"] - fn __lsx_vclo_w(a: __v4i32) -> __v4i32; - #[link_name = "llvm.loongarch.lsx.vclo.d"] - fn __lsx_vclo_d(a: __v2i64) -> __v2i64; #[link_name = "llvm.loongarch.lsx.vfcvt.h.s"] fn __lsx_vfcvt_h_s(a: __v4f32, b: __v4f32) -> __v8i16; #[link_name = "llvm.loongarch.lsx.vfcvt.s.d"] @@ -861,35 +853,35 @@ unsafe extern "llvm-intrinsic" { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrar_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrar_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrar_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrar_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrar_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrar_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrar_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrar_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrari_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsrari_b(transmute(a), IMM3)) } @@ -897,7 +889,7 @@ pub fn lsx_vsrari_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrari_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrari_h(transmute(a), IMM4)) } @@ -905,7 +897,7 @@ pub fn lsx_vsrari_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrari_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrari_w(transmute(a), IMM5)) } @@ -913,7 +905,7 @@ pub fn lsx_vsrari_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrari_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrari_d(transmute(a), IMM6)) } @@ -921,35 +913,35 @@ pub fn lsx_vsrari_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlr_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlr_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlr_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlr_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlr_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlr_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlr_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlr_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlri_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsrlri_b(transmute(a), IMM3)) } @@ -957,7 +949,7 @@ pub fn lsx_vsrlri_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlri_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrlri_h(transmute(a), IMM4)) } @@ -965,7 +957,7 @@ pub fn lsx_vsrlri_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlri_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrlri_w(transmute(a), IMM5)) } @@ -973,7 +965,7 @@ pub fn lsx_vsrlri_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlri_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrlri_d(transmute(a), IMM6)) } @@ -981,7 +973,7 @@ pub fn lsx_vsrlri_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitclri_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vbitclri_b(transmute(a), IMM3)) } @@ -989,7 +981,7 @@ pub fn lsx_vbitclri_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitclri_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vbitclri_h(transmute(a), IMM4)) } @@ -997,7 +989,7 @@ pub fn lsx_vbitclri_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitclri_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vbitclri_w(transmute(a), IMM5)) } @@ -1005,7 +997,7 @@ pub fn lsx_vbitclri_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitclri_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vbitclri_d(transmute(a), IMM6)) } @@ -1013,7 +1005,7 @@ pub fn lsx_vbitclri_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitseti_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vbitseti_b(transmute(a), IMM3)) } @@ -1021,7 +1013,7 @@ pub fn lsx_vbitseti_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitseti_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vbitseti_h(transmute(a), IMM4)) } @@ -1029,7 +1021,7 @@ pub fn lsx_vbitseti_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitseti_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vbitseti_w(transmute(a), IMM5)) } @@ -1037,7 +1029,7 @@ pub fn lsx_vbitseti_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitseti_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vbitseti_d(transmute(a), IMM6)) } @@ -1045,7 +1037,7 @@ pub fn lsx_vbitseti_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitrevi_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vbitrevi_b(transmute(a), IMM3)) } @@ -1053,7 +1045,7 @@ pub fn lsx_vbitrevi_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitrevi_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vbitrevi_h(transmute(a), IMM4)) } @@ -1061,7 +1053,7 @@ pub fn lsx_vbitrevi_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitrevi_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vbitrevi_w(transmute(a), IMM5)) } @@ -1069,7 +1061,7 @@ pub fn lsx_vbitrevi_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitrevi_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vbitrevi_d(transmute(a), IMM6)) } @@ -1077,7 +1069,7 @@ pub fn lsx_vbitrevi_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubi_bu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsubi_bu(transmute(a), IMM5)) } @@ -1085,7 +1077,7 @@ pub fn lsx_vsubi_bu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubi_hu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsubi_hu(transmute(a), IMM5)) } @@ -1093,7 +1085,7 @@ pub fn lsx_vsubi_hu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubi_wu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsubi_wu(transmute(a), IMM5)) } @@ -1101,7 +1093,7 @@ pub fn lsx_vsubi_wu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubi_du(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsubi_du(transmute(a), IMM5)) } @@ -1109,7 +1101,7 @@ pub fn lsx_vsubi_du(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsat_b(transmute(a), IMM3)) } @@ -1117,7 +1109,7 @@ pub fn lsx_vsat_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsat_h(transmute(a), IMM4)) } @@ -1125,7 +1117,7 @@ pub fn lsx_vsat_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsat_w(transmute(a), IMM5)) } @@ -1133,7 +1125,7 @@ pub fn lsx_vsat_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_d(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsat_d(transmute(a), IMM6)) } @@ -1141,7 +1133,7 @@ pub fn lsx_vsat_d(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_bu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsat_bu(transmute(a), IMM3)) } @@ -1149,7 +1141,7 @@ pub fn lsx_vsat_bu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_hu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsat_hu(transmute(a), IMM4)) } @@ -1157,7 +1149,7 @@ pub fn lsx_vsat_hu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_wu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsat_wu(transmute(a), IMM5)) } @@ -1165,7 +1157,7 @@ pub fn lsx_vsat_wu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsat_du(a: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsat_du(transmute(a), IMM6)) } @@ -1173,252 +1165,252 @@ pub fn lsx_vsat_du(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vdiv_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vdiv_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_hu_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_hu_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_wu_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_wu_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_du_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_du_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_hu_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_hu_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_wu_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_wu_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_du_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_du_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmod_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmod_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vreplve_b(a: m128i, b: i32) -> m128i { unsafe { transmute(__lsx_vreplve_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vreplve_h(a: m128i, b: i32) -> m128i { unsafe { transmute(__lsx_vreplve_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vreplve_w(a: m128i, b: i32) -> m128i { unsafe { transmute(__lsx_vreplve_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vreplve_d(a: m128i, b: i32) -> m128i { unsafe { transmute(__lsx_vreplve_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vshuf_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vshuf_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vshuf_w(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vshuf_w(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vshuf_d(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vshuf_d(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vandi_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vandi_b(transmute(a), IMM8)) } @@ -1426,7 +1418,7 @@ pub fn lsx_vandi_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vori_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vori_b(transmute(a), IMM8)) } @@ -1434,7 +1426,7 @@ pub fn lsx_vori_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vnori_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vnori_b(transmute(a), IMM8)) } @@ -1442,7 +1434,7 @@ pub fn lsx_vnori_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vxori_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vxori_b(transmute(a), IMM8)) } @@ -1450,14 +1442,14 @@ pub fn lsx_vxori_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitsel_v(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vbitsel_v(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vbitseli_b(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vbitseli_b(transmute(a), transmute(b), IMM8)) } @@ -1465,287 +1457,259 @@ pub fn lsx_vbitseli_b(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lsx_vclo_b(a: m128i) -> m128i { - unsafe { transmute(__lsx_vclo_b(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lsx_vclo_h(a: m128i) -> m128i { - unsafe { transmute(__lsx_vclo_h(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lsx_vclo_w(a: m128i) -> m128i { - unsafe { transmute(__lsx_vclo_w(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] -pub fn lsx_vclo_d(a: m128i) -> m128i { - unsafe { transmute(__lsx_vclo_d(transmute(a))) } -} - -#[inline] -#[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvt_h_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcvt_h_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvt_s_d(a: m128d, b: m128d) -> m128 { unsafe { transmute(__lsx_vfcvt_s_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmin_s(a: m128, b: m128) -> m128 { unsafe { transmute(__lsx_vfmin_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmin_d(a: m128d, b: m128d) -> m128d { unsafe { transmute(__lsx_vfmin_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmina_s(a: m128, b: m128) -> m128 { unsafe { transmute(__lsx_vfmina_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmina_d(a: m128d, b: m128d) -> m128d { unsafe { transmute(__lsx_vfmina_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmax_s(a: m128, b: m128) -> m128 { unsafe { transmute(__lsx_vfmax_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmax_d(a: m128d, b: m128d) -> m128d { unsafe { transmute(__lsx_vfmax_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmaxa_s(a: m128, b: m128) -> m128 { unsafe { transmute(__lsx_vfmaxa_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfmaxa_d(a: m128d, b: m128d) -> m128d { unsafe { transmute(__lsx_vfmaxa_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfclass_s(a: m128) -> m128i { unsafe { transmute(__lsx_vfclass_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfclass_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vfclass_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrecipe_s(a: m128) -> m128 { unsafe { transmute(__lsx_vfrecipe_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrecipe_d(a: m128d) -> m128d { unsafe { transmute(__lsx_vfrecipe_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrsqrte_s(a: m128) -> m128 { unsafe { transmute(__lsx_vfrsqrte_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx,frecipe")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrsqrte_d(a: m128d) -> m128d { unsafe { transmute(__lsx_vfrsqrte_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrint_s(a: m128) -> m128 { unsafe { transmute(__lsx_vfrint_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrint_d(a: m128d) -> m128d { unsafe { transmute(__lsx_vfrint_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vflogb_s(a: m128) -> m128 { unsafe { transmute(__lsx_vflogb_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vflogb_d(a: m128d) -> m128d { unsafe { transmute(__lsx_vflogb_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvth_s_h(a: m128i) -> m128 { unsafe { transmute(__lsx_vfcvth_s_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvth_d_s(a: m128) -> m128d { unsafe { transmute(__lsx_vfcvth_d_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvtl_s_h(a: m128i) -> m128 { unsafe { transmute(__lsx_vfcvtl_s_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcvtl_d_s(a: m128) -> m128d { unsafe { transmute(__lsx_vfcvtl_d_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftint_w_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftint_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftint_l_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftint_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftint_wu_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftint_wu_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftint_lu_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftint_lu_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrz_w_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrz_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrz_l_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftintrz_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrz_wu_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrz_wu_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrz_lu_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftintrz_lu_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffint_s_w(a: m128i) -> m128 { unsafe { transmute(__lsx_vffint_s_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffint_d_l(a: m128i) -> m128d { unsafe { transmute(__lsx_vffint_d_l(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffint_s_wu(a: m128i) -> m128 { unsafe { transmute(__lsx_vffint_s_wu(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffint_d_lu(a: m128i) -> m128d { unsafe { transmute(__lsx_vffint_d_lu(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_h_b(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsllwil_h_b(transmute(a), IMM3)) } @@ -1753,7 +1717,7 @@ pub fn lsx_vsllwil_h_b(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_w_h(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsllwil_w_h(transmute(a), IMM4)) } @@ -1761,7 +1725,7 @@ pub fn lsx_vsllwil_w_h(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_d_w(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsllwil_d_w(transmute(a), IMM5)) } @@ -1769,7 +1733,7 @@ pub fn lsx_vsllwil_d_w(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_hu_bu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM3, 3); unsafe { transmute(__lsx_vsllwil_hu_bu(transmute(a), IMM3)) } @@ -1777,7 +1741,7 @@ pub fn lsx_vsllwil_hu_bu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_wu_hu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsllwil_wu_hu(transmute(a), IMM4)) } @@ -1785,7 +1749,7 @@ pub fn lsx_vsllwil_wu_hu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsllwil_du_wu(a: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsllwil_du_wu(transmute(a), IMM5)) } @@ -1793,217 +1757,217 @@ pub fn lsx_vsllwil_du_wu(a: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsran_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsran_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsran_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsran_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsran_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsran_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_bu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_hu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssran_wu_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssran_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarn_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrarn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarn_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrarn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarn_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrarn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_bu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_hu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarn_wu_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrarn_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrln_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrln_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrln_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrln_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrln_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrln_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_bu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_hu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_wu_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrn_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlrn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrn_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlrn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrn_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsrlrn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_bu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_bu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_hu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_hu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_wu_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_wu_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrstpi_b(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vfrstpi_b(transmute(a), transmute(b), IMM5)) } @@ -2011,7 +1975,7 @@ pub fn lsx_vfrstpi_b(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrstpi_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vfrstpi_h(transmute(a), transmute(b), IMM5)) } @@ -2019,21 +1983,21 @@ pub fn lsx_vfrstpi_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrstp_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vfrstp_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrstp_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vfrstp_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextrins_b(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vextrins_b(transmute(a), transmute(b), IMM8)) } @@ -2041,7 +2005,7 @@ pub fn lsx_vextrins_b(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextrins_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vextrins_h(transmute(a), transmute(b), IMM8)) } @@ -2049,7 +2013,7 @@ pub fn lsx_vextrins_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextrins_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vextrins_w(transmute(a), transmute(b), IMM8)) } @@ -2057,7 +2021,7 @@ pub fn lsx_vextrins_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextrins_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vextrins_d(transmute(a), transmute(b), IMM8)) } @@ -2065,245 +2029,245 @@ pub fn lsx_vextrins_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmskltz_b(a: m128i) -> m128i { unsafe { transmute(__lsx_vmskltz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmskltz_h(a: m128i) -> m128i { unsafe { transmute(__lsx_vmskltz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmskltz_w(a: m128i) -> m128i { unsafe { transmute(__lsx_vmskltz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmskltz_d(a: m128i) -> m128i { unsafe { transmute(__lsx_vmskltz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsigncov_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsigncov_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsigncov_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsigncov_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsigncov_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsigncov_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsigncov_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsigncov_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrne_w_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrne_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrne_l_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftintrne_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrp_w_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrp_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrp_l_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftintrp_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrm_w_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrm_w_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrm_l_d(a: m128d) -> m128i { unsafe { transmute(__lsx_vftintrm_l_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftint_w_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vftint_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffint_s_l(a: m128i, b: m128i) -> m128 { unsafe { transmute(__lsx_vffint_s_l(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrz_w_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vftintrz_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrp_w_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vftintrp_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrm_w_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vftintrm_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrne_w_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vftintrne_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintl_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftinth_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftinth_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffinth_d_w(a: m128i) -> m128d { unsafe { transmute(__lsx_vffinth_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vffintl_d_w(a: m128i) -> m128d { unsafe { transmute(__lsx_vffintl_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrzl_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrzl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrzh_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrzh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrpl_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrpl_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrph_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrph_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrml_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrml_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrmh_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrmh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrnel_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrnel_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vftintrneh_l_s(a: m128) -> m128i { unsafe { transmute(__lsx_vftintrneh_l_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrintrne_s(a: m128) -> m128 { unsafe { transmute(__lsx_vfrintrne_s(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfrintrne_d(a: m128d) -> m128d { unsafe { transmute(__lsx_vfrintrne_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vstelm_b(a: m128i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM4, 4); @@ -2312,7 +2276,7 @@ pub unsafe fn lsx_vstelm_b(a: m128i, mem_add #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vstelm_h(a: m128i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM3, 3); @@ -2321,7 +2285,7 @@ pub unsafe fn lsx_vstelm_h(a: m128i, mem_add #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vstelm_w(a: m128i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM2, 2); @@ -2330,7 +2294,7 @@ pub unsafe fn lsx_vstelm_w(a: m128i, mem_add #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vstelm_d(a: m128i, mem_addr: *mut i8) { static_assert_simm_bits!(IMM_S8, 8); static_assert_uimm_bits!(IMM1, 1); @@ -2339,504 +2303,504 @@ pub unsafe fn lsx_vstelm_d(a: m128i, mem_add #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_d_wu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_w_hu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_h_bu_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_d_wu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_w_hu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_h_bu_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwev_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsubwod_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsubwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwev_q_du_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwev_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vaddwod_q_du_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vaddwod_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_d_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_d_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_w_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_w_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_h_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_h_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_d_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_d_wu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_w_hu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_w_hu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_h_bu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_h_bu(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_d_wu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_w_hu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_h_bu_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_d_wu_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_d_wu_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_w_hu_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_w_hu_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_h_bu_b(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_h_bu_b(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_q_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_q_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwev_q_du_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwev_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmulwod_q_du_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vmulwod_q_du_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhaddw_qu_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhaddw_qu_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_q_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_q_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vhsubw_qu_du(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_qu_du(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_d_w(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_d_w(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_w_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_w_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_h_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_h_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_d_wu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_d_wu( @@ -2849,7 +2813,7 @@ pub fn lsx_vmaddwev_d_wu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_w_hu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_w_hu( @@ -2862,7 +2826,7 @@ pub fn lsx_vmaddwev_w_hu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_h_bu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_h_bu( @@ -2875,28 +2839,28 @@ pub fn lsx_vmaddwev_h_bu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_d_w(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_d_w(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_w_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_w_h(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_h_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_h_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_d_wu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_d_wu( @@ -2909,7 +2873,7 @@ pub fn lsx_vmaddwod_d_wu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_w_hu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_w_hu( @@ -2922,7 +2886,7 @@ pub fn lsx_vmaddwod_w_hu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_h_bu(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_h_bu( @@ -2935,7 +2899,7 @@ pub fn lsx_vmaddwod_h_bu(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_d_wu_w(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_d_wu_w( @@ -2948,7 +2912,7 @@ pub fn lsx_vmaddwev_d_wu_w(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_w_hu_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_w_hu_h( @@ -2961,7 +2925,7 @@ pub fn lsx_vmaddwev_w_hu_h(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_h_bu_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_h_bu_b( @@ -2974,7 +2938,7 @@ pub fn lsx_vmaddwev_h_bu_b(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_d_wu_w(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_d_wu_w( @@ -2987,7 +2951,7 @@ pub fn lsx_vmaddwod_d_wu_w(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_w_hu_h(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_w_hu_h( @@ -3000,7 +2964,7 @@ pub fn lsx_vmaddwod_w_hu_h(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_h_bu_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_h_bu_b( @@ -3013,21 +2977,21 @@ pub fn lsx_vmaddwod_h_bu_b(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_q_d(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_q_d(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_q_d(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_q_d(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_q_du(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_q_du( @@ -3040,7 +3004,7 @@ pub fn lsx_vmaddwev_q_du(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_q_du(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_q_du( @@ -3053,7 +3017,7 @@ pub fn lsx_vmaddwod_q_du(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwev_q_du_d(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwev_q_du_d( @@ -3066,7 +3030,7 @@ pub fn lsx_vmaddwev_q_du_d(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmaddwod_q_du_d(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vmaddwod_q_du_d( @@ -3079,21 +3043,21 @@ pub fn lsx_vmaddwod_q_du_d(a: m128i, b: m128i, c: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vadd_q(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vadd_q(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsub_q(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vsub_q(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vldrepl_b(mem_addr: *const i8) -> m128i { static_assert_simm_bits!(IMM_S12, 12); transmute(__lsx_vldrepl_b(mem_addr, IMM_S12)) @@ -3101,7 +3065,7 @@ pub unsafe fn lsx_vldrepl_b(mem_addr: *const i8) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vldrepl_h(mem_addr: *const i8) -> m128i { static_assert_simm_bits!(IMM_S11, 11); transmute(__lsx_vldrepl_h(mem_addr, IMM_S11)) @@ -3109,7 +3073,7 @@ pub unsafe fn lsx_vldrepl_h(mem_addr: *const i8) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vldrepl_w(mem_addr: *const i8) -> m128i { static_assert_simm_bits!(IMM_S10, 10); transmute(__lsx_vldrepl_w(mem_addr, IMM_S10)) @@ -3117,7 +3081,7 @@ pub unsafe fn lsx_vldrepl_w(mem_addr: *const i8) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn lsx_vldrepl_d(mem_addr: *const i8) -> m128i { static_assert_simm_bits!(IMM_S9, 9); transmute(__lsx_vldrepl_d(mem_addr, IMM_S9)) @@ -3125,84 +3089,84 @@ pub unsafe fn lsx_vldrepl_d(mem_addr: *const i8) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmskgez_b(a: m128i) -> m128i { unsafe { transmute(__lsx_vmskgez_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vmsknz_b(a: m128i) -> m128i { unsafe { transmute(__lsx_vmsknz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_h_b(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_h_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_w_h(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_w_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_d_w(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_d_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_q_d(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_q_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_hu_bu(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_hu_bu(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_wu_hu(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_wu_hu(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_du_wu(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_du_wu(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vexth_qu_du(a: m128i) -> m128i { unsafe { transmute(__lsx_vexth_qu_du(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextl_q_d(a: m128i) -> m128i { unsafe { transmute(__lsx_vextl_q_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrlni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3210,7 +3174,7 @@ pub fn lsx_vsrlni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrlni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3218,7 +3182,7 @@ pub fn lsx_vsrlni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrlni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3226,7 +3190,7 @@ pub fn lsx_vsrlni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vsrlni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3234,7 +3198,7 @@ pub fn lsx_vsrlni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrlrni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3242,7 +3206,7 @@ pub fn lsx_vsrlrni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrlrni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3250,7 +3214,7 @@ pub fn lsx_vsrlrni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrlrni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3258,7 +3222,7 @@ pub fn lsx_vsrlrni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrlrni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vsrlrni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3266,7 +3230,7 @@ pub fn lsx_vsrlrni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrlni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3274,7 +3238,7 @@ pub fn lsx_vssrlni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrlni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3282,7 +3246,7 @@ pub fn lsx_vssrlni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrlni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3290,7 +3254,7 @@ pub fn lsx_vssrlni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrlni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3298,7 +3262,7 @@ pub fn lsx_vssrlni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_bu_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrlni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3306,7 +3270,7 @@ pub fn lsx_vssrlni_bu_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_hu_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrlni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3314,7 +3278,7 @@ pub fn lsx_vssrlni_hu_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_wu_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrlni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3322,7 +3286,7 @@ pub fn lsx_vssrlni_wu_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlni_du_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrlni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3330,7 +3294,7 @@ pub fn lsx_vssrlni_du_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrlrni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3338,7 +3302,7 @@ pub fn lsx_vssrlrni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrlrni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3346,7 +3310,7 @@ pub fn lsx_vssrlrni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrlrni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3354,7 +3318,7 @@ pub fn lsx_vssrlrni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrlrni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3362,7 +3326,7 @@ pub fn lsx_vssrlrni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_bu_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrlrni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3370,7 +3334,7 @@ pub fn lsx_vssrlrni_bu_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_hu_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrlrni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3378,7 +3342,7 @@ pub fn lsx_vssrlrni_hu_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_wu_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrlrni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3386,7 +3350,7 @@ pub fn lsx_vssrlrni_wu_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrni_du_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrlrni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3394,7 +3358,7 @@ pub fn lsx_vssrlrni_du_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrani_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrani_b_h(transmute(a), transmute(b), IMM4)) } @@ -3402,7 +3366,7 @@ pub fn lsx_vsrani_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrani_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrani_h_w(transmute(a), transmute(b), IMM5)) } @@ -3410,7 +3374,7 @@ pub fn lsx_vsrani_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrani_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrani_w_d(transmute(a), transmute(b), IMM6)) } @@ -3418,7 +3382,7 @@ pub fn lsx_vsrani_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrani_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vsrani_d_q(transmute(a), transmute(b), IMM7)) } @@ -3426,7 +3390,7 @@ pub fn lsx_vsrani_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vsrarni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3434,7 +3398,7 @@ pub fn lsx_vsrarni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vsrarni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3442,7 +3406,7 @@ pub fn lsx_vsrarni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vsrarni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3450,7 +3414,7 @@ pub fn lsx_vsrarni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vsrarni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vsrarni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3458,7 +3422,7 @@ pub fn lsx_vsrarni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrani_b_h(transmute(a), transmute(b), IMM4)) } @@ -3466,7 +3430,7 @@ pub fn lsx_vssrani_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrani_h_w(transmute(a), transmute(b), IMM5)) } @@ -3474,7 +3438,7 @@ pub fn lsx_vssrani_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrani_w_d(transmute(a), transmute(b), IMM6)) } @@ -3482,7 +3446,7 @@ pub fn lsx_vssrani_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrani_d_q(transmute(a), transmute(b), IMM7)) } @@ -3490,7 +3454,7 @@ pub fn lsx_vssrani_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_bu_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrani_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3498,7 +3462,7 @@ pub fn lsx_vssrani_bu_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_hu_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrani_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3506,7 +3470,7 @@ pub fn lsx_vssrani_hu_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_wu_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrani_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3514,7 +3478,7 @@ pub fn lsx_vssrani_wu_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrani_du_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrani_du_q(transmute(a), transmute(b), IMM7)) } @@ -3522,7 +3486,7 @@ pub fn lsx_vssrani_du_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_b_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrarni_b_h(transmute(a), transmute(b), IMM4)) } @@ -3530,7 +3494,7 @@ pub fn lsx_vssrarni_b_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_h_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrarni_h_w(transmute(a), transmute(b), IMM5)) } @@ -3538,7 +3502,7 @@ pub fn lsx_vssrarni_h_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_w_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrarni_w_d(transmute(a), transmute(b), IMM6)) } @@ -3546,7 +3510,7 @@ pub fn lsx_vssrarni_w_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_d_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrarni_d_q(transmute(a), transmute(b), IMM7)) } @@ -3554,7 +3518,7 @@ pub fn lsx_vssrarni_d_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_bu_h(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute(__lsx_vssrarni_bu_h(transmute(a), transmute(b), IMM4)) } @@ -3562,7 +3526,7 @@ pub fn lsx_vssrarni_bu_h(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_hu_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM5, 5); unsafe { transmute(__lsx_vssrarni_hu_w(transmute(a), transmute(b), IMM5)) } @@ -3570,7 +3534,7 @@ pub fn lsx_vssrarni_hu_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_wu_d(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM6, 6); unsafe { transmute(__lsx_vssrarni_wu_d(transmute(a), transmute(b), IMM6)) } @@ -3578,7 +3542,7 @@ pub fn lsx_vssrarni_wu_d(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrarni_du_q(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM7, 7); unsafe { transmute(__lsx_vssrarni_du_q(transmute(a), transmute(b), IMM7)) } @@ -3586,7 +3550,7 @@ pub fn lsx_vssrarni_du_q(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vpermi_w(a: m128i, b: m128i) -> m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(__lsx_vpermi_w(transmute(a), transmute(b), IMM8)) } @@ -3594,434 +3558,434 @@ pub fn lsx_vpermi_w(a: m128i, b: m128i) -> m128i { #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrlrn_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrlrn_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_b_h(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_b_h(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_h_w(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_h_w(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vssrln_w_d(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vssrln_w_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vshuf_b(a: m128i, b: m128i, c: m128i) -> m128i { unsafe { transmute(__lsx_vshuf_b(transmute(a), transmute(b), transmute(c))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vextl_qu_du(a: m128i) -> m128i { unsafe { transmute(__lsx_vextl_qu_du(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bnz_b(a: m128i) -> i32 { unsafe { transmute(__lsx_bnz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bnz_d(a: m128i) -> i32 { unsafe { transmute(__lsx_bnz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bnz_h(a: m128i) -> i32 { unsafe { transmute(__lsx_bnz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bnz_v(a: m128i) -> i32 { unsafe { transmute(__lsx_bnz_v(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bnz_w(a: m128i) -> i32 { unsafe { transmute(__lsx_bnz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bz_b(a: m128i) -> i32 { unsafe { transmute(__lsx_bz_b(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bz_d(a: m128i) -> i32 { unsafe { transmute(__lsx_bz_d(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bz_h(a: m128i) -> i32 { unsafe { transmute(__lsx_bz_h(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bz_v(a: m128i) -> i32 { unsafe { transmute(__lsx_bz_v(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_bz_w(a: m128i) -> i32 { unsafe { transmute(__lsx_bz_w(transmute(a))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_caf_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_caf_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_caf_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_caf_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_ceq_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_ceq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_ceq_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_ceq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cle_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cle_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cle_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cle_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_clt_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_clt_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_clt_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_clt_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cne_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cne_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cne_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cne_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cor_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cor_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cor_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cor_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cueq_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cueq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cueq_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cueq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cule_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cule_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cule_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cule_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cult_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cult_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cult_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cult_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cun_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cun_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cune_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_cune_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cune_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cune_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_cun_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_cun_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_saf_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_saf_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_saf_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_saf_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_seq_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_seq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_seq_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_seq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sle_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sle_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sle_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sle_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_slt_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_slt_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_slt_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_slt_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sne_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sne_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sne_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sne_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sor_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sor_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sor_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sor_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sueq_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sueq_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sueq_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sueq_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sule_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sule_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sule_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sule_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sult_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sult_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sult_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sult_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sun_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sun_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sune_d(a: m128d, b: m128d) -> m128i { unsafe { transmute(__lsx_vfcmp_sune_d(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sune_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sune_s(transmute(a), transmute(b))) } } #[inline] #[target_feature(enable = "lsx")] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn lsx_vfcmp_sun_s(a: m128, b: m128) -> m128i { unsafe { transmute(__lsx_vfcmp_sun_s(transmute(a), transmute(b))) } } diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/mod.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/mod.rs index 7ad1009f0245a..77099bb2fd541 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/mod.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/mod.rs @@ -6,21 +6,21 @@ mod types; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::types::*; #[rustfmt::skip] mod generated; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::generated::*; #[rustfmt::skip] mod portable; #[rustfmt::skip] -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::portable::*; #[rustfmt::skip] diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs index f2b86dae00af8..68588bd087335 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs @@ -271,6 +271,10 @@ impl_vv!("lsx", lsx_vclz_b, simd_ctlz, m128i, i8x16); impl_vv!("lsx", lsx_vclz_h, simd_ctlz, m128i, i16x8); impl_vv!("lsx", lsx_vclz_w, simd_ctlz, m128i, i32x4); impl_vv!("lsx", lsx_vclz_d, simd_ctlz, m128i, i64x2); +impl_vv!("lsx", lsx_vclo_b, simd_ext_ctlo, m128i, i8x16); +impl_vv!("lsx", lsx_vclo_h, simd_ext_ctlo, m128i, i16x8); +impl_vv!("lsx", lsx_vclo_w, simd_ext_ctlo, m128i, i32x4); +impl_vv!("lsx", lsx_vclo_d, simd_ext_ctlo, m128i, i64x2); impl_vv!("lsx", lsx_vneg_b, simd_neg, m128i, i8x16); impl_vv!("lsx", lsx_vneg_h, simd_neg, m128i, i16x8); impl_vv!("lsx", lsx_vneg_w, simd_neg, m128i, i32x4); diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/types.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/types.rs index 2d331498f19b9..38a502377feeb 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/types.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/types.rs @@ -1,5 +1,5 @@ types! { - #![stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #![stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] /// 128-bit wide integer vector type, LoongArch-specific /// diff --git a/library/stdarch/crates/core_arch/src/loongarch64/mod.rs b/library/stdarch/crates/core_arch/src/loongarch64/mod.rs index 77c6033a71cc1..467a7c717f3c5 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/mod.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/mod.rs @@ -4,9 +4,9 @@ mod lasx; mod lsx; mod simd; -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::lasx::*; -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub use self::lsx::*; use crate::arch::asm; diff --git a/library/stdarch/crates/core_arch/src/loongarch64/simd.rs b/library/stdarch/crates/core_arch/src/loongarch64/simd.rs index 3152864ab864e..cae446afa1865 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/simd.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/simd.rs @@ -99,6 +99,12 @@ pub(super) const unsafe fn simd_ext_bitset(a: T, b: T) simd_or(simd_ext_shl(simd_ext_splat(1), b), a) } +#[inline(always)] +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(super) const unsafe fn simd_ext_ctlo(a: T) -> T { + simd_ctlz(simd_ext_not(a)) +} + #[inline(always)] #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] pub(super) const unsafe fn simd_ext_fmsub(a: T, b: T, c: T) -> T { @@ -308,7 +314,7 @@ macro_rules! impl_vavg { ($ft:literal, $name:ident, $oty:ty, $ity:ty, $wty:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty) -> $oty { unsafe { let a: $wty = simd_cast(transmute::<_, $ity>(a)); @@ -324,7 +330,7 @@ macro_rules! impl_vavgr { ($ft:literal, $name:ident, $oty:ty, $ity:ty, $wty:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty) -> $oty { unsafe { let a: $wty = simd_cast(transmute::<_, $ity>(a)); @@ -346,7 +352,7 @@ macro_rules! impl_vv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $oty { unsafe { let a: $ity = transmute(a); @@ -363,7 +369,7 @@ macro_rules! impl_gv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $gty) -> $oty { unsafe { let r: $ity = $op(a.into()); @@ -379,7 +385,7 @@ macro_rules! impl_ggv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $xty:ty, unsafe) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn $name(a: $gty, b: $xty) -> $oty { let r: $ity = $op(a, b); transmute(r) @@ -393,7 +399,7 @@ macro_rules! impl_gsv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $ibs:expr, const, unsafe) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn $name(a: $gty) -> $oty { static_assert_simm_bits!(IMM, $ibs); let r: $ity = $op::(a); @@ -408,7 +414,7 @@ macro_rules! impl_sv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name() -> $oty { static_assert_simm_bits!(IMM, $ibs); unsafe { @@ -420,7 +426,7 @@ macro_rules! impl_sv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr, const) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name() -> $oty { static_assert_simm_bits!(IMM, $ibs); unsafe { @@ -437,7 +443,7 @@ macro_rules! impl_vvv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty) -> $oty { unsafe { let a: $ity = transmute(a); @@ -450,7 +456,7 @@ macro_rules! impl_vvv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ty, $wty:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty) -> $oty { unsafe { let a: $ity = transmute(a); @@ -468,7 +474,7 @@ macro_rules! impl_vgg { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $xty:ty, unsafe) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn $name(a: $oty, b: $gty, c: $xty) { $op(a, b, c); } @@ -481,7 +487,7 @@ macro_rules! impl_vgs { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $ibs:expr, const, unsafe) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub unsafe fn $name(a: $oty, b: $gty) { static_assert_simm_bits!(IMM, $ibs); $op::(a, b); @@ -495,7 +501,7 @@ macro_rules! impl_vuv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $oty { static_assert_uimm_bits!(IMM, (size_of::<<$ity as SimdExt>::Elem>() * 8).ilog2()); unsafe { @@ -509,7 +515,7 @@ macro_rules! impl_vuv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $oty { static_assert_uimm_bits!(IMM, $ibs); unsafe { @@ -523,7 +529,7 @@ macro_rules! impl_vuv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr, const) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $oty { static_assert_uimm_bits!(IMM, $ibs); unsafe { @@ -541,7 +547,7 @@ macro_rules! impl_vug { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $ibs:expr) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $gty { static_assert_uimm_bits!(IMM, $ibs); unsafe { @@ -559,7 +565,7 @@ macro_rules! impl_vsv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty) -> $oty { static_assert_simm_bits!(IMM, $ibs); unsafe { @@ -578,7 +584,7 @@ macro_rules! impl_vvvv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ty) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty, c: $oty) -> $oty { unsafe { let a: $ity = transmute(a); @@ -597,7 +603,7 @@ macro_rules! impl_vvuv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $ibs:expr, const) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $oty) -> $oty { static_assert_uimm_bits!(IMM, $ibs); unsafe { @@ -616,7 +622,7 @@ macro_rules! impl_vugv { ($ft:literal, $name:ident, $op:ident, $oty:ty, $ity:ident, $gty:ty, $ibs:expr) => { #[inline] #[target_feature(enable = $ft)] - #[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] pub fn $name(a: $oty, b: $gty) -> $oty { static_assert_uimm_bits!(IMM, $ibs); unsafe { diff --git a/library/stdarch/crates/core_arch/src/mips/msa.rs b/library/stdarch/crates/core_arch/src/mips/msa.rs index ebd9558ef513c..04a14f471031b 100644 --- a/library/stdarch/crates/core_arch/src/mips/msa.rs +++ b/library/stdarch/crates/core_arch/src/mips/msa.rs @@ -1408,7 +1408,6 @@ pub unsafe fn __msa_addv_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(addvi.b, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_addvi_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM5, 5); @@ -1424,7 +1423,6 @@ pub unsafe fn __msa_addvi_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(addvi.h, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_addvi_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM5, 5); @@ -1440,7 +1438,6 @@ pub unsafe fn __msa_addvi_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(addvi.w, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_addvi_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -1456,7 +1453,6 @@ pub unsafe fn __msa_addvi_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(addvi.d, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_addvi_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM5, 5); @@ -1487,7 +1483,6 @@ pub unsafe fn __msa_and_v(a: v16u8, b: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(andi.b, IMM8 = 0b10010111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_andi_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -1938,8 +1933,7 @@ pub unsafe fn __msa_bclr_d(a: v2u64, b: v2u64) -> v2u64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(bclri.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(andi.b, IMM3 = 0b111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bclri_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -1955,7 +1949,6 @@ pub unsafe fn __msa_bclri_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bclri.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bclri_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -1971,7 +1964,6 @@ pub unsafe fn __msa_bclri_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bclri.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bclri_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -1987,7 +1979,6 @@ pub unsafe fn __msa_bclri_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bclri.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bclri_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -2062,8 +2053,7 @@ pub unsafe fn __msa_binsl_d(a: v2u64, b: v2u64, c: v2u64) -> v2u64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsli.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsli.b, IMM3 = 0b101))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsli_b(a: v16u8, b: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -2078,8 +2068,7 @@ pub unsafe fn __msa_binsli_b(a: v16u8, b: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsli.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsli.h, IMM4 = 0b1011))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsli_h(a: v8u16, b: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -2094,8 +2083,7 @@ pub unsafe fn __msa_binsli_h(a: v8u16, b: v8u16) -> v8u16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsli.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsli.w, IMM5 = 0b10111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsli_w(a: v4u32, b: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -2110,8 +2098,7 @@ pub unsafe fn __msa_binsli_w(a: v4u32, b: v4u32) -> v4u32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsli.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsli.d, IMM6 = 0b101111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsli_d(a: v2u64, b: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -2186,8 +2173,7 @@ pub unsafe fn __msa_binsr_d(a: v2u64, b: v2u64, c: v2u64) -> v2u64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsri.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsri.b, IMM3 = 0b101))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsri_b(a: v16u8, b: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -2202,8 +2188,7 @@ pub unsafe fn __msa_binsri_b(a: v16u8, b: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsri.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsri.h, IMM4 = 0b1011))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsri_h(a: v8u16, b: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -2218,8 +2203,7 @@ pub unsafe fn __msa_binsri_h(a: v8u16, b: v8u16) -> v8u16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsri.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsri.w, IMM5 = 0b10111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsri_w(a: v4u32, b: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -2234,8 +2218,7 @@ pub unsafe fn __msa_binsri_w(a: v4u32, b: v4u32) -> v4u32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(binsri.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(binsri.d, IMM6 = 0b101111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_binsri_d(a: v2u64, b: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -2265,8 +2248,7 @@ pub unsafe fn __msa_bmnz_v(a: v16u8, b: v16u8, c: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(bmnzi.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(bmnzi.b, IMM8 = 0b1011_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bmnzi_b(a: v16u8, b: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -2282,7 +2264,7 @@ pub unsafe fn __msa_bmnzi_b(a: v16u8, b: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(bmz.v))] +#[cfg_attr(test, assert_instr(bmnz.v))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bmz_v(a: v16u8, b: v16u8, c: v16u8) -> v16u8 { msa_bmz_v(a, mem::transmute(b), c) @@ -2296,8 +2278,7 @@ pub unsafe fn __msa_bmz_v(a: v16u8, b: v16u8, c: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(bmzi.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(bmnzi.b, IMM8 = 0b1011_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bmzi_b(a: v16u8, b: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -2373,7 +2354,6 @@ pub unsafe fn __msa_bneg_d(a: v2u64, b: v2u64) -> v2u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bnegi.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bnegi_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -2389,7 +2369,6 @@ pub unsafe fn __msa_bnegi_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bnegi.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bnegi_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -2405,7 +2384,6 @@ pub unsafe fn __msa_bnegi_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bnegi.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bnegi_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -2421,7 +2399,6 @@ pub unsafe fn __msa_bnegi_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bnegi.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bnegi_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -2498,7 +2475,7 @@ pub unsafe fn __msa_bnz_v(a: v16u8) -> i32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(bsel.v))] +#[cfg_attr(test, assert_instr(bmnz.v))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bsel_v(a: v16u8, b: v16u8, c: v16u8) -> v16u8 { msa_bsel_v(a, mem::transmute(b), c) @@ -2513,7 +2490,6 @@ pub unsafe fn __msa_bsel_v(a: v16u8, b: v16u8, c: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bseli.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bseli_b(a: v16u8, b: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -2589,7 +2565,6 @@ pub unsafe fn __msa_bset_d(a: v2u64, b: v2u64) -> v2u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bseti.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bseti_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -2605,7 +2580,6 @@ pub unsafe fn __msa_bseti_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bseti.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bseti_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -2621,7 +2595,6 @@ pub unsafe fn __msa_bseti_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bseti.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bseti_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -2637,7 +2610,6 @@ pub unsafe fn __msa_bseti_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(bseti.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_bseti_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -2770,7 +2742,6 @@ pub unsafe fn __msa_ceq_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ceqi.b, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ceqi_b(a: v16i8) -> v16i8 { static_assert_simm_bits!(IMM_S5, 5); @@ -2786,7 +2757,6 @@ pub unsafe fn __msa_ceqi_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ceqi.h, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ceqi_h(a: v8i16) -> v8i16 { static_assert_simm_bits!(IMM_S5, 5); @@ -2802,7 +2772,6 @@ pub unsafe fn __msa_ceqi_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ceqi.w, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ceqi_w(a: v4i32) -> v4i32 { static_assert_simm_bits!(IMM_S5, 5); @@ -2818,7 +2787,6 @@ pub unsafe fn __msa_ceqi_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ceqi.d, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ceqi_d(a: v2i64) -> v2i64 { static_assert_simm_bits!(IMM_S5, 5); @@ -2833,7 +2801,6 @@ pub unsafe fn __msa_ceqi_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(cfcmsa, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(0)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_cfcmsa() -> i32 { static_assert_uimm_bits!(IMM5, 5); @@ -2970,7 +2937,6 @@ pub unsafe fn __msa_cle_u_d(a: v2u64, b: v2u64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_s.b, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_s_b(a: v16i8) -> v16i8 { static_assert_simm_bits!(IMM_S5, 5); @@ -2987,7 +2953,6 @@ pub unsafe fn __msa_clei_s_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_s.h, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_s_h(a: v8i16) -> v8i16 { static_assert_simm_bits!(IMM_S5, 5); @@ -3004,7 +2969,6 @@ pub unsafe fn __msa_clei_s_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_s.w, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_s_w(a: v4i32) -> v4i32 { static_assert_simm_bits!(IMM_S5, 5); @@ -3021,7 +2985,6 @@ pub unsafe fn __msa_clei_s_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_s.d, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_s_d(a: v2i64) -> v2i64 { static_assert_simm_bits!(IMM_S5, 5); @@ -3038,7 +3001,6 @@ pub unsafe fn __msa_clei_s_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_u.b, IMM5 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_u_b(a: v16u8) -> v16i8 { static_assert_uimm_bits!(IMM5, 5); @@ -3055,7 +3017,6 @@ pub unsafe fn __msa_clei_u_b(a: v16u8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_u.h, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_u_h(a: v8u16) -> v8i16 { static_assert_uimm_bits!(IMM5, 5); @@ -3072,7 +3033,6 @@ pub unsafe fn __msa_clei_u_h(a: v8u16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_u.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_u_w(a: v4u32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -3089,7 +3049,6 @@ pub unsafe fn __msa_clei_u_w(a: v4u32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clei_u.d, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clei_u_d(a: v2u64) -> v2i64 { static_assert_uimm_bits!(IMM5, 5); @@ -3226,7 +3185,6 @@ pub unsafe fn __msa_clt_u_d(a: v2u64, b: v2u64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_s.b, IMM_S5 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_s_b(a: v16i8) -> v16i8 { static_assert_simm_bits!(IMM_S5, 5); @@ -3243,7 +3201,6 @@ pub unsafe fn __msa_clti_s_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_s.h, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_s_h(a: v8i16) -> v8i16 { static_assert_simm_bits!(IMM_S5, 5); @@ -3260,7 +3217,6 @@ pub unsafe fn __msa_clti_s_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_s.w, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_s_w(a: v4i32) -> v4i32 { static_assert_simm_bits!(IMM_S5, 5); @@ -3277,7 +3233,6 @@ pub unsafe fn __msa_clti_s_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_s.d, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_s_d(a: v2i64) -> v2i64 { static_assert_simm_bits!(IMM_S5, 5); @@ -3294,7 +3249,6 @@ pub unsafe fn __msa_clti_s_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_u.b, IMM5 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_u_b(a: v16u8) -> v16i8 { static_assert_uimm_bits!(IMM5, 5); @@ -3311,7 +3265,6 @@ pub unsafe fn __msa_clti_u_b(a: v16u8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_u.h, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_u_h(a: v8u16) -> v8i16 { static_assert_uimm_bits!(IMM5, 5); @@ -3328,7 +3281,6 @@ pub unsafe fn __msa_clti_u_h(a: v8u16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_u.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_u_w(a: v4u32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -3345,7 +3297,6 @@ pub unsafe fn __msa_clti_u_w(a: v4u32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(clti_u.d, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_clti_u_d(a: v2u64) -> v2i64 { static_assert_uimm_bits!(IMM5, 5); @@ -3360,7 +3311,6 @@ pub unsafe fn __msa_clti_u_d(a: v2u64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_s.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_s_b(a: v16i8) -> i32 { static_assert_uimm_bits!(IMM4, 4); @@ -3375,7 +3325,6 @@ pub unsafe fn __msa_copy_s_b(a: v16i8) -> i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_s.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_s_h(a: v8i16) -> i32 { static_assert_uimm_bits!(IMM3, 3); @@ -3390,7 +3339,6 @@ pub unsafe fn __msa_copy_s_h(a: v8i16) -> i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_s.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_s_w(a: v4i32) -> i32 { static_assert_uimm_bits!(IMM2, 2); @@ -3405,7 +3353,6 @@ pub unsafe fn __msa_copy_s_w(a: v4i32) -> i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_s.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_s_d(a: v2i64) -> i64 { static_assert_uimm_bits!(IMM1, 1); @@ -3420,7 +3367,6 @@ pub unsafe fn __msa_copy_s_d(a: v2i64) -> i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_u.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_u_b(a: v16i8) -> u32 { static_assert_uimm_bits!(IMM4, 4); @@ -3435,7 +3381,6 @@ pub unsafe fn __msa_copy_u_b(a: v16i8) -> u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_u.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_u_h(a: v8i16) -> u32 { static_assert_uimm_bits!(IMM3, 3); @@ -3450,7 +3395,6 @@ pub unsafe fn __msa_copy_u_h(a: v8i16) -> u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(copy_u.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_u_w(a: v4i32) -> u32 { static_assert_uimm_bits!(IMM2, 2); @@ -3464,8 +3408,7 @@ pub unsafe fn __msa_copy_u_w(a: v4i32) -> u32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(copy_u.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(copy_s.d, IMM1 = 0b1))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_copy_u_d(a: v2i64) -> u64 { static_assert_uimm_bits!(IMM1, 1); @@ -3482,7 +3425,6 @@ pub unsafe fn __msa_copy_u_d(a: v2i64) -> u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ctcmsa, IMM5 = 0b1))] -#[rustc_legacy_const_generics(0)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ctcmsa(a: i32) -> () { static_assert_uimm_bits!(IMM5, 5); @@ -5856,7 +5798,6 @@ pub unsafe fn __msa_ilvr_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insert.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insert_b(a: v16i8, c: i32) -> v16i8 { static_assert_uimm_bits!(IMM4, 4); @@ -5872,7 +5813,6 @@ pub unsafe fn __msa_insert_b(a: v16i8, c: i32) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insert.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insert_h(a: v8i16, c: i32) -> v8i16 { static_assert_uimm_bits!(IMM3, 3); @@ -5888,7 +5828,6 @@ pub unsafe fn __msa_insert_h(a: v8i16, c: i32) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insert.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insert_w(a: v4i32, c: i32) -> v4i32 { static_assert_uimm_bits!(IMM2, 2); @@ -5904,7 +5843,6 @@ pub unsafe fn __msa_insert_w(a: v4i32, c: i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insert.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insert_d(a: v2i64, c: i64) -> v2i64 { static_assert_uimm_bits!(IMM1, 1); @@ -5920,7 +5858,6 @@ pub unsafe fn __msa_insert_d(a: v2i64, c: i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insve.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insve_b(a: v16i8, c: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM4, 4); @@ -5936,7 +5873,6 @@ pub unsafe fn __msa_insve_b(a: v16i8, c: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insve.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insve_h(a: v8i16, c: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM3, 3); @@ -5952,7 +5888,6 @@ pub unsafe fn __msa_insve_h(a: v8i16, c: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insve.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insve_w(a: v4i32, c: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM2, 2); @@ -5968,7 +5903,6 @@ pub unsafe fn __msa_insve_w(a: v4i32, c: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(insve.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_insve_d(a: v2i64, c: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM1, 1); @@ -5983,8 +5917,7 @@ pub unsafe fn __msa_insve_d(a: v2i64, c: v2i64) -> v2i64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ld.b, IMM_S10 = -1))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(ld.d, IMM_S10 = -1))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ld_b(mem_addr: *mut u8) -> v16i8 { static_assert_simm_bits!(IMM_S10, 10); @@ -5999,8 +5932,7 @@ pub unsafe fn __msa_ld_b(mem_addr: *mut u8) -> v16i8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ld.h, IMM_S11 = -2))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(ld.d, IMM_S11 = -2))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ld_h(mem_addr: *mut u8) -> v8i16 { static_assert_simm_bits!(IMM_S11, 11); @@ -6016,8 +5948,7 @@ pub unsafe fn __msa_ld_h(mem_addr: *mut u8) -> v8i16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ld.w, IMM_S12 = -4))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(ld.d, IMM_S12 = -4))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ld_w(mem_addr: *mut u8) -> v4i32 { static_assert_simm_bits!(IMM_S12, 12); @@ -6034,7 +5965,6 @@ pub unsafe fn __msa_ld_w(mem_addr: *mut u8) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ld.d, IMM_S13 = -8))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ld_d(mem_addr: *mut u8) -> v2i64 { static_assert_simm_bits!(IMM_S13, 13); @@ -6051,7 +5981,6 @@ pub unsafe fn __msa_ld_d(mem_addr: *mut u8) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(ldi.b, IMM_S10 = -1))] -#[rustc_legacy_const_generics(0)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ldi_b() -> v16i8 { static_assert_simm_bits!(IMM_S10, 10); @@ -6066,8 +5995,7 @@ pub unsafe fn __msa_ldi_b() -> v16i8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ldi.h, IMM_S10 = -1))] -#[rustc_legacy_const_generics(0)] +#[cfg_attr(test, assert_instr(ldi.h, IMM_S10 = 0b01_00001111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ldi_h() -> v8i16 { static_assert_simm_bits!(IMM_S10, 10); @@ -6082,8 +6010,7 @@ pub unsafe fn __msa_ldi_h() -> v8i16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ldi.w, IMM_S10 = -1))] -#[rustc_legacy_const_generics(0)] +#[cfg_attr(test, assert_instr(ldi.w, IMM_S10 = 0b01_00001111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ldi_w() -> v4i32 { static_assert_simm_bits!(IMM_S10, 10); @@ -6098,8 +6025,7 @@ pub unsafe fn __msa_ldi_w() -> v4i32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ldi.d, IMM_S10 = -1))] -#[rustc_legacy_const_generics(0)] +#[cfg_attr(test, assert_instr(ldi.d, IMM_S10 = 0b01_00001111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ldi_d() -> v2i64 { static_assert_simm_bits!(IMM_S10, 10); @@ -6411,7 +6337,6 @@ pub unsafe fn __msa_max_u_d(a: v2u64, b: v2u64) -> v2u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_s.b, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_s_b(a: v16i8) -> v16i8 { static_assert_simm_bits!(IMM_S5, 5); @@ -6427,7 +6352,6 @@ pub unsafe fn __msa_maxi_s_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_s.h, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_s_h(a: v8i16) -> v8i16 { static_assert_simm_bits!(IMM_S5, 5); @@ -6443,7 +6367,6 @@ pub unsafe fn __msa_maxi_s_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_s.w, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_s_w(a: v4i32) -> v4i32 { static_assert_simm_bits!(IMM_S5, 5); @@ -6459,7 +6382,6 @@ pub unsafe fn __msa_maxi_s_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_s.d, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_s_d(a: v2i64) -> v2i64 { static_assert_simm_bits!(IMM_S5, 5); @@ -6475,7 +6397,6 @@ pub unsafe fn __msa_maxi_s_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_u.b, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_u_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM5, 5); @@ -6491,7 +6412,6 @@ pub unsafe fn __msa_maxi_u_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_u.h, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_u_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM5, 5); @@ -6507,7 +6427,6 @@ pub unsafe fn __msa_maxi_u_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_u.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_u_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -6523,7 +6442,6 @@ pub unsafe fn __msa_maxi_u_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(maxi_u.d, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_maxi_u_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM5, 5); @@ -6655,7 +6573,6 @@ pub unsafe fn __msa_min_s_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_s.b, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_s_b(a: v16i8) -> v16i8 { static_assert_simm_bits!(IMM_S5, 5); @@ -6671,7 +6588,6 @@ pub unsafe fn __msa_mini_s_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_s.h, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_s_h(a: v8i16) -> v8i16 { static_assert_simm_bits!(IMM_S5, 5); @@ -6687,7 +6603,6 @@ pub unsafe fn __msa_mini_s_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_s.w, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_s_w(a: v4i32) -> v4i32 { static_assert_simm_bits!(IMM_S5, 5); @@ -6703,7 +6618,6 @@ pub unsafe fn __msa_mini_s_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_s.d, IMM_S5 = -1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_s_d(a: v2i64) -> v2i64 { static_assert_simm_bits!(IMM_S5, 5); @@ -6775,7 +6689,6 @@ pub unsafe fn __msa_min_u_d(a: v2u64, b: v2u64) -> v2u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_u.b, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_u_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM5, 5); @@ -6791,7 +6704,6 @@ pub unsafe fn __msa_mini_u_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_u.h, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_u_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM5, 5); @@ -6807,7 +6719,6 @@ pub unsafe fn __msa_mini_u_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_u.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_u_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -6823,7 +6734,6 @@ pub unsafe fn __msa_mini_u_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(mini_u.d, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_mini_u_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM5, 5); @@ -7343,8 +7253,7 @@ pub unsafe fn __msa_nor_v(a: v16u8, b: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(nori.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(nori.b, IMM8 = 0b1011_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_nori_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -7375,8 +7284,7 @@ pub unsafe fn __msa_or_v(a: v16u8, b: v16u8) -> v16u8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(ori.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(ori.b, IMM8 = 0b1011_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_ori_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -7556,7 +7464,6 @@ pub unsafe fn __msa_pcnt_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_s.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_s_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM3, 3); @@ -7572,7 +7479,6 @@ pub unsafe fn __msa_sat_s_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_s.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_s_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM4, 4); @@ -7588,7 +7494,6 @@ pub unsafe fn __msa_sat_s_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_s.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_s_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -7604,7 +7509,6 @@ pub unsafe fn __msa_sat_s_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_s.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_s_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM6, 6); @@ -7620,7 +7524,6 @@ pub unsafe fn __msa_sat_s_d(a: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_u.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_u_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM3, 3); @@ -7636,7 +7539,6 @@ pub unsafe fn __msa_sat_u_b(a: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_u.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_u_h(a: v8u16) -> v8u16 { static_assert_uimm_bits!(IMM4, 4); @@ -7652,7 +7554,6 @@ pub unsafe fn __msa_sat_u_h(a: v8u16) -> v8u16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_u.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_u_w(a: v4u32) -> v4u32 { static_assert_uimm_bits!(IMM5, 5); @@ -7668,7 +7569,6 @@ pub unsafe fn __msa_sat_u_w(a: v4u32) -> v4u32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sat_u.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sat_u_d(a: v2u64) -> v2u64 { static_assert_uimm_bits!(IMM6, 6); @@ -7685,7 +7585,6 @@ pub unsafe fn __msa_sat_u_d(a: v2u64) -> v2u64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(shf.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_shf_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM8, 8); @@ -7702,7 +7601,6 @@ pub unsafe fn __msa_shf_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(shf.h, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_shf_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM8, 8); @@ -7719,7 +7617,6 @@ pub unsafe fn __msa_shf_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(shf.w, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_shf_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM8, 8); @@ -7824,7 +7721,6 @@ pub unsafe fn __msa_sld_d(a: v2i64, b: v2i64, c: i32) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sldi.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sldi_b(a: v16i8, b: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM4, 4); @@ -7844,8 +7740,7 @@ pub unsafe fn __msa_sldi_b(a: v16i8, b: v16i8) -> v16i8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(sldi.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(sldi.h, IMM3 = 0b101))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sldi_h(a: v8i16, b: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM3, 3); @@ -7866,7 +7761,6 @@ pub unsafe fn __msa_sldi_h(a: v8i16, b: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sldi.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sldi_w(a: v4i32, b: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM2, 2); @@ -7887,7 +7781,6 @@ pub unsafe fn __msa_sldi_w(a: v4i32, b: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(sldi.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_sldi_d(a: v2i64, b: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM1, 1); @@ -7962,12 +7855,11 @@ pub unsafe fn __msa_sll_d(a: v2i64, b: v2i64) -> v2i64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(slli.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(slli.b, IMM3 = 0b111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_slli_b(a: v16i8) -> v16i8 { - static_assert_uimm_bits!(IMM4, 4); - msa_slli_b(a, IMM4) +pub unsafe fn __msa_slli_b(a: v16i8) -> v16i8 { + static_assert_uimm_bits!(IMM3, 3); + msa_slli_b(a, IMM3) } /// Immediate Shift Left @@ -7978,12 +7870,11 @@ pub unsafe fn __msa_slli_b(a: v16i8) -> v16i8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(slli.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(slli.h, IMM4 = 0b1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_slli_h(a: v8i16) -> v8i16 { - static_assert_uimm_bits!(IMM3, 3); - msa_slli_h(a, IMM3) +pub unsafe fn __msa_slli_h(a: v8i16) -> v8i16 { + static_assert_uimm_bits!(IMM4, 4); + msa_slli_h(a, IMM4) } /// Immediate Shift Left @@ -7994,12 +7885,11 @@ pub unsafe fn __msa_slli_h(a: v8i16) -> v8i16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(slli.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(slli.w, IMM5 = 0b1_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_slli_w(a: v4i32) -> v4i32 { - static_assert_uimm_bits!(IMM2, 2); - msa_slli_w(a, IMM2) +pub unsafe fn __msa_slli_w(a: v4i32) -> v4i32 { + static_assert_uimm_bits!(IMM5, 5); + msa_slli_w(a, IMM5) } /// Immediate Shift Left @@ -8010,12 +7900,11 @@ pub unsafe fn __msa_slli_w(a: v4i32) -> v4i32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(slli.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(slli.d, IMM6 = 0b11_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_slli_d(a: v2i64) -> v2i64 { - static_assert_uimm_bits!(IMM1, 1); - msa_slli_d(a, IMM1) +pub unsafe fn __msa_slli_d(a: v2i64) -> v2i64 { + static_assert_uimm_bits!(IMM6, 6); + msa_slli_d(a, IMM6) } /// GPR Element Splat @@ -8086,7 +7975,6 @@ pub unsafe fn __msa_splat_d(a: v2i64, b: i32) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(splati.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_splati_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM4, 4); @@ -8101,7 +7989,6 @@ pub unsafe fn __msa_splati_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(splati.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_splati_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM3, 3); @@ -8116,7 +8003,6 @@ pub unsafe fn __msa_splati_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(splati.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_splati_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM2, 2); @@ -8131,7 +8017,6 @@ pub unsafe fn __msa_splati_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(splati.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_splati_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM1, 1); @@ -8207,7 +8092,6 @@ pub unsafe fn __msa_sra_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srai.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srai_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM3, 3); @@ -8223,7 +8107,6 @@ pub unsafe fn __msa_srai_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srai.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srai_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM4, 4); @@ -8239,7 +8122,6 @@ pub unsafe fn __msa_srai_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srai.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srai_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -8255,7 +8137,6 @@ pub unsafe fn __msa_srai_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srai.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srai_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM6, 6); @@ -8336,7 +8217,6 @@ pub unsafe fn __msa_srar_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srari.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srari_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM3, 3); @@ -8353,7 +8233,6 @@ pub unsafe fn __msa_srari_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srari.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srari_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM4, 4); @@ -8370,7 +8249,6 @@ pub unsafe fn __msa_srari_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srari.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srari_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -8387,7 +8265,6 @@ pub unsafe fn __msa_srari_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srari.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srari_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM6, 6); @@ -8462,12 +8339,11 @@ pub unsafe fn __msa_srl_d(a: v2i64, b: v2i64) -> v2i64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(srli.b, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(srli.b, IMM3 = 0b111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_srli_b(a: v16i8) -> v16i8 { - static_assert_uimm_bits!(IMM4, 4); - msa_srli_b(a, IMM4) +pub unsafe fn __msa_srli_b(a: v16i8) -> v16i8 { + static_assert_uimm_bits!(IMM3, 3); + msa_srli_b(a, IMM3) } /// Immediate Shift Right Logical @@ -8478,12 +8354,11 @@ pub unsafe fn __msa_srli_b(a: v16i8) -> v16i8 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(srli.h, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(srli.h, IMM4 = 0b1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_srli_h(a: v8i16) -> v8i16 { - static_assert_uimm_bits!(IMM3, 3); - msa_srli_h(a, IMM3) +pub unsafe fn __msa_srli_h(a: v8i16) -> v8i16 { + static_assert_uimm_bits!(IMM4, 4); + msa_srli_h(a, IMM4) } /// Immediate Shift Right Logical @@ -8494,12 +8369,11 @@ pub unsafe fn __msa_srli_h(a: v8i16) -> v8i16 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(srli.w, IMM2 = 0b11))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(srli.w, IMM5 = 0b1_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_srli_w(a: v4i32) -> v4i32 { - static_assert_uimm_bits!(IMM2, 2); - msa_srli_w(a, IMM2) +pub unsafe fn __msa_srli_w(a: v4i32) -> v4i32 { + static_assert_uimm_bits!(IMM5, 5); + msa_srli_w(a, IMM5) } /// Immediate Shift Right Logical @@ -8510,12 +8384,11 @@ pub unsafe fn __msa_srli_w(a: v4i32) -> v4i32 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(srli.d, IMM1 = 0b1))] -#[rustc_legacy_const_generics(1)] +#[cfg_attr(test, assert_instr(srli.d, IMM6 = 0b11_1111))] #[unstable(feature = "stdarch_mips", issue = "111198")] -pub unsafe fn __msa_srli_d(a: v2i64) -> v2i64 { - static_assert_uimm_bits!(IMM1, 1); - msa_srli_d(a, IMM1) +pub unsafe fn __msa_srli_d(a: v2i64) -> v2i64 { + static_assert_uimm_bits!(IMM6, 6); + msa_srli_d(a, IMM6) } /// Vector Shift Right Logical Rounded @@ -8592,7 +8465,6 @@ pub unsafe fn __msa_srlr_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srlri.b, IMM3 = 0b111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srlri_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM3, 3); @@ -8609,7 +8481,6 @@ pub unsafe fn __msa_srlri_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srlri.h, IMM4 = 0b1111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srlri_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM4, 4); @@ -8626,7 +8497,6 @@ pub unsafe fn __msa_srlri_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srlri.w, IMM5 = 0b11111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srlri_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -8643,7 +8513,6 @@ pub unsafe fn __msa_srlri_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(srlri.d, IMM6 = 0b111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_srlri_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM6, 6); @@ -8658,8 +8527,7 @@ pub unsafe fn __msa_srlri_d(a: v2i64) -> v2i64 { /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(st.b, IMM_S10 = -1))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(st.d, IMM_S10 = -1))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_st_b(a: v16i8, mem_addr: *mut u8) -> () { static_assert_simm_bits!(IMM_S10, 10); @@ -8674,8 +8542,7 @@ pub unsafe fn __msa_st_b(a: v16i8, mem_addr: *mut u8) -> () /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(st.h, IMM_S11 = -2))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(st.d, IMM_S11 = -2))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_st_h(a: v8i16, mem_addr: *mut u8) -> () { static_assert_simm_bits!(IMM_S11, 11); @@ -8691,8 +8558,7 @@ pub unsafe fn __msa_st_h(a: v8i16, mem_addr: *mut u8) -> () /// #[inline] #[target_feature(enable = "msa")] -#[cfg_attr(test, assert_instr(st.w, IMM_S12 = -4))] -#[rustc_legacy_const_generics(2)] +#[cfg_attr(test, assert_instr(st.d, IMM_S12 = -4))] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_st_w(a: v4i32, mem_addr: *mut u8) -> () { static_assert_simm_bits!(IMM_S12, 12); @@ -8709,7 +8575,6 @@ pub unsafe fn __msa_st_w(a: v4i32, mem_addr: *mut u8) -> () #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(st.d, IMM_S13 = -8))] -#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_st_d(a: v2i64, mem_addr: *mut u8) -> () { static_assert_simm_bits!(IMM_S13, 13); @@ -9022,7 +8887,6 @@ pub unsafe fn __msa_subv_d(a: v2i64, b: v2i64) -> v2i64 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(subvi.b, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_subvi_b(a: v16i8) -> v16i8 { static_assert_uimm_bits!(IMM5, 5); @@ -9038,7 +8902,6 @@ pub unsafe fn __msa_subvi_b(a: v16i8) -> v16i8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(subvi.h, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_subvi_h(a: v8i16) -> v8i16 { static_assert_uimm_bits!(IMM5, 5); @@ -9054,7 +8917,6 @@ pub unsafe fn __msa_subvi_h(a: v8i16) -> v8i16 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(subvi.w, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_subvi_w(a: v4i32) -> v4i32 { static_assert_uimm_bits!(IMM5, 5); @@ -9070,7 +8932,6 @@ pub unsafe fn __msa_subvi_w(a: v4i32) -> v4i32 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(subvi.d, IMM5 = 0b10111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_subvi_d(a: v2i64) -> v2i64 { static_assert_uimm_bits!(IMM5, 5); @@ -9174,7 +9035,6 @@ pub unsafe fn __msa_xor_v(a: v16u8, b: v16u8) -> v16u8 { #[inline] #[target_feature(enable = "msa")] #[cfg_attr(test, assert_instr(xori.b, IMM8 = 0b11111111))] -#[rustc_legacy_const_generics(1)] #[unstable(feature = "stdarch_mips", issue = "111198")] pub unsafe fn __msa_xori_b(a: v16u8) -> v16u8 { static_assert_uimm_bits!(IMM8, 8); @@ -13245,14 +13105,15 @@ mod tests { #[simd_test(enable = "msa")] unsafe fn test_msa_fmadd_w() { - #[rustfmt::skip] let a = f32x4::new(1.0, 2.0, 3.0, 4.0); - #[rustfmt::skip] let b = f32x4::new(5.0, 6.0, 7.0, 8.0); - #[rustfmt::skip] let c = f32x4::new(9.0, 10.0, 11.0, 12.0); - #[rustfmt::skip] - let r = f32x4::new(46.0, 62.0, 80.0, 100.0); + let r = f32x4::new( + 1.0 * 5.0 + 9.0, + 2.0 * 6.0 + 10.0, + 3.0 * 7.0 + 11.0, + 4.0 * 8.0 + 12.0, + ); assert_eq!( r, @@ -13266,14 +13127,10 @@ mod tests { #[simd_test(enable = "msa")] unsafe fn test_msa_fmadd_d() { - #[rustfmt::skip] let a = f64x2::new(1.0, 2.0); - #[rustfmt::skip] let b = f64x2::new(3.0, 4.0); - #[rustfmt::skip] let c = f64x2::new(5.0, 6.0); - #[rustfmt::skip] - let r = f64x2::new(16.0, 26.0); + let r = f64x2::new(1.0 * 3.0 + 5.0, 2.0 * 4.0 + 6.0); assert_eq!( r, diff --git a/library/stdarch/crates/core_arch/src/mod.rs b/library/stdarch/crates/core_arch/src/mod.rs index 4583142cd59cd..d19ed25a5b140 100644 --- a/library/stdarch/crates/core_arch/src/mod.rs +++ b/library/stdarch/crates/core_arch/src/mod.rs @@ -308,11 +308,11 @@ pub mod arch { /// See the [module documentation](../index.html) for more details. #[cfg(any(target_arch = "loongarch64", doc))] #[doc(cfg(target_arch = "loongarch64"))] - #[stable(feature = "stdarch_loongarch64", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch64", since = "1.101.0")] pub mod loongarch64 { - #[stable(feature = "stdarch_loongarch64", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch64", since = "1.101.0")] pub use crate::core_arch::loongarch_shared::*; - #[stable(feature = "stdarch_loongarch64", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_loongarch64", since = "1.101.0")] pub use crate::core_arch::loongarch64::*; } diff --git a/library/stdarch/crates/core_arch/src/powerpc/altivec.rs b/library/stdarch/crates/core_arch/src/powerpc/altivec.rs index a8621802b90f2..4bd6b1e99208e 100644 --- a/library/stdarch/crates/core_arch/src/powerpc/altivec.rs +++ b/library/stdarch/crates/core_arch/src/powerpc/altivec.rs @@ -408,6 +408,11 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.nearbyint.v4f32"] fn vrfin(a: vector_float) -> vector_float; + + #[link_name = "llvm.ppc.altivec.vclzlsbb"] + fn vclzlsbb(a: vector_signed_char) -> i32; + #[link_name = "llvm.ppc.altivec.vctzlsbb"] + fn vctzlsbb(a: vector_signed_char) -> i32; } #[macro_use] @@ -3305,6 +3310,62 @@ mod sealed { vec_vrfin(self) } } + + #[inline] + #[target_feature(enable = "power9-vector")] + #[cfg_attr(test, assert_instr(vclzlsbb))] + pub unsafe fn vec_vcntlz_lsbb(a: vector_signed_char) -> i32 { + vclzlsbb(a) + } + + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub trait VectorCntlzLsbb { + unsafe fn vec_cntlz_lsbb(self) -> i32; + } + + macro_rules! impl_vec_cntlz_lsbb { + ($a:ty) => { + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + impl VectorCntlzLsbb for $a { + #[inline] + #[target_feature(enable = "power9-vector")] + unsafe fn vec_cntlz_lsbb(self) -> i32 { + vec_vcntlz_lsbb(transmute(self)) + } + } + }; + } + + impl_vec_cntlz_lsbb! { vector_signed_char } + impl_vec_cntlz_lsbb! { vector_unsigned_char } + + #[inline] + #[target_feature(enable = "power9-vector")] + #[cfg_attr(test, assert_instr(vctzlsbb))] + pub unsafe fn vec_vcnttz_lsbb(a: vector_signed_char) -> i32 { + vctzlsbb(a) + } + + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub trait VectorCnttzLsbb { + unsafe fn vec_cnttz_lsbb(self) -> i32; + } + + macro_rules! impl_vec_cnttz_lsbb { + ($a:ty) => { + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + impl VectorCnttzLsbb for $a { + #[inline] + #[target_feature(enable = "power9-vector")] + unsafe fn vec_cnttz_lsbb(self) -> i32 { + vec_vcnttz_lsbb(transmute(self)) + } + } + }; + } + + impl_vec_cnttz_lsbb! { vector_signed_char } + impl_vec_cnttz_lsbb! { vector_unsigned_char } } /// Vector Insert @@ -4236,6 +4297,30 @@ mod endian { { a.vec_mule(b) } + + // Trailing and leading are swapped in little-endian + + /// Vector Count Leading Zero Least-Significant Bits Byte + #[inline] + #[target_feature(enable = "power9-vector")] + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub unsafe fn vec_cntlz_lsbb(a: T) -> i32 + where + T: sealed::VectorCnttzLsbb, + { + a.vec_cnttz_lsbb() + } + + /// Vector Count Trailing Zero Least-Significant Bits Byte + #[inline] + #[target_feature(enable = "power9-vector")] + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub unsafe fn vec_cnttz_lsbb(a: T) -> i32 + where + T: sealed::VectorCntlzLsbb, + { + a.vec_cntlz_lsbb() + } } /// Vector Multiply @@ -4679,6 +4764,28 @@ mod endian { { a.vec_mulo(b) } + + /// Vector Count Leading Zero Least-Significant Bits Byte + #[inline] + #[target_feature(enable = "power9-altivec")] + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub unsafe fn vec_cntlz_lsbb(a: T) -> i32 + where + T: sealed::VectorCntlzLsbb, + { + a.vec_cntlz_lsbb() + } + + /// Vector Count Trailing Zero Least-Significant Bits Byte + #[inline] + #[target_feature(enable = "power9-altivec")] + #[unstable(feature = "stdarch_powerpc", issue = "111145")] + pub unsafe fn vec_cnttz_lsbb(a: T) -> i32 + where + T: sealed::VectorCnttzLsbb, + { + a.vec_cnttz_lsbb() + } } #[unstable(feature = "stdarch_powerpc", issue = "111145")] @@ -6767,4 +6874,22 @@ mod tests { [4, 8, 12, 68], [0x23456781, 0xBCDEF09A, 0xF0F0F0F0, 0x23456781] } + + #[simd_test(enable = "power9-vector")] + fn test_vec_cntlz_lsbb() { + let a = i8x16::new(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0); + + let count = unsafe { vec_cntlz_lsbb(transmute::<_, vector_signed_char>(a)) }; + + assert_eq!(count, 4); + } + + #[simd_test(enable = "power9-vector")] + fn test_vec_cnttz_lsbb() { + let a = i8x16::new(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0); + + let count = unsafe { vec_cnttz_lsbb(transmute::<_, vector_signed_char>(a)) }; + + assert_eq!(count, 2); + } } diff --git a/library/stdarch/crates/core_arch/src/powerpc/vsx.rs b/library/stdarch/crates/core_arch/src/powerpc/vsx.rs index 5f62aebca92b9..7f8e8e4fd1cf3 100644 --- a/library/stdarch/crates/core_arch/src/powerpc/vsx.rs +++ b/library/stdarch/crates/core_arch/src/powerpc/vsx.rs @@ -176,7 +176,6 @@ mod sealed { /// Vector permute. #[inline] #[target_feature(enable = "vsx")] -//#[rustc_legacy_const_generics(2)] #[unstable(feature = "stdarch_powerpc", issue = "111145")] pub unsafe fn vec_xxpermdi(a: T, b: T) -> T where diff --git a/library/stdarch/crates/core_arch/src/riscv32/mod.rs b/library/stdarch/crates/core_arch/src/riscv32/mod.rs index 7ff871227b503..7017b7edc479b 100644 --- a/library/stdarch/crates/core_arch/src/riscv32/mod.rs +++ b/library/stdarch/crates/core_arch/src/riscv32/mod.rs @@ -1,6 +1,10 @@ //! RISC-V RV32 specific intrinsics +mod zb; mod zk; +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +pub use zb::*; + #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub use zk::*; diff --git a/library/stdarch/crates/core_arch/src/riscv32/zb.rs b/library/stdarch/crates/core_arch/src/riscv32/zb.rs new file mode 100644 index 0000000000000..1639890baf9bd --- /dev/null +++ b/library/stdarch/crates/core_arch/src/riscv32/zb.rs @@ -0,0 +1,137 @@ +#[cfg(test)] +use stdarch_test::assert_instr; + +unsafe extern "llvm-intrinsic" { + #[link_name = "llvm.riscv.xperm8.i32"] + fn _xperm8_32(rs1: u32, rs2: u32) -> u32; + + #[link_name = "llvm.riscv.xperm4.i32"] + fn _xperm4_32(rs1: u32, rs2: u32) -> u32; + + #[link_name = "llvm.riscv.clmulh.i32"] + fn _clmulh_32(rs1: u32, rs2: u32) -> u32; + + #[link_name = "llvm.riscv.clmulr.i32"] + fn _clmulr_32(rs1: u32, rs2: u32) -> u32; + + #[link_name = "llvm.riscv.zip.i32"] + fn _zip_32(rs1: u32) -> u32; + + #[link_name = "llvm.riscv.unzip.i32"] + fn _unzip_32(rs1: u32) -> u32; +} + +/// Byte-wise lookup of indices into a vector in registers. +/// +/// The xperm8 instruction operates on bytes. The rs1 register contains a vector of 4 +/// 8-bit elements. The rs2 register contains a vector of 4 8-bit indexes. The result is +/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 +/// is out of bounds. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.47 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkx")] +#[cfg_attr(test, assert_instr(xperm8))] +#[inline] +pub fn xperm8_32(rs1: u32, rs2: u32) -> u32 { + unsafe { _xperm8_32(rs1, rs2) } +} + +/// Nibble-wise lookup of indices into a vector. +/// +/// The xperm4 instruction operates on nibbles. The rs1 register contains a vector of 8 +/// 4-bit elements. The rs2 register contains a vector of 8 4-bit indexes. The result is +/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 +/// is out of bounds. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.48 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkx")] +#[cfg_attr(test, assert_instr(xperm4))] +#[inline] +pub fn xperm4_32(rs1: u32, rs2: u32) -> u32 { + unsafe { _xperm4_32(rs1, rs2) } +} + +/// Carry-less multiply (high-part) +/// +/// clmulh produces the upper half of the 64-bit carry-less product. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.12 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkc")] +#[cfg_attr(test, assert_instr(clmulh))] +#[inline] +pub fn clmulh_32(rs1: u32, rs2: u32) -> u32 { + unsafe { _clmulh_32(rs1, rs2) } +} + +/// Carry-less multiply (reversed) +/// +/// clmulr produces bits 62:31 of the 64-bit carry-less product. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.13 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbc")] +#[cfg_attr(test, assert_instr(clmulr))] +#[inline] +pub fn clmulr_32(rs1: u32, rs2: u32) -> u32 { + unsafe { _clmulr_32(rs1, rs2) } +} + +/// Place upper/lower halves of the source register into odd/even bits of the destination +/// respectivley. +/// +/// This instruction places bits in the low half of the source register into the even bit +/// positions of the destination, and bits in the high half of the source register into the odd +/// bit positions of the destination. It is the inverse of the unzip instruction. This +/// instruction is available only on RV32. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.49 +#[target_feature(enable = "zbkb")] +// See #1464 +// #[cfg_attr(test, assert_instr(zip))] +#[inline] +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +pub fn zip_32(rs: u32) -> u32 { + unsafe { _zip_32(rs) } +} + +/// Place odd and even bits of the source word into upper/lower halves of the destination. +/// +/// This instruction places the even bits of the source register into the low half of the +/// destination, and the odd bits of the source into the high bits of the destination. It is +/// the inverse of the zip instruction. This instruction is available only on RV32. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.45 +#[target_feature(enable = "zbkb")] +#[cfg_attr(test, assert_instr(unzip))] +#[inline] +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +pub fn unzip_32(rs: u32) -> u32 { + unsafe { _unzip_32(rs) } +} diff --git a/library/stdarch/crates/core_arch/src/riscv32/zk.rs b/library/stdarch/crates/core_arch/src/riscv32/zk.rs index 3ffe0819e75bd..ae3d80fa2a0d3 100644 --- a/library/stdarch/crates/core_arch/src/riscv32/zk.rs +++ b/library/stdarch/crates/core_arch/src/riscv32/zk.rs @@ -3,40 +3,34 @@ use stdarch_test::assert_instr; unsafe extern "llvm-intrinsic" { #[link_name = "llvm.riscv.aes32esi"] - fn _aes32esi(rs1: i32, rs2: i32, bs: i32) -> i32; + fn _aes32esi(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.aes32esmi"] - fn _aes32esmi(rs1: i32, rs2: i32, bs: i32) -> i32; + fn _aes32esmi(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.aes32dsi"] - fn _aes32dsi(rs1: i32, rs2: i32, bs: i32) -> i32; + fn _aes32dsi(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.aes32dsmi"] - fn _aes32dsmi(rs1: i32, rs2: i32, bs: i32) -> i32; - - #[link_name = "llvm.riscv.zip.i32"] - fn _zip(rs1: i32) -> i32; - - #[link_name = "llvm.riscv.unzip.i32"] - fn _unzip(rs1: i32) -> i32; + fn _aes32dsmi(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.sha512sig0h"] - fn _sha512sig0h(rs1: i32, rs2: i32) -> i32; + fn _sha512sig0h(rs1: u32, rs2: u32) -> u32; #[link_name = "llvm.riscv.sha512sig0l"] - fn _sha512sig0l(rs1: i32, rs2: i32) -> i32; + fn _sha512sig0l(rs1: u32, rs2: u32) -> u32; #[link_name = "llvm.riscv.sha512sig1h"] - fn _sha512sig1h(rs1: i32, rs2: i32) -> i32; + fn _sha512sig1h(rs1: u32, rs2: u32) -> u32; #[link_name = "llvm.riscv.sha512sig1l"] - fn _sha512sig1l(rs1: i32, rs2: i32) -> i32; + fn _sha512sig1l(rs1: u32, rs2: u32) -> u32; #[link_name = "llvm.riscv.sha512sum0r"] - fn _sha512sum0r(rs1: i32, rs2: i32) -> i32; + fn _sha512sum0r(rs1: u32, rs2: u32) -> u32; #[link_name = "llvm.riscv.sha512sum1r"] - fn _sha512sum1r(rs1: i32, rs2: i32) -> i32; + fn _sha512sum1r(rs1: u32, rs2: u32) -> u32; } /// AES final round encryption instruction for RV32. @@ -57,7 +51,6 @@ unsafe extern "llvm-intrinsic" { /// The `BS` parameter is expected to be a constant value and only the bottom 2 bits of `bs` are /// used. #[target_feature(enable = "zkne")] -#[rustc_legacy_const_generics(2)] // See #1464 // #[cfg_attr(test, assert_instr(aes32esi, BS = 0))] #[inline] @@ -65,10 +58,10 @@ unsafe extern "llvm-intrinsic" { pub fn aes32esi(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _aes32esi(rs1 as i32, rs2 as i32, BS as i32) as u32 } + unsafe { _aes32esi(rs1, rs2, BS as u32) } } -/// AES middle round encryption instruction for RV32 with. +/// AES middle round encryption instruction for RV32. /// /// This instruction sources a single byte from rs2 according to bs. To this it applies the /// forward AES SBox operation, and a partial forward MixColumn, before XOR’ing the result with @@ -86,7 +79,6 @@ pub fn aes32esi(rs1: u32, rs2: u32) -> u32 { /// The `bs` parameter is expected to be a constant value and only the bottom 2 bits of `bs` are /// used. #[target_feature(enable = "zkne")] -#[rustc_legacy_const_generics(2)] // See #1464 // #[cfg_attr(test, assert_instr(aes32esmi, BS = 0))] #[inline] @@ -94,7 +86,7 @@ pub fn aes32esi(rs1: u32, rs2: u32) -> u32 { pub fn aes32esmi(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _aes32esmi(rs1 as i32, rs2 as i32, BS as i32) as u32 } + unsafe { _aes32esmi(rs1, rs2, BS as u32) } } /// AES final round decryption instruction for RV32. @@ -114,7 +106,6 @@ pub fn aes32esmi(rs1: u32, rs2: u32) -> u32 { /// The `BS` parameter is expected to be a constant value and only the bottom 2 bits of `bs` are /// used. #[target_feature(enable = "zknd")] -#[rustc_legacy_const_generics(2)] // See #1464 // #[cfg_attr(test, assert_instr(aes32dsi, BS = 0))] #[inline] @@ -122,7 +113,7 @@ pub fn aes32esmi(rs1: u32, rs2: u32) -> u32 { pub fn aes32dsi(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _aes32dsi(rs1 as i32, rs2 as i32, BS as i32) as u32 } + unsafe { _aes32dsi(rs1, rs2, BS as u32) } } /// AES middle round decryption instruction for RV32. @@ -143,7 +134,6 @@ pub fn aes32dsi(rs1: u32, rs2: u32) -> u32 { /// The `BS` parameter is expected to be a constant value and only the bottom 2 bits of `bs` are /// used. #[target_feature(enable = "zknd")] -#[rustc_legacy_const_generics(2)] // See #1464 // #[cfg_attr(test, assert_instr(aes32dsmi, BS = 0))] #[inline] @@ -151,48 +141,7 @@ pub fn aes32dsi(rs1: u32, rs2: u32) -> u32 { pub fn aes32dsmi(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _aes32dsmi(rs1 as i32, rs2 as i32, BS as i32) as u32 } -} - -/// Place upper/lower halves of the source register into odd/even bits of the destination -/// respectivley. -/// -/// This instruction places bits in the low half of the source register into the even bit -/// positions of the destination, and bits in the high half of the source register into the odd -/// bit positions of the destination. It is the inverse of the unzip instruction. This -/// instruction is available only on RV32. -/// -/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions -/// -/// Version: v1.0.1 -/// -/// Section: 3.49 -#[target_feature(enable = "zbkb")] -// See #1464 -// #[cfg_attr(test, assert_instr(zip))] -#[inline] -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -pub fn zip(rs: u32) -> u32 { - unsafe { _zip(rs as i32) as u32 } -} - -/// Place odd and even bits of the source word into upper/lower halves of the destination. -/// -/// This instruction places the even bits of the source register into the low half of the -/// destination, and the odd bits of the source into the high bits of the destination. It is -/// the inverse of the zip instruction. This instruction is available only on RV32. -/// -/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions -/// -/// Version: v1.0.1 -/// -/// Section: 3.45 -#[target_feature(enable = "zbkb")] -#[cfg_attr(test, assert_instr(unzip))] -#[inline] -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -pub fn unzip(rs: u32) -> u32 { - unsafe { _unzip(rs as i32) as u32 } + unsafe { _aes32dsmi(rs1, rs2, BS as u32) } } /// Implements the high half of the Sigma0 transformation, as used in the SHA2-512 hash @@ -215,7 +164,7 @@ pub fn unzip(rs: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig0h(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sig0h(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sig0h(rs1, rs2) } } /// Implements the low half of the Sigma0 transformation, as used in the SHA2-512 hash function @@ -238,7 +187,7 @@ pub fn sha512sig0h(rs1: u32, rs2: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig0l(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sig0l(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sig0l(rs1, rs2) } } /// Implements the high half of the Sigma1 transformation, as used in the SHA2-512 hash @@ -261,7 +210,7 @@ pub fn sha512sig0l(rs1: u32, rs2: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig1h(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sig1h(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sig1h(rs1, rs2) } } /// Implements the low half of the Sigma1 transformation, as used in the SHA2-512 hash function @@ -283,7 +232,7 @@ pub fn sha512sig1h(rs1: u32, rs2: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig1l(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sig1l(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sig1l(rs1, rs2) } } /// Implements the Sum0 transformation, as used in the SHA2-512 hash function \[49\] (Section @@ -305,7 +254,7 @@ pub fn sha512sig1l(rs1: u32, rs2: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sum0r(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sum0r(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sum0r(rs1, rs2) } } /// Implements the Sum1 transformation, as used in the SHA2-512 hash function \[49\] (Section @@ -327,5 +276,5 @@ pub fn sha512sum0r(rs1: u32, rs2: u32) -> u32 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sum1r(rs1: u32, rs2: u32) -> u32 { - unsafe { _sha512sum1r(rs1 as i32, rs2 as i32) as u32 } + unsafe { _sha512sum1r(rs1, rs2) } } diff --git a/library/stdarch/crates/core_arch/src/riscv64/mod.rs b/library/stdarch/crates/core_arch/src/riscv64/mod.rs index a7efc0c7f58a1..8301ea2b23401 100644 --- a/library/stdarch/crates/core_arch/src/riscv64/mod.rs +++ b/library/stdarch/crates/core_arch/src/riscv64/mod.rs @@ -1,8 +1,12 @@ //! RISC-V RV64 specific intrinsics use crate::arch::asm; +mod zb; mod zk; +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +pub use zb::*; + #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub use zk::*; diff --git a/library/stdarch/crates/core_arch/src/riscv64/zb.rs b/library/stdarch/crates/core_arch/src/riscv64/zb.rs new file mode 100644 index 0000000000000..95c6fdf9cda1b --- /dev/null +++ b/library/stdarch/crates/core_arch/src/riscv64/zb.rs @@ -0,0 +1,132 @@ +#[cfg(test)] +use stdarch_test::assert_instr; + +unsafe extern "llvm-intrinsic" { + #[link_name = "llvm.riscv.xperm8.i64"] + fn _xperm8_64(rs1: u64, rs2: u64) -> u64; + + #[link_name = "llvm.riscv.xperm4.i64"] + fn _xperm4_64(rs1: u64, rs2: u64) -> u64; + + #[link_name = "llvm.riscv.orc.b.i64"] + fn _orc_b_64(rs: u64) -> u64; + + #[link_name = "llvm.riscv.clmul.i64"] + fn _clmul_64(rs1: u64, rs2: u64) -> u64; + + #[link_name = "llvm.riscv.clmulh.i64"] + fn _clmulh_64(rs1: u64, rs2: u64) -> u64; + + #[link_name = "llvm.riscv.clmulr.i64"] + fn _clmulr_64(rs1: u64, rs2: u64) -> u64; +} + +/// Byte-wise lookup of indices into a vector in registers. +/// +/// The xperm8 instruction operates on bytes. The rs1 register contains a vector of 8 +/// 8-bit elements. The rs2 register contains a vector of 8 8-bit indexes. The result is +/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 +/// is out of bounds. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.47 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkx")] +#[cfg_attr(test, assert_instr(xperm8))] +#[inline] +pub fn xperm8_64(rs1: u64, rs2: u64) -> u64 { + unsafe { _xperm8_64(rs1, rs2) } +} + +/// Nibble-wise lookup of indices into a vector. +/// +/// The xperm4 instruction operates on nibbles. The rs1 register contains a vector of 16 +/// 4-bit elements. The rs2 register contains a vector of 16 4-bit indexes. The result is +/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 +/// is out of bounds. +/// +/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions +/// +/// Version: v1.0.1 +/// +/// Section: 3.48 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkx")] +#[cfg_attr(test, assert_instr(xperm4))] +#[inline] +pub fn xperm4_64(rs1: u64, rs2: u64) -> u64 { + unsafe { _xperm4_64(rs1, rs2) } +} + +/// Bitwise OR-Combine, byte granule +/// +/// Combines the bits within every byte through a reciprocal bitwise logical OR. This sets the bits of each byte in +/// the result rd to all zeros if no bit within the respective byte of rs is set, or to all ones if any bit within the +/// respective byte of rs is set. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.24 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbb")] +#[cfg_attr(test, assert_instr(orc.b))] +#[inline] +pub fn orc_b_64(rs: u64) -> u64 { + unsafe { _orc_b_64(rs) } +} + +/// Carry-less multiply (low-part) +/// +/// clmul produces the lower half of the 128-bit carry-less product. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.11 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkc")] +#[cfg_attr(test, assert_instr(clmul))] +#[inline] +pub fn clmul_64(rs1: u64, rs2: u64) -> u64 { + unsafe { _clmul_64(rs1, rs2) } +} + +/// Carry-less multiply (high-part) +/// +/// clmulh produces the upper half of the 128-bit carry-less product. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.12 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbkc")] +#[cfg_attr(test, assert_instr(clmulh))] +#[inline] +pub fn clmulh_64(rs1: u64, rs2: u64) -> u64 { + unsafe { _clmulh_64(rs1, rs2) } +} + +/// Carry-less multiply (reversed) +/// +/// clmulr produces bits 126:63 of the 128-bit carry-less product. +/// +/// Source: RISC-V Bit-Manipulation ISA-extensions +/// +/// Version: v1.0.0 +/// +/// Section: 2.13 +#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] +#[target_feature(enable = "zbc")] +#[cfg_attr(test, assert_instr(clmulr))] +#[inline] +pub fn clmulr_64(rs1: u64, rs2: u64) -> u64 { + unsafe { _clmulr_64(rs1, rs2) } +} diff --git a/library/stdarch/crates/core_arch/src/riscv64/zk.rs b/library/stdarch/crates/core_arch/src/riscv64/zk.rs index 21cfefafdd5c0..6903c2ae4f0c1 100644 --- a/library/stdarch/crates/core_arch/src/riscv64/zk.rs +++ b/library/stdarch/crates/core_arch/src/riscv64/zk.rs @@ -5,31 +5,31 @@ use crate::arch::asm; unsafe extern "llvm-intrinsic" { #[link_name = "llvm.riscv.aes64es"] - fn _aes64es(rs1: i64, rs2: i64) -> i64; + fn _aes64es(rs1: u64, rs2: u64) -> u64; #[link_name = "llvm.riscv.aes64esm"] - fn _aes64esm(rs1: i64, rs2: i64) -> i64; + fn _aes64esm(rs1: u64, rs2: u64) -> u64; #[link_name = "llvm.riscv.aes64ds"] - fn _aes64ds(rs1: i64, rs2: i64) -> i64; + fn _aes64ds(rs1: u64, rs2: u64) -> u64; #[link_name = "llvm.riscv.aes64dsm"] - fn _aes64dsm(rs1: i64, rs2: i64) -> i64; + fn _aes64dsm(rs1: u64, rs2: u64) -> u64; #[link_name = "llvm.riscv.aes64im"] - fn _aes64im(rs1: i64) -> i64; + fn _aes64im(rs1: u64) -> u64; #[link_name = "llvm.riscv.sha512sig0"] - fn _sha512sig0(rs1: i64) -> i64; + fn _sha512sig0(rs1: u64) -> u64; #[link_name = "llvm.riscv.sha512sig1"] - fn _sha512sig1(rs1: i64) -> i64; + fn _sha512sig1(rs1: u64) -> u64; #[link_name = "llvm.riscv.sha512sum0"] - fn _sha512sum0(rs1: i64) -> i64; + fn _sha512sum0(rs1: u64) -> u64; #[link_name = "llvm.riscv.sha512sum1"] - fn _sha512sum1(rs1: i64) -> i64; + fn _sha512sum1(rs1: u64) -> u64; } /// AES final round encryption instruction for RV64. @@ -49,7 +49,7 @@ unsafe extern "llvm-intrinsic" { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64es(rs1: u64, rs2: u64) -> u64 { - unsafe { _aes64es(rs1 as i64, rs2 as i64) as u64 } + unsafe { _aes64es(rs1, rs2) } } /// AES middle round encryption instruction for RV64. @@ -69,7 +69,7 @@ pub fn aes64es(rs1: u64, rs2: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64esm(rs1: u64, rs2: u64) -> u64 { - unsafe { _aes64esm(rs1 as i64, rs2 as i64) as u64 } + unsafe { _aes64esm(rs1, rs2) } } /// AES final round decryption instruction for RV64. @@ -89,7 +89,7 @@ pub fn aes64esm(rs1: u64, rs2: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64ds(rs1: u64, rs2: u64) -> u64 { - unsafe { _aes64ds(rs1 as i64, rs2 as i64) as u64 } + unsafe { _aes64ds(rs1, rs2) } } /// AES middle round decryption instruction for RV64. @@ -109,7 +109,7 @@ pub fn aes64ds(rs1: u64, rs2: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64dsm(rs1: u64, rs2: u64) -> u64 { - unsafe { _aes64dsm(rs1 as i64, rs2 as i64) as u64 } + unsafe { _aes64dsm(rs1, rs2) } } /// This instruction implements part of the KeySchedule operation for the AES Block cipher @@ -130,7 +130,6 @@ pub fn aes64dsm(rs1: u64, rs2: u64) -> u64 { /// /// The `RNUM` parameter is expected to be a constant value inside the range of `0..=10`. #[target_feature(enable = "zkne_or_zknd")] -#[rustc_legacy_const_generics(1)] #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64ks1i(rs1: u64) -> u64 { @@ -200,7 +199,7 @@ pub fn aes64ks2(rs1: u64, rs2: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn aes64im(rs1: u64) -> u64 { - unsafe { _aes64im(rs1 as i64) as u64 } + unsafe { _aes64im(rs1) } } /// Implements the Sigma0 transformation function as used in the SHA2-512 hash function \[49\] @@ -220,7 +219,7 @@ pub fn aes64im(rs1: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig0(rs1: u64) -> u64 { - unsafe { _sha512sig0(rs1 as i64) as u64 } + unsafe { _sha512sig0(rs1) } } /// Implements the Sigma1 transformation function as used in the SHA2-512 hash function \[49\] @@ -240,7 +239,7 @@ pub fn sha512sig0(rs1: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sig1(rs1: u64) -> u64 { - unsafe { _sha512sig1(rs1 as i64) as u64 } + unsafe { _sha512sig1(rs1) } } /// Implements the Sum0 transformation function as used in the SHA2-512 hash function \[49\] @@ -260,7 +259,7 @@ pub fn sha512sig1(rs1: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sum0(rs1: u64) -> u64 { - unsafe { _sha512sum0(rs1 as i64) as u64 } + unsafe { _sha512sum0(rs1) } } /// Implements the Sum1 transformation function as used in the SHA2-512 hash function \[49\] @@ -280,5 +279,5 @@ pub fn sha512sum0(rs1: u64) -> u64 { #[inline] #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] pub fn sha512sum1(rs1: u64) -> u64 { - unsafe { _sha512sum1(rs1 as i64) as u64 } + unsafe { _sha512sum1(rs1) } } diff --git a/library/stdarch/crates/core_arch/src/riscv_shared/zb.rs b/library/stdarch/crates/core_arch/src/riscv_shared/zb.rs index 79ffe2af337b2..04a42f02357d1 100644 --- a/library/stdarch/crates/core_arch/src/riscv_shared/zb.rs +++ b/library/stdarch/crates/core_arch/src/riscv_shared/zb.rs @@ -1,34 +1,12 @@ #[cfg(test)] use stdarch_test::assert_instr; -#[cfg(target_arch = "riscv32")] unsafe extern "llvm-intrinsic" { #[link_name = "llvm.riscv.orc.b.i32"] - fn _orc_b_32(rs: i32) -> i32; + fn _orc_b_32(rs: u32) -> u32; #[link_name = "llvm.riscv.clmul.i32"] - fn _clmul_32(rs1: i32, rs2: i32) -> i32; - - #[link_name = "llvm.riscv.clmulh.i32"] - fn _clmulh_32(rs1: i32, rs2: i32) -> i32; - - #[link_name = "llvm.riscv.clmulr.i32"] - fn _clmulr_32(rs1: i32, rs2: i32) -> i32; -} - -#[cfg(target_arch = "riscv64")] -unsafe extern "llvm-intrinsic" { - #[link_name = "llvm.riscv.orc.b.i64"] - fn _orc_b_64(rs1: i64) -> i64; - - #[link_name = "llvm.riscv.clmul.i64"] - fn _clmul_64(rs1: i64, rs2: i64) -> i64; - - #[link_name = "llvm.riscv.clmulh.i64"] - fn _clmulh_64(rs1: i64, rs2: i64) -> i64; - - #[link_name = "llvm.riscv.clmulr.i64"] - fn _clmulr_64(rs1: i64, rs2: i64) -> i64; + fn _clmul_32(rs1: u32, rs2: u32) -> u32; } /// Bitwise OR-Combine, byte granule @@ -46,21 +24,13 @@ unsafe extern "llvm-intrinsic" { #[target_feature(enable = "zbb")] #[cfg_attr(test, assert_instr(orc.b))] #[inline] -pub fn orc_b(rs: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _orc_b_32(rs as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _orc_b_64(rs as i64) as usize - } +pub fn orc_b_32(rs: u32) -> u32 { + unsafe { _orc_b_32(rs) } } /// Carry-less multiply (low-part) /// -/// clmul produces the lower half of the 2·XLEN carry-less product. +/// clmul produces the lower half of the 32-bit carry-less product. /// /// Source: RISC-V Bit-Manipulation ISA-extensions /// @@ -71,64 +41,6 @@ pub fn orc_b(rs: usize) -> usize { #[target_feature(enable = "zbkc")] #[cfg_attr(test, assert_instr(clmul))] #[inline] -pub fn clmul(rs1: usize, rs2: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _clmul_32(rs1 as i32, rs2 as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _clmul_64(rs1 as i64, rs2 as i64) as usize - } -} - -/// Carry-less multiply (high-part) -/// -/// clmulh produces the upper half of the 2·XLEN carry-less product. -/// -/// Source: RISC-V Bit-Manipulation ISA-extensions -/// -/// Version: v1.0.0 -/// -/// Section: 2.12 -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -#[target_feature(enable = "zbkc")] -#[cfg_attr(test, assert_instr(clmulh))] -#[inline] -pub fn clmulh(rs1: usize, rs2: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _clmulh_32(rs1 as i32, rs2 as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _clmulh_64(rs1 as i64, rs2 as i64) as usize - } -} - -/// Carry-less multiply (reversed) -/// -/// clmulr produces bits 2·XLEN−2:XLEN-1 of the 2·XLEN carry-less product. -/// -/// Source: RISC-V Bit-Manipulation ISA-extensions -/// -/// Version: v1.0.0 -/// -/// Section: 2.13 -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -#[target_feature(enable = "zbc")] -#[cfg_attr(test, assert_instr(clmulr))] -#[inline] -pub fn clmulr(rs1: usize, rs2: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _clmulr_32(rs1 as i32, rs2 as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _clmulr_64(rs1 as i64, rs2 as i64) as usize - } +pub fn clmul_32(rs1: u32, rs2: u32) -> u32 { + unsafe { _clmul_32(rs1, rs2) } } diff --git a/library/stdarch/crates/core_arch/src/riscv_shared/zk.rs b/library/stdarch/crates/core_arch/src/riscv_shared/zk.rs index 589ea9779866d..9902dbabf59ae 100644 --- a/library/stdarch/crates/core_arch/src/riscv_shared/zk.rs +++ b/library/stdarch/crates/core_arch/src/riscv_shared/zk.rs @@ -3,102 +3,28 @@ use stdarch_test::assert_instr; unsafe extern "llvm-intrinsic" { #[link_name = "llvm.riscv.sm4ed"] - fn _sm4ed(rs1: i32, rs2: i32, bs: i32) -> i32; + fn _sm4ed(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.sm4ks"] - fn _sm4ks(rs1: i32, rs2: i32, bs: i32) -> i32; + fn _sm4ks(rs1: u32, rs2: u32, bs: u32) -> u32; #[link_name = "llvm.riscv.sm3p0"] - fn _sm3p0(rs1: i32) -> i32; + fn _sm3p0(rs1: u32) -> u32; #[link_name = "llvm.riscv.sm3p1"] - fn _sm3p1(rs1: i32) -> i32; + fn _sm3p1(rs1: u32) -> u32; #[link_name = "llvm.riscv.sha256sig0"] - fn _sha256sig0(rs1: i32) -> i32; + fn _sha256sig0(rs1: u32) -> u32; #[link_name = "llvm.riscv.sha256sig1"] - fn _sha256sig1(rs1: i32) -> i32; + fn _sha256sig1(rs1: u32) -> u32; #[link_name = "llvm.riscv.sha256sum0"] - fn _sha256sum0(rs1: i32) -> i32; + fn _sha256sum0(rs1: u32) -> u32; #[link_name = "llvm.riscv.sha256sum1"] - fn _sha256sum1(rs1: i32) -> i32; -} - -#[cfg(target_arch = "riscv32")] -unsafe extern "llvm-intrinsic" { - #[link_name = "llvm.riscv.xperm8.i32"] - fn _xperm8_32(rs1: i32, rs2: i32) -> i32; - - #[link_name = "llvm.riscv.xperm4.i32"] - fn _xperm4_32(rs1: i32, rs2: i32) -> i32; -} - -#[cfg(target_arch = "riscv64")] -unsafe extern "llvm-intrinsic" { - #[link_name = "llvm.riscv.xperm8.i64"] - fn _xperm8_64(rs1: i64, rs2: i64) -> i64; - - #[link_name = "llvm.riscv.xperm4.i64"] - fn _xperm4_64(rs1: i64, rs2: i64) -> i64; -} - -/// Byte-wise lookup of indicies into a vector in registers. -/// -/// The xperm8 instruction operates on bytes. The rs1 register contains a vector of XLEN/8 -/// 8-bit elements. The rs2 register contains a vector of XLEN/8 8-bit indexes. The result is -/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 -/// is out of bounds. -/// -/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions -/// -/// Version: v1.0.1 -/// -/// Section: 3.47 -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -#[target_feature(enable = "zbkx")] -#[cfg_attr(test, assert_instr(xperm8))] -#[inline] -pub fn xperm8(rs1: usize, rs2: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _xperm8_32(rs1 as i32, rs2 as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _xperm8_64(rs1 as i64, rs2 as i64) as usize - } -} - -/// Nibble-wise lookup of indicies into a vector. -/// -/// The xperm4 instruction operates on nibbles. The rs1 register contains a vector of XLEN/4 -/// 4-bit elements. The rs2 register contains a vector of XLEN/4 4-bit indexes. The result is -/// each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 -/// is out of bounds. -/// -/// Source: RISC-V Cryptography Extensions Volume I: Scalar & Entropy Source Instructions -/// -/// Version: v1.0.1 -/// -/// Section: 3.48 -#[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] -#[target_feature(enable = "zbkx")] -#[cfg_attr(test, assert_instr(xperm4))] -#[inline] -pub fn xperm4(rs1: usize, rs2: usize) -> usize { - #[cfg(target_arch = "riscv32")] - unsafe { - _xperm4_32(rs1 as i32, rs2 as i32) as usize - } - - #[cfg(target_arch = "riscv64")] - unsafe { - _xperm4_64(rs1 as i64, rs2 as i64) as usize - } + fn _sha256sum1(rs1: u32) -> u32; } /// Implements the Sigma0 transformation function as used in the SHA2-256 hash function \[49\] @@ -121,7 +47,7 @@ pub fn xperm4(rs1: usize, rs2: usize) -> usize { #[cfg_attr(test, assert_instr(sha256sig0))] #[inline] pub fn sha256sig0(rs1: u32) -> u32 { - unsafe { _sha256sig0(rs1 as i32) as u32 } + unsafe { _sha256sig0(rs1) } } /// Implements the Sigma1 transformation function as used in the SHA2-256 hash function \[49\] @@ -144,7 +70,7 @@ pub fn sha256sig0(rs1: u32) -> u32 { #[cfg_attr(test, assert_instr(sha256sig1))] #[inline] pub fn sha256sig1(rs1: u32) -> u32 { - unsafe { _sha256sig1(rs1 as i32) as u32 } + unsafe { _sha256sig1(rs1) } } /// Implements the Sum0 transformation function as used in the SHA2-256 hash function \[49\] @@ -167,7 +93,7 @@ pub fn sha256sig1(rs1: u32) -> u32 { #[cfg_attr(test, assert_instr(sha256sum0))] #[inline] pub fn sha256sum0(rs1: u32) -> u32 { - unsafe { _sha256sum0(rs1 as i32) as u32 } + unsafe { _sha256sum0(rs1) } } /// Implements the Sum1 transformation function as used in the SHA2-256 hash function \[49\] @@ -190,7 +116,7 @@ pub fn sha256sum0(rs1: u32) -> u32 { #[cfg_attr(test, assert_instr(sha256sum1))] #[inline] pub fn sha256sum1(rs1: u32) -> u32 { - unsafe { _sha256sum1(rs1 as i32) as u32 } + unsafe { _sha256sum1(rs1) } } /// Accelerates the block encrypt/decrypt operation of the SM4 block cipher \[5, 31\]. @@ -243,7 +169,7 @@ pub fn sha256sum1(rs1: u32) -> u32 { /// C = L(B) = B ⊕ (B ≪ 2) ⊕ (B ≪ 10) ⊕ (B ≪ 18) ⊕ (B ≪ 24) /// ``` /// -/// It can be implemented by `sm4ed` instruction like: +/// It can be implemented by the `sm4ed` instruction like this: /// /// ```no_run /// # #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] @@ -251,22 +177,21 @@ pub fn sha256sum1(rs1: u32) -> u32 { /// # #[cfg(target_arch = "riscv32")] use core::arch::riscv32::sm4ed; /// # #[cfg(target_arch = "riscv64")] use core::arch::riscv64::sm4ed; /// let a = x1 ^ x2 ^ x3 ^ rk; -/// let c0 = sm4ed(x0, a, 0); -/// let c1 = sm4ed(c0, a, 1); // c1 represents c[0..=1], etc. -/// let c2 = sm4ed(c1, a, 2); -/// let c3 = sm4ed(c2, a, 3); +/// let c0 = sm4ed::<0>(x0, a); +/// let c1 = sm4ed::<1>(c0, a); // c1 represents c[0..=1], etc. +/// let c2 = sm4ed::<2>(c1, a); +/// let c3 = sm4ed::<3>(c2, a); /// return c3; // c3 represents c[0..=3] /// # } /// ``` #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] #[target_feature(enable = "zksed")] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(sm4ed, BS = 0))] #[inline] pub fn sm4ed(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _sm4ed(rs1 as i32, rs2 as i32, BS as i32) as u32 } + unsafe { _sm4ed(rs1, rs2, BS as u32) } } /// Accelerates the Key Schedule operation of the SM4 block cipher \[5, 31\] with `bs=0`. @@ -327,22 +252,21 @@ pub fn sm4ed(rs1: u32, rs2: u32) -> u32 { /// # #[cfg(target_arch = "riscv32")] use core::arch::riscv32::sm4ed; /// # #[cfg(target_arch = "riscv64")] use core::arch::riscv64::sm4ed; /// let a = x1 ^ x2 ^ x3 ^ rk; -/// let c0 = sm4ed(x0, a, 0); -/// let c1 = sm4ed(c0, a, 1); // c1 represents c[0..=1], etc. -/// let c2 = sm4ed(c1, a, 2); -/// let c3 = sm4ed(c2, a, 3); +/// let c0 = sm4ed::<0>(x0, a); +/// let c1 = sm4ed::<1>(c0, a); // c1 represents c[0..=1], etc. +/// let c2 = sm4ed::<2>(c1, a); +/// let c3 = sm4ed::<3>(c2, a); /// return c3; // c3 represents c[0..=3] /// # } /// ``` #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] #[target_feature(enable = "zksed")] -#[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(sm4ks, BS = 0))] #[inline] pub fn sm4ks(rs1: u32, rs2: u32) -> u32 { static_assert!(BS < 4); - unsafe { _sm4ks(rs1 as i32, rs2 as i32, BS as i32) as u32 } + unsafe { _sm4ks(rs1, rs2, BS as u32) } } /// Implements the P0 transformation function as used in the SM3 hash function [4, 30]. @@ -377,7 +301,7 @@ pub fn sm4ks(rs1: u32, rs2: u32) -> u32 { #[cfg_attr(test, assert_instr(sm3p0))] #[inline] pub fn sm3p0(rs1: u32) -> u32 { - unsafe { _sm3p0(rs1 as i32) as u32 } + unsafe { _sm3p0(rs1) } } /// Implements the P1 transformation function as used in the SM3 hash function [4, 30]. @@ -418,5 +342,5 @@ pub fn sm3p0(rs1: u32) -> u32 { #[cfg_attr(test, assert_instr(sm3p1))] #[inline] pub fn sm3p1(rs1: u32) -> u32 { - unsafe { _sm3p1(rs1 as i32) as u32 } + unsafe { _sm3p1(rs1) } } diff --git a/library/stdarch/crates/core_arch/src/simd.rs b/library/stdarch/crates/core_arch/src/simd.rs index 8a8756a571cd6..69f5eda9993da 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs @@ -37,6 +37,8 @@ unsafe impl SimdElement for i64 {} unsafe impl SimdElement for i128 {} unsafe impl SimdElement for f16 {} +#[cfg(any(target_has_reliable_f16b, doc))] +unsafe impl SimdElement for core::num::f16b {} unsafe impl SimdElement for f32 {} unsafe impl SimdElement for f64 {} @@ -342,6 +344,8 @@ pub(crate) type i16x4 = Simd; pub(crate) type i32x2 = Simd; pub(crate) type i64x1 = Simd; +#[cfg(any(target_has_reliable_f16b, doc))] +pub(crate) type f16bx4 = Simd; pub(crate) type f16x4 = Simd; pub(crate) type f32x2 = Simd; pub(crate) type f64x1 = Simd; @@ -358,6 +362,8 @@ pub(crate) type i16x8 = Simd; pub(crate) type i32x4 = Simd; pub(crate) type i64x2 = Simd; +#[cfg(any(target_has_reliable_f16b, doc))] +pub(crate) type f16bx8 = Simd; pub(crate) type f16x8 = Simd; pub(crate) type f32x4 = Simd; pub(crate) type f64x2 = Simd; diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 168871188868b..2a94cef521f3f 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -2297,7 +2297,7 @@ pub const fn _mm256_or_si256(a: __m256i, b: __m256i) -> __m256i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_packs_epi16) #[inline] #[target_feature(enable = "avx2")] -#[cfg_attr(test, assert_instr(vpacksswb))] +#[cfg_attr(test, assert_instr(vpacksswb, limit(5), not(vpmin), not(vpmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_packs_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(packsswb(a.as_i16x16(), b.as_i16x16())) } @@ -2309,7 +2309,7 @@ pub fn _mm256_packs_epi16(a: __m256i, b: __m256i) -> __m256i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_packs_epi32) #[inline] #[target_feature(enable = "avx2")] -#[cfg_attr(test, assert_instr(vpackssdw))] +#[cfg_attr(test, assert_instr(vpackssdw, limit(5), not(vpmin), not(vpmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_packs_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(packssdw(a.as_i32x8(), b.as_i32x8())) } @@ -2321,7 +2321,7 @@ pub fn _mm256_packs_epi32(a: __m256i, b: __m256i) -> __m256i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_packus_epi16) #[inline] #[target_feature(enable = "avx2")] -#[cfg_attr(test, assert_instr(vpackuswb))] +#[cfg_attr(test, assert_instr(vpackuswb, limit(5), not(vpmin), not(vpmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_packus_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(packuswb(a.as_i16x16(), b.as_i16x16())) } @@ -2333,7 +2333,7 @@ pub fn _mm256_packus_epi16(a: __m256i, b: __m256i) -> __m256i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_packus_epi32) #[inline] #[target_feature(enable = "avx2")] -#[cfg_attr(test, assert_instr(vpackusdw))] +#[cfg_attr(test, assert_instr(vpackusdw, limit(5), not(vpmin), not(vpmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_packus_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(packusdw(a.as_i32x8(), b.as_i32x8())) } diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index bc119870fa99a..e2d1be4bc76ec 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -6478,7 +6478,7 @@ pub fn _mm_maskz_maddubs_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpackssdw))] +#[cfg_attr(test, assert_instr(vpackssdw, limit(5), not(vpmin), not(vpmax)))] pub fn _mm512_packs_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(vpackssdw(a.as_i32x16(), b.as_i32x16())) } } @@ -6573,7 +6573,7 @@ pub fn _mm_maskz_packs_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpacksswb))] +#[cfg_attr(test, assert_instr(vpacksswb, limit(5), not(vpmin), not(vpmax)))] pub fn _mm512_packs_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(vpacksswb(a.as_i16x32(), b.as_i16x32())) } } @@ -6668,7 +6668,7 @@ pub fn _mm_maskz_packs_epi16(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpackusdw))] +#[cfg_attr(test, assert_instr(vpackusdw, limit(5), not(vpmin), not(vpmax)))] pub fn _mm512_packus_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(vpackusdw(a.as_i32x16(), b.as_i32x16())) } } @@ -6763,7 +6763,7 @@ pub fn _mm_maskz_packus_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpackuswb))] +#[cfg_attr(test, assert_instr(vpackuswb, limit(5), not(vpmin), not(vpmax)))] pub fn _mm512_packus_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(vpackuswb(a.as_i16x32(), b.as_i16x32())) } } diff --git a/library/stdarch/crates/core_arch/src/x86/avx512ifma.rs b/library/stdarch/crates/core_arch/src/x86/avx512ifma.rs index 035b6a7e7e9ce..41505f7587ea1 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512ifma.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512ifma.rs @@ -24,7 +24,7 @@ pub fn _mm512_madd52hi_epu64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm512_mask_madd52hi_epu64) #[inline] @@ -71,7 +71,7 @@ pub fn _mm512_madd52lo_epu64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm512_mask_madd52lo_epu64) #[inline] @@ -133,7 +133,7 @@ pub fn _mm256_madd52hi_epu64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm256_mask_madd52hi_epu64) #[inline] @@ -195,7 +195,7 @@ pub fn _mm256_madd52lo_epu64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm256_mask_madd52lo_epu64) #[inline] @@ -257,7 +257,7 @@ pub fn _mm_madd52hi_epu64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm_mask_madd52hi_epu64) #[inline] @@ -319,7 +319,7 @@ pub fn _mm_madd52lo_epu64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { /// unsigned integer from the intermediate result with the /// corresponding unsigned 64-bit integer in `a`, and store the /// results in `dst` using writemask `k` (elements are copied -/// from `k` when the corresponding mask bit is not set). +/// from `a` when the corresponding mask bit is not set). /// /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avx512techs=AVX512IFMA52&text=_mm_mask_madd52lo_epu64) #[inline] diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs index 3f13ea8369bb8..f74574fb53dec 100644 --- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs +++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs @@ -111,7 +111,7 @@ pub fn __cpuid(leaf: u32) -> CpuidResult { /// Returns the EAX and EBX register after calling CPUID with the provided `leaf`, /// with `sub_leaf` set to 0. /// -/// If `leaf` if 0 or `0x80000000`, the first tuple argument contains the maximum +/// If `leaf` is 0 or `0x80000000`, the first tuple argument contains the maximum /// supported basic or extended leaf, respectively. /// /// See also [`__cpuid`](fn.__cpuid.html) and diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 32817290d2c20..6b94229c57fb5 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -1473,7 +1473,7 @@ pub const fn _mm_move_epi64(a: __m128i) -> __m128i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_packs_epi16) #[inline] #[target_feature(enable = "sse2")] -#[cfg_attr(test, assert_instr(packsswb))] +#[cfg_attr(test, assert_instr(packsswb, limit(5), not(pmin), not(pmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_packs_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(packsswb(a.as_i16x8(), b.as_i16x8())) } @@ -1485,7 +1485,7 @@ pub fn _mm_packs_epi16(a: __m128i, b: __m128i) -> __m128i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_packs_epi32) #[inline] #[target_feature(enable = "sse2")] -#[cfg_attr(test, assert_instr(packssdw))] +#[cfg_attr(test, assert_instr(packssdw, limit(5), not(pmin), not(pmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_packs_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(packssdw(a.as_i32x4(), b.as_i32x4())) } @@ -1497,7 +1497,7 @@ pub fn _mm_packs_epi32(a: __m128i, b: __m128i) -> __m128i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_packus_epi16) #[inline] #[target_feature(enable = "sse2")] -#[cfg_attr(test, assert_instr(packuswb))] +#[cfg_attr(test, assert_instr(packuswb, limit(5), not(pmin), not(pmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_packus_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(packuswb(a.as_i16x8(), b.as_i16x8())) } diff --git a/library/stdarch/crates/core_arch/src/x86/sse41.rs b/library/stdarch/crates/core_arch/src/x86/sse41.rs index b9f60cb8b8416..0c4c18916502e 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse41.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse41.rs @@ -424,7 +424,7 @@ pub const fn _mm_min_epu32(a: __m128i, b: __m128i) -> __m128i { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_packus_epi32) #[inline] #[target_feature(enable = "sse4.1")] -#[cfg_attr(test, assert_instr(packusdw))] +#[cfg_attr(test, assert_instr(packusdw, limit(5), not(pmin), not(pmax)))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_packus_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(packusdw(a.as_i32x4(), b.as_i32x4())) } diff --git a/library/stdarch/crates/core_arch/src/x86_64/amx.rs b/library/stdarch/crates/core_arch/src/x86_64/amx.rs index 3f98df5b77376..22b9598d5aa0b 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/amx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/amx.rs @@ -106,7 +106,8 @@ pub unsafe fn _tile_stored(base: *mut u8, stride: usize) { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_stored&ig_expand=6881) #[inline] #[target_feature(enable = "amx-tile")] -#[cfg_attr(test, assert_instr(tilestored))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tilestored))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_stored(base: *mut u8, stride: usize, src: __tile1024i) { tilestored64_internal(src.rows, src.colsb, base, stride as u64, src.tile); @@ -191,7 +192,8 @@ pub unsafe fn _tile_dpbf16ps() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpbf16ps&ig_expand=6864) #[inline] #[target_feature(enable = "amx-bf16")] -#[cfg_attr(test, assert_instr(tdpbf16ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpbf16ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbf16ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbf16ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -224,7 +226,8 @@ pub unsafe fn _tile_dpbssd() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpbssd&ig_expand=6866) #[inline] #[target_feature(enable = "amx-int8")] -#[cfg_attr(test, assert_instr(tdpbssd))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpbssd))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbssd(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbssd_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -257,7 +260,8 @@ pub unsafe fn _tile_dpbsud() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpbsud&ig_expand=6868) #[inline] #[target_feature(enable = "amx-int8")] -#[cfg_attr(test, assert_instr(tdpbsud))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpbsud))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbsud(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbsud_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -290,7 +294,8 @@ pub unsafe fn _tile_dpbusd() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpbusd&ig_expand=6870) #[inline] #[target_feature(enable = "amx-int8")] -#[cfg_attr(test, assert_instr(tdpbusd))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpbusd))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbusd(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbusd_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -323,7 +328,8 @@ pub unsafe fn _tile_dpbuud() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpbuud&ig_expand=6872) #[inline] #[target_feature(enable = "amx-int8")] -#[cfg_attr(test, assert_instr(tdpbuud))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpbuud))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbuud(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbuud_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -354,7 +360,8 @@ pub unsafe fn _tile_dpfp16ps() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_dpfp16ps&ig_expand=6874) #[inline] #[target_feature(enable = "amx-fp16")] -#[cfg_attr(test, assert_instr(tdpfp16ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tdpfp16ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpfp16ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpfp16ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -393,7 +400,8 @@ pub unsafe fn _tile_cmmimfp16ps() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_cmmimfp16ps&ig_expand=6860) #[inline] #[target_feature(enable = "amx-complex")] -#[cfg_attr(test, assert_instr(tcmmimfp16ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tcmmimfp16ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cmmimfp16ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tcmmimfp16ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -432,7 +440,8 @@ pub unsafe fn _tile_cmmrlfp16ps() { /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=__tile_cmmrlfp16ps&ig_expand=6862) #[inline] #[target_feature(enable = "amx-complex")] -#[cfg_attr(test, assert_instr(tcmmrlfp16ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(test, assert_instr(tcmmrlfp16ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cmmrlfp16ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tcmmrlfp16ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -464,7 +473,8 @@ pub unsafe fn _tile_dpbf8ps() { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-fp8")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdpbf8ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdpbf8ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbf8ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbf8ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -496,7 +506,8 @@ pub unsafe fn _tile_dpbhf8ps() { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-fp8")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdpbhf8ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdpbhf8ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dpbhf8ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdpbhf8ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -528,7 +539,8 @@ pub unsafe fn _tile_dphbf8ps() { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-fp8")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdphbf8ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdphbf8ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dphbf8ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdphbf8ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -560,7 +572,8 @@ pub unsafe fn _tile_dphf8ps() { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-fp8")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdphf8ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tdphf8ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_dphf8ps(dst: *mut __tile1024i, a: __tile1024i, b: __tile1024i) { (*dst).tile = tdphf8ps_internal(a.rows, b.colsb, a.colsb, (*dst).tile, a.tile, b.tile); @@ -668,7 +681,8 @@ pub unsafe fn _tile_cvtrowd2psi() -> __m512 { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowd2ps))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowd2ps))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cvtrowd2ps(src: __tile1024i, row: u32) -> __m512 { tcvtrowd2ps_internal(src.rows, src.colsb, src.tile, row).as_m512() @@ -713,7 +727,8 @@ pub unsafe fn _tile_cvtrowps2phhi() -> __m512h /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2phh))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2phh))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cvtrowps2phh(src: __tile1024i, row: u32) -> __m512h { tcvtrowps2phh_internal(src.rows, src.colsb, src.tile, row).as_m512h() @@ -758,7 +773,8 @@ pub unsafe fn _tile_cvtrowps2phli() -> __m512h /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2phl))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2phl))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cvtrowps2phl(src: __tile1024i, row: u32) -> __m512h { tcvtrowps2phl_internal(src.rows, src.colsb, src.tile, row).as_m512h() @@ -803,7 +819,8 @@ pub unsafe fn _tile_cvtrowps2bf16hi() -> __m512 /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2bf16h))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2bf16h))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cvtrowps2bf16h(src: __tile1024i, row: u32) -> __m512bh { tcvtrowps2bf16h_internal(src.rows, src.colsb, src.tile, row).as_m512bh() @@ -848,7 +865,8 @@ pub unsafe fn _tile_cvtrowps2bf16li() -> __m512 /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2bf16l))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tcvtrowps2bf16l))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_cvtrowps2bf16l(src: __tile1024i, row: u32) -> __m512bh { tcvtrowps2bf16l_internal(src.rows, src.colsb, src.tile, row).as_m512bh() @@ -887,7 +905,8 @@ pub unsafe fn _tile_movrowi() -> __m512i { /// The shape of the tile is specified in the struct of [`__tile1024i`]. The register of the tile is allocated by the compiler. #[inline] #[target_feature(enable = "amx-avx512,avx10.2")] -#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tilemovrow))] +// FIXME(amx) see https://github.com/rust-lang/rust/issues/165931. +// #[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(tilemovrow))] #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] pub unsafe fn __tile_movrow(src: __tile1024i, row: u32) -> __m512i { tilemovrow_internal(src.rows, src.colsb, src.tile, row).as_m512i() diff --git a/library/stdarch/crates/intrinsic-test/missing_aarch64_be_common.txt b/library/stdarch/crates/intrinsic-test/missing_aarch64_be_common.txt index 327c8207a0ff5..9f22e528ba0fb 100644 --- a/library/stdarch/crates/intrinsic-test/missing_aarch64_be_common.txt +++ b/library/stdarch/crates/intrinsic-test/missing_aarch64_be_common.txt @@ -14,12 +14,14 @@ vscale_f32 vscaleq_f16 vscaleq_f32 vscaleq_f64 +vluti2_lane_bf16 vluti2_lane_p16 vluti2_lane_p8 vluti2_lane_s16 vluti2_lane_s8 vluti2_lane_u16 vluti2_lane_u8 +vluti2q_lane_bf16 vluti2q_lane_p16 vluti2q_lane_p8 vluti2q_lane_s16 @@ -28,6 +30,7 @@ vluti2q_lane_u16 vluti2_laneq_f16 vluti2_lane_f16 vluti2_laneq_f16 +vluti2_laneq_bf16 vluti2_laneq_p16 vluti2_laneq_p8 vluti2_laneq_s16 @@ -36,6 +39,7 @@ vluti2_laneq_u16 vluti2_laneq_u8 vluti2q_lane_f16 vluti2q_laneq_f16 +vluti2q_laneq_bf16 vluti2q_laneq_p16 vluti2q_laneq_p8 vluti2q_laneq_s16 @@ -44,6 +48,7 @@ vluti2q_laneq_u16 vluti2q_laneq_u8 vluti2q_lane_u8 vluti4q_lane_f16_x2 +vluti4q_lane_bf16_x2 vluti4q_lane_p16_x2 vluti4q_lane_p8 vluti4q_lane_s16_x2 @@ -51,6 +56,7 @@ vluti4q_lane_s8 vluti4q_lane_u16_x2 vluti4q_lane_u8 vluti4q_laneq_f16_x2 +vluti4q_laneq_bf16_x2 vluti4q_laneq_p16_x2 vluti4q_laneq_p8 vluti4q_laneq_s16_x2 diff --git a/library/stdarch/crates/intrinsic-test/missing_aarch64_common.txt b/library/stdarch/crates/intrinsic-test/missing_aarch64_common.txt index 327c8207a0ff5..f154f90442efe 100644 --- a/library/stdarch/crates/intrinsic-test/missing_aarch64_common.txt +++ b/library/stdarch/crates/intrinsic-test/missing_aarch64_common.txt @@ -14,17 +14,20 @@ vscale_f32 vscaleq_f16 vscaleq_f32 vscaleq_f64 +vluti2_lane_bf16 vluti2_lane_p16 vluti2_lane_p8 vluti2_lane_s16 vluti2_lane_s8 vluti2_lane_u16 vluti2_lane_u8 +vluti2q_lane_bf16 vluti2q_lane_p16 vluti2q_lane_p8 vluti2q_lane_s16 vluti2q_lane_s8 vluti2q_lane_u16 +vluti2_laneq_bf16 vluti2_laneq_f16 vluti2_lane_f16 vluti2_laneq_f16 @@ -35,6 +38,7 @@ vluti2_laneq_s8 vluti2_laneq_u16 vluti2_laneq_u8 vluti2q_lane_f16 +vluti2q_laneq_bf16 vluti2q_laneq_f16 vluti2q_laneq_p16 vluti2q_laneq_p8 @@ -43,6 +47,7 @@ vluti2q_laneq_s8 vluti2q_laneq_u16 vluti2q_laneq_u8 vluti2q_lane_u8 +vluti4q_lane_bf16_x2 vluti4q_lane_f16_x2 vluti4q_lane_p16_x2 vluti4q_lane_p8 @@ -50,6 +55,7 @@ vluti4q_lane_s16_x2 vluti4q_lane_s8 vluti4q_lane_u16_x2 vluti4q_lane_u8 +vluti4q_laneq_bf16_x2 vluti4q_laneq_f16_x2 vluti4q_laneq_p16_x2 vluti4q_laneq_p8 diff --git a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs index 5e892c613464a..38f57310a3745 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs @@ -45,8 +45,8 @@ impl SupportedArchitecture for Arm { let a32 = cli_options.target.starts_with("armv7"); match cli_options.cc_arg_style { CcArgStyle::Clang if !a32 && !big_endian => vec![ - "-march=armv8.6a+crypto+crc+dotprod+fp16+sve2-aes+sve2-sm4+sve2-sha3+sve2-bitperm+\ - f32mm+f64mm+sve2p1", + "-march=armv8.6a+crypto+crc+dotprod+fp16+bf16+sve2-aes+sve2-sm4+sve2-sha3+\ + sve2-bitperm+f32mm+f64mm+sve2p1", ], CcArgStyle::Clang => vec!["-march=armv8.6a+crypto+crc+dotprod+fp16"], // SVE tests aren't run under GCC so there are no target features added for SVE @@ -70,9 +70,6 @@ impl SupportedArchitecture for Arm { .into_iter() // Skip intrinsics that don't return a value. .filter(|i| i.results.kind() != TypeKind::Void) - // Skip bfloat intrinsics - not currently supported - .filter(|i| i.results.kind() != TypeKind::BFloat) - .filter(|i| !i.arguments.iter().any(|a| a.ty.kind() == TypeKind::BFloat)) // Skip SVE intrinsics that have `f16` - not yet implemented! .filter(|i| { let has_f16_arg = i @@ -121,6 +118,8 @@ impl SupportedArchitecture for Arm { .filter(|i| !i.arguments.iter().any(|a| a.is_ptr())) // Skip intrinsics with 128-bit elements (e.g. `p128`) .filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128)) + // A32 does not provide polynomial 128-bit return types either. + .filter(|i| !(a32 && i.results.inner_size() == 128)) // Skip intrinsics from `--skip` .filter(|i| !cli_options.skip.contains(&i.name)) // Skip A64-specific intrinsics on A32 @@ -178,9 +177,13 @@ const RUST_PRELUDE: &str = r#" #![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_ftts))] #![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_feat_lut))] #![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_fp8))] +#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_bf16))] #![cfg_attr(all(any(target_arch = "aarch64", target_arch = "arm64ec"), target_endian = "little"), feature(stdarch_aarch64_sve))] #![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(faminmax))] #![feature(stdarch_neon_f16)] +#![feature(f16b)] + +use core::num::f16b; #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] use core_arch::arch::aarch64::*; diff --git a/library/stdarch/crates/intrinsic-test/src/arm/types.rs b/library/stdarch/crates/intrinsic-test/src/arm/types.rs index cced3bc40c0e1..b14a6b7d83b44 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/types.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/types.rs @@ -39,6 +39,12 @@ impl TypeDefinition for ArmType { } fn rust_type(&self) -> String { + // Scalar BF16 uses Rust's `f16b` spelling rather than `bf16`. This also + // gives the comparison wrapper its expected `NanEqF16b` name. + if self.kind() == TypeKind::BFloat && self.simd_len.is_none() && self.vec_len.is_none() { + return "f16b".to_string(); + } + let rust_prefix = self.kind.rust_prefix(); let c_prefix = self.kind.c_prefix(); diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs index f319418b49c7f..350744e53fd0e 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs @@ -31,6 +31,23 @@ macro_rules! wrap_partialeq { } wrap_partialeq!(NanEqF16(f16), NanEqF32(f32), NanEqF64(f64)); + +#[cfg(target_has_reliable_f16b)] +#[derive(Debug, Copy, Clone)] +#[repr(transparent)] +pub struct NanEqF16b(f16b); + +#[cfg(target_has_reliable_f16b)] +impl PartialEq for NanEqF16b { + fn eq(&self, other: &Self) -> bool { + let a = f32::from(self.0); + let b = f32::from(other.0); + a == b || (a.is_nan() && b.is_nan()) + } +} + +#[cfg(target_has_reliable_f16b)] +impl Eq for NanEqF16b {} "#; /// Run rustfmt on the generated source code @@ -131,6 +148,9 @@ core_arch = {{ path = "../../crates/core_arch" }} [build-dependencies] cc = "1" + +[lints.rust] +unexpected_cfgs = {{ level = "warn", check-cfg = ['cfg(target_has_reliable_f16b)'] }} "#, authors = env!("CARGO_PKG_AUTHORS") .split(":") @@ -165,6 +185,8 @@ pub fn write_lib_rs( {notice} #![feature(simd_ffi)] #![feature(f16)] +#![feature(cfg_target_has_reliable_f16b)] +#![allow(internal_features)] #![allow(unused)] // Cargo will spam the logs if these warnings are not silenced. diff --git a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs index bc47a90d3fe16..76da7ca80b4b1 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs @@ -79,6 +79,7 @@ impl TypeKind { pub fn c_prefix(&self) -> &str { match self { Self::Bool => "bool", + Self::BFloat => "bfloat", Self::Float => "float", Self::Int(Sign::Signed) => "int", Self::Int(Sign::Unsigned) => "uint", @@ -253,6 +254,8 @@ pub(crate) fn default_fixed_vector_comparison( ), ")", ) + } else if ty.kind == TypeKind::BFloat { + ("NanEqF16b(".to_string(), ")") } else if ty.kind == TypeKind::Float { ( match ty.inner_size() { diff --git a/library/stdarch/crates/intrinsic-test/src/common/values.rs b/library/stdarch/crates/intrinsic-test/src/common/values.rs index d1f333fd19363..88d217b288e81 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/values.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/values.rs @@ -61,10 +61,10 @@ pub fn test_values_array(ty: &IntrinsicType) -> String { .. } => (1, TypeKind::Bool), IntrinsicType { - kind: TypeKind::Float, + kind: kind @ (TypeKind::Float | TypeKind::BFloat), bit_len: Some(bit_len), .. - } => (*bit_len, TypeKind::Float), + } => (*bit_len, *kind), IntrinsicType { kind: TypeKind::Vector, .. @@ -87,6 +87,7 @@ pub fn test_values_array(ty: &IntrinsicType) -> String { fmt(&format_args!("{}", if src == 1 { true } else { false })) } TypeKind::Float => fmt(&format_args!("f{bit_len}::from_bits({src:#x})")), + TypeKind::BFloat => fmt(&format_args!("f16b::from_bits({src:#x})")), TypeKind::Vector | TypeKind::Int(Sign::Signed) if (src >> (bit_len - 1)) != 0 => { // `src` is a two's complement representation of a negative value. let mask = !0u64 >> (64 - bit_len); diff --git a/library/stdarch/crates/simd-test-macro/Cargo.toml b/library/stdarch/crates/simd-test-macro/Cargo.toml index 8f9f9b13273cb..717acb03b2b54 100644 --- a/library/stdarch/crates/simd-test-macro/Cargo.toml +++ b/library/stdarch/crates/simd-test-macro/Cargo.toml @@ -11,4 +11,4 @@ test = false [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = { version = "2.0", features = ["full"] } +syn = { version = "3.0", features = ["full"] } diff --git a/library/stdarch/crates/simd-test-macro/src/lib.rs b/library/stdarch/crates/simd-test-macro/src/lib.rs index 51dd8aaf46fe7..286b36d3dd249 100644 --- a/library/stdarch/crates/simd-test-macro/src/lib.rs +++ b/library/stdarch/crates/simd-test-macro/src/lib.rs @@ -2,13 +2,9 @@ //! //! This macro expands to a `#[test]` function which tests the local machine //! for the appropriate cfg before calling the inner test function. -#![deny(rust_2018_idioms)] -#[macro_use] -extern crate quote; - -use proc_macro2::{Ident, Span, TokenStream, TokenTree}; -use quote::ToTokens; +use proc_macro2::{Span, TokenStream, TokenTree}; +use quote::{ToTokens, quote, quote_spanned}; use std::env; #[proc_macro_attribute] @@ -18,14 +14,6 @@ pub fn simd_test( ) -> proc_macro::TokenStream { let tokens = TokenStream::from(attr).into_iter().collect::>(); - let target = env::var("TARGET").expect( - "TARGET environment variable should be set for rustc (e.g. TARGET=x86_64-apple-darwin cargo test)" - ); - let target_arch = target - .split('-') - .next() - .unwrap_or_else(|| panic!("target triple contained no \"-\": {target}")); - let (target_features, target_feature_attr) = match &tokens[..] { [] => (Vec::new(), TokenStream::new()), [ @@ -33,25 +21,25 @@ pub fn simd_test( TokenTree::Punct(equals), TokenTree::Literal(literal), ] if enable == "enable" && equals.as_char() == '=' => { - let mut enable_feature = literal - .to_string() - .trim_start_matches('"') - .trim_end_matches('"') - .to_string(); + let lit = literal.to_string(); + let enable_feature = lit.trim_start_matches('"').trim_end_matches('"'); let target_features: Vec<_> = enable_feature .replace('+', "") .split(',') .map(String::from) .collect(); + let mut enable_feature_arm = enable_feature.to_string(); + // Allows using `#[simd_test(enable = "neon")]` on aarch64/armv7 shared tests. - if target_arch == "armv7" && target_features.iter().any(|feat| feat == "neon") { - enable_feature.push_str(",v7"); + if target_features.iter().any(|feat| feat == "neon") { + enable_feature_arm.push_str(",v7"); } ( target_features, quote! { - #[target_feature(enable = #enable_feature)] + #[cfg_attr(target_arch = "arm", target_feature(enable = #enable_feature_arm))] + #[cfg_attr(not(target_arch = "arm"), target_feature(enable = #enable_feature))] }, ) } @@ -62,83 +50,107 @@ pub fn simd_test( let item_attrs = std::mem::take(&mut item.attrs); let name = &item.sig.ident; - let macro_test = match target_arch { - "i686" | "x86_64" | "i586" => "is_x86_feature_detected", - "arm" | "armv7" | "thumbv7neon" => "is_arm_feature_detected", - "aarch64" | "arm64ec" | "aarch64_be" => "is_aarch64_feature_detected", - maybe_riscv if maybe_riscv.starts_with("riscv") => "is_riscv_feature_detected", - "powerpc" | "powerpcle" | "powerpc64" | "powerpc64le" => "is_powerpc_feature_detected", - "loongarch32" | "loongarch64" => "is_loongarch_feature_detected", - "s390x" => "is_s390x_feature_detected", - "mips64" | "mips64el" => "is_mips64_feature_detected", - t => panic!("unknown target: {t}"), - }; - let macro_test = Ident::new(macro_test, Span::call_site()); - - let skipped_functions = env::var("STDARCH_TEST_SKIP_FUNCTION").unwrap_or_default(); - let skipped_features = env::var("STDARCH_TEST_SKIP_FEATURE").unwrap_or_default(); - let mut name_str = &*name.to_string(); if name_str.starts_with("test_") { name_str = &name_str[5..]; } - let skip_this = skipped_functions + let skipped_functions = env::var("STDARCH_TEST_SKIP_FUNCTION").unwrap_or_default(); + let skipped_features = env::var("STDARCH_TEST_SKIP_FEATURE").unwrap_or_default(); + let skipped_function = skipped_functions + .split(',') + .map(str::trim) + .any(|s| s == name_str); + let skipped_feature = skipped_features .split(',') .map(str::trim) - .any(|s| s == name_str) - || skipped_features - .split(',') - .map(str::trim) - .any(|s| target_features.iter().any(|feature| s == feature)); + .any(|s| target_features.iter().any(|feature| s == feature)); let mut detect_missing_features = TokenStream::new(); for feature in target_features { - let q = if target_arch == "armv7" && feature == "fp16" { - // "fp16" cannot be checked at runtime - quote_spanned! { - proc_macro2::Span::call_site() => - if !cfg!(target_feature = #feature) { - missing_features.push(#feature); - } + let mut q = quote_spanned! { Span::call_site() => + // Default target feature check + if !test_macro!(#feature) { + missing_features.push(#feature); } - } else { - quote_spanned! { - proc_macro2::Span::call_site() => - if !::std::arch::#macro_test!(#feature) { - missing_features.push(#feature); + }; + + // For features that cannot be checked at runtime (currently fp16 on arm32), use the + // static check instead. + if feature == "fp16" { + q = quote_spanned! { Span::call_site() => + cfg_select! { + target_arch = "arm" => { + if !cfg!(target_feature = #feature) { + missing_features.push(#feature); + } + } + _ => { + #q + } } } - }; + } + q.to_tokens(&mut detect_missing_features); } - let maybe_ignore = if skip_this { - quote! { #[ignore] } - } else { - TokenStream::new() - }; + let mut maybe_ignore = TokenStream::new(); + let mut const_test = TokenStream::new(); + let mut const_stability = TokenStream::new(); - let (const_test, const_stability) = if item.sig.constness.is_some() { - ( - quote! { - const _: () = unsafe { #name() }; - }, - quote! { - #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] - }, - ) - } else { - (TokenStream::new(), TokenStream::new()) - }; + if skipped_function || skipped_feature { + maybe_ignore = quote! { #[ignore] } + } - let ret: TokenStream = quote_spanned! { - proc_macro2::Span::call_site() => + if item.sig.constness.is_some() { + const_test = quote! { + const _: () = unsafe { #name() }; + }; + const_stability = quote! { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + }; + } + + let ret: TokenStream = quote_spanned! { Span::call_site() => #[allow(non_snake_case)] #[test] #maybe_ignore #(#item_attrs)* fn #name() { + cfg_select! { + any(target_arch = "x86", target_arch = "x86_64") => { + use std::arch::is_x86_feature_detected as test_macro; + } + target_arch = "arm" => { + use std::arch::is_arm_feature_detected as test_macro; + } + any(target_arch = "aarch64", target_arch = "arm64ec") => { + use std::arch::is_aarch64_feature_detected as test_macro; + } + any(target_arch = "riscv32", target_arch = "riscv64") => { + use std::arch::is_riscv_feature_detected as test_macro; + } + any(target_arch = "powerpc", target_arch = "powerpc64") => { + use std::arch::is_powerpc_feature_detected as test_macro; + } + any(target_arch = "loongarch32", target_arch = "loongarch64") => { + use std::arch::is_loongarch_feature_detected as test_macro; + } + target_arch = "s390x" => { + use std::arch::is_s390x_feature_detected as test_macro; + } + any( + target_arch = "mips", + target_arch = "mips32r6" + target_arch = "mips64", + target_arch = "mips64r6", + ) => { + use std::arch::is_mips_feature_detected as test_macro; + } + _ => compile_error!("unknown target; need to update simd-test-macro"), + } + #const_test let mut missing_features = ::std::vec::Vec::new(); diff --git a/library/stdarch/crates/stdarch-gen-arm/README.md b/library/stdarch/crates/stdarch-gen-arm/README.md index 970721681c04a..1a10afedb52bd 100644 --- a/library/stdarch/crates/stdarch-gen-arm/README.md +++ b/library/stdarch/crates/stdarch-gen-arm/README.md @@ -91,7 +91,7 @@ attribute: - `target_features` (_Optional_) - A sequence of target features to enable for this intrinsic (merged with any global `arch_cfgs` settings). - `assert_instr` (_Optional_) - - A sequence of strings expected to be found in the assembly. Required if `attr` is not set. + - A string expected to be found in the assembly, followed by value assignments for const generic arguments to be used for this test. Required if `attr` is not set. - `safety` (_Optional_) - Use `safe`, or map `unsafe:` to a sequence of unsafety comments: - `custom: ""` diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml index 0b52f2701fa0e..4cb43ee580ecf 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml @@ -41,6 +41,10 @@ neon-i8mm: &neon-i8mm neon-fp16: &neon-fp16 FnCall: [target_feature, ['enable = "neon,fp16"']] +# #[target_feature(enable = "neon,bf16")] +neon-bf16: &neon-bf16 + FnCall: [target_feature, ['enable = "neon,bf16"']] + # #[cfg_attr(not(target_arch = "arm"), target_feature(enable = "fhm"))] enable-fhm: &enable-fhm FnCall: [cfg_attr, [{ FnCall: [not, ['target_arch = "arm"']]}, { FnCall: [target_feature, ['enable = "fhm"']] }]] @@ -59,6 +63,18 @@ aarch64-crc-stable: &aarch64-crc-stable neon-unstable-f16: &neon-unstable-f16 FnCall: [unstable, ['feature = "stdarch_neon_f16"', 'issue = "136306"']] +# #[unstable(feature = "stdarch_neon_bf16", issue = "164986")] +neon-unstable-bf16: &neon-unstable-bf16 + FnCall: [unstable, ['feature = "stdarch_neon_bf16"', 'issue = "164986"']] + +# #[cfg(any(target_has_reliable_f16b, doc))] +cfg-reliable-bf16: &cfg-reliable-bf16 + FnCall: [cfg, [{ FnCall: [any, [target_has_reliable_f16b, doc]]}]] + +# #[doc(cfg(target_has_reliable_f16b))] +doc-cfg-reliable-bf16: &doc-cfg-reliable-bf16 + FnCall: [doc, [{ FnCall: [cfg, [target_has_reliable_f16b]]}]] + # #[unstable(feature = "stdarch_neon_feat_lut", issue = "138050")] neon-unstable-feat-lut: &neon-unstable-feat-lut FnCall: [unstable, ['feature = "stdarch_neon_feat_lut"', 'issue = "138050"']] @@ -14215,3 +14231,180 @@ intrinsics: compose: - FnCall: [static_assert_uimm_bits!, [IMM5, "1"]] - FnCall: ['simd_extract!', [a, 'IMM5 as u32'], [] , true] + +########## bf16 intrinsics + - name: "vreinterpret{neon_type[1].no}{neon_type[0].noq}" + doc: Vector reinterpret cast operation + arguments: ["a: {type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + - *target-not-arm64ec + assert_instr: [nop] + safety: safe + types: + - [float64x1_t, bfloat16x4_t] + - [bfloat16x4_t, float64x1_t] + - [float64x2_t, bfloat16x8_t] + - [bfloat16x8_t, float64x2_t] + compose: + - FnCall: [transmute, [a]] + + - name: "vcopy{neon_type[0].lane_nox}" + doc: "Insert vector element from another vector element" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "{neon_type[0]}" + attr: + - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [nop, 'LANE1 = {type[2]}', 'LANE2 = {type[3]}']]}]] + - FnCall: [rustc_legacy_const_generics, ['1', '3']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE1: i32, const LANE2: i32'] + safety: safe + types: + - [bfloat16x4_t, bfloat16x4_t, '3', '3', 'vcopy_lane_u16'] + - [bfloat16x8_t, bfloat16x4_t, '7', '3', 'vcopyq_lane_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[4]}::', [FnCall: [transmute, [a]], FnCall: [transmute, [b]]]]]] + + - name: "vcopy{neon_type[0].laneq_nox}" + doc: "Insert vector element from another vector element" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "{neon_type[0]}" + attr: + - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [nop, 'LANE1 = {type[2]}', 'LANE2 = {type[3]}']]}]] + - FnCall: [rustc_legacy_const_generics, ['1', '3']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE1: i32, const LANE2: i32'] + safety: safe + types: + - [bfloat16x4_t, bfloat16x8_t, '3', '7', 'vcopy_laneq_u16'] + - [bfloat16x8_t, bfloat16x8_t, '7', '7', 'vcopyq_laneq_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[4]}::', [FnCall: [transmute, [a]], FnCall: [transmute, [b]]]]]] + + # MSVC's dumpbin prints raw opcodes for BF16 LUT instructions. + - name: "vluti2{neon_type[0].lane_nox}" + doc: "Lookup table read with 2-bit indices" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "bfloat16x8_t" + attr: + - FnCall: [target_feature, ['enable = "neon,lut,bf16"']] + - FnCall: [cfg_attr, [*msvc-disabled, {FnCall: [assert_instr, [luti2, 'LANE = 1']]}]] + - FnCall: [rustc_legacy_const_generics, ['2']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE: i32'] + safety: + unsafe: [neon] + types: + - [bfloat16x4_t, uint8x8_t, 'LANE >= 0 && LANE <= 3'] + - [bfloat16x8_t, uint8x8_t, 'LANE >= 0 && LANE <= 3'] + compose: + - FnCall: ['static_assert!', ['{type[2]}']] + - LLVMLink: + name: "vluti2{neon_type[0].lane_nox}" + arguments: + - 'a: {neon_type[0]}' + - 'b: {neon_type[1]}' + - 'n: i32' + links: + - link: "llvm.aarch64.neon.vluti2.lane.v8bf16.{neon_type[0]}" + arch: aarch64,arm64ec + - FnCall: ['_vluti2{neon_type[0].lane_nox}', [a, b, LANE]] + + - name: "vluti2{neon_type[0].laneq_nox}" + doc: "Lookup table read with 2-bit indices" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "bfloat16x8_t" + attr: + - FnCall: [target_feature, ['enable = "neon,lut,bf16"']] + - FnCall: [cfg_attr, [*msvc-disabled, {FnCall: [assert_instr, [luti2, 'LANE = 1']]}]] + - FnCall: [rustc_legacy_const_generics, ['2']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE: i32'] + safety: + unsafe: [neon] + types: + - [bfloat16x4_t, uint8x16_t, 'LANE >= 0 && LANE <= 7'] + - [bfloat16x8_t, uint8x16_t, 'LANE >= 0 && LANE <= 7'] + compose: + - FnCall: ['static_assert!', ['{type[2]}']] + - LLVMLink: + name: "vluti2{neon_type[0].laneq_nox}" + arguments: + - 'a: {neon_type[0]}' + - 'b: {neon_type[1]}' + - 'n: i32' + links: + - link: "llvm.aarch64.neon.vluti2.laneq.v8bf16.{neon_type[0]}" + arch: aarch64,arm64ec + - FnCall: ['_vluti2{neon_type[0].laneq_nox}', [a, b, LANE]] + + - name: "vluti4q_lane_bf16_x2" + doc: "Lookup table read with 4-bit indices" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "bfloat16x8_t" + attr: + - FnCall: [target_feature, ['enable = "neon,lut,bf16"']] + - FnCall: [cfg_attr, [*msvc-disabled, {FnCall: [assert_instr, [luti4, 'LANE = 0']]}]] + - FnCall: [rustc_legacy_const_generics, ['2']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE: i32'] + safety: + unsafe: [neon] + types: + - [bfloat16x8x2_t, uint8x8_t, 'LANE >= 0 && LANE <= 1'] + compose: + - FnCall: ['static_assert!', ['{type[2]}']] + - LLVMLink: + name: "vluti4q_lane_bf16_x2" + arguments: + - 'a0: bfloat16x8_t' + - 'a1: bfloat16x8_t' + - 'b: {neon_type[1]}' + - 'n: i32' + links: + - link: "llvm.aarch64.neon.vluti4q.lane.x2.v8bf16" + arch: aarch64,arm64ec + - FnCall: ['_vluti4q_lane_bf16_x2', [a.0, a.1, b, LANE]] + + - name: "vluti4q_laneq_bf16_x2" + doc: "Lookup table read with 4-bit indices" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}"] + return_type: "bfloat16x8_t" + attr: + - FnCall: [target_feature, ['enable = "neon,lut,bf16"']] + - FnCall: [cfg_attr, [*msvc-disabled, {FnCall: [assert_instr, [luti4, 'LANE = 0']]}]] + - FnCall: [rustc_legacy_const_generics, ['2']] + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-unstable-bf16 + static_defs: ['const LANE: i32'] + safety: + unsafe: [neon] + types: + - [bfloat16x8x2_t, uint8x16_t, 'LANE >= 0 && LANE <= 3'] + compose: + - FnCall: ['static_assert!', ['{type[2]}']] + - LLVMLink: + name: "vluti4q_laneq_bf16_x2" + arguments: + - 'a0: bfloat16x8_t' + - 'a1: bfloat16x8_t' + - 'b: {neon_type[1]}' + - 'n: i32' + links: + - link: "llvm.aarch64.neon.vluti4q.laneq.x2.v8bf16" + arch: aarch64,arm64ec + - FnCall: ['_vluti4q_laneq_bf16_x2', [a.0, a.1, b, LANE]] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index 35c2a108c39ab..d33a12230b656 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -55,6 +55,10 @@ not-arm: ¬-arm neon-target-aarch64-arm64ec: &neon-target-aarch64-arm64ec FnCall: [all, [test, {FnCall: [any, ['target_arch = "aarch64"', 'target_arch = "arm64ec"']]}]] +# MSVC's dumpbin prints raw opcodes for these BF16 instructions. +neon-target-aarch64-arm64ec-no-msvc: &neon-target-aarch64-arm64ec-no-msvc + FnCall: [all, [test, {FnCall: [any, ['target_arch = "aarch64"', 'target_arch = "arm64ec"']]}, {FnCall: [not, ['target_env = "msvc"']]}]] + neon-target-aarch64-le: &neon-target-aarch64-le FnCall: [all, [test, 'target_arch = "aarch64"', 'target_endian = "little"', {FnCall: [not, [windows]]}]] @@ -99,6 +103,10 @@ neon-i8mm: &neon-i8mm neon-fp16: &neon-fp16 FnCall: [target_feature, ['enable = "neon,fp16"']] +# #[target_feature(enable = "neon,bf16")] +neon-bf16: &neon-bf16 + FnCall: [target_feature, ['enable = "neon,bf16"']] + # #[cfg_attr[target_arch = "arm", target_feature(enable = "neon,fp16")] arm-fp16: &arm-fp16 FnCall: [cfg_attr, ['target_arch = "arm"', {FnCall: [target_feature, ['enable = "fp16"']]}]] @@ -128,6 +136,18 @@ neon-unstable-f16: &neon-unstable-f16 all-neon-target-aarch64-arm64ec-little-endian: &all-neon-target-aarch64-arm64ec-little-endian FnCall: [all, [test, {FnCall: [any, ['target_arch = "aarch64"', 'target_arch = "arm64ec"']]}, 'target_endian = "little"']] +# #[cfg_attr(not(target_arch = "arm"), unstable(feature = "stdarch_neon_bf16", issue = "164986"))] +neon-unstable-bf16: &neon-unstable-bf16 + FnCall: [cfg_attr, [*not-arm, {FnCall: [unstable, ['feature = "stdarch_neon_bf16"', 'issue = "164986"']]}]] + +# #[cfg(any(target_has_reliable_f16b, doc))] +cfg-reliable-bf16: &cfg-reliable-bf16 + FnCall: [cfg, [{ FnCall: [any, [target_has_reliable_f16b, doc]]}]] + +# #[doc(cfg(target_has_reliable_f16b))] +doc-cfg-reliable-bf16: &doc-cfg-reliable-bf16 + FnCall: [doc, [{ FnCall: [cfg, [target_has_reliable_f16b]]}]] + intrinsics: - name: "vand{neon_type.no}" doc: Vector bitwise and @@ -11825,7 +11845,7 @@ intrinsics: arguments: - "ptr: {type[0]}" links: - - link: "llvm.aarch64.neon.ld4r.{neon_type[2]}.p0.p0" + - link: "llvm.aarch64.neon.ld4r.{neon_type[2]}.p0" arch: aarch64,arm64ec - FnCall: ["_vld4{neon_type[1].dup_nox}", ['a as _']] @@ -15338,3 +15358,1349 @@ intrinsics: - ['vrev64q_f32', 'float32x4_t', 'vrev64.32', 'rev64', '[1, 0, 3, 2]'] compose: - FnCall: ['simd_shuffle!', [a, a, '{type[4]}']] + +##### bf16 intrinsics + - name: "vbfdot{neon_type[0].no}" + doc: "BFloat16 floating-point dot product (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdot.bf16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfdot]]}]] + safety: safe + types: + - [float32x2_t, bfloat16x4_t, bfloat16x4_t] + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - LLVMLink: + name: "bfdot.{neon_type[0]}" + links: + - link: "llvm.aarch64.neon.bfdot.{neon_type[0]}.{neon_type[1]}" + arch: aarch64,arm64ec + - link: "llvm.arm.neon.bfdot.{neon_type[0]}.{neon_type[1]}" + arch: arm + + - name: "vbfdot{neon_type[0].lane_nox}" + doc: "BFloat16 floating-point dot product (vector, by element)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdot.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfdot, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x2_t, bfloat16x4_t, bfloat16x4_t, 'vdup_lane_u32'] + - [float32x4_t, bfloat16x8_t, bfloat16x4_t, 'vdupq_lane_u32'] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '1']] + - Let: [pairs, "{neon_type[2]}", "c"] + - Let: [duped, '{neon_type[1]}', FnCall: [transmute, [FnCall: ['{type[3]}::', [FnCall: [transmute, [pairs]]]]]]] + - FnCall: ['vbfdot{neon_type[0].no}', [a, b, duped]] + + - name: "vbfdot{neon_type[0].laneq_nox}" + doc: "BFloat16 floating-point dot product (vector, by element)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdot.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfdot, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t, 'vdupq_laneq_u32'] + - [float32x2_t, bfloat16x4_t, bfloat16x8_t, 'vdup_laneq_u32'] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '2']] + - Let: [pairs, "{neon_type[2]}", "c"] + - Let: [duped, '{neon_type[1]}', FnCall: [transmute, [FnCall: ['{type[3]}::', [FnCall: [transmute, [pairs]]]]]]] + - FnCall: ['vbfdot{neon_type[0].no}', [a, b, duped]] + + - name: "vbfmlalbq_f32" + big_endian_inverse: true + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmab.bf16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalb]]}]] + safety: safe + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - LLVMLink: + name: "vbfmlalbq_f32" + links: + - link: "llvm.aarch64.neon.bfmlalb" + arch: aarch64,arm64ec + - link: "llvm.arm.neon.bfmlalb" + arch: arm + +# "vbfmlalbq_lane_f32" ARM + - name: "vbfmlalbq_lane_f32" + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmab.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalb, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x4_t, bfloat16x8_t, bfloat16x4_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '2']] + - Let: [duped, bfloat16x8_t, FnCall: [transmute, [FnCall: ['vdupq_lane_u16::', [FnCall: [transmute, [c]]]]]]] + - FnCall: [vbfmlalbq_f32, [a, b, duped]] + + - name: "vbfmlalbq_laneq_f32" + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmab.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalb, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '3']] + - Let: [duped, bfloat16x8_t, FnCall: [transmute, [FnCall: ['vdupq_laneq_u16::', [FnCall: [transmute, [c]]]]]]] + - FnCall: [vbfmlalbq_f32, [a, b, duped]] + + - name: "vbfmlaltq_f32" + big_endian_inverse: true + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmat.bf16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalt]]}]] + safety: safe + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - LLVMLink: + name: "vbfmlalbq_f32" + links: + - link: "llvm.aarch64.neon.bfmlalt" + arch: aarch64,arm64ec + - link: "llvm.arm.neon.bfmlalt" + arch: arm + +# "vbfmlalbq_lane_f32" ARM + - name: "vbfmlaltq_lane_f32" + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmat.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalt, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x4_t, bfloat16x8_t, bfloat16x4_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '2']] + - Let: [duped, bfloat16x8_t, FnCall: [transmute, [FnCall: ['vdupq_lane_u16::', [FnCall: [transmute, [c]]]]]]] + - FnCall: [vbfmlaltq_f32, [a, b, duped]] + + - name: "vbfmlaltq_laneq_f32" + doc: "BFloat16 floating-point widening multiply-add long (vector)" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vfmat.bf16"', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmlalt, 'LANE = 0']]}]] + safety: safe + static_defs: ['const LANE: i32'] + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '3']] + - Let: [duped, bfloat16x8_t, FnCall: [transmute, [FnCall: ['vdupq_laneq_u16::', [FnCall: [transmute, [c]]]]]]] + - FnCall: [vbfmlaltq_f32, [a, b, duped]] + + - name: "vbfmmlaq_f32" + big_endian_inverse: true + doc: "BFloat16 floating-point matrix multiply-accumulate into 2x2 matrix" + arguments: ["a: {neon_type[0]}", "b: {neon_type[1]}", "c: {neon_type[2]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vmmla.bf16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfmmla]]}]] + safety: safe + types: + - [float32x4_t, bfloat16x8_t, bfloat16x8_t] + compose: + - LLVMLink: + name: "bfmmla.{neon_type[0]}" + links: + - link: "llvm.aarch64.neon.bfmmla" + arch: aarch64,arm64ec + - link: "llvm.arm.neon.bfmmla" + arch: arm + + - name: "vcombine_bf16" + doc: Join two smaller vectors into a single larger vector + arguments: ["a: {neon_type[0]}", "b: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: safe + big_endian_inverse: true + types: + - [bfloat16x4_t, bfloat16x8_t] + compose: + - FnCall: [simd_shuffle!, [a, b, '[0, 1, 2, 3, 4, 5, 6, 7]']] + + - name: "vcreate_bf16" + doc: Insert vector element from another vector element + arguments: ["a: {type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - ['u64', 'bfloat16x4_t'] + compose: + - FnCall: [transmute, [a]] + + - name: "vcvt_bf16_f32" + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - *target-is-arm + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vcvt.bf16.f32"']]}]] + safety: safe + types: + - [float32x4_t, bfloat16x4_t] + compose: + - LLVMLink: + name: "vcvt_bf16_f32" + links: + - link: "llvm.arm.neon.vcvtfp2bf.v4bf16" + arch: arm + + - name: "vcvt_bf16_f32" + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-unstable-bf16 + - *target-not-arm + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [bfcvtn]]}]] + safety: safe + types: + - [float32x4_t, bfloat16x4_t] + compose: + - FnCall: [vget_low_bf16, [FnCall: [vcvtq_low_bf16_f32, [a], [], true]], [], true] + + - name: "vcvt_f32_bf16" + doc: "Shift Left Long (by element size)" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vshll.i16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [shll]]}]] + safety: safe + types: + - [bfloat16x4_t, float32x4_t] + compose: + - Let: [half, uint16x4_t, FnCall: [transmute, [a]]] + - FnCall: [vreinterpretq_f32_u32, [FnCall: ['vshll_n_u16::<16>', [half]]]] + + - name: "vcvtah_f32_bf16" + doc: "Shift Left (immediate)" + arguments: ["a: {type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: safe + types: + - ['bfloat16_t', float32_t] + compose: + - FnCall: [f32::from_bits, ['(a.to_bits() as u32) << 16']] + + - name: "vcvth_bf16_f32" + doc: "Floating-point convert from single-precision to BFloat16 format (scalar)" + arguments: ["a: {type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vcvtb.bf16.f32"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec-no-msvc, {FnCall: [assert_instr, [bfcvt]]}]] + safety: safe + types: + - [float32_t, bfloat16_t] + compose: + - LLVMLink: + name: "vcvth_bf16_f32" + links: + - link: "llvm.arm.neon.vcvtbfp2bf" + arch: arm + - link: "llvm.aarch64.neon.bfcvt" + arch: aarch64,arm64ec + + - name: "vcvtq_low_bf16_f32" + big_endian_inverse: true + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["a: {type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - *target-is-arm + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vcvt.bf16.f32"']]}]] + safety: + unsafe: [neon] + types: + - [float32x4_t, bfloat16x8_t] + compose: + - Let: [a, int32x4_t, FnCall: [transmute, [a]]] + - Let: [a, int8x16_t, FnCall: [transmute, [a]]] + - Let: [a, float32x4_t, FnCall: [transmute, [a]]] + - Let: [vec, bfloat16x4_t, FnCall: [vcvt_bf16_f32, [a]]] + - Let: [z, bfloat16x4_t, 'bfloat16x4_t([bfloat16_t::from_bits(0x0), bfloat16_t::from_bits(0x0), bfloat16_t::from_bits(0x0), bfloat16_t::from_bits(0x0)])'] + - FnCall: [simd_shuffle!, [z, vec, '[0, 1, 2, 3, 4, 5, 6, 7]']] + + - name: "vcvtq_low_bf16_f32" + big_endian_inverse: true + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["a: {type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - *target-not-arm + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [bfcvtn]]}]] + safety: + unsafe: [neon] + types: + - [float32x4_t, bfloat16x8_t] + compose: + - LLVMLink: + name: "vcvtq_low_bf16_f32" + links: + - link: "llvm.aarch64.neon.bfcvtn" + arch: aarch64,arm64ec + + - name: "vcvtq_high_f32_bf16" + doc: "Shift Left Long (by element size)" + arguments: ["a: {type[1]}"] + return_type: "{type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vshll.i16"']]}]] + - FnCall: [cfg_attr, [*all-neon-target-aarch64-arm64ec-little-endian, {FnCall: [assert_instr, [shll2]]}]] + # Reversing big-endian lanes lets LLVM use the low-half instruction. + - FnCall: [cfg_attr, [*neon-target-aarch64-be, {FnCall: [assert_instr, [shll]]}]] + safety: safe + types: + - [float32x4_t, bfloat16x8_t] + compose: + - Let: [half, uint16x4_t, FnCall: [vget_high_u16, [FnCall: [transmute, [a]]]]] + - FnCall: [vreinterpretq_f32_u32, [FnCall: ['vshll_n_u16::<16>', [half]]]] + + - name: "vcvtq_high_bf16_f32" + big_endian_inverse: true + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["_inactive: {neon_type[0]}", "a: {neon_type[1]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - *target-not-arm + - FnCall: [cfg_attr, [*all-neon-target-aarch64-arm64ec-little-endian, {FnCall: [assert_instr, [bfcvtn2]]}]] + # Reversing big-endian lanes lets LLVM use the low-half instruction. + - FnCall: [cfg_attr, [*neon-target-aarch64-be, {FnCall: [assert_instr, [bfcvtn]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, float32x4_t] + compose: + - LLVMLink: + name: "vcvtq_high_bf16_f32" + links: + - link: "llvm.aarch64.neon.bfcvtn2" + arch: aarch64,arm64ec + + # T + - name: "vcvtq_high_bf16_f32" + doc: "Floating-point convert from single-precision to BFloat16 format (vector)" + arguments: ["_inactive: {neon_type[0]}", "a: {neon_type[1]}"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - *target-is-arm + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vcvt.bf16.f32"']]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, float32x4_t] + compose: + - Let: [b, bfloat16x4_t, FnCall: [simd_shuffle!, [_inactive, _inactive, '[0, 1, 2, 3]']]] + - Let: [a, int32x4_t, FnCall: [transmute, [a]]] + - Let: [a, int16x8_t, FnCall: [transmute, [a]]] + - Let: [a, float32x4_t, FnCall: [transmute, [a]]] + - Let: [a, bfloat16x4_t, FnCall: [vcvt_bf16_f32, [a]]] + - Let: [vec, bfloat16x4_t, FnCall: [simd_shuffle!, [a, a, '[0, 1, 2, 3]']]] + - FnCall: [simd_shuffle!, [vec, b, '[0, 1, 2, 3, 4, 5, 6, 7]']] + + - name: "vcvtq_low_f32_bf16" + doc: "Shift Left Long (by element size)" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vshll.i16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [shll]]}]] + safety: safe + types: + - [bfloat16x8_t, float32x4_t] + compose: + - Let: [half, uint16x4_t, FnCall: [vget_low_u16, [FnCall: [transmute, [a]]]]] + - FnCall: [vreinterpretq_f32_u32, [FnCall: ['vshll_n_u16::<16>', [half]]]] + + - name: "vdup_lane_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: bfloat16x4_t"] + return_type: "{neon_type[0]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + static_defs: ['const LANE: i32'] + types: + - [bfloat16x4_t, bfloat16x4_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, 2]] + - Let: [c, uint16x4_t, FnCall: [vreinterpret_u16_bf16, [a]]] + - Let: [duped, uint16x4_t, FnCall: ['vdup_lane_u16::', [c]]] + - FnCall: [vreinterpret_bf16_u16, [duped]] + + - name: "vdupq_lane_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + static_defs: ['const LANE: i32'] + types: + - [bfloat16x4_t, bfloat16x8_t] + compose: + # cast to u16s, duplicate the lane using a u16 intrinsic and then cast back + - FnCall: [static_assert_uimm_bits!, [LANE, 2]] + - Let: [c, uint16x4_t, FnCall: [vreinterpret_u16_bf16, [a]]] + - Let: [duped, uint16x8_t, FnCall: ['vdupq_lane_u16::', [c]]] + - FnCall: [vreinterpretq_bf16_u16, [duped]] + + - name: "vdup_n_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16_t, bfloat16x4_t] + compose: + - FnCall: [vreinterpret_bf16_u16, [FnCall: [vdup_n_u16, [MethodCall: [a, to_bits, []]]]]] + + - name: "vdupq_n_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16_t, bfloat16x8_t] + compose: + - FnCall: [vreinterpretq_bf16_u16, [FnCall: [vdupq_n_u16, [MethodCall: [a, to_bits, []]]]]] + + - name: "vget_lane_bf16" + big_endian_inverse: true + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + static_defs: ['const LANE: i32'] + types: + - [bfloat16x4_t, bfloat16_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '2']] + - FnCall: [simd_extract!, [a, 'LANE as u32']] + + - name: "vgetq_lane_bf16" + big_endian_inverse: true + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + static_defs: ['const LANE: i32'] + types: + - [bfloat16x8_t, bfloat16_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '3']] + - FnCall: [simd_extract!, [a, 'LANE as u32']] + + - name: "vduph_lane_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{type[1]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x4_t, bfloat16_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, 2]] + - FnCall: ['vget_lane_bf16::', [a]] + + - name: "vduph_laneq_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{type[1]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, bfloat16_t] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '3']] + - FnCall: ['vgetq_lane_bf16::', [a]] + + - name: "vdup{neon_type[1].laneq_nox}" + big_endian_inverse: true + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, bfloat16x4_t] + - [bfloat16x8_t, bfloat16x8_t] + compose: + - FnCall: ["static_assert_uimm_bits!", [LANE, '3']] + - FnCall: ["simd_shuffle!", [a, a, '[LANE as u32; {neon_type[1].lane}]']] + + - name: "vget_high_bf16" + big_endian_inverse: true + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, bfloat16x4_t] + compose: + - FnCall: [simd_shuffle!, [a, a, "[4, 5, 6, 7]"]] + + - name: "vget_low_bf16" + doc: "Duplicate vector element to vector or scalar" + arguments: ["a: {neon_type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16x8_t, bfloat16x4_t] + compose: + - FnCall: [transmute, [FnCall: [vget_low_u64, [FnCall: [transmute, [a]]]]]] + + - name: "vld1{neon_type[1].no}" + doc: "Load multiple single-element structures to one, two, three, or four registers" + arguments: ["ptr: *const {type[0]}"] + return_type: "{neon_type[1]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - [bfloat16_t, bfloat16x4_t] + - [bfloat16_t, bfloat16x8_t] + compose: + - FnCall: ['crate::ptr::read_unaligned', [MethodCall: [ptr, cast, []]]] + + - name: "{type[0]}" + doc: "Load multiple single-element structures to one, two, three, or four registers" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *target-is-arm + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vld1.8"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld1]]}]] + safety: + unsafe: [neon] + types: + - ['vld1_bf16_x2', bfloat16_t, bfloat16x4x2_t, "ld1x2.v4bf16.p0", 'vld1_u16_x2'] + - ['vld1q_bf16_x2', bfloat16_t, bfloat16x8x2_t, "ld1x2.v8bf16.p0", 'vld1q_u16_x2'] + - ['vld1_bf16_x3', bfloat16_t, bfloat16x4x3_t, "ld1x3.v4bf16.p0", 'vld1_u16_x3'] + - ['vld1q_bf16_x3', bfloat16_t, bfloat16x8x3_t, "ld1x3.v8bf16.p0", 'vld1q_u16_x3'] + - ['vld1_bf16_x4', bfloat16_t, bfloat16x4x4_t, "ld1x4.v4bf16.p0", 'vld1_u16_x4'] + - ['vld1q_bf16_x4', bfloat16_t, bfloat16x8x4_t, "ld1x4.v8bf16.p0", 'vld1q_u16_x4'] + compose: + - FnCall: [transmute, [FnCall: ['{type[4]}', [MethodCall: [ptr, cast, []]]]]] + + - name: "{type[0]}" + doc: "Load multiple single-element structures to one, two, three, or four registers" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *target-not-arm + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vld1.8"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld1]]}]] + safety: + unsafe: [neon] + types: + - ['vld1_bf16_x2', bfloat16_t, bfloat16x4x2_t, "ld1x2.v4bf16.p0", 'vld1_u16_x2'] + - ['vld1q_bf16_x2', bfloat16_t, bfloat16x8x2_t, "ld1x2.v8bf16.p0", 'vld1q_u16_x2'] + - ['vld1_bf16_x3', bfloat16_t, bfloat16x4x3_t, "ld1x3.v4bf16.p0", 'vld1_u16_x3'] + - ['vld1q_bf16_x3', bfloat16_t, bfloat16x8x3_t, "ld1x3.v8bf16.p0", 'vld1q_u16_x3'] + - ['vld1_bf16_x4', bfloat16_t, bfloat16x4x4_t, "ld1x4.v4bf16.p0", 'vld1_u16_x4'] + - ['vld1q_bf16_x4', bfloat16_t, bfloat16x8x4_t, "ld1x4.v8bf16.p0", 'vld1q_u16_x4'] + compose: + - LLVMLink: + name: "{type[0]}" + links: + - link: "llvm.aarch64.neon.{type[3]}" + arch: aarch64,arm64ec + + - name: "{type[0]}" + doc: "Load one single-element structure and Replicate to all lanes (of one register)" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - ['vld1_dup_bf16', bfloat16_t, bfloat16x4_t, 'f16bx4::splat', 'vld1_dup_u16'] + - ['vld1q_dup_bf16', bfloat16_t, bfloat16x8_t, 'f16bx8::splat', 'vld1q_dup_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[4]}', [MethodCall: [ptr, cast, []]]]]] + + - name: "{type[0]}" + doc: "Load one single-element structure to one lane of one register" + arguments: ["ptr: *const {type[1]}", "src: {neon_type[2]}"] + return_type: "{neon_type[2]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vld1_lane_bf16', bfloat16_t, bfloat16x4_t, '2', 'vld1_lane_u16'] + - ['vld1q_lane_bf16', bfloat16_t, bfloat16x8_t, '3', 'vld1q_lane_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[4]}::', [MethodCall: [ptr, cast, []], FnCall: [transmute, [src]]]]]] + + - name: "{type[0]}" + doc: "Load multiple 2-element structures to two registers" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *target-is-arm + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}']]}]] + safety: + unsafe: [neon] + types: + - ['vld2_bf16', bfloat16_t, bfloat16x4x2_t, "ld2.v4bf16.p0", 'ld2', 'vld2_u16'] + - ['vld2q_bf16', bfloat16_t, bfloat16x8x2_t, "ld2.v8bf16.p0", 'ld2', 'vld2q_u16'] + - ['vld3_bf16', bfloat16_t, bfloat16x4x3_t, "ld3.v4bf16.p0", 'ld3', 'vld3_u16'] + - ['vld3q_bf16', bfloat16_t, bfloat16x8x3_t, "ld3.v8bf16.p0", 'ld3', 'vld3q_u16'] + - ['vld4_bf16', bfloat16_t, bfloat16x4x4_t, "ld4.v4bf16.p0", 'ld4', 'vld4_u16'] + - ['vld4q_bf16', bfloat16_t, bfloat16x8x4_t, "ld4.v8bf16.p0", 'ld4', 'vld4q_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[5]}', [MethodCall: [ptr, cast, []]]]]] + + - name: "{type[0]}" + doc: "Load multiple 2-element structures to two registers" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *target-not-arm + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}']]}]] + safety: + unsafe: [neon] + types: + - ['vld2_bf16', bfloat16_t, bfloat16x4x2_t, "ld2.v4bf16.p0", 'ld2', 'vld2_u16'] + - ['vld2q_bf16', bfloat16_t, bfloat16x8x2_t, "ld2.v8bf16.p0", 'ld2', 'vld2q_u16'] + - ['vld3_bf16', bfloat16_t, bfloat16x4x3_t, "ld3.v4bf16.p0", 'ld3', 'vld3_u16'] + - ['vld3q_bf16', bfloat16_t, bfloat16x8x3_t, "ld3.v8bf16.p0", 'ld3', 'vld3q_u16'] + - ['vld4_bf16', bfloat16_t, bfloat16x4x4_t, "ld4.v4bf16.p0", 'ld4', 'vld4_u16'] + - ['vld4q_bf16', bfloat16_t, bfloat16x8x4_t, "ld4.v8bf16.p0", 'ld4', 'vld4q_u16'] + compose: + - LLVMLink: + name: "{type[0]}" + links: + - link: "llvm.aarch64.neon.{type[3]}" + arch: aarch64,arm64ec + + - name: "{type[0]}" + doc: "Load single 2-element structure and Replicate to all lanes of two registers" + arguments: ["ptr: *const {type[1]}"] + return_type: "{neon_type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}']]}]] + safety: + unsafe: [neon] + types: + - ['vld2_dup_bf16', bfloat16_t, bfloat16x4x2_t, "ld2r.v4bf16.p0", 'ld2', 'vld2_dup_u16'] + - ['vld2q_dup_bf16', bfloat16_t, bfloat16x8x2_t, "ld2dup.v8bf16.p0", 'ld2', 'vld2q_dup_u16'] + - ['vld3_dup_bf16', bfloat16_t, bfloat16x4x3_t, "ld3r.v4bf16.p0", 'ld3', 'vld3_dup_u16'] + - ['vld3q_dup_bf16', bfloat16_t, bfloat16x8x3_t, "ld3dup.v8bf16.p0", 'ld3', 'vld3q_dup_u16'] + - ['vld4_dup_bf16', bfloat16_t, bfloat16x4x4_t, "ld4r.v4bf16.p0", 'ld4', 'vld4_dup_u16'] + - ['vld4q_dup_bf16', bfloat16_t, bfloat16x8x4_t, "ld4dup.v8bf16.p0", 'ld4', 'vld4q_dup_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[5]}', [MethodCall: [ptr, cast, []]]]]] + + - name: "{type[0]}" + doc: "Load single 2-element structure and Replicate to all lanes of two registers" + arguments: ["ptr: *const {type[1]}", "src: {neon_type[2]}"] + return_type: "{neon_type[2]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vld2_lane_bf16', bfloat16_t, bfloat16x4x2_t, "ld2lane.v4bf16.p0", 'ld2', '2', 'vld2_lane_u16'] + - ['vld2q_lane_bf16', bfloat16_t, bfloat16x8x2_t, "ld2lane.v8bf16.p0", 'ld2', '3', 'vld2q_lane_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[6]}::', [MethodCall: [ptr, cast, []], FnCall: [transmute, [src]]]]]] + + - name: "{type[0]}" + doc: "Load single 3-element structure to one lane of three registers" + arguments: ["ptr: *const {type[1]}", "src: {neon_type[2]}"] + return_type: "{neon_type[2]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vld3_lane_bf16', bfloat16_t, bfloat16x4x3_t, "ld3lane.v4bf16.p0", 'ld3', '2', 'vld3_lane_u16'] + - ['vld3q_lane_bf16', bfloat16_t, bfloat16x8x3_t, "ld3lane.v8bf16.p0", 'ld3', '3', 'vld3q_lane_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[6]}::', [MethodCall: [ptr, cast, []], FnCall: [transmute, [src]]]]]] + + - name: "{type[0]}" + doc: "Load single 4-element structure and Replicate to all lanes of four registers" + arguments: ["ptr: *const {type[1]}", "src: {neon_type[2]}"] + return_type: "{neon_type[2]}" + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vld4_lane_bf16', bfloat16_t, bfloat16x4x4_t, "ld4lane.v4bf16.p0", 'ld4', '2', 'vld4_lane_u16'] + - ['vld4q_lane_bf16', bfloat16_t, bfloat16x8x4_t, "ld4lane.v8bf16.p0", 'ld4', '3', 'vld4q_lane_u16'] + compose: + - FnCall: [transmute, [FnCall: ['{type[6]}::', [MethodCall: [ptr, cast, []], FnCall: [transmute, [src]]]]]] + + - name: "{type[0]}" + doc: "Insert vector element from another vector element" + arguments: ["a: {type[1]}", "v: {neon_type[2]}"] + return_type: "{neon_type[2]}" + big_endian_inverse: true + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['nop', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['nop', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vset_lane_bf16', bfloat16_t, bfloat16x4_t, '2'] + - ['vsetq_lane_bf16', bfloat16_t, bfloat16x8_t, '3'] + compose: + - FnCall: [static_assert_uimm_bits!, [LANE, '{type[3]}']] + - FnCall: ['simd_insert!', [v, 'LANE as u32', a]] + + - name: "{type[0]}" + doc: "Store multiple single-element structures from one, two, three, or four registers" + arguments: ["ptr: *mut {type[1]}", "val: {neon_type[2]}"] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst1.8"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [str]]}]] + safety: + unsafe: [neon] + types: + - ['vst1_bf16', bfloat16_t, bfloat16x4_t, '2', 'vst1_u16'] + - ['vst1q_bf16', bfloat16_t, bfloat16x8_t, '3', 'vst1q_u16'] + compose: + - FnCall: ['crate::ptr::write_unaligned', [MethodCall: [ptr, cast, []], val]] + + - name: "{type[0]}" + doc: "Load single 2-element structure and Replicate to all lanes of two registers" + arguments: ["ptr: *mut {type[1]}", "val: {neon_type[2]}"] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"v{type[4]}.16"']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['{type[4]}']]}]] + safety: + unsafe: [neon] + types: + - ['vst1_bf16_x2', bfloat16_t, bfloat16x4x2_t, "st1x2.p0.v4bf16", 'st1', 'vst1_u16_x2'] + - ['vst1q_bf16_x2', bfloat16_t, bfloat16x8x2_t, "st1x2.p0.v8bf16", 'st1', 'vst1q_u16_x2'] + - ['vst1_bf16_x3', bfloat16_t, bfloat16x4x3_t, "st1x3.p0.v4bf16", 'st1', 'vst1_u16_x3'] + - ['vst1q_bf16_x3', bfloat16_t, bfloat16x8x3_t, "st1x3.p0.v8bf16", 'st1', 'vst1q_u16_x3'] + - ['vst1_bf16_x4', bfloat16_t, bfloat16x4x4_t, "st1x4.p0.v4bf16", 'st1', 'vst1_u16_x4'] + - ['vst1q_bf16_x4', bfloat16_t, bfloat16x8x4_t, "st1x4.p0.v8bf16", 'st1', 'vst1q_u16_x4'] + compose: + - FnCall: ['{type[5]}', [MethodCall: [ptr, cast, []], FnCall: [transmute, [val]]]] + + - name: "{type[0]}" + doc: "Store a single-element structure from one lane of one register" + arguments: ["a: *mut {type[1]}", "v: {neon_type[2]}"] + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['nop', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['nop', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vst1_lane_bf16', bfloat16_t, bfloat16x4_t, '2', 'vst1_lane_u16'] + - ['vst1q_lane_bf16', bfloat16_t, bfloat16x8_t, '3', 'vst1q_lane_u16'] + compose: + - FnCall: ['{type[4]}::', [MethodCall: [a, cast, []], FnCall: [transmute, [v]]]] + + - name: "{type[0]}" + doc: "Store multiple 2-element structures from two registers" + arguments: ["a: *mut {type[1]}", "b: {neon_type[2]}"] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + safety: + unsafe: [neon] + types: + - ['vst2_bf16', bfloat16_t, bfloat16x4x2_t, '4', 'vst2_u16'] + - ['vst2q_bf16', bfloat16_t, bfloat16x8x2_t, '8', 'vst2q_u16'] + compose: + - FnCall: ['{type[4]}', [MethodCall: [a, cast, []], FnCall: [transmute, [b]]]] + + - name: "{type[0]}" + doc: "Store single 2-element structure from one lane of two registers" + arguments: ["a: *mut {type[1]}", "v: {neon_type[2]}"] + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst2.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['st2', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vst2_lane_bf16', bfloat16_t, bfloat16x4x2_t, 'st2lane.v4bf16', '2', 'vst2_lane_u16'] + - ['vst2q_lane_bf16', bfloat16_t, bfloat16x8x2_t, 'st2lane.v8bf16', '3', 'vst2q_lane_u16'] + compose: + - FnCall: ['{type[5]}::', [MethodCall: [a, cast, []], FnCall: [transmute, [v]]]] + + - name: "{type[0]}" + doc: "Store multiple 3-element structures from three registers" + arguments: ["a: *mut {type[1]}", "b: {neon_type[2]}"] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + safety: + unsafe: [neon] + types: + - ['vst3_bf16', bfloat16_t, bfloat16x4x3_t, '4', 'vst3_u16'] + - ['vst3q_bf16', bfloat16_t, bfloat16x8x3_t, '8', 'vst3q_u16'] + compose: + - FnCall: ['{type[4]}', [MethodCall: [a, cast, []], FnCall: [transmute, [b]]]] + + - name: "{type[0]}" + doc: "Store single 3-element structure from one lane of three registers" + arguments: ["a: *mut {type[1]}", "v: {neon_type[2]}"] + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst3.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['st3', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vst3_lane_bf16', bfloat16_t, bfloat16x4x3_t, 'st3lane.v4bf16', '2', 'vst3_lane_u16'] + - ['vst3q_lane_bf16', bfloat16_t, bfloat16x8x3_t, 'st3lane.v8bf16', '3', 'vst3q_lane_u16'] + compose: + - FnCall: ['{type[5]}::', [MethodCall: [a, cast, []], FnCall: [transmute, [v]]]] + + - name: "{type[0]}" + doc: "Store multiple 4-element structures from four registers" + arguments: ["a: *mut {type[1]}", "b: {neon_type[2]}"] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['nop', 'LANE = 0']]}]] + safety: + unsafe: [neon] + types: + - ['vst4_bf16', bfloat16_t, bfloat16x4x4_t, '4', 'vst4_u16'] + - ['vst4q_bf16', bfloat16_t, bfloat16x8x4_t, '8', 'vst4q_u16'] + compose: + - FnCall: ['{type[4]}', [MethodCall: [a, cast, []], FnCall: [transmute, [b]]]] + + - name: "{type[0]}" + doc: "Store single 4-element structure from one lane of four registerss" + arguments: ["a: *mut {type[1]}", "v: {neon_type[2]}"] + static_defs: ['const LANE: i32'] + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst4.16"', 'LANE = 2']]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, ['st4', 'LANE = 2']]}]] + safety: + unsafe: [neon] + types: + - ['vst4_lane_bf16', bfloat16_t, bfloat16x4x4_t, 'st4lane.v4bf16', '2', 'vst4_lane_u16'] + - ['vst4q_lane_bf16', bfloat16_t, bfloat16x8x4_t, 'st4lane.v8bf16', '3', 'vst4q_lane_u16'] + compose: + - FnCall: ['{type[5]}::', [MethodCall: [a, cast, []], FnCall: [transmute, [v]]]] + + - name: "vreinterpret{type[0]}" + doc: "Vector reinterpret cast operation" + arguments: ["a: {type[1]}"] + return_type: "{type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - ["_bf16_f16", "float16x4_t", "bfloat16x4_t"] + - ["_bf16_f32", "float32x2_t", "bfloat16x4_t"] + - ["_bf16_p16", "poly16x4_t", "bfloat16x4_t"] + - ["_bf16_p64", "poly64x1_t", "bfloat16x4_t"] + - ["_bf16_p8", "poly8x8_t", "bfloat16x4_t"] + - ["_bf16_s16", "int16x4_t", "bfloat16x4_t"] + - ["_bf16_s32", "int32x2_t", "bfloat16x4_t"] + - ["_bf16_s64", "int64x1_t", "bfloat16x4_t"] + - ["_bf16_s8", "int8x8_t", "bfloat16x4_t"] + - ["_bf16_u16", "uint16x4_t", "bfloat16x4_t"] + - ["_bf16_u32", "uint32x2_t", "bfloat16x4_t"] + - ["_bf16_u64", "uint64x1_t", "bfloat16x4_t"] + - ["_bf16_u8", "uint8x8_t", "bfloat16x4_t"] + - ["_f16_bf16", "bfloat16x4_t", "float16x4_t"] + - ["_f32_bf16", "bfloat16x4_t", "float32x2_t"] + - ["_p8_bf16", "bfloat16x4_t", "poly8x8_t"] + - ["_p16_bf16", "bfloat16x4_t", "poly16x4_t"] + - ["_p64_bf16", "bfloat16x4_t", "poly64x1_t"] + - ["_s8_bf16", "bfloat16x4_t", "int8x8_t"] + - ["_s16_bf16", "bfloat16x4_t", "int16x4_t"] + - ["_s32_bf16", "bfloat16x4_t", "int32x2_t"] + - ["_s64_bf16", "bfloat16x4_t", "int64x1_t"] + - ["_u8_bf16", "bfloat16x4_t", "uint8x8_t"] + - ["_u16_bf16", "bfloat16x4_t", "uint16x4_t"] + - ["_u32_bf16", "bfloat16x4_t", "uint32x2_t"] + - ["_u64_bf16", "bfloat16x4_t", "uint64x1_t"] + compose: + - FnCall: [transmute, [a]] + + - name: "vreinterpretq{type[0]}" + doc: "Vector reinterpret cast operation" + arguments: ["a: {type[1]}"] + return_type: "{type[2]}" + attr: + - *cfg-reliable-bf16 + - *doc-cfg-reliable-bf16 + - *neon-bf16 + - *neon-v8 + - *neon-unstable-bf16 + - *neon-cfg-arm-unstable + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] + - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] + safety: + unsafe: [neon] + types: + - ["_bf16_f16", "float16x8_t", "bfloat16x8_t"] + - ["_bf16_f32", "float32x4_t", "bfloat16x8_t"] + - ["_bf16_p128", "p128", "bfloat16x8_t"] + - ["_bf16_p16", "poly16x8_t", "bfloat16x8_t"] + - ["_bf16_p64", "poly64x2_t", "bfloat16x8_t"] + - ["_bf16_p8", "poly8x16_t", "bfloat16x8_t"] + - ["_bf16_s16", "int16x8_t", "bfloat16x8_t"] + - ["_bf16_s32", "int32x4_t", "bfloat16x8_t"] + - ["_bf16_s64", "int64x2_t", "bfloat16x8_t"] + - ["_bf16_s8", "int8x16_t", "bfloat16x8_t"] + - ["_bf16_u16", "uint16x8_t", "bfloat16x8_t"] + - ["_bf16_u32", "uint32x4_t", "bfloat16x8_t"] + - ["_bf16_u64", "uint64x2_t", "bfloat16x8_t"] + - ["_bf16_u8", "uint8x16_t", "bfloat16x8_t"] + - ["_f16_bf16", "bfloat16x8_t", "float16x8_t"] + - ["_f32_bf16", "bfloat16x8_t", "float32x4_t"] + - ["_p128_bf16", "bfloat16x8_t", "p128"] + - ["_p16_bf16", "bfloat16x8_t", "poly16x8_t"] + - ["_p64_bf16", "bfloat16x8_t", "poly64x2_t"] + - ["_p8_bf16", "bfloat16x8_t", "poly8x16_t"] + - ["_s16_bf16", "bfloat16x8_t", "int16x8_t"] + - ["_s32_bf16", "bfloat16x8_t", "int32x4_t"] + - ["_s64_bf16", "bfloat16x8_t", "int64x2_t"] + - ["_s8_bf16", "bfloat16x8_t", "int8x16_t"] + - ["_u16_bf16", "bfloat16x8_t", "uint16x8_t"] + - ["_u32_bf16", "bfloat16x8_t", "uint32x4_t"] + - ["_u64_bf16", "bfloat16x8_t", "uint64x2_t"] + - ["_u8_bf16", "bfloat16x8_t", "uint8x16_t"] + compose: + - FnCall: [transmute, [a]] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/sve/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/sve/aarch64.spec.yml index 0b2d17d3b195f..24effec6ad6a3 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/sve/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/sve/aarch64.spec.yml @@ -1335,7 +1335,7 @@ intrinsics: assert_instr: ["ld1{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld1.{sve_type}" } + - LLVMLink: { name: "ld1.{sve_type}.p0" } - name: svld1_vnum[_{type}] attr: [*sve-unstable] @@ -1380,10 +1380,10 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1]}" + name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1]}.p0" doubleword: LLVMLink: - name: "ld1.gather.index.{sve_type[1]}" + name: "ld1.gather.index.{sve_type[1]}.p0" - name: svld1_gather_[{type[0]}]offset[_{type[1]}] attr: [*sve-unstable] @@ -1405,10 +1405,10 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1]}" + name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1]}.p0" doubleword: LLVMLink: - name: "ld1.gather.{sve_type[1]}" + name: "ld1.gather.{sve_type[1]}.p0" - name: svld1_gather[_{type[0]}base]_offset_{type[1]} attr: [*sve-unstable] @@ -1493,11 +1493,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ld1.gather.index.{sve_type[1] as {type[2]}}" + name: "ld1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -1523,11 +1523,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ld1.gather.index.{sve_type[1] as {type[2]}}" + name: "ld1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -1555,11 +1555,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ld1.gather.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -1585,11 +1585,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ld1.gather.{sve_type[1] as {type[2]}}" + name: "ld1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -1747,7 +1747,7 @@ intrinsics: assert_instr: ["ldnt1{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ldnt1.{sve_type}" } + - LLVMLink: { name: "ldnt1.{sve_type}.p0" } - name: svldnt1_vnum[_{type}] attr: [*sve-unstable] @@ -1790,7 +1790,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ld1.{sve_type[0] as {type[1]}}" + name: "ld1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -1814,7 +1814,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ld1.{sve_type[0] as {type[1]}}" + name: "ld1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -1889,7 +1889,7 @@ intrinsics: assert_instr: ["ld2{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld2.sret.{sve_type}" } + - LLVMLink: { name: "ld2.sret.{sve_type}.p0" } - name: svld2_vnum[_{type}] attr: [*sve-unstable] @@ -1927,7 +1927,7 @@ intrinsics: assert_instr: ["ld3{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld3.sret.{sve_type}" } + - LLVMLink: { name: "ld3.sret.{sve_type}.p0" } - name: svld3_vnum[_{type}] attr: [*sve-unstable] @@ -1965,7 +1965,7 @@ intrinsics: assert_instr: ["ld4{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld4.sret.{sve_type}" } + - LLVMLink: { name: "ld4.sret.{sve_type}.p0" } - name: svld4_vnum[_{type}] attr: [*sve-unstable] @@ -2003,7 +2003,7 @@ intrinsics: assert_instr: ["ld1rq{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld1rq.{sve_type}" } + - LLVMLink: { name: "ld1rq.{sve_type}.p0" } - name: svld1ro[_{type}] attr: [*sve-unstable] @@ -2019,7 +2019,7 @@ intrinsics: assert_instr: ["ld1ro{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ld1ro.{sve_type}" } + - LLVMLink: { name: "ld1ro.{sve_type}.p0" } - name: svldnf1[_{type}] attr: [*sve-unstable] @@ -2035,7 +2035,7 @@ intrinsics: assert_instr: ["ldnf1{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ldnf1.{sve_type}" } + - LLVMLink: { name: "ldnf1.{sve_type}.p0" } - name: svldnf1_vnum[_{type}] attr: [*sve-unstable] @@ -2079,7 +2079,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ldnf1.{sve_type[0] as {type[1]}}" + name: "ldnf1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -2104,7 +2104,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ldnf1.{sve_type[0] as {type[1]}}" + name: "ldnf1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -2182,7 +2182,7 @@ intrinsics: assert_instr: ["ldff1{size_literal}"] test: { load: 0 } compose: - - LLVMLink: { name: "ldff1.{sve_type}" } + - LLVMLink: { name: "ldff1.{sve_type}.p0" } - name: svldff1_vnum[_{type}] attr: [*sve-unstable] @@ -2226,7 +2226,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ldff1.{sve_type[0] as {type[1]}}" + name: "ldff1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -2251,7 +2251,7 @@ intrinsics: test: { load: 1 } compose: - LLVMLink: - name: "ldff1.{sve_type[0] as {type[1]}}" + name: "ldff1.{sve_type[0] as {type[1]}}.p0" arguments: ["pg: {predicate[0]}", "base: *{type[1]}"] return_type: "{sve_type[0] as {type[1]}}" - FnCall: @@ -2336,10 +2336,10 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1]}" + name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1]}.p0" doubleword: LLVMLink: - name: "ldff1.gather.index.{sve_type[1]}" + name: "ldff1.gather.index.{sve_type[1]}.p0" - name: svldff1_gather_[{type[0]}]offset[_{type[1]}] attr: [*sve-unstable] @@ -2362,10 +2362,10 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1]}" + name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1]}.p0" doubleword: LLVMLink: - name: "ldff1.gather.{sve_type[1]}" + name: "ldff1.gather.{sve_type[1]}.p0" - name: svldff1_gather[_{type[0]}base]_offset_{type[1]} attr: [*sve-unstable] @@ -2454,11 +2454,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldff1.gather.index.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -2485,11 +2485,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldff1.gather.index.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -2518,11 +2518,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldff1.gather.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -2549,11 +2549,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldff1.gather.{sve_type[1] as {type[2]}}" + name: "ldff1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - crate::intrinsics::simd::simd_cast @@ -2936,7 +2936,7 @@ intrinsics: test: { store: 0 } compose: - LLVMLink: - name: "st1.{sve_type}" + name: "st1.{sve_type}.p0" arguments: - "data: {sve_type}" - "pg: {predicate}" @@ -2965,7 +2965,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "st1.scatter.{type_kind[0].su}xtw.index.{sve_type[1]}" + name: "st1.scatter.{type_kind[0].su}xtw.index.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -2973,7 +2973,7 @@ intrinsics: - "indices: {sve_type[0]}" doubleword: LLVMLink: - name: "st1.scatter.index.{sve_type[1]}" + name: "st1.scatter.index.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -3003,7 +3003,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "st1.scatter.{type_kind[0].su}xtw.{sve_type[1]}" + name: "st1.scatter.{type_kind[0].su}xtw.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -3011,7 +3011,7 @@ intrinsics: - "offsets: {sve_type[0]}" doubleword: LLVMLink: - name: "st1.scatter.{sve_type[1]}" + name: "st1.scatter.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -3120,7 +3120,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "st1.scatter.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}" + name: "st1.scatter.{type_kind[0].su}xtw.index.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -3128,7 +3128,7 @@ intrinsics: - "indices: {sve_type[0]}" doubleword: LLVMLink: - name: "st1.scatter.index.{sve_type[1] as {type[2]}}" + name: "st1.scatter.index.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -3162,7 +3162,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "st1.scatter.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}" + name: "st1.scatter.{type_kind[0].su}xtw.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -3170,7 +3170,7 @@ intrinsics: - "offsets: {sve_type[0]}" doubleword: LLVMLink: - name: "st1.scatter.{sve_type[1] as {type[2]}}" + name: "st1.scatter.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -3273,7 +3273,7 @@ intrinsics: test: { store: 0 } compose: - LLVMLink: - name: "stnt1.{sve_type}" + name: "stnt1.{sve_type}.p0" arguments: - "data: {sve_type}" - "pg: {predicate}" @@ -3325,7 +3325,7 @@ intrinsics: test: { store: 1 } compose: - LLVMLink: - name: "st1.{sve_type[0] as {type[1]}}" + name: "st1.{sve_type[0] as {type[1]}}.p0" arguments: - "data: {sve_type[0] as {type[1]}}" - "pg: {predicate[0]}" @@ -3405,7 +3405,7 @@ intrinsics: test: { store: 0 } compose: - LLVMLink: - name: "st2.{sve_type}" + name: "st2.{sve_type}.p0" arguments: - "data0: {sve_type}" - "data1: {sve_type}" @@ -3458,7 +3458,7 @@ intrinsics: test: { store: 0 } compose: - LLVMLink: - name: "st3.{sve_type}" + name: "st3.{sve_type}.p0" arguments: - "data0: {sve_type}" - "data1: {sve_type}" @@ -3513,7 +3513,7 @@ intrinsics: test: { store: 0 } compose: - LLVMLink: - name: "st4.{sve_type}" + name: "st4.{sve_type}.p0" arguments: - "data0: {sve_type}" - "data1: {sve_type}" @@ -4028,7 +4028,7 @@ intrinsics: test: { load: 0 } compose: - LLVMLink: - name: "prf.{sve_type}" + name: "prf.{sve_type}.p0" arguments: ["pg: {predicate}", "base: *crate::ffi::c_void", "op: svprfop"] - FnCall: @@ -4099,7 +4099,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "prf{size_literal[1]}.gather.{type_kind[0].su}xtw.index.{sve_type[0]}" + name: "prf{size_literal[1]}.gather.{type_kind[0].su}xtw.index.p0.{sve_type[0]}" arguments: - "pg: {predicate[0]}" - "base: *crate::ffi::c_void" @@ -4107,7 +4107,7 @@ intrinsics: - "op: svprfop" doubleword: LLVMLink: - name: "prf{size_literal[1]}.gather.index.{sve_type[0]}" + name: "prf{size_literal[1]}.gather.index.p0.{sve_type[0]}" arguments: - "pg: {predicate[0]}" - "base: *crate::ffi::c_void" diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/sve2/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/sve2/aarch64.spec.yml index 269d7ff0eacbb..46379d470631e 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/sve2/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/sve2/aarch64.spec.yml @@ -804,7 +804,7 @@ intrinsics: assert_instr: ["ldnt1{size_literal[0]}"] test: { load: 1 } compose: - - LLVMLink: { name: "ldnt1.gather.index.{sve_type[1]}" } + - LLVMLink: { name: "ldnt1.gather.index.{sve_type[1]}.p0" } - name: svldnt1_gather_[{type[0]}]offset[_{type[1]}] attr: [*sve-unstable] @@ -826,9 +826,9 @@ intrinsics: - MatchSize: - "{type[0]}" - default: - LLVMLink: { name: "ldnt1.gather.uxtw.{sve_type[1]}" } + LLVMLink: { name: "ldnt1.gather.uxtw.{sve_type[1]}.p0" } doubleword: - LLVMLink: { name: "ldnt1.gather.{sve_type[1]}" } + LLVMLink: { name: "ldnt1.gather.{sve_type[1]}.p0" } - name: svldnt1_gather[_{type[0]}base]_offset_{type[1]} attr: [*sve-unstable] @@ -913,7 +913,7 @@ intrinsics: test: { load: 2 } compose: - LLVMLink: - name: "ldnt1.gather.index.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - "crate::intrinsics::simd::simd_cast" @@ -936,7 +936,7 @@ intrinsics: test: { load: 2 } compose: - LLVMLink: - name: "ldnt1.gather.index.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.index.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - "crate::intrinsics::simd::simd_cast" @@ -965,11 +965,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldnt1.gather.uxtw.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.uxtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldnt1.gather.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - "crate::intrinsics::simd::simd_cast" @@ -996,11 +996,11 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "ldnt1.gather.uxtw.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.uxtw.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" doubleword: LLVMLink: - name: "ldnt1.gather.{sve_type[1] as {type[2]}}" + name: "ldnt1.gather.{sve_type[1] as {type[2]}}.p0" return_type: "{sve_type[1] as {type[2]}}" - FnCall: - "crate::intrinsics::simd::simd_cast" @@ -1169,7 +1169,7 @@ intrinsics: test: { store: 1 } compose: - LLVMLink: - name: "stnt1.scatter.index.{sve_type[1]}" + name: "stnt1.scatter.index.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -1200,7 +1200,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "stnt1.scatter.uxtw.{sve_type[1]}" + name: "stnt1.scatter.uxtw.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -1208,7 +1208,7 @@ intrinsics: - "offsets: {sve_type[0]}" doubleword: LLVMLink: - name: "stnt1.scatter.{sve_type[1]}" + name: "stnt1.scatter.{sve_type[1]}.p0" arguments: - "data: {sve_type[1]}" - "pg: {predicate[0]}" @@ -1316,7 +1316,7 @@ intrinsics: test: { store: 2 } compose: - LLVMLink: - name: "stnt1.scatter.index.{sve_type[1] as {type[2]}}" + name: "stnt1.scatter.index.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -1351,7 +1351,7 @@ intrinsics: - "{type[0]}" - default: LLVMLink: - name: "stnt1.scatter.uxtw.{sve_type[1] as {type[2]}}" + name: "stnt1.scatter.uxtw.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" @@ -1359,7 +1359,7 @@ intrinsics: - "offsets: {sve_type[0]}" doubleword: LLVMLink: - name: "stnt1.scatter.{sve_type[1] as {type[2]}}" + name: "stnt1.scatter.{sve_type[1] as {type[2]}}.p0" arguments: - "data: {sve_type[1] as {type[2]}}" - "pg: {predicate[0]}" diff --git a/library/stdarch/crates/stdarch-gen-arm/src/fn_suffix.rs b/library/stdarch/crates/stdarch-gen-arm/src/fn_suffix.rs index 6fba3dc74476e..3b27b533b0c97 100644 --- a/library/stdarch/crates/stdarch-gen-arm/src/fn_suffix.rs +++ b/library/stdarch/crates/stdarch-gen-arm/src/fn_suffix.rs @@ -44,7 +44,7 @@ pub fn type_to_size(str_type: &str) -> i32 { "int8x8_t" | "int8x16_t" | "i8" | "s8" | "uint8x8_t" | "uint8x16_t" | "u8" | "poly8x8_t" | "poly8x16_t" => 8, "int16x4_t" | "int16x8_t" | "i16" | "s16" | "uint16x4_t" | "uint16x8_t" | "u16" - | "float16x4_t" | "float16x8_t" | "_f16" | "poly16x4_t" | "poly16x8_t" => 16, + | "_bf16" | "float16x4_t" | "float16x8_t" | "_f16" | "poly16x4_t" | "poly16x8_t" => 16, "int32x2_t" | "int32x4_t" | "i32" | "s32" | "uint32x2_t" | "uint32x4_t" | "u32" | "float32x2_t" | "float32x4_t" | "f32" => 32, "int64x1_t" | "int64x2_t" | "i64" | "s64" | "uint64x1_t" | "uint64x2_t" | "u64" @@ -54,9 +54,17 @@ pub fn type_to_size(str_type: &str) -> i32 { } } +fn is_bfloat(ty: &VectorType) -> bool { + match ty.base_type() { + BaseType::Sized(BaseTypeKind::BFloat, _) => true, + _ => false, + } +} + fn neon_get_base_and_char(ty: &VectorType) -> (u32, char, bool) { let lanes = ty.lanes(); match ty.base_type() { + BaseType::Sized(BaseTypeKind::BFloat, size) => (*size, 'b', *size * lanes == 128), BaseType::Sized(BaseTypeKind::Float, size) => (*size, 'f', *size * lanes == 128), BaseType::Sized(BaseTypeKind::Int, size) => (*size, 's', *size * lanes == 128), BaseType::Sized(BaseTypeKind::UInt, size) => (*size, 'u', *size * lanes == 128), @@ -73,11 +81,16 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String TypeKind::Vector(ty) => { let tuple_size = ty.tuple_size().map_or(0, |t| t.to_int()); let (base_size, prefix_char, requires_q) = neon_get_base_and_char(&ty); + let prefix_str = if is_bfloat(&ty) { + String::from("bf") + } else { + String::from(prefix_char) + }; let prefix_q = if requires_q { "q" } else { "" }; let lanes = ty.lanes(); match suffix_kind { SuffixKind::Normal => { - let mut str_suffix: String = format!("{prefix_q}_{prefix_char}{base_size}"); + let mut str_suffix: String = format!("{prefix_q}_{prefix_str}{base_size}"); if tuple_size > 0 { str_suffix.push_str("_x"); str_suffix.push_str(tuple_size.to_string().as_str()); @@ -85,11 +98,11 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String str_suffix } SuffixKind::NSuffix => { - format!("{prefix_q}_n_{prefix_char}{base_size}") + format!("{prefix_q}_n_{prefix_str}{base_size}") } - SuffixKind::NoQ => format!("_{prefix_char}{base_size}"), - SuffixKind::NoQNSuffix => format!("_n{prefix_char}{base_size}"), + SuffixKind::NoQ => format!("_{prefix_str}{base_size}"), + SuffixKind::NoQNSuffix => format!("_n{prefix_str}{base_size}"), SuffixKind::Unsigned => { let t = type_kind.to_string(); @@ -114,10 +127,10 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String } SuffixKind::Base => base_size.to_string(), SuffixKind::NoX => { - format!("{prefix_q}_{prefix_char}{base_size}") + format!("{prefix_q}_{prefix_str}{base_size}") } SuffixKind::Dup => { - let mut str_suffix: String = format!("{prefix_q}_dup_{prefix_char}{base_size}"); + let mut str_suffix: String = format!("{prefix_q}_dup_{prefix_str}{base_size}"); if tuple_size > 0 { str_suffix.push_str("_x"); str_suffix.push_str(tuple_size.to_string().as_str()); @@ -125,40 +138,40 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String str_suffix } SuffixKind::DupNox => { - format!("{prefix_q}_dup_{prefix_char}{base_size}") + format!("{prefix_q}_dup_{prefix_str}{base_size}") } SuffixKind::LaneNoX => { - format!("{prefix_q}_lane_{prefix_char}{base_size}") + format!("{prefix_q}_lane_{prefix_str}{base_size}") } SuffixKind::LaneQNoX => { - format!("{prefix_q}_laneq_{prefix_char}{base_size}") + format!("{prefix_q}_laneq_{prefix_str}{base_size}") } SuffixKind::Rot270 => { - format!("{prefix_q}_rot270_{prefix_char}{base_size}") + format!("{prefix_q}_rot270_{prefix_str}{base_size}") } SuffixKind::Rot270Lane => { - format!("{prefix_q}_rot270_lane_{prefix_char}{base_size}") + format!("{prefix_q}_rot270_lane_{prefix_str}{base_size}") } SuffixKind::Rot270LaneQ => { - format!("{prefix_q}_rot270_laneq_{prefix_char}{base_size}") + format!("{prefix_q}_rot270_laneq_{prefix_str}{base_size}") } SuffixKind::Rot180 => { - format!("{prefix_q}_rot180_{prefix_char}{base_size}") + format!("{prefix_q}_rot180_{prefix_str}{base_size}") } SuffixKind::Rot180Lane => { - format!("{prefix_q}_rot180_lane_{prefix_char}{base_size}") + format!("{prefix_q}_rot180_lane_{prefix_str}{base_size}") } SuffixKind::Rot180LaneQ => { - format!("{prefix_q}_rot180_laneq_{prefix_char}{base_size}") + format!("{prefix_q}_rot180_laneq_{prefix_str}{base_size}") } SuffixKind::Rot90 => { - format!("{prefix_q}_rot90_{prefix_char}{base_size}") + format!("{prefix_q}_rot90_{prefix_str}{base_size}") } SuffixKind::Rot90Lane => { - format!("{prefix_q}_rot90_lane_{prefix_char}{base_size}") + format!("{prefix_q}_rot90_lane_{prefix_str}{base_size}") } SuffixKind::Rot90LaneQ => { - format!("{prefix_q}_rot90_laneq_{prefix_char}{base_size}") + format!("{prefix_q}_rot90_laneq_{prefix_str}{base_size}") } SuffixKind::BaseByteSize => format!("{}", base_size / 8), } diff --git a/library/stdarch/crates/stdarch-gen-arm/src/typekinds.rs b/library/stdarch/crates/stdarch-gen-arm/src/typekinds.rs index c3aa22294d9fc..f833cb3d5d207 100644 --- a/library/stdarch/crates/stdarch-gen-arm/src/typekinds.rs +++ b/library/stdarch/crates/stdarch-gen-arm/src/typekinds.rs @@ -77,7 +77,7 @@ impl TypeKindOptions { BaseTypeKind::Int => self.s, BaseTypeKind::UInt => self.u, BaseTypeKind::Poly => self.p, - BaseTypeKind::Bool => false, + BaseTypeKind::BFloat | BaseTypeKind::Bool => false, } } } @@ -113,6 +113,7 @@ impl fmt::Display for TypeKindOptions { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum BaseTypeKind { Float, + BFloat, Int, UInt, Bool, @@ -497,7 +498,7 @@ impl FromStr for VectorType { fn from_str(s: &str) -> Result { static RE: LazyLock = LazyLock::new(|| { - Regex::new(r"^(?:(?:sv(?P(?:uint|int|bool|float)(?:\d+)?))|(?:(?P(?:uint|int|bool|poly|float)(?:\d+)?)x(?P(?:\d+)?)))(?:x(?P2|3|4))?_t$").unwrap() + Regex::new(r"^(?:(?:sv(?P(?:uint|int|bool|float|bfloat)(?:\d+)?))|(?:(?P(?:uint|int|bool|poly|float|bfloat)(?:\d+)?)x(?P(?:\d+)?)))(?:x(?P2|3|4))?_t$").unwrap() }); if let Some(c) = RE.captures(s) { @@ -634,6 +635,7 @@ impl FromStr for BaseTypeKind { fn from_str(s: &str) -> Result { match s { "float" | "f" => Ok(Self::Float), + "bfloat" | "bf16" => Ok(Self::BFloat), "int" | "i" => Ok(Self::Int), "uint" | "u" => Ok(Self::UInt), "poly" | "p" => Ok(Self::Poly), @@ -647,9 +649,14 @@ impl ToRepr for BaseTypeKind { fn repr(&self, repr: TypeRepr) -> String { match (repr, self) { (TypeRepr::C, Self::Float) => "float", + (TypeRepr::C, Self::BFloat) => "bfloat16", (TypeRepr::C, Self::Int) => "int", (TypeRepr::C, Self::UInt) => "uint", (TypeRepr::C, Self::Poly) => "poly", + + (TypeRepr::Rust, Self::BFloat) => "bfloat16_t", + (TypeRepr::LLVMMachine | TypeRepr::ACLENotation, Self::BFloat) => "bf16", + (TypeRepr::Rust | TypeRepr::LLVMMachine | TypeRepr::ACLENotation, Self::Float) => "f", (TypeRepr::Rust, Self::Int) | (TypeRepr::LLVMMachine, Self::Int | Self::UInt) => "i", (TypeRepr::Rust | TypeRepr::ACLENotation, Self::UInt) => "u", @@ -692,6 +699,10 @@ impl BaseType { pub fn is_float(&self) -> bool { self.kind() == &BaseTypeKind::Float } + + pub fn is_bfloat(&self) -> bool { + self.kind() == &BaseTypeKind::BFloat + } } impl FromStr for BaseType { @@ -709,6 +720,13 @@ impl FromStr for BaseType { .map(u32::from_str) .transpose() .unwrap(); + + if kind == BaseTypeKind::BFloat && size != Some(16) { + return Err(format!( + "a `bfloat` must have a size of `16`, got `{size:?}`" + )); + } + match size { Some(size) => Ok(Self::Sized(kind, size)), None => Ok(Self::Unsized(kind)), @@ -733,6 +751,7 @@ impl ToRepr for BaseType { (Sized(_, size), SizeLiteral) if *size == 128 => "q".to_string(), (_, SizeLiteral) => unreachable!("cannot represent {self:#?} as size literal"), (Sized(Float, _) | Unsized(Float), TypeKind) => "f".to_string(), + (Sized(BFloat, _) | Unsized(BFloat), TypeKind) => "bf16".to_string(), (Sized(Int, _) | Unsized(Int), TypeKind) => "s".to_string(), (Sized(UInt, _) | Unsized(UInt), TypeKind) => "u".to_string(), (Sized(_, size), Size) => size.to_string(), @@ -740,7 +759,14 @@ impl ToRepr for BaseType { assert!(size.is_power_of_two() && *size >= 8); (size >> 3).trailing_zeros().to_string() } - (Sized(kind, size), _) => format!("{}{size}", kind.repr(repr)), + (Sized(kind, size), _) => { + if self.is_bfloat() { + assert!(*size == 16); + format!("{}", kind.repr(repr)) + } else { + format!("{}{size}", kind.repr(repr)) + } + } (Unsized(kind), _) => kind.repr(repr), } } diff --git a/library/stdarch/crates/stdarch-gen-hexagon/src/scalar.rs b/library/stdarch/crates/stdarch-gen-hexagon/src/scalar.rs index 8c7880b58a023..a8da2da5736c6 100644 --- a/library/stdarch/crates/stdarch-gen-hexagon/src/scalar.rs +++ b/library/stdarch/crates/stdarch-gen-hexagon/src/scalar.rs @@ -521,17 +521,6 @@ fn generate_functions(intrinsics: &[ScalarIntrinsic]) -> String { output.push_str("#[inline(always)]\n"); } - // Immediate parameters become const generics but are passed as positional - // arguments at the call site: Q6_R_add_RI(rs, 42) rather than Q6_R_add_RI::<42>(rs). - // This matches the assembly syntax where the immediate is an operand. - if !imm_params.is_empty() { - let indices: Vec = imm_params.iter().map(|(i, _, _)| i.to_string()).collect(); - output.push_str(&format!( - "#[rustc_legacy_const_generics({})]\n", - indices.join(", ") - )); - } - if let Some(instr) = extract_instr_name(&info.asm_syntax) { if imm_params.is_empty() { output.push_str(&format!("#[cfg_attr(test, assert_instr({}))]\n", instr)); diff --git a/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec b/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec index 63895945948f8..8c76696055248 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec +++ b/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec @@ -1708,21 +1708,25 @@ asm-fmts = xd, xj data-types = V4DI, V4DI /// lasx_xvclo_b +impl = portable name = lasx_xvclo_b asm-fmts = xd, xj data-types = V32QI, V32QI /// lasx_xvclo_h +impl = portable name = lasx_xvclo_h asm-fmts = xd, xj data-types = V16HI, V16HI /// lasx_xvclo_w +impl = portable name = lasx_xvclo_w asm-fmts = xd, xj data-types = V8SI, V8SI /// lasx_xvclo_d +impl = portable name = lasx_xvclo_d asm-fmts = xd, xj data-types = V4DI, V4DI diff --git a/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec b/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec index e1fb72c7901c9..1ac70cbe15a99 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec +++ b/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec @@ -1723,21 +1723,25 @@ asm-fmts = vd, vj data-types = V2DI, V2DI /// lsx_vclo_b +impl = portable name = lsx_vclo_b asm-fmts = vd, vj data-types = V16QI, V16QI /// lsx_vclo_h +impl = portable name = lsx_vclo_h asm-fmts = vd, vj data-types = V8HI, V8HI /// lsx_vclo_w +impl = portable name = lsx_vclo_w asm-fmts = vd, vj data-types = V4SI, V4SI /// lsx_vclo_d +impl = portable name = lsx_vclo_d asm-fmts = vd, vj data-types = V2DI, V2DI diff --git a/library/stdarch/crates/stdarch-gen-loongarch/src/main.rs b/library/stdarch/crates/stdarch-gen-loongarch/src/main.rs index 02ebf6ffe10a5..97b7d94e6a625 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/src/main.rs +++ b/library/stdarch/crates/stdarch-gen-loongarch/src/main.rs @@ -607,7 +607,7 @@ fn gen_bind_body( let function = format!( r#" #[inline]{target_feature} -#[stable(feature = "stdarch_loongarch_simd", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "stdarch_loongarch_simd", since = "1.101.0")] {fn_decl}{{ {call_params} }} diff --git a/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt b/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt index 4005385b75198..53afc395a4c8e 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt +++ b/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt @@ -131,6 +131,10 @@ lsx_vclz_b lsx_vclz_h lsx_vclz_w lsx_vclz_d +lsx_vclo_b +lsx_vclo_h +lsx_vclo_w +lsx_vclo_d lsx_vreplgr2vr_b lsx_vreplgr2vr_h lsx_vreplgr2vr_w @@ -430,6 +434,10 @@ lasx_xvclz_b lasx_xvclz_h lasx_xvclz_w lasx_xvclz_d +lasx_xvclo_b +lasx_xvclo_h +lasx_xvclo_w +lasx_xvclo_d lasx_xvreplgr2vr_b lasx_xvreplgr2vr_h lasx_xvreplgr2vr_w diff --git a/library/stdarch/crates/stdarch-test/src/lib.rs b/library/stdarch/crates/stdarch-test/src/lib.rs index 9ef25a7957c1d..2075e9d820ff4 100644 --- a/library/stdarch/crates/stdarch-test/src/lib.rs +++ b/library/stdarch/crates/stdarch-test/src/lib.rs @@ -54,7 +54,7 @@ impl hash::Hash for Function { /// /// This asserts that the function at `fnptr` contains the instruction /// `expected` provided. -pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { +pub fn assert(shim_addr: usize, fnname: &str, expected: &str, not: &[&str], limit: Option) { // Make sure that the shim is not removed black_box(shim_addr); @@ -100,6 +100,12 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { // && !instruction[expected.len()..].starts_with(|c: char| c.is_ascii_alphanumeric()) }); + let found_bad = not + .iter() + // We deliberately only check `sarts_with` here, so one can exclude a bunch of related + // instructions at once. + .find(|not| instrs.iter().any(|instr| instr.starts_with(**not))); + // Look for subroutine call instructions in the disassembly to detect whether // inlining failed: all intrinsics are `#[inline(always)]`, so calling one // intrinsic from another should not generate subroutine call instructions. @@ -127,71 +133,70 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { let instruction_limit = std::env::var("STDARCH_ASSERT_INSTR_LIMIT") .ok() - .map_or_else( - || match expected { - // `cpuid` returns a pretty big aggregate structure, so exempt - // it from the slightly more restrictive 22 instructions below. - "cpuid" => 30, - - // These require 8 loads and stores, so it _just_ overflows the limit - "aesencwide128kl" | "aesencwide256kl" | "aesdecwide128kl" | "aesdecwide256kl" => 24, - - // Apparently, on Windows, LLVM generates a bunch of - // saves/restores of xmm registers around these instructions, - // which exceeds the limit of 20 below. As it seems dictated by - // Windows's ABI (I believe?), we probably can't do much - // about it. - "vzeroall" | "vzeroupper" if cfg!(windows) => 30, - - // Intrinsics using `cvtpi2ps` are typically "composites" and - // in some cases exceed the limit. - "cvtpi2ps" => 25, - // core_arch/src/arm_shared/simd32 - // vfmaq_n_f32_vfma : #instructions = 26 >= 22 (limit) - "usad8" | "vfma" | "vfms" => 27, - "qadd8" | "qsub8" | "sadd8" | "sel" | "shadd8" | "shsub8" | "usub8" | "ssub8" => 29, - // core_arch/src/arm_shared/simd32 - // vst1q_s64_x4_vst1 : #instructions = 27 >= 22 (limit) - "vld3" => 28, - // core_arch/src/arm_shared/simd32 - // vld4q_lane_u32_vld4 : #instructions = 36 >= 22 (limit) - "vld4" => 37, - // core_arch/src/arm_shared/simd32 - // vst1q_s64_x4_vst1 : #instructions = 40 >= 22 (limit) - "vst1" => 41, - // core_arch/src/arm_shared/simd32 - // vst3q_u32_vst3 : #instructions = 25 >= 22 (limit) - "vst3" => 26, - // core_arch/src/arm_shared/simd32 - // vst4q_u32_vst4 : #instructions = 33 >= 22 (limit) - "vst4" => 34, - - // core_arch/src/arm_shared/simd32 - // vst1q_p64_x4_nop : #instructions = 33 >= 22 (limit) - "nop" if fnname.contains("vst1q_p64") => 34, - - // AMX intrinsics generate a lot of move instructions to load/store the tile registers - // due to Rust ABI - _ if fnname.contains("___tile") => 165, - - // Original limit was 20 instructions, but ARM DSP Intrinsics - // are exactly 20 instructions long. So, bump the limit to 22 - // instead of adding here a long list of exceptions. - _ => { - // aarch64_be may add reverse instructions which increases - // the number of instructions generated. - if cfg!(all(target_endian = "big", target_arch = "aarch64")) { - 32 - } else { - 22 - } + .map(|v| v.parse().unwrap()) + .or(limit.map(|n| n + 1)) // adjust for the `<` below: `limit = 2` means 2 instructions is okay + .unwrap_or_else(|| match expected { + // `cpuid` returns a pretty big aggregate structure, so exempt + // it from the slightly more restrictive 22 instructions below. + "cpuid" => 30, + + // These require 8 loads and stores, so it _just_ overflows the limit + "aesencwide128kl" | "aesencwide256kl" | "aesdecwide128kl" | "aesdecwide256kl" => 24, + + // Apparently, on Windows, LLVM generates a bunch of + // saves/restores of xmm registers around these instructions, + // which exceeds the limit of 20 below. As it seems dictated by + // Windows's ABI (I believe?), we probably can't do much + // about it. + "vzeroall" | "vzeroupper" if cfg!(windows) => 30, + + // Intrinsics using `cvtpi2ps` are typically "composites" and + // in some cases exceed the limit. + "cvtpi2ps" => 25, + // core_arch/src/arm_shared/simd32 + // vfmaq_n_f32_vfma : #instructions = 26 >= 22 (limit) + "usad8" | "vfma" | "vfms" => 27, + "qadd8" | "qsub8" | "sadd8" | "sel" | "shadd8" | "shsub8" | "usub8" | "ssub8" => 29, + // core_arch/src/arm_shared/simd32 + // vst1q_s64_x4_vst1 : #instructions = 27 >= 22 (limit) + "vld3" => 28, + // core_arch/src/arm_shared/simd32 + // vld4q_lane_u32_vld4 : #instructions = 36 >= 22 (limit) + "vld4" => 37, + // core_arch/src/arm_shared/simd32 + // vst1q_s64_x4_vst1 : #instructions = 40 >= 22 (limit) + "vst1" => 41, + // core_arch/src/arm_shared/simd32 + // vst3q_u32_vst3 : #instructions = 25 >= 22 (limit) + "vst3" => 26, + // core_arch/src/arm_shared/simd32 + // vst4q_u32_vst4 : #instructions = 33 >= 22 (limit) + "vst4" => 34, + + // core_arch/src/arm_shared/simd32 + // vst1q_p64_x4_nop : #instructions = 33 >= 22 (limit) + "nop" if fnname.contains("vst1q_p64") => 34, + + // AMX intrinsics generate a lot of move instructions to load/store the tile registers + // due to Rust ABI + _ if fnname.contains("___tile") => 165, + + // Original limit was 20 instructions, but ARM DSP Intrinsics + // are exactly 20 instructions long. So, bump the limit to 22 + // instead of adding here a long list of exceptions. + _ => { + // aarch64_be may add reverse instructions which increases + // the number of instructions generated. + if cfg!(all(target_endian = "big", target_arch = "aarch64")) { + 32 + } else { + 22 } - }, - |v| v.parse().unwrap(), - ); + } + }); let probably_only_one_instruction = instrs.len() < instruction_limit; - if found && probably_only_one_instruction && !inlining_failed { + if found && found_bad.is_none() && probably_only_one_instruction && !inlining_failed { return; } @@ -204,6 +209,8 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { if !found { panic!("failed to find instruction `{expected}` in the disassembly"); + } else if let Some(bad) = found_bad { + panic!("instruction found, but the disassembly also contains the bad instructions `{bad}`"); } else if !probably_only_one_instruction { panic!( "instruction found, but the disassembly contains too many \ diff --git a/library/stdarch/crates/stdarch-verify/Cargo.toml b/library/stdarch/crates/stdarch-verify/Cargo.toml index c82a1262d04fc..ca921fd8a3cda 100644 --- a/library/stdarch/crates/stdarch-verify/Cargo.toml +++ b/library/stdarch/crates/stdarch-verify/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = { version = "2.0", features = ["full"] } +syn = { version = "3.0", features = ["full"] } [lib] proc-macro = true diff --git a/library/stdarch/crates/stdarch-verify/src/lib.rs b/library/stdarch/crates/stdarch-verify/src/lib.rs index 5412ab466ad58..2167ebbd9979d 100644 --- a/library/stdarch/crates/stdarch-verify/src/lib.rs +++ b/library/stdarch/crates/stdarch-verify/src/lib.rs @@ -110,37 +110,21 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream { quote! { None } }; - let required_const = find_required_const("rustc_args_required_const", &f.attrs); - let mut legacy_const_generics = - find_required_const("rustc_legacy_const_generics", &f.attrs); - if !required_const.is_empty() && !legacy_const_generics.is_empty() { - panic!( - "Can't have both #[rustc_args_required_const] and \ - #[rustc_legacy_const_generics]" - ); - } + let mut legacy_const_generics = find_legacy_const_generics(&f.attrs); // Newer intrinsics don't have `rustc_legacy_const_generics` - assume they belong at // the end of the argument list - if required_const.is_empty() && legacy_const_generics.is_empty() { + if legacy_const_generics.is_empty() { legacy_const_generics = (arguments.len()..(arguments.len() + const_arguments.len())).collect(); } - // The list of required consts, used to verify the arguments, comes from either the - // `rustc_args_required_const` or the `rustc_legacy_const_generics` attribute. - let required_const = if required_const.is_empty() { - legacy_const_generics.clone() - } else { - required_const - }; - legacy_const_generics.sort(); for (idx, ty) in legacy_const_generics - .into_iter() + .iter() .zip(const_arguments.into_iter()) { - arguments.insert(idx, ty); + arguments.insert(*idx, ty); } // Strip leading underscore from fn name when building a test @@ -162,7 +146,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream { target_feature: #target_feature, instrs: &[#(#instrs),*], file: stringify!(#path), - required_const: &[#(#required_const),*], + legacy_const_generics: &[#(#legacy_const_generics),*], has_test: #has_test, doc: #doc } @@ -205,6 +189,7 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { "__tile1024i" => quote! { &TILE1024I }, "bool" => quote! { &BOOL }, "bf16" => quote! { &BF16 }, + "f16b" | "bfloat16_t" => quote! { &BF16 }, "f16" => quote! { &F16 }, "f32" => quote! { &F32 }, "f64" => quote! { &F64 }, @@ -292,6 +277,14 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { "uint64x2x3_t" => quote! { &U64X2X3 }, "uint64x2x4_t" => quote! { &U64X2X4 }, "float16x2_t" => quote! { &F16X2 }, + "bfloat16x4_t" => quote! { &BF16X4 }, + "bfloat16x4x2_t" => quote! { &BF16X4X2 }, + "bfloat16x4x3_t" => quote! { &BF16X4X3 }, + "bfloat16x4x4_t" => quote! { &BF16X4X4 }, + "bfloat16x8_t" => quote! { &BF16X8 }, + "bfloat16x8x2_t" => quote! { &BF16X8X2 }, + "bfloat16x8x3_t" => quote! { &BF16X8X3 }, + "bfloat16x8x4_t" => quote! { &BF16X8X4 }, "float16x4_t" => quote! { &F16X4 }, "float16x4x2_t" => quote! { &F16X4X2 }, "float16x4x3_t" => quote! { &F16X4X3 }, @@ -407,23 +400,32 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { }, syn::Type::Ptr(syn::TypePtr { ref elem, - ref mutability, + mutability: syn::PointerMutability::Mut(_), .. }) | syn::Type::Reference(syn::TypeReference { ref elem, - ref mutability, + mutability: Some(_), .. }) => { - // Both pointers and references can have a mut token (*mut and &mut) - if mutability.is_some() { - let tokens = to_type(elem); - quote! { &Type::MutPtr(#tokens) } - } else { - // If they don't (*const or &) then they are "const" - let tokens = to_type(elem); - quote! { &Type::ConstPtr(#tokens) } - } + // // Both pointers and references can have a mut token (*mut and &mut) + let tokens = to_type(elem); + quote! { &Type::MutPtr(#tokens) } + } + + syn::Type::Ptr(syn::TypePtr { + ref elem, + mutability: syn::PointerMutability::Const(_), + .. + }) + | syn::Type::Reference(syn::TypeReference { + ref elem, + mutability: None, + .. + }) => { + // If they don't (*const or &) then they are "const" + let tokens = to_type(elem); + quote! { &Type::ConstPtr(#tokens) } } syn::Type::Slice(_) => panic!("unsupported slice"), @@ -596,7 +598,7 @@ fn find_doc(attrs: &[syn::Attribute]) -> String { .collect() } -fn find_required_const(name: &str, attrs: &[syn::Attribute]) -> Vec { +fn find_legacy_const_generics(attrs: &[syn::Attribute]) -> Vec { attrs .iter() .filter_map(|a| { @@ -607,7 +609,7 @@ fn find_required_const(name: &str, attrs: &[syn::Attribute]) -> Vec { } }) .flat_map(|l| { - if l.path.segments[0].ident == name { + if l.path.segments[0].ident == "rustc_legacy_const_generics" { syn::parse2::(l.tokens.clone()) .unwrap() .args diff --git a/library/stdarch/crates/stdarch-verify/tests/arm.rs b/library/stdarch/crates/stdarch-verify/tests/arm.rs index 6ba9c17c4804c..1ff89d00db14c 100644 --- a/library/stdarch/crates/stdarch-verify/tests/arm.rs +++ b/library/stdarch/crates/stdarch-verify/tests/arm.rs @@ -11,12 +11,13 @@ struct Function { target_feature: Option<&'static str>, instrs: &'static [&'static str], file: &'static str, - required_const: &'static [usize], + legacy_const_generics: &'static [usize], has_test: bool, doc: &'static str, } static BOOL: Type = Type::PrimBool; +static BF16: Type = Type::BFloat16; static F16: Type = Type::PrimFloat(16); static F32: Type = Type::PrimFloat(32); static F64: Type = Type::PrimFloat(64); @@ -34,6 +35,14 @@ static GENERICT: Type = Type::GenericParam("T"); static GENERICU: Type = Type::GenericParam("U"); static F16X4: Type = Type::F(16, 4, 1); +static BF16X4: Type = Type::BF(4, 1); +static BF16X4X2: Type = Type::BF(4, 2); +static BF16X4X3: Type = Type::BF(4, 3); +static BF16X4X4: Type = Type::BF(4, 4); +static BF16X8: Type = Type::BF(8, 1); +static BF16X8X2: Type = Type::BF(8, 2); +static BF16X8X3: Type = Type::BF(8, 3); +static BF16X8X4: Type = Type::BF(8, 4); static F16X4X2: Type = Type::F(16, 4, 2); static F16X4X3: Type = Type::F(16, 4, 3); static F16X4X4: Type = Type::F(16, 4, 4); @@ -209,6 +218,7 @@ static SVPATTERN: Type = Type::Enum("svpattern"); enum Type { Void, PrimBool, + BFloat16, PrimFloat(u8), PrimSigned(u8), PrimUnsigned(u8), @@ -221,6 +231,7 @@ enum Type { U(u8, u8, u8), P(u8, u8, u8), F(u8, u8, u8), + BF(u8, u8), Pred(u8), SVI(u8, u8), SVU(u8, u8), @@ -276,6 +287,10 @@ fn verify_all_signatures() { "vreinterpretq_p64_p128", "vreinterpretq_p128_p64", "vreinterpretq_f32_p128", + "vreinterpret_bf16_f16", + "vreinterpret_f16_bf16", + "vreinterpretq_bf16_f16", + "vreinterpretq_f16_bf16", "vtst_p16", "vtstq_p16", "__dbg", @@ -333,7 +348,9 @@ fn matches(rust: &Function, arm: &Intrinsic) -> Result<(), String> { // SVE uses generic type parameters to handle void pointers (Type::ConstPtr(Type::GenericParam("T")), Type::ConstPtr(Type::Void)) => (), // SVE const generics use i32 over u64 for usability reasons - (Type::PrimSigned(32), Type::PrimUnsigned(64)) if rust.required_const.contains(&i) => { + (Type::PrimSigned(32), Type::PrimUnsigned(64)) + if rust.legacy_const_generics.contains(&i) => + { () } // svset doesn't have its const argument last as we assumed when building the Function @@ -343,12 +360,12 @@ fn matches(rust: &Function, arm: &Intrinsic) -> Result<(), String> { } if *arm_const { nconst += 1; - if !rust.required_const.contains(&i) && !rust.name.starts_with("svset") { + if !rust.legacy_const_generics.contains(&i) && !rust.name.starts_with("svset") { bail!("argument const mismatch"); } } } - if nconst != rust.required_const.len() { + if nconst != rust.legacy_const_generics.len() { bail!("wrong number of const arguments"); } @@ -489,6 +506,15 @@ fn parse_ty_base(s: &str) -> &'static Type { match s { "bool" => &BOOL, "void" => &VOID, + "bfloat16_t" => &BF16, + "bfloat16x4_t" => &BF16X4, + "bfloat16x4x2_t" => &BF16X4X2, + "bfloat16x4x3_t" => &BF16X4X3, + "bfloat16x4x4_t" => &BF16X4X4, + "bfloat16x8_t" => &BF16X8, + "bfloat16x8x2_t" => &BF16X8X2, + "bfloat16x8x3_t" => &BF16X8X3, + "bfloat16x8x4_t" => &BF16X8X4, "float16_t" => &F16, "float16x4_t" => &F16X4, "float16x4x2_t" => &F16X4X2, @@ -683,6 +709,163 @@ static SKIP_ASSERT_INSTR_TESTS: &'static [&'static str] = &["svpfalse_b"]; // are no longer being added and just adding to this list indefinitely isn't the best solution for // dealing with that. static SKIP_RUNTIME_TESTS: &'static [&'static str] = &[ + "vbfdot_f32", + "vbfdot_lane_f32", + "vbfdot_laneq_f32", + "vbfdotq_f32", + "vbfdotq_lane_f32", + "vbfdotq_laneq_f32", + "vbfmlalbq_f32", + "vbfmlalbq_lane_f32", + "vbfmlalbq_laneq_f32", + "vbfmlaltq_f32", + "vbfmlaltq_lane_f32", + "vbfmlaltq_laneq_f32", + "vbfmmlaq_f32", + "vcombine_bf16", + "vcopy_lane_bf16", + "vcopy_laneq_bf16", + "vcopyq_lane_bf16", + "vcopyq_laneq_bf16", + "vcreate_bf16", + "vcvt_bf16_f32", + "vcvt_f32_bf16", + "vcvtah_f32_bf16", + "vcvth_bf16_f32", + "vcvtq_high_bf16_f32", + "vcvtq_high_f32_bf16", + "vcvtq_low_bf16_f32", + "vcvtq_low_f32_bf16", + "vdup_lane_bf16", + "vdup_laneq_bf16", + "vdup_n_bf16", + "vduph_lane_bf16", + "vduph_laneq_bf16", + "vdupq_lane_bf16", + "vdupq_laneq_bf16", + "vdupq_n_bf16", + "vget_high_bf16", + "vget_lane_bf16", + "vget_low_bf16", + "vgetq_lane_bf16", + "vld1_bf16", + "vld1_bf16_x2", + "vld1_bf16_x3", + "vld1_bf16_x4", + "vld1_dup_bf16", + "vld1_lane_bf16", + "vld1q_bf16", + "vld1q_bf16_x2", + "vld1q_bf16_x3", + "vld1q_bf16_x4", + "vld1q_dup_bf16", + "vld1q_lane_bf16", + "vld2_bf16", + "vld2_dup_bf16", + "vld2_lane_bf16", + "vld2q_bf16", + "vld2q_dup_bf16", + "vld2q_lane_bf16", + "vld3_bf16", + "vld3_dup_bf16", + "vld3_lane_bf16", + "vld3q_bf16", + "vld3q_dup_bf16", + "vld3q_lane_bf16", + "vld4_bf16", + "vld4_dup_bf16", + "vld4_lane_bf16", + "vld4q_bf16", + "vld4q_dup_bf16", + "vld4q_lane_bf16", + "vluti2_lane_bf16", + "vluti2_laneq_bf16", + "vluti2q_lane_bf16", + "vluti2q_laneq_bf16", + "vluti4q_lane_bf16_x2", + "vluti4q_laneq_bf16_x2", + "vreinterpret_bf16_f16", + "vreinterpret_bf16_f32", + "vreinterpret_bf16_f64", + "vreinterpret_bf16_p16", + "vreinterpret_bf16_p64", + "vreinterpret_bf16_p8", + "vreinterpret_bf16_s16", + "vreinterpret_bf16_s32", + "vreinterpret_bf16_s64", + "vreinterpret_bf16_s8", + "vreinterpret_bf16_u16", + "vreinterpret_bf16_u32", + "vreinterpret_bf16_u64", + "vreinterpret_bf16_u8", + "vreinterpret_f16_bf16", + "vreinterpret_f32_bf16", + "vreinterpret_f64_bf16", + "vreinterpret_p16_bf16", + "vreinterpret_p64_bf16", + "vreinterpret_p8_bf16", + "vreinterpret_s16_bf16", + "vreinterpret_s32_bf16", + "vreinterpret_s64_bf16", + "vreinterpret_s8_bf16", + "vreinterpret_u16_bf16", + "vreinterpret_u32_bf16", + "vreinterpret_u64_bf16", + "vreinterpret_u8_bf16", + "vreinterpretq_bf16_f16", + "vreinterpretq_bf16_f32", + "vreinterpretq_bf16_f64", + "vreinterpretq_bf16_p128", + "vreinterpretq_bf16_p16", + "vreinterpretq_bf16_p64", + "vreinterpretq_bf16_p8", + "vreinterpretq_bf16_s16", + "vreinterpretq_bf16_s32", + "vreinterpretq_bf16_s64", + "vreinterpretq_bf16_s8", + "vreinterpretq_bf16_u16", + "vreinterpretq_bf16_u32", + "vreinterpretq_bf16_u64", + "vreinterpretq_bf16_u8", + "vreinterpretq_f16_bf16", + "vreinterpretq_f32_bf16", + "vreinterpretq_f64_bf16", + "vreinterpretq_p128_bf16", + "vreinterpretq_p16_bf16", + "vreinterpretq_p64_bf16", + "vreinterpretq_p8_bf16", + "vreinterpretq_s16_bf16", + "vreinterpretq_s32_bf16", + "vreinterpretq_s64_bf16", + "vreinterpretq_s8_bf16", + "vreinterpretq_u16_bf16", + "vreinterpretq_u32_bf16", + "vreinterpretq_u64_bf16", + "vreinterpretq_u8_bf16", + "vset_lane_bf16", + "vsetq_lane_bf16", + "vst1_bf16", + "vst1_bf16_x2", + "vst1_bf16_x3", + "vst1_bf16_x4", + "vst1_lane_bf16", + "vst1q_bf16", + "vst1q_bf16_x2", + "vst1q_bf16_x3", + "vst1q_bf16_x4", + "vst1q_lane_bf16", + "vst2_bf16", + "vst2_lane_bf16", + "vst2q_bf16", + "vst2q_lane_bf16", + "vst3_bf16", + "vst3_lane_bf16", + "vst3q_bf16", + "vst3q_lane_bf16", + "vst4_bf16", + "vst4_lane_bf16", + "vst4q_bf16", + "vst4q_lane_bf16", "vaddq_s64", "vaddq_u64", "vrsqrte_f32", diff --git a/library/stdarch/crates/stdarch-verify/tests/mips.rs b/library/stdarch/crates/stdarch-verify/tests/mips.rs index ba639c3f92f76..504f362d2b3c5 100644 --- a/library/stdarch/crates/stdarch-verify/tests/mips.rs +++ b/library/stdarch/crates/stdarch-verify/tests/mips.rs @@ -14,7 +14,7 @@ struct Function { target_feature: Option<&'static str>, instrs: &'static [&'static str], file: &'static str, - required_const: &'static [usize], + legacy_const_generics: &'static [usize], has_test: bool, doc: &'static str, } @@ -94,6 +94,26 @@ enum MsaTy { MutVoidPtr, } +impl MsaTy { + fn is_const(&self) -> bool { + matches!( + self, + MsaTy::imm0_1 + | MsaTy::imm0_3 + | MsaTy::imm0_7 + | MsaTy::imm0_15 + | MsaTy::imm0_31 + | MsaTy::imm0_63 + | MsaTy::imm0_255 + | MsaTy::imm_n16_15 + | MsaTy::imm_n512_511 + | MsaTy::imm_n1024_1022 + | MsaTy::imm_n2048_2044 + | MsaTy::imm_n4096_4088 + ) + } +} + impl<'a> From<&'a str> for MsaTy { fn from(s: &'a str) -> MsaTy { match s { @@ -169,6 +189,11 @@ impl std::convert::TryFrom<&'static str> for MsaIntrinsic { arg_tys.push(MsaTy::from(arg)); } + // Some of the functions extracted from mips-msa.h have immediate arguments between non-immediate arguments, + // but Rust const generics are not function arguments and cannot be expressed in a way that matches the header. + // For the sake of verification, rust const generics are treated as "the last arguments to a function". + arg_tys.sort_by(|arg1, arg2| arg1.is_const().cmp(&arg2.is_const())); + // The instruction is the intrinsic name without the __msa_ prefix. let instruction = &id[6..]; let mut instruction = instruction.to_string(); @@ -261,6 +286,22 @@ fn verify_all_signatures() { assert!(all_valid); } +// Intrinsics for which LLVM does not emit the exact instruction that you'd +// expect based on the intrinsic name, but something equivalent. +static LLVM_SELECTS_SOMETHING_EQUIVALENT: &[(&str, &str)] = &[ + ("__msa_bclri_b", "andi.b"), + ("__msa_bmz_v", "bmnz.v"), + ("__msa_bmzi_b", "bmnzi.b"), + ("__msa_bsel_v", "bmnz.v"), + ("__msa_copy_u_d", "copy_s.d"), + ("__msa_ld_b", "ld.d"), + ("__msa_ld_h", "ld.d"), + ("__msa_ld_w", "ld.d"), + ("__msa_st_b", "st.d"), + ("__msa_st_h", "st.d"), + ("__msa_st_w", "st.d"), +]; + fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> { macro_rules! bail { ($($t:tt)*) => (return Err(format!($($t)*))) @@ -313,30 +354,15 @@ fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> { ), } - let is_const = matches!( - mips_arg, - MsaTy::imm0_1 - | MsaTy::imm0_3 - | MsaTy::imm0_7 - | MsaTy::imm0_15 - | MsaTy::imm0_31 - | MsaTy::imm0_63 - | MsaTy::imm0_255 - | MsaTy::imm_n16_15 - | MsaTy::imm_n512_511 - | MsaTy::imm_n1024_1022 - | MsaTy::imm_n2048_2044 - | MsaTy::imm_n4096_4088 - ); - if is_const { + if mips_arg.is_const() { nconst += 1; - if !rust.required_const.contains(&i) { + if !rust.legacy_const_generics.contains(&i) { bail!("argument const mismatch"); } } } - if nconst != rust.required_const.len() { + if nconst != rust.legacy_const_generics.len() { bail!("wrong number of const arguments"); } @@ -348,7 +374,9 @@ fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> { // Normalize slightly to get rid of assembler differences let actual = rust.instrs[0].replace('.', "_"); let expected = mips.instruction.replace('.', "_"); - if actual != expected { + if actual != expected + && !LLVM_SELECTS_SOMETHING_EQUIVALENT.contains(&(rust.name, rust.instrs[0])) + { bail!( "wrong instruction: \"{}\" != \"{}\"", rust.instrs[0], diff --git a/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs b/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs index d2839bb300c2d..fbc999780bf37 100644 --- a/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs +++ b/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs @@ -18,7 +18,7 @@ struct Function { target_feature: Option<&'static str>, instrs: &'static [&'static str], file: &'static str, - required_const: &'static [usize], + legacy_const_generics: &'static [usize], has_test: bool, doc: &'static str, } @@ -555,7 +555,7 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> { bail!("wrong number of arguments on {}", rust.name); } for (i, (a, b)) in intel.parameters.iter().zip(rust.arguments).enumerate() { - let is_const = rust.required_const.contains(&i); + let is_const = rust.legacy_const_generics.contains(&i); equate(b, &a.type_, &a.etype, &intel, is_const)?; } } diff --git a/library/stdarch/intrinsics_data/arm_intrinsics.json b/library/stdarch/intrinsics_data/arm_intrinsics.json index 7f749fe4d8842..171b042bc3e98 100644 --- a/library/stdarch/intrinsics_data/arm_intrinsics.json +++ b/library/stdarch/intrinsics_data/arm_intrinsics.json @@ -51174,15 +51174,15 @@ "svfloat16x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat16_t" - }, "Architectures": [ "A64" ] @@ -51194,15 +51194,15 @@ "svfloat32x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat32_t" - }, "Architectures": [ "A64" ] @@ -51214,15 +51214,15 @@ "svfloat64x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat64_t" - }, "Architectures": [ "A64" ] @@ -51234,15 +51234,15 @@ "svint16x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint16_t" - }, "Architectures": [ "A64" ] @@ -51254,15 +51254,15 @@ "svint32x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint32_t" - }, "Architectures": [ "A64" ] @@ -51274,15 +51274,15 @@ "svint64x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint64_t" - }, "Architectures": [ "A64" ] @@ -51294,15 +51294,15 @@ "svint8x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint8_t" - }, "Architectures": [ "A64" ] @@ -51314,15 +51314,15 @@ "svuint16x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint16_t" - }, "Architectures": [ "A64" ] @@ -51334,15 +51334,15 @@ "svuint32x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint32_t" - }, "Architectures": [ "A64" ] @@ -51354,15 +51354,15 @@ "svuint64x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint64_t" - }, "Architectures": [ "A64" ] @@ -51374,15 +51374,15 @@ "svuint8x2_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint8_t" - }, "Architectures": [ "A64" ] @@ -51394,15 +51394,15 @@ "svfloat16x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat16_t" - }, "Architectures": [ "A64" ] @@ -51414,15 +51414,15 @@ "svfloat32x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat32_t" - }, "Architectures": [ "A64" ] @@ -51434,15 +51434,15 @@ "svfloat64x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat64_t" - }, "Architectures": [ "A64" ] @@ -51454,15 +51454,15 @@ "svint16x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint16_t" - }, "Architectures": [ "A64" ] @@ -51474,15 +51474,15 @@ "svint32x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint32_t" - }, "Architectures": [ "A64" ] @@ -51494,15 +51494,15 @@ "svint64x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint64_t" - }, "Architectures": [ "A64" ] @@ -51514,15 +51514,15 @@ "svint8x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint8_t" - }, "Architectures": [ "A64" ] @@ -51534,15 +51534,15 @@ "svuint16x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint16_t" - }, "Architectures": [ "A64" ] @@ -51554,15 +51554,15 @@ "svuint32x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint32_t" - }, "Architectures": [ "A64" ] @@ -51574,15 +51574,15 @@ "svuint64x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint64_t" - }, "Architectures": [ "A64" ] @@ -51594,15 +51594,15 @@ "svuint8x3_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint8_t" - }, "Architectures": [ "A64" ] @@ -51614,15 +51614,15 @@ "svfloat16x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat16_t" - }, "Architectures": [ "A64" ] @@ -51634,15 +51634,15 @@ "svfloat32x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat32_t" - }, "Architectures": [ "A64" ] @@ -51654,15 +51654,15 @@ "svfloat64x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svfloat64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat64_t" - }, "Architectures": [ "A64" ] @@ -51674,15 +51674,15 @@ "svint16x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint16_t" - }, "Architectures": [ "A64" ] @@ -51694,15 +51694,15 @@ "svint32x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint32_t" - }, "Architectures": [ "A64" ] @@ -51714,15 +51714,15 @@ "svint64x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint64_t" - }, "Architectures": [ "A64" ] @@ -51734,15 +51734,15 @@ "svint8x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint8_t" - }, "Architectures": [ "A64" ] @@ -51754,15 +51754,15 @@ "svuint16x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint16_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint16_t" - }, "Architectures": [ "A64" ] @@ -51774,15 +51774,15 @@ "svuint32x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint32_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint32_t" - }, "Architectures": [ "A64" ] @@ -51794,15 +51794,15 @@ "svuint64x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint64_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint64_t" - }, "Architectures": [ "A64" ] @@ -51814,15 +51814,15 @@ "svuint8x4_t tuple", "uint64_t imm_index" ], + "return_type": { + "value": "svuint8_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint8_t" - }, "Architectures": [ "A64" ] @@ -163197,15 +163197,15 @@ "uint64_t imm_index", "svfloat16_t x" ], + "return_type": { + "value": "svfloat16x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat16x2_t" - }, "Architectures": [ "A64" ] @@ -163218,15 +163218,15 @@ "uint64_t imm_index", "svfloat32_t x" ], + "return_type": { + "value": "svfloat32x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat32x2_t" - }, "Architectures": [ "A64" ] @@ -163239,15 +163239,15 @@ "uint64_t imm_index", "svfloat64_t x" ], + "return_type": { + "value": "svfloat64x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svfloat64x2_t" - }, "Architectures": [ "A64" ] @@ -163260,15 +163260,15 @@ "uint64_t imm_index", "svint16_t x" ], + "return_type": { + "value": "svint16x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint16x2_t" - }, "Architectures": [ "A64" ] @@ -163281,15 +163281,15 @@ "uint64_t imm_index", "svint32_t x" ], + "return_type": { + "value": "svint32x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint32x2_t" - }, "Architectures": [ "A64" ] @@ -163302,15 +163302,15 @@ "uint64_t imm_index", "svint64_t x" ], + "return_type": { + "value": "svint64x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint64x2_t" - }, "Architectures": [ "A64" ] @@ -163323,15 +163323,15 @@ "uint64_t imm_index", "svint8_t x" ], + "return_type": { + "value": "svint8x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svint8x2_t" - }, "Architectures": [ "A64" ] @@ -163344,15 +163344,15 @@ "uint64_t imm_index", "svuint16_t x" ], + "return_type": { + "value": "svuint16x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint16x2_t" - }, "Architectures": [ "A64" ] @@ -163365,15 +163365,15 @@ "uint64_t imm_index", "svuint32_t x" ], + "return_type": { + "value": "svuint32x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint32x2_t" - }, "Architectures": [ "A64" ] @@ -163386,15 +163386,15 @@ "uint64_t imm_index", "svuint64_t x" ], + "return_type": { + "value": "svuint64x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint64x2_t" - }, "Architectures": [ "A64" ] @@ -163407,15 +163407,15 @@ "uint64_t imm_index", "svuint8_t x" ], + "return_type": { + "value": "svuint8x2_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 1 } }, - "return_type": { - "value": "svuint8x2_t" - }, "Architectures": [ "A64" ] @@ -163428,15 +163428,15 @@ "uint64_t imm_index", "svfloat16_t x" ], + "return_type": { + "value": "svfloat16x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat16x3_t" - }, "Architectures": [ "A64" ] @@ -163449,15 +163449,15 @@ "uint64_t imm_index", "svfloat32_t x" ], + "return_type": { + "value": "svfloat32x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat32x3_t" - }, "Architectures": [ "A64" ] @@ -163470,15 +163470,15 @@ "uint64_t imm_index", "svfloat64_t x" ], + "return_type": { + "value": "svfloat64x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svfloat64x3_t" - }, "Architectures": [ "A64" ] @@ -163491,15 +163491,15 @@ "uint64_t imm_index", "svint16_t x" ], + "return_type": { + "value": "svint16x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint16x3_t" - }, "Architectures": [ "A64" ] @@ -163512,15 +163512,15 @@ "uint64_t imm_index", "svint32_t x" ], + "return_type": { + "value": "svint32x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint32x3_t" - }, "Architectures": [ "A64" ] @@ -163533,15 +163533,15 @@ "uint64_t imm_index", "svint64_t x" ], + "return_type": { + "value": "svint64x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint64x3_t" - }, "Architectures": [ "A64" ] @@ -163554,15 +163554,15 @@ "uint64_t imm_index", "svint8_t x" ], + "return_type": { + "value": "svint8x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svint8x3_t" - }, "Architectures": [ "A64" ] @@ -163575,15 +163575,15 @@ "uint64_t imm_index", "svuint16_t x" ], + "return_type": { + "value": "svuint16x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint16x3_t" - }, "Architectures": [ "A64" ] @@ -163596,15 +163596,15 @@ "uint64_t imm_index", "svuint32_t x" ], + "return_type": { + "value": "svuint32x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint32x3_t" - }, "Architectures": [ "A64" ] @@ -163617,15 +163617,15 @@ "uint64_t imm_index", "svuint64_t x" ], + "return_type": { + "value": "svuint64x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint64x3_t" - }, "Architectures": [ "A64" ] @@ -163638,15 +163638,15 @@ "uint64_t imm_index", "svuint8_t x" ], + "return_type": { + "value": "svuint8x3_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 2 } }, - "return_type": { - "value": "svuint8x3_t" - }, "Architectures": [ "A64" ] @@ -163659,15 +163659,15 @@ "uint64_t imm_index", "svfloat16_t x" ], + "return_type": { + "value": "svfloat16x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat16x4_t" - }, "Architectures": [ "A64" ] @@ -163680,15 +163680,15 @@ "uint64_t imm_index", "svfloat32_t x" ], + "return_type": { + "value": "svfloat32x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat32x4_t" - }, "Architectures": [ "A64" ] @@ -163701,15 +163701,15 @@ "uint64_t imm_index", "svfloat64_t x" ], + "return_type": { + "value": "svfloat64x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svfloat64x4_t" - }, "Architectures": [ "A64" ] @@ -163722,15 +163722,15 @@ "uint64_t imm_index", "svint16_t x" ], + "return_type": { + "value": "svint16x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint16x4_t" - }, "Architectures": [ "A64" ] @@ -163743,15 +163743,15 @@ "uint64_t imm_index", "svint32_t x" ], + "return_type": { + "value": "svint32x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint32x4_t" - }, "Architectures": [ "A64" ] @@ -163764,15 +163764,15 @@ "uint64_t imm_index", "svint64_t x" ], + "return_type": { + "value": "svint64x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint64x4_t" - }, "Architectures": [ "A64" ] @@ -163785,15 +163785,15 @@ "uint64_t imm_index", "svint8_t x" ], + "return_type": { + "value": "svint8x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svint8x4_t" - }, "Architectures": [ "A64" ] @@ -163806,15 +163806,15 @@ "uint64_t imm_index", "svuint16_t x" ], + "return_type": { + "value": "svuint16x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint16x4_t" - }, "Architectures": [ "A64" ] @@ -163827,15 +163827,15 @@ "uint64_t imm_index", "svuint32_t x" ], + "return_type": { + "value": "svuint32x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint32x4_t" - }, "Architectures": [ "A64" ] @@ -163848,15 +163848,15 @@ "uint64_t imm_index", "svuint64_t x" ], + "return_type": { + "value": "svuint64x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint64x4_t" - }, "Architectures": [ "A64" ] @@ -163869,15 +163869,15 @@ "uint64_t imm_index", "svuint8_t x" ], + "return_type": { + "value": "svuint8x4_t" + }, "Arguments_Preparation": { "imm_index": { "minimum": 0, "maximum": 3 } }, - "return_type": { - "value": "svuint8x4_t" - }, "Architectures": [ "A64" ] @@ -201117,6 +201117,462 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vbfdot_f32", + "arguments": [ + "float32x2_t r", + "bfloat16x4_t a", + "bfloat16x4_t b" + ], + "return_type": { + "value": "float32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4H" + }, + "b": { + "register": "Vm.4H" + }, + "r": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfdot_lane_f32", + "arguments": [ + "float32x2_t r", + "bfloat16x4_t a", + "bfloat16x4_t b", + "const int lane" + ], + "return_type": { + "value": "float32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4H" + }, + "b": { + "register": "Vm.4H" + }, + "lane": { + "minimum": 0, + "maximum": 1 + }, + "r": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfdot_laneq_f32", + "arguments": [ + "float32x2_t r", + "bfloat16x4_t a", + "bfloat16x8_t b", + "const int lane" + ], + "return_type": { + "value": "float32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4H" + }, + "b": { + "register": "Vm.8H" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "r": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfdotq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfdotq_lane_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x4_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.4H" + }, + "lane": { + "minimum": 0, + "maximum": 1 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfdotq_laneq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFDOT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlalbq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALB" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlalbq_lane_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x4_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.4H" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALB" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlalbq_laneq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "lane": { + "minimum": 0, + "maximum": 7 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALB" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlaltq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlaltq_lane_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x4_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.4H" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmlaltq_laneq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b", + "const int lane" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "lane": { + "minimum": 0, + "maximum": 7 + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMLALT" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vbfmmlaq_f32", + "arguments": [ + "float32x4_t r", + "bfloat16x8_t a", + "bfloat16x8_t b" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + }, + "b": { + "register": "Vm.8H" + }, + "r": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFMMLA" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vbic_s16", @@ -212637,6 +213093,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcombine_bf16", + "arguments": [ + "bfloat16x4_t low", + "bfloat16x4_t high" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "high": { + "register": "Vm.4H" + }, + "low": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP", + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcombine_f16", @@ -213054,6 +213539,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcopy_lane_bf16", + "arguments": [ + "bfloat16x4_t a", + "const int lane1", + "bfloat16x4_t b", + "const int lane2" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + }, + "b": { + "register": "Vn.4H" + }, + "lane1": { + "minimum": 0, + "maximum": 3 + }, + "lane2": { + "minimum": 0, + "maximum": 3 + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcopy_lane_f32", @@ -213536,6 +214058,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcopy_laneq_bf16", + "arguments": [ + "bfloat16x4_t a", + "const int lane1", + "bfloat16x8_t b", + "const int lane2" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + }, + "b": { + "register": "Vn.8H" + }, + "lane1": { + "minimum": 0, + "maximum": 3 + }, + "lane2": { + "minimum": 0, + "maximum": 7 + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcopy_laneq_f32", @@ -214018,6 +214577,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcopyq_lane_bf16", + "arguments": [ + "bfloat16x8_t a", + "const int lane1", + "bfloat16x4_t b", + "const int lane2" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + }, + "b": { + "register": "Vn.4H" + }, + "lane1": { + "minimum": 0, + "maximum": 7 + }, + "lane2": { + "minimum": 0, + "maximum": 3 + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcopyq_lane_f32", @@ -214500,6 +215096,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcopyq_laneq_bf16", + "arguments": [ + "bfloat16x8_t a", + "const int lane1", + "bfloat16x8_t b", + "const int lane2" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + }, + "b": { + "register": "Vn.8H" + }, + "lane1": { + "minimum": 0, + "maximum": 7 + }, + "lane2": { + "minimum": 0, + "maximum": 7 + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcopyq_laneq_f32", @@ -214982,6 +215615,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcreate_bf16", + "arguments": [ + "uint64_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcreate_f16", @@ -215329,6 +215986,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcvt_bf16_f32", + "arguments": [ + "float32x4_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFCVTN" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcvt_f16_f32", @@ -215402,6 +216083,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcvt_f32_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "SHLL" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcvt_f32_f16", @@ -216395,6 +217100,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcvtah_f32_bf16", + "arguments": [ + "bfloat16_t a" + ], + "return_type": { + "value": "float32_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Hn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "SHL" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcvtah_s16_f16", @@ -217017,6 +217746,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcvth_bf16_f32", + "arguments": [ + "float32_t a" + ], + "return_type": { + "value": "bfloat16_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Sn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFCVT" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcvth_f16_s16", @@ -219597,6 +220350,106 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vcvtq_high_bf16_f32", + "arguments": [ + "bfloat16x8_t inactive", + "float32x4_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4S" + }, + "inactive": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFCVTN2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vcvtq_high_f32_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "SHLL2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vcvtq_low_bf16_f32", + "arguments": [ + "float32x4_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "BFCVTN" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vcvtq_low_f32_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "float32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "SHLL" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vcvtq_n_f16_s16", @@ -221026,6 +221879,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdup_lane_bf16", + "arguments": [ + "bfloat16x4_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "vec": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdup_lane_f16", @@ -221443,6 +222325,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdup_laneq_bf16", + "arguments": [ + "bfloat16x8_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "vec": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdup_laneq_f16", @@ -221835,6 +222746,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdup_n_bf16", + "arguments": [ + "bfloat16_t value" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "value": { + "register": "rn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdup_n_f16", @@ -222518,6 +223453,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vduph_lane_bf16", + "arguments": [ + "bfloat16x4_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "vec": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vduph_lane_f16", @@ -222630,6 +223594,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vduph_laneq_bf16", + "arguments": [ + "bfloat16x8_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "vec": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vduph_laneq_f16", @@ -222742,6 +223735,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdupq_lane_bf16", + "arguments": [ + "bfloat16x4_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "vec": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdupq_lane_f16", @@ -223159,6 +224181,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdupq_laneq_bf16", + "arguments": [ + "bfloat16x8_t vec", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "vec": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdupq_laneq_f16", @@ -223551,6 +224602,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vdupq_n_bf16", + "arguments": [ + "bfloat16_t value" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "value": { + "register": "rn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vdupq_n_f16", @@ -228692,6 +229767,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vget_high_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vget_high_f16", @@ -229041,13 +230140,13 @@ }, { "SIMD_ISA": "Neon", - "name": "vget_lane_f16", + "name": "vget_lane_bf16", "arguments": [ - "float16x4_t v", + "bfloat16x4_t v", "const int lane" ], "return_type": { - "value": "float16_t" + "value": "bfloat16_t" }, "Arguments_Preparation": { "lane": { @@ -229059,7 +230158,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -229071,160 +230169,13 @@ }, { "SIMD_ISA": "Neon", - "name": "vget_lane_f32", - "arguments": [ - "float32x2_t v", - "const int lane" - ], - "return_type": { - "value": "float32_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 1 - }, - "v": { - "register": "Vn.2S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "DUP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_f64", - "arguments": [ - "float64x1_t v", - "const int lane" - ], - "return_type": { - "value": "float64_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 0 - }, - "v": { - "register": "Vn.1D" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "DUP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_p16", - "arguments": [ - "poly16x4_t v", - "const int lane" - ], - "return_type": { - "value": "poly16_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 3 - }, - "v": { - "register": "Vn.4H" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "UMOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_p64", - "arguments": [ - "poly64x1_t v", - "const int lane" - ], - "return_type": { - "value": "poly64_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 0 - }, - "v": { - "register": "Vn.1D" - } - }, - "Architectures": [ - "A32", - "A64" - ], - "instructions": [ - [ - "UMOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_p8", - "arguments": [ - "poly8x8_t v", - "const int lane" - ], - "return_type": { - "value": "poly8_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 7 - }, - "v": { - "register": "Vn.8B" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "UMOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_s16", + "name": "vget_lane_f16", "arguments": [ - "int16x4_t v", + "float16x4_t v", "const int lane" ], "return_type": { - "value": "int16_t" + "value": "float16_t" }, "Arguments_Preparation": { "lane": { @@ -229242,19 +230193,19 @@ ], "instructions": [ [ - "SMOV" + "DUP" ] ] }, { "SIMD_ISA": "Neon", - "name": "vget_lane_s32", + "name": "vget_lane_f32", "arguments": [ - "int32x2_t v", + "float32x2_t v", "const int lane" ], "return_type": { - "value": "int32_t" + "value": "float32_t" }, "Arguments_Preparation": { "lane": { @@ -229272,19 +230223,19 @@ ], "instructions": [ [ - "SMOV" + "DUP" ] ] }, { "SIMD_ISA": "Neon", - "name": "vget_lane_s64", + "name": "vget_lane_f64", "arguments": [ - "int64x1_t v", + "float64x1_t v", "const int lane" ], "return_type": { - "value": "int64_t" + "value": "float64_t" }, "Arguments_Preparation": { "lane": { @@ -229296,55 +230247,23 @@ } }, "Architectures": [ - "v7", - "A32", "A64" ], "instructions": [ [ - "UMOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_s8", - "arguments": [ - "int8x8_t v", - "const int lane" - ], - "return_type": { - "value": "int8_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 7 - }, - "v": { - "register": "Vn.8B" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "SMOV" + "DUP" ] ] }, { "SIMD_ISA": "Neon", - "name": "vget_lane_u16", + "name": "vget_lane_p16", "arguments": [ - "uint16x4_t v", + "poly16x4_t v", "const int lane" ], "return_type": { - "value": "uint16_t" + "value": "poly16_t" }, "Arguments_Preparation": { "lane": { @@ -229368,43 +230287,13 @@ }, { "SIMD_ISA": "Neon", - "name": "vget_lane_u32", - "arguments": [ - "uint32x2_t v", - "const int lane" - ], - "return_type": { - "value": "uint32_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 1 - }, - "v": { - "register": "Vn.2S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "UMOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vget_lane_u64", + "name": "vget_lane_p64", "arguments": [ - "uint64x1_t v", + "poly64x1_t v", "const int lane" ], "return_type": { - "value": "uint64_t" + "value": "poly64_t" }, "Arguments_Preparation": { "lane": { @@ -229416,7 +230305,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -229428,13 +230316,13 @@ }, { "SIMD_ISA": "Neon", - "name": "vget_lane_u8", + "name": "vget_lane_p8", "arguments": [ - "uint8x8_t v", + "poly8x8_t v", "const int lane" ], "return_type": { - "value": "uint8_t" + "value": "poly8_t" }, "Arguments_Preparation": { "lane": { @@ -229456,6 +230344,270 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_s16", + "arguments": [ + "int16x4_t v", + "const int lane" + ], + "return_type": { + "value": "int16_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "v": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_s32", + "arguments": [ + "int32x2_t v", + "const int lane" + ], + "return_type": { + "value": "int32_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 1 + }, + "v": { + "register": "Vn.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_s64", + "arguments": [ + "int64x1_t v", + "const int lane" + ], + "return_type": { + "value": "int64_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 0 + }, + "v": { + "register": "Vn.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "UMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_s8", + "arguments": [ + "int8x8_t v", + "const int lane" + ], + "return_type": { + "value": "int8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "v": { + "register": "Vn.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_u16", + "arguments": [ + "uint16x4_t v", + "const int lane" + ], + "return_type": { + "value": "uint16_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "v": { + "register": "Vn.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "UMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_u32", + "arguments": [ + "uint32x2_t v", + "const int lane" + ], + "return_type": { + "value": "uint32_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 1 + }, + "v": { + "register": "Vn.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "UMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_u64", + "arguments": [ + "uint64x1_t v", + "const int lane" + ], + "return_type": { + "value": "uint64_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 0 + }, + "v": { + "register": "Vn.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "UMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_lane_u8", + "arguments": [ + "uint8x8_t v", + "const int lane" + ], + "return_type": { + "value": "uint8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "v": { + "register": "Vn.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "UMOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vget_low_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vget_low_f16", @@ -229803,6 +230955,35 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vgetq_lane_bf16", + "arguments": [ + "bfloat16x8_t v", + "const int lane" + ], + "return_type": { + "value": "bfloat16_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "v": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "DUP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vgetq_lane_f16", @@ -230916,6 +232097,127 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld1_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_bf16_x2", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_bf16_x3", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_bf16_x4", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld1_dup_f16", @@ -231557,14 +232859,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_f16", + "name": "vld1_lane_bf16", "arguments": [ - "float16_t const * ptr", - "float16x4_t src", + "bfloat16_t const * ptr", + "bfloat16x4_t src", "const int lane" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "lane": { @@ -231579,7 +232881,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -231591,25 +232892,25 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_f32", + "name": "vld1_lane_f16", "arguments": [ - "float32_t const * ptr", - "float32x2_t src", + "float16_t const * ptr", + "float16x4_t src", "const int lane" ], "return_type": { - "value": "float32x2_t" + "value": "float16x4_t" }, "Arguments_Preparation": { "lane": { "minimum": 0, - "maximum": 1 + "maximum": 3 }, "ptr": { "register": "Xn" }, "src": { - "register": "Vt.2S" + "register": "Vt.4H" } }, "Architectures": [ @@ -231625,57 +232926,25 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_f64", - "arguments": [ - "float64_t const * ptr", - "float64x1_t src", - "const int lane" - ], - "return_type": { - "value": "float64x1_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 0 - }, - "ptr": { - "register": "Xn" - }, - "src": { - "register": "Vt.1D" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "LD1" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vld1_lane_p16", + "name": "vld1_lane_f32", "arguments": [ - "poly16_t const * ptr", - "poly16x4_t src", + "float32_t const * ptr", + "float32x2_t src", "const int lane" ], "return_type": { - "value": "poly16x4_t" + "value": "float32x2_t" }, "Arguments_Preparation": { "lane": { "minimum": 0, - "maximum": 3 + "maximum": 1 }, "ptr": { "register": "Xn" }, "src": { - "register": "Vt.4H" + "register": "Vt.2S" } }, "Architectures": [ @@ -231691,14 +232960,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_p64", + "name": "vld1_lane_f64", "arguments": [ - "poly64_t const * ptr", - "poly64x1_t src", + "float64_t const * ptr", + "float64x1_t src", "const int lane" ], "return_type": { - "value": "poly64x1_t" + "value": "float64x1_t" }, "Arguments_Preparation": { "lane": { @@ -231713,41 +232982,6 @@ } }, "Architectures": [ - "A32", - "A64" - ], - "instructions": [ - [ - "LD1" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vld1_lane_p8", - "arguments": [ - "poly8_t const * ptr", - "poly8x8_t src", - "const int lane" - ], - "return_type": { - "value": "poly8x8_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 7 - }, - "ptr": { - "register": "Xn" - }, - "src": { - "register": "Vt.8B" - } - }, - "Architectures": [ - "v7", - "A32", "A64" ], "instructions": [ @@ -231758,14 +232992,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_s16", + "name": "vld1_lane_p16", "arguments": [ - "int16_t const * ptr", - "int16x4_t src", + "poly16_t const * ptr", + "poly16x4_t src", "const int lane" ], "return_type": { - "value": "int16x4_t" + "value": "poly16x4_t" }, "Arguments_Preparation": { "lane": { @@ -231792,48 +233026,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_s32", - "arguments": [ - "int32_t const * ptr", - "int32x2_t src", - "const int lane" - ], - "return_type": { - "value": "int32x2_t" - }, - "Arguments_Preparation": { - "lane": { - "minimum": 0, - "maximum": 1 - }, - "ptr": { - "register": "Xn" - }, - "src": { - "register": "Vt.2S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "LD1" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vld1_lane_s64", + "name": "vld1_lane_p64", "arguments": [ - "int64_t const * ptr", - "int64x1_t src", + "poly64_t const * ptr", + "poly64x1_t src", "const int lane" ], "return_type": { - "value": "int64x1_t" + "value": "poly64x1_t" }, "Arguments_Preparation": { "lane": { @@ -231848,7 +233048,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -231860,14 +233059,150 @@ }, { "SIMD_ISA": "Neon", - "name": "vld1_lane_s8", + "name": "vld1_lane_p8", "arguments": [ - "int8_t const * ptr", - "int8x8_t src", + "poly8_t const * ptr", + "poly8x8_t src", "const int lane" ], "return_type": { - "value": "int8x8_t" + "value": "poly8x8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "src": { + "register": "Vt.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_lane_s16", + "arguments": [ + "int16_t const * ptr", + "int16x4_t src", + "const int lane" + ], + "return_type": { + "value": "int16x4_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "src": { + "register": "Vt.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_lane_s32", + "arguments": [ + "int32_t const * ptr", + "int32x2_t src", + "const int lane" + ], + "return_type": { + "value": "int32x2_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 1 + }, + "ptr": { + "register": "Xn" + }, + "src": { + "register": "Vt.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_lane_s64", + "arguments": [ + "int64_t const * ptr", + "int64x1_t src", + "const int lane" + ], + "return_type": { + "value": "int64x1_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 0 + }, + "ptr": { + "register": "Xn" + }, + "src": { + "register": "Vt.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1_lane_s8", + "arguments": [ + "int8_t const * ptr", + "int8x8_t src", + "const int lane" + ], + "return_type": { + "value": "int8x8_t" }, "Arguments_Preparation": { "lane": { @@ -233124,6 +234459,127 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_bf16_x2", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_bf16_x3", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_bf16_x4", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld1q_dup_f16", @@ -233763,6 +235219,39 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld1q_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x8_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "src": { + "register": "Vt.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD1" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld1q_lane_f16", @@ -235332,6 +236821,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld2_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld2_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld2_dup_f16", @@ -235752,6 +237289,42 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld2_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x4x2_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4x2_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.4H" + }, + "src.val[1]": { + "register": "Vt2.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld2_lane_f16", @@ -236536,6 +238109,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld2q_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld2q_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x2_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld2q_dup_f16", @@ -236951,6 +238572,42 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld2q_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x8x2_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8x2_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.8H" + }, + "src.val[1]": { + "register": "Vt2.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld2q_lane_f16", @@ -237724,6 +239381,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld3_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld3_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld3_dup_f16", @@ -238144,6 +239849,45 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld3_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x4x3_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4x3_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.4H" + }, + "src.val[1]": { + "register": "Vt2.4H" + }, + "src.val[2]": { + "register": "Vt3.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld3_lane_f16", @@ -238970,6 +240714,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld3q_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld3q_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x3_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld3q_dup_f16", @@ -239385,6 +241177,45 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld3q_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x8x3_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8x3_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.8H" + }, + "src.val[1]": { + "register": "Vt2.8H" + }, + "src.val[2]": { + "register": "Vt3.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD3" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld3q_lane_f16", @@ -240200,6 +242031,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld4_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld4_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x4x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld4_dup_f16", @@ -240620,6 +242499,48 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld4_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x4x4_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4x4_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.4H" + }, + "src.val[1]": { + "register": "Vt2.4H" + }, + "src.val[2]": { + "register": "Vt3.4H" + }, + "src.val[3]": { + "register": "Vt4.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld4_lane_f16", @@ -241488,6 +243409,54 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld4q_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vld4q_dup_bf16", + "arguments": [ + "bfloat16_t const * ptr" + ], + "return_type": { + "value": "bfloat16x8x4_t" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4R" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld4q_dup_f16", @@ -241903,6 +243872,48 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vld4q_lane_bf16", + "arguments": [ + "bfloat16_t const * ptr", + "bfloat16x8x4_t src", + "const int lane" + ], + "return_type": { + "value": "bfloat16x8x4_t" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "src.val[0]": { + "register": "Vt.8H" + }, + "src.val[1]": { + "register": "Vt2.8H" + }, + "src.val[2]": { + "register": "Vt3.8H" + }, + "src.val[3]": { + "register": "Vt4.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "LD4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vld4q_lane_f16", @@ -243042,14 +245053,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_f16", + "name": "vluti2_lane_bf16", "arguments": [ - "float16x4_t vn", + "bfloat16x4_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "float16x8_t" + "value": "bfloat16x8_t" }, "Arguments_Preparation": { "index": { @@ -243074,14 +245085,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_p16", + "name": "vluti2_lane_f16", "arguments": [ - "poly16x4_t vn", + "float16x4_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "poly16x8_t" + "value": "float16x8_t" }, "Arguments_Preparation": { "index": { @@ -243106,46 +245117,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_p8", - "arguments": [ - "poly8x8_t vn", - "uint8x8_t vm", - "const int index" - ], - "return_type": { - "value": "poly8x16_t" - }, - "Arguments_Preparation": { - "index": { - "minimum": 0, - "maximum": 1 - }, - "vm": { - "register": "Vm" - }, - "vn": { - "register": "Vn.16B" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "LUTI2" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vluti2_lane_s16", + "name": "vluti2_lane_p16", "arguments": [ - "int16x4_t vn", + "poly16x4_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "int16x8_t" + "value": "poly16x8_t" }, "Arguments_Preparation": { "index": { @@ -243170,14 +245149,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_s8", + "name": "vluti2_lane_p8", "arguments": [ - "int8x8_t vn", + "poly8x8_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "int8x16_t" + "value": "poly8x16_t" }, "Arguments_Preparation": { "index": { @@ -243202,14 +245181,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_u16", + "name": "vluti2_lane_s16", "arguments": [ - "uint16x4_t vn", + "int16x4_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "uint16x8_t" + "value": "int16x8_t" }, "Arguments_Preparation": { "index": { @@ -243234,14 +245213,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti2_lane_u8", + "name": "vluti2_lane_s8", "arguments": [ - "uint8x8_t vn", + "int8x8_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "uint8x16_t" + "value": "int8x16_t" }, "Arguments_Preparation": { "index": { @@ -243264,6 +245243,102 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vluti2_lane_u16", + "arguments": [ + "uint16x4_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "uint16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 3 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti2_lane_u8", + "arguments": [ + "uint8x8_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "uint8x16_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 1 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.16B" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI2" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti2_laneq_bf16", + "arguments": [ + "bfloat16x4_t vn", + "uint8x16_t vm", + "const int index" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 7 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vluti2_laneq_f16", @@ -243488,6 +245563,38 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vluti2q_lane_bf16", + "arguments": [ + "bfloat16x8_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 3 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vluti2q_lane_f16", @@ -243712,6 +245819,38 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vluti2q_laneq_bf16", + "arguments": [ + "bfloat16x8_t vn", + "uint8x16_t vm", + "const int index" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 7 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vluti2q_laneq_f16", @@ -243938,49 +246077,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti4q_lane_f16_x2", - "arguments": [ - "float16x8x2_t vn", - "uint8x8_t vm", - "const int index" - ], - "return_type": { - "value": "float16x8_t" - }, - "Arguments_Preparation": { - "index": { - "minimum": 0, - "maximum": 1 - }, - "vm": { - "register": "Vm" - }, - "vn.val[0]": { - "register": "Vn1.8H" - }, - "vn.val[1]": { - "register": "Vn2.8H" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "LUTI4" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vluti4q_lane_p16_x2", + "name": "vluti4q_lane_bf16_x2", "arguments": [ - "poly16x8x2_t vn", + "bfloat16x8x2_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "poly16x8_t" + "value": "bfloat16x8_t" }, "Arguments_Preparation": { "index": { @@ -244008,46 +246112,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti4q_lane_p8", - "arguments": [ - "poly8x16_t vn", - "uint8x8_t vm", - "const int index" - ], - "return_type": { - "value": "poly8x16_t" - }, - "Arguments_Preparation": { - "index": { - "minimum": 0, - "maximum": 0 - }, - "vm": { - "register": "Vm" - }, - "vn": { - "register": "Vn.16B" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "LUTI4" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vluti4q_lane_s16_x2", + "name": "vluti4q_lane_f16_x2", "arguments": [ - "int16x8x2_t vn", + "float16x8x2_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "int16x8_t" + "value": "float16x8_t" }, "Arguments_Preparation": { "index": { @@ -244075,46 +246147,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti4q_lane_s8", - "arguments": [ - "int8x16_t vn", - "uint8x8_t vm", - "const int index" - ], - "return_type": { - "value": "int8x16_t" - }, - "Arguments_Preparation": { - "index": { - "minimum": 0, - "maximum": 0 - }, - "vm": { - "register": "Vm" - }, - "vn": { - "register": "Vn.16B" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "LUTI4" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vluti4q_lane_u16_x2", + "name": "vluti4q_lane_p16_x2", "arguments": [ - "uint16x8x2_t vn", + "poly16x8x2_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "uint16x8_t" + "value": "poly16x8_t" }, "Arguments_Preparation": { "index": { @@ -244142,14 +246182,14 @@ }, { "SIMD_ISA": "Neon", - "name": "vluti4q_lane_u8", + "name": "vluti4q_lane_p8", "arguments": [ - "uint8x16_t vn", + "poly8x16_t vn", "uint8x8_t vm", "const int index" ], "return_type": { - "value": "uint8x16_t" + "value": "poly8x16_t" }, "Arguments_Preparation": { "index": { @@ -244172,6 +246212,175 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vluti4q_lane_s16_x2", + "arguments": [ + "int16x8x2_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "int16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 1 + }, + "vm": { + "register": "Vm" + }, + "vn.val[0]": { + "register": "Vn1.8H" + }, + "vn.val[1]": { + "register": "Vn2.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti4q_lane_s8", + "arguments": [ + "int8x16_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "int8x16_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 0 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.16B" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti4q_lane_u16_x2", + "arguments": [ + "uint16x8x2_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "uint16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 1 + }, + "vm": { + "register": "Vm" + }, + "vn.val[0]": { + "register": "Vn1.8H" + }, + "vn.val[1]": { + "register": "Vn2.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti4q_lane_u8", + "arguments": [ + "uint8x16_t vn", + "uint8x8_t vm", + "const int index" + ], + "return_type": { + "value": "uint8x16_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 0 + }, + "vm": { + "register": "Vm" + }, + "vn": { + "register": "Vn.16B" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI4" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vluti4q_laneq_bf16_x2", + "arguments": [ + "bfloat16x8x2_t vn", + "uint8x16_t vm", + "const int index" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "index": { + "minimum": 0, + "maximum": 3 + }, + "vm": { + "register": "Vm" + }, + "vn.val[0]": { + "register": "Vn1.8H" + }, + "vn.val[1]": { + "register": "Vn2.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "LUTI4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vluti4q_laneq_f16_x2", @@ -276421,12 +278630,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_f32", + "name": "vreinterpret_bf16_f32", "arguments": [ "float32x2_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276434,7 +278643,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276446,12 +278654,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_f64", + "name": "vreinterpret_bf16_f64", "arguments": [ "float64x1_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276469,12 +278677,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_p16", + "name": "vreinterpret_bf16_p16", "arguments": [ "poly16x4_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276482,7 +278690,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276494,12 +278701,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_p64", + "name": "vreinterpret_bf16_p64", "arguments": [ "poly64x1_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276518,12 +278725,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_p8", + "name": "vreinterpret_bf16_p8", "arguments": [ "poly8x8_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276531,7 +278738,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276543,12 +278749,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_s16", + "name": "vreinterpret_bf16_s16", "arguments": [ "int16x4_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276556,7 +278762,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276568,12 +278773,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_s32", + "name": "vreinterpret_bf16_s32", "arguments": [ "int32x2_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276581,7 +278786,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276593,12 +278797,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_s64", + "name": "vreinterpret_bf16_s64", "arguments": [ "int64x1_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276606,7 +278810,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276618,12 +278821,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_s8", + "name": "vreinterpret_bf16_s8", "arguments": [ "int8x8_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276631,7 +278834,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276643,12 +278845,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_u16", + "name": "vreinterpret_bf16_u16", "arguments": [ "uint16x4_t a" ], "return_type": { - "value": "float16x4_t" + "value": "bfloat16x4_t" }, "Arguments_Preparation": { "a": { @@ -276656,7 +278858,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -276668,7 +278869,326 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_f16_u32", + "name": "vreinterpret_bf16_u32", + "arguments": [ + "uint32x2_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_bf16_u64", + "arguments": [ + "uint64x1_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_bf16_u8", + "arguments": [ + "uint8x8_t a" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8B" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_f32", + "arguments": [ + "float32x2_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_f64", + "arguments": [ + "float64x1_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_p16", + "arguments": [ + "poly16x4_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_p64", + "arguments": [ + "poly64x1_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_p8", + "arguments": [ + "poly8x8_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_s16", + "arguments": [ + "int16x4_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_s32", + "arguments": [ + "int32x2_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_s64", + "arguments": [ + "int64x1_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_s8", + "arguments": [ + "int8x8_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_u16", + "arguments": [ + "uint16x4_t a" + ], + "return_type": { + "value": "float16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f16_u32", "arguments": [ "uint32x2_t a" ], @@ -276741,6 +279261,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f32_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "float32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_f32_f16", @@ -277039,6 +279583,29 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_f64_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "float64x1_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_f64_f16", @@ -277338,6 +279905,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_p16_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "poly16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_p16_f16", @@ -277660,6 +280251,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_p64_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "poly64x1_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_p64_f16", @@ -277947,6 +280562,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_p8_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "poly8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_p8_f16", @@ -278269,6 +280908,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_s16_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "int16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_s16_f16", @@ -278591,6 +281254,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_s32_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "int32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_s32_f16", @@ -278913,6 +281600,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_s64_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "int64x1_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_s64_f16", @@ -279235,6 +281946,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_s8_bf16", + "arguments": [ + "bfloat16x4_t a" + ], + "return_type": { + "value": "int8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpret_s8_f16", @@ -279559,9 +282294,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_f16", + "name": "vreinterpret_u16_bf16", "arguments": [ - "float16x4_t a" + "bfloat16x4_t a" ], "return_type": { "value": "uint16x4_t" @@ -279572,7 +282307,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -279584,16 +282318,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_f32", + "name": "vreinterpret_u16_f16", "arguments": [ - "float32x2_t a" + "float16x4_t a" ], "return_type": { "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.4H" } }, "Architectures": [ @@ -279609,39 +282343,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_f64", - "arguments": [ - "float64x1_t a" - ], - "return_type": { - "value": "uint16x4_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.1D" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_p16", + "name": "vreinterpret_u16_f32", "arguments": [ - "poly16x4_t a" + "float32x2_t a" ], "return_type": { "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.2S" } }, "Architectures": [ @@ -279657,9 +282368,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_p64", + "name": "vreinterpret_u16_f64", "arguments": [ - "poly64x1_t a" + "float64x1_t a" ], "return_type": { "value": "uint16x4_t" @@ -279670,7 +282381,6 @@ } }, "Architectures": [ - "A32", "A64" ], "instructions": [ @@ -279681,34 +282391,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_p8", - "arguments": [ - "poly8x8_t a" - ], - "return_type": { - "value": "uint16x4_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.8B" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_s16", + "name": "vreinterpret_u16_p16", "arguments": [ - "int16x4_t a" + "poly16x4_t a" ], "return_type": { "value": "uint16x4_t" @@ -279731,34 +282416,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_s32", - "arguments": [ - "int32x2_t a" - ], - "return_type": { - "value": "uint16x4_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.2S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_s64", + "name": "vreinterpret_u16_p64", "arguments": [ - "int64x1_t a" + "poly64x1_t a" ], "return_type": { "value": "uint16x4_t" @@ -279769,7 +282429,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -279781,9 +282440,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_s8", + "name": "vreinterpret_u16_p8", "arguments": [ - "int8x8_t a" + "poly8x8_t a" ], "return_type": { "value": "uint16x4_t" @@ -279806,16 +282465,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_u32", + "name": "vreinterpret_u16_s16", "arguments": [ - "uint32x2_t a" + "int16x4_t a" ], "return_type": { "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.4H" } }, "Architectures": [ @@ -279831,16 +282490,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_u64", + "name": "vreinterpret_u16_s32", "arguments": [ - "uint64x1_t a" + "int32x2_t a" ], "return_type": { "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.2S" } }, "Architectures": [ @@ -279856,16 +282515,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u16_u8", + "name": "vreinterpret_u16_s64", "arguments": [ - "uint8x8_t a" + "int64x1_t a" ], "return_type": { "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.1D" } }, "Architectures": [ @@ -279881,16 +282540,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_f16", + "name": "vreinterpret_u16_s8", "arguments": [ - "float16x4_t a" + "int8x8_t a" ], "return_type": { - "value": "uint32x2_t" + "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.8B" } }, "Architectures": [ @@ -279906,12 +282565,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_f32", + "name": "vreinterpret_u16_u32", "arguments": [ - "float32x2_t a" + "uint32x2_t a" ], "return_type": { - "value": "uint32x2_t" + "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { @@ -279931,12 +282590,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_f64", + "name": "vreinterpret_u16_u64", "arguments": [ - "float64x1_t a" + "uint64x1_t a" ], "return_type": { - "value": "uint32x2_t" + "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { @@ -279944,6 +282603,8 @@ } }, "Architectures": [ + "v7", + "A32", "A64" ], "instructions": [ @@ -279954,16 +282615,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_p16", + "name": "vreinterpret_u16_u8", "arguments": [ - "poly16x4_t a" + "uint8x8_t a" ], "return_type": { - "value": "uint32x2_t" + "value": "uint16x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.8B" } }, "Architectures": [ @@ -279979,16 +282640,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_p64", + "name": "vreinterpret_u32_bf16", "arguments": [ - "poly64x1_t a" + "bfloat16x4_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.4H" } }, "Architectures": [ @@ -280003,16 +282664,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_p8", + "name": "vreinterpret_u32_f16", "arguments": [ - "poly8x8_t a" + "float16x4_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.4H" } }, "Architectures": [ @@ -280028,16 +282689,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_s16", + "name": "vreinterpret_u32_f32", "arguments": [ - "int16x4_t a" + "float32x2_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.2S" } }, "Architectures": [ @@ -280053,16 +282714,39 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_s32", + "name": "vreinterpret_u32_f64", "arguments": [ - "int32x2_t a" + "float64x1_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.1D" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u32_p16", + "arguments": [ + "poly16x4_t a" + ], + "return_type": { + "value": "uint32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" } }, "Architectures": [ @@ -280078,9 +282762,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_s64", + "name": "vreinterpret_u32_p64", "arguments": [ - "int64x1_t a" + "poly64x1_t a" ], "return_type": { "value": "uint32x2_t" @@ -280091,7 +282775,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -280103,9 +282786,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_s8", + "name": "vreinterpret_u32_p8", "arguments": [ - "int8x8_t a" + "poly8x8_t a" ], "return_type": { "value": "uint32x2_t" @@ -280128,9 +282811,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_u16", + "name": "vreinterpret_u32_s16", "arguments": [ - "uint16x4_t a" + "int16x4_t a" ], "return_type": { "value": "uint32x2_t" @@ -280153,16 +282836,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_u64", + "name": "vreinterpret_u32_s32", "arguments": [ - "uint64x1_t a" + "int32x2_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.2S" } }, "Architectures": [ @@ -280178,16 +282861,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u32_u8", + "name": "vreinterpret_u32_s64", "arguments": [ - "uint8x8_t a" + "int64x1_t a" ], "return_type": { "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.1D" } }, "Architectures": [ @@ -280203,16 +282886,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_f16", + "name": "vreinterpret_u32_s8", "arguments": [ - "float16x4_t a" + "int8x8_t a" ], "return_type": { - "value": "uint64x1_t" + "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.8B" } }, "Architectures": [ @@ -280228,16 +282911,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_f32", + "name": "vreinterpret_u32_u16", "arguments": [ - "float32x2_t a" + "uint16x4_t a" ], "return_type": { - "value": "uint64x1_t" + "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.4H" } }, "Architectures": [ @@ -280253,12 +282936,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_f64", + "name": "vreinterpret_u32_u64", "arguments": [ - "float64x1_t a" + "uint64x1_t a" ], "return_type": { - "value": "uint64x1_t" + "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { @@ -280266,6 +282949,8 @@ } }, "Architectures": [ + "v7", + "A32", "A64" ], "instructions": [ @@ -280276,16 +282961,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_p16", + "name": "vreinterpret_u32_u8", "arguments": [ - "poly16x4_t a" + "uint8x8_t a" ], "return_type": { - "value": "uint64x1_t" + "value": "uint32x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.8B" } }, "Architectures": [ @@ -280301,16 +282986,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_p64", + "name": "vreinterpret_u64_bf16", "arguments": [ - "poly64x1_t a" + "bfloat16x4_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.4H" } }, "Architectures": [ @@ -280325,16 +283010,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_p8", + "name": "vreinterpret_u64_f16", "arguments": [ - "poly8x8_t a" + "float16x4_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.4H" } }, "Architectures": [ @@ -280350,16 +283035,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_s16", + "name": "vreinterpret_u64_f32", "arguments": [ - "int16x4_t a" + "float32x2_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.2S" } }, "Architectures": [ @@ -280375,21 +283060,19 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_s32", + "name": "vreinterpret_u64_f64", "arguments": [ - "int32x2_t a" + "float64x1_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.1D" } }, "Architectures": [ - "v7", - "A32", "A64" ], "instructions": [ @@ -280400,16 +283083,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_s64", + "name": "vreinterpret_u64_p16", "arguments": [ - "int64x1_t a" + "poly16x4_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.4H" } }, "Architectures": [ @@ -280425,20 +283108,19 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_s8", + "name": "vreinterpret_u64_p64", "arguments": [ - "int8x8_t a" + "poly64x1_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.1D" } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -280450,16 +283132,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_u16", + "name": "vreinterpret_u64_p8", "arguments": [ - "uint16x4_t a" + "poly8x8_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.8B" } }, "Architectures": [ @@ -280475,16 +283157,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_u32", + "name": "vreinterpret_u64_s16", "arguments": [ - "uint32x2_t a" + "int16x4_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.4H" } }, "Architectures": [ @@ -280500,16 +283182,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u64_u8", + "name": "vreinterpret_u64_s32", "arguments": [ - "uint8x8_t a" + "int32x2_t a" ], "return_type": { "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.2S" } }, "Architectures": [ @@ -280525,16 +283207,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_f16", + "name": "vreinterpret_u64_s64", "arguments": [ - "float16x4_t a" + "int64x1_t a" ], "return_type": { - "value": "uint8x8_t" + "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.1D" } }, "Architectures": [ @@ -280550,16 +283232,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_f32", + "name": "vreinterpret_u64_s8", "arguments": [ - "float32x2_t a" + "int8x8_t a" ], "return_type": { - "value": "uint8x8_t" + "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2S" + "register": "Vd.8B" } }, "Architectures": [ @@ -280575,19 +283257,21 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_f64", + "name": "vreinterpret_u64_u16", "arguments": [ - "float64x1_t a" + "uint16x4_t a" ], "return_type": { - "value": "uint8x8_t" + "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.4H" } }, "Architectures": [ + "v7", + "A32", "A64" ], "instructions": [ @@ -280598,16 +283282,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_p16", + "name": "vreinterpret_u64_u32", "arguments": [ - "poly16x4_t a" + "uint32x2_t a" ], "return_type": { - "value": "uint8x8_t" + "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4H" + "register": "Vd.2S" } }, "Architectures": [ @@ -280623,19 +283307,20 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_p64", + "name": "vreinterpret_u64_u8", "arguments": [ - "poly64x1_t a" + "uint8x8_t a" ], "return_type": { - "value": "uint8x8_t" + "value": "uint64x1_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.1D" + "register": "Vd.8B" } }, "Architectures": [ + "v7", "A32", "A64" ], @@ -280647,20 +283332,19 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_p8", + "name": "vreinterpret_u8_bf16", "arguments": [ - "poly8x8_t a" + "bfloat16x4_t a" ], "return_type": { "value": "uint8x8_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8B" + "register": "Vd.4H" } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -280672,9 +283356,156 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpret_u8_s16", + "name": "vreinterpret_u8_f16", "arguments": [ - "int16x4_t a" + "float16x4_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_f32", + "arguments": [ + "float32x2_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_f64", + "arguments": [ + "float64x1_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_p16", + "arguments": [ + "poly16x4_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_p64", + "arguments": [ + "poly64x1_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_p8", + "arguments": [ + "poly8x8_t a" + ], + "return_type": { + "value": "uint8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpret_u8_s16", + "arguments": [ + "int16x4_t a" ], "return_type": { "value": "uint8x8_t" @@ -280845,6 +283676,341 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_f32", + "arguments": [ + "float32x4_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_f64", + "arguments": [ + "float64x2_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_p128", + "arguments": [ + "poly128_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1Q" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_p16", + "arguments": [ + "poly16x8_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_p64", + "arguments": [ + "poly64x2_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_p8", + "arguments": [ + "poly8x16_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_s16", + "arguments": [ + "int16x8_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_s32", + "arguments": [ + "int32x4_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_s64", + "arguments": [ + "int64x2_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_s8", + "arguments": [ + "int8x16_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_u16", + "arguments": [ + "uint16x8_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_u32", + "arguments": [ + "uint32x4_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_u64", + "arguments": [ + "uint64x2_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_bf16_u8", + "arguments": [ + "uint8x16_t a" + ], + "return_type": { + "value": "bfloat16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_f16_f32", @@ -280993,9 +284159,109 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_s16", + "name": "vreinterpretq_f16_s16", + "arguments": [ + "int16x8_t a" + ], + "return_type": { + "value": "float16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_f16_s32", + "arguments": [ + "int32x4_t a" + ], + "return_type": { + "value": "float16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_f16_s64", + "arguments": [ + "int64x2_t a" + ], + "return_type": { + "value": "float16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_f16_s8", + "arguments": [ + "int8x16_t a" + ], + "return_type": { + "value": "float16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_f16_u16", "arguments": [ - "int16x8_t a" + "uint16x8_t a" ], "return_type": { "value": "float16x8_t" @@ -281018,9 +284284,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_s32", + "name": "vreinterpretq_f16_u32", "arguments": [ - "int32x4_t a" + "uint32x4_t a" ], "return_type": { "value": "float16x8_t" @@ -281043,9 +284309,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_s64", + "name": "vreinterpretq_f16_u64", "arguments": [ - "int64x2_t a" + "uint64x2_t a" ], "return_type": { "value": "float16x8_t" @@ -281068,9 +284334,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_s8", + "name": "vreinterpretq_f16_u8", "arguments": [ - "int8x16_t a" + "uint8x16_t a" ], "return_type": { "value": "float16x8_t" @@ -281093,12 +284359,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_u16", + "name": "vreinterpretq_f32_bf16", "arguments": [ - "uint16x8_t a" + "bfloat16x8_t a" ], "return_type": { - "value": "float16x8_t" + "value": "float32x4_t" }, "Arguments_Preparation": { "a": { @@ -281106,82 +284372,6 @@ } }, "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_u32", - "arguments": [ - "uint32x4_t a" - ], - "return_type": { - "value": "float16x8_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.4S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_u64", - "arguments": [ - "uint64x2_t a" - ], - "return_type": { - "value": "float16x8_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.2D" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_f16_u8", - "arguments": [ - "uint8x16_t a" - ], - "return_type": { - "value": "float16x8_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.16B" - } - }, - "Architectures": [ - "v7", "A32", "A64" ], @@ -281489,6 +284679,29 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_f64_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "float64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_f64_f16", @@ -281813,6 +285026,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_p128_f16", @@ -281863,9 +285100,128 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_f64", + "name": "vreinterpretq_p128_f64", + "arguments": [ + "float64x2_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.1Q" + } + }, + "Architectures": [ + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_p16", + "arguments": [ + "poly16x8_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_p8", + "arguments": [ + "poly8x16_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_s16", + "arguments": [ + "int16x8_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_s32", + "arguments": [ + "int32x4_t a" + ], + "return_type": { + "value": "poly128_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p128_s64", "arguments": [ - "float64x2_t a" + "int64x2_t a" ], "return_type": { "value": "poly128_t" @@ -281875,29 +285231,6 @@ "register": "Vd.1Q" } }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_p16", - "arguments": [ - "poly16x8_t a" - ], - "return_type": { - "value": "poly128_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.8H" - } - }, "Architectures": [ "A32", "A64" @@ -281910,9 +285243,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_p8", + "name": "vreinterpretq_p128_s8", "arguments": [ - "poly8x16_t a" + "int8x16_t a" ], "return_type": { "value": "poly128_t" @@ -281934,9 +285267,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_s16", + "name": "vreinterpretq_p128_u16", "arguments": [ - "int16x8_t a" + "uint16x8_t a" ], "return_type": { "value": "poly128_t" @@ -281958,9 +285291,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_s32", + "name": "vreinterpretq_p128_u32", "arguments": [ - "int32x4_t a" + "uint32x4_t a" ], "return_type": { "value": "poly128_t" @@ -281982,9 +285315,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_s64", + "name": "vreinterpretq_p128_u64", "arguments": [ - "int64x2_t a" + "uint64x2_t a" ], "return_type": { "value": "poly128_t" @@ -282006,9 +285339,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_s8", + "name": "vreinterpretq_p128_u8", "arguments": [ - "int8x16_t a" + "uint8x16_t a" ], "return_type": { "value": "poly128_t" @@ -282030,12 +285363,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_u16", + "name": "vreinterpretq_p16_bf16", "arguments": [ - "uint16x8_t a" + "bfloat16x8_t a" ], "return_type": { - "value": "poly128_t" + "value": "poly16x8_t" }, "Arguments_Preparation": { "a": { @@ -282052,78 +285385,6 @@ ] ] }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_u32", - "arguments": [ - "uint32x4_t a" - ], - "return_type": { - "value": "poly128_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.4S" - } - }, - "Architectures": [ - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_u64", - "arguments": [ - "uint64x2_t a" - ], - "return_type": { - "value": "poly128_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.1Q" - } - }, - "Architectures": [ - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_p128_u8", - "arguments": [ - "uint8x16_t a" - ], - "return_type": { - "value": "poly128_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.16B" - } - }, - "Architectures": [ - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_p16_f16", @@ -282470,6 +285731,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p64_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "poly64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_p64_f16", @@ -282781,6 +286066,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_p8_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "poly8x16_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_p8_f16", @@ -283127,6 +286436,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s16_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "int16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_s16_f16", @@ -283473,6 +286806,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s32_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "int32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_s32_f16", @@ -283646,9 +287003,84 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_s16", + "name": "vreinterpretq_s32_s16", + "arguments": [ + "int16x8_t a" + ], + "return_type": { + "value": "int32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s32_s64", + "arguments": [ + "int64x2_t a" + ], + "return_type": { + "value": "int32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s32_s8", + "arguments": [ + "int8x16_t a" + ], + "return_type": { + "value": "int32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s32_u16", "arguments": [ - "int16x8_t a" + "uint16x8_t a" ], "return_type": { "value": "int32x4_t" @@ -283671,66 +287103,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_s64", - "arguments": [ - "int64x2_t a" - ], - "return_type": { - "value": "int32x4_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.2D" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_s8", - "arguments": [ - "int8x16_t a" - ], - "return_type": { - "value": "int32x4_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.16B" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_u16", + "name": "vreinterpretq_s32_u32", "arguments": [ - "uint16x8_t a" + "uint32x4_t a" ], "return_type": { "value": "int32x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.8H" + "register": "Vd.4S" } }, "Architectures": [ @@ -283746,16 +287128,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_u32", + "name": "vreinterpretq_s32_u64", "arguments": [ - "uint32x4_t a" + "uint64x2_t a" ], "return_type": { "value": "int32x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.4S" + "register": "Vd.2D" } }, "Architectures": [ @@ -283771,16 +287153,16 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_u64", + "name": "vreinterpretq_s32_u8", "arguments": [ - "uint64x2_t a" + "uint8x16_t a" ], "return_type": { "value": "int32x4_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.2D" + "register": "Vd.16B" } }, "Architectures": [ @@ -283796,20 +287178,19 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_s32_u8", + "name": "vreinterpretq_s64_bf16", "arguments": [ - "uint8x16_t a" + "bfloat16x8_t a" ], "return_type": { - "value": "int32x4_t" + "value": "int64x2_t" }, "Arguments_Preparation": { "a": { - "register": "Vd.16B" + "register": "Vd.8H" } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -284165,6 +287546,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_s8_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "int8x16_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_s8_f16", @@ -284511,6 +287916,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u16_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "uint16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_u16_f16", @@ -284857,6 +288286,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u32_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "uint32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_u32_f16", @@ -285203,6 +288656,30 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u64_bf16", + "arguments": [ + "bfloat16x8_t a" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vreinterpretq_u64_f16", @@ -285376,9 +288853,109 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_s16", + "name": "vreinterpretq_u64_s16", + "arguments": [ + "int16x8_t a" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u64_s32", + "arguments": [ + "int32x4_t a" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u64_s64", + "arguments": [ + "int64x2_t a" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u64_s8", + "arguments": [ + "int8x16_t a" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "NOP" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vreinterpretq_u64_u16", "arguments": [ - "int16x8_t a" + "uint16x8_t a" ], "return_type": { "value": "uint64x2_t" @@ -285401,9 +288978,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_s32", + "name": "vreinterpretq_u64_u32", "arguments": [ - "int32x4_t a" + "uint32x4_t a" ], "return_type": { "value": "uint64x2_t" @@ -285426,34 +289003,9 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_s64", - "arguments": [ - "int64x2_t a" - ], - "return_type": { - "value": "uint64x2_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.2D" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_s8", + "name": "vreinterpretq_u64_u8", "arguments": [ - "int8x16_t a" + "uint8x16_t a" ], "return_type": { "value": "uint64x2_t" @@ -285476,12 +289028,12 @@ }, { "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_u16", + "name": "vreinterpretq_u8_bf16", "arguments": [ - "uint16x8_t a" + "bfloat16x8_t a" ], "return_type": { - "value": "uint64x2_t" + "value": "uint8x16_t" }, "Arguments_Preparation": { "a": { @@ -285489,57 +289041,6 @@ } }, "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_u32", - "arguments": [ - "uint32x4_t a" - ], - "return_type": { - "value": "uint64x2_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.4S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "NOP" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vreinterpretq_u64_u8", - "arguments": [ - "uint8x16_t a" - ], - "return_type": { - "value": "uint64x2_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Vd.16B" - } - }, - "Architectures": [ - "v7", "A32", "A64" ], @@ -291788,6 +295289,39 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vset_lane_bf16", + "arguments": [ + "bfloat16_t a", + "bfloat16x4_t v", + "const int lane" + ], + "return_type": { + "value": "bfloat16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "VnH" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "v": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "INS" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vset_lane_f16", @@ -292093,14 +295627,150 @@ }, { "SIMD_ISA": "Neon", - "name": "vset_lane_s8", + "name": "vset_lane_s8", + "arguments": [ + "int8_t a", + "int8x8_t v", + "const int lane" + ], + "return_type": { + "value": "int8x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Rn" + }, + "lane": { + "minimum": 0, + "maximum": 7 + }, + "v": { + "register": "Vd.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "MOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vset_lane_u16", + "arguments": [ + "uint16_t a", + "uint16x4_t v", + "const int lane" + ], + "return_type": { + "value": "uint16x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Rn" + }, + "lane": { + "minimum": 0, + "maximum": 3 + }, + "v": { + "register": "Vd.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "MOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vset_lane_u32", + "arguments": [ + "uint32_t a", + "uint32x2_t v", + "const int lane" + ], + "return_type": { + "value": "uint32x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Rn" + }, + "lane": { + "minimum": 0, + "maximum": 1 + }, + "v": { + "register": "Vd.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "MOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vset_lane_u64", + "arguments": [ + "uint64_t a", + "uint64x1_t v", + "const int lane" + ], + "return_type": { + "value": "uint64x1_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Rn" + }, + "lane": { + "minimum": 0, + "maximum": 0 + }, + "v": { + "register": "Vd.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "MOV" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vset_lane_u8", "arguments": [ - "int8_t a", - "int8x8_t v", + "uint8_t a", + "uint8x8_t v", "const int lane" ], "return_type": { - "value": "int8x8_t" + "value": "uint8x8_t" }, "Arguments_Preparation": { "a": { @@ -292127,137 +295797,34 @@ }, { "SIMD_ISA": "Neon", - "name": "vset_lane_u16", + "name": "vsetq_lane_bf16", "arguments": [ - "uint16_t a", - "uint16x4_t v", + "bfloat16_t a", + "bfloat16x8_t v", "const int lane" ], "return_type": { - "value": "uint16x4_t" + "value": "bfloat16x8_t" }, "Arguments_Preparation": { "a": { - "register": "Rn" - }, - "lane": { - "minimum": 0, - "maximum": 3 - }, - "v": { - "register": "Vd.4H" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "MOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vset_lane_u32", - "arguments": [ - "uint32_t a", - "uint32x2_t v", - "const int lane" - ], - "return_type": { - "value": "uint32x2_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Rn" - }, - "lane": { - "minimum": 0, - "maximum": 1 - }, - "v": { - "register": "Vd.2S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "MOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vset_lane_u64", - "arguments": [ - "uint64_t a", - "uint64x1_t v", - "const int lane" - ], - "return_type": { - "value": "uint64x1_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Rn" - }, - "lane": { - "minimum": 0, - "maximum": 0 - }, - "v": { - "register": "Vd.1D" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "MOV" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vset_lane_u8", - "arguments": [ - "uint8_t a", - "uint8x8_t v", - "const int lane" - ], - "return_type": { - "value": "uint8x8_t" - }, - "Arguments_Preparation": { - "a": { - "register": "Rn" + "register": "VnH" }, "lane": { "minimum": 0, "maximum": 7 }, "v": { - "register": "Vd.8B" + "register": "Vd.8H" } }, "Architectures": [ - "v7", "A32", "A64" ], "instructions": [ [ - "MOV" + "INS" ] ] }, @@ -298339,137 +301906,267 @@ }, { "SIMD_ISA": "Neon", - "name": "vsriq_n_u16", + "name": "vsriq_n_u16", + "arguments": [ + "uint16x8_t a", + "uint16x8_t b", + "const int n" + ], + "return_type": { + "value": "uint16x8_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.8H" + }, + "b": { + "register": "Vn.8H" + }, + "n": { + "minimum": 1, + "maximum": 16 + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SRI" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vsriq_n_u32", + "arguments": [ + "uint32x4_t a", + "uint32x4_t b", + "const int n" + ], + "return_type": { + "value": "uint32x4_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.4S" + }, + "b": { + "register": "Vn.4S" + }, + "n": { + "minimum": 1, + "maximum": 32 + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SRI" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vsriq_n_u64", + "arguments": [ + "uint64x2_t a", + "uint64x2_t b", + "const int n" + ], + "return_type": { + "value": "uint64x2_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.2D" + }, + "b": { + "register": "Vn.2D" + }, + "n": { + "minimum": 1, + "maximum": 64 + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SRI" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vsriq_n_u8", + "arguments": [ + "uint8x16_t a", + "uint8x16_t b", + "const int n" + ], + "return_type": { + "value": "uint8x16_t" + }, + "Arguments_Preparation": { + "a": { + "register": "Vd.16B" + }, + "b": { + "register": "Vn.16B" + }, + "n": { + "minimum": 1, + "maximum": 8 + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "SRI" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst1_bf16", "arguments": [ - "uint16x8_t a", - "uint16x8_t b", - "const int n" + "bfloat16_t * ptr", + "bfloat16x4_t val" ], "return_type": { - "value": "uint16x8_t" + "value": "void" }, "Arguments_Preparation": { - "a": { - "register": "Vd.8H" - }, - "b": { - "register": "Vn.8H" + "ptr": { + "register": "Xn" }, - "n": { - "minimum": 1, - "maximum": 16 + "val": { + "register": "Vt.4H" } }, "Architectures": [ - "v7", "A32", "A64" ], "instructions": [ [ - "SRI" + "ST1" ] ] }, { "SIMD_ISA": "Neon", - "name": "vsriq_n_u32", + "name": "vst1_bf16_x2", "arguments": [ - "uint32x4_t a", - "uint32x4_t b", - "const int n" + "bfloat16_t * ptr", + "bfloat16x4x2_t val" ], "return_type": { - "value": "uint32x4_t" + "value": "void" }, "Arguments_Preparation": { - "a": { - "register": "Vd.4S" + "ptr": { + "register": "Xn" }, - "b": { - "register": "Vn.4S" + "val.val[0]": { + "register": "Vt.4H" }, - "n": { - "minimum": 1, - "maximum": 32 + "val.val[1]": { + "register": "Vt2.4H" } }, "Architectures": [ - "v7", "A32", "A64" ], "instructions": [ [ - "SRI" + "ST1" ] ] }, { "SIMD_ISA": "Neon", - "name": "vsriq_n_u64", + "name": "vst1_bf16_x3", "arguments": [ - "uint64x2_t a", - "uint64x2_t b", - "const int n" + "bfloat16_t * ptr", + "bfloat16x4x3_t val" ], "return_type": { - "value": "uint64x2_t" + "value": "void" }, "Arguments_Preparation": { - "a": { - "register": "Vd.2D" + "ptr": { + "register": "Xn" }, - "b": { - "register": "Vn.2D" + "val.val[0]": { + "register": "Vt.4H" }, - "n": { - "minimum": 1, - "maximum": 64 + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" } }, "Architectures": [ - "v7", "A32", "A64" ], "instructions": [ [ - "SRI" + "ST1" ] ] }, { "SIMD_ISA": "Neon", - "name": "vsriq_n_u8", + "name": "vst1_bf16_x4", "arguments": [ - "uint8x16_t a", - "uint8x16_t b", - "const int n" + "bfloat16_t * ptr", + "bfloat16x4x4_t val" ], "return_type": { - "value": "uint8x16_t" + "value": "void" }, "Arguments_Preparation": { - "a": { - "register": "Vd.16B" + "ptr": { + "register": "Xn" }, - "b": { - "register": "Vn.16B" + "val.val[0]": { + "register": "Vt.4H" }, - "n": { - "minimum": 1, - "maximum": 8 + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + }, + "val.val[3]": { + "register": "Vt4.4H" } }, "Architectures": [ - "v7", "A32", "A64" ], "instructions": [ [ - "SRI" + "ST1" ] ] }, @@ -298867,6 +302564,39 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst1_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "val": { + "register": "Vt.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst1_lane_f16", @@ -300846,6 +304576,136 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst1q_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val": { + "register": "Vt.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst1q_bf16_x2", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x2_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst1q_bf16_x3", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + }, + "val.val[2]": { + "register": "Vt3.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst1q_bf16_x4", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x4_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + }, + "val.val[2]": { + "register": "Vt3.8H" + }, + "val.val[3]": { + "register": "Vt4.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst1q_f16", @@ -301240,6 +305100,39 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst1q_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "val": { + "register": "Vt.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst1q_lane_f16", @@ -303220,6 +307113,37 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst2_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x2_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst2_f16", @@ -303314,6 +307238,42 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst2_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x2_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst2_lane_f16", @@ -304175,6 +308135,37 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst2q_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x2_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst2q_f16", @@ -304269,6 +308260,42 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst2q_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x2_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST2" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst2q_lane_f16", @@ -305119,6 +309146,40 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst3_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST3" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst3_f16", @@ -305222,6 +309283,45 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst3_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x3_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST3" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst3_lane_f16", @@ -306020,10 +310120,150 @@ }, { "SIMD_ISA": "Neon", - "name": "vst3_u16", + "name": "vst3_u16", + "arguments": [ + "uint16_t * ptr", + "uint16x4x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "ST3" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst3_u32", + "arguments": [ + "uint32_t * ptr", + "uint32x2x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.2S" + }, + "val.val[1]": { + "register": "Vt2.2S" + }, + "val.val[2]": { + "register": "Vt3.2S" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "ST3" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst3_u64", + "arguments": [ + "uint64_t * ptr", + "uint64x1x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.1D" + }, + "val.val[1]": { + "register": "Vt2.1D" + }, + "val.val[2]": { + "register": "Vt3.1D" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "ST1" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst3_u8", + "arguments": [ + "uint8_t * ptr", + "uint8x8x3_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8B" + }, + "val.val[1]": { + "register": "Vt2.8B" + }, + "val.val[2]": { + "register": "Vt3.8B" + } + }, + "Architectures": [ + "v7", + "A32", + "A64" + ], + "instructions": [ + [ + "ST3" + ] + ] + }, + { + "SIMD_ISA": "Neon", + "name": "vst3q_bf16", "arguments": [ - "uint16_t * ptr", - "uint16x4x3_t val" + "bfloat16_t * ptr", + "bfloat16x8x3_t val" ], "return_type": { "value": "void" @@ -306033,17 +310273,16 @@ "register": "Xn" }, "val.val[0]": { - "register": "Vt.4H" + "register": "Vt.8H" }, "val.val[1]": { - "register": "Vt2.4H" + "register": "Vt2.8H" }, "val.val[2]": { - "register": "Vt3.4H" + "register": "Vt3.8H" } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -306055,10 +310294,10 @@ }, { "SIMD_ISA": "Neon", - "name": "vst3_u32", + "name": "vst3q_f16", "arguments": [ - "uint32_t * ptr", - "uint32x2x3_t val" + "float16_t * ptr", + "float16x8x3_t val" ], "return_type": { "value": "void" @@ -306068,13 +310307,13 @@ "register": "Xn" }, "val.val[0]": { - "register": "Vt.2S" + "register": "Vt.8H" }, "val.val[1]": { - "register": "Vt2.2S" + "register": "Vt2.8H" }, "val.val[2]": { - "register": "Vt3.2S" + "register": "Vt3.8H" } }, "Architectures": [ @@ -306090,10 +310329,10 @@ }, { "SIMD_ISA": "Neon", - "name": "vst3_u64", + "name": "vst3q_f32", "arguments": [ - "uint64_t * ptr", - "uint64x1x3_t val" + "float32_t * ptr", + "float32x4x3_t val" ], "return_type": { "value": "void" @@ -306103,13 +310342,13 @@ "register": "Xn" }, "val.val[0]": { - "register": "Vt.1D" + "register": "Vt.4S" }, "val.val[1]": { - "register": "Vt2.1D" + "register": "Vt2.4S" }, "val.val[2]": { - "register": "Vt3.1D" + "register": "Vt3.4S" } }, "Architectures": [ @@ -306119,16 +310358,16 @@ ], "instructions": [ [ - "ST1" + "ST3" ] ] }, { "SIMD_ISA": "Neon", - "name": "vst3_u8", + "name": "vst3q_f64", "arguments": [ - "uint8_t * ptr", - "uint8x8x3_t val" + "float64_t * ptr", + "float64x2x3_t val" ], "return_type": { "value": "void" @@ -306138,18 +310377,16 @@ "register": "Xn" }, "val.val[0]": { - "register": "Vt.8B" + "register": "Vt.2D" }, "val.val[1]": { - "register": "Vt2.8B" + "register": "Vt2.2D" }, "val.val[2]": { - "register": "Vt3.8B" + "register": "Vt3.2D" } }, "Architectures": [ - "v7", - "A32", "A64" ], "instructions": [ @@ -306160,15 +310397,20 @@ }, { "SIMD_ISA": "Neon", - "name": "vst3q_f16", + "name": "vst3q_lane_bf16", "arguments": [ - "float16_t * ptr", - "float16x8x3_t val" + "bfloat16_t * ptr", + "bfloat16x8x3_t val", + "const int lane" ], "return_type": { "value": "void" }, "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, "ptr": { "register": "Xn" }, @@ -306183,7 +310425,6 @@ } }, "Architectures": [ - "v7", "A32", "A64" ], @@ -306193,74 +310434,6 @@ ] ] }, - { - "SIMD_ISA": "Neon", - "name": "vst3q_f32", - "arguments": [ - "float32_t * ptr", - "float32x4x3_t val" - ], - "return_type": { - "value": "void" - }, - "Arguments_Preparation": { - "ptr": { - "register": "Xn" - }, - "val.val[0]": { - "register": "Vt.4S" - }, - "val.val[1]": { - "register": "Vt2.4S" - }, - "val.val[2]": { - "register": "Vt3.4S" - } - }, - "Architectures": [ - "v7", - "A32", - "A64" - ], - "instructions": [ - [ - "ST3" - ] - ] - }, - { - "SIMD_ISA": "Neon", - "name": "vst3q_f64", - "arguments": [ - "float64_t * ptr", - "float64x2x3_t val" - ], - "return_type": { - "value": "void" - }, - "Arguments_Preparation": { - "ptr": { - "register": "Xn" - }, - "val.val[0]": { - "register": "Vt.2D" - }, - "val.val[1]": { - "register": "Vt2.2D" - }, - "val.val[2]": { - "register": "Vt3.2D" - } - }, - "Architectures": [ - "A64" - ], - "instructions": [ - [ - "ST3" - ] - ] - }, { "SIMD_ISA": "Neon", "name": "vst3q_lane_f16", @@ -307192,6 +311365,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst4_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x4_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + }, + "val.val[3]": { + "register": "Vt4.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst4_f16", @@ -307304,6 +311514,48 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst4_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x4x4_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 3 + }, + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.4H" + }, + "val.val[1]": { + "register": "Vt2.4H" + }, + "val.val[2]": { + "register": "Vt3.4H" + }, + "val.val[3]": { + "register": "Vt4.4H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst4_lane_f16", @@ -308315,6 +312567,43 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst4q_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x4_t val" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + }, + "val.val[2]": { + "register": "Vt3.8H" + }, + "val.val[3]": { + "register": "Vt4.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst4q_f16", @@ -308427,6 +312716,48 @@ ] ] }, + { + "SIMD_ISA": "Neon", + "name": "vst4q_lane_bf16", + "arguments": [ + "bfloat16_t * ptr", + "bfloat16x8x4_t val", + "const int lane" + ], + "return_type": { + "value": "void" + }, + "Arguments_Preparation": { + "lane": { + "minimum": 0, + "maximum": 7 + }, + "ptr": { + "register": "Xn" + }, + "val.val[0]": { + "register": "Vt.8H" + }, + "val.val[1]": { + "register": "Vt2.8H" + }, + "val.val[2]": { + "register": "Vt3.8H" + }, + "val.val[3]": { + "register": "Vt4.8H" + } + }, + "Architectures": [ + "A32", + "A64" + ], + "instructions": [ + [ + "ST4" + ] + ] + }, { "SIMD_ISA": "Neon", "name": "vst4q_lane_f16", diff --git a/library/stdarch/rust-version b/library/stdarch/rust-version index e4f77638aebc8..30b1b9cf6bef6 100644 --- a/library/stdarch/rust-version +++ b/library/stdarch/rust-version @@ -1 +1 @@ -16d1ffac17ad8b739e32483ac2e65fe7e1804977 +4de190d26178bb0c22ed4c005679bb621f7e9c18 diff --git a/library/unwind/src/types.rs b/library/unwind/src/types.rs index d299d8e7e2252..d745b836e822b 100644 --- a/library/unwind/src/types.rs +++ b/library/unwind/src/types.rs @@ -19,28 +19,27 @@ pub use _Unwind_Reason_Code::*; pub type _Unwind_Exception_Class = u64; pub type _Unwind_Word = *const u8; -pub const unwinder_private_data_size: usize = - cfg_select! { - target_arch = "x86" => 5, - all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))) => 2, - all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")) => 6, - all(target_arch = "arm", not(target_vendor = "apple")) => 20, - all(target_arch = "arm", target_vendor = "apple") => 5, - all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")) => 2, - all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows") => 6, - all(target_arch = "aarch64", target_pointer_width = "32") => 5, - target_arch = "m68k" => 2, - any(target_arch = "mips", target_arch = "mips32r6") => 2, - target_arch = "csky" => 2, - any(target_arch = "mips64", target_arch = "mips64r6") => 2, - any(target_arch = "powerpc", target_arch = "powerpc64") => 2, - target_arch = "s390x" => 2, - any(target_arch = "sparc", target_arch = "sparc64") => 2, - any(target_arch = "riscv64", target_arch = "riscv32") => 2, - target_family = "wasm" => 2, - target_arch = "hexagon" => 5, - any(target_arch = "loongarch32", target_arch = "loongarch64") => 2, - }; +pub const unwinder_private_data_size: usize = cfg_select! { + target_arch = "x86" => 5, + all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))) => 2, + all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")) => 6, + all(target_arch = "arm", not(target_vendor = "apple")) => 20, + all(target_arch = "arm", target_vendor = "apple") => 5, + all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")) => 2, + all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows") => 6, + all(target_arch = "aarch64", target_pointer_width = "32") => 5, + target_arch = "m68k" => 2, + any(target_arch = "mips", target_arch = "mips32r6") => 2, + target_arch = "csky" => 2, + any(target_arch = "mips64", target_arch = "mips64r6") => 2, + any(target_arch = "powerpc", target_arch = "powerpc64") => 2, + target_arch = "s390x" => 2, + any(target_arch = "sparc", target_arch = "sparc64") => 2, + any(target_arch = "riscv64", target_arch = "riscv32") => 2, + target_family = "wasm" => 2, + target_arch = "hexagon" => 5, + any(target_arch = "loongarch32", target_arch = "loongarch64") => 2, +}; #[repr(C)] // The Itanium C++ ABI requires this type to have "double-word" alignment, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7509dd7d336f3..5a1c0fb8753ba 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # standard library we currently track. [toolchain] -channel = "nightly-2026-11-12" +channel = "nightly-2026-11-19" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] diff --git a/tool_config/kani-version.toml b/tool_config/kani-version.toml index ae2781ce7747e..c864abe9aa242 100644 --- a/tool_config/kani-version.toml +++ b/tool_config/kani-version.toml @@ -2,4 +2,4 @@ # incompatible with the verify-std repo. [kani] -commit = "53cb5317eef5f0ae9fa7c3d20de908f0559c4535" +commit = "9834c96ce90ff57d8495416530b080dc3d52ce25" diff --git a/verifast-proofs/alloc/collections/linked_list.rs-negative/original/linked_list.rs b/verifast-proofs/alloc/collections/linked_list.rs-negative/original/linked_list.rs index 38c1e770e6981..07d7a62a03b24 100644 --- a/verifast-proofs/alloc/collections/linked_list.rs-negative/original/linked_list.rs +++ b/verifast-proofs/alloc/collections/linked_list.rs-negative/original/linked_list.rs @@ -689,7 +689,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.head.is_none() } @@ -717,7 +717,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.len diff --git a/verifast-proofs/alloc/collections/linked_list.rs-negative/verified/linked_list.rs b/verifast-proofs/alloc/collections/linked_list.rs-negative/verified/linked_list.rs index 0216fcade4086..4939baa730fad 100644 --- a/verifast-proofs/alloc/collections/linked_list.rs-negative/verified/linked_list.rs +++ b/verifast-proofs/alloc/collections/linked_list.rs-negative/verified/linked_list.rs @@ -851,7 +851,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.head.is_none() } @@ -879,7 +879,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.len diff --git a/verifast-proofs/alloc/collections/linked_list.rs/original/linked_list.rs b/verifast-proofs/alloc/collections/linked_list.rs/original/linked_list.rs index 38c1e770e6981..07d7a62a03b24 100644 --- a/verifast-proofs/alloc/collections/linked_list.rs/original/linked_list.rs +++ b/verifast-proofs/alloc/collections/linked_list.rs/original/linked_list.rs @@ -689,7 +689,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.head.is_none() } @@ -717,7 +717,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize { self.len diff --git a/verifast-proofs/alloc/collections/linked_list.rs/verified/linked_list.rs b/verifast-proofs/alloc/collections/linked_list.rs/verified/linked_list.rs index 199f6b48e9f38..8e47548528d6b 100644 --- a/verifast-proofs/alloc/collections/linked_list.rs/verified/linked_list.rs +++ b/verifast-proofs/alloc/collections/linked_list.rs/verified/linked_list.rs @@ -1904,7 +1904,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] pub const fn is_empty(&self) -> bool { self.head.is_none() } @@ -1932,7 +1932,7 @@ impl LinkedList { #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_linked_list_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_linked_list_len", since = "1.101.0")] #[rustc_confusables("length", "size")] pub const fn len(&self) -> usize //@ req [?f](*self).len |-> ?len;