Skip to content

Commit e19ebda

Browse files
folkertdevAmanieu
authored andcommitted
s390x vector: add vec_and, vec_or and vec_xor
1 parent 255da5e commit e19ebda

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

Diff for: crates/core_arch/src/s390x/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ macro_rules! impl_vec_trait {
104104
impl_vec_trait!{ [$Trait $m] $sg (vector_signed_long_long, ~vector_bool_long_long) -> vector_signed_long_long }
105105
};
106106
([$Trait:ident $m:ident] ~($fn:ident)) => {
107-
impl_vec_trait!{ [$Trait $m] ~($fn, $fn, $fn, $fn, $fn, $fn) }
107+
impl_vec_trait!{ [$Trait $m] ~($fn, $fn, $fn, $fn, $fn, $fn, $fn, $fn) }
108108
};
109109
([$Trait:ident $m:ident] 2 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
110110
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }

Diff for: crates/core_arch/src/s390x/vector.rs

+57-1
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,31 @@ mod sealed {
520520
// instructions in later facilities. Add tests when possible.
521521
test_impl! { vec_popcnt_signed +(a: vector_signed_char) -> vector_signed_char [simd_ctpop, vpopctb] }
522522
test_impl! { vec_popcnt_unsigned +(a: vector_unsigned_char) -> vector_unsigned_char [simd_ctpop, vpopctb] }
523-
}
524523

524+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
525+
pub trait VectorAnd<Other> {
526+
type Result;
527+
unsafe fn vec_and(self, b: Other) -> Self::Result;
528+
}
529+
530+
impl_vec_trait! { [VectorAnd vec_and] ~(simd_and) }
531+
532+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
533+
pub trait VectorOr<Other> {
534+
type Result;
535+
unsafe fn vec_or(self, b: Other) -> Self::Result;
536+
}
537+
538+
impl_vec_trait! { [VectorOr vec_or] ~(simd_or) }
539+
540+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
541+
pub trait VectorXor<Other> {
542+
type Result;
543+
unsafe fn vec_xor(self, b: Other) -> Self::Result;
544+
}
545+
546+
impl_vec_trait! { [VectorXor vec_xor] ~(simd_xor) }
547+
}
525548

526549
/// Vector element-wise addition.
527550
#[inline]
@@ -641,6 +664,39 @@ where
641664
a.vec_splats()
642665
}
643666

667+
/// Vector and
668+
#[inline]
669+
#[target_feature(enable = "vector")]
670+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
671+
pub unsafe fn vec_and<T, U>(a: T, b: U) -> <T as sealed::VectorAnd<U>>::Result
672+
where
673+
T: sealed::VectorAnd<U>,
674+
{
675+
a.vec_and(b)
676+
}
677+
678+
/// Vector or
679+
#[inline]
680+
#[target_feature(enable = "vector")]
681+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
682+
pub unsafe fn vec_or<T, U>(a: T, b: U) -> <T as sealed::VectorOr<U>>::Result
683+
where
684+
T: sealed::VectorOr<U>,
685+
{
686+
a.vec_or(b)
687+
}
688+
689+
/// Vector xor
690+
#[inline]
691+
#[target_feature(enable = "vector")]
692+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
693+
pub unsafe fn vec_xor<T, U>(a: T, b: U) -> <T as sealed::VectorXor<U>>::Result
694+
where
695+
T: sealed::VectorXor<U>,
696+
{
697+
a.vec_xor(b)
698+
}
699+
644700
#[cfg(test)]
645701
mod tests {
646702
use super::*;

0 commit comments

Comments
 (0)