1 /* PowerPC AltiVec include file.
2 Copyright (C) 2002-2017 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez (aldyh@redhat.com).
4 Rewritten by Paolo Bonzini (bonzini@gnu.org).
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 /* Implemented to conform to the specification included in the AltiVec
28 Technology Programming Interface Manual (ALTIVECPIM/D 6/1999 Rev 0). */
33 #if !defined(__VEC__) || !defined(__ALTIVEC__)
34 #error Use the "-maltivec" flag to enable PowerPC AltiVec support
37 /* If __APPLE_ALTIVEC__ is defined, the compiler supports 'vector',
38 'pixel' and 'bool' as context-sensitive AltiVec keywords (in
39 non-AltiVec contexts, they revert to their original meanings,
40 if any), so we do not need to define them as macros. */
42 #if !defined(__APPLE_ALTIVEC__)
43 /* You are allowed to undef these for C++ compatibility. */
44 #define vector __vector
49 /* Condition register codes for AltiVec predicates. */
52 #define __CR6_EQ_REV 1
54 #define __CR6_LT_REV 3
57 #define vec_vaddcuw vec_addc
58 #define vec_vand vec_and
59 #define vec_vandc vec_andc
60 #define vec_vrfip vec_ceil
61 #define vec_vcmpbfp vec_cmpb
62 #define vec_vcmpgefp vec_cmpge
63 #define vec_vctsxs vec_cts
64 #define vec_vctuxs vec_ctu
65 #define vec_vexptefp vec_expte
66 #define vec_vrfim vec_floor
67 #define vec_lvx vec_ld
68 #define vec_lvxl vec_ldl
69 #define vec_vlogefp vec_loge
70 #define vec_vmaddfp vec_madd
71 #define vec_vmhaddshs vec_madds
72 #define vec_vmladduhm vec_mladd
73 #define vec_vmhraddshs vec_mradds
74 #define vec_vnmsubfp vec_nmsub
75 #define vec_vnor vec_nor
76 #define vec_vor vec_or
77 #define vec_vpkpx vec_packpx
78 #define vec_vperm vec_perm
79 #define vec_vrefp vec_re
80 #define vec_vrfin vec_round
81 #define vec_vrsqrtefp vec_rsqrte
82 #define vec_vsel vec_sel
83 #define vec_vsldoi vec_sld
84 #define vec_vsl vec_sll
85 #define vec_vslo vec_slo
86 #define vec_vspltisb vec_splat_s8
87 #define vec_vspltish vec_splat_s16
88 #define vec_vspltisw vec_splat_s32
89 #define vec_vsr vec_srl
90 #define vec_vsro vec_sro
91 #define vec_stvx vec_st
92 #define vec_stvxl vec_stl
93 #define vec_vsubcuw vec_subc
94 #define vec_vsum2sws vec_sum2s
95 #define vec_vsumsws vec_sums
96 #define vec_vrfiz vec_trunc
97 #define vec_vxor vec_xor
99 /* Functions that are resolved by the backend to one of the
101 #define vec_vaddfp __builtin_vec_vaddfp
102 #define vec_addc __builtin_vec_addc
103 #define vec_adde __builtin_vec_adde
104 #define vec_addec __builtin_vec_addec
105 #define vec_vaddsws __builtin_vec_vaddsws
106 #define vec_vaddshs __builtin_vec_vaddshs
107 #define vec_vaddsbs __builtin_vec_vaddsbs
108 #define vec_vavgsw __builtin_vec_vavgsw
109 #define vec_vavguw __builtin_vec_vavguw
110 #define vec_vavgsh __builtin_vec_vavgsh
111 #define vec_vavguh __builtin_vec_vavguh
112 #define vec_vavgsb __builtin_vec_vavgsb
113 #define vec_vavgub __builtin_vec_vavgub
114 #define vec_ceil __builtin_vec_ceil
115 #define vec_cmpb __builtin_vec_cmpb
116 #define vec_vcmpeqfp __builtin_vec_vcmpeqfp
117 #define vec_cmpge __builtin_vec_cmpge
118 #define vec_vcmpgtfp __builtin_vec_vcmpgtfp
119 #define vec_vcmpgtsw __builtin_vec_vcmpgtsw
120 #define vec_vcmpgtuw __builtin_vec_vcmpgtuw
121 #define vec_vcmpgtsh __builtin_vec_vcmpgtsh
122 #define vec_vcmpgtuh __builtin_vec_vcmpgtuh
123 #define vec_vcmpgtsb __builtin_vec_vcmpgtsb
124 #define vec_vcmpgtub __builtin_vec_vcmpgtub
125 #define vec_vcfsx __builtin_vec_vcfsx
126 #define vec_vcfux __builtin_vec_vcfux
127 #define vec_cts __builtin_vec_cts
128 #define vec_ctu __builtin_vec_ctu
129 #define vec_cpsgn __builtin_vec_copysign
130 #define vec_double __builtin_vec_double
131 #define vec_doublee __builtin_vec_doublee
132 #define vec_doubleo __builtin_vec_doubleo
133 #define vec_doublel __builtin_vec_doublel
134 #define vec_doubleh __builtin_vec_doubleh
135 #define vec_expte __builtin_vec_expte
136 #define vec_float __builtin_vec_float
137 #define vec_float2 __builtin_vec_float2
138 #define vec_floate __builtin_vec_floate
139 #define vec_floato __builtin_vec_floato
140 #define vec_floor __builtin_vec_floor
141 #define vec_loge __builtin_vec_loge
142 #define vec_madd __builtin_vec_madd
143 #define vec_madds __builtin_vec_madds
144 #define vec_mtvscr __builtin_vec_mtvscr
145 #define vec_reve __builtin_vec_vreve
146 #define vec_vmaxfp __builtin_vec_vmaxfp
147 #define vec_vmaxsw __builtin_vec_vmaxsw
148 #define vec_vmaxsh __builtin_vec_vmaxsh
149 #define vec_vmaxsb __builtin_vec_vmaxsb
150 #define vec_vminfp __builtin_vec_vminfp
151 #define vec_vminsw __builtin_vec_vminsw
152 #define vec_vminsh __builtin_vec_vminsh
153 #define vec_vminsb __builtin_vec_vminsb
154 #define vec_mradds __builtin_vec_mradds
155 #define vec_vmsumshm __builtin_vec_vmsumshm
156 #define vec_vmsumuhm __builtin_vec_vmsumuhm
157 #define vec_vmsummbm __builtin_vec_vmsummbm
158 #define vec_vmsumubm __builtin_vec_vmsumubm
159 #define vec_vmsumshs __builtin_vec_vmsumshs
160 #define vec_vmsumuhs __builtin_vec_vmsumuhs
161 #define vec_vmulesb __builtin_vec_vmulesb
162 #define vec_vmulesh __builtin_vec_vmulesh
163 #define vec_vmuleuh __builtin_vec_vmuleuh
164 #define vec_vmuleub __builtin_vec_vmuleub
165 #define vec_vmulosh __builtin_vec_vmulosh
166 #define vec_vmulouh __builtin_vec_vmulouh
167 #define vec_vmulosb __builtin_vec_vmulosb
168 #define vec_vmuloub __builtin_vec_vmuloub
169 #define vec_nmsub __builtin_vec_nmsub
170 #define vec_packpx __builtin_vec_packpx
171 #define vec_vpkswss __builtin_vec_vpkswss
172 #define vec_vpkuwus __builtin_vec_vpkuwus
173 #define vec_vpkshss __builtin_vec_vpkshss
174 #define vec_vpkuhus __builtin_vec_vpkuhus
175 #define vec_vpkswus __builtin_vec_vpkswus
176 #define vec_vpkshus __builtin_vec_vpkshus
177 #define vec_re __builtin_vec_re
178 #define vec_round __builtin_vec_round
179 #define vec_recipdiv __builtin_vec_recipdiv
180 #define vec_rlmi __builtin_vec_rlmi
181 #define vec_vrlnm __builtin_vec_rlnm
182 #define vec_rlnm(a,b,c) (__builtin_vec_rlnm((a),((b)<<8)|(c)))
183 #define vec_rsqrt __builtin_vec_rsqrt
184 #define vec_rsqrte __builtin_vec_rsqrte
185 #define vec_signed __builtin_vec_vsigned
186 #define vec_signed2 __builtin_vec_vsigned2
187 #define vec_signede __builtin_vec_vsignede
188 #define vec_signedo __builtin_vec_vsignedo
189 #define vec_unsigned __builtin_vec_vunsigned
190 #define vec_unsigned2 __builtin_vec_vunsigned2
191 #define vec_unsignede __builtin_vec_vunsignede
192 #define vec_unsignedo __builtin_vec_vunsignedo
193 #define vec_vsubfp __builtin_vec_vsubfp
194 #define vec_subc __builtin_vec_subc
195 #define vec_sube __builtin_vec_sube
196 #define vec_subec __builtin_vec_subec
197 #define vec_vsubsws __builtin_vec_vsubsws
198 #define vec_vsubshs __builtin_vec_vsubshs
199 #define vec_vsubsbs __builtin_vec_vsubsbs
200 #define vec_sum4s __builtin_vec_sum4s
201 #define vec_vsum4shs __builtin_vec_vsum4shs
202 #define vec_vsum4sbs __builtin_vec_vsum4sbs
203 #define vec_vsum4ubs __builtin_vec_vsum4ubs
204 #define vec_sum2s __builtin_vec_sum2s
205 #define vec_sums __builtin_vec_sums
206 #define vec_trunc __builtin_vec_trunc
207 #define vec_vupkhpx __builtin_vec_vupkhpx
208 #define vec_vupkhsh __builtin_vec_vupkhsh
209 #define vec_vupkhsb __builtin_vec_vupkhsb
210 #define vec_vupklpx __builtin_vec_vupklpx
211 #define vec_vupklsh __builtin_vec_vupklsh
212 #define vec_vupklsb __builtin_vec_vupklsb
213 #define vec_abs __builtin_vec_abs
214 #define vec_nabs __builtin_vec_nabs
215 #define vec_abss __builtin_vec_abss
216 #define vec_add __builtin_vec_add
217 #define vec_adds __builtin_vec_adds
218 #define vec_and __builtin_vec_and
219 #define vec_andc __builtin_vec_andc
220 #define vec_avg __builtin_vec_avg
221 #define vec_cmpeq __builtin_vec_cmpeq
222 #define vec_cmpne __builtin_vec_cmpne
223 #define vec_cmpgt __builtin_vec_cmpgt
224 #define vec_ctf __builtin_vec_ctf
225 #define vec_dst __builtin_vec_dst
226 #define vec_dstst __builtin_vec_dstst
227 #define vec_dststt __builtin_vec_dststt
228 #define vec_dstt __builtin_vec_dstt
229 #define vec_ld __builtin_vec_ld
230 #define vec_lde __builtin_vec_lde
231 #define vec_ldl __builtin_vec_ldl
232 #define vec_lvebx __builtin_vec_lvebx
233 #define vec_lvehx __builtin_vec_lvehx
234 #define vec_lvewx __builtin_vec_lvewx
235 #define vec_neg __builtin_vec_neg
236 #define vec_pmsum_be __builtin_vec_vpmsum
237 #define vec_shasigma_be __builtin_crypto_vshasigma
238 /* Cell only intrinsics. */
240 #define vec_lvlx __builtin_vec_lvlx
241 #define vec_lvlxl __builtin_vec_lvlxl
242 #define vec_lvrx __builtin_vec_lvrx
243 #define vec_lvrxl __builtin_vec_lvrxl
245 #define vec_lvsl __builtin_vec_lvsl
246 #define vec_lvsr __builtin_vec_lvsr
247 #define vec_max __builtin_vec_max
248 #define vec_mergee __builtin_vec_vmrgew
249 #define vec_mergeh __builtin_vec_mergeh
250 #define vec_mergel __builtin_vec_mergel
251 #define vec_mergeo __builtin_vec_vmrgow
252 #define vec_min __builtin_vec_min
253 #define vec_mladd __builtin_vec_mladd
254 #define vec_msum __builtin_vec_msum
255 #define vec_msums __builtin_vec_msums
256 #define vec_mul __builtin_vec_mul
257 #define vec_mule __builtin_vec_mule
258 #define vec_mulo __builtin_vec_mulo
259 #define vec_nor __builtin_vec_nor
260 #define vec_or __builtin_vec_or
261 #define vec_pack __builtin_vec_pack
262 #define vec_packs __builtin_vec_packs
263 #define vec_packsu __builtin_vec_packsu
264 #define vec_perm __builtin_vec_perm
265 #define vec_rl __builtin_vec_rl
266 #define vec_sel __builtin_vec_sel
267 #define vec_sl __builtin_vec_sl
268 #define vec_sld __builtin_vec_sld
269 #define vec_sldw __builtin_vsx_xxsldwi
270 #define vec_sll __builtin_vec_sll
271 #define vec_slo __builtin_vec_slo
272 #define vec_splat __builtin_vec_splat
273 #define vec_sr __builtin_vec_sr
274 #define vec_sra __builtin_vec_sra
275 #define vec_srl __builtin_vec_srl
276 #define vec_sro __builtin_vec_sro
277 #define vec_st __builtin_vec_st
278 #define vec_ste __builtin_vec_ste
279 #define vec_stl __builtin_vec_stl
280 #define vec_stvebx __builtin_vec_stvebx
281 #define vec_stvehx __builtin_vec_stvehx
282 #define vec_stvewx __builtin_vec_stvewx
283 /* Cell only intrinsics. */
285 #define vec_stvlx __builtin_vec_stvlx
286 #define vec_stvlxl __builtin_vec_stvlxl
287 #define vec_stvrx __builtin_vec_stvrx
288 #define vec_stvrxl __builtin_vec_stvrxl
290 #define vec_sub __builtin_vec_sub
291 #define vec_subs __builtin_vec_subs
292 #define vec_sum __builtin_vec_sum
293 #define vec_unpackh __builtin_vec_unpackh
294 #define vec_unpackl __builtin_vec_unpackl
295 #define vec_vaddubm __builtin_vec_vaddubm
296 #define vec_vaddubs __builtin_vec_vaddubs
297 #define vec_vadduhm __builtin_vec_vadduhm
298 #define vec_vadduhs __builtin_vec_vadduhs
299 #define vec_vadduwm __builtin_vec_vadduwm
300 #define vec_vadduws __builtin_vec_vadduws
301 #define vec_vcmpequb __builtin_vec_vcmpequb
302 #define vec_vcmpequh __builtin_vec_vcmpequh
303 #define vec_vcmpequw __builtin_vec_vcmpequw
304 #define vec_vmaxub __builtin_vec_vmaxub
305 #define vec_vmaxuh __builtin_vec_vmaxuh
306 #define vec_vmaxuw __builtin_vec_vmaxuw
307 #define vec_vminub __builtin_vec_vminub
308 #define vec_vminuh __builtin_vec_vminuh
309 #define vec_vminuw __builtin_vec_vminuw
310 #define vec_vmrghb __builtin_vec_vmrghb
311 #define vec_vmrghh __builtin_vec_vmrghh
312 #define vec_vmrghw __builtin_vec_vmrghw
313 #define vec_vmrglb __builtin_vec_vmrglb
314 #define vec_vmrglh __builtin_vec_vmrglh
315 #define vec_vmrglw __builtin_vec_vmrglw
316 #define vec_vpkuhum __builtin_vec_vpkuhum
317 #define vec_vpkuwum __builtin_vec_vpkuwum
318 #define vec_vrlb __builtin_vec_vrlb
319 #define vec_vrlh __builtin_vec_vrlh
320 #define vec_vrlw __builtin_vec_vrlw
321 #define vec_vslb __builtin_vec_vslb
322 #define vec_vslh __builtin_vec_vslh
323 #define vec_vslw __builtin_vec_vslw
324 #define vec_vspltb __builtin_vec_vspltb
325 #define vec_vsplth __builtin_vec_vsplth
326 #define vec_vspltw __builtin_vec_vspltw
327 #define vec_vsrab __builtin_vec_vsrab
328 #define vec_vsrah __builtin_vec_vsrah
329 #define vec_vsraw __builtin_vec_vsraw
330 #define vec_vsrb __builtin_vec_vsrb
331 #define vec_vsrh __builtin_vec_vsrh
332 #define vec_vsrw __builtin_vec_vsrw
333 #define vec_vsububs __builtin_vec_vsububs
334 #define vec_vsububm __builtin_vec_vsububm
335 #define vec_vsubuhm __builtin_vec_vsubuhm
336 #define vec_vsubuhs __builtin_vec_vsubuhs
337 #define vec_vsubuwm __builtin_vec_vsubuwm
338 #define vec_vsubuws __builtin_vec_vsubuws
339 #define vec_xor __builtin_vec_xor
341 #define vec_extract __builtin_vec_extract
342 #define vec_insert __builtin_vec_insert
343 #define vec_splats __builtin_vec_splats
344 #define vec_promote __builtin_vec_promote
348 #define vec_div __builtin_vec_div
349 #define vec_mul __builtin_vec_mul
350 #define vec_msub __builtin_vec_msub
351 #define vec_nmadd __builtin_vec_nmadd
352 #define vec_nearbyint __builtin_vec_nearbyint
353 #define vec_rint __builtin_vec_rint
354 #define vec_sqrt __builtin_vec_sqrt
355 #define vec_vsx_ld __builtin_vec_vsx_ld
356 #define vec_vsx_st __builtin_vec_vsx_st
357 #define vec_xl __builtin_vec_vsx_ld
358 #define vec_xst __builtin_vec_vsx_st
360 /* Note, xxsldi and xxpermdi were added as __builtin_vsx_<xxx> functions
361 instead of __builtin_vec_<xxx> */
362 #define vec_xxsldwi __builtin_vsx_xxsldwi
363 #define vec_xxpermdi __builtin_vsx_xxpermdi
367 /* Vector additions added in ISA 2.07. */
368 #define vec_eqv __builtin_vec_eqv
369 #define vec_nand __builtin_vec_nand
370 #define vec_orc __builtin_vec_orc
371 #define vec_vaddcuq __builtin_vec_vaddcuq
372 #define vec_vaddudm __builtin_vec_vaddudm
373 #define vec_vadduqm __builtin_vec_vadduqm
374 #define vec_vbpermq __builtin_vec_vbpermq
375 #define vec_bperm __builtin_vec_vbperm_api
376 #define vec_vclz __builtin_vec_vclz
377 #define vec_cntlz __builtin_vec_vclz
378 #define vec_vclzb __builtin_vec_vclzb
379 #define vec_vclzd __builtin_vec_vclzd
380 #define vec_vclzh __builtin_vec_vclzh
381 #define vec_vclzw __builtin_vec_vclzw
382 #define vec_vaddecuq __builtin_vec_vaddecuq
383 #define vec_vaddeuqm __builtin_vec_vaddeuqm
384 #define vec_vsubecuq __builtin_vec_vsubecuq
385 #define vec_vsubeuqm __builtin_vec_vsubeuqm
386 #define vec_vgbbd __builtin_vec_vgbbd
387 #define vec_gb __builtin_vec_vgbbd
388 #define vec_vmaxsd __builtin_vec_vmaxsd
389 #define vec_vmaxud __builtin_vec_vmaxud
390 #define vec_vminsd __builtin_vec_vminsd
391 #define vec_vminud __builtin_vec_vminud
392 #define vec_vmrgew __builtin_vec_vmrgew
393 #define vec_vmrgow __builtin_vec_vmrgow
394 #define vec_vpksdss __builtin_vec_vpksdss
395 #define vec_vpksdus __builtin_vec_vpksdus
396 #define vec_vpkudum __builtin_vec_vpkudum
397 #define vec_vpkudus __builtin_vec_vpkudus
398 #define vec_vpopcnt __builtin_vec_vpopcnt
399 #define vec_vpopcntb __builtin_vec_vpopcntb
400 #define vec_vpopcntd __builtin_vec_vpopcntd
401 #define vec_vpopcnth __builtin_vec_vpopcnth
402 #define vec_vpopcntw __builtin_vec_vpopcntw
403 #define vec_popcnt __builtin_vec_vpopcntu
404 #define vec_popcntb __builtin_vec_vpopcntub
405 #define vec_popcnth __builtin_vec_vpopcntuh
406 #define vec_popcntw __builtin_vec_vpopcntuw
407 #define vec_popcntd __builtin_vec_vpopcntud
408 #define vec_vrld __builtin_vec_vrld
409 #define vec_vsld __builtin_vec_vsld
410 #define vec_vsrad __builtin_vec_vsrad
411 #define vec_vsrd __builtin_vec_vsrd
412 #define vec_vsubcuq __builtin_vec_vsubcuq
413 #define vec_vsubudm __builtin_vec_vsubudm
414 #define vec_vsubuqm __builtin_vec_vsubuqm
415 #define vec_vupkhsw __builtin_vec_vupkhsw
416 #define vec_vupklsw __builtin_vec_vupklsw
419 #ifdef __POWER9_VECTOR__
420 /* Vector additions added in ISA 3.0. */
421 #define vec_vctz __builtin_vec_vctz
422 #define vec_cnttz __builtin_vec_vctz
423 #define vec_vctzb __builtin_vec_vctzb
424 #define vec_vctzd __builtin_vec_vctzd
425 #define vec_vctzh __builtin_vec_vctzh
426 #define vec_vctzw __builtin_vec_vctzw
427 #define vec_vextract4b __builtin_vec_vextract4b
428 #define vec_vinsert4b __builtin_vec_vinsert4b
429 #define vec_vprtyb __builtin_vec_vprtyb
430 #define vec_vprtybd __builtin_vec_vprtybd
431 #define vec_vprtybw __builtin_vec_vprtybw
434 #define vec_vprtybq __builtin_vec_vprtybq
437 #define vec_absd __builtin_vec_vadu
438 #define vec_absdb __builtin_vec_vadub
439 #define vec_absdh __builtin_vec_vaduh
440 #define vec_absdw __builtin_vec_vaduw
442 #define vec_slv __builtin_vec_vslv
443 #define vec_srv __builtin_vec_vsrv
445 #define vec_extract_exp __builtin_vec_extract_exp
446 #define vec_extract_sig __builtin_vec_extract_sig
447 #define vec_insert_exp __builtin_vec_insert_exp
448 #define vec_test_data_class __builtin_vec_test_data_class
450 #define scalar_extract_exp __builtin_vec_scalar_extract_exp
451 #define scalar_extract_sig __builtin_vec_scalar_extract_sig
452 #define scalar_insert_exp __builtin_vec_scalar_insert_exp
453 #define scalar_test_data_class __builtin_vec_scalar_test_data_class
454 #define scalar_test_neg __builtin_vec_scalar_test_neg
456 #define scalar_cmp_exp_gt __builtin_vec_scalar_cmp_exp_gt
457 #define scalar_cmp_exp_lt __builtin_vec_scalar_cmp_exp_lt
458 #define scalar_cmp_exp_eq __builtin_vec_scalar_cmp_exp_eq
459 #define scalar_cmp_exp_unordered __builtin_vec_scalar_cmp_exp_unordered
462 #define vec_xl_len __builtin_vec_lxvl
463 #define vec_xst_len __builtin_vec_stxvl
466 #define vec_cmpnez __builtin_vec_vcmpnez
468 #define vec_cntlz_lsbb __builtin_vec_vclzlsbb
469 #define vec_cnttz_lsbb __builtin_vec_vctzlsbb
471 #define vec_xlx __builtin_vec_vextulx
472 #define vec_xrx __builtin_vec_vexturx
474 #define vec_revb __builtin_vec_revb
478 For C++, we use templates in order to allow non-parenthesized arguments.
479 For C, instead, we use macros since non-parenthesized arguments were
480 not allowed even in older GCC implementation of AltiVec.
482 In the future, we may add more magic to the back-end, so that no
483 one- or two-argument macros are used. */
486 #define __altivec_unary_pred(NAME, CALL) \
487 template <class T> int NAME (T a1) { return CALL; }
489 #define __altivec_scalar_pred(NAME, CALL) \
490 template <class T, class U> int NAME (T a1, U a2) { return CALL; }
492 /* Given the vec_step of a type, return the corresponding bool type. */
493 template <int STEP
> class __altivec_bool_ret
{ };
494 template <> class __altivec_bool_ret
<4> {
495 typedef __vector __bool
int __ret
;
497 template <> class __altivec_bool_ret
<8> {
498 typedef __vector __bool
short __ret
;
500 template <> class __altivec_bool_ret
<16> {
501 typedef __vector __bool
char __ret
;
504 /* Be very liberal in the pairs we accept. Mistakes such as passing
505 a `vector char' and `vector short' will be caught by the middle-end,
506 while any attempt to detect them here would produce hard to understand
507 error messages involving the implementation details of AltiVec. */
508 #define __altivec_binary_pred(NAME, CALL) \
509 template <class T, class U> \
510 typename __altivec_bool_ret <vec_step (T)>::__ret \
516 __altivec_binary_pred(vec_cmplt
,
517 __builtin_vec_cmpgt (a2
, a1
))
518 __altivec_binary_pred(vec_cmple
,
519 __builtin_vec_cmpge (a2
, a1
))
521 __altivec_scalar_pred(vec_all_in
,
522 __builtin_altivec_vcmpbfp_p (__CR6_EQ
, a1
, a2
))
523 __altivec_scalar_pred(vec_any_out
,
524 __builtin_altivec_vcmpbfp_p (__CR6_EQ_REV
, a1
, a2
))
526 __altivec_unary_pred(vec_all_nan
,
527 __builtin_altivec_vcmpeq_p (__CR6_EQ
, a1
, a1
))
528 __altivec_unary_pred(vec_any_nan
,
529 __builtin_altivec_vcmpeq_p (__CR6_LT_REV
, a1
, a1
))
531 __altivec_unary_pred(vec_all_numeric
,
532 __builtin_altivec_vcmpeq_p (__CR6_LT
, a1
, a1
))
533 __altivec_unary_pred(vec_any_numeric
,
534 __builtin_altivec_vcmpeq_p (__CR6_EQ_REV
, a1
, a1
))
536 __altivec_scalar_pred(vec_all_eq
,
537 __builtin_vec_vcmpeq_p (__CR6_LT
, a1
, a2
))
539 #ifndef __POWER9_VECTOR__
540 __altivec_scalar_pred(vec_all_ne
,
541 __builtin_vec_vcmpeq_p (__CR6_EQ
, a1
, a2
))
542 __altivec_scalar_pred(vec_any_eq
,
543 __builtin_vec_vcmpeq_p (__CR6_EQ_REV
, a1
, a2
))
545 __altivec_scalar_pred(vec_all_nez
,
546 __builtin_vec_vcmpnez_p (__CR6_LT
, a1
, a2
))
547 __altivec_scalar_pred(vec_any_eqz
,
548 __builtin_vec_vcmpnez_p (__CR6_LT_REV
, a1
, a2
))
549 __altivec_scalar_pred(vec_all_ne
,
550 __builtin_vec_vcmpne_p (a1
, a2
))
551 __altivec_scalar_pred(vec_any_eq
,
552 __builtin_vec_vcmpae_p (a1
, a2
))
555 __altivec_scalar_pred(vec_any_ne
,
556 __builtin_vec_vcmpeq_p (__CR6_LT_REV
, a1
, a2
))
558 __altivec_scalar_pred(vec_all_gt
,
559 __builtin_vec_vcmpgt_p (__CR6_LT
, a1
, a2
))
560 __altivec_scalar_pred(vec_all_lt
,
561 __builtin_vec_vcmpgt_p (__CR6_LT
, a2
, a1
))
562 __altivec_scalar_pred(vec_any_gt
,
563 __builtin_vec_vcmpgt_p (__CR6_EQ_REV
, a1
, a2
))
564 __altivec_scalar_pred(vec_any_lt
,
565 __builtin_vec_vcmpgt_p (__CR6_EQ_REV
, a2
, a1
))
567 __altivec_scalar_pred(vec_all_ngt
,
568 __builtin_altivec_vcmpgt_p (__CR6_EQ
, a1
, a2
))
569 __altivec_scalar_pred(vec_all_nlt
,
570 __builtin_altivec_vcmpgt_p (__CR6_EQ
, a2
, a1
))
571 __altivec_scalar_pred(vec_any_ngt
,
572 __builtin_altivec_vcmpgt_p (__CR6_LT_REV
, a1
, a2
))
573 __altivec_scalar_pred(vec_any_nlt
,
574 __builtin_altivec_vcmpgt_p (__CR6_LT_REV
, a2
, a1
))
576 /* __builtin_vec_vcmpge_p is vcmpgefp for floating-point vector types,
577 while for integer types it is converted to __builtin_vec_vcmpgt_p,
578 with inverted args and condition code. */
579 __altivec_scalar_pred(vec_all_le
,
580 __builtin_vec_vcmpge_p (__CR6_LT
, a2
, a1
))
581 __altivec_scalar_pred(vec_all_ge
,
582 __builtin_vec_vcmpge_p (__CR6_LT
, a1
, a2
))
583 __altivec_scalar_pred(vec_any_le
,
584 __builtin_vec_vcmpge_p (__CR6_EQ_REV
, a2
, a1
))
585 __altivec_scalar_pred(vec_any_ge
,
586 __builtin_vec_vcmpge_p (__CR6_EQ_REV
, a1
, a2
))
588 __altivec_scalar_pred(vec_all_nge
,
589 __builtin_altivec_vcmpge_p (__CR6_EQ
, a1
, a2
))
590 __altivec_scalar_pred(vec_all_nle
,
591 __builtin_altivec_vcmpge_p (__CR6_EQ
, a2
, a1
))
592 __altivec_scalar_pred(vec_any_nge
,
593 __builtin_altivec_vcmpge_p (__CR6_LT_REV
, a1
, a2
))
594 __altivec_scalar_pred(vec_any_nle
,
595 __builtin_altivec_vcmpge_p (__CR6_LT_REV
, a2
, a1
))
597 #undef __altivec_scalar_pred
598 #undef __altivec_unary_pred
599 #undef __altivec_binary_pred
601 #define vec_cmplt(a1, a2) __builtin_vec_cmpgt ((a2), (a1))
602 #define vec_cmple(a1, a2) __builtin_vec_cmpge ((a2), (a1))
604 #define vec_all_in(a1, a2) __builtin_altivec_vcmpbfp_p (__CR6_EQ, (a1), (a2))
605 #define vec_any_out(a1, a2) __builtin_altivec_vcmpbfp_p (__CR6_EQ_REV, (a1), (a2))
607 #define vec_all_nan(a1) __builtin_vec_vcmpeq_p (__CR6_EQ, (a1), (a1))
608 #define vec_any_nan(a1) __builtin_vec_vcmpeq_p (__CR6_LT_REV, (a1), (a1))
610 #define vec_all_numeric(a1) __builtin_vec_vcmpeq_p (__CR6_LT, (a1), (a1))
611 #define vec_any_numeric(a1) __builtin_vec_vcmpeq_p (__CR6_EQ_REV, (a1), (a1))
613 #define vec_all_eq(a1, a2) __builtin_vec_vcmpeq_p (__CR6_LT, (a1), (a2))
615 #ifdef __POWER9_VECTOR__
616 #define vec_all_nez(a1, a2) __builtin_vec_vcmpnez_p (__CR6_LT, (a1), (a2))
617 #define vec_any_eqz(a1, a2) __builtin_vec_vcmpnez_p (__CR6_LT_REV, (a1), (a2))
618 #define vec_all_ne(a1, a2) __builtin_vec_vcmpne_p ((a1), (a2))
619 #define vec_any_eq(a1, a2) __builtin_vec_vcmpae_p ((a1), (a2))
621 #define vec_all_ne(a1, a2) __builtin_vec_vcmpeq_p (__CR6_EQ, (a1), (a2))
622 #define vec_any_eq(a1, a2) __builtin_vec_vcmpeq_p (__CR6_EQ_REV, (a1), (a2))
625 #define vec_any_ne(a1, a2) __builtin_vec_vcmpeq_p (__CR6_LT_REV, (a1), (a2))
627 #define vec_all_gt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_LT, (a1), (a2))
628 #define vec_all_lt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_LT, (a2), (a1))
629 #define vec_any_gt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_EQ_REV, (a1), (a2))
630 #define vec_any_lt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_EQ_REV, (a2), (a1))
632 #define vec_all_ngt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_EQ, (a1), (a2))
633 #define vec_all_nlt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_EQ, (a2), (a1))
634 #define vec_any_ngt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_LT_REV, (a1), (a2))
635 #define vec_any_nlt(a1, a2) __builtin_vec_vcmpgt_p (__CR6_LT_REV, (a2), (a1))
637 /* __builtin_vec_vcmpge_p is vcmpgefp for floating-point vector types,
638 while for integer types it is converted to __builtin_vec_vcmpgt_p,
639 with inverted args and condition code. */
640 #define vec_all_le(a1, a2) __builtin_vec_vcmpge_p (__CR6_LT, (a2), (a1))
641 #define vec_all_ge(a1, a2) __builtin_vec_vcmpge_p (__CR6_LT, (a1), (a2))
642 #define vec_any_le(a1, a2) __builtin_vec_vcmpge_p (__CR6_EQ_REV, (a2), (a1))
643 #define vec_any_ge(a1, a2) __builtin_vec_vcmpge_p (__CR6_EQ_REV, (a1), (a2))
645 #define vec_all_nge(a1, a2) __builtin_vec_vcmpge_p (__CR6_EQ, (a1), (a2))
646 #define vec_all_nle(a1, a2) __builtin_vec_vcmpge_p (__CR6_EQ, (a2), (a1))
647 #define vec_any_nge(a1, a2) __builtin_vec_vcmpge_p (__CR6_LT_REV, (a1), (a2))
648 #define vec_any_nle(a1, a2) __builtin_vec_vcmpge_p (__CR6_LT_REV, (a2), (a1))
651 /* These do not accept vectors, so they do not have a __builtin_vec_*
653 #define vec_dss(x) __builtin_altivec_dss((x))
654 #define vec_dssall() __builtin_altivec_dssall ()
655 #define vec_mfvscr() ((__vector unsigned short) __builtin_altivec_mfvscr ())
656 #define vec_splat_s8(x) __builtin_altivec_vspltisb ((x))
657 #define vec_splat_s16(x) __builtin_altivec_vspltish ((x))
658 #define vec_splat_s32(x) __builtin_altivec_vspltisw ((x))
659 #define vec_splat_u8(x) ((__vector unsigned char) vec_splat_s8 ((x)))
660 #define vec_splat_u16(x) ((__vector unsigned short) vec_splat_s16 ((x)))
661 #define vec_splat_u32(x) ((__vector unsigned int) vec_splat_s32 ((x)))
663 /* This also accepts a type for its parameter, so it is not enough
664 to #define vec_step to __builtin_vec_step. */
665 #define vec_step(x) __builtin_vec_step (* (__typeof__ (x) *) 0)
667 #endif /* _ALTIVEC_H */