Update comments

This commit is contained in:
Jeffrey Walton 2018-08-06 18:37:25 -04:00
parent 194307308c
commit a4ebb75538
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 22 additions and 4 deletions

View File

@ -168,9 +168,10 @@ using CryptoPP::uint64x2_p;
using CryptoPP::VectorAnd;
using CryptoPP::VectorShiftRight;
// _mm_clmulepi64_si128(a, b, 0x00)
// High dwords of 'a' and 'b' are masked out.
inline uint64x2_p VMULL_00(uint64x2_p a, uint64x2_p b)
{
// Multiplies low dwords
#if defined(__xlc__) || defined(__xlC__)
const uint64x2_p m = {0xffffffffffffffffull, 0};
return __vpmsumd (VectorAnd(a, m), VectorAnd(b, m));
@ -180,9 +181,10 @@ inline uint64x2_p VMULL_00(uint64x2_p a, uint64x2_p b)
#endif
}
// _mm_clmulepi64_si128(a, b, 0x01)
// High dword of 'a' is masked out. High dword of 'b' is shifted down.
inline uint64x2_p VMULL_01(uint64x2_p a, uint64x2_p b)
{
// Multiplies high and low dwords
#if defined(__xlc__) || defined(__xlC__)
const uint64x2_p m = {0xffffffffffffffffull, 0};
return __vpmsumd (VectorAnd(a, m), VectorShiftRight<8>(b));
@ -192,9 +194,10 @@ inline uint64x2_p VMULL_01(uint64x2_p a, uint64x2_p b)
#endif
}
// _mm_clmulepi64_si128(a, b, 0x10)
// High dword of 'a' is shifted down. High dword of 'b' is masked out.
inline uint64x2_p VMULL_10(uint64x2_p a, uint64x2_p b)
{
// Multiplies high and low dwords
#if defined(__xlc__) || defined(__xlC__)
const uint64x2_p m = {0xffffffffffffffffull, 0};
return __vpmsumd (VectorShiftRight<8>(a), VectorAnd(b, m));
@ -204,9 +207,10 @@ inline uint64x2_p VMULL_10(uint64x2_p a, uint64x2_p b)
#endif
}
// _mm_clmulepi64_si128(a, b, 0x11)
// Low dwords of 'a' and 'b' are masked out.
inline uint64x2_p VMULL_11(uint64x2_p a, uint64x2_p b)
{
// Multiplies high dwords
#if defined(__xlc__) || defined(__xlC__)
const uint64x2_p m = {0, 0xffffffffffffffffull};
return __vpmsumd (VectorAnd(a, m), VectorAnd(b, m));

View File

@ -90,6 +90,20 @@ inline T1 VectorPermute(const T1& vec1, const T1& vec2, const T2& mask)
return (T1)vec_perm(vec1, vec2, (uint8x16_p)mask);
}
/// \brief AND two vectors
/// \tparam T1 vector type
/// \tparam T2 vector type
/// \param vec1 the first vector
/// \param vec2 the second vector
/// \details VectorAnd returns a new vector from vec1 and vec2. The return
/// vector is the same type as vec1.
/// \since Crypto++ 6.0
template <class T1, class T2>
inline T1 VectorAnd(const T1& vec1, const T2& vec2)
{
return (T1)vec_and(vec1, (T1)vec2);
}
/// \brief XOR two vectors
/// \tparam T1 vector type
/// \tparam T2 vector type