From a4ebb75538f1fde6cdba481765b5f9216ecb0bc3 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 6 Aug 2018 18:37:25 -0400 Subject: [PATCH] Update comments --- gcm-simd.cpp | 12 ++++++++---- ppc-simd.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gcm-simd.cpp b/gcm-simd.cpp index 123fefde..8e3ca50a 100644 --- a/gcm-simd.cpp +++ b/gcm-simd.cpp @@ -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)); diff --git a/ppc-simd.h b/ppc-simd.h index e076cc94..f3cdc7d3 100644 --- a/ppc-simd.h +++ b/ppc-simd.h @@ -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 +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