[PATCH] D155861: [Headers][doc] Add SHA1/SHA256 intrinsic descriptions
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG775d6df6a5f2: [Headers][doc] Add SHA1/SHA256 intrinsic descriptions (authored by probinson). Herald added a project: clang. Changed prior to commit: https://reviews.llvm.org/D155861?vs=542569=543066#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155861/new/ https://reviews.llvm.org/D155861 Files: clang/lib/Headers/shaintrin.h Index: clang/lib/Headers/shaintrin.h === --- clang/lib/Headers/shaintrin.h +++ clang/lib/Headers/shaintrin.h @@ -17,39 +17,167 @@ /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sha"), __min_vector_width__(128))) +/// Performs four iterations of the inner loop of the SHA-1 message digest +///algorithm using the starting SHA-1 state (A, B, C, D) from the 128-bit +///vector of [4 x i32] in \a V1 and the next four 32-bit elements of the +///message from the 128-bit vector of [4 x i32] in \a V2. Note that the +///SHA-1 state variable E must have already been added to \a V2 +///(\c _mm_sha1nexte_epu32() can perform this step). Returns the updated +///SHA-1 state (A, B, C, D) as a 128-bit vector of [4 x i32]. +/// +///The SHA-1 algorithm has an inner loop of 80 iterations, twenty each +///with a different combining function and rounding constant. This +///intrinsic performs four iterations using a combining function and +///rounding constant selected by \a M[1:0]. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sha1rnds4_epu32(__m128i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c SHA1RNDS4 instruction. +/// +/// \param V1 +///A 128-bit vector of [4 x i32] containing the initial SHA-1 state. +/// \param V2 +///A 128-bit vector of [4 x i32] containing the next four elements of +///the message, plus SHA-1 state variable E. +/// \param M +///An immediate value where bits [1:0] select among four possible +///combining functions and rounding constants (not specified here). +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state. #define _mm_sha1rnds4_epu32(V1, V2, M) \ __builtin_ia32_sha1rnds4((__v4si)(__m128i)(V1), (__v4si)(__m128i)(V2), (M)) +/// Calculates the SHA-1 state variable E from the SHA-1 state variables in +///the 128-bit vector of [4 x i32] in \a __X, adds that to the next set of +///four message elements in the 128-bit vector of [4 x i32] in \a __Y, and +///returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1NEXTE instruction. +/// +/// \param __X +///A 128-bit vector of [4 x i32] containing the current SHA-1 state. +/// \param __Y +///A 128-bit vector of [4 x i32] containing the next four elements of the +///message. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +///values. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1nexte_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1nexte((__v4si)__X, (__v4si)__Y); } +/// Performs an intermediate calculation for deriving the next four SHA-1 +///message elements using previous message elements from the 128-bit +///vectors of [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG1 instruction. +/// +/// \param __X +///A 128-bit vector of [4 x i32] containing previous message elements. +/// \param __Y +///A 128-bit vector of [4 x i32] containing previous message elements. +/// \returns A 128-bit vector of [4 x i32] containing the derived SHA-1 +///elements. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1msg1_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1msg1((__v4si)__X, (__v4si)__Y); } +/// Performs the final calculation for deriving the next four SHA-1 message +///elements using previous message elements from the 128-bit vectors of +///[4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG2 instruction. +/// +/// \param __X +///A 128-bit vector of [4 x i32] containing an intermediate result. +/// \param __Y +///A 128-bit vector of [4 x i32] containing previous message values. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +///values. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1msg2_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1msg2((__v4si)__X, (__v4si)__Y); } +/// Performs two rounds of SHA-256 operation using the following inputs: a +///starting SHA-256 state (C, D, G, H) from the 128-bit
[PATCH] D155861: [Headers][doc] Add SHA1/SHA256 intrinsic descriptions
probinson added a comment. Thanks! The pre-merge check caught mistakes in the \param commands, which I fixed before pushing. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155861/new/ https://reviews.llvm.org/D155861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155861: [Headers][doc] Add SHA1/SHA256 intrinsic descriptions
pengfei accepted this revision. pengfei added a comment. This revision is now accepted and ready to land. LGTM. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155861/new/ https://reviews.llvm.org/D155861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155861: [Headers][doc] Add SHA1/SHA256 intrinsic descriptions
probinson created this revision. probinson added reviewers: pengfei, RKSimon, goldstein.w.n, craig.topper. Herald added a project: All. probinson requested review of this revision. I didn't include pseudo-code, because it would be long and complicated, probably not tell the whole story, and these are _extremely_ specialized instructions. I can have a go at it if reviewers insist. FTR this should be the last of the intrinsic description reviews I plan to post. I still need to double-check my list, but I'm pretty sure I got them all. https://reviews.llvm.org/D155861 Files: clang/lib/Headers/shaintrin.h Index: clang/lib/Headers/shaintrin.h === --- clang/lib/Headers/shaintrin.h +++ clang/lib/Headers/shaintrin.h @@ -17,39 +17,167 @@ /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sha"), __min_vector_width__(128))) +/// Performs four iterations of the inner loop of the SHA-1 message digest +///algorithm using the starting SHA-1 state (A, B, C, D) from the 128-bit +///vector of [4 x i32] in \a V1 and the next four 32-bit elements of the +///message from the 128-bit vector of [4 x i32] in \a V2. Note that the +///SHA-1 state variable E must have already been added to \a V2 +///(\c _mm_sha1nexte_epu32() can perform this step). Returns the updated +///SHA-1 state (A, B, C, D) as a 128-bit vector of [4 x i32]. +/// +///The SHA-1 algorithm has an inner loop of 80 iterations, twenty each +///with a different combining function and rounding constant. This +///intrinsic performs four iterations using a combining function and +///rounding constant selected by \a M[1:0]. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sha1rnds4_epu32(__m128i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c SHA1RNDS4 instruction. +/// +/// \param V1 +///A 128-bit vector of [4 x i32] containing the initial SHA-1 state. +/// \param V2 +///A 128-bit vector of [4 x i32] containing the next four elements of +///the message, plus SHA-1 state variable E. +/// \param M +///An immediate value where bits [1:0] select among four possible +///combining functions and rounding constants (not specified here). +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state. #define _mm_sha1rnds4_epu32(V1, V2, M) \ __builtin_ia32_sha1rnds4((__v4si)(__m128i)(V1), (__v4si)(__m128i)(V2), (M)) +/// Calculates the SHA-1 state variable E from the SHA-1 state variables in +///the 128-bit vector of [4 x i32] in \a __X, adds that to the next set of +///four message elements in the 128-bit vector of [4 x i32] in \a __Y, and +///returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1NEXTE instruction. +/// +/// \param V1 +///A 128-bit vector of [4 x i32] containing the current SHA-1 state. +/// \param V2 +///A 128-bit vector of [4 x i32] containing the next four elements of the +///message. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +///values. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1nexte_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1nexte((__v4si)__X, (__v4si)__Y); } +/// Performs an intermediate calculation for deriving the next four SHA-1 +///message elements using previous message elements from the 128-bit +///vectors of [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG1 instruction. +/// +/// \param V1 +///A 128-bit vector of [4 x i32] containing previous message elements. +/// \param V2 +///A 128-bit vector of [4 x i32] containing previous message elements. +/// \returns A 128-bit vector of [4 x i32] containing the derived SHA-1 +///elements. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1msg1_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1msg1((__v4si)__X, (__v4si)__Y); } +/// Performs the final calculation for deriving the next four SHA-1 message +///elements using previous message elements from the 128-bit vectors of +///[4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG2 instruction. +/// +/// \param V1 +///A 128-bit vector of [4 x i32] containing an intermediate result. +/// \param V2 +///A 128-bit vector of [4 x i32] containing previous message values. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +///values. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sha1msg2_epu32(__m128i __X, __m128i __Y) { return (__m128i)__builtin_ia32_sha1msg2((__v4si)__X, (__v4si)__Y); } +/// Performs two rounds of SHA-256 operation using the