1 /* Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 This file is part of GCC.
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)
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.
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.
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/>. */
24 /* Implemented from the specification included in the Intel C++ Compiler
25 User Guide and Reference, version 10.1. */
27 #ifndef _WMMINTRIN_H_INCLUDED
28 #define _WMMINTRIN_H_INCLUDED
30 /* We need definitions from the SSE2 header file. */
31 #include <emmintrin.h>
36 #pragma GCC push_options
37 #pragma GCC target("aes")
38 #define __DISABLE_AES__
41 /* Performs 1 round of AES decryption of the first m128i using
42 the second m128i as a round key. */
43 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
44 _mm_aesdec_si128 (__m128i __X
, __m128i __Y
)
46 return (__m128i
) __builtin_ia32_aesdec128 ((__v2di
)__X
, (__v2di
)__Y
);
49 /* Performs the last round of AES decryption of the first m128i
50 using the second m128i as a round key. */
51 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
52 _mm_aesdeclast_si128 (__m128i __X
, __m128i __Y
)
54 return (__m128i
) __builtin_ia32_aesdeclast128 ((__v2di
)__X
,
58 /* Performs 1 round of AES encryption of the first m128i using
59 the second m128i as a round key. */
60 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
61 _mm_aesenc_si128 (__m128i __X
, __m128i __Y
)
63 return (__m128i
) __builtin_ia32_aesenc128 ((__v2di
)__X
, (__v2di
)__Y
);
66 /* Performs the last round of AES encryption of the first m128i
67 using the second m128i as a round key. */
68 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
69 _mm_aesenclast_si128 (__m128i __X
, __m128i __Y
)
71 return (__m128i
) __builtin_ia32_aesenclast128 ((__v2di
)__X
, (__v2di
)__Y
);
74 /* Performs the InverseMixColumn operation on the source m128i
75 and stores the result into m128i destination. */
76 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
77 _mm_aesimc_si128 (__m128i __X
)
79 return (__m128i
) __builtin_ia32_aesimc128 ((__v2di
)__X
);
82 /* Generates a m128i round key for the input m128i AES cipher key and
83 byte round constant. The second parameter must be a compile time
86 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
87 _mm_aeskeygenassist_si128 (__m128i __X
, const int __C
)
89 return (__m128i
) __builtin_ia32_aeskeygenassist128 ((__v2di
)__X
, __C
);
92 #define _mm_aeskeygenassist_si128(X, C) \
93 ((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \
97 #ifdef __DISABLE_AES__
98 #undef __DISABLE_AES__
99 #pragma GCC pop_options
100 #endif /* __DISABLE_AES__ */
105 #pragma GCC push_options
106 #pragma GCC target("pclmul")
107 #define __DISABLE_PCLMUL__
108 #endif /* __PCLMUL__ */
110 /* Performs carry-less integer multiplication of 64-bit halves of
111 128-bit input operands. The third parameter inducates which 64-bit
112 haves of the input parameters v1 and v2 should be used. It must be
113 a compile time constant. */
115 extern __inline __m128i
__attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
116 _mm_clmulepi64_si128 (__m128i __X
, __m128i __Y
, const int __I
)
118 return (__m128i
) __builtin_ia32_pclmulqdq128 ((__v2di
)__X
,
122 #define _mm_clmulepi64_si128(X, Y, I) \
123 ((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \
124 (__v2di)(__m128i)(Y), (int)(I)))
127 #ifdef __DISABLE_PCLMUL__
128 #undef __DISABLE_PCLMUL__
129 #pragma GCC pop_options
130 #endif /* __DISABLE_PCLMUL__ */
132 #endif /* _WMMINTRIN_H_INCLUDED */