xref: /minix3/external/bsd/llvm/dist/clang/lib/Headers/shaintrin.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc /*===---- shaintrin.h - SHA intrinsics -------------------------------------===
2f4a2713aSLionel Sambuc  *
3f4a2713aSLionel Sambuc  * Permission is hereby granted, free of charge, to any person obtaining a copy
4f4a2713aSLionel Sambuc  * of this software and associated documentation files (the "Software"), to deal
5f4a2713aSLionel Sambuc  * in the Software without restriction, including without limitation the rights
6f4a2713aSLionel Sambuc  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7f4a2713aSLionel Sambuc  * copies of the Software, and to permit persons to whom the Software is
8f4a2713aSLionel Sambuc  * furnished to do so, subject to the following conditions:
9f4a2713aSLionel Sambuc  *
10f4a2713aSLionel Sambuc  * The above copyright notice and this permission notice shall be included in
11f4a2713aSLionel Sambuc  * all copies or substantial portions of the Software.
12f4a2713aSLionel Sambuc  *
13f4a2713aSLionel Sambuc  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14f4a2713aSLionel Sambuc  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15f4a2713aSLionel Sambuc  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16f4a2713aSLionel Sambuc  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17f4a2713aSLionel Sambuc  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18f4a2713aSLionel Sambuc  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19f4a2713aSLionel Sambuc  * THE SOFTWARE.
20f4a2713aSLionel Sambuc  *
21f4a2713aSLionel Sambuc  *===-----------------------------------------------------------------------===
22f4a2713aSLionel Sambuc  */
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc #ifndef __IMMINTRIN_H
25f4a2713aSLionel Sambuc #error "Never use <shaintrin.h> directly; include <immintrin.h> instead."
26f4a2713aSLionel Sambuc #endif
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc #ifndef __SHAINTRIN_H
29f4a2713aSLionel Sambuc #define __SHAINTRIN_H
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc #if !defined (__SHA__)
32f4a2713aSLionel Sambuc #  error "SHA instructions not enabled"
33f4a2713aSLionel Sambuc #endif
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc #define _mm_sha1rnds4_epu32(V1, V2, M) __extension__ ({ \
36f4a2713aSLionel Sambuc   __builtin_ia32_sha1rnds4((V1), (V2), (M)); })
37f4a2713aSLionel Sambuc 
38f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha1nexte_epu32(__m128i __X,__m128i __Y)39f4a2713aSLionel Sambuc _mm_sha1nexte_epu32(__m128i __X, __m128i __Y)
40f4a2713aSLionel Sambuc {
41*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha1nexte((__v4si)__X, (__v4si)__Y);
42f4a2713aSLionel Sambuc }
43f4a2713aSLionel Sambuc 
44f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha1msg1_epu32(__m128i __X,__m128i __Y)45f4a2713aSLionel Sambuc _mm_sha1msg1_epu32(__m128i __X, __m128i __Y)
46f4a2713aSLionel Sambuc {
47*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha1msg1((__v4si)__X, (__v4si)__Y);
48f4a2713aSLionel Sambuc }
49f4a2713aSLionel Sambuc 
50f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha1msg2_epu32(__m128i __X,__m128i __Y)51f4a2713aSLionel Sambuc _mm_sha1msg2_epu32(__m128i __X, __m128i __Y)
52f4a2713aSLionel Sambuc {
53*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha1msg2((__v4si)__X, (__v4si)__Y);
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc 
56f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha256rnds2_epu32(__m128i __X,__m128i __Y,__m128i __Z)57f4a2713aSLionel Sambuc _mm_sha256rnds2_epu32(__m128i __X, __m128i __Y, __m128i __Z)
58f4a2713aSLionel Sambuc {
59*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha256rnds2((__v4si)__X, (__v4si)__Y, (__v4si)__Z);
60f4a2713aSLionel Sambuc }
61f4a2713aSLionel Sambuc 
62f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha256msg1_epu32(__m128i __X,__m128i __Y)63f4a2713aSLionel Sambuc _mm_sha256msg1_epu32(__m128i __X, __m128i __Y)
64f4a2713aSLionel Sambuc {
65*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha256msg1((__v4si)__X, (__v4si)__Y);
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc 
68f4a2713aSLionel Sambuc static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_sha256msg2_epu32(__m128i __X,__m128i __Y)69f4a2713aSLionel Sambuc _mm_sha256msg2_epu32(__m128i __X, __m128i __Y)
70f4a2713aSLionel Sambuc {
71*0a6a1f1dSLionel Sambuc   return (__m128i)__builtin_ia32_sha256msg2((__v4si)__X, (__v4si)__Y);
72f4a2713aSLionel Sambuc }
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc #endif /* __SHAINTRIN_H */
75