-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #113437 - workingjubilee:sync-simd-2023-july-07, r=work…
…ingjubilee Sync portable-simd to 2023 July 07 r? `@ghost`
- Loading branch information
Showing
19 changed files
with
339 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,51 @@ | ||
use crate::simd::SimdElement; | ||
|
||
mod sealed { | ||
/// Cast vector elements to other types. | ||
/// | ||
/// # Safety | ||
/// Implementing this trait asserts that the type is a valid vector element for the `simd_cast` | ||
/// or `simd_as` intrinsics. | ||
pub unsafe trait Sealed {} | ||
} | ||
use sealed::Sealed; | ||
|
||
/// Supporting trait for `Simd::cast`. Typically doesn't need to be used directly. | ||
/// | ||
/// # Safety | ||
/// Implementing this trait asserts that the type is a valid vector element for the `simd_cast` or | ||
/// `simd_as` intrinsics. | ||
pub unsafe trait SimdCast: SimdElement {} | ||
pub trait SimdCast: Sealed + SimdElement {} | ||
|
||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for i8 {} | ||
unsafe impl Sealed for i8 {} | ||
impl SimdCast for i8 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for i16 {} | ||
unsafe impl Sealed for i16 {} | ||
impl SimdCast for i16 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for i32 {} | ||
unsafe impl Sealed for i32 {} | ||
impl SimdCast for i32 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for i64 {} | ||
unsafe impl Sealed for i64 {} | ||
impl SimdCast for i64 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for isize {} | ||
unsafe impl Sealed for isize {} | ||
impl SimdCast for isize {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for u8 {} | ||
unsafe impl Sealed for u8 {} | ||
impl SimdCast for u8 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for u16 {} | ||
unsafe impl Sealed for u16 {} | ||
impl SimdCast for u16 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for u32 {} | ||
unsafe impl Sealed for u32 {} | ||
impl SimdCast for u32 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for u64 {} | ||
unsafe impl Sealed for u64 {} | ||
impl SimdCast for u64 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for usize {} | ||
unsafe impl Sealed for usize {} | ||
impl SimdCast for usize {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for f32 {} | ||
unsafe impl Sealed for f32 {} | ||
impl SimdCast for f32 {} | ||
// Safety: primitive number types can be cast to other primitive number types | ||
unsafe impl SimdCast for f64 {} | ||
|
||
/// Supporting trait for `Simd::cast_ptr`. Typically doesn't need to be used directly. | ||
/// | ||
/// # Safety | ||
/// Implementing this trait asserts that the type is a valid vector element for the `simd_cast_ptr` | ||
/// intrinsic. | ||
pub unsafe trait SimdCastPtr<T> {} | ||
|
||
// Safety: pointers can be cast to other pointer types | ||
unsafe impl<T, U> SimdCastPtr<T> for *const U | ||
where | ||
U: core::ptr::Pointee, | ||
T: core::ptr::Pointee<Metadata = U::Metadata>, | ||
{ | ||
} | ||
// Safety: pointers can be cast to other pointer types | ||
unsafe impl<T, U> SimdCastPtr<T> for *mut U | ||
where | ||
U: core::ptr::Pointee, | ||
T: core::ptr::Pointee<Metadata = U::Metadata>, | ||
{ | ||
} | ||
unsafe impl Sealed for f64 {} | ||
impl SimdCast for f64 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.