1 /* Copyright (C) 2017-2018 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 #ifndef __VAESINTRIN_H_INCLUDED 25 #define __VAESINTRIN_H_INCLUDED 26 27 #if !defined(__VAES__) || !defined(__AVX__) 28 #pragma GCC push_options 29 #pragma GCC target("vaes,avx") 30 #define __DISABLE_VAES__ 31 #endif /* __VAES__ */ 32 33 extern __inline __m256i 34 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 35 _mm256_aesdec_epi128 (__m256i __A, __m256i __B) 36 { 37 return (__m256i)__builtin_ia32_vaesdec_v32qi ((__v32qi) __A, (__v32qi) __B); 38 } 39 40 extern __inline __m256i 41 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 42 _mm256_aesdeclast_epi128 (__m256i __A, __m256i __B) 43 { 44 return (__m256i)__builtin_ia32_vaesdeclast_v32qi ((__v32qi) __A, 45 (__v32qi) __B); 46 } 47 48 extern __inline __m256i 49 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 50 _mm256_aesenc_epi128 (__m256i __A, __m256i __B) 51 { 52 return (__m256i)__builtin_ia32_vaesenc_v32qi ((__v32qi) __A, (__v32qi) __B); 53 } 54 55 extern __inline __m256i 56 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 57 _mm256_aesenclast_epi128 (__m256i __A, __m256i __B) 58 { 59 return (__m256i)__builtin_ia32_vaesenclast_v32qi ((__v32qi) __A, 60 (__v32qi) __B); 61 } 62 63 #ifdef __DISABLE_VAES__ 64 #undef __DISABLE_VAES__ 65 #pragma GCC pop_options 66 #endif /* __DISABLE_VAES__ */ 67 68 69 #if !defined(__VAES__) || !defined(__AVX512F__) 70 #pragma GCC push_options 71 #pragma GCC target("vaes,avx512f") 72 #define __DISABLE_VAESF__ 73 #endif /* __VAES__ */ 74 75 76 extern __inline __m512i 77 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 78 _mm512_aesdec_epi128 (__m512i __A, __m512i __B) 79 { 80 return (__m512i)__builtin_ia32_vaesdec_v64qi ((__v64qi) __A, (__v64qi) __B); 81 } 82 83 extern __inline __m512i 84 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 85 _mm512_aesdeclast_epi128 (__m512i __A, __m512i __B) 86 { 87 return (__m512i)__builtin_ia32_vaesdeclast_v64qi ((__v64qi) __A, 88 (__v64qi) __B); 89 } 90 91 extern __inline __m512i 92 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 93 _mm512_aesenc_epi128 (__m512i __A, __m512i __B) 94 { 95 return (__m512i)__builtin_ia32_vaesenc_v64qi ((__v64qi) __A, (__v64qi) __B); 96 } 97 98 extern __inline __m512i 99 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 100 _mm512_aesenclast_epi128 (__m512i __A, __m512i __B) 101 { 102 return (__m512i)__builtin_ia32_vaesenclast_v64qi ((__v64qi) __A, 103 (__v64qi) __B); 104 } 105 106 #ifdef __DISABLE_VAESF__ 107 #undef __DISABLE_VAESF__ 108 #pragma GCC pop_options 109 #endif /* __DISABLE_VAES__ */ 110 111 #if !defined(__VAES__) || !defined(__AVX512VL__) 112 #pragma GCC push_options 113 #pragma GCC target("vaes,avx512vl") 114 #define __DISABLE_VAESVL__ 115 #endif /* __VAES__ */ 116 117 extern __inline __m128i 118 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 119 _mm_aesdec_epi128 (__m128i __A, __m128i __B) 120 { 121 return (__m128i)__builtin_ia32_vaesdec_v16qi ((__v16qi) __A, (__v16qi) __B); 122 } 123 124 extern __inline __m128i 125 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 126 _mm_aesdeclast_epi128 (__m128i __A, __m128i __B) 127 { 128 return (__m128i)__builtin_ia32_vaesdeclast_v16qi ((__v16qi) __A, 129 (__v16qi) __B); 130 } 131 132 extern __inline __m128i 133 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 134 _mm_aesenc_epi128 (__m128i __A, __m128i __B) 135 { 136 return (__m128i)__builtin_ia32_vaesenc_v16qi ((__v16qi) __A, (__v16qi) __B); 137 } 138 139 extern __inline __m128i 140 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 141 _mm_aesenclast_epi128 (__m128i __A, __m128i __B) 142 { 143 return (__m128i)__builtin_ia32_vaesenclast_v16qi ((__v16qi) __A, 144 (__v16qi) __B); 145 } 146 147 #ifdef __DISABLE_VAESVL__ 148 #undef __DISABLE_VAESVL__ 149 #pragma GCC pop_options 150 #endif /* __DISABLE_VAES__ */ 151 #endif /* __VAESINTRIN_H_INCLUDED */ 152