╭ sha512intrin.h ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
.. llvm_libc_wrappers/ openmp_wrappers/ ppc_wrappers/ __clang_spirv_builtins.h __float_float.h __float_header_macro.h __float_infinity_nan.h __stdarg___gnuc_va_list.h __stdarg___va_copy.h __stdarg_header_macro.h __stdarg_va_arg.h __stdarg_va_copy.h __stdarg_va_list.h __stddef_header_macro.h __stddef_max_align_t.h __stddef_null.h __stddef_nullptr_t.h __stddef_offsetof.h __stddef_ptrdiff_t.h __stddef_rsize_t.h __stddef_size_t.h __stddef_unreachable.h __stddef_wchar_t.h __stddef_wint_t.h __wmmintrin_aes.h __wmmintrin_pclmul.h adcintrin.h adxintrin.h altivec.h ammintrin.h amo.h amxavx512intrin.h amxcomplexintrin.h amxfp16intrin.h amxfp8intrin.h amxintrin.h amxmovrsintrin.h amxtf32intrin.h andes_vector.h arm64intr.h arm_acle.h arm_bf16.h arm_cde.h arm_cmse.h arm_fp16.h arm_mve.h arm_neon.h arm_neon_sve_bridge.h arm_sme.h arm_sve.h arm_vector_types.h armintr.h avx10_2_512bf16intrin.h avx10_2_512convertintrin.h avx10_2_512minmaxintrin.h avx10_2_512niintrin.h avx10_2_512satcvtdsintrin.h avx10_2_512satcvtintrin.h avx10_2bf16intrin.h avx10_2convertintrin.h avx10_2copyintrin.h avx10_2minmaxintrin.h avx10_2niintrin.h avx10_2satcvtdsintrin.h avx10_2satcvtintrin.h avx2intrin.h avx512bf16intrin.h avx512bitalgintrin.h avx512bwintrin.h avx512cdintrin.h avx512dqintrin.h avx512fintrin.h avx512fp16intrin.h avx512ifmaintrin.h avx512ifmavlintrin.h avx512vbmi2intrin.h avx512vbmiintrin.h avx512vbmivlintrin.h avx512vlbf16intrin.h avx512vlbitalgintrin.h avx512vlbwintrin.h avx512vlcdintrin.h avx512vldqintrin.h avx512vlfp16intrin.h avx512vlintrin.h avx512vlvbmi2intrin.h avx512vlvnniintrin.h avx512vlvp2intersectintrin.h avx512vnniintrin.h avx512vp2intersectintrin.h avx512vpopcntdqintrin.h avx512vpopcntdqvlintrin.h avxifmaintrin.h avxintrin.h avxneconvertintrin.h avxvnniint16intrin.h avxvnniint8intrin.h avxvnniintrin.h bmi2intrin.h bmiintrin.h builtins.h cet.h cetintrin.h cldemoteintrin.h clflushoptintrin.h clwbintrin.h clzerointrin.h cmpccxaddintrin.h cpuid.h crc32intrin.h emmintrin.h enqcmdintrin.h f16cintrin.h float.h fma4intrin.h fmaintrin.h fxsrintrin.h gfniintrin.h hexagon_circ_brev_intrinsics.h hexagon_protos.h hexagon_types.h hresetintrin.h htmintrin.h htmxlintrin.h hvx_hexagon_protos.h ia32intrin.h immintrin.h intrin.h intrin0.h inttypes.h invpcidintrin.h iso646.h keylockerintrin.h larchintrin.h lasxintrin.h limits.h lsxintrin.h lwpintrin.h lzcntintrin.h mm3dnow.h mm_malloc.h mmintrin.h module.modulemap movdirintrin.h movrs_avx10_2_512intrin.h movrs_avx10_2intrin.h movrsintrin.h msa.h mwaitxintrin.h nmmintrin.h pconfigintrin.h pkuintrin.h pmmintrin.h popcntintrin.h prfchiintrin.h prfchwintrin.h ptrauth.h ptwriteintrin.h raointintrin.h rdpruintrin.h rdseedintrin.h riscv_bitmanip.h riscv_corev_alu.h riscv_crypto.h riscv_mips.h riscv_nds.h riscv_ntlh.h riscv_vector.h rtmintrin.h s390intrin.h serializeintrin.h sgxintrin.h ╭─────────────────────────────────╮ │sha512intrin.h │ ╰─────────────────────────────────╯ shaintrin.h sifive_vector.h sm3intrin.h sm4evexintrin.h sm4intrin.h smmintrin.h spirvintrin.h stdalign.h stdarg.h stdatomic.h stdbool.h stdckdint.h stdcountof.h stddef.h stddefer.h stdint.h stdnoreturn.h tbmintrin.h tgmath.h tmmintrin.h tsxldtrkintrin.h uintrintrin.h unwind.h usermsrintrin.h vadefs.h vaesintrin.h varargs.h vecintrin.h velintrin.h velintrin_approx.h velintrin_gen.h vpclmulqdqintrin.h waitpkgintrin.h wasm_simd128.h wbnoinvdintrin.h wmmintrin.h x86gprintrin.h x86intrin.h xmmintrin.h xopintrin.h xsavecintrin.h xsaveintrin.h xsaveoptintrin.h xsavesintrin.h xtestintrin.h yvals_core.h
1 /*===--------------- sha512intrin.h - SHA512 intrinsics -----------------=== 2 * 3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 * See https://llvm.org/LICENSE.txt for license information. 5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 * 7 *===-----------------------------------------------------------------------=== 8 */ 9 10 #ifndef __IMMINTRIN_H 11 #error "Never use <sha512intrin.h> directly; include <immintrin.h> instead." 12 #endif // __IMMINTRIN_H 13 14 #ifndef __SHA512INTRIN_H 15 #define __SHA512INTRIN_H 16 17 #define __DEFAULT_FN_ATTRS256 \ 18 __attribute__((__always_inline__, __nodebug__, __target__("sha512"), \ 19 __min_vector_width__(256))) 20 21 /// This intrinisc is one of the two SHA512 message scheduling instructions. 22 /// The intrinsic performs an intermediate calculation for the next four 23 /// SHA512 message qwords. The calculated results are stored in \a dst. 24 /// 25 /// \headerfile <immintrin.h> 26 /// 27 /// \code 28 /// __m256i _mm256_sha512msg1_epi64(__m256i __A, __m128i __B) 29 /// \endcode 30 /// 31 /// This intrinsic corresponds to the \c VSHA512MSG1 instruction. 32 /// 33 /// \param __A 34 /// A 256-bit vector of [4 x long long]. 35 /// \param __B 36 /// A 128-bit vector of [2 x long long]. 37 /// \returns 38 /// A 256-bit vector of [4 x long long]. 39 /// 40 /// \code{.operation} 41 /// DEFINE ROR64(qword, n) { 42 /// count := n % 64 43 /// dest := (qword >> count) | (qword << (64 - count)) 44 /// RETURN dest 45 /// } 46 /// DEFINE SHR64(qword, n) { 47 /// RETURN qword >> n 48 /// } 49 /// DEFINE s0(qword): 50 /// RETURN ROR64(qword,1) ^ ROR64(qword, 8) ^ SHR64(qword, 7) 51 /// } 52 /// W[4] := __B.qword[0] 53 /// W[3] := __A.qword[3] 54 /// W[2] := __A.qword[2] 55 /// W[1] := __A.qword[1] 56 /// W[0] := __A.qword[0] 57 /// dst.qword[3] := W[3] + s0(W[4]) 58 /// dst.qword[2] := W[2] + s0(W[3]) 59 /// dst.qword[1] := W[1] + s0(W[2]) 60 /// dst.qword[0] := W[0] + s0(W[1]) 61 /// dst[MAX:256] := 0 62 /// \endcode 63 static __inline__ __m256i __DEFAULT_FN_ATTRS256 64 _mm256_sha512msg1_epi64(__m256i __A, __m128i __B) { 65 return (__m256i)__builtin_ia32_vsha512msg1((__v4du)__A, (__v2du)__B); 66 } 67 68 /// This intrinisc is one of the two SHA512 message scheduling instructions. 69 /// The intrinsic performs the final calculation for the next four SHA512 70 /// message qwords. The calculated results are stored in \a dst. 71 /// 72 /// \headerfile <immintrin.h> 73 /// 74 /// \code 75 /// __m256i _mm256_sha512msg2_epi64(__m256i __A, __m256i __B) 76 /// \endcode 77 /// 78 /// This intrinsic corresponds to the \c VSHA512MSG2 instruction. 79 /// 80 /// \param __A 81 /// A 256-bit vector of [4 x long long]. 82 /// \param __B 83 /// A 256-bit vector of [4 x long long]. 84 /// \returns 85 /// A 256-bit vector of [4 x long long]. 86 /// 87 /// \code{.operation} 88 /// DEFINE ROR64(qword, n) { 89 /// count := n % 64 90 /// dest := (qword >> count) | (qword << (64 - count)) 91 /// RETURN dest 92 /// } 93 /// DEFINE SHR64(qword, n) { 94 /// RETURN qword >> n 95 /// } 96 /// DEFINE s1(qword) { 97 /// RETURN ROR64(qword,19) ^ ROR64(qword, 61) ^ SHR64(qword, 6) 98 /// } 99 /// W[14] := __B.qword[2] 100 /// W[15] := __B.qword[3] 101 /// W[16] := __A.qword[0] + s1(W[14]) 102 /// W[17] := __A.qword[1] + s1(W[15]) 103 /// W[18] := __A.qword[2] + s1(W[16]) 104 /// W[19] := __A.qword[3] + s1(W[17]) 105 /// dst.qword[3] := W[19] 106 /// dst.qword[2] := W[18] 107 /// dst.qword[1] := W[17] 108 /// dst.qword[0] := W[16] 109 /// dst[MAX:256] := 0 110 /// \endcode 111 static __inline__ __m256i __DEFAULT_FN_ATTRS256 112 _mm256_sha512msg2_epi64(__m256i __A, __m256i __B) { 113 return (__m256i)__builtin_ia32_vsha512msg2((__v4du)__A, (__v4du)__B); 114 } 115 116 /// This intrinisc performs two rounds of SHA512 operation using initial SHA512 117 /// state (C,D,G,H) from \a __A, an initial SHA512 state (A,B,E,F) from 118 /// \a __A, and a pre-computed sum of the next two round message qwords and 119 /// the corresponding round constants from \a __C (only the two lower qwords 120 /// of the third operand). The updated SHA512 state (A,B,E,F) is written to 121 /// \a __A, and \a __A can be used as the updated state (C,D,G,H) in later 122 /// rounds. 123 /// 124 /// \headerfile <immintrin.h> 125 /// 126 /// \code 127 /// __m256i _mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C) 128 /// \endcode 129 /// 130 /// This intrinsic corresponds to the \c VSHA512RNDS2 instruction. 131 /// 132 /// \param __A 133 /// A 256-bit vector of [4 x long long]. 134 /// \param __B 135 /// A 256-bit vector of [4 x long long]. 136 /// \param __C 137 /// A 128-bit vector of [2 x long long]. 138 /// \returns 139 /// A 256-bit vector of [4 x long long]. 140 /// 141 /// \code{.operation} 142 /// DEFINE ROR64(qword, n) { 143 /// count := n % 64 144 /// dest := (qword >> count) | (qword << (64 - count)) 145 /// RETURN dest 146 /// } 147 /// DEFINE SHR64(qword, n) { 148 /// RETURN qword >> n 149 /// } 150 /// DEFINE cap_sigma0(qword) { 151 /// RETURN ROR64(qword,28) ^ ROR64(qword, 34) ^ ROR64(qword, 39) 152 /// } 153 /// DEFINE cap_sigma1(qword) { 154 /// RETURN ROR64(qword,14) ^ ROR64(qword, 18) ^ ROR64(qword, 41) 155 /// } 156 /// DEFINE MAJ(a,b,c) { 157 /// RETURN (a & b) ^ (a & c) ^ (b & c) 158 /// } 159 /// DEFINE CH(e,f,g) { 160 /// RETURN (e & f) ^ (g & ~e) 161 /// } 162 /// A[0] := __B.qword[3] 163 /// B[0] := __B.qword[2] 164 /// C[0] := __C.qword[3] 165 /// D[0] := __C.qword[2] 166 /// E[0] := __B.qword[1] 167 /// F[0] := __B.qword[0] 168 /// G[0] := __C.qword[1] 169 /// H[0] := __C.qword[0] 170 /// WK[0]:= __A.qword[0] 171 /// WK[1]:= __A.qword[1] 172 /// FOR i := 0 to 1: 173 /// A[i+1] := CH(E[i], F[i], G[i]) + 174 /// cap_sigma1(E[i]) + WK[i] + H[i] + 175 /// MAJ(A[i], B[i], C[i]) + 176 /// cap_sigma0(A[i]) 177 /// B[i+1] := A[i] 178 /// C[i+1] := B[i] 179 /// D[i+1] := C[i] 180 /// E[i+1] := CH(E[i], F[i], G[i]) + 181 /// cap_sigma1(E[i]) + WK[i] + H[i] + D[i] 182 /// F[i+1] := E[i] 183 /// G[i+1] := F[i] 184 /// H[i+1] := G[i] 185 /// ENDFOR 186 /// dst.qword[3] := A[2] 187 /// dst.qword[2] := B[2] 188 /// dst.qword[1] := E[2] 189 /// dst.qword[0] := F[2] 190 /// dst[MAX:256] := 0 191 /// \endcode 192 static __inline__ __m256i __DEFAULT_FN_ATTRS256 193 _mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C) { 194 return (__m256i)__builtin_ia32_vsha512rnds2((__v4du)__A, (__v4du)__B, 195 (__v2du)__C); 196 } 197 198 #undef __DEFAULT_FN_ATTRS256 199 200 #endif // __SHA512INTRIN_H 201