xref: /aosp_15_r20/prebuilts/sdk/renderscript/clang-include/__wmmintrin_aes.h (revision 344a7f5ef16c479e7a7f54ee6567a9d112f9e72b)
1*344a7f5eSAndroid Build Coastguard Worker /*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===
2*344a7f5eSAndroid Build Coastguard Worker  *
3*344a7f5eSAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a copy
4*344a7f5eSAndroid Build Coastguard Worker  * of this software and associated documentation files (the "Software"), to deal
5*344a7f5eSAndroid Build Coastguard Worker  * in the Software without restriction, including without limitation the rights
6*344a7f5eSAndroid Build Coastguard Worker  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*344a7f5eSAndroid Build Coastguard Worker  * copies of the Software, and to permit persons to whom the Software is
8*344a7f5eSAndroid Build Coastguard Worker  * furnished to do so, subject to the following conditions:
9*344a7f5eSAndroid Build Coastguard Worker  *
10*344a7f5eSAndroid Build Coastguard Worker  * The above copyright notice and this permission notice shall be included in
11*344a7f5eSAndroid Build Coastguard Worker  * all copies or substantial portions of the Software.
12*344a7f5eSAndroid Build Coastguard Worker  *
13*344a7f5eSAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14*344a7f5eSAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15*344a7f5eSAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16*344a7f5eSAndroid Build Coastguard Worker  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17*344a7f5eSAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18*344a7f5eSAndroid Build Coastguard Worker  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19*344a7f5eSAndroid Build Coastguard Worker  * THE SOFTWARE.
20*344a7f5eSAndroid Build Coastguard Worker  *
21*344a7f5eSAndroid Build Coastguard Worker  *===-----------------------------------------------------------------------===
22*344a7f5eSAndroid Build Coastguard Worker  */
23*344a7f5eSAndroid Build Coastguard Worker #ifndef _WMMINTRIN_AES_H
24*344a7f5eSAndroid Build Coastguard Worker #define _WMMINTRIN_AES_H
25*344a7f5eSAndroid Build Coastguard Worker 
26*344a7f5eSAndroid Build Coastguard Worker #include <emmintrin.h>
27*344a7f5eSAndroid Build Coastguard Worker 
28*344a7f5eSAndroid Build Coastguard Worker /* Define the default attributes for the functions in this file. */
29*344a7f5eSAndroid Build Coastguard Worker #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes")))
30*344a7f5eSAndroid Build Coastguard Worker 
31*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a single round of AES encryption using the Equivalent
32*344a7f5eSAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
33*344a7f5eSAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
34*344a7f5eSAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
35*344a7f5eSAndroid Build Coastguard Worker ///
36*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
37*344a7f5eSAndroid Build Coastguard Worker ///
38*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c VAESENC instruction.
39*344a7f5eSAndroid Build Coastguard Worker ///
40*344a7f5eSAndroid Build Coastguard Worker /// \param __V
41*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
42*344a7f5eSAndroid Build Coastguard Worker /// \param __R
43*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
44*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the encrypted value.
45*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesenc_si128(__m128i __V,__m128i __R)46*344a7f5eSAndroid Build Coastguard Worker _mm_aesenc_si128(__m128i __V, __m128i __R)
47*344a7f5eSAndroid Build Coastguard Worker {
48*344a7f5eSAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R);
49*344a7f5eSAndroid Build Coastguard Worker }
50*344a7f5eSAndroid Build Coastguard Worker 
51*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs the final round of AES encryption using the Equivalent
52*344a7f5eSAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
53*344a7f5eSAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
54*344a7f5eSAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
55*344a7f5eSAndroid Build Coastguard Worker ///
56*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
57*344a7f5eSAndroid Build Coastguard Worker ///
58*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c VAESENCLAST instruction.
59*344a7f5eSAndroid Build Coastguard Worker ///
60*344a7f5eSAndroid Build Coastguard Worker /// \param __V
61*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
62*344a7f5eSAndroid Build Coastguard Worker /// \param __R
63*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
64*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the encrypted value.
65*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesenclast_si128(__m128i __V,__m128i __R)66*344a7f5eSAndroid Build Coastguard Worker _mm_aesenclast_si128(__m128i __V, __m128i __R)
67*344a7f5eSAndroid Build Coastguard Worker {
68*344a7f5eSAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R);
69*344a7f5eSAndroid Build Coastguard Worker }
70*344a7f5eSAndroid Build Coastguard Worker 
71*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a single round of AES decryption using the Equivalent
72*344a7f5eSAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
73*344a7f5eSAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
74*344a7f5eSAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
75*344a7f5eSAndroid Build Coastguard Worker ///
76*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
77*344a7f5eSAndroid Build Coastguard Worker ///
78*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c VAESDEC instruction.
79*344a7f5eSAndroid Build Coastguard Worker ///
80*344a7f5eSAndroid Build Coastguard Worker /// \param __V
81*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
82*344a7f5eSAndroid Build Coastguard Worker /// \param __R
83*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
84*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the decrypted value.
85*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesdec_si128(__m128i __V,__m128i __R)86*344a7f5eSAndroid Build Coastguard Worker _mm_aesdec_si128(__m128i __V, __m128i __R)
87*344a7f5eSAndroid Build Coastguard Worker {
88*344a7f5eSAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R);
89*344a7f5eSAndroid Build Coastguard Worker }
90*344a7f5eSAndroid Build Coastguard Worker 
91*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs the final round of AES decryption using the Equivalent
92*344a7f5eSAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
93*344a7f5eSAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
94*344a7f5eSAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
95*344a7f5eSAndroid Build Coastguard Worker ///
96*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
97*344a7f5eSAndroid Build Coastguard Worker ///
98*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c VAESDECLAST instruction.
99*344a7f5eSAndroid Build Coastguard Worker ///
100*344a7f5eSAndroid Build Coastguard Worker /// \param __V
101*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
102*344a7f5eSAndroid Build Coastguard Worker /// \param __R
103*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
104*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the decrypted value.
105*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesdeclast_si128(__m128i __V,__m128i __R)106*344a7f5eSAndroid Build Coastguard Worker _mm_aesdeclast_si128(__m128i __V, __m128i __R)
107*344a7f5eSAndroid Build Coastguard Worker {
108*344a7f5eSAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R);
109*344a7f5eSAndroid Build Coastguard Worker }
110*344a7f5eSAndroid Build Coastguard Worker 
111*344a7f5eSAndroid Build Coastguard Worker /// \brief Applies the AES InvMixColumns() transformation to an expanded key
112*344a7f5eSAndroid Build Coastguard Worker ///    contained in the source operand, and writes the result to the
113*344a7f5eSAndroid Build Coastguard Worker ///    destination.
114*344a7f5eSAndroid Build Coastguard Worker ///
115*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
116*344a7f5eSAndroid Build Coastguard Worker ///
117*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c VAESIMC instruction.
118*344a7f5eSAndroid Build Coastguard Worker ///
119*344a7f5eSAndroid Build Coastguard Worker /// \param __V
120*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the expanded key.
121*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the transformed value.
122*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesimc_si128(__m128i __V)123*344a7f5eSAndroid Build Coastguard Worker _mm_aesimc_si128(__m128i __V)
124*344a7f5eSAndroid Build Coastguard Worker {
125*344a7f5eSAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesimc128((__v2di)__V);
126*344a7f5eSAndroid Build Coastguard Worker }
127*344a7f5eSAndroid Build Coastguard Worker 
128*344a7f5eSAndroid Build Coastguard Worker /// \brief Generates a round key for AES encyption, operating on 128-bit data
129*344a7f5eSAndroid Build Coastguard Worker ///    specified in the first source operand and using an 8-bit round constant
130*344a7f5eSAndroid Build Coastguard Worker ///    specified by the second source operand, and writes the result to the
131*344a7f5eSAndroid Build Coastguard Worker ///    destination.
132*344a7f5eSAndroid Build Coastguard Worker ///
133*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
134*344a7f5eSAndroid Build Coastguard Worker ///
135*344a7f5eSAndroid Build Coastguard Worker /// \code
136*344a7f5eSAndroid Build Coastguard Worker /// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);
137*344a7f5eSAndroid Build Coastguard Worker /// \endcode
138*344a7f5eSAndroid Build Coastguard Worker ///
139*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c AESKEYGENASSIST instruction.
140*344a7f5eSAndroid Build Coastguard Worker ///
141*344a7f5eSAndroid Build Coastguard Worker /// \param C
142*344a7f5eSAndroid Build Coastguard Worker ///    A 128-bit integer vector that is used to generate the AES encryption key.
143*344a7f5eSAndroid Build Coastguard Worker /// \param R
144*344a7f5eSAndroid Build Coastguard Worker ///    An 8-bit round constant used to generate the AES encryption key.
145*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit round key for AES encryption.
146*344a7f5eSAndroid Build Coastguard Worker #define _mm_aeskeygenassist_si128(C, R) \
147*344a7f5eSAndroid Build Coastguard Worker   (__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R))
148*344a7f5eSAndroid Build Coastguard Worker 
149*344a7f5eSAndroid Build Coastguard Worker #undef __DEFAULT_FN_ATTRS
150*344a7f5eSAndroid Build Coastguard Worker 
151*344a7f5eSAndroid Build Coastguard Worker #endif  /* _WMMINTRIN_AES_H */
152