summaryrefslogtreecommitdiff
path: root/ppc_simd.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-04-08 22:19:50 -0400
committerJeffrey Walton <noloader@gmail.com>2020-04-08 22:19:50 -0400
commitbe0dea49be333f4c7434bf8e2fffb81b5e00498d (patch)
tree24e1d094baf4bc81288395a08dcce412dd509518 /ppc_simd.h
parent38df1c0024e1217e1064d1800140586c523b1c74 (diff)
downloadcryptopp-git-be0dea49be333f4c7434bf8e2fffb81b5e00498d.tar.gz
Add VecSplatElement64 for PowerPC
Diffstat (limited to 'ppc_simd.h')
-rw-r--r--ppc_simd.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/ppc_simd.h b/ppc_simd.h
index 1bb91d99..1803c00d 100644
--- a/ppc_simd.h
+++ b/ppc_simd.h
@@ -1773,6 +1773,41 @@ inline uint32x4_p VecSplatWord(word32 val)
#endif
}
+/// \brief Broadcast 32-bit word to a vector
+/// \tparam the element number
+/// \param val the 32-bit value
+/// \returns vector
+/// \since Crypto++ 8.3
+template <unsigned int N>
+inline uint32x4_p VecSplatElement(const uint32x4_p val)
+{
+#if defined(_ARCH_PWR8)
+ return vec_splat(val, N);
+#else
+ enum {E=N&3};
+ if (E == 0)
+ {
+ const uint8x16_p m = {0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3};
+ return vec_perm(val, val, m);
+ }
+ else if (E == 1)
+ {
+ const uint8x16_p m = {4,5,6,7, 4,5,6,7, 4,5,6,7, 4,5,6,7};
+ return vec_perm(val, val, m);
+ }
+ else if (E == 2)
+ {
+ const uint8x16_p m = {8,9,10,11, 8,9,10,11, 8,9,10,11, 8,9,10,11};
+ return vec_perm(val, val, m);
+ }
+ else // (E == 3)
+ {
+ const uint8x16_p m = {12,13,14,15, 12,13,14,15, 12,13,14,15, 12,13,14,15};
+ return vec_perm(val, val, m);
+ }
+#endif
+}
+
#if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
/// \brief Broadcast 64-bit double word to a vector
/// \param val the 64-bit value
@@ -1783,6 +1818,31 @@ inline uint64x2_p VecSplatWord(word64 val)
// The PPC64 ABI says so.
return vec_splats((unsigned long long)val);
}
+
+/// \brief Broadcast 64-bit word to a vector
+/// \tparam the element number
+/// \param val the 64-bit value
+/// \returns vector
+/// \since Crypto++ 8.3
+template <unsigned int N>
+inline uint64x2_p VecSplatElement(const uint64x2_p val)
+{
+#if defined(_ARCH_PWR8)
+ return vec_splat(val, N);
+#else
+ enum {E=N&1};
+ if (E == 0)
+ {
+ const uint8x16_p m = {0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7};
+ return vec_perm(val, val, m);
+ }
+ else // (E == 1)
+ {
+ const uint8x16_p m = {8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15};
+ return vec_perm(val, val, m);
+ }
+#endif
+}
#endif
/// \brief Extract a dword from a vector
@@ -2219,6 +2279,44 @@ inline uint32x4_p VecSplatWord64(word64 val)
#endif
}
+/// \brief Broadcast 64-bit word to a vector
+/// \tparam the element number
+/// \param val the 64-bit value
+/// \returns vector
+/// \since Crypto++ 8.3
+template <unsigned int N>
+inline uint32x4_p VecSplatElement64(const uint32x4_p val)
+{
+#if defined(_ARCH_PWR8)
+ return vec_splat((uint64x2_p)val, N);
+#else
+ enum {E=N&1};
+ if (E == 0)
+ {
+ const uint8x16_p m = {0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7};
+ return vec_perm(val, val, m);
+ }
+ else // (E == 1)
+ {
+ const uint8x16_p m = {8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15};
+ return vec_perm(val, val, m);
+ }
+#endif
+}
+
+#if defined(_ARCH_PWR8) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
+/// \brief Broadcast 64-bit word to a vector
+/// \tparam the element number
+/// \param val the 64-bit value
+/// \returns vector
+/// \since Crypto++ 8.3
+template <unsigned int N>
+inline uint64x2_p VecSplatElement64(const uint64x2_p val)
+{
+ return vec_splat(val, N);
+}
+#endif
+
//@}
//////////////////////// Power8 Crypto ////////////////////////