1 1.12 mrg /* Copyright (C) 2008-2022 Free Software Foundation, Inc. 2 1.1 mrg 3 1.1 mrg This file is part of GCC. 4 1.1 mrg 5 1.1 mrg GCC is free software; you can redistribute it and/or modify 6 1.1 mrg it under the terms of the GNU General Public License as published by 7 1.1 mrg the Free Software Foundation; either version 3, or (at your option) 8 1.1 mrg any later version. 9 1.1 mrg 10 1.1 mrg GCC is distributed in the hope that it will be useful, 11 1.1 mrg but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 mrg GNU General Public License for more details. 14 1.1 mrg 15 1.1 mrg Under Section 7 of GPL version 3, you are granted additional 16 1.1 mrg permissions described in the GCC Runtime Library Exception, version 17 1.1 mrg 3.1, as published by the Free Software Foundation. 18 1.1 mrg 19 1.1 mrg You should have received a copy of the GNU General Public License and 20 1.1 mrg a copy of the GCC Runtime Library Exception along with this program; 21 1.1 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 1.1 mrg <http://www.gnu.org/licenses/>. */ 23 1.1 mrg 24 1.1 mrg /* Implemented from the specification included in the Intel C++ Compiler 25 1.1 mrg User Guide and Reference, version 10.1. */ 26 1.1 mrg 27 1.1 mrg #ifndef _WMMINTRIN_H_INCLUDED 28 1.1 mrg #define _WMMINTRIN_H_INCLUDED 29 1.1 mrg 30 1.1 mrg /* We need definitions from the SSE2 header file. */ 31 1.1 mrg #include <emmintrin.h> 32 1.1 mrg 33 1.5 mrg /* AES */ 34 1.1 mrg 35 1.9 mrg #if !defined(__AES__) || !defined(__SSE2__) 36 1.5 mrg #pragma GCC push_options 37 1.9 mrg #pragma GCC target("aes,sse2") 38 1.5 mrg #define __DISABLE_AES__ 39 1.5 mrg #endif /* __AES__ */ 40 1.1 mrg 41 1.1 mrg /* Performs 1 round of AES decryption of the first m128i using 42 1.1 mrg the second m128i as a round key. */ 43 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 44 1.1 mrg _mm_aesdec_si128 (__m128i __X, __m128i __Y) 45 1.1 mrg { 46 1.1 mrg return (__m128i) __builtin_ia32_aesdec128 ((__v2di)__X, (__v2di)__Y); 47 1.1 mrg } 48 1.1 mrg 49 1.1 mrg /* Performs the last round of AES decryption of the first m128i 50 1.1 mrg using the second m128i as a round key. */ 51 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 52 1.1 mrg _mm_aesdeclast_si128 (__m128i __X, __m128i __Y) 53 1.1 mrg { 54 1.1 mrg return (__m128i) __builtin_ia32_aesdeclast128 ((__v2di)__X, 55 1.1 mrg (__v2di)__Y); 56 1.1 mrg } 57 1.1 mrg 58 1.1 mrg /* Performs 1 round of AES encryption of the first m128i using 59 1.1 mrg the second m128i as a round key. */ 60 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 61 1.1 mrg _mm_aesenc_si128 (__m128i __X, __m128i __Y) 62 1.1 mrg { 63 1.1 mrg return (__m128i) __builtin_ia32_aesenc128 ((__v2di)__X, (__v2di)__Y); 64 1.1 mrg } 65 1.1 mrg 66 1.1 mrg /* Performs the last round of AES encryption of the first m128i 67 1.1 mrg using the second m128i as a round key. */ 68 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 69 1.1 mrg _mm_aesenclast_si128 (__m128i __X, __m128i __Y) 70 1.1 mrg { 71 1.1 mrg return (__m128i) __builtin_ia32_aesenclast128 ((__v2di)__X, (__v2di)__Y); 72 1.1 mrg } 73 1.1 mrg 74 1.1 mrg /* Performs the InverseMixColumn operation on the source m128i 75 1.1 mrg and stores the result into m128i destination. */ 76 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 77 1.1 mrg _mm_aesimc_si128 (__m128i __X) 78 1.1 mrg { 79 1.1 mrg return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X); 80 1.1 mrg } 81 1.1 mrg 82 1.1 mrg /* Generates a m128i round key for the input m128i AES cipher key and 83 1.1 mrg byte round constant. The second parameter must be a compile time 84 1.1 mrg constant. */ 85 1.1 mrg #ifdef __OPTIMIZE__ 86 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 87 1.1 mrg _mm_aeskeygenassist_si128 (__m128i __X, const int __C) 88 1.1 mrg { 89 1.1 mrg return (__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)__X, __C); 90 1.1 mrg } 91 1.1 mrg #else 92 1.1 mrg #define _mm_aeskeygenassist_si128(X, C) \ 93 1.1 mrg ((__m128i) __builtin_ia32_aeskeygenassist128 ((__v2di)(__m128i)(X), \ 94 1.1 mrg (int)(C))) 95 1.1 mrg #endif 96 1.5 mrg 97 1.5 mrg #ifdef __DISABLE_AES__ 98 1.5 mrg #undef __DISABLE_AES__ 99 1.5 mrg #pragma GCC pop_options 100 1.5 mrg #endif /* __DISABLE_AES__ */ 101 1.1 mrg 102 1.1 mrg /* PCLMUL */ 103 1.1 mrg 104 1.9 mrg #if !defined(__PCLMUL__) || !defined(__SSE2__) 105 1.5 mrg #pragma GCC push_options 106 1.9 mrg #pragma GCC target("pclmul,sse2") 107 1.5 mrg #define __DISABLE_PCLMUL__ 108 1.5 mrg #endif /* __PCLMUL__ */ 109 1.5 mrg 110 1.1 mrg /* Performs carry-less integer multiplication of 64-bit halves of 111 1.1 mrg 128-bit input operands. The third parameter inducates which 64-bit 112 1.1 mrg haves of the input parameters v1 and v2 should be used. It must be 113 1.1 mrg a compile time constant. */ 114 1.1 mrg #ifdef __OPTIMIZE__ 115 1.1 mrg extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 116 1.1 mrg _mm_clmulepi64_si128 (__m128i __X, __m128i __Y, const int __I) 117 1.1 mrg { 118 1.1 mrg return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X, 119 1.1 mrg (__v2di)__Y, __I); 120 1.1 mrg } 121 1.1 mrg #else 122 1.1 mrg #define _mm_clmulepi64_si128(X, Y, I) \ 123 1.1 mrg ((__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)(__m128i)(X), \ 124 1.1 mrg (__v2di)(__m128i)(Y), (int)(I))) 125 1.1 mrg #endif 126 1.1 mrg 127 1.5 mrg #ifdef __DISABLE_PCLMUL__ 128 1.5 mrg #undef __DISABLE_PCLMUL__ 129 1.5 mrg #pragma GCC pop_options 130 1.5 mrg #endif /* __DISABLE_PCLMUL__ */ 131 1.1 mrg 132 1.1 mrg #endif /* _WMMINTRIN_H_INCLUDED */ 133