Skip to content

Commit

Permalink
Move the endian-biased intrinsics in a separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed May 17, 2018
1 parent 5285028 commit c9417d5
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions coresimd/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,18 @@ where
a.vec_add(b)
}

/// Vector permute.
#[inline]
#[target_feature(enable = "altivec")]
pub unsafe fn vec_perm<T>(a: T, b: T, c: vector_unsigned_char) -> T
where
T: sealed::VectorPerm,
{

if cfg!(target_endian = "little") {
/// Endian-biased intrinsics
#[cfg(target_endian = "little")]
mod endian {
use super::*;
/// Vector permute.
#[inline]
#[target_feature(enable = "altivec")]
pub unsafe fn vec_perm<T>(a: T, b: T, c: vector_unsigned_char) -> T
where
T: sealed::VectorPerm,
{
// vperm has big-endian bias
//
// Xor the mask and flip the arguments
Expand All @@ -718,11 +721,24 @@ where
let c = simd_xor(c, d);

b.vec_vperm(a, c)
} else {
}
}
#[cfg(target_endian = "big")]
mod endian {
use super::*;
/// Vector permute.
#[inline]
#[target_feature(enable = "altivec")]
pub unsafe fn vec_perm<T>(a: T, b: T, c: vector_unsigned_char) -> T
where
T: sealed::VectorPerm,
{
a.vec_vperm(b, c)
}
}

pub use self::endian::*;

#[cfg(test)]
mod tests {
#[cfg(target_arch = "powerpc")]
Expand Down

0 comments on commit c9417d5

Please sign in to comment.