blob: 1cd0db8e4b849226143ec554644732608254fcd3 [file] [log] [blame]
Chris Lattnerdd173942010-04-14 03:54:58 +00001/*===---- altivec.h - Standard header for type generic math ---------------===*\
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21\*===----------------------------------------------------------------------===*/
22
23#ifndef __ALTIVEC_H
24#define __ALTIVEC_H
25
26#ifndef __ALTIVEC__
27#error "AltiVec support not enabled"
28#endif
29
30/* constants for mapping CR6 bits to predicate result. */
31
32#define __CR6_EQ 0
33#define __CR6_EQ_REV 1
34#define __CR6_LT 2
35#define __CR6_LT_REV 3
36
37#define _ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
38
39/* vec_abs */
40
41#define __builtin_vec_abs vec_abs
42#define __builtin_altivec_abs_v16qi vec_abs
43#define __builtin_altivec_abs_v8hi vec_abs
44#define __builtin_altivec_abs_v4si vec_abs
45
46static vector signed char _ATTRS_o_ai
47vec_abs(vector signed char a)
48{
49 return __builtin_altivec_vmaxsb(a, -a);
50}
51
52static vector signed short _ATTRS_o_ai
53vec_abs(vector signed short a)
54{
55 return __builtin_altivec_vmaxsh(a, -a);
56}
57
58static vector signed int _ATTRS_o_ai
59vec_abs(vector signed int a)
60{
61 return __builtin_altivec_vmaxsw(a, -a);
62}
63
64static vector float _ATTRS_o_ai
65vec_abs(vector float a)
66{
Chris Lattnerab866b42010-04-14 20:35:39 +000067 vector unsigned int res = (vector unsigned int)a &
68 (vector unsigned int)(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF);
69 return (vector float)res;
Chris Lattnerdd173942010-04-14 03:54:58 +000070}
71
72/* vec_abss */
73
74#define __builtin_vec_abss vec_abss
75#define __builtin_altivec_abss_v16qi vec_abss
76#define __builtin_altivec_abss_v8hi vec_abss
77#define __builtin_altivec_abss_v4si vec_abss
78
79static vector signed char _ATTRS_o_ai
80vec_abss(vector signed char a)
81{
82 return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs(
83 (vector signed char)(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), a));
84}
85
86static vector signed short _ATTRS_o_ai
87vec_abss(vector signed short a)
88{
89 return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs(
90 (vector signed short)(0, 0, 0, 0, 0, 0, 0, 0), a));
91}
92
93static vector signed int _ATTRS_o_ai
94vec_abss(vector signed int a)
95{
96 return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws(
97 (vector signed int)(0, 0, 0, 0), a));
98}
99
100/* vec_add */
101
102#define __builtin_altivec_vaddubm vec_add
103#define __builtin_altivec_vadduhm vec_add
104#define __builtin_altivec_vadduwm vec_add
105#define __builtin_altivec_vaddfp vec_add
106#define __builtin_vec_vaddubm vec_add
107#define __builtin_vec_vadduhm vec_add
108#define __builtin_vec_vadduwm vec_add
109#define __builtin_vec_vaddfp vec_add
110#define vec_vaddubm vec_add
111#define vec_vadduhm vec_add
112#define vec_vadduwm vec_add
113#define vec_vaddfp vec_add
114
Chris Lattnerdd173942010-04-14 03:54:58 +0000115static vector signed char _ATTRS_o_ai
116vec_add(vector signed char a, vector signed char b)
117{
118 return a + b;
119}
120
121static vector unsigned char _ATTRS_o_ai
122vec_add(vector unsigned char a, vector unsigned char b)
123{
124 return a + b;
125}
126
127static vector short _ATTRS_o_ai
128vec_add(vector short a, vector short b)
129{
130 return a + b;
131}
132
133static vector unsigned short _ATTRS_o_ai
134vec_add(vector unsigned short a, vector unsigned short b)
135{
136 return a + b;
137}
138
139static vector int _ATTRS_o_ai
140vec_add(vector int a, vector int b)
141{
142 return a + b;
143}
144
145static vector unsigned int _ATTRS_o_ai
146vec_add(vector unsigned int a, vector unsigned int b)
147{
148 return a + b;
149}
150
151static vector float _ATTRS_o_ai
152vec_add(vector float a, vector float b)
153{
154 return a + b;
155}
156
157/* vec_addc */
158
159#define __builtin_vec_addc __builtin_altivec_vaddcuw
160#define vec_vaddcuw __builtin_altivec_vaddcuw
161#define vec_addc __builtin_altivec_vaddcuw
162
163/* vec_adds */
164
165#define __builtin_vec_vaddsbs __builtin_altivec_vaddsbs
166#define __builtin_vec_vaddubs __builtin_altivec_vaddubs
167#define __builtin_vec_vaddshs __builtin_altivec_vaddshs
168#define __builtin_vec_vadduhs __builtin_altivec_vadduhs
169#define __builtin_vec_vaddsws __builtin_altivec_vaddsws
170#define __builtin_vec_vadduws __builtin_altivec_vadduws
171#define vec_vaddsbs __builtin_altivec_vaddsbs
172#define vec_vaddubs __builtin_altivec_vaddubs
173#define vec_vaddshs __builtin_altivec_vaddshs
174#define vec_vadduhs __builtin_altivec_vadduhs
175#define vec_vaddsws __builtin_altivec_vaddsws
176#define vec_vadduws __builtin_altivec_vadduws
177
Chris Lattnerdd173942010-04-14 03:54:58 +0000178static vector signed char _ATTRS_o_ai
179vec_adds(vector signed char a, vector signed char b)
180{
181 return __builtin_altivec_vaddsbs(a, b);
182}
183
184static vector unsigned char _ATTRS_o_ai
185vec_adds(vector unsigned char a, vector unsigned char b)
186{
187 return __builtin_altivec_vaddubs(a, b);
188}
189
190static vector short _ATTRS_o_ai
191vec_adds(vector short a, vector short b)
192{
193 return __builtin_altivec_vaddshs(a, b);
194}
195
196static vector unsigned short _ATTRS_o_ai
197vec_adds(vector unsigned short a, vector unsigned short b)
198{
199 return __builtin_altivec_vadduhs(a, b);
200}
201
202static vector int _ATTRS_o_ai
203vec_adds(vector int a, vector int b)
204{
205 return __builtin_altivec_vaddsws(a, b);
206}
207
208static vector unsigned int _ATTRS_o_ai
209vec_adds(vector unsigned int a, vector unsigned int b)
210{
211 return __builtin_altivec_vadduws(a, b);
212}
213
214/* vec_sub */
215
216#define __builtin_altivec_vsububm vec_sub
217#define __builtin_altivec_vsubuhm vec_sub
218#define __builtin_altivec_vsubuwm vec_sub
219#define __builtin_altivec_vsubfp vec_sub
220#define __builtin_vec_vsububm vec_sub
221#define __builtin_vec_vsubuhm vec_sub
222#define __builtin_vec_vsubuwm vec_sub
223#define __builtin_vec_vsubfp vec_sub
224#define vec_vsububm vec_sub
225#define vec_vsubuhm vec_sub
226#define vec_vsubuwm vec_sub
227#define vec_vsubfp vec_sub
228
Chris Lattnerdd173942010-04-14 03:54:58 +0000229static vector signed char _ATTRS_o_ai
230vec_sub(vector signed char a, vector signed char b)
231{
232 return a - b;
233}
234
235static vector unsigned char _ATTRS_o_ai
236vec_sub(vector unsigned char a, vector unsigned char b)
237{
238 return a - b;
239}
240
241static vector short _ATTRS_o_ai
242vec_sub(vector short a, vector short b)
243{
244 return a - b;
245}
246
247static vector unsigned short _ATTRS_o_ai
248vec_sub(vector unsigned short a, vector unsigned short b)
249{
250 return a - b;
251}
252
253static vector int _ATTRS_o_ai
254vec_sub(vector int a, vector int b)
255{
256 return a - b;
257}
258
259static vector unsigned int _ATTRS_o_ai
260vec_sub(vector unsigned int a, vector unsigned int b)
261{
262 return a - b;
263}
264
265static vector float _ATTRS_o_ai
266vec_sub(vector float a, vector float b)
267{
268 return a - b;
269}
270
271/* vec_subs */
272
273#define __builtin_vec_vsubsbs __builtin_altivec_vsubsbs
274#define __builtin_vec_vsububs __builtin_altivec_vsububs
275#define __builtin_vec_vsubshs __builtin_altivec_vsubshs
276#define __builtin_vec_vsubuhs __builtin_altivec_vsubuhs
277#define __builtin_vec_vsubsws __builtin_altivec_vsubsws
278#define __builtin_vec_vsubuws __builtin_altivec_vsubuws
279#define vec_vsubsbs __builtin_altivec_vsubsbs
280#define vec_vsububs __builtin_altivec_vsububs
281#define vec_vsubshs __builtin_altivec_vsubshs
282#define vec_vsubuhs __builtin_altivec_vsubuhs
283#define vec_vsubsws __builtin_altivec_vsubsws
284#define vec_vsubuws __builtin_altivec_vsubuws
285
Chris Lattnerdd173942010-04-14 03:54:58 +0000286static vector signed char _ATTRS_o_ai
287vec_subs(vector signed char a, vector signed char b)
288{
289 return __builtin_altivec_vsubsbs(a, b);
290}
291
292static vector unsigned char _ATTRS_o_ai
293vec_subs(vector unsigned char a, vector unsigned char b)
294{
295 return __builtin_altivec_vsububs(a, b);
296}
297
298static vector short _ATTRS_o_ai
299vec_subs(vector short a, vector short b)
300{
301 return __builtin_altivec_vsubshs(a, b);
302}
303
304static vector unsigned short _ATTRS_o_ai
305vec_subs(vector unsigned short a, vector unsigned short b)
306{
307 return __builtin_altivec_vsubuhs(a, b);
308}
309
310static vector int _ATTRS_o_ai
311vec_subs(vector int a, vector int b)
312{
313 return __builtin_altivec_vsubsws(a, b);
314}
315
316static vector unsigned int _ATTRS_o_ai
317vec_subs(vector unsigned int a, vector unsigned int b)
318{
319 return __builtin_altivec_vsubuws(a, b);
320}
321
322/* vec_avg */
323
324#define __builtin_vec_vavgsb __builtin_altivec_vavgsb
325#define __builtin_vec_vavgub __builtin_altivec_vavgub
326#define __builtin_vec_vavgsh __builtin_altivec_vavgsh
327#define __builtin_vec_vavguh __builtin_altivec_vavguh
328#define __builtin_vec_vavgsw __builtin_altivec_vavgsw
329#define __builtin_vec_vavguw __builtin_altivec_vavguw
330#define vec_vavgsb __builtin_altivec_vavgsb
331#define vec_vavgub __builtin_altivec_vavgub
332#define vec_vavgsh __builtin_altivec_vavgsh
333#define vec_vavguh __builtin_altivec_vavguh
334#define vec_vavgsw __builtin_altivec_vavgsw
335#define vec_vavguw __builtin_altivec_vavguw
336
Chris Lattnerdd173942010-04-14 03:54:58 +0000337static vector signed char _ATTRS_o_ai
338vec_avg(vector signed char a, vector signed char b)
339{
340 return __builtin_altivec_vavgsb(a, b);
341}
342
343static vector unsigned char _ATTRS_o_ai
344vec_avg(vector unsigned char a, vector unsigned char b)
345{
346 return __builtin_altivec_vavgub(a, b);
347}
348
349static vector short _ATTRS_o_ai
350vec_avg(vector short a, vector short b)
351{
352 return __builtin_altivec_vavgsh(a, b);
353}
354
355static vector unsigned short _ATTRS_o_ai
356vec_avg(vector unsigned short a, vector unsigned short b)
357{
358 return __builtin_altivec_vavguh(a, b);
359}
360
361static vector int _ATTRS_o_ai
362vec_avg(vector int a, vector int b)
363{
364 return __builtin_altivec_vavgsw(a, b);
365}
366
367static vector unsigned int _ATTRS_o_ai
368vec_avg(vector unsigned int a, vector unsigned int b)
369{
370 return __builtin_altivec_vavguw(a, b);
371}
372
373/* vec_st */
374
375#define __builtin_vec_st vec_st
376#define vec_stvx vec_st
377
378static void _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000379vec_st(vector signed char a, int b, vector signed char *c)
380{
381 __builtin_altivec_stvx((vector int)a, b, (void *)c);
382}
383
384static void _ATTRS_o_ai
385vec_st(vector unsigned char a, int b, vector unsigned char *c)
386{
387 __builtin_altivec_stvx((vector int)a, b, (void *)c);
388}
389
390static void _ATTRS_o_ai
391vec_st(vector short a, int b, vector short *c)
392{
393 __builtin_altivec_stvx((vector int)a, b, (void *)c);
394}
395
396static void _ATTRS_o_ai
397vec_st(vector unsigned short a, int b, vector unsigned short *c)
398{
399 __builtin_altivec_stvx((vector int)a, b, (void *)c);
400}
401
402static void _ATTRS_o_ai
403vec_st(vector int a, int b, vector int *c)
404{
405 __builtin_altivec_stvx(a, b, (void *)c);
406}
407
408static void _ATTRS_o_ai
409vec_st(vector unsigned int a, int b, vector unsigned int *c)
410{
411 __builtin_altivec_stvx((vector int)a, b, (void *)c);
412}
413
414static void _ATTRS_o_ai
415vec_st(vector float a, int b, vector float *c)
416{
417 __builtin_altivec_stvx((vector int)a, b, (void *)c);
418}
419
420/* vec_stl */
421
422#define __builtin_vec_stl vec_stl
423#define vec_stvxl vec_stl
424
425static void _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000426vec_stl(vector signed char a, int b, vector signed char *c)
427{
428 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
429}
430
431static void _ATTRS_o_ai
432vec_stl(vector unsigned char a, int b, vector unsigned char *c)
433{
434 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
435}
436
437static void _ATTRS_o_ai
438vec_stl(vector short a, int b, vector short *c)
439{
440 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
441}
442
443static void _ATTRS_o_ai
444vec_stl(vector unsigned short a, int b, vector unsigned short *c)
445{
446 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
447}
448
449static void _ATTRS_o_ai
450vec_stl(vector int a, int b, vector int *c)
451{
452 __builtin_altivec_stvxl(a, b, (void *)c);
453}
454
455static void _ATTRS_o_ai
456vec_stl(vector unsigned int a, int b, vector unsigned int *c)
457{
458 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
459}
460
461static void _ATTRS_o_ai
462vec_stl(vector float a, int b, vector float *c)
463{
464 __builtin_altivec_stvxl((vector int)a, b, (void *)c);
465}
466
467/* vec_ste */
468
469#define __builtin_vec_stvebx __builtin_altivec_stvebx
470#define __builtin_vec_stvehx __builtin_altivec_stvehx
471#define __builtin_vec_stvewx __builtin_altivec_stvewx
472#define vec_stvebx __builtin_altivec_stvebx
473#define vec_stvehx __builtin_altivec_stvehx
474#define vec_stvewx __builtin_altivec_stvewx
475
476static void _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000477vec_ste(vector signed char a, int b, vector signed char *c)
478{
Chris Lattnerab866b42010-04-14 20:35:39 +0000479 __builtin_altivec_stvebx((vector char)a, b, (void *)c);
Chris Lattnerdd173942010-04-14 03:54:58 +0000480}
481
482static void _ATTRS_o_ai
483vec_ste(vector unsigned char a, int b, vector unsigned char *c)
484{
Chris Lattnerab866b42010-04-14 20:35:39 +0000485 __builtin_altivec_stvebx((vector char)a, b, (void *)c);
Chris Lattnerdd173942010-04-14 03:54:58 +0000486}
487
488static void _ATTRS_o_ai
489vec_ste(vector short a, int b, vector short *c)
490{
Chris Lattnerab866b42010-04-14 20:35:39 +0000491 __builtin_altivec_stvehx(a, b, (void *)c);
Chris Lattnerdd173942010-04-14 03:54:58 +0000492}
493
494static void _ATTRS_o_ai
495vec_ste(vector unsigned short a, int b, vector unsigned short *c)
496{
Chris Lattnerab866b42010-04-14 20:35:39 +0000497 __builtin_altivec_stvehx((vector short)a, b, (void *)c);
Chris Lattnerdd173942010-04-14 03:54:58 +0000498}
499
500static void _ATTRS_o_ai
501vec_ste(vector int a, int b, vector int *c)
502{
503 __builtin_altivec_stvewx(a, b, (void *)c);
504}
505
506static void _ATTRS_o_ai
507vec_ste(vector unsigned int a, int b, vector unsigned int *c)
508{
509 __builtin_altivec_stvewx((vector int)a, b, (void *)c);
510}
511
512static void _ATTRS_o_ai
513vec_ste(vector float a, int b, vector float *c)
514{
515 __builtin_altivec_stvewx((vector int)a, b, (void *)c);
516}
517
518/* vec_cmpb */
519
520#define vec_cmpb __builtin_altivec_vcmpbfp
521#define vec_vcmpbfp __builtin_altivec_vcmpbfp
522#define __builtin_vec_cmpb __builtin_altivec_vcmpbfp
523
524/* vec_cmpeq */
525
526#define __builtin_vec_cmpeq vec_cmpeq
527
Chris Lattnerab866b42010-04-14 20:35:39 +0000528static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000529vec_cmpeq(vector signed char a, vector signed char b)
530{
Chris Lattnerab866b42010-04-14 20:35:39 +0000531 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000532}
533
Chris Lattnerab866b42010-04-14 20:35:39 +0000534static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000535vec_cmpeq(vector unsigned char a, vector unsigned char b)
536{
Chris Lattnerab866b42010-04-14 20:35:39 +0000537 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000538}
539
Chris Lattnerab866b42010-04-14 20:35:39 +0000540static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000541vec_cmpeq(vector short a, vector short b)
542{
543 return __builtin_altivec_vcmpequh(a, b);
544}
545
Chris Lattnerab866b42010-04-14 20:35:39 +0000546static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000547vec_cmpeq(vector unsigned short a, vector unsigned short b)
548{
Chris Lattnerab866b42010-04-14 20:35:39 +0000549 return __builtin_altivec_vcmpequh((vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000550}
551
Chris Lattnerab866b42010-04-14 20:35:39 +0000552static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000553vec_cmpeq(vector int a, vector int b)
554{
555 return __builtin_altivec_vcmpequw(a, b);
556}
557
Chris Lattnerab866b42010-04-14 20:35:39 +0000558static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000559vec_cmpeq(vector unsigned int a, vector unsigned int b)
560{
Chris Lattnerab866b42010-04-14 20:35:39 +0000561 return __builtin_altivec_vcmpequw((vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000562}
563
Chris Lattnerab866b42010-04-14 20:35:39 +0000564static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000565vec_cmpeq(vector float a, vector float b)
566{
567 return __builtin_altivec_vcmpeqfp(a, b);
568}
569
570/* vec_cmpge */
571
572#define vec_cmpge __builtin_altivec_vcmpgefp
573#define vec_vcmpgefp __builtin_altivec_vcmpgefp
574#define __builtin_vec_cmpge __builtin_altivec_vcmpgefp
575
576/* vec_cmpgt */
577
578#define vec_vcmpgtsb __builtin_altivec_vcmpgtsb
579#define vec_vcmpgtub __builtin_altivec_vcmpgtub
580#define vec_vcmpgtsh __builtin_altivec_vcmpgtsh
581#define vec_vcmpgtuh __builtin_altivec_vcmpgtuh
582#define vec_vcmpgtsw __builtin_altivec_vcmpgtsw
583#define vec_vcmpgtuw __builtin_altivec_vcmpgtuw
584#define vec_vcmpgtfp __builtin_altivec_vcmpgtfp
585#define __builtin_vec_vcmpgtsb __builtin_altivec_vcmpgtsb
586#define __builtin_vec_vcmpgtub __builtin_altivec_vcmpgtub
587#define __builtin_vec_vcmpgtsh __builtin_altivec_vcmpgtsh
588#define __builtin_vec_vcmpgtuh __builtin_altivec_vcmpgtuh
589#define __builtin_vec_vcmpgtsw __builtin_altivec_vcmpgtsw
590#define __builtin_vec_vcmpgtuw __builtin_altivec_vcmpgtuw
591#define __builtin_vec_vcmpgtfp __builtin_altivec_vcmpgtfp
592
Chris Lattnerab866b42010-04-14 20:35:39 +0000593static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000594vec_cmpgt(vector signed char a, vector signed char b)
595{
596 return __builtin_altivec_vcmpgtsb(a, b);
597}
598
Chris Lattnerab866b42010-04-14 20:35:39 +0000599static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000600vec_cmpgt(vector unsigned char a, vector unsigned char b)
601{
602 return __builtin_altivec_vcmpgtub(a, b);
603}
604
Chris Lattnerab866b42010-04-14 20:35:39 +0000605static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000606vec_cmpgt(vector short a, vector short b)
607{
608 return __builtin_altivec_vcmpgtsh(a, b);
609}
610
Chris Lattnerab866b42010-04-14 20:35:39 +0000611static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000612vec_cmpgt(vector unsigned short a, vector unsigned short b)
613{
614 return __builtin_altivec_vcmpgtuh(a, b);
615}
616
Chris Lattnerab866b42010-04-14 20:35:39 +0000617static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000618vec_cmpgt(vector int a, vector int b)
619{
620 return __builtin_altivec_vcmpgtsw(a, b);
621}
622
Chris Lattnerab866b42010-04-14 20:35:39 +0000623static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000624vec_cmpgt(vector unsigned int a, vector unsigned int b)
625{
626 return __builtin_altivec_vcmpgtuw(a, b);
627}
628
Chris Lattnerab866b42010-04-14 20:35:39 +0000629static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000630vec_cmpgt(vector float a, vector float b)
631{
632 return __builtin_altivec_vcmpgtfp(a, b);
633}
634
635/* vec_cmple */
636
637#define __builtin_vec_cmple vec_cmple
638
Chris Lattnerab866b42010-04-14 20:35:39 +0000639static vector /*bool*/ int __attribute__((__always_inline__))
Chris Lattnerdd173942010-04-14 03:54:58 +0000640vec_cmple(vector float a, vector float b)
641{
642 return __builtin_altivec_vcmpgefp(b, a);
643}
644
645/* vec_cmplt */
646
647#define __builtin_vec_cmplt vec_cmplt
648
Chris Lattnerab866b42010-04-14 20:35:39 +0000649static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000650vec_cmplt(vector signed char a, vector signed char b)
651{
652 return __builtin_altivec_vcmpgtsb(b, a);
653}
654
Chris Lattnerab866b42010-04-14 20:35:39 +0000655static vector /*bool*/ char _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000656vec_cmplt(vector unsigned char a, vector unsigned char b)
657{
658 return __builtin_altivec_vcmpgtub(b, a);
659}
660
Chris Lattnerab866b42010-04-14 20:35:39 +0000661static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000662vec_cmplt(vector short a, vector short b)
663{
664 return __builtin_altivec_vcmpgtsh(b, a);
665}
666
Chris Lattnerab866b42010-04-14 20:35:39 +0000667static vector /*bool*/ short _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000668vec_cmplt(vector unsigned short a, vector unsigned short b)
669{
670 return __builtin_altivec_vcmpgtuh(b, a);
671}
672
Chris Lattnerab866b42010-04-14 20:35:39 +0000673static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000674vec_cmplt(vector int a, vector int b)
675{
676 return __builtin_altivec_vcmpgtsw(b, a);
677}
678
Chris Lattnerab866b42010-04-14 20:35:39 +0000679static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000680vec_cmplt(vector unsigned int a, vector unsigned int b)
681{
682 return __builtin_altivec_vcmpgtuw(b, a);
683}
684
Chris Lattnerab866b42010-04-14 20:35:39 +0000685static vector /*bool*/ int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000686vec_cmplt(vector float a, vector float b)
687{
688 return __builtin_altivec_vcmpgtfp(b, a);
689}
690
691/* vec_max */
692
693#define __builtin_vec_vmaxsb __builtin_altivec_vmaxsb
694#define __builtin_vec_vmaxub __builtin_altivec_vmaxub
695#define __builtin_vec_vmaxsh __builtin_altivec_vmaxsh
696#define __builtin_vec_vmaxuh __builtin_altivec_vmaxuh
697#define __builtin_vec_vmaxsw __builtin_altivec_vmaxsw
698#define __builtin_vec_vmaxuw __builtin_altivec_vmaxuw
699#define __builtin_vec_vmaxfp __builtin_altivec_vmaxfp
700#define vec_vmaxsb __builtin_altivec_vmaxsb
701#define vec_vmaxub __builtin_altivec_vmaxub
702#define vec_vmaxsh __builtin_altivec_vmaxsh
703#define vec_vmaxuh __builtin_altivec_vmaxuh
704#define vec_vmaxsw __builtin_altivec_vmaxsw
705#define vec_vmaxuw __builtin_altivec_vmaxuw
706#define vec_vmaxfp __builtin_altivec_vmaxfp
707#define __builtin_vec_max vec_max
708
Chris Lattnerdd173942010-04-14 03:54:58 +0000709static vector signed char _ATTRS_o_ai
710vec_max(vector signed char a, vector signed char b)
711{
712 return __builtin_altivec_vmaxsb(a, b);
713}
714
715static vector unsigned char _ATTRS_o_ai
716vec_max(vector unsigned char a, vector unsigned char b)
717{
718 return __builtin_altivec_vmaxub(a, b);
719}
720
721static vector short _ATTRS_o_ai
722vec_max(vector short a, vector short b)
723{
724 return __builtin_altivec_vmaxsh(a, b);
725}
726
727static vector unsigned short _ATTRS_o_ai
728vec_max(vector unsigned short a, vector unsigned short b)
729{
730 return __builtin_altivec_vmaxuh(a, b);
731}
732
733static vector int _ATTRS_o_ai
734vec_max(vector int a, vector int b)
735{
736 return __builtin_altivec_vmaxsw(a, b);
737}
738
739static vector unsigned int _ATTRS_o_ai
740vec_max(vector unsigned int a, vector unsigned int b)
741{
742 return __builtin_altivec_vmaxuw(a, b);
743}
744
745static vector float _ATTRS_o_ai
746vec_max(vector float a, vector float b)
747{
748 return __builtin_altivec_vmaxfp(a, b);
749}
750
751/* vec_mfvscr */
752
753#define __builtin_vec_mfvscr __builtin_altivec_mfvscr
754#define vec_mfvscr __builtin_altivec_mfvscr
755
756/* vec_min */
757
758#define __builtin_vec_vminsb __builtin_altivec_vminsb
759#define __builtin_vec_vminub __builtin_altivec_vminub
760#define __builtin_vec_vminsh __builtin_altivec_vminsh
761#define __builtin_vec_vminuh __builtin_altivec_vminuh
762#define __builtin_vec_vminsw __builtin_altivec_vminsw
763#define __builtin_vec_vminuw __builtin_altivec_vminuw
764#define __builtin_vec_vminfp __builtin_altivec_vminfp
765#define vec_vminsb __builtin_altivec_vminsb
766#define vec_vminub __builtin_altivec_vminub
767#define vec_vminsh __builtin_altivec_vminsh
768#define vec_vminuh __builtin_altivec_vminuh
769#define vec_vminsw __builtin_altivec_vminsw
770#define vec_vminuw __builtin_altivec_vminuw
771#define vec_vminfp __builtin_altivec_vminfp
772#define __builtin_vec_min vec_min
773
Chris Lattnerdd173942010-04-14 03:54:58 +0000774static vector signed char _ATTRS_o_ai
775vec_min(vector signed char a, vector signed char b)
776{
777 return __builtin_altivec_vminsb(a, b);
778}
779
780static vector unsigned char _ATTRS_o_ai
781vec_min(vector unsigned char a, vector unsigned char b)
782{
783 return __builtin_altivec_vminub(a, b);
784}
785
786static vector short _ATTRS_o_ai
787vec_min(vector short a, vector short b)
788{
789 return __builtin_altivec_vminsh(a, b);
790}
791
792static vector unsigned short _ATTRS_o_ai
793vec_min(vector unsigned short a, vector unsigned short b)
794{
795 return __builtin_altivec_vminuh(a, b);
796}
797
798static vector int _ATTRS_o_ai
799vec_min(vector int a, vector int b)
800{
801 return __builtin_altivec_vminsw(a, b);
802}
803
804static vector unsigned int _ATTRS_o_ai
805vec_min(vector unsigned int a, vector unsigned int b)
806{
807 return __builtin_altivec_vminuw(a, b);
808}
809
810static vector float _ATTRS_o_ai
811vec_min(vector float a, vector float b)
812{
813 return __builtin_altivec_vminfp(a, b);
814}
815
816/* vec_mtvscr */
817
818#define __builtin_vec_mtvscr __builtin_altivec_mtvscr
819#define vec_mtvscr __builtin_altivec_mtvscr
820
821/* ------------------------------ predicates ------------------------------------ */
822
823static int __attribute__((__always_inline__))
824__builtin_vec_vcmpeq_p(char CR6_param, vector float a, vector float b)
825{
826 return __builtin_altivec_vcmpeqfp_p(CR6_param, a, b);
827}
828
829static int __attribute__((__always_inline__))
830__builtin_vec_vcmpge_p(char CR6_param, vector float a, vector float b)
831{
832 return __builtin_altivec_vcmpgefp_p(CR6_param, a, b);
833}
834
835static int __attribute__((__always_inline__))
836__builtin_vec_vcmpgt_p(char CR6_param, vector float a, vector float b)
837{
838 return __builtin_altivec_vcmpgtfp_p(CR6_param, a, b);
839}
840
841/* vec_all_eq */
842
843static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000844vec_all_eq(vector signed char a, vector signed char b)
845{
Chris Lattnerab866b42010-04-14 20:35:39 +0000846 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000847}
848
849static int _ATTRS_o_ai
850vec_all_eq(vector unsigned char a, vector unsigned char b)
851{
Chris Lattnerab866b42010-04-14 20:35:39 +0000852 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000853}
854
855static int _ATTRS_o_ai
856vec_all_eq(vector short a, vector short b)
857{
858 return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b);
859}
860
861static int _ATTRS_o_ai
862vec_all_eq(vector unsigned short a, vector unsigned short b)
863{
Chris Lattnerab866b42010-04-14 20:35:39 +0000864 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000865}
866
867static int _ATTRS_o_ai
868vec_all_eq(vector int a, vector int b)
869{
870 return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b);
871}
872
873static int _ATTRS_o_ai
874vec_all_eq(vector unsigned int a, vector unsigned int b)
875{
Chris Lattnerab866b42010-04-14 20:35:39 +0000876 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000877}
878
879static int _ATTRS_o_ai
880vec_all_eq(vector float a, vector float b)
881{
882 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, b);
883}
884
885/* vec_all_ge */
886
887static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000888vec_all_ge(vector signed char a, vector signed char b)
889{
890 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a);
891}
892
893static int _ATTRS_o_ai
894vec_all_ge(vector unsigned char a, vector unsigned char b)
895{
896 return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a);
897}
898
899static int _ATTRS_o_ai
900vec_all_ge(vector short a, vector short b)
901{
902 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a);
903}
904
905static int _ATTRS_o_ai
906vec_all_ge(vector unsigned short a, vector unsigned short b)
907{
908 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a);
909}
910
911static int _ATTRS_o_ai
912vec_all_ge(vector int a, vector int b)
913{
914 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a);
915}
916
917static int _ATTRS_o_ai
918vec_all_ge(vector unsigned int a, vector unsigned int b)
919{
920 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a);
921}
922
923static int _ATTRS_o_ai
924vec_all_ge(vector float a, vector float b)
925{
926 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a);
927}
928
929/* vec_all_gt */
930
931static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000932vec_all_gt(vector signed char a, vector signed char b)
933{
934 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b);
935}
936
937static int _ATTRS_o_ai
938vec_all_gt(vector unsigned char a, vector unsigned char b)
939{
940 return __builtin_altivec_vcmpgtub_p(__CR6_LT, a, b);
941}
942
943static int _ATTRS_o_ai
944vec_all_gt(vector short a, vector short b)
945{
946 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, a, b);
947}
948
949static int _ATTRS_o_ai
950vec_all_gt(vector unsigned short a, vector unsigned short b)
951{
952 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, a, b);
953}
954
955static int _ATTRS_o_ai
956vec_all_gt(vector int a, vector int b)
957{
958 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, a, b);
959}
960
961static int _ATTRS_o_ai
962vec_all_gt(vector unsigned int a, vector unsigned int b)
963{
964 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, a, b);
965}
966
967static int _ATTRS_o_ai
968vec_all_gt(vector float a, vector float b)
969{
970 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, a, b);
971}
972
973/* vec_all_in */
974
975static int __attribute__((__always_inline__))
976vec_all_in(vector float a, vector float b)
977{
978 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, a, b);
979}
980
981/* vec_all_le */
982
983static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000984vec_all_le(vector signed char a, vector signed char b)
985{
986 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b);
987}
988
989static int _ATTRS_o_ai
990vec_all_le(vector unsigned char a, vector unsigned char b)
991{
992 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, a, b);
993}
994
995static int _ATTRS_o_ai
996vec_all_le(vector short a, vector short b)
997{
998 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, a, b);
999}
1000
1001static int _ATTRS_o_ai
1002vec_all_le(vector unsigned short a, vector unsigned short b)
1003{
1004 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, a, b);
1005}
1006
1007static int _ATTRS_o_ai
1008vec_all_le(vector int a, vector int b)
1009{
1010 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, a, b);
1011}
1012
1013static int _ATTRS_o_ai
1014vec_all_le(vector unsigned int a, vector unsigned int b)
1015{
1016 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, a, b);
1017}
1018
1019static int _ATTRS_o_ai
1020vec_all_le(vector float a, vector float b)
1021{
1022 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b);
1023}
1024
1025/* vec_all_lt */
1026
1027static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001028vec_all_lt(vector signed char a, vector signed char b)
1029{
1030 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a);
1031}
1032
1033static int _ATTRS_o_ai
1034vec_all_lt(vector unsigned char a, vector unsigned char b)
1035{
1036 return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a);
1037}
1038
1039static int _ATTRS_o_ai
1040vec_all_lt(vector short a, vector short b)
1041{
1042 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a);
1043}
1044
1045static int _ATTRS_o_ai
1046vec_all_lt(vector unsigned short a, vector unsigned short b)
1047{
1048 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a);
1049}
1050
1051static int _ATTRS_o_ai
1052vec_all_lt(vector int a, vector int b)
1053{
1054 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a);
1055}
1056
1057static int _ATTRS_o_ai
1058vec_all_lt(vector unsigned int a, vector unsigned int b)
1059{
1060 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a);
1061}
1062
1063static int _ATTRS_o_ai
1064vec_all_lt(vector float a, vector float b)
1065{
1066 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a);
1067}
1068
1069/* vec_all_nan */
1070
1071static int __attribute__((__always_inline__))
1072vec_all_nan(vector float a)
1073{
1074 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, a);
1075}
1076
1077/* vec_all_ne */
1078
1079static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001080vec_all_ne(vector signed char a, vector signed char b)
1081{
Chris Lattnerab866b42010-04-14 20:35:39 +00001082 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001083}
1084
1085static int _ATTRS_o_ai
1086vec_all_ne(vector unsigned char a, vector unsigned char b)
1087{
Chris Lattnerab866b42010-04-14 20:35:39 +00001088 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001089}
1090
1091static int _ATTRS_o_ai
1092vec_all_ne(vector short a, vector short b)
1093{
1094 return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b);
1095}
1096
1097static int _ATTRS_o_ai
1098vec_all_ne(vector unsigned short a, vector unsigned short b)
1099{
Chris Lattnerab866b42010-04-14 20:35:39 +00001100 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001101}
1102
1103static int _ATTRS_o_ai
1104vec_all_ne(vector int a, vector int b)
1105{
1106 return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b);
1107}
1108
1109static int _ATTRS_o_ai
1110vec_all_ne(vector unsigned int a, vector unsigned int b)
1111{
Chris Lattnerab866b42010-04-14 20:35:39 +00001112 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001113}
1114
1115static int _ATTRS_o_ai
1116vec_all_ne(vector float a, vector float b)
1117{
1118 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, b);
1119}
1120
1121/* vec_all_nge */
1122
1123static int __attribute__((__always_inline__))
1124vec_all_nge(vector float a, vector float b)
1125{
1126 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, a, b);
1127}
1128
1129/* vec_all_ngt */
1130
1131static int __attribute__((__always_inline__))
1132vec_all_ngt(vector float a, vector float b)
1133{
1134 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b);
1135}
1136
1137/* vec_all_nle */
1138
1139static int __attribute__((__always_inline__))
1140vec_all_nle(vector float a, vector float b)
1141{
1142 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, b, a);
1143}
1144
1145/* vec_all_nlt */
1146
1147static int __attribute__((__always_inline__))
1148vec_all_nlt(vector float a, vector float b)
1149{
1150 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, b, a);
1151}
1152
1153/* vec_all_numeric */
1154
1155static int __attribute__((__always_inline__))
1156vec_all_numeric(vector float a)
1157{
1158 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, a);
1159}
1160
1161/* vec_any_eq */
1162
1163static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001164vec_any_eq(vector signed char a, vector signed char b)
1165{
Chris Lattnerab866b42010-04-14 20:35:39 +00001166 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001167}
1168
1169static int _ATTRS_o_ai
1170vec_any_eq(vector unsigned char a, vector unsigned char b)
1171{
Chris Lattnerab866b42010-04-14 20:35:39 +00001172 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001173}
1174
1175static int _ATTRS_o_ai
1176vec_any_eq(vector short a, vector short b)
1177{
1178 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b);
1179}
1180
1181static int _ATTRS_o_ai
1182vec_any_eq(vector unsigned short a, vector unsigned short b)
1183{
Chris Lattnerab866b42010-04-14 20:35:39 +00001184 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001185}
1186
1187static int _ATTRS_o_ai
1188vec_any_eq(vector int a, vector int b)
1189{
1190 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b);
1191}
1192
1193static int _ATTRS_o_ai
1194vec_any_eq(vector unsigned int a, vector unsigned int b)
1195{
Chris Lattnerab866b42010-04-14 20:35:39 +00001196 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001197}
1198
1199static int _ATTRS_o_ai
1200vec_any_eq(vector float a, vector float b)
1201{
1202 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, b);
1203}
1204
1205/* vec_any_ge */
1206
1207static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001208vec_any_ge(vector signed char a, vector signed char b)
1209{
1210 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a);
1211}
1212
1213static int _ATTRS_o_ai
1214vec_any_ge(vector unsigned char a, vector unsigned char b)
1215{
1216 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, b, a);
1217}
1218
1219static int _ATTRS_o_ai
1220vec_any_ge(vector short a, vector short b)
1221{
1222 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, b, a);
1223}
1224
1225static int _ATTRS_o_ai
1226vec_any_ge(vector unsigned short a, vector unsigned short b)
1227{
1228 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, b, a);
1229}
1230
1231static int _ATTRS_o_ai
1232vec_any_ge(vector int a, vector int b)
1233{
1234 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, b, a);
1235}
1236
1237static int _ATTRS_o_ai
1238vec_any_ge(vector unsigned int a, vector unsigned int b)
1239{
1240 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, b, a);
1241}
1242
1243static int _ATTRS_o_ai
1244vec_any_ge(vector float a, vector float b)
1245{
1246 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a);
1247}
1248
1249/* vec_any_gt */
1250
1251static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001252vec_any_gt(vector signed char a, vector signed char b)
1253{
1254 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b);
1255}
1256
1257static int _ATTRS_o_ai
1258vec_any_gt(vector unsigned char a, vector unsigned char b)
1259{
1260 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, a, b);
1261}
1262
1263static int _ATTRS_o_ai
1264vec_any_gt(vector short a, vector short b)
1265{
1266 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, a, b);
1267}
1268
1269static int _ATTRS_o_ai
1270vec_any_gt(vector unsigned short a, vector unsigned short b)
1271{
1272 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, a, b);
1273}
1274
1275static int _ATTRS_o_ai
1276vec_any_gt(vector int a, vector int b)
1277{
1278 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, a, b);
1279}
1280
1281static int _ATTRS_o_ai
1282vec_any_gt(vector unsigned int a, vector unsigned int b)
1283{
1284 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, a, b);
1285}
1286
1287static int _ATTRS_o_ai
1288vec_any_gt(vector float a, vector float b)
1289{
1290 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, a, b);
1291}
1292
1293/* vec_any_le */
1294
1295static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001296vec_any_le(vector signed char a, vector signed char b)
1297{
1298 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b);
1299}
1300
1301static int _ATTRS_o_ai
1302vec_any_le(vector unsigned char a, vector unsigned char b)
1303{
1304 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, a, b);
1305}
1306
1307static int _ATTRS_o_ai
1308vec_any_le(vector short a, vector short b)
1309{
1310 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, a, b);
1311}
1312
1313static int _ATTRS_o_ai
1314vec_any_le(vector unsigned short a, vector unsigned short b)
1315{
1316 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, a, b);
1317}
1318
1319static int _ATTRS_o_ai
1320vec_any_le(vector int a, vector int b)
1321{
1322 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, a, b);
1323}
1324
1325static int _ATTRS_o_ai
1326vec_any_le(vector unsigned int a, vector unsigned int b)
1327{
1328 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, a, b);
1329}
1330
1331static int _ATTRS_o_ai
1332vec_any_le(vector float a, vector float b)
1333{
1334 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b);
1335}
1336
1337/* vec_any_lt */
1338
1339static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001340vec_any_lt(vector signed char a, vector signed char b)
1341{
1342 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a);
1343}
1344
1345static int _ATTRS_o_ai
1346vec_any_lt(vector unsigned char a, vector unsigned char b)
1347{
1348 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, b, a);
1349}
1350
1351static int _ATTRS_o_ai
1352vec_any_lt(vector short a, vector short b)
1353{
1354 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, b, a);
1355}
1356
1357static int _ATTRS_o_ai
1358vec_any_lt(vector unsigned short a, vector unsigned short b)
1359{
1360 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, b, a);
1361}
1362
1363static int _ATTRS_o_ai
1364vec_any_lt(vector int a, vector int b)
1365{
1366 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, b, a);
1367}
1368
1369static int _ATTRS_o_ai
1370vec_any_lt(vector unsigned int a, vector unsigned int b)
1371{
1372 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, b, a);
1373}
1374
1375static int _ATTRS_o_ai
1376vec_any_lt(vector float a, vector float b)
1377{
1378 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, b, a);
1379}
1380
1381/* vec_any_nan */
1382
1383static int __attribute__((__always_inline__))
1384vec_any_nan(vector float a)
1385{
1386 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, a);
1387}
1388
1389/* vec_any_ne */
1390
1391static int _ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001392vec_any_ne(vector signed char a, vector signed char b)
1393{
Chris Lattnerab866b42010-04-14 20:35:39 +00001394 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001395}
1396
1397static int _ATTRS_o_ai
1398vec_any_ne(vector unsigned char a, vector unsigned char b)
1399{
Chris Lattnerab866b42010-04-14 20:35:39 +00001400 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001401}
1402
1403static int _ATTRS_o_ai
1404vec_any_ne(vector short a, vector short b)
1405{
1406 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b);
1407}
1408
1409static int _ATTRS_o_ai
1410vec_any_ne(vector unsigned short a, vector unsigned short b)
1411{
Chris Lattnerab866b42010-04-14 20:35:39 +00001412 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001413}
1414
1415static int _ATTRS_o_ai
1416vec_any_ne(vector int a, vector int b)
1417{
1418 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b);
1419}
1420
1421static int _ATTRS_o_ai
1422vec_any_ne(vector unsigned int a, vector unsigned int b)
1423{
Chris Lattnerab866b42010-04-14 20:35:39 +00001424 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001425}
1426
1427static int _ATTRS_o_ai
1428vec_any_ne(vector float a, vector float b)
1429{
1430 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, b);
1431}
1432
1433/* vec_any_nge */
1434
1435static int __attribute__((__always_inline__))
1436vec_any_nge(vector float a, vector float b)
1437{
1438 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, a, b);
1439}
1440
1441/* vec_any_ngt */
1442
1443static int __attribute__((__always_inline__))
1444vec_any_ngt(vector float a, vector float b)
1445{
1446 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b);
1447}
1448
1449/* vec_any_nle */
1450
1451static int __attribute__((__always_inline__))
1452vec_any_nle(vector float a, vector float b)
1453{
1454 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, b, a);
1455}
1456
1457/* vec_any_nlt */
1458
1459static int __attribute__((__always_inline__))
1460vec_any_nlt(vector float a, vector float b)
1461{
1462 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a);
1463}
1464
1465/* vec_any_numeric */
1466
1467static int __attribute__((__always_inline__))
1468vec_any_numeric(vector float a)
1469{
1470 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, a);
1471}
1472
1473/* vec_any_out */
1474
1475static int __attribute__((__always_inline__))
1476vec_any_out(vector float a, vector float b)
1477{
1478 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, a, b);
1479}
1480
1481#undef _ATTRS_o_ai
1482
1483#endif /* __ALTIVEC_H */