]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/wmmintrin.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / i386 / wmmintrin.h
1 /* Copyright (C) 2008-2024 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
24 /* Implemented from the specification included in the Intel C++ Compiler
25 User Guide and Reference, version 10.1. */
26
27 #ifndef _WMMINTRIN_H_INCLUDED
28 #define _WMMINTRIN_H_INCLUDED
29
30 /* We need definitions from the SSE2 header file. */
31 #include <emmintrin.h>
32
33 /* AES */
34
35 #if !defined(__AES__) || !defined(__SSE2__)
36 #pragma GCC push_options
37 #pragma GCC target("aes,sse2")
38 #define __DISABLE_AES__
39 #endif /* __AES__ */
40
41 /* Performs 1 round of AES decryption of the first m128i using
42 the second m128i as a round key. */
43 #define _mm_aesdec_si128(X, Y) \
44 (__m128i) __builtin_ia32_aesdec128 ((__v2di) (X), (__v2di) (Y))
45
46 /* Performs the last round of AES decryption of the first m128i
47 using the second m128i as a round key. */
48 #define _mm_aesdeclast_si128(X, Y) \
49 (__m128i) __builtin_ia32_aesdeclast128 ((__v2di) (X), (__v2di) (Y))
50
51 /* Performs 1 round of AES encryption of the first m128i using
52 the second m128i as a round key. */
53 #define _mm_aesenc_si128(X, Y) \
54 (__m128i) __builtin_ia32_aesenc128 ((__v2di) (X), (__v2di) (Y))
55
56 /* Performs the last round of AES encryption of the first m128i
57 using the second m128i as a round key. */
58 #define _mm_aesenclast_si128(X, Y) \
59 (__m128i) __builtin_ia32_aesenclast128 ((__v2di) (X), (__v2di) (Y))
60
61 /* Performs the InverseMixColumn operation on the source m128i
62 and stores the result into m128i destination. */
63 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
64 _mm_aesimc_si128 (__m128i __X)
65 {
66 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
67 }
68
69 /* Generates a m128i round key for the input m128i AES cipher key and
70 byte round constant. The second parameter must be a compile time
71 constant. */
72 #ifdef __OPTIMIZE__
73 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
74 _mm_aeskeygenassist_si128 (__m128i __X, const int __C)
75 {
76 return (__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)__X, __C);
77 }
78 #else
79 #define _mm_aeskeygenassist_si128(X, C) \
80 ((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \
81 (int)(C)))
82 #endif
83
84 #ifdef __DISABLE_AES__
85 #undef __DISABLE_AES__
86 #pragma GCC pop_options
87 #endif /* __DISABLE_AES__ */
88
89 /* PCLMUL */
90
91 #if !defined(__PCLMUL__) || !defined(__SSE2__)
92 #pragma GCC push_options
93 #pragma GCC target("pclmul,sse2")
94 #define __DISABLE_PCLMUL__
95 #endif /* __PCLMUL__ */
96
97 /* Performs carry-less integer multiplication of 64-bit halves of
98 128-bit input operands. The third parameter inducates which 64-bit
99 haves of the input parameters v1 and v2 should be used. It must be
100 a compile time constant. */
101 #ifdef __OPTIMIZE__
102 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
103 _mm_clmulepi64_si128 (__m128i __X, __m128i __Y, const int __I)
104 {
105 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
106 (__v2di)__Y, __I);
107 }
108 #else
109 #define _mm_clmulepi64_si128(X, Y, I) \
110 ((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \
111 (__v2di)(__m128i)(Y), (int)(I)))
112 #endif
113
114 #ifdef __DISABLE_PCLMUL__
115 #undef __DISABLE_PCLMUL__
116 #pragma GCC pop_options
117 #endif /* __DISABLE_PCLMUL__ */
118
119 #endif /* _WMMINTRIN_H_INCLUDED */