]>
Commit | Line | Data |
---|---|---|
99dee823 | 1 | /* Copyright (C) 2018-2021 Free Software Foundation, Inc. |
98e07d5c PC |
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 9.0. | |
26 | ||
27 | NOTE: This is NOT a complete implementation of the SSE4 intrinsics! */ | |
28 | ||
29 | #ifndef NO_WARN_X86_INTRINSICS | |
30 | /* This header is distributed to simplify porting x86_64 code that | |
31 | makes explicit use of Intel intrinsics to powerpc64le. | |
32 | It is the user's responsibility to determine if the results are | |
33 | acceptable and make additional changes as necessary. | |
34 | Note that much code that uses Intel intrinsics can be rewritten in | |
35 | standard C or GNU C extensions, which are more portable and better | |
36 | optimized across multiple targets. */ | |
37 | #endif | |
38 | ||
39 | #ifndef SMMINTRIN_H_ | |
40 | #define SMMINTRIN_H_ | |
41 | ||
42 | #include <altivec.h> | |
43 | #include <tmmintrin.h> | |
44 | ||
4d09cc91 PC |
45 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
46 | _mm_insert_epi8 (__m128i const __A, int const __D, int const __N) | |
47 | { | |
48 | __v16qi result = (__v16qi)__A; | |
49 | ||
50 | result [__N & 0xf] = __D; | |
51 | ||
52 | return (__m128i) result; | |
53 | } | |
54 | ||
55 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
56 | _mm_insert_epi32 (__m128i const __A, int const __D, int const __N) | |
57 | { | |
58 | __v4si result = (__v4si)__A; | |
59 | ||
60 | result [__N & 3] = __D; | |
61 | ||
62 | return (__m128i) result; | |
63 | } | |
64 | ||
65 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
66 | _mm_insert_epi64 (__m128i const __A, long long const __D, int const __N) | |
67 | { | |
68 | __v2di result = (__v2di)__A; | |
69 | ||
70 | result [__N & 1] = __D; | |
71 | ||
72 | return (__m128i) result; | |
73 | } | |
74 | ||
98e07d5c PC |
75 | extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
76 | _mm_extract_epi8 (__m128i __X, const int __N) | |
77 | { | |
78 | return (unsigned char) ((__v16qi)__X)[__N & 15]; | |
79 | } | |
80 | ||
81 | extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
82 | _mm_extract_epi32 (__m128i __X, const int __N) | |
83 | { | |
84 | return ((__v4si)__X)[__N & 3]; | |
85 | } | |
86 | ||
87 | extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
88 | _mm_extract_epi64 (__m128i __X, const int __N) | |
89 | { | |
90 | return ((__v2di)__X)[__N & 1]; | |
91 | } | |
92 | ||
93 | extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
94 | _mm_extract_ps (__m128 __X, const int __N) | |
95 | { | |
96 | return ((__v4si)__X)[__N & 3]; | |
97 | } | |
98 | ||
1c4547f1 PC |
99 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
100 | _mm_blend_epi16 (__m128i __A, __m128i __B, const int __imm8) | |
101 | { | |
102 | __v16qi __charmask = vec_splats ((signed char) __imm8); | |
103 | __charmask = vec_gb (__charmask); | |
104 | __v8hu __shortmask = (__v8hu) vec_unpackh (__charmask); | |
105 | #ifdef __BIG_ENDIAN__ | |
106 | __shortmask = vec_reve (__shortmask); | |
107 | #endif | |
108 | return (__m128i) vec_sel ((__v8hu) __A, (__v8hu) __B, __shortmask); | |
109 | } | |
110 | ||
111 | extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) | |
112 | _mm_blendv_epi8 (__m128i __A, __m128i __B, __m128i __mask) | |
113 | { | |
114 | const __v16qu __seven = vec_splats ((unsigned char) 0x07); | |
115 | __v16qu __lmask = vec_sra ((__v16qu) __mask, __seven); | |
116 | return (__m128i) vec_sel ((__v16qu) __A, (__v16qu) __B, __lmask); | |
117 | } | |
118 | ||
98e07d5c | 119 | #endif |