Skip to content

Commit 1e62d4c

Browse files
committed
Rename Mask::to_int to Mask::to_simd
1 parent 295ba3b commit 1e62d4c

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

crates/core_simd/src/masks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ where
175175
// This would be hypothetically valid as an "in-place" transmute,
176176
// but these are "dependently-sized" types, so copy elision it is!
177177
unsafe {
178-
let mut bytes: Simd<i8, N> = core::intrinsics::simd::simd_cast(self.to_int());
178+
let mut bytes: Simd<i8, N> = core::intrinsics::simd::simd_cast(self.to_simd());
179179
bytes &= Simd::splat(1i8);
180180
mem::transmute_copy(&bytes)
181181
}
@@ -214,8 +214,8 @@ where
214214
/// represents `true`.
215215
#[inline]
216216
#[must_use = "method returns a new vector and does not mutate the original value"]
217-
pub fn to_int(self) -> Simd<T, N> {
218-
self.0.to_int()
217+
pub fn to_simd(self) -> Simd<T, N> {
218+
self.0.to_simd()
219219
}
220220

221221
/// Converts the mask to a mask of any other element size.
@@ -352,7 +352,7 @@ where
352352
// Safety: the input and output are integer vectors
353353
let index: Simd<T, N> = unsafe { core::intrinsics::simd::simd_cast(index) };
354354

355-
let masked_index = self.select(index, Self::splat(true).to_int());
355+
let masked_index = self.select(index, Self::splat(true).to_simd());
356356

357357
// Safety: the input and output are integer vectors
358358
let masked_index: Simd<T::Unsigned, N> =

crates/core_simd/src/masks/bitmask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ where
105105

106106
#[inline]
107107
#[must_use = "method returns a new vector and does not mutate the original value"]
108-
pub(crate) fn to_int(self) -> Simd<T, N> {
108+
pub(crate) fn to_simd(self) -> Simd<T, N> {
109109
unsafe {
110110
core::intrinsics::simd::simd_select_bitmask(
111111
self.0,

crates/core_simd/src/masks/full_masks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ where
120120

121121
#[inline]
122122
#[must_use = "method returns a new vector and does not mutate the original value"]
123-
pub(crate) fn to_int(self) -> Simd<T, N> {
123+
pub(crate) fn to_simd(self) -> Simd<T, N> {
124124
self.0
125125
}
126126

@@ -145,7 +145,7 @@ where
145145
where
146146
LaneCount<M>: SupportedLaneCount,
147147
{
148-
let resized = self.to_int().resize::<M>(T::FALSE);
148+
let resized = self.to_simd().resize::<M>(T::FALSE);
149149

150150
// Safety: `resized` is an integer vector with length M, which must match T
151151
let bitmask: U = unsafe { core::intrinsics::simd::simd_bitmask(resized) };
@@ -223,14 +223,14 @@ where
223223
#[must_use = "method returns a new bool and does not mutate the original value"]
224224
pub(crate) fn any(self) -> bool {
225225
// Safety: use `self` as an integer vector
226-
unsafe { core::intrinsics::simd::simd_reduce_any(self.to_int()) }
226+
unsafe { core::intrinsics::simd::simd_reduce_any(self.to_simd()) }
227227
}
228228

229229
#[inline]
230230
#[must_use = "method returns a new bool and does not mutate the original value"]
231231
pub(crate) fn all(self) -> bool {
232232
// Safety: use `self` as an integer vector
233-
unsafe { core::intrinsics::simd::simd_reduce_all(self.to_int()) }
233+
unsafe { core::intrinsics::simd::simd_reduce_all(self.to_simd()) }
234234
}
235235
}
236236

crates/core_simd/src/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
{
2929
// Safety: The mask has been cast to a vector of integers,
3030
// and the operands to select between are vectors of the same type and length.
31-
unsafe { core::intrinsics::simd::simd_select(self.to_int(), true_values, false_values) }
31+
unsafe { core::intrinsics::simd::simd_select(self.to_simd(), true_values, false_values) }
3232
}
3333

3434
/// Choose elements from two masks.

crates/core_simd/src/simd/cmp/eq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ macro_rules! impl_mask {
5959
fn simd_eq(self, other: Self) -> Self::Mask {
6060
// Safety: `self` is a vector, and the result of the comparison
6161
// is always a valid mask.
62-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_eq(self.to_int(), other.to_int())) }
62+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_eq(self.to_simd(), other.to_simd())) }
6363
}
6464

6565
#[inline]
6666
fn simd_ne(self, other: Self) -> Self::Mask {
6767
// Safety: `self` is a vector, and the result of the comparison
6868
// is always a valid mask.
69-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ne(self.to_int(), other.to_int())) }
69+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ne(self.to_simd(), other.to_simd())) }
7070
}
7171
}
7272
)*

