summaryrefslogtreecommitdiff
path: root/ppc_simd.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-05-11 22:43:07 -0400
committerJeffrey Walton <noloader@gmail.com>2020-05-11 22:43:07 -0400
commit5ce8a3e7f6e0b47ffa975c4ef5a3e7d4844cd47b (patch)
tree7af1f56961964e60b7ff0970761b6fa95e3c2b9e /ppc_simd.h
parentd84a9176de79fb62aa4e390969846d26728cf235 (diff)
downloadcryptopp-git-5ce8a3e7f6e0b47ffa975c4ef5a3e7d4844cd47b.tar.gz
Add VecReverseBE for big-endian systems
Diffstat (limited to 'ppc_simd.h')
-rw-r--r--ppc_simd.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/ppc_simd.h b/ppc_simd.h
index 6fe1fe8c..9011724d 100644
--- a/ppc_simd.h
+++ b/ppc_simd.h
@@ -233,7 +233,7 @@ inline uint32x4_p VecOne()
/// \details VecReverseLE() reverses the bytes in a vector on
/// little-endian systems.
/// \par Wraps
-/// vec_perm on POWER8 and below
+/// vec_perm
/// \since Crypto++ 6.0
template <class T>
inline T VecReverseLE(const T data)
@@ -246,6 +246,26 @@ inline T VecReverseLE(const T data)
#endif
}
+/// \brief Reverse bytes in a vector
+/// \tparam T vector type
+/// \param data the vector
+/// \returns vector
+/// \details VecReverseLE() reverses the bytes in a vector on
+/// big-endian systems.
+/// \par Wraps
+/// vec_perm
+/// \since Crypto++ 6.0
+template <class T>
+inline T VecReverseBE(const T data)
+{
+#if defined(CRYPTOPP_BIG_ENDIAN)
+ const uint8x16_p mask = {15,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0};
+ return (T)vec_perm(data, data, mask);
+#else
+ return data;
+#endif
+}
+
/// \name LOAD OPERATIONS
//@{