xref: /aosp_15_r20/prebuilts/clang-tools/linux-x86/clang-headers/__wmmintrin_aes.h (revision bed243d3d9cd544cfb038bfa7be843dedc6e6bf7)
1*bed243d3SAndroid Build Coastguard Worker /*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===
2*bed243d3SAndroid Build Coastguard Worker  *
3*bed243d3SAndroid Build Coastguard Worker  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bed243d3SAndroid Build Coastguard Worker  * See https://llvm.org/LICENSE.txt for license information.
5*bed243d3SAndroid Build Coastguard Worker  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bed243d3SAndroid Build Coastguard Worker  *
7*bed243d3SAndroid Build Coastguard Worker  *===-----------------------------------------------------------------------===
8*bed243d3SAndroid Build Coastguard Worker  */
9*bed243d3SAndroid Build Coastguard Worker 
10*bed243d3SAndroid Build Coastguard Worker #ifndef __WMMINTRIN_H
11*bed243d3SAndroid Build Coastguard Worker #error "Never use <__wmmintrin_aes.h> directly; include <wmmintrin.h> instead."
12*bed243d3SAndroid Build Coastguard Worker #endif
13*bed243d3SAndroid Build Coastguard Worker 
14*bed243d3SAndroid Build Coastguard Worker #ifndef __WMMINTRIN_AES_H
15*bed243d3SAndroid Build Coastguard Worker #define __WMMINTRIN_AES_H
16*bed243d3SAndroid Build Coastguard Worker 
17*bed243d3SAndroid Build Coastguard Worker /* Define the default attributes for the functions in this file. */
18*bed243d3SAndroid Build Coastguard Worker #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes"), __min_vector_width__(128)))
19*bed243d3SAndroid Build Coastguard Worker 
20*bed243d3SAndroid Build Coastguard Worker /// Performs a single round of AES encryption using the Equivalent
21*bed243d3SAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
22*bed243d3SAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
23*bed243d3SAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
24*bed243d3SAndroid Build Coastguard Worker ///
25*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
26*bed243d3SAndroid Build Coastguard Worker ///
27*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> VAESENC </c> instruction.
28*bed243d3SAndroid Build Coastguard Worker ///
29*bed243d3SAndroid Build Coastguard Worker /// \param __V
30*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
31*bed243d3SAndroid Build Coastguard Worker /// \param __R
32*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
33*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the encrypted value.
34*bed243d3SAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesenc_si128(__m128i __V,__m128i __R)35*bed243d3SAndroid Build Coastguard Worker _mm_aesenc_si128(__m128i __V, __m128i __R)
36*bed243d3SAndroid Build Coastguard Worker {
37*bed243d3SAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R);
38*bed243d3SAndroid Build Coastguard Worker }
39*bed243d3SAndroid Build Coastguard Worker 
40*bed243d3SAndroid Build Coastguard Worker /// Performs the final round of AES encryption using the Equivalent
41*bed243d3SAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
42*bed243d3SAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
43*bed243d3SAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
44*bed243d3SAndroid Build Coastguard Worker ///
45*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
46*bed243d3SAndroid Build Coastguard Worker ///
47*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> VAESENCLAST </c> instruction.
48*bed243d3SAndroid Build Coastguard Worker ///
49*bed243d3SAndroid Build Coastguard Worker /// \param __V
50*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
51*bed243d3SAndroid Build Coastguard Worker /// \param __R
52*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
53*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the encrypted value.
54*bed243d3SAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesenclast_si128(__m128i __V,__m128i __R)55*bed243d3SAndroid Build Coastguard Worker _mm_aesenclast_si128(__m128i __V, __m128i __R)
56*bed243d3SAndroid Build Coastguard Worker {
57*bed243d3SAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R);
58*bed243d3SAndroid Build Coastguard Worker }
59*bed243d3SAndroid Build Coastguard Worker 
60*bed243d3SAndroid Build Coastguard Worker /// Performs a single round of AES decryption using the Equivalent
61*bed243d3SAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
62*bed243d3SAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
63*bed243d3SAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
64*bed243d3SAndroid Build Coastguard Worker ///
65*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
66*bed243d3SAndroid Build Coastguard Worker ///
67*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> VAESDEC </c> instruction.
68*bed243d3SAndroid Build Coastguard Worker ///
69*bed243d3SAndroid Build Coastguard Worker /// \param __V
70*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
71*bed243d3SAndroid Build Coastguard Worker /// \param __R
72*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
73*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the decrypted value.
74*bed243d3SAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesdec_si128(__m128i __V,__m128i __R)75*bed243d3SAndroid Build Coastguard Worker _mm_aesdec_si128(__m128i __V, __m128i __R)
76*bed243d3SAndroid Build Coastguard Worker {
77*bed243d3SAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R);
78*bed243d3SAndroid Build Coastguard Worker }
79*bed243d3SAndroid Build Coastguard Worker 
80*bed243d3SAndroid Build Coastguard Worker /// Performs the final round of AES decryption using the Equivalent
81*bed243d3SAndroid Build Coastguard Worker ///    Inverse Cipher, transforming the state value from the first source
82*bed243d3SAndroid Build Coastguard Worker ///    operand using a 128-bit round key value contained in the second source
83*bed243d3SAndroid Build Coastguard Worker ///    operand, and writes the result to the destination.
84*bed243d3SAndroid Build Coastguard Worker ///
85*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
86*bed243d3SAndroid Build Coastguard Worker ///
87*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> VAESDECLAST </c> instruction.
88*bed243d3SAndroid Build Coastguard Worker ///
89*bed243d3SAndroid Build Coastguard Worker /// \param __V
90*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the state value.
91*bed243d3SAndroid Build Coastguard Worker /// \param __R
92*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the round key value.
93*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the decrypted value.
94*bed243d3SAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesdeclast_si128(__m128i __V,__m128i __R)95*bed243d3SAndroid Build Coastguard Worker _mm_aesdeclast_si128(__m128i __V, __m128i __R)
96*bed243d3SAndroid Build Coastguard Worker {
97*bed243d3SAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R);
98*bed243d3SAndroid Build Coastguard Worker }
99*bed243d3SAndroid Build Coastguard Worker 
100*bed243d3SAndroid Build Coastguard Worker /// Applies the AES InvMixColumns() transformation to an expanded key
101*bed243d3SAndroid Build Coastguard Worker ///    contained in the source operand, and writes the result to the
102*bed243d3SAndroid Build Coastguard Worker ///    destination.
103*bed243d3SAndroid Build Coastguard Worker ///
104*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
105*bed243d3SAndroid Build Coastguard Worker ///
106*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> VAESIMC </c> instruction.
107*bed243d3SAndroid Build Coastguard Worker ///
108*bed243d3SAndroid Build Coastguard Worker /// \param __V
109*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector containing the expanded key.
110*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the transformed value.
111*bed243d3SAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_aesimc_si128(__m128i __V)112*bed243d3SAndroid Build Coastguard Worker _mm_aesimc_si128(__m128i __V)
113*bed243d3SAndroid Build Coastguard Worker {
114*bed243d3SAndroid Build Coastguard Worker   return (__m128i)__builtin_ia32_aesimc128((__v2di)__V);
115*bed243d3SAndroid Build Coastguard Worker }
116*bed243d3SAndroid Build Coastguard Worker 
117*bed243d3SAndroid Build Coastguard Worker /// Generates a round key for AES encryption, operating on 128-bit data
118*bed243d3SAndroid Build Coastguard Worker ///    specified in the first source operand and using an 8-bit round constant
119*bed243d3SAndroid Build Coastguard Worker ///    specified by the second source operand, and writes the result to the
120*bed243d3SAndroid Build Coastguard Worker ///    destination.
121*bed243d3SAndroid Build Coastguard Worker ///
122*bed243d3SAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
123*bed243d3SAndroid Build Coastguard Worker ///
124*bed243d3SAndroid Build Coastguard Worker /// \code
125*bed243d3SAndroid Build Coastguard Worker /// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);
126*bed243d3SAndroid Build Coastguard Worker /// \endcode
127*bed243d3SAndroid Build Coastguard Worker ///
128*bed243d3SAndroid Build Coastguard Worker /// This intrinsic corresponds to the <c> AESKEYGENASSIST </c> instruction.
129*bed243d3SAndroid Build Coastguard Worker ///
130*bed243d3SAndroid Build Coastguard Worker /// \param C
131*bed243d3SAndroid Build Coastguard Worker ///    A 128-bit integer vector that is used to generate the AES encryption key.
132*bed243d3SAndroid Build Coastguard Worker /// \param R
133*bed243d3SAndroid Build Coastguard Worker ///    An 8-bit round constant used to generate the AES encryption key.
134*bed243d3SAndroid Build Coastguard Worker /// \returns A 128-bit round key for AES encryption.
135*bed243d3SAndroid Build Coastguard Worker #define _mm_aeskeygenassist_si128(C, R) \
136*bed243d3SAndroid Build Coastguard Worker   ((__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R)))
137*bed243d3SAndroid Build Coastguard Worker 
138*bed243d3SAndroid Build Coastguard Worker #undef __DEFAULT_FN_ATTRS
139*bed243d3SAndroid Build Coastguard Worker 
140*bed243d3SAndroid Build Coastguard Worker #endif  /* __WMMINTRIN_AES_H */
141