]>
Commit | Line | Data |
---|---|---|
8b96a312 L |
1 | /* Copyright (C) 2008 Free Software Foundation, Inc. |
2 | ||
3 | This file is part of GCC. | |
4 | ||
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 2, or (at your option) | |
8 | any later version. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with GCC; see the file COPYING. If not, write to | |
17 | the Free Software Foundation, 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | /* As a special exception, if you include this header file into source | |
21 | files compiled by GCC, this header file does not by itself cause | |
22 | the resulting executable to be covered by the GNU General Public | |
23 | License. This exception does not however invalidate any other | |
24 | reasons why the executable file might be covered by the GNU General | |
25 | Public License. */ | |
26 | ||
27 | /* Implemented from the specification included in the Intel C++ Compiler | |
28 | User Guide and Reference, version 10.1. */ | |
29 | ||
30 | #ifndef _WMMINTRIN_H_INCLUDED | |
31 | #define _WMMINTRIN_H_INCLUDED | |
32 | ||
33 | /* We need definitions from the SSE2 header file. */ | |
34 | #include <emmintrin.h> | |
35 | ||
36 | #if !defined (__AES__) && !defined (__PCLMUL__) | |
37 | # error "AES/PCLMUL instructions not enabled" | |
38 | #else | |
39 | ||
40 | /* AES */ | |
41 | ||
42 | #ifdef __AES__ | |
43 | /* Performs 1 round of AES decryption of the first m128i using | |
44 | the second m128i as a round key. */ | |
45 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
46 | _mm_aesdec_si128 (__m128i __X, __m128i __Y) | |
47 | { | |
48 | return (__m128i) __builtin_ia32_aesdec128 ((__v2di)__X, (__v2di)__Y); | |
49 | } | |
50 | ||
51 | /* Performs the last round of AES decryption of the first m128i | |
52 | using the second m128i as a round key. */ | |
53 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
54 | _mm_aesdeclast_si128 (__m128i __X, __m128i __Y) | |
55 | { | |
56 | return (__m128i) __builtin_ia32_aesdeclast128 ((__v2di)__X, | |
57 | (__v2di)__Y); | |
58 | } | |
59 | ||
60 | /* Performs 1 round of AES encryption of the first m128i using | |
61 | the second m128i as a round key. */ | |
62 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
63 | _mm_aesenc_si128 (__m128i __X, __m128i __Y) | |
64 | { | |
65 | return (__m128i) __builtin_ia32_aesenc128 ((__v2di)__X, (__v2di)__Y); | |
66 | } | |
67 | ||
68 | /* Performs the last round of AES encryption of the first m128i | |
69 | using the second m128i as a round key. */ | |
70 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
71 | _mm_aesenclast_si128 (__m128i __X, __m128i __Y) | |
72 | { | |
73 | return (__m128i) __builtin_ia32_aesenclast128 ((__v2di)__X, (__v2di)__Y); | |
74 | } | |
75 | ||
76 | /* Performs the InverseMixColumn operation on the source m128i | |
77 | and stores the result into m128i destination. */ | |
78 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
79 | _mm_aesimc_si128 (__m128i __X) | |
80 | { | |
81 | return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X); | |
82 | } | |
83 | ||
84 | /* Generates a m128i round key for the input m128i AES cipher key and | |
85 | byte round constant. The second parameter must be a compile time | |
86 | constant. */ | |
87 | #ifdef __OPTIMIZE__ | |
88 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
89 | _mm_aeskeygenassist_si128 (__m128i __X, const int __C) | |
90 | { | |
91 | return (__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)__X, __C); | |
92 | } | |
93 | #else | |
94 | #define _mm_aeskeygenassist_si128(X, C) \ | |
95 | ((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \ | |
96 | (int)(C))) | |
97 | #endif | |
98 | #endif /* __AES__ */ | |
99 | ||
100 | /* PCLMUL */ | |
101 | ||
102 | #ifdef __PCLMUL__ | |
103 | /* Performs carry-less integer multiplication of 64-bit halves of | |
104 | 128-bit input operands. The third parameter inducates which 64-bit | |
105 | haves of the input parameters v1 and v2 should be used. It must be | |
106 | a compile time constant. */ | |
107 | #ifdef __OPTIMIZE__ | |
108 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
109 | _mm_clmulepi64_si128 (__m128i __X, __m128i __Y, const int __I) | |
110 | { | |
111 | return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X, | |
112 | (__v2di)__Y, __I); | |
113 | } | |
114 | #else | |
115 | #define _mm_clmulepi64_si128(X, Y, I) \ | |
116 | ((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \ | |
117 | (__v2di)(__m128i)(Y), (int)(I))) | |
118 | #endif | |
119 | #endif /* __PCLMUL__ */ | |
120 | ||
121 | #endif /* __AES__/__PCLMUL__ */ | |
122 | ||
123 | #endif /* _WMMINTRIN_H_INCLUDED */ |