Daily bump.
[official-gcc.git] / gcc / config / i386 / wmmintrin.h
blob2c4bdc99aa9c3a62bbe3b34e1ae50a7fa6a0007a
1 /* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3 This file is part of GCC.
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 3, or (at your option)
8 any later version.
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.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* Implemented from the specification included in the Intel C++ Compiler
25 User Guide and Reference, version 10.1. */
27 #ifndef _WMMINTRIN_H_INCLUDED
28 #define _WMMINTRIN_H_INCLUDED
30 /* We need definitions from the SSE2 header file. */
31 #include <emmintrin.h>
33 #if !defined (__AES__) && !defined (__PCLMUL__)
34 # error "AES/PCLMUL instructions not enabled"
35 #else
37 /* AES */
39 #ifdef __AES__
40 /* Performs 1 round of AES decryption of the first m128i using
41 the second m128i as a round key. */
42 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
43 _mm_aesdec_si128 (__m128i __X, __m128i __Y)
45 return (__m128i) __builtin_ia32_aesdec128 ((__v2di)__X, (__v2di)__Y);
48 /* Performs the last round of AES decryption of the first m128i
49 using the second m128i as a round key. */
50 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
51 _mm_aesdeclast_si128 (__m128i __X, __m128i __Y)
53 return (__m128i) __builtin_ia32_aesdeclast128 ((__v2di)__X,
54 (__v2di)__Y);
57 /* Performs 1 round of AES encryption of the first m128i using
58 the second m128i as a round key. */
59 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
60 _mm_aesenc_si128 (__m128i __X, __m128i __Y)
62 return (__m128i) __builtin_ia32_aesenc128 ((__v2di)__X, (__v2di)__Y);
65 /* Performs the last round of AES encryption of the first m128i
66 using the second m128i as a round key. */
67 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
68 _mm_aesenclast_si128 (__m128i __X, __m128i __Y)
70 return (__m128i) __builtin_ia32_aesenclast128 ((__v2di)__X, (__v2di)__Y);
73 /* Performs the InverseMixColumn operation on the source m128i
74 and stores the result into m128i destination. */
75 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
76 _mm_aesimc_si128 (__m128i __X)
78 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
81 /* Generates a m128i round key for the input m128i AES cipher key and
82 byte round constant. The second parameter must be a compile time
83 constant. */
84 #ifdef __OPTIMIZE__
85 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
86 _mm_aeskeygenassist_si128 (__m128i __X, const int __C)
88 return (__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)__X, __C);
90 #else
91 #define _mm_aeskeygenassist_si128(X, C) \
92 ((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \
93 (int)(C)))
94 #endif
95 #endif /* __AES__ */
97 /* PCLMUL */
99 #ifdef __PCLMUL__
100 /* Performs carry-less integer multiplication of 64-bit halves of
101 128-bit input operands. The third parameter inducates which 64-bit
102 haves of the input parameters v1 and v2 should be used. It must be
103 a compile time constant. */
104 #ifdef __OPTIMIZE__
105 extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
106 _mm_clmulepi64_si128 (__m128i __X, __m128i __Y, const int __I)
108 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
109 (__v2di)__Y, __I);
111 #else
112 #define _mm_clmulepi64_si128(X, Y, I) \
113 ((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \
114 (__v2di)(__m128i)(Y), (int)(I)))
115 #endif
116 #endif /* __PCLMUL__ */
118 #endif /* __AES__/__PCLMUL__ */
120 #endif /* _WMMINTRIN_H_INCLUDED */