| 1 |
/* Copyright (C) 2008-2015 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 3, 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 |
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. |
| 18 |
|
| 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/>. */ |
| 23 |
|
| 24 |
/* Implemented from the specification included in the Intel C++ Compiler |
| 25 |
User Guide and Reference, version 10.1. */ |
| 26 |
|
| 27 |
#ifndef _WMMINTRIN_H_INCLUDED |
| 28 |
#define _WMMINTRIN_H_INCLUDED |
| 29 |
|
| 30 |
/* We need definitions from the SSE2 header file. */ |
| 31 |
#include <emmintrin.h> |
| 32 |
|
| 33 |
/* AES */ |
| 34 |
|
| 35 |
#ifndef __AES__ |
| 36 |
#pragma GCC push_options |
| 37 |
#pragma GCC target("aes") |
| 38 |
#define __DISABLE_AES__ |
| 39 |
#endif /* __AES__ */ |
| 40 |
|
| 41 |
/* Performs 1 round of AES decryption of the first m128i using |
| 42 |
the second m128i as a round key. */ |
| 43 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 44 |
_mm_aesdec_si128 (__m128i __X, __m128i __Y) |
| 45 |
{ |
| 46 |
return (__m128i) __builtin_ia32_aesdec128 ((__v2di)__X, (__v2di)__Y); |
| 47 |
} |
| 48 |
|
| 49 |
/* Performs the last round of AES decryption of the first m128i |
| 50 |
using the second m128i as a round key. */ |
| 51 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 52 |
_mm_aesdeclast_si128 (__m128i __X, __m128i __Y) |
| 53 |
{ |
| 54 |
return (__m128i) __builtin_ia32_aesdeclast128 ((__v2di)__X, |
| 55 |
(__v2di)__Y); |
| 56 |
} |
| 57 |
|
| 58 |
/* Performs 1 round of AES encryption of the first m128i using |
| 59 |
the second m128i as a round key. */ |
| 60 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 61 |
_mm_aesenc_si128 (__m128i __X, __m128i __Y) |
| 62 |
{ |
| 63 |
return (__m128i) __builtin_ia32_aesenc128 ((__v2di)__X, (__v2di)__Y); |
| 64 |
} |
| 65 |
|
| 66 |
/* Performs the last round of AES encryption of the first m128i |
| 67 |
using the second m128i as a round key. */ |
| 68 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 69 |
_mm_aesenclast_si128 (__m128i __X, __m128i __Y) |
| 70 |
{ |
| 71 |
return (__m128i) __builtin_ia32_aesenclast128 ((__v2di)__X, (__v2di)__Y); |
| 72 |
} |
| 73 |
|
| 74 |
/* Performs the InverseMixColumn operation on the source m128i |
| 75 |
and stores the result into m128i destination. */ |
| 76 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 77 |
_mm_aesimc_si128 (__m128i __X) |
| 78 |
{ |
| 79 |
return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X); |
| 80 |
} |
| 81 |
|
| 82 |
/* Generates a m128i round key for the input m128i AES cipher key and |
| 83 |
byte round constant. The second parameter must be a compile time |
| 84 |
constant. */ |
| 85 |
#ifdef __OPTIMIZE__ |
| 86 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 87 |
_mm_aeskeygenassist_si128 (__m128i __X, const int __C) |
| 88 |
{ |
| 89 |
return (__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)__X, __C); |
| 90 |
} |
| 91 |
#else |
| 92 |
#define _mm_aeskeygenassist_si128(X, C) \ |
| 93 |
((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \ |
| 94 |
(int)(C))) |
| 95 |
#endif |
| 96 |
|
| 97 |
#ifdef __DISABLE_AES__ |
| 98 |
#undef __DISABLE_AES__ |
| 99 |
#pragma GCC pop_options |
| 100 |
#endif /* __DISABLE_AES__ */ |
| 101 |
|
| 102 |
/* PCLMUL */ |
| 103 |
|
| 104 |
#ifndef __PCLMUL__ |
| 105 |
#pragma GCC push_options |
| 106 |
#pragma GCC target("pclmul") |
| 107 |
#define __DISABLE_PCLMUL__ |
| 108 |
#endif /* __PCLMUL__ */ |
| 109 |
|
| 110 |
/* Performs carry-less integer multiplication of 64-bit halves of |
| 111 |
128-bit input operands. The third parameter inducates which 64-bit |
| 112 |
haves of the input parameters v1 and v2 should be used. It must be |
| 113 |
a compile time constant. */ |
| 114 |
#ifdef __OPTIMIZE__ |
| 115 |
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 116 |
_mm_clmulepi64_si128 (__m128i __X, __m128i __Y, const int __I) |
| 117 |
{ |
| 118 |
return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X, |
| 119 |
(__v2di)__Y, __I); |
| 120 |
} |
| 121 |
#else |
| 122 |
#define _mm_clmulepi64_si128(X, Y, I) \ |
| 123 |
((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \ |
| 124 |
(__v2di)(__m128i)(Y), (int)(I))) |
| 125 |
#endif |
| 126 |
|
| 127 |
#ifdef __DISABLE_PCLMUL__ |
| 128 |
#undef __DISABLE_PCLMUL__ |
| 129 |
#pragma GCC pop_options |
| 130 |
#endif /* __DISABLE_PCLMUL__ */ |
| 131 |
|
| 132 |
#endif /* _WMMINTRIN_H_INCLUDED */ |