Skip to content

Commit

Permalink
Merge pull request #414 from rust-lang/sync-2024-04-09
Browse files Browse the repository at this point in the history
Sync 2024-04-09
  • Loading branch information
calebzulawski authored Apr 11, 2024
2 parents 979a495 + b8a18fa commit f0cbf40
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
4 changes: 0 additions & 4 deletions crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
#![unstable(feature = "portable_simd", issue = "86656")]
//! Portable SIMD module.
#[prelude_import]
#[allow(unused_imports)]
use core::prelude::v1::*;

#[path = "mod.rs"]
mod core_simd;
pub use self::core_simd::simd;
18 changes: 9 additions & 9 deletions crates/core_simd/src/simd/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ pub trait SimdConstPtr: Copy + Sealed {
/// Equivalent to calling [`pointer::with_addr`] on each element.
fn with_addr(self, addr: Self::Usize) -> Self;

/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
/// in [`Self::from_exposed_addr`].
fn expose_addr(self) -> Self::Usize;
/// Exposes the "provenance" part of the pointer for future use in
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::from_exposed_addr`] on each element.
fn from_exposed_addr(addr: Self::Usize) -> Self;
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;

/// Calculates the offset from a pointer using wrapping arithmetic.
///
Expand Down Expand Up @@ -152,15 +152,15 @@ where
}

#[inline]
fn expose_addr(self) -> Self::Usize {
fn expose_provenance(self) -> Self::Usize {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_expose_addr(self) }
unsafe { core::intrinsics::simd::simd_expose_provenance(self) }
}

#[inline]
fn from_exposed_addr(addr: Self::Usize) -> Self {
fn with_exposed_provenance(addr: Self::Usize) -> Self {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
}

#[inline]
Expand Down
18 changes: 9 additions & 9 deletions crates/core_simd/src/simd/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ pub trait SimdMutPtr: Copy + Sealed {
/// Equivalent to calling [`pointer::with_addr`] on each element.
fn with_addr(self, addr: Self::Usize) -> Self;

/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
/// in [`Self::from_exposed_addr`].
fn expose_addr(self) -> Self::Usize;
/// Exposes the "provenance" part of the pointer for future use in
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::from_exposed_addr_mut`] on each element.
fn from_exposed_addr(addr: Self::Usize) -> Self;
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;

/// Calculates the offset from a pointer using wrapping arithmetic.
///
Expand Down Expand Up @@ -149,15 +149,15 @@ where
}

#[inline]
fn expose_addr(self) -> Self::Usize {
fn expose_provenance(self) -> Self::Usize {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_expose_addr(self) }
unsafe { core::intrinsics::simd::simd_expose_provenance(self) }
}

#[inline]
fn from_exposed_addr(addr: Self::Usize) -> Self {
fn with_exposed_provenance(addr: Self::Usize) -> Self {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
}

#[inline]
Expand Down
1 change: 0 additions & 1 deletion crates/core_simd/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::simd::{
ptr::{SimdConstPtr, SimdMutPtr},
LaneCount, Mask, MaskElement, SupportedLaneCount, Swizzle,
};
use core::convert::{TryFrom, TryInto};

/// A SIMD vector with the shape of `[T; N]` but the operations of `T`.
///
Expand Down
18 changes: 9 additions & 9 deletions crates/core_simd/tests/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ macro_rules! common_tests {
);
}

fn expose_addr<const LANES: usize>() {
fn expose_provenance<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&Simd::<*$constness u32, LANES>::expose_addr,
&<*$constness u32>::expose_addr,
&Simd::<*$constness u32, LANES>::expose_provenance,
&<*$constness u32>::expose_provenance,
&|_| true,
);
}
Expand Down Expand Up @@ -80,10 +80,10 @@ mod const_ptr {
);
}

fn from_exposed_addr<const LANES: usize>() {
fn with_exposed_provenance<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&Simd::<*const u32, LANES>::from_exposed_addr,
&core::ptr::from_exposed_addr::<u32>,
&Simd::<*const u32, LANES>::with_exposed_provenance,
&core::ptr::with_exposed_provenance::<u32>,
&|_| true,
);
}
Expand All @@ -103,10 +103,10 @@ mod mut_ptr {
);
}

fn from_exposed_addr<const LANES: usize>() {
fn with_exposed_provenance<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&Simd::<*mut u32, LANES>::from_exposed_addr,
&core::ptr::from_exposed_addr_mut::<u32>,
&Simd::<*mut u32, LANES>::with_exposed_provenance,
&core::ptr::with_exposed_provenance_mut::<u32>,
&|_| true,
);
}
Expand Down

0 comments on commit f0cbf40

Please sign in to comment.