]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/s390/vecintrin.h
S/390: Fix vec_splat_* builtins.
[thirdparty/gcc.git] / gcc / config / s390 / vecintrin.h
1 /* GNU compiler hardware transactional execution intrinsics
2 Copyright (C) 2015 Free Software Foundation, Inc.
3 Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #ifndef _VECINTRIN_H
22 #define _VECINTRIN_H
23
24 #ifdef __VEC__
25
26 #define __VFTCI_ZERO 1<<11
27 #define __VFTCI_ZERO_N 1<<10
28 #define __VFTCI_NORMAL 1<<9
29 #define __VFTCI_NORMAL_N 1<<8
30 #define __VFTCI_SUBNORMAL 1<<7
31 #define __VFTCI_SUBNORMAL_N 1<<6
32 #define __VFTCI_INF 1<<5
33 #define __VFTCI_INF_N 1<<4
34 #define __VFTCI_QNAN 1<<3
35 #define __VFTCI_QNAN_N 1<<2
36 #define __VFTCI_SNAN 1<<1
37 #define __VFTCI_SNAN_N 1<<0
38
39 /* This also accepts a type for its parameter, so it is not enough
40 to #define vec_step to __builtin_vec_step. */
41 #define vec_step(x) __builtin_vec_step (* (__typeof__ (x) *) 0)
42
43 static inline int
44 __lcbb(const void *ptr, int bndry)
45 {
46 int code;
47 switch (bndry)
48 {
49 case 64: code = 0; break;
50 case 128: code = 1; break;
51 case 256: code = 2; break;
52 case 512: code = 3; break;
53 case 1024: code = 4; break;
54 case 2048: code = 5; break;
55 case 4096: code = 6; break;
56 default: return 0;
57 }
58 return __builtin_s390_lcbb (ptr, code);
59 }
60
61 #define vec_all_nle(X, Y) vec_all_nge ((Y), (X))
62 #define vec_all_nlt(X, Y) vec_all_ngt ((Y), (X))
63 #define vec_any_nle(X, Y) vec_any_nge ((Y), (X))
64 #define vec_any_nlt(X, Y) vec_any_ngt ((Y), (X))
65 #define vec_genmask __builtin_s390_vgbm
66 #define vec_genmasks_8 __builtin_s390_vgmb
67 #define vec_genmasks_16 __builtin_s390_vgmh
68 #define vec_genmasks_32 __builtin_s390_vgmf
69 #define vec_genmasks_64 __builtin_s390_vgmg
70 #define vec_splat_u8 __builtin_s390_vec_splat_u8
71 #define vec_splat_s8 __builtin_s390_vec_splat_s8
72 #define vec_splat_u16 __builtin_s390_vec_splat_u16
73 #define vec_splat_s16 __builtin_s390_vec_splat_s16
74 #define vec_splat_u32 __builtin_s390_vec_splat_u32
75 #define vec_splat_s32 __builtin_s390_vec_splat_s32
76 #define vec_splat_u64 __builtin_s390_vec_splat_u64
77 #define vec_splat_s64 __builtin_s390_vec_splat_s64
78 #define vec_add_u128 __builtin_s390_vaq
79 #define vec_addc_u128 __builtin_s390_vaccq
80 #define vec_adde_u128 __builtin_s390_vacq
81 #define vec_addec_u128 __builtin_s390_vacccq
82 #define vec_checksum __builtin_s390_vcksm
83 #define vec_gfmsum_128 __builtin_s390_vgfmg
84 #define vec_gfmsum_accum_128 __builtin_s390_vgfmag
85 #define vec_subc_u128 __builtin_s390_vscbiq
86 #define vec_sube_u128 __builtin_s390_vsbiq
87 #define vec_subec_u128 __builtin_s390_vsbcbiq
88 #define vec_ceil(X) __builtin_s390_vfidb((X), 4, 6)
89 #define vec_roundp(X) __builtin_s390_vfidb((X), 4, 6)
90 #define vec_floor(X) __builtin_s390_vfidb((X), 4, 7)
91 #define vec_roundm(X) __builtin_s390_vfidb((X), 4, 7)
92 #define vec_trunc(X) __builtin_s390_vfidb((X), 4, 5)
93 #define vec_roundz(X) __builtin_s390_vfidb((X), 4, 5)
94 #define vec_roundc(X) __builtin_s390_vfidb((X), 4, 0)
95 #define vec_round(X) __builtin_s390_vfidb((X), 4, 4)
96 #define vec_madd __builtin_s390_vfmadb
97 #define vec_msub __builtin_s390_vfmsdb
98
99 static inline int
100 vec_all_nan (__vector double a)
101 {
102 int cc;
103 __builtin_s390_vftcidb (a,
104 __VFTCI_QNAN
105 | __VFTCI_QNAN_N
106 | __VFTCI_SNAN
107 | __VFTCI_SNAN_N, &cc);
108 return cc == 0 ? 1 : 0;
109 }
110
111 static inline int
112 vec_all_numeric (__vector double a)
113 {
114 int cc;
115 __builtin_s390_vftcidb (a,
116 __VFTCI_NORMAL
117 | __VFTCI_NORMAL_N
118 | __VFTCI_SUBNORMAL
119 | __VFTCI_SUBNORMAL_N, &cc);
120 return cc == 0 ? 1 : 0;
121 }
122
123 static inline int
124 vec_any_nan (__vector double a)
125 {
126 int cc;
127 __builtin_s390_vftcidb (a,
128 __VFTCI_QNAN
129 | __VFTCI_QNAN_N
130 | __VFTCI_SNAN
131 | __VFTCI_SNAN_N, &cc);
132 return cc != 3 ? 1 : 0;
133 }
134
135 static inline int
136 vec_any_numeric (__vector double a)
137 {
138 int cc;
139 __builtin_s390_vftcidb (a,
140 __VFTCI_NORMAL
141 | __VFTCI_NORMAL_N
142 | __VFTCI_SUBNORMAL
143 | __VFTCI_SUBNORMAL_N, &cc);
144 return cc != 3 ? 1 : 0;
145 }
146 #define vec_gather_element __builtin_s390_vec_gather_element
147 #define vec_xld2 __builtin_s390_vec_xld2
148 #define vec_xlw4 __builtin_s390_vec_xlw4
149 #define vec_splats __builtin_s390_vec_splats
150 #define vec_insert __builtin_s390_vec_insert
151 #define vec_promote __builtin_s390_vec_promote
152 #define vec_extract __builtin_s390_vec_extract
153 #define vec_insert_and_zero __builtin_s390_vec_insert_and_zero
154 #define vec_load_bndry __builtin_s390_vec_load_bndry
155 #define vec_load_pair __builtin_s390_vec_load_pair
156 #define vec_load_len __builtin_s390_vec_load_len
157 #define vec_mergeh __builtin_s390_vec_mergeh
158 #define vec_mergel __builtin_s390_vec_mergel
159 #define vec_pack __builtin_s390_vec_pack
160 #define vec_packs __builtin_s390_vec_packs
161 #define vec_packs_cc __builtin_s390_vec_packs_cc
162 #define vec_packsu __builtin_s390_vec_packsu
163 #define vec_packsu_cc __builtin_s390_vec_packsu_cc
164 #define vec_perm __builtin_s390_vec_perm
165 #define vec_permi __builtin_s390_vec_permi
166 #define vec_splat __builtin_s390_vec_splat
167 #define vec_scatter_element __builtin_s390_vec_scatter_element
168 #define vec_sel __builtin_s390_vec_sel
169 #define vec_extend_s64 __builtin_s390_vec_extend_s64
170 #define vec_xstd2 __builtin_s390_vec_xstd2
171 #define vec_xstw4 __builtin_s390_vec_xstw4
172 #define vec_store_len __builtin_s390_vec_store_len
173 #define vec_unpackh __builtin_s390_vec_unpackh
174 #define vec_unpackl __builtin_s390_vec_unpackl
175 #define vec_addc __builtin_s390_vec_addc
176 #define vec_and __builtin_s390_vec_and
177 #define vec_andc __builtin_s390_vec_andc
178 #define vec_avg __builtin_s390_vec_avg
179 #define vec_all_eq __builtin_s390_vec_all_eq
180 #define vec_all_ne __builtin_s390_vec_all_ne
181 #define vec_all_ge __builtin_s390_vec_all_ge
182 #define vec_all_gt __builtin_s390_vec_all_gt
183 #define vec_all_le __builtin_s390_vec_all_le
184 #define vec_all_lt __builtin_s390_vec_all_lt
185 #define vec_any_eq __builtin_s390_vec_any_eq
186 #define vec_any_ne __builtin_s390_vec_any_ne
187 #define vec_any_ge __builtin_s390_vec_any_ge
188 #define vec_any_gt __builtin_s390_vec_any_gt
189 #define vec_any_le __builtin_s390_vec_any_le
190 #define vec_any_lt __builtin_s390_vec_any_lt
191 #define vec_cmpeq __builtin_s390_vec_cmpeq
192 #define vec_cmpge __builtin_s390_vec_cmpge
193 #define vec_cmpgt __builtin_s390_vec_cmpgt
194 #define vec_cmple __builtin_s390_vec_cmple
195 #define vec_cmplt __builtin_s390_vec_cmplt
196 #define vec_cntlz __builtin_s390_vec_cntlz
197 #define vec_cnttz __builtin_s390_vec_cnttz
198 #define vec_xor __builtin_s390_vec_xor
199 #define vec_gfmsum __builtin_s390_vec_gfmsum
200 #define vec_gfmsum_accum __builtin_s390_vec_gfmsum_accum
201 #define vec_abs __builtin_s390_vec_abs
202 #define vec_max __builtin_s390_vec_max
203 #define vec_min __builtin_s390_vec_min
204 #define vec_mladd __builtin_s390_vec_mladd
205 #define vec_mhadd __builtin_s390_vec_mhadd
206 #define vec_meadd __builtin_s390_vec_meadd
207 #define vec_moadd __builtin_s390_vec_moadd
208 #define vec_mulh __builtin_s390_vec_mulh
209 #define vec_mule __builtin_s390_vec_mule
210 #define vec_mulo __builtin_s390_vec_mulo
211 #define vec_nor __builtin_s390_vec_nor
212 #define vec_or __builtin_s390_vec_or
213 #define vec_popcnt __builtin_s390_vec_popcnt
214 #define vec_rl __builtin_s390_vec_rl
215 #define vec_rli __builtin_s390_vec_rli
216 #define vec_rl_mask __builtin_s390_vec_rl_mask
217 #define vec_sll __builtin_s390_vec_sll
218 #define vec_slb __builtin_s390_vec_slb
219 #define vec_sld __builtin_s390_vec_sld
220 #define vec_sldw __builtin_s390_vec_sldw
221 #define vec_sral __builtin_s390_vec_sral
222 #define vec_srab __builtin_s390_vec_srab
223 #define vec_srl __builtin_s390_vec_srl
224 #define vec_srb __builtin_s390_vec_srb
225 #define vec_subc __builtin_s390_vec_subc
226 #define vec_sum2 __builtin_s390_vec_sum2
227 #define vec_sum_u128 __builtin_s390_vec_sum_u128
228 #define vec_sum4 __builtin_s390_vec_sum4
229 #define vec_test_mask __builtin_s390_vec_test_mask
230 #define vec_find_any_eq_idx __builtin_s390_vec_find_any_eq_idx
231 #define vec_find_any_ne_idx __builtin_s390_vec_find_any_ne_idx
232 #define vec_find_any_eq_or_0_idx __builtin_s390_vec_find_any_eq_or_0_idx
233 #define vec_find_any_ne_or_0_idx __builtin_s390_vec_find_any_ne_or_0_idx
234 #define vec_find_any_eq __builtin_s390_vec_find_any_eq
235 #define vec_find_any_ne __builtin_s390_vec_find_any_ne
236 #define vec_find_any_eq_idx_cc __builtin_s390_vec_find_any_eq_idx_cc
237 #define vec_find_any_ne_idx_cc __builtin_s390_vec_find_any_ne_idx_cc
238 #define vec_find_any_eq_or_0_idx_cc __builtin_s390_vec_find_any_eq_or_0_idx_cc
239 #define vec_find_any_ne_or_0_idx_cc __builtin_s390_vec_find_any_ne_or_0_idx_cc
240 #define vec_find_any_eq_cc __builtin_s390_vec_find_any_eq_cc
241 #define vec_find_any_ne_cc __builtin_s390_vec_find_any_ne_cc
242 #define vec_cmpeq_idx __builtin_s390_vec_cmpeq_idx
243 #define vec_cmpeq_or_0_idx __builtin_s390_vec_cmpeq_or_0_idx
244 #define vec_cmpeq_idx_cc __builtin_s390_vec_cmpeq_idx_cc
245 #define vec_cmpeq_or_0_idx_cc __builtin_s390_vec_cmpeq_or_0_idx_cc
246 #define vec_cmpne_idx __builtin_s390_vec_cmpne_idx
247 #define vec_cmpne_or_0_idx __builtin_s390_vec_cmpne_or_0_idx
248 #define vec_cmpne_idx_cc __builtin_s390_vec_cmpne_idx_cc
249 #define vec_cmpne_or_0_idx_cc __builtin_s390_vec_cmpne_or_0_idx_cc
250 #define vec_cp_until_zero __builtin_s390_vec_cp_until_zero
251 #define vec_cp_until_zero_cc __builtin_s390_vec_cp_until_zero_cc
252 #define vec_cmprg_idx __builtin_s390_vec_cmprg_idx
253 #define vec_cmpnrg_idx __builtin_s390_vec_cmpnrg_idx
254 #define vec_cmprg_or_0_idx __builtin_s390_vec_cmprg_or_0_idx
255 #define vec_cmpnrg_or_0_idx __builtin_s390_vec_cmpnrg_or_0_idx
256 #define vec_cmprg __builtin_s390_vec_cmprg
257 #define vec_cmpnrg __builtin_s390_vec_cmpnrg
258 #define vec_cmprg_idx_cc __builtin_s390_vec_cmprg_idx_cc
259 #define vec_cmpnrg_idx_cc __builtin_s390_vec_cmpnrg_idx_cc
260 #define vec_cmprg_or_0_idx_cc __builtin_s390_vec_cmprg_or_0_idx_cc
261 #define vec_cmpnrg_or_0_idx_cc __builtin_s390_vec_cmpnrg_or_0_idx_cc
262 #define vec_cmprg_cc __builtin_s390_vec_cmprg_cc
263 #define vec_cmpnrg_cc __builtin_s390_vec_cmpnrg_cc
264 #define vec_all_nge __builtin_s390_vec_all_nge
265 #define vec_all_ngt __builtin_s390_vec_all_ngt
266 #define vec_any_nge __builtin_s390_vec_any_nge
267 #define vec_any_ngt __builtin_s390_vec_any_ngt
268 #define vec_ctd __builtin_s390_vec_ctd
269 #define vec_ctd_s64 __builtin_s390_vec_ctd_s64
270 #define vec_ctd_u64 __builtin_s390_vec_ctd_u64
271 #define vec_ctsl __builtin_s390_vec_ctsl
272 #define vec_ctul __builtin_s390_vec_ctul
273 #define vec_ld2f __builtin_s390_vec_ld2f
274 #define vec_st2f __builtin_s390_vec_st2f
275 #endif /* __VEC__ */
276 #endif /* _VECINTRIN_H */