crates/core_simd/src/simd/cmp/ord.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,28 +163,28 @@ macro_rules! impl_mask {
163163
fn simd_lt(self, other: Self) -> Self::Mask {
164164
// Safety: `self` is a vector, and the result of the comparison
165165
// is always a valid mask.
166-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_lt(self.to_int(), other.to_int())) }
166+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_lt(self.to_simd(), other.to_simd())) }
167167
}
168168

169169
#[inline]
170170
fn simd_le(self, other: Self) -> Self::Mask {
171171
// Safety: `self` is a vector, and the result of the comparison
172172
// is always a valid mask.
173-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_le(self.to_int(), other.to_int())) }
173+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_le(self.to_simd(), other.to_simd())) }
174174
}
175175

176176
#[inline]
177177
fn simd_gt(self, other: Self) -> Self::Mask {
178178
// Safety: `self` is a vector, and the result of the comparison
179179
// is always a valid mask.
180-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_gt(self.to_int(), other.to_int())) }
180+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_gt(self.to_simd(), other.to_simd())) }
181181
}
182182

183183
#[inline]
184184
fn simd_ge(self, other: Self) -> Self::Mask {
185185
// Safety: `self` is a vector, and the result of the comparison
186186
// is always a valid mask.
187-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ge(self.to_int(), other.to_int())) }
187+
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ge(self.to_simd(), other.to_simd())) }
188188
}
189189
}
190190

crates/core_simd/src/swizzle.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub trait Swizzle<const N: usize> {
165165
LaneCount<M>: SupportedLaneCount,
166166
{
167167
// SAFETY: all elements of this mask come from another mask
168-
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_int())) }
168+
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_simd())) }
169169
}
170170

171171
/// Creates a new mask from the elements of `first` and `second`.
@@ -181,7 +181,7 @@ pub trait Swizzle<const N: usize> {
181181
LaneCount<M>: SupportedLaneCount,
182182
{
183183
// SAFETY: all elements of this mask come from another mask
184-
unsafe { Mask::from_int_unchecked(Self::concat_swizzle(first.to_int(), second.to_int())) }
184+
unsafe { Mask::from_int_unchecked(Self::concat_swizzle(first.to_simd(), second.to_simd())) }
185185
}
186186
}
187187

@@ -524,7 +524,7 @@ where
524524
#[must_use = "method returns a new vector and does not mutate the original inputs"]
525525
pub fn reverse(self) -> Self {
526526
// Safety: swizzles are safe for masks
527-
unsafe { Self::from_int_unchecked(self.to_int().reverse()) }
527+
unsafe { Self::from_int_unchecked(self.to_simd().reverse()) }
528528
}
529529

530530
/// Rotates the mask such that the first `OFFSET` elements of the slice move to the end
@@ -534,7 +534,7 @@ where
534534
#[must_use = "method returns a new vector and does not mutate the original inputs"]
535535
pub fn rotate_elements_left<const OFFSET: usize>(self) -> Self {
536536
// Safety: swizzles are safe for masks
537-
unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_left::<OFFSET>()) }
537+
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_left::<OFFSET>()) }
538538
}
539539

540540
/// Rotates the mask such that the first `self.len() - OFFSET` elements of the mask move to
@@ -544,7 +544,7 @@ where
544544
#[must_use = "method returns a new vector and does not mutate the original inputs"]
545545
pub fn rotate_elements_right<const OFFSET: usize>(self) -> Self {
546546
// Safety: swizzles are safe for masks
547-
unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_right::<OFFSET>()) }
547+
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_right::<OFFSET>()) }
548548
}
549549

550550
/// Shifts the mask elements to the left by `OFFSET`, filling in with
@@ -554,7 +554,7 @@ where
554554
pub fn shift_elements_left<const OFFSET: usize>(self, padding: bool) -> Self {
555555
// Safety: swizzles are safe for masks
556556
unsafe {
557-
Self::from_int_unchecked(self.to_int().shift_elements_left::<OFFSET>(if padding {
557+
Self::from_int_unchecked(self.to_simd().shift_elements_left::<OFFSET>(if padding {
558558
T::TRUE
559559
} else {
560560
T::FALSE
@@ -569,7 +569,7 @@ where
569569
pub fn shift_elements_right<const OFFSET: usize>(self, padding: bool) -> Self {
570570
// Safety: swizzles are safe for masks
571571
unsafe {
572-
Self::from_int_unchecked(self.to_int().shift_elements_right::<OFFSET>(if padding {
572+
Self::from_int_unchecked(self.to_simd().shift_elements_right::<OFFSET>(if padding {
573573
T::TRUE
574574
} else {
575575
T::FALSE
@@ -598,7 +598,7 @@ where
598598
#[inline]
599599
#[must_use = "method returns a new vector and does not mutate the original inputs"]
600600
pub fn interleave(self, other: Self) -> (Self, Self) {
601-
let (lo, hi) = self.to_int().interleave(other.to_int());
601+
let (lo, hi) = self.to_simd().interleave(other.to_simd());
602602
// Safety: swizzles are safe for masks
603603
unsafe { (Self::from_int_unchecked(lo), Self::from_int_unchecked(hi)) }
604604
}
@@ -627,7 +627,7 @@ where
627627
#[inline]
628628
#[must_use = "method returns a new vector and does not mutate the original inputs"]
629629
pub fn deinterleave(self, other: Self) -> (Self, Self) {
630-
let (even, odd) = self.to_int().deinterleave(other.to_int());
630+
let (even, odd) = self.to_simd().deinterleave(other.to_simd());
631631
// Safety: swizzles are safe for masks
632632
unsafe {
633633
(
@@ -659,7 +659,7 @@ where
659659
{
660660
// Safety: swizzles are safe for masks
661661
unsafe {
662-
Mask::<T, M>::from_int_unchecked(self.to_int().resize::<M>(if value {
662+
Mask::<T, M>::from_int_unchecked(self.to_simd().resize::<M>(if value {
663663
T::TRUE
664664
} else {
665665
T::FALSE
@@ -684,6 +684,6 @@ where
684684
LaneCount<LEN>: SupportedLaneCount,
685685
{
686686
// Safety: swizzles are safe for masks
687-
unsafe { Mask::<T, LEN>::from_int_unchecked(self.to_int().extract::<START, LEN>()) }
687+
unsafe { Mask::<T, LEN>::from_int_unchecked(self.to_simd().extract::<START, LEN>()) }
688688
}
689689
}

crates/core_simd/src/vector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ where
474474
or: Self,
475475
) -> Self {
476476
// SAFETY: The safety of reading elements through `ptr` is ensured by the caller.
477-
unsafe { core::intrinsics::simd::simd_masked_load(enable.to_int(), ptr, or) }
477+
unsafe { core::intrinsics::simd::simd_masked_load(enable.to_simd(), ptr, or) }
478478
}
479479

480480
/// Reads from potentially discontiguous indices in `slice` to construct a SIMD vector.
@@ -652,7 +652,7 @@ where
652652
or: Self,
653653
) -> Self {
654654
// Safety: The caller is responsible for upholding all invariants
655-
unsafe { core::intrinsics::simd::simd_gather(or, source, enable.to_int()) }
655+
unsafe { core::intrinsics::simd::simd_gather(or, source, enable.to_simd()) }
656656
}
657657

658658
/// Conditionally write contiguous elements to `slice`. The `enable` mask controls
@@ -723,7 +723,7 @@ where
723723
#[inline]
724724
pub unsafe fn store_select_ptr(self, ptr: *mut T, enable: Mask<<T as SimdElement>::Mask, N>) {
725725
// SAFETY: The safety of writing elements through `ptr` is ensured by the caller.
726-
unsafe { core::intrinsics::simd::simd_masked_store(enable.to_int(), ptr, self) }
726+
unsafe { core::intrinsics::simd::simd_masked_store(enable.to_simd(), ptr, self) }
727727
}
728728

729729
/// Writes the values in a SIMD vector to potentially discontiguous indices in `slice`.
@@ -882,7 +882,7 @@ where
882882
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
883883
pub unsafe fn scatter_select_ptr(self, dest: Simd<*mut T, N>, enable: Mask<isize, N>) {
884884
// Safety: The caller is responsible for upholding all invariants
885-
unsafe { core::intrinsics::simd::simd_scatter(self, dest, enable.to_int()) }
885+
unsafe { core::intrinsics::simd::simd_scatter(self, dest, enable.to_simd()) }
886886
}
887887
}
888888

crates/core_simd/tests/masks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ macro_rules! test_mask_api {
6565
fn roundtrip_int_conversion() {
6666
let values = [true, false, false, true, false, false, true, false];
6767
let mask = Mask::<$type, 8>::from_array(values);
68-
let int = mask.to_int();
68+
let int = mask.to_simd();
6969
assert_eq!(int.to_array(), [-1, 0, 0, -1, 0, 0, -1, 0]);
7070
assert_eq!(Mask::<$type, 8>::from_int(int), mask);
7171
}

0 commit comments

Comments
 (0)