Skip to content

Commit 0139d83

Browse files
committed
Initial commit
1 parent 1f528bf commit 0139d83

File tree

903 files changed

+263186
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

903 files changed

+263186
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.exe
2+
*.elf
3+
*.self
4+
*.pkg
5+
*.o
6+
*.a
7+
*.d
8+
.DS_Store
9+
._*

include/__wmmintrin_aes.h

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

include/__wmmintrin_pclmul.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*===---- __wmmintrin_pclmul.h - PCMUL intrinsics ---------------------------===
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
* THE SOFTWARE.
20+
*
21+
*===-----------------------------------------------------------------------===
22+
*/
23+
24+
#ifndef __WMMINTRIN_H
25+
#error "Never use <__wmmintrin_pclmul.h> directly; include <wmmintrin.h> instead."
26+
#endif
27+
28+
#ifndef __WMMINTRIN_PCLMUL_H
29+
#define __WMMINTRIN_PCLMUL_H
30+
31+
/// Multiplies two 64-bit integer values, which are selected from source
32+
/// operands using the immediate-value operand. The multiplication is a
33+
/// carry-less multiplication, and the 128-bit integer product is stored in
34+
/// the destination.
35+
///
36+
/// \headerfile <x86intrin.h>
37+
///
38+
/// \code
39+
/// __m128i _mm_clmulepi64_si128(__m128i __X, __m128i __Y, const int __I);
40+
/// \endcode
41+
///
42+
/// This intrinsic corresponds to the <c> VPCLMULQDQ </c> instruction.
43+
///
44+
/// \param __X
45+
/// A 128-bit vector of [2 x i64] containing one of the source operands.
46+
/// \param __Y
47+
/// A 128-bit vector of [2 x i64] containing one of the source operands.
48+
/// \param __I
49+
/// An immediate value specifying which 64-bit values to select from the
50+
/// operands. Bit 0 is used to select a value from operand \a __X, and bit
51+
/// 4 is used to select a value from operand \a __Y: \n
52+
/// Bit[0]=0 indicates that bits[63:0] of operand \a __X are used. \n
53+
/// Bit[0]=1 indicates that bits[127:64] of operand \a __X are used. \n
54+
/// Bit[4]=0 indicates that bits[63:0] of operand \a __Y are used. \n
55+
/// Bit[4]=1 indicates that bits[127:64] of operand \a __Y are used.
56+
/// \returns The 128-bit integer vector containing the result of the carry-less
57+
/// multiplication of the selected 64-bit values.
58+
#define _mm_clmulepi64_si128(X, Y, I) \
59+
((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(X), \
60+
(__v2di)(__m128i)(Y), (char)(I)))
61+
62+
#endif /* __WMMINTRIN_PCLMUL_H */

0 commit comments

Comments
 (0)