Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/core_simd/src/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
use crate::simd::{Simd, SimdElement};
use core::fmt;

impl<T, const N: usize> fmt::Debug for Simd<T, N>
where
LaneCount<N>: SupportedLaneCount,
T: SimdElement + fmt::Debug,
{
/// A `Simd<T, N>` has a debug format like the one for `[T]`:
Expand Down
10 changes: 1 addition & 9 deletions crates/core_simd/src/iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::simd::{LaneCount, Simd, SupportedLaneCount};
use crate::simd::Simd;
use core::{
iter::{Product, Sum},
ops::{Add, Mul},
Expand All @@ -7,8 +7,6 @@ use core::{
macro_rules! impl_traits {
{ $type:ty } => {
impl<const N: usize> Sum<Self> for Simd<$type, N>
where
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
Expand All @@ -17,8 +15,6 @@ macro_rules! impl_traits {
}

impl<const N: usize> Product<Self> for Simd<$type, N>
where
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
Expand All @@ -27,8 +23,6 @@ macro_rules! impl_traits {
}

impl<'a, const N: usize> Sum<&'a Self> for Simd<$type, N>
where
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
Expand All @@ -37,8 +31,6 @@ macro_rules! impl_traits {
}

impl<'a, const N: usize> Product<&'a Self> for Simd<$type, N>
where
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
Expand Down
52 changes: 0 additions & 52 deletions crates/core_simd/src/lane_count.rs

This file was deleted.

3 changes: 2 additions & 1 deletion crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
simd_ffi,
staged_api,
prelude_import,
ptr_metadata
ptr_metadata,
rustc_attrs
)]
#![cfg_attr(
all(
Expand Down
45 changes: 5 additions & 40 deletions crates/core_simd/src/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Types representing
#![allow(non_camel_case_types)]

use crate::simd::{LaneCount, Select, Simd, SimdCast, SimdElement, SupportedLaneCount};
use crate::simd::{Select, Simd, SimdCast, SimdElement};
use core::cmp::Ordering;
use core::{fmt, mem};

Expand Down Expand Up @@ -41,7 +41,6 @@ mod sealed {
pub trait Sealed {
fn valid<const N: usize>(values: Simd<Self, N>) -> bool
where
LaneCount<N>: SupportedLaneCount,
Self: SimdElement;

fn eq(self, other: Self) -> bool;
Expand Down Expand Up @@ -69,8 +68,6 @@ macro_rules! impl_element {
impl Sealed for $ty {
#[inline]
fn valid<const N: usize>(value: Simd<Self, N>) -> bool
where
LaneCount<N>: SupportedLaneCount,
{
// We can't use `Simd` directly, because `Simd`'s functions call this function and
// we will end up with an infinite loop.
Expand Down Expand Up @@ -121,23 +118,18 @@ impl_element! { isize, usize }
/// The layout of this type is unspecified, and may change between platforms
/// and/or Rust versions, and code should not assume that it is equivalent to
/// `[T; N]`.
///
/// `N` cannot be 0 and may be at most 64.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `N` cannot be 0 and may be at most 64.
/// `N` cannot be 0 and may be at most 64 (though this limit may be increased in the future).

#[repr(transparent)]
pub struct Mask<T, const N: usize>(Simd<T, N>)
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount;
T: MaskElement;

impl<T, const N: usize> Copy for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
}
impl<T, const N: usize> Copy for Mask<T, N> where T: MaskElement {}

impl<T, const N: usize> Clone for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn clone(&self) -> Self {
Expand All @@ -148,7 +140,6 @@ where
impl<T, const N: usize> Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
/// Constructs a mask by setting all elements to the given value.
#[inline]
Expand Down Expand Up @@ -315,8 +306,6 @@ where
) -> U
where
T: MaskElement,
LaneCount<M>: SupportedLaneCount,
LaneCount<N>: SupportedLaneCount,
{
let resized = mask.resize::<M>(false);

Expand Down Expand Up @@ -421,7 +410,6 @@ where
impl<T, const N: usize> From<[bool; N]> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn from(array: [bool; N]) -> Self {
Expand All @@ -432,7 +420,6 @@ where
impl<T, const N: usize> From<Mask<T, N>> for [bool; N]
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn from(vector: Mask<T, N>) -> Self {
Expand All @@ -443,7 +430,6 @@ where
impl<T, const N: usize> Default for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn default() -> Self {
Expand All @@ -454,7 +440,6 @@ where
impl<T, const N: usize> PartialEq for Mask<T, N>
where
T: MaskElement + PartialEq,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn eq(&self, other: &Self) -> bool {
Expand All @@ -465,7 +450,6 @@ where
impl<T, const N: usize> PartialOrd for Mask<T, N>
where
T: MaskElement + PartialOrd,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Expand All @@ -476,7 +460,6 @@ where
impl<T, const N: usize> fmt::Debug for Mask<T, N>
where
T: MaskElement + fmt::Debug,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -489,7 +472,6 @@ where
impl<T, const N: usize> core::ops::BitAnd for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -502,7 +484,6 @@ where
impl<T, const N: usize> core::ops::BitAnd<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -514,7 +495,6 @@ where
impl<T, const N: usize> core::ops::BitAnd<Mask<T, N>> for bool
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Mask<T, N>;
#[inline]
Expand All @@ -526,7 +506,6 @@ where
impl<T, const N: usize> core::ops::BitOr for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -539,7 +518,6 @@ where
impl<T, const N: usize> core::ops::BitOr<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -551,7 +529,6 @@ where
impl<T, const N: usize> core::ops::BitOr<Mask<T, N>> for bool
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Mask<T, N>;
#[inline]
Expand All @@ -563,7 +540,6 @@ where
impl<T, const N: usize> core::ops::BitXor for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -576,7 +552,6 @@ where
impl<T, const N: usize> core::ops::BitXor<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Self;
#[inline]
Expand All @@ -588,7 +563,6 @@ where
impl<T, const N: usize> core::ops::BitXor<Mask<T, N>> for bool
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Mask<T, N>;
#[inline]
Expand All @@ -600,7 +574,6 @@ where
impl<T, const N: usize> core::ops::Not for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
type Output = Mask<T, N>;
#[inline]
Expand All @@ -612,7 +585,6 @@ where
impl<T, const N: usize> core::ops::BitAndAssign for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
Expand All @@ -623,7 +595,6 @@ where
impl<T, const N: usize> core::ops::BitAndAssign<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitand_assign(&mut self, rhs: bool) {
Expand All @@ -634,7 +605,6 @@ where
impl<T, const N: usize> core::ops::BitOrAssign for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
Expand All @@ -645,7 +615,6 @@ where
impl<T, const N: usize> core::ops::BitOrAssign<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitor_assign(&mut self, rhs: bool) {
Expand All @@ -656,7 +625,6 @@ where
impl<T, const N: usize> core::ops::BitXorAssign for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
Expand All @@ -667,7 +635,6 @@ where
impl<T, const N: usize> core::ops::BitXorAssign<bool> for Mask<T, N>
where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn bitxor_assign(&mut self, rhs: bool) {
Expand All @@ -679,8 +646,6 @@ macro_rules! impl_from {
{ $from:ty => $($to:ty),* } => {
$(
impl<const N: usize> From<Mask<$from, N>> for Mask<$to, N>
where
LaneCount<N>: SupportedLaneCount,
{
#[inline]
fn from(value: Mask<$from, N>) -> Self {
Expand Down
2 changes: 0 additions & 2 deletions crates/core_simd/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod alias;
mod cast;
mod fmt;
mod iter;
mod lane_count;
mod masks;
mod ops;
mod select;
Expand All @@ -27,7 +26,6 @@ pub mod simd {

pub use crate::core_simd::alias::*;
pub use crate::core_simd::cast::*;
pub use crate::core_simd::lane_count::{LaneCount, SupportedLaneCount};
pub use crate::core_simd::masks::*;
pub use crate::core_simd::select::*;
pub use crate::core_simd::swizzle::*;
Expand Down
Loading