__wmmintrin_aes.h revision 309124
1243791Sdim/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===
2243791Sdim *
3243791Sdim * Permission is hereby granted, free of charge, to any person obtaining a copy
4243791Sdim * of this software and associated documentation files (the "Software"), to deal
5243791Sdim * in the Software without restriction, including without limitation the rights
6243791Sdim * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7243791Sdim * copies of the Software, and to permit persons to whom the Software is
8243791Sdim * furnished to do so, subject to the following conditions:
9243791Sdim *
10243791Sdim * The above copyright notice and this permission notice shall be included in
11243791Sdim * all copies or substantial portions of the Software.
12243791Sdim *
13243791Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14243791Sdim * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15243791Sdim * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16243791Sdim * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17243791Sdim * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18243791Sdim * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19243791Sdim * THE SOFTWARE.
20243791Sdim *
21243791Sdim *===-----------------------------------------------------------------------===
22243791Sdim */
23243791Sdim#ifndef _WMMINTRIN_AES_H
24243791Sdim#define _WMMINTRIN_AES_H
25243791Sdim
26243791Sdim#include <emmintrin.h>
27243791Sdim
28288943Sdim/* Define the default attributes for the functions in this file. */
29296417Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes")))
30288943Sdim
31309124Sdim/// \brief Performs a single round of AES encryption using the Equivalent
32309124Sdim///    Inverse Cipher, transforming the state value from the first source
33309124Sdim///    operand using a 128-bit round key value contained in the second source
34309124Sdim///    operand, and writes the result to the destination.
35309124Sdim///
36309124Sdim/// \headerfile <x86intrin.h>
37309124Sdim///
38309124Sdim/// This intrinsic corresponds to the \c VAESENC instruction.
39309124Sdim///
40309124Sdim/// \param __V
41309124Sdim///    A 128-bit integer vector containing the state value.
42309124Sdim/// \param __R
43309124Sdim///    A 128-bit integer vector containing the round key value.
44309124Sdim/// \returns A 128-bit integer vector containing the encrypted value.
45288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
46243791Sdim_mm_aesenc_si128(__m128i __V, __m128i __R)
47243791Sdim{
48309124Sdim  return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R);
49243791Sdim}
50243791Sdim
51309124Sdim/// \brief Performs the final round of AES encryption using the Equivalent
52309124Sdim///    Inverse Cipher, transforming the state value from the first source
53309124Sdim///    operand using a 128-bit round key value contained in the second source
54309124Sdim///    operand, and writes the result to the destination.
55309124Sdim///
56309124Sdim/// \headerfile <x86intrin.h>
57309124Sdim///
58309124Sdim/// This intrinsic corresponds to the \c VAESENCLAST instruction.
59309124Sdim///
60309124Sdim/// \param __V
61309124Sdim///    A 128-bit integer vector containing the state value.
62309124Sdim/// \param __R
63309124Sdim///    A 128-bit integer vector containing the round key value.
64309124Sdim/// \returns A 128-bit integer vector containing the encrypted value.
65288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
66243791Sdim_mm_aesenclast_si128(__m128i __V, __m128i __R)
67243791Sdim{
68309124Sdim  return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R);
69243791Sdim}
70243791Sdim
71309124Sdim/// \brief Performs a single round of AES decryption using the Equivalent
72309124Sdim///    Inverse Cipher, transforming the state value from the first source
73309124Sdim///    operand using a 128-bit round key value contained in the second source
74309124Sdim///    operand, and writes the result to the destination.
75309124Sdim///
76309124Sdim/// \headerfile <x86intrin.h>
77309124Sdim///
78309124Sdim/// This intrinsic corresponds to the \c VAESDEC instruction.
79309124Sdim///
80309124Sdim/// \param __V
81309124Sdim///    A 128-bit integer vector containing the state value.
82309124Sdim/// \param __R
83309124Sdim///    A 128-bit integer vector containing the round key value.
84309124Sdim/// \returns A 128-bit integer vector containing the decrypted value.
85288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
86243791Sdim_mm_aesdec_si128(__m128i __V, __m128i __R)
87243791Sdim{
88309124Sdim  return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R);
89243791Sdim}
90243791Sdim
91309124Sdim/// \brief Performs the final round of AES decryption using the Equivalent
92309124Sdim///    Inverse Cipher, transforming the state value from the first source
93309124Sdim///    operand using a 128-bit round key value contained in the second source
94309124Sdim///    operand, and writes the result to the destination.
95309124Sdim///
96309124Sdim/// \headerfile <x86intrin.h>
97309124Sdim///
98309124Sdim/// This intrinsic corresponds to the \c VAESDECLAST instruction.
99309124Sdim///
100309124Sdim/// \param __V
101309124Sdim///    A 128-bit integer vector containing the state value.
102309124Sdim/// \param __R
103309124Sdim///    A 128-bit integer vector containing the round key value.
104309124Sdim/// \returns A 128-bit integer vector containing the decrypted value.
105288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
106243791Sdim_mm_aesdeclast_si128(__m128i __V, __m128i __R)
107243791Sdim{
108309124Sdim  return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R);
109243791Sdim}
110243791Sdim
111309124Sdim/// \brief Applies the AES InvMixColumns() transformation to an expanded key
112309124Sdim///    contained in the source operand, and writes the result to the
113309124Sdim///    destination.
114309124Sdim///
115309124Sdim/// \headerfile <x86intrin.h>
116309124Sdim///
117309124Sdim/// This intrinsic corresponds to the \c VAESIMC instruction.
118309124Sdim///
119309124Sdim/// \param __V
120309124Sdim///    A 128-bit integer vector containing the expanded key.
121309124Sdim/// \returns A 128-bit integer vector containing the transformed value.
122288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
123243791Sdim_mm_aesimc_si128(__m128i __V)
124243791Sdim{
125309124Sdim  return (__m128i)__builtin_ia32_aesimc128((__v2di)__V);
126243791Sdim}
127243791Sdim
128309124Sdim/// \brief Generates a round key for AES encyption, operating on 128-bit data
129309124Sdim///    specified in the first source operand and using an 8-bit round constant
130309124Sdim///    specified by the second source operand, and writes the result to the
131309124Sdim///    destination.
132309124Sdim///
133309124Sdim/// \headerfile <x86intrin.h>
134309124Sdim///
135309124Sdim/// \code
136309124Sdim/// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);
137309124Sdim/// \endcode
138309124Sdim///
139309124Sdim/// This intrinsic corresponds to the \c AESKEYGENASSIST instruction.
140309124Sdim///
141309124Sdim/// \param C
142309124Sdim///    A 128-bit integer vector that is used to generate the AES encryption key.
143309124Sdim/// \param R
144309124Sdim///    An 8-bit round constant used to generate the AES encryption key.
145309124Sdim/// \returns A 128-bit round key for AES encryption.
146243791Sdim#define _mm_aeskeygenassist_si128(C, R) \
147296417Sdim  (__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R))
148243791Sdim
149288943Sdim#undef __DEFAULT_FN_ATTRS
150288943Sdim
151243791Sdim#endif  /* _WMMINTRIN_AES_H */
152