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
51 changes: 45 additions & 6 deletions crates/core_arch/src/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,46 @@ unsafe extern "C" {
fn vrfin(a: vector_float) -> vector_float;
}

impl_neg! { i8x16 : 0 }
impl_neg! { i16x8 : 0 }
impl_neg! { i32x4 : 0 }
impl_neg! { f32x4 : 0f32 }

#[macro_use]
mod sealed {
use super::*;

#[unstable(feature = "stdarch_powerpc", issue = "111145")]
pub trait VectorNeg {
unsafe fn vec_neg(self) -> Self;
}

macro_rules! impl_neg {
($($v:ty)*) => {
$(
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
impl VectorNeg for $v {
#[inline]
#[target_feature(enable = "altivec")]
unsafe fn vec_neg(self) -> Self {
simd_neg(self)
}
}
)*
}
}

impl_neg! {
vector_signed_char
vector_unsigned_char
vector_bool_char

vector_signed_short
vector_unsigned_short
vector_bool_short

vector_signed_int
vector_unsigned_int
vector_bool_int

vector_float
}

#[unstable(feature = "stdarch_powerpc", issue = "111145")]
pub trait VectorInsert {
type Scalar;
Expand Down Expand Up @@ -1378,7 +1409,7 @@ mod sealed {
#[inline]
#[target_feature(enable = "altivec")]
unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
v.vec_max(-v)
v.vec_max(simd_neg(v))
}

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

/// Vector Negate
#[inline]
#[target_feature(enable = "altivec")]
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
pub unsafe fn vec_neg<T: sealed::VectorNeg>(a: T) -> T {
a.vec_neg()
}

/// Vector add.
#[inline]
#[target_feature(enable = "altivec")]
Expand Down
14 changes: 0 additions & 14 deletions crates/core_arch/src/powerpc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,6 @@ macro_rules! t_b {
};
}

macro_rules! impl_neg {
($s: ident : $zero: expr) => {
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
impl crate::ops::Neg for s_t_l!($s) {
type Output = s_t_l!($s);
#[inline]
fn neg(self) -> Self::Output {
unsafe { simd_neg(self) }
}
}
};
}

pub(crate) use impl_neg;
pub(crate) use impl_vec_trait;
pub(crate) use s_t_l;
pub(crate) use t_b;
Expand Down
14 changes: 0 additions & 14 deletions crates/core_arch/src/s390x/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,20 +431,6 @@ macro_rules! t_b {
};
}

macro_rules! impl_neg {
($s: ident : $zero: expr) => {
#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl crate::ops::Neg for s_t_l!($s) {
type Output = s_t_l!($s);
#[inline]
fn neg(self) -> Self::Output {
unsafe { simd_neg(self) }
}
}
};
}

pub(crate) use impl_neg;
pub(crate) use impl_vec_trait;
pub(crate) use l_t_t;
pub(crate) use s_t_l;
Expand Down
54 changes: 46 additions & 8 deletions crates/core_arch/src/s390x/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,6 @@ unsafe extern "unadjusted" {
#[link_name = "llvm.s390.vfenezfs"] fn vfenezfs(a: i32x4, b: i32x4) -> PackedTuple<i32x4, i32>;
}

impl_neg! { i8x16 : 0 }
impl_neg! { i16x8 : 0 }
impl_neg! { i32x4 : 0 }
impl_neg! { i64x2 : 0 }
impl_neg! { f32x4 : 0f32 }
impl_neg! { f64x2 : 0f64 }

#[repr(simd)]
struct ShuffleMask<const N: usize>([u32; N]);

Expand Down Expand Up @@ -437,6 +430,43 @@ enum FindImm {
mod sealed {
use super::*;

#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub trait VectorNeg {
unsafe fn vec_neg(self) -> Self;
}

macro_rules! impl_neg {
($($v:ty)*) => {
$(
#[unstable(feature = "stdarch_s390x", issue = "135681")]
impl VectorNeg for $v {
#[inline]
#[target_feature(enable = "vector")]
unsafe fn vec_neg(self) -> Self {
simd_neg(self)
}
}
)*
}
}

impl_neg! {
vector_signed_char
vector_unsigned_char

vector_signed_short
vector_unsigned_short

vector_signed_int
vector_unsigned_int

vector_signed_long_long
vector_unsigned_long_long

vector_float
vector_double
}

#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub trait VectorAdd<Other> {
type Result;
Expand Down Expand Up @@ -759,7 +789,7 @@ mod sealed {
#[inline]
#[target_feature(enable = "vector")]
unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
v.vec_max(-v)
v.vec_max(simd_neg(v))
}

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

/// Vector Negate
#[inline]
#[target_feature(enable = "vector")]
#[unstable(feature = "stdarch_s390x", issue = "135681")]
pub unsafe fn vec_neg<T: sealed::VectorNeg>(a: T) -> T {
a.vec_neg()
}

/// Vector Add
#[inline]
#[target_feature(enable = "vector")]
Expand Down