Skip to content

Commit c35c91a

Browse files
committed
remove impl Neg on s390x/powerpc vector types
For other targets we don't have such instances. We specifically decided agains implementing arithmetic operators on these low-level vector types
1 parent 1b8539c commit c35c91a

File tree

4 files changed

+91
-42
lines changed

4 files changed

+91
-42
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,46 @@ unsafe extern "C" {
364364
fn vrfin(a: vector_float) -> vector_float;
365365
}
366366

367-
impl_neg! { i8x16 : 0 }
368-
impl_neg! { i16x8 : 0 }
369-
impl_neg! { i32x4 : 0 }
370-
impl_neg! { f32x4 : 0f32 }
371-
372367
#[macro_use]
373368
mod sealed {
374369
use super::*;
375370

371+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
372+
pub trait VectorNeg {
373+
unsafe fn vec_neg(self) -> Self;
374+
}
375+
376+
macro_rules! impl_neg {
377+
($($v:ty)*) => {
378+
$(
379+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
380+
impl VectorNeg for $v {
381+
#[inline]
382+
#[target_feature(enable = "altivec")]
383+
unsafe fn vec_neg(self) -> Self {
384+
simd_neg(self)
385+
}
386+
}
387+
)*
388+
}
389+
}
390+
391+
impl_neg! {
392+
vector_signed_char
393+
vector_unsigned_char
394+
vector_bool_char
395+
396+
vector_signed_short
397+
vector_unsigned_short
398+
vector_bool_short
399+
400+
vector_signed_int
401+
vector_unsigned_int
402+
vector_bool_int
403+
404+
vector_float
405+
}
406+
376407
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
377408
pub trait VectorInsert {
378409
type Scalar;
@@ -1378,7 +1409,7 @@ mod sealed {
13781409
#[inline]
13791410
#[target_feature(enable = "altivec")]
13801411
unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
1381-
v.vec_max(-v)
1412+
v.vec_max(simd_neg(v))
13821413
}
13831414

13841415
impl_vec_trait! { [VectorAbs vec_abs] $name (s_t_l!($ty)) }
@@ -4030,6 +4061,14 @@ pub unsafe fn vec_mfvscr() -> vector_unsigned_short {
40304061
mfvscr()
40314062
}
40324063

4064+
/// Vector Negate
4065+
#[inline]
4066+
#[target_feature(enable = "altivec")]
4067+
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4068+
pub unsafe fn vec_neg<T: sealed::VectorNeg>(a: T) -> T {
4069+
a.vec_neg()
4070+
}
4071+
40334072
/// Vector add.
40344073
#[inline]
40354074
#[target_feature(enable = "altivec")]

crates/core_arch/src/powerpc/macros.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,6 @@ macro_rules! t_b {
274274
};
275275
}
276276

277-
macro_rules! impl_neg {
278-
($s: ident : $zero: expr) => {
279-
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
280-
impl crate::ops::Neg for s_t_l!($s) {
281-
type Output = s_t_l!($s);
282-
#[inline]
283-
fn neg(self) -> Self::Output {
284-
unsafe { simd_neg(self) }
285-
}
286-
}
287-
};
288-
}
289-
290-
pub(crate) use impl_neg;
291277
pub(crate) use impl_vec_trait;
292278
pub(crate) use s_t_l;
293279
pub(crate) use t_b;

crates/core_arch/src/s390x/macros.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -431,20 +431,6 @@ macro_rules! t_b {
431431
};
432432
}
433433

434-
macro_rules! impl_neg {
435-
($s: ident : $zero: expr) => {
436-
#[unstable(feature = "stdarch_s390x", issue = "135681")]
437-
impl crate::ops::Neg for s_t_l!($s) {
438-
type Output = s_t_l!($s);
439-
#[inline]
440-
fn neg(self) -> Self::Output {
441-
unsafe { simd_neg(self) }
442-
}
443-
}
444-
};
445-
}
446-
447-
pub(crate) use impl_neg;
448434
pub(crate) use impl_vec_trait;
449435
pub(crate) use l_t_t;
450436
pub(crate) use s_t_l;

crates/core_arch/src/s390x/vector.rs

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,6 @@ unsafe extern "unadjusted" {
283283
#[link_name = "llvm.s390.vfenezfs"] fn vfenezfs(a: i32x4, b: i32x4) -> PackedTuple<i32x4, i32>;
284284
}
285285

286-
impl_neg! { i8x16 : 0 }
287-
impl_neg! { i16x8 : 0 }
288-
impl_neg! { i32x4 : 0 }
289-
impl_neg! { i64x2 : 0 }
290-
impl_neg! { f32x4 : 0f32 }
291-
impl_neg! { f64x2 : 0f64 }
292-
293286
#[repr(simd)]
294287
struct ShuffleMask<const N: usize>([u32; N]);
295288

@@ -437,6 +430,43 @@ enum FindImm {
437430
mod sealed {
438431
use super::*;
439432

433+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
434+
pub trait VectorNeg {
435+
unsafe fn vec_neg(self) -> Self;
436+
}
437+
438+
macro_rules! impl_neg {
439+
($($v:ty)*) => {
440+
$(
441+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
442+
impl VectorNeg for $v {
443+
#[inline]
444+
#[target_feature(enable = "vector")]
445+
unsafe fn vec_neg(self) -> Self {
446+
simd_neg(self)
447+
}
448+
}
449+
)*
450+
}
451+
}
452+
453+
impl_neg! {
454+
vector_signed_char
455+
vector_unsigned_char
456+
457+
vector_signed_short
458+
vector_unsigned_short
459+
460+
vector_signed_int
461+
vector_unsigned_int
462+
463+
vector_signed_long_long
464+
vector_unsigned_long_long
465+
466+
vector_float
467+
vector_double
468+
}
469+
440470
#[unstable(feature = "stdarch_s390x", issue = "135681")]
441471
pub trait VectorAdd<Other> {
442472
type Result;
@@ -759,7 +789,7 @@ mod sealed {
759789
#[inline]
760790
#[target_feature(enable = "vector")]
761791
unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
762-
v.vec_max(-v)
792+
v.vec_max(simd_neg(v))
763793
}
764794

765795
impl_vec_trait! { [VectorAbs vec_abs] $name (s_t_l!($ty)) }
@@ -4053,6 +4083,14 @@ unsafe fn __lcbb<const BLOCK_BOUNDARY: u16>(ptr: *const u8) -> u32 {
40534083
lcbb(ptr, const { validate_block_boundary(BLOCK_BOUNDARY) })
40544084
}
40554085

4086+
/// Vector Negate
4087+
#[inline]
4088+
#[target_feature(enable = "vector")]
4089+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4090+
pub unsafe fn vec_neg<T: sealed::VectorNeg>(a: T) -> T {
4091+
a.vec_neg()
4092+
}
4093+
40564094
/// Vector Add
40574095
#[inline]
40584096
#[target_feature(enable = "vector")]

0 commit comments

Comments
 (0)