Add missing pointer tests and rename pointer cast fns to match scalars
This commit is contained in:
parent
de30820035
commit
572122a95d
@ -19,7 +19,9 @@ pub trait SimdConstPtr: Copy + Sealed {
|
|||||||
fn is_null(self) -> Self::Mask;
|
fn is_null(self) -> Self::Mask;
|
||||||
|
|
||||||
/// Changes constness without changing the type.
|
/// Changes constness without changing the type.
|
||||||
fn as_mut(self) -> Self::MutPtr;
|
///
|
||||||
|
/// Equivalent to calling [`pointer::cast_mut`] on each lane.
|
||||||
|
fn cast_mut(self) -> Self::MutPtr;
|
||||||
|
|
||||||
/// Gets the "address" portion of the pointer.
|
/// Gets the "address" portion of the pointer.
|
||||||
///
|
///
|
||||||
@ -85,7 +87,7 @@ fn is_null(self) -> Self::Mask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut(self) -> Self::MutPtr {
|
fn cast_mut(self) -> Self::MutPtr {
|
||||||
self.cast_ptr()
|
self.cast_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@ pub trait SimdMutPtr: Copy + Sealed {
|
|||||||
fn is_null(self) -> Self::Mask;
|
fn is_null(self) -> Self::Mask;
|
||||||
|
|
||||||
/// Changes constness without changing the type.
|
/// Changes constness without changing the type.
|
||||||
fn as_const(self) -> Self::ConstPtr;
|
///
|
||||||
|
/// Equivalent to calling [`pointer::cast_const`] on each lane.
|
||||||
|
fn cast_const(self) -> Self::ConstPtr;
|
||||||
|
|
||||||
/// Gets the "address" portion of the pointer.
|
/// Gets the "address" portion of the pointer.
|
||||||
///
|
///
|
||||||
@ -80,7 +82,7 @@ fn is_null(self) -> Self::Mask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_const(self) -> Self::ConstPtr {
|
fn cast_const(self) -> Self::ConstPtr {
|
||||||
self.cast_ptr()
|
self.cast_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,22 @@ fn addr<const LANES: usize>() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn with_addr<const LANES: usize>() {
|
||||||
|
test_helpers::test_binary_elementwise(
|
||||||
|
&Simd::<*$constness u32, LANES>::with_addr,
|
||||||
|
&<*$constness u32>::with_addr,
|
||||||
|
&|_, _| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expose_addr<const LANES: usize>() {
|
||||||
|
test_helpers::test_unary_elementwise(
|
||||||
|
&Simd::<*$constness u32, LANES>::expose_addr,
|
||||||
|
&<*$constness u32>::expose_addr,
|
||||||
|
&|_| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn wrapping_offset<const LANES: usize>() {
|
fn wrapping_offset<const LANES: usize>() {
|
||||||
test_helpers::test_binary_elementwise(
|
test_helpers::test_binary_elementwise(
|
||||||
&Simd::<*$constness u32, LANES>::wrapping_offset,
|
&Simd::<*$constness u32, LANES>::wrapping_offset,
|
||||||
@ -51,9 +67,45 @@ fn wrapping_sub<const LANES: usize>() {
|
|||||||
mod const_ptr {
|
mod const_ptr {
|
||||||
use super::*;
|
use super::*;
|
||||||
common_tests! { const }
|
common_tests! { const }
|
||||||
|
|
||||||
|
test_helpers::test_lanes! {
|
||||||
|
fn cast_mut<const LANES: usize>() {
|
||||||
|
test_helpers::test_unary_elementwise(
|
||||||
|
&Simd::<*const u32, LANES>::cast_mut,
|
||||||
|
&<*const u32>::cast_mut,
|
||||||
|
&|_| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_exposed_addr<const LANES: usize>() {
|
||||||
|
test_helpers::test_unary_elementwise(
|
||||||
|
&Simd::<*const u32, LANES>::from_exposed_addr,
|
||||||
|
&core::ptr::from_exposed_addr::<u32>,
|
||||||
|
&|_| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod mut_ptr {
|
mod mut_ptr {
|
||||||
use super::*;
|
use super::*;
|
||||||
common_tests! { mut }
|
common_tests! { mut }
|
||||||
|
|
||||||
|
test_helpers::test_lanes! {
|
||||||
|
fn cast_const<const LANES: usize>() {
|
||||||
|
test_helpers::test_unary_elementwise(
|
||||||
|
&Simd::<*mut u32, LANES>::cast_const,
|
||||||
|
&<*mut u32>::cast_const,
|
||||||
|
&|_| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_exposed_addr<const LANES: usize>() {
|
||||||
|
test_helpers::test_unary_elementwise(
|
||||||
|
&Simd::<*mut u32, LANES>::from_exposed_addr,
|
||||||
|
&core::ptr::from_exposed_addr_mut::<u32>,
|
||||||
|
&|_| true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user