blob: d3d5ad90aef18c4329781376148dabfa83ed0518 [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
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000023// TODO: add functions for 'vector bool ..' and 'vector pixel' argument types according to
24// the 'AltiVec Technology Programming Interface Manual'
25
Chris Lattnerdd173942010-04-14 03:54:58 +000026#ifndef __ALTIVEC_H
27#define __ALTIVEC_H
28
29#ifndef __ALTIVEC__
30#error "AltiVec support not enabled"
31#endif
32
33/* constants for mapping CR6 bits to predicate result. */
34
35#define __CR6_EQ 0
36#define __CR6_EQ_REV 1
37#define __CR6_LT 2
38#define __CR6_LT_REV 3
39
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000040#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
41
42static vector signed char __ATTRS_o_ai
43vec_perm(vector signed char a, vector signed char b, vector unsigned char c);
44
45static vector unsigned char __ATTRS_o_ai
46vec_perm(vector unsigned char a, vector unsigned char b, vector unsigned char c);
47
48static vector short __ATTRS_o_ai
49vec_perm(vector short a, vector short b, vector unsigned char c);
50
51static vector unsigned short __ATTRS_o_ai
52vec_perm(vector unsigned short a, vector unsigned short b, vector unsigned char c);
53
54static vector int __ATTRS_o_ai
55vec_perm(vector int a, vector int b, vector unsigned char c);
56
57static vector unsigned int __ATTRS_o_ai
58vec_perm(vector unsigned int a, vector unsigned int b, vector unsigned char c);
59
60static vector float __ATTRS_o_ai
61vec_perm(vector float a, vector float b, vector unsigned char c);
Chris Lattnerdd173942010-04-14 03:54:58 +000062
63/* vec_abs */
64
Chris Lattnerdd173942010-04-14 03:54:58 +000065#define __builtin_altivec_abs_v16qi vec_abs
66#define __builtin_altivec_abs_v8hi vec_abs
67#define __builtin_altivec_abs_v4si vec_abs
68
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000069static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000070vec_abs(vector signed char a)
71{
72 return __builtin_altivec_vmaxsb(a, -a);
73}
74
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000075static vector signed short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000076vec_abs(vector signed short a)
77{
78 return __builtin_altivec_vmaxsh(a, -a);
79}
80
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000081static vector signed int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000082vec_abs(vector signed int a)
83{
84 return __builtin_altivec_vmaxsw(a, -a);
85}
86
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000087static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000088vec_abs(vector float a)
89{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000090 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)(0x7FFFFFFF);
Chris Lattnerab866b42010-04-14 20:35:39 +000091 return (vector float)res;
Chris Lattnerdd173942010-04-14 03:54:58 +000092}
93
94/* vec_abss */
95
Chris Lattnerdd173942010-04-14 03:54:58 +000096#define __builtin_altivec_abss_v16qi vec_abss
97#define __builtin_altivec_abss_v8hi vec_abss
98#define __builtin_altivec_abss_v4si vec_abss
99
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000100static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000101vec_abss(vector signed char a)
102{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000103 return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs((vector signed char)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000104}
105
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000106static vector signed short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000107vec_abss(vector signed short a)
108{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000109 return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs((vector signed short)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000110}
111
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000112static vector signed int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000113vec_abss(vector signed int a)
114{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000115 return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws((vector signed int)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000116}
117
118/* vec_add */
119
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000120static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000121vec_add(vector signed char a, vector signed char b)
122{
123 return a + b;
124}
125
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000126static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000127vec_add(vector unsigned char a, vector unsigned char b)
128{
129 return a + b;
130}
131
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000132static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000133vec_add(vector short a, vector short b)
134{
135 return a + b;
136}
137
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000138static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000139vec_add(vector unsigned short a, vector unsigned short b)
140{
141 return a + b;
142}
143
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000144static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000145vec_add(vector int a, vector int b)
146{
147 return a + b;
148}
149
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000150static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000151vec_add(vector unsigned int a, vector unsigned int b)
152{
153 return a + b;
154}
155
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000156static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000157vec_add(vector float a, vector float b)
158{
159 return a + b;
160}
161
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000162/* vec_vaddubm */
163
164#define __builtin_altivec_vaddubm vec_vaddubm
165
166static vector signed char __ATTRS_o_ai
167vec_vaddubm(vector signed char a, vector signed char b)
168{
169 return a + b;
170}
171
172static vector unsigned char __ATTRS_o_ai
173vec_vaddubm(vector unsigned char a, vector unsigned char b)
174{
175 return a + b;
176}
177
178/* vec_vadduhm */
179
180#define __builtin_altivec_vadduhm vec_vadduhm
181
182static vector short __ATTRS_o_ai
183vec_vadduhm(vector short a, vector short b)
184{
185 return a + b;
186}
187
188static vector unsigned short __ATTRS_o_ai
189vec_vadduhm(vector unsigned short a, vector unsigned short b)
190{
191 return a + b;
192}
193
194/* vec_vadduwm */
195
196#define __builtin_altivec_vadduwm vec_vadduwm
197
198static vector int __ATTRS_o_ai
199vec_vadduwm(vector int a, vector int b)
200{
201 return a + b;
202}
203
204static vector unsigned int __ATTRS_o_ai
205vec_vadduwm(vector unsigned int a, vector unsigned int b)
206{
207 return a + b;
208}
209
210/* vec_vaddfp */
211
212#define __builtin_altivec_vaddfp vec_vaddfp
213
214static vector float __attribute__((__always_inline__))
215vec_vaddfp(vector float a, vector float b)
216{
217 return a + b;
218}
219
Chris Lattnerdd173942010-04-14 03:54:58 +0000220/* vec_addc */
221
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000222static vector unsigned int __attribute__((__always_inline__))
223vec_addc(vector unsigned int a, vector unsigned int b)
224{
225 return __builtin_altivec_vaddcuw(a, b);
226}
227
228/* vec_vaddcuw */
229
230static vector unsigned int __attribute__((__always_inline__))
231vec_vaddcuw(vector unsigned int a, vector unsigned int b)
232{
233 return __builtin_altivec_vaddcuw(a, b);
234}
Chris Lattnerdd173942010-04-14 03:54:58 +0000235
236/* vec_adds */
237
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000238static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000239vec_adds(vector signed char a, vector signed char b)
240{
241 return __builtin_altivec_vaddsbs(a, b);
242}
243
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000244static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000245vec_adds(vector unsigned char a, vector unsigned char b)
246{
247 return __builtin_altivec_vaddubs(a, b);
248}
249
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000250static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000251vec_adds(vector short a, vector short b)
252{
253 return __builtin_altivec_vaddshs(a, b);
254}
255
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000256static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000257vec_adds(vector unsigned short a, vector unsigned short b)
258{
259 return __builtin_altivec_vadduhs(a, b);
260}
261
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000262static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000263vec_adds(vector int a, vector int b)
264{
265 return __builtin_altivec_vaddsws(a, b);
266}
267
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000268static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000269vec_adds(vector unsigned int a, vector unsigned int b)
270{
271 return __builtin_altivec_vadduws(a, b);
272}
273
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000274/* vec_vaddsbs */
Chris Lattnerdd173942010-04-14 03:54:58 +0000275
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000276static vector signed char __attribute__((__always_inline__))
277vec_vaddsbs(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000278{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000279 return __builtin_altivec_vaddsbs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000280}
281
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000282/* vec_vaddubs */
283
284static vector unsigned char __attribute__((__always_inline__))
285vec_vaddubs(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000286{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000287 return __builtin_altivec_vaddubs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000288}
289
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000290/* vec_vaddshs */
291
292static vector short __attribute__((__always_inline__))
293vec_vaddshs(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000294{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000295 return __builtin_altivec_vaddshs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000296}
297
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000298/* vec_vadduhs */
299
300static vector unsigned short __attribute__((__always_inline__))
301vec_vadduhs(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000302{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000303 return __builtin_altivec_vadduhs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000304}
305
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000306/* vec_vaddsws */
307
308static vector int __attribute__((__always_inline__))
309vec_vaddsws(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000310{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000311 return __builtin_altivec_vaddsws(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000312}
313
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000314/* vec_vadduws */
315
316static vector unsigned int __attribute__((__always_inline__))
317vec_vadduws(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000318{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000319 return __builtin_altivec_vadduws(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000320}
321
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000322/* vec_and */
323
324#define __builtin_altivec_vand vec_and
325
326static vector signed char __ATTRS_o_ai
327vec_and(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000328{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000329 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000330}
331
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000332static vector unsigned char __ATTRS_o_ai
333vec_and(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000334{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000335 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000336}
337
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000338static vector short __ATTRS_o_ai
339vec_and(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000340{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000341 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000342}
343
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000344static vector unsigned short __ATTRS_o_ai
345vec_and(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000346{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000347 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000348}
349
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000350static vector int __ATTRS_o_ai
351vec_and(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000352{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000353 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000354}
355
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000356static vector unsigned int __ATTRS_o_ai
357vec_and(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000358{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000359 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000360}
361
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000362static vector float __ATTRS_o_ai
363vec_and(vector float a, vector float b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000364{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000365 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
366 return (vector float)res;
367}
368
369/* vec_vand */
370
371static vector signed char __ATTRS_o_ai
372vec_vand(vector signed char a, vector signed char b)
373{
374 return a & b;
375}
376
377static vector unsigned char __ATTRS_o_ai
378vec_vand(vector unsigned char a, vector unsigned char b)
379{
380 return a & b;
381}
382
383static vector short __ATTRS_o_ai
384vec_vand(vector short a, vector short b)
385{
386 return a & b;
387}
388
389static vector unsigned short __ATTRS_o_ai
390vec_vand(vector unsigned short a, vector unsigned short b)
391{
392 return a & b;
393}
394
395static vector int __ATTRS_o_ai
396vec_vand(vector int a, vector int b)
397{
398 return a & b;
399}
400
401static vector unsigned int __ATTRS_o_ai
402vec_vand(vector unsigned int a, vector unsigned int b)
403{
404 return a & b;
405}
406
407static vector float __ATTRS_o_ai
408vec_vand(vector float a, vector float b)
409{
410 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
411 return (vector float)res;
412}
413
414/* vec_andc */
415
416#define __builtin_altivec_vandc vec_andc
417
418static vector signed char __ATTRS_o_ai
419vec_andc(vector signed char a, vector signed char b)
420{
421 return a & ~b;
422}
423
424static vector unsigned char __ATTRS_o_ai
425vec_andc(vector unsigned char a, vector unsigned char b)
426{
427 return a & ~b;
428}
429
430static vector short __ATTRS_o_ai
431vec_andc(vector short a, vector short b)
432{
433 return a & ~b;
434}
435
436static vector unsigned short __ATTRS_o_ai
437vec_andc(vector unsigned short a, vector unsigned short b)
438{
439 return a & ~b;
440}
441
442static vector int __ATTRS_o_ai
443vec_andc(vector int a, vector int b)
444{
445 return a & ~b;
446}
447
448static vector unsigned int __ATTRS_o_ai
449vec_andc(vector unsigned int a, vector unsigned int b)
450{
451 return a & ~b;
452}
453
454static vector float __ATTRS_o_ai
455vec_andc(vector float a, vector float b)
456{
457 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
458 return (vector float)res;
459}
460
461/* vec_vandc */
462
463static vector signed char __ATTRS_o_ai
464vec_vandc(vector signed char a, vector signed char b)
465{
466 return a & ~b;
467}
468
469static vector unsigned char __ATTRS_o_ai
470vec_vandc(vector unsigned char a, vector unsigned char b)
471{
472 return a & ~b;
473}
474
475static vector short __ATTRS_o_ai
476vec_vandc(vector short a, vector short b)
477{
478 return a & ~b;
479}
480
481static vector unsigned short __ATTRS_o_ai
482vec_vandc(vector unsigned short a, vector unsigned short b)
483{
484 return a & ~b;
485}
486
487static vector int __ATTRS_o_ai
488vec_vandc(vector int a, vector int b)
489{
490 return a & ~b;
491}
492
493static vector unsigned int __ATTRS_o_ai
494vec_vandc(vector unsigned int a, vector unsigned int b)
495{
496 return a & ~b;
497}
498
499static vector float __ATTRS_o_ai
500vec_vandc(vector float a, vector float b)
501{
502 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
503 return (vector float)res;
Chris Lattnerdd173942010-04-14 03:54:58 +0000504}
505
506/* vec_avg */
507
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000508static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000509vec_avg(vector signed char a, vector signed char b)
510{
511 return __builtin_altivec_vavgsb(a, b);
512}
513
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000514static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000515vec_avg(vector unsigned char a, vector unsigned char b)
516{
517 return __builtin_altivec_vavgub(a, b);
518}
519
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000520static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000521vec_avg(vector short a, vector short b)
522{
523 return __builtin_altivec_vavgsh(a, b);
524}
525
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000526static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000527vec_avg(vector unsigned short a, vector unsigned short b)
528{
529 return __builtin_altivec_vavguh(a, b);
530}
531
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000532static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000533vec_avg(vector int a, vector int b)
534{
535 return __builtin_altivec_vavgsw(a, b);
536}
537
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000538static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000539vec_avg(vector unsigned int a, vector unsigned int b)
540{
541 return __builtin_altivec_vavguw(a, b);
542}
543
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000544/* vec_vavgsb */
Chris Lattnerdd173942010-04-14 03:54:58 +0000545
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000546static vector signed char __attribute__((__always_inline__))
547vec_vavgsb(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000548{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000549 return __builtin_altivec_vavgsb(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000550}
551
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000552/* vec_vavgub */
553
554static vector unsigned char __attribute__((__always_inline__))
555vec_vavgub(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000556{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000557 return __builtin_altivec_vavgub(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000558}
559
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000560/* vec_vavgsh */
561
562static vector short __attribute__((__always_inline__))
563vec_vavgsh(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000564{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000565 return __builtin_altivec_vavgsh(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000566}
567
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000568/* vec_vavguh */
569
570static vector unsigned short __attribute__((__always_inline__))
571vec_vavguh(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000572{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000573 return __builtin_altivec_vavguh(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000574}
575
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000576/* vec_vavgsw */
577
578static vector int __attribute__((__always_inline__))
579vec_vavgsw(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000580{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000581 return __builtin_altivec_vavgsw(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000582}
583
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000584/* vec_vavguw */
585
586static vector unsigned int __attribute__((__always_inline__))
587vec_vavguw(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000588{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000589 return __builtin_altivec_vavguw(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000590}
591
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000592/* vec_ceil */
593
594static vector float __attribute__((__always_inline__))
595vec_ceil(vector float a)
Chris Lattnerdd173942010-04-14 03:54:58 +0000596{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000597 return __builtin_altivec_vrfip(a);
Chris Lattnerdd173942010-04-14 03:54:58 +0000598}
599
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000600/* vec_vrfip */
Chris Lattnerdd173942010-04-14 03:54:58 +0000601
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000602static vector float __attribute__((__always_inline__))
603vec_vrfip(vector float a)
Chris Lattnerdd173942010-04-14 03:54:58 +0000604{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000605 return __builtin_altivec_vrfip(a);
Chris Lattnerdd173942010-04-14 03:54:58 +0000606}
607
608/* vec_cmpb */
609
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000610static vector int __attribute__((__always_inline__))
611vec_cmpb(vector float a, vector float b)
612{
613 return __builtin_altivec_vcmpbfp(a, b);
614}
615
616/* vec_vcmpbfp */
617
618static vector int __attribute__((__always_inline__))
619vec_vcmpbfp(vector float a, vector float b)
620{
621 return __builtin_altivec_vcmpbfp(a, b);
622}
Chris Lattnerdd173942010-04-14 03:54:58 +0000623
624/* vec_cmpeq */
625
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000626static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000627vec_cmpeq(vector signed char a, vector signed char b)
628{
Chris Lattnerab866b42010-04-14 20:35:39 +0000629 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000630}
631
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000632static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000633vec_cmpeq(vector unsigned char a, vector unsigned char b)
634{
Chris Lattnerab866b42010-04-14 20:35:39 +0000635 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000636}
637
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000638static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000639vec_cmpeq(vector short a, vector short b)
640{
641 return __builtin_altivec_vcmpequh(a, b);
642}
643
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000644static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000645vec_cmpeq(vector unsigned short a, vector unsigned short b)
646{
Chris Lattnerab866b42010-04-14 20:35:39 +0000647 return __builtin_altivec_vcmpequh((vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000648}
649
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000650static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000651vec_cmpeq(vector int a, vector int b)
652{
653 return __builtin_altivec_vcmpequw(a, b);
654}
655
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000656static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000657vec_cmpeq(vector unsigned int a, vector unsigned int b)
658{
Chris Lattnerab866b42010-04-14 20:35:39 +0000659 return __builtin_altivec_vcmpequw((vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000660}
661
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000662static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000663vec_cmpeq(vector float a, vector float b)
664{
665 return __builtin_altivec_vcmpeqfp(a, b);
666}
667
668/* vec_cmpge */
669
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000670static vector /*bool*/ int __attribute__((__always_inline__))
671vec_cmpge(vector float a, vector float b)
672{
673 return __builtin_altivec_vcmpgefp(a, b);
674}
675
676/* vec_vcmpgefp */
677
678static vector /*bool*/ int __attribute__((__always_inline__))
679vec_vcmpgefp(vector float a, vector float b)
680{
681 return __builtin_altivec_vcmpgefp(a, b);
682}
Chris Lattnerdd173942010-04-14 03:54:58 +0000683
684/* vec_cmpgt */
685
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000686static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000687vec_cmpgt(vector signed char a, vector signed char b)
688{
689 return __builtin_altivec_vcmpgtsb(a, b);
690}
691
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000692static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000693vec_cmpgt(vector unsigned char a, vector unsigned char b)
694{
695 return __builtin_altivec_vcmpgtub(a, b);
696}
697
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000698static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000699vec_cmpgt(vector short a, vector short b)
700{
701 return __builtin_altivec_vcmpgtsh(a, b);
702}
703
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000704static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000705vec_cmpgt(vector unsigned short a, vector unsigned short b)
706{
707 return __builtin_altivec_vcmpgtuh(a, b);
708}
709
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000710static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000711vec_cmpgt(vector int a, vector int b)
712{
713 return __builtin_altivec_vcmpgtsw(a, b);
714}
715
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000716static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000717vec_cmpgt(vector unsigned int a, vector unsigned int b)
718{
719 return __builtin_altivec_vcmpgtuw(a, b);
720}
721
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000722static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000723vec_cmpgt(vector float a, vector float b)
724{
725 return __builtin_altivec_vcmpgtfp(a, b);
726}
727
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000728/* vec_vcmpgtsb */
Chris Lattnerdd173942010-04-14 03:54:58 +0000729
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000730static vector /*bool*/ char __attribute__((__always_inline__))
731vec_vcmpgtsb(vector signed char a, vector signed char b)
732{
733 return __builtin_altivec_vcmpgtsb(a, b);
734}
735
736/* vec_vcmpgtub */
737
738static vector /*bool*/ char __attribute__((__always_inline__))
739vec_vcmpgtub(vector unsigned char a, vector unsigned char b)
740{
741 return __builtin_altivec_vcmpgtub(a, b);
742}
743
744/* vec_vcmpgtsh */
745
746static vector /*bool*/ short __attribute__((__always_inline__))
747vec_vcmpgtsh(vector short a, vector short b)
748{
749 return __builtin_altivec_vcmpgtsh(a, b);
750}
751
752/* vec_vcmpgtuh */
753
754static vector /*bool*/ short __attribute__((__always_inline__))
755vec_vcmpgtuh(vector unsigned short a, vector unsigned short b)
756{
757 return __builtin_altivec_vcmpgtuh(a, b);
758}
759
760/* vec_vcmpgtsw */
761
762static vector /*bool*/ int __attribute__((__always_inline__))
763vec_vcmpgtsw(vector int a, vector int b)
764{
765 return __builtin_altivec_vcmpgtsw(a, b);
766}
767
768/* vec_vcmpgtuw */
769
770static vector /*bool*/ int __attribute__((__always_inline__))
771vec_vcmpgtuw(vector unsigned int a, vector unsigned int b)
772{
773 return __builtin_altivec_vcmpgtuw(a, b);
774}
775
776/* vec_vcmpgtfp */
777
778static vector /*bool*/ int __attribute__((__always_inline__))
779vec_vcmpgtfp(vector float a, vector float b)
780{
781 return __builtin_altivec_vcmpgtfp(a, b);
782}
783
784/* vec_cmple */
Chris Lattnerdd173942010-04-14 03:54:58 +0000785
Chris Lattnerab866b42010-04-14 20:35:39 +0000786static vector /*bool*/ int __attribute__((__always_inline__))
Chris Lattnerdd173942010-04-14 03:54:58 +0000787vec_cmple(vector float a, vector float b)
788{
789 return __builtin_altivec_vcmpgefp(b, a);
790}
791
792/* vec_cmplt */
793
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000794static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000795vec_cmplt(vector signed char a, vector signed char b)
796{
797 return __builtin_altivec_vcmpgtsb(b, a);
798}
799
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000800static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000801vec_cmplt(vector unsigned char a, vector unsigned char b)
802{
803 return __builtin_altivec_vcmpgtub(b, a);
804}
805
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000806static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000807vec_cmplt(vector short a, vector short b)
808{
809 return __builtin_altivec_vcmpgtsh(b, a);
810}
811
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000812static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000813vec_cmplt(vector unsigned short a, vector unsigned short b)
814{
815 return __builtin_altivec_vcmpgtuh(b, a);
816}
817
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000818static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000819vec_cmplt(vector int a, vector int b)
820{
821 return __builtin_altivec_vcmpgtsw(b, a);
822}
823
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000824static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000825vec_cmplt(vector unsigned int a, vector unsigned int b)
826{
827 return __builtin_altivec_vcmpgtuw(b, a);
828}
829
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000830static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000831vec_cmplt(vector float a, vector float b)
832{
833 return __builtin_altivec_vcmpgtfp(b, a);
834}
835
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000836/* vec_ctf */
837
838static vector float __ATTRS_o_ai
839vec_ctf(vector int a, int b)
840{
841 return __builtin_altivec_vcfsx(a, b);
842}
843
844static vector float __ATTRS_o_ai
845vec_ctf(vector unsigned int a, int b)
846{
847 return __builtin_altivec_vcfux((vector int)a, b);
848}
849
850/* vec_vcfsx */
851
852static vector float __attribute__((__always_inline__))
853vec_vcfsx(vector int a, int b)
854{
855 return __builtin_altivec_vcfsx(a, b);
856}
857
858/* vec_vcfux */
859
860static vector float __attribute__((__always_inline__))
861vec_vcfux(vector unsigned int a, int b)
862{
863 return __builtin_altivec_vcfux((vector int)a, b);
864}
865
866/* vec_cts */
867
868static vector int __attribute__((__always_inline__))
869vec_cts(vector float a, int b)
870{
871 return __builtin_altivec_vctsxs(a, b);
872}
873
874/* vec_vctsxs */
875
876static vector int __attribute__((__always_inline__))
877vec_vctsxs(vector float a, int b)
878{
879 return __builtin_altivec_vctsxs(a, b);
880}
881
882/* vec_ctu */
883
884static vector unsigned int __attribute__((__always_inline__))
885vec_ctu(vector float a, int b)
886{
887 return __builtin_altivec_vctuxs(a, b);
888}
889
890/* vec_vctuxs */
891
892static vector unsigned int __attribute__((__always_inline__))
893vec_vctuxs(vector float a, int b)
894{
895 return __builtin_altivec_vctuxs(a, b);
896}
897
898/* vec_dss */
899
900static void __attribute__((__always_inline__))
901vec_dss(int a)
902{
903 __builtin_altivec_dss(a);
904}
905
906/* vec_dssall */
907
908static void __attribute__((__always_inline__))
909vec_dssall(void)
910{
911 __builtin_altivec_dssall();
912}
913
914/* vec_dst */
915
916static void __attribute__((__always_inline__))
917vec_dst(void *a, int b, int c)
918{
919 __builtin_altivec_dst(a, b, c);
920}
921
922/* vec_dstst */
923
924static void __attribute__((__always_inline__))
925vec_dstst(void *a, int b, int c)
926{
927 __builtin_altivec_dstst(a, b, c);
928}
929
930/* vec_dststt */
931
932static void __attribute__((__always_inline__))
933vec_dststt(void *a, int b, int c)
934{
935 __builtin_altivec_dststt(a, b, c);
936}
937
938/* vec_dstt */
939
940static void __attribute__((__always_inline__))
941vec_dstt(void *a, int b, int c)
942{
943 __builtin_altivec_dstt(a, b, c);
944}
945
946/* vec_expte */
947
948static vector float __attribute__((__always_inline__))
949vec_expte(vector float a)
950{
951 return __builtin_altivec_vexptefp(a);
952}
953
954/* vec_vexptefp */
955
956static vector float __attribute__((__always_inline__))
957vec_vexptefp(vector float a)
958{
959 return __builtin_altivec_vexptefp(a);
960}
961
962/* vec_floor */
963
964static vector float __attribute__((__always_inline__))
965vec_floor(vector float a)
966{
967 return __builtin_altivec_vrfim(a);
968}
969
970/* vec_vrfim */
971
972static vector float __attribute__((__always_inline__))
973vec_vrfim(vector float a)
974{
975 return __builtin_altivec_vrfim(a);
976}
977
978/* vec_ld */
979
980static vector signed char __ATTRS_o_ai
981vec_ld(int a, vector signed char *b)
982{
983 return (vector signed char)__builtin_altivec_lvx(a, b);
984}
985
986static vector signed char __ATTRS_o_ai
987vec_ld(int a, signed char *b)
988{
989 return (vector signed char)__builtin_altivec_lvx(a, b);
990}
991
992static vector unsigned char __ATTRS_o_ai
993vec_ld(int a, vector unsigned char *b)
994{
995 return (vector unsigned char)__builtin_altivec_lvx(a, b);
996}
997
998static vector unsigned char __ATTRS_o_ai
999vec_ld(int a, unsigned char *b)
1000{
1001 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1002}
1003
1004static vector short __ATTRS_o_ai
1005vec_ld(int a, vector short *b)
1006{
1007 return (vector short)__builtin_altivec_lvx(a, b);
1008}
1009
1010static vector short __ATTRS_o_ai
1011vec_ld(int a, short *b)
1012{
1013 return (vector short)__builtin_altivec_lvx(a, b);
1014}
1015
1016static vector unsigned short __ATTRS_o_ai
1017vec_ld(int a, vector unsigned short *b)
1018{
1019 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1020}
1021
1022static vector unsigned short __ATTRS_o_ai
1023vec_ld(int a, unsigned short *b)
1024{
1025 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1026}
1027
1028static vector int __ATTRS_o_ai
1029vec_ld(int a, vector int *b)
1030{
1031 return (vector int)__builtin_altivec_lvx(a, b);
1032}
1033
1034static vector int __ATTRS_o_ai
1035vec_ld(int a, int *b)
1036{
1037 return (vector int)__builtin_altivec_lvx(a, b);
1038}
1039
1040static vector unsigned int __ATTRS_o_ai
1041vec_ld(int a, vector unsigned int *b)
1042{
1043 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1044}
1045
1046static vector unsigned int __ATTRS_o_ai
1047vec_ld(int a, unsigned int *b)
1048{
1049 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1050}
1051
1052static vector float __ATTRS_o_ai
1053vec_ld(int a, vector float *b)
1054{
1055 return (vector float)__builtin_altivec_lvx(a, b);
1056}
1057
1058static vector float __ATTRS_o_ai
1059vec_ld(int a, float *b)
1060{
1061 return (vector float)__builtin_altivec_lvx(a, b);
1062}
1063
1064/* vec_lvx */
1065
1066static vector signed char __ATTRS_o_ai
1067vec_lvx(int a, vector signed char *b)
1068{
1069 return (vector signed char)__builtin_altivec_lvx(a, b);
1070}
1071
1072static vector signed char __ATTRS_o_ai
1073vec_lvx(int a, signed char *b)
1074{
1075 return (vector signed char)__builtin_altivec_lvx(a, b);
1076}
1077
1078static vector unsigned char __ATTRS_o_ai
1079vec_lvx(int a, vector unsigned char *b)
1080{
1081 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1082}
1083
1084static vector unsigned char __ATTRS_o_ai
1085vec_lvx(int a, unsigned char *b)
1086{
1087 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1088}
1089
1090static vector short __ATTRS_o_ai
1091vec_lvx(int a, vector short *b)
1092{
1093 return (vector short)__builtin_altivec_lvx(a, b);
1094}
1095
1096static vector short __ATTRS_o_ai
1097vec_lvx(int a, short *b)
1098{
1099 return (vector short)__builtin_altivec_lvx(a, b);
1100}
1101
1102static vector unsigned short __ATTRS_o_ai
1103vec_lvx(int a, vector unsigned short *b)
1104{
1105 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1106}
1107
1108static vector unsigned short __ATTRS_o_ai
1109vec_lvx(int a, unsigned short *b)
1110{
1111 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1112}
1113
1114static vector int __ATTRS_o_ai
1115vec_lvx(int a, vector int *b)
1116{
1117 return (vector int)__builtin_altivec_lvx(a, b);
1118}
1119
1120static vector int __ATTRS_o_ai
1121vec_lvx(int a, int *b)
1122{
1123 return (vector int)__builtin_altivec_lvx(a, b);
1124}
1125
1126static vector unsigned int __ATTRS_o_ai
1127vec_lvx(int a, vector unsigned int *b)
1128{
1129 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1130}
1131
1132static vector unsigned int __ATTRS_o_ai
1133vec_lvx(int a, unsigned int *b)
1134{
1135 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1136}
1137
1138static vector float __ATTRS_o_ai
1139vec_lvx(int a, vector float *b)
1140{
1141 return (vector float)__builtin_altivec_lvx(a, b);
1142}
1143
1144static vector float __ATTRS_o_ai
1145vec_lvx(int a, float *b)
1146{
1147 return (vector float)__builtin_altivec_lvx(a, b);
1148}
1149
1150/* vec_lde */
1151
1152static vector signed char __ATTRS_o_ai
1153vec_lde(int a, vector signed char *b)
1154{
1155 return (vector signed char)__builtin_altivec_lvebx(a, b);
1156}
1157
1158static vector unsigned char __ATTRS_o_ai
1159vec_lde(int a, vector unsigned char *b)
1160{
1161 return (vector unsigned char)__builtin_altivec_lvebx(a, b);
1162}
1163
1164static vector short __ATTRS_o_ai
1165vec_lde(int a, vector short *b)
1166{
1167 return (vector short)__builtin_altivec_lvehx(a, b);
1168}
1169
1170static vector unsigned short __ATTRS_o_ai
1171vec_lde(int a, vector unsigned short *b)
1172{
1173 return (vector unsigned short)__builtin_altivec_lvehx(a, b);
1174}
1175
1176static vector int __ATTRS_o_ai
1177vec_lde(int a, vector int *b)
1178{
1179 return (vector int)__builtin_altivec_lvewx(a, b);
1180}
1181
1182static vector unsigned int __ATTRS_o_ai
1183vec_lde(int a, vector unsigned int *b)
1184{
1185 return (vector unsigned int)__builtin_altivec_lvewx(a, b);
1186}
1187
1188static vector float __ATTRS_o_ai
1189vec_lde(int a, vector float *b)
1190{
1191 return (vector float)__builtin_altivec_lvewx(a, b);
1192}
1193
1194/* vec_lvebx */
1195
1196static vector signed char __ATTRS_o_ai
1197vec_lvebx(int a, vector signed char *b)
1198{
1199 return (vector signed char)__builtin_altivec_lvebx(a, b);
1200}
1201
1202static vector unsigned char __ATTRS_o_ai
1203vec_lvebx(int a, vector unsigned char *b)
1204{
1205 return (vector unsigned char)__builtin_altivec_lvebx(a, b);
1206}
1207
1208/* vec_lvehx */
1209
1210static vector short __ATTRS_o_ai
1211vec_lvehx(int a, vector short *b)
1212{
1213 return (vector short)__builtin_altivec_lvehx(a, b);
1214}
1215
1216static vector unsigned short __ATTRS_o_ai
1217vec_lvehx(int a, vector unsigned short *b)
1218{
1219 return (vector unsigned short)__builtin_altivec_lvehx(a, b);
1220}
1221
1222/* vec_lvewx */
1223
1224static vector int __ATTRS_o_ai
1225vec_lvewx(int a, vector int *b)
1226{
1227 return (vector int)__builtin_altivec_lvewx(a, b);
1228}
1229
1230static vector unsigned int __ATTRS_o_ai
1231vec_lvewx(int a, vector unsigned int *b)
1232{
1233 return (vector unsigned int)__builtin_altivec_lvewx(a, b);
1234}
1235
1236static vector float __ATTRS_o_ai
1237vec_lvewx(int a, vector float *b)
1238{
1239 return (vector float)__builtin_altivec_lvewx(a, b);
1240}
1241
1242/* vec_ldl */
1243
1244static vector signed char __ATTRS_o_ai
1245vec_ldl(int a, vector signed char *b)
1246{
1247 return (vector signed char)__builtin_altivec_lvxl(a, b);
1248}
1249
1250static vector signed char __ATTRS_o_ai
1251vec_ldl(int a, signed char *b)
1252{
1253 return (vector signed char)__builtin_altivec_lvxl(a, b);
1254}
1255
1256static vector unsigned char __ATTRS_o_ai
1257vec_ldl(int a, vector unsigned char *b)
1258{
1259 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1260}
1261
1262static vector unsigned char __ATTRS_o_ai
1263vec_ldl(int a, unsigned char *b)
1264{
1265 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1266}
1267
1268static vector short __ATTRS_o_ai
1269vec_ldl(int a, vector short *b)
1270{
1271 return (vector short)__builtin_altivec_lvxl(a, b);
1272}
1273
1274static vector short __ATTRS_o_ai
1275vec_ldl(int a, short *b)
1276{
1277 return (vector short)__builtin_altivec_lvxl(a, b);
1278}
1279
1280static vector unsigned short __ATTRS_o_ai
1281vec_ldl(int a, vector unsigned short *b)
1282{
1283 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
1284}
1285
1286static vector unsigned short __ATTRS_o_ai
1287vec_ldl(int a, unsigned short *b)
1288{
1289 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
1290}
1291
1292static vector int __ATTRS_o_ai
1293vec_ldl(int a, vector int *b)
1294{
1295 return (vector int)__builtin_altivec_lvxl(a, b);
1296}
1297
1298static vector int __ATTRS_o_ai
1299vec_ldl(int a, int *b)
1300{
1301 return (vector int)__builtin_altivec_lvxl(a, b);
1302}
1303
1304static vector unsigned int __ATTRS_o_ai
1305vec_ldl(int a, vector unsigned int *b)
1306{
1307 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
1308}
1309
1310static vector unsigned int __ATTRS_o_ai
1311vec_ldl(int a, unsigned int *b)
1312{
1313 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
1314}
1315
1316static vector float __ATTRS_o_ai
1317vec_ldl(int a, vector float *b)
1318{
1319 return (vector float)__builtin_altivec_lvxl(a, b);
1320}
1321
1322static vector float __ATTRS_o_ai
1323vec_ldl(int a, float *b)
1324{
1325 return (vector float)__builtin_altivec_lvxl(a, b);
1326}
1327
1328/* vec_lvxl */
1329
1330static vector signed char __ATTRS_o_ai
1331vec_lvxl(int a, vector signed char *b)
1332{
1333 return (vector signed char)__builtin_altivec_lvxl(a, b);
1334}
1335
1336static vector signed char __ATTRS_o_ai
1337vec_lvxl(int a, signed char *b)
1338{
1339 return (vector signed char)__builtin_altivec_lvxl(a, b);
1340}
1341
1342static vector unsigned char __ATTRS_o_ai
1343vec_lvxl(int a, vector unsigned char *b)
1344{
1345 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1346}
1347
1348static vector unsigned char __ATTRS_o_ai
1349vec_lvxl(int a, unsigned char *b)
1350{
1351 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1352}
1353
1354static vector short __ATTRS_o_ai
1355vec_lvxl(int a, vector short *b)
1356{
1357 return (vector short)__builtin_altivec_lvxl(a, b);
1358}
1359
1360static vector short __ATTRS_o_ai
1361vec_lvxl(int a, short *b)
1362{
1363 return (vector short)__builtin_altivec_lvxl(a, b);
1364}
1365
1366static vector unsigned short __ATTRS_o_ai
1367vec_lvxl(int a, vector unsigned short *b)
1368{
1369 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
1370}
1371
1372static vector unsigned short __ATTRS_o_ai
1373vec_lvxl(int a, unsigned short *b)
1374{
1375 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
1376}
1377
1378static vector int __ATTRS_o_ai
1379vec_lvxl(int a, vector int *b)
1380{
1381 return (vector int)__builtin_altivec_lvxl(a, b);
1382}
1383
1384static vector int __ATTRS_o_ai
1385vec_lvxl(int a, int *b)
1386{
1387 return (vector int)__builtin_altivec_lvxl(a, b);
1388}
1389
1390static vector unsigned int __ATTRS_o_ai
1391vec_lvxl(int a, vector unsigned int *b)
1392{
1393 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
1394}
1395
1396static vector unsigned int __ATTRS_o_ai
1397vec_lvxl(int a, unsigned int *b)
1398{
1399 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
1400}
1401
1402static vector float __ATTRS_o_ai
1403vec_lvxl(int a, vector float *b)
1404{
1405 return (vector float)__builtin_altivec_lvxl(a, b);
1406}
1407
1408static vector float __ATTRS_o_ai
1409vec_lvxl(int a, float *b)
1410{
1411 return (vector float)__builtin_altivec_lvxl(a, b);
1412}
1413
1414/* vec_loge */
1415
1416static vector float __attribute__((__always_inline__))
1417vec_loge(vector float a)
1418{
1419 return __builtin_altivec_vlogefp(a);
1420}
1421
1422/* vec_vlogefp */
1423
1424static vector float __attribute__((__always_inline__))
1425vec_vlogefp(vector float a)
1426{
1427 return __builtin_altivec_vlogefp(a);
1428}
1429
1430/* vec_lvsl */
1431
1432static vector unsigned char __ATTRS_o_ai
1433vec_lvsl(int a, signed char *b)
1434{
1435 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1436}
1437
1438static vector unsigned char __ATTRS_o_ai
1439vec_lvsl(int a, unsigned char *b)
1440{
1441 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1442}
1443
1444static vector unsigned char __ATTRS_o_ai
1445vec_lvsl(int a, short *b)
1446{
1447 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1448}
1449
1450static vector unsigned char __ATTRS_o_ai
1451vec_lvsl(int a, unsigned short *b)
1452{
1453 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1454}
1455
1456static vector unsigned char __ATTRS_o_ai
1457vec_lvsl(int a, int *b)
1458{
1459 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1460}
1461
1462static vector unsigned char __ATTRS_o_ai
1463vec_lvsl(int a, unsigned int *b)
1464{
1465 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1466}
1467
1468static vector unsigned char __ATTRS_o_ai
1469vec_lvsl(int a, float *b)
1470{
1471 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
1472}
1473
1474/* vec_lvsr */
1475
1476static vector unsigned char __ATTRS_o_ai
1477vec_lvsr(int a, signed char *b)
1478{
1479 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1480}
1481
1482static vector unsigned char __ATTRS_o_ai
1483vec_lvsr(int a, unsigned char *b)
1484{
1485 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1486}
1487
1488static vector unsigned char __ATTRS_o_ai
1489vec_lvsr(int a, short *b)
1490{
1491 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1492}
1493
1494static vector unsigned char __ATTRS_o_ai
1495vec_lvsr(int a, unsigned short *b)
1496{
1497 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1498}
1499
1500static vector unsigned char __ATTRS_o_ai
1501vec_lvsr(int a, int *b)
1502{
1503 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1504}
1505
1506static vector unsigned char __ATTRS_o_ai
1507vec_lvsr(int a, unsigned int *b)
1508{
1509 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1510}
1511
1512static vector unsigned char __ATTRS_o_ai
1513vec_lvsr(int a, float *b)
1514{
1515 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
1516}
1517
1518/* vec_madd */
1519
1520static vector float __attribute__((__always_inline__))
1521vec_madd(vector float a, vector float b, vector float c)
1522{
1523 return __builtin_altivec_vmaddfp(a, b, c);
1524}
1525
1526/* vec_vmaddfp */
1527
1528static vector float __attribute__((__always_inline__))
1529vec_vmaddfp(vector float a, vector float b, vector float c)
1530{
1531 return __builtin_altivec_vmaddfp(a, b, c);
1532}
1533
1534/* vec_madds */
1535
1536static vector signed short __attribute__((__always_inline__))
1537vec_madds(vector signed short a, vector signed short b, vector signed short c)
1538{
1539 return __builtin_altivec_vmhaddshs(a, b, c);
1540}
1541
1542/* vec_vmhaddshs */
1543static vector signed short __attribute__((__always_inline__))
1544vec_vmhaddshs(vector signed short a, vector signed short b, vector signed short c)
1545{
1546 return __builtin_altivec_vmhaddshs(a, b, c);
1547}
1548
Chris Lattnerdd173942010-04-14 03:54:58 +00001549/* vec_max */
1550
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001551static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001552vec_max(vector signed char a, vector signed char b)
1553{
1554 return __builtin_altivec_vmaxsb(a, b);
1555}
1556
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001557static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001558vec_max(vector unsigned char a, vector unsigned char b)
1559{
1560 return __builtin_altivec_vmaxub(a, b);
1561}
1562
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001563static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001564vec_max(vector short a, vector short b)
1565{
1566 return __builtin_altivec_vmaxsh(a, b);
1567}
1568
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001569static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001570vec_max(vector unsigned short a, vector unsigned short b)
1571{
1572 return __builtin_altivec_vmaxuh(a, b);
1573}
1574
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001575static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001576vec_max(vector int a, vector int b)
1577{
1578 return __builtin_altivec_vmaxsw(a, b);
1579}
1580
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001581static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001582vec_max(vector unsigned int a, vector unsigned int b)
1583{
1584 return __builtin_altivec_vmaxuw(a, b);
1585}
1586
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001587static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001588vec_max(vector float a, vector float b)
1589{
1590 return __builtin_altivec_vmaxfp(a, b);
1591}
1592
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001593/* vec_vmaxsb */
1594
1595static vector signed char __attribute__((__always_inline__))
1596vec_vmaxsb(vector signed char a, vector signed char b)
1597{
1598 return __builtin_altivec_vmaxsb(a, b);
1599}
1600
1601/* vec_vmaxub */
1602
1603static vector unsigned char __attribute__((__always_inline__))
1604vec_vmaxub(vector unsigned char a, vector unsigned char b)
1605{
1606 return __builtin_altivec_vmaxub(a, b);
1607}
1608
1609/* vec_vmaxsh */
1610
1611static vector short __attribute__((__always_inline__))
1612vec_vmaxsh(vector short a, vector short b)
1613{
1614 return __builtin_altivec_vmaxsh(a, b);
1615}
1616
1617/* vec_vmaxuh */
1618
1619static vector unsigned short __attribute__((__always_inline__))
1620vec_vmaxuh(vector unsigned short a, vector unsigned short b)
1621{
1622 return __builtin_altivec_vmaxuh(a, b);
1623}
1624
1625/* vec_vmaxsw */
1626
1627static vector int __attribute__((__always_inline__))
1628vec_vmaxsw(vector int a, vector int b)
1629{
1630 return __builtin_altivec_vmaxsw(a, b);
1631}
1632
1633/* vec_vmaxuw */
1634
1635static vector unsigned int __attribute__((__always_inline__))
1636vec_vmaxuw(vector unsigned int a, vector unsigned int b)
1637{
1638 return __builtin_altivec_vmaxuw(a, b);
1639}
1640
1641/* vec_vmaxfp */
1642
1643static vector float __attribute__((__always_inline__))
1644vec_vmaxfp(vector float a, vector float b)
1645{
1646 return __builtin_altivec_vmaxfp(a, b);
1647}
1648
1649/* vec_mergeh */
1650
1651static vector signed char __ATTRS_o_ai
1652vec_mergeh(vector signed char a, vector signed char b)
1653{
1654 return vec_perm(a, b, (vector unsigned char)
1655 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
1656 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
1657}
1658
1659static vector unsigned char __ATTRS_o_ai
1660vec_mergeh(vector unsigned char a, vector unsigned char b)
1661{
1662 return vec_perm(a, b, (vector unsigned char)
1663 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
1664 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
1665}
1666
1667static vector short __ATTRS_o_ai
1668vec_mergeh(vector short a, vector short b)
1669{
1670 return vec_perm(a, b, (vector unsigned char)
1671 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
1672 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
1673}
1674
1675static vector unsigned short __ATTRS_o_ai
1676vec_mergeh(vector unsigned short a, vector unsigned short b)
1677{
1678 return vec_perm(a, b, (vector unsigned char)
1679 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
1680 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
1681}
1682
1683static vector int __ATTRS_o_ai
1684vec_mergeh(vector int a, vector int b)
1685{
1686 return vec_perm(a, b, (vector unsigned char)
1687 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1688 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1689}
1690
1691static vector unsigned int __ATTRS_o_ai
1692vec_mergeh(vector unsigned int a, vector unsigned int b)
1693{
1694 return vec_perm(a, b, (vector unsigned char)
1695 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1696 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1697}
1698
1699static vector float __ATTRS_o_ai
1700vec_mergeh(vector float a, vector float b)
1701{
1702 return vec_perm(a, b, (vector unsigned char)
1703 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1704 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1705}
1706
1707/* vec_vmrghb */
1708
1709#define __builtin_altivec_vmrghb vec_vmrghb
1710
1711static vector signed char __ATTRS_o_ai
1712vec_vmrghb(vector signed char a, vector signed char b)
1713{
1714 return vec_perm(a, b, (vector unsigned char)
1715 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
1716 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
1717}
1718
1719static vector unsigned char __ATTRS_o_ai
1720vec_vmrghb(vector unsigned char a, vector unsigned char b)
1721{
1722 return vec_perm(a, b, (vector unsigned char)
1723 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
1724 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
1725}
1726
1727/* vec_vmrghh */
1728
1729#define __builtin_altivec_vmrghh vec_vmrghh
1730
1731static vector short __ATTRS_o_ai
1732vec_vmrghh(vector short a, vector short b)
1733{
1734 return vec_perm(a, b, (vector unsigned char)
1735 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
1736 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
1737}
1738
1739static vector unsigned short __ATTRS_o_ai
1740vec_vmrghh(vector unsigned short a, vector unsigned short b)
1741{
1742 return vec_perm(a, b, (vector unsigned char)
1743 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
1744 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
1745}
1746
1747/* vec_vmrghw */
1748
1749#define __builtin_altivec_vmrghw vec_vmrghw
1750
1751static vector int __ATTRS_o_ai
1752vec_vmrghw(vector int a, vector int b)
1753{
1754 return vec_perm(a, b, (vector unsigned char)
1755 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1756 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1757}
1758
1759static vector unsigned int __ATTRS_o_ai
1760vec_vmrghw(vector unsigned int a, vector unsigned int b)
1761{
1762 return vec_perm(a, b, (vector unsigned char)
1763 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1764 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1765}
1766
1767static vector float __ATTRS_o_ai
1768vec_vmrghw(vector float a, vector float b)
1769{
1770 return vec_perm(a, b, (vector unsigned char)
1771 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
1772 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
1773}
1774
1775/* vec_mergel */
1776
1777static vector signed char __ATTRS_o_ai
1778vec_mergel(vector signed char a, vector signed char b)
1779{
1780 return vec_perm(a, b, (vector unsigned char)
1781 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
1782 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
1783}
1784
1785static vector unsigned char __ATTRS_o_ai
1786vec_mergel(vector unsigned char a, vector unsigned char b)
1787{
1788 return vec_perm(a, b, (vector unsigned char)
1789 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
1790 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
1791}
1792
1793static vector short __ATTRS_o_ai
1794vec_mergel(vector short a, vector short b)
1795{
1796 return vec_perm(a, b, (vector unsigned char)
1797 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
1798 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
1799}
1800
1801static vector unsigned short __ATTRS_o_ai
1802vec_mergel(vector unsigned short a, vector unsigned short b)
1803{
1804 return vec_perm(a, b, (vector unsigned char)
1805 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
1806 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
1807}
1808
1809static vector int __ATTRS_o_ai
1810vec_mergel(vector int a, vector int b)
1811{
1812 return vec_perm(a, b, (vector unsigned char)
1813 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1814 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1815}
1816
1817static vector unsigned int __ATTRS_o_ai
1818vec_mergel(vector unsigned int a, vector unsigned int b)
1819{
1820 return vec_perm(a, b, (vector unsigned char)
1821 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1822 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1823}
1824
1825static vector float __ATTRS_o_ai
1826vec_mergel(vector float a, vector float b)
1827{
1828 return vec_perm(a, b, (vector unsigned char)
1829 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1830 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1831}
1832
1833/* vec_vmrglb */
1834
1835#define __builtin_altivec_vmrglb vec_vmrglb
1836
1837static vector signed char __ATTRS_o_ai
1838vec_vmrglb(vector signed char a, vector signed char b)
1839{
1840 return vec_perm(a, b, (vector unsigned char)
1841 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
1842 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
1843}
1844
1845static vector unsigned char __ATTRS_o_ai
1846vec_vmrglb(vector unsigned char a, vector unsigned char b)
1847{
1848 return vec_perm(a, b, (vector unsigned char)
1849 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
1850 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
1851}
1852
1853/* vec_vmrglh */
1854
1855#define __builtin_altivec_vmrglh vec_vmrglh
1856
1857static vector short __ATTRS_o_ai
1858vec_vmrglh(vector short a, vector short b)
1859{
1860 return vec_perm(a, b, (vector unsigned char)
1861 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
1862 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
1863}
1864
1865static vector unsigned short __ATTRS_o_ai
1866vec_vmrglh(vector unsigned short a, vector unsigned short b)
1867{
1868 return vec_perm(a, b, (vector unsigned char)
1869 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
1870 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
1871}
1872
1873/* vec_vmrglw */
1874
1875#define __builtin_altivec_vmrglw vec_vmrglw
1876
1877static vector int __ATTRS_o_ai
1878vec_vmrglw(vector int a, vector int b)
1879{
1880 return vec_perm(a, b, (vector unsigned char)
1881 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1882 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1883}
1884
1885static vector unsigned int __ATTRS_o_ai
1886vec_vmrglw(vector unsigned int a, vector unsigned int b)
1887{
1888 return vec_perm(a, b, (vector unsigned char)
1889 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1890 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1891}
1892
1893static vector float __ATTRS_o_ai
1894vec_vmrglw(vector float a, vector float b)
1895{
1896 return vec_perm(a, b, (vector unsigned char)
1897 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
1898 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
1899}
1900
Chris Lattnerdd173942010-04-14 03:54:58 +00001901/* vec_mfvscr */
1902
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001903static vector unsigned short __attribute__((__always_inline__))
1904vec_mfvscr(void)
1905{
1906 return __builtin_altivec_mfvscr();
1907}
Chris Lattnerdd173942010-04-14 03:54:58 +00001908
1909/* vec_min */
1910
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001911static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001912vec_min(vector signed char a, vector signed char b)
1913{
1914 return __builtin_altivec_vminsb(a, b);
1915}
1916
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001917static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001918vec_min(vector unsigned char a, vector unsigned char b)
1919{
1920 return __builtin_altivec_vminub(a, b);
1921}
1922
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001923static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001924vec_min(vector short a, vector short b)
1925{
1926 return __builtin_altivec_vminsh(a, b);
1927}
1928
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001929static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001930vec_min(vector unsigned short a, vector unsigned short b)
1931{
1932 return __builtin_altivec_vminuh(a, b);
1933}
1934
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001935static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001936vec_min(vector int a, vector int b)
1937{
1938 return __builtin_altivec_vminsw(a, b);
1939}
1940
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001941static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001942vec_min(vector unsigned int a, vector unsigned int b)
1943{
1944 return __builtin_altivec_vminuw(a, b);
1945}
1946
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001947static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001948vec_min(vector float a, vector float b)
1949{
1950 return __builtin_altivec_vminfp(a, b);
1951}
1952
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001953/* vec_vminsb */
1954
1955static vector signed char __attribute__((__always_inline__))
1956vec_vminsb(vector signed char a, vector signed char b)
1957{
1958 return __builtin_altivec_vminsb(a, b);
1959}
1960
1961/* vec_vminub */
1962
1963static vector unsigned char __attribute__((__always_inline__))
1964vec_vminub(vector unsigned char a, vector unsigned char b)
1965{
1966 return __builtin_altivec_vminub(a, b);
1967}
1968
1969/* vec_vminsh */
1970
1971static vector short __attribute__((__always_inline__))
1972vec_vminsh(vector short a, vector short b)
1973{
1974 return __builtin_altivec_vminsh(a, b);
1975}
1976
1977/* vec_vminuh */
1978
1979static vector unsigned short __attribute__((__always_inline__))
1980vec_vminuh(vector unsigned short a, vector unsigned short b)
1981{
1982 return __builtin_altivec_vminuh(a, b);
1983}
1984
1985/* vec_vminsw */
1986
1987static vector int __attribute__((__always_inline__))
1988vec_vminsw(vector int a, vector int b)
1989{
1990 return __builtin_altivec_vminsw(a, b);
1991}
1992
1993/* vec_vminuw */
1994
1995static vector unsigned int __attribute__((__always_inline__))
1996vec_vminuw(vector unsigned int a, vector unsigned int b)
1997{
1998 return __builtin_altivec_vminuw(a, b);
1999}
2000
2001/* vec_vminfp */
2002
2003static vector float __attribute__((__always_inline__))
2004vec_vminfp(vector float a, vector float b)
2005{
2006 return __builtin_altivec_vminfp(a, b);
2007}
2008
2009/* vec_mladd */
2010
2011#define __builtin_altivec_vmladduhm vec_mladd
2012
2013static vector short __ATTRS_o_ai
2014vec_mladd(vector short a, vector short b, vector short c)
2015{
2016 return a * b + c;
2017}
2018
2019static vector short __ATTRS_o_ai
2020vec_mladd(vector short a, vector unsigned short b, vector unsigned short c)
2021{
2022 return a * (vector short)b + (vector short)c;
2023}
2024
2025static vector short __ATTRS_o_ai
2026vec_mladd(vector unsigned short a, vector short b, vector short c)
2027{
2028 return (vector short)a * b + c;
2029}
2030
2031static vector unsigned short __ATTRS_o_ai
2032vec_mladd(vector unsigned short a, vector unsigned short b, vector unsigned short c)
2033{
2034 return a * b + c;
2035}
2036
2037/* vec_vmladduhm */
2038
2039static vector short __ATTRS_o_ai
2040vec_vmladduhm(vector short a, vector short b, vector short c)
2041{
2042 return a * b + c;
2043}
2044
2045static vector short __ATTRS_o_ai
2046vec_vmladduhm(vector short a, vector unsigned short b, vector unsigned short c)
2047{
2048 return a * (vector short)b + (vector short)c;
2049}
2050
2051static vector short __ATTRS_o_ai
2052vec_vmladduhm(vector unsigned short a, vector short b, vector short c)
2053{
2054 return (vector short)a * b + c;
2055}
2056
2057static vector unsigned short __ATTRS_o_ai
2058vec_vmladduhm(vector unsigned short a, vector unsigned short b, vector unsigned short c)
2059{
2060 return a * b + c;
2061}
2062
2063/* vec_mradds */
2064
2065static vector short __attribute__((__always_inline__))
2066vec_mradds(vector short a, vector short b, vector short c)
2067{
2068 return __builtin_altivec_vmhraddshs(a, b, c);
2069}
2070
2071/* vec_vmhraddshs */
2072
2073static vector short __attribute__((__always_inline__))
2074vec_vmhraddshs(vector short a, vector short b, vector short c)
2075{
2076 return __builtin_altivec_vmhraddshs(a, b, c);
2077}
2078
2079/* vec_msum */
2080
2081static vector int __ATTRS_o_ai
2082vec_msum(vector signed char a, vector unsigned char b, vector int c)
2083{
2084 return __builtin_altivec_vmsummbm(a, b, c);
2085}
2086
2087static vector unsigned int __ATTRS_o_ai
2088vec_msum(vector unsigned char a, vector unsigned char b, vector unsigned int c)
2089{
2090 return __builtin_altivec_vmsumubm(a, b, c);
2091}
2092
2093static vector int __ATTRS_o_ai
2094vec_msum(vector short a, vector short b, vector int c)
2095{
2096 return __builtin_altivec_vmsumshm(a, b, c);
2097}
2098
2099static vector unsigned int __ATTRS_o_ai
2100vec_msum(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2101{
2102 return __builtin_altivec_vmsumuhm(a, b, c);
2103}
2104
2105/* vec_vmsummbm */
2106
2107static vector int __attribute__((__always_inline__))
2108vec_vmsummbm(vector signed char a, vector unsigned char b, vector int c)
2109{
2110 return __builtin_altivec_vmsummbm(a, b, c);
2111}
2112
2113/* vec_vmsumubm */
2114
2115static vector unsigned int __attribute__((__always_inline__))
2116vec_vmsumubm(vector unsigned char a, vector unsigned char b, vector unsigned int c)
2117{
2118 return __builtin_altivec_vmsumubm(a, b, c);
2119}
2120
2121/* vec_vmsumshm */
2122
2123static vector int __attribute__((__always_inline__))
2124vec_vmsumshm(vector short a, vector short b, vector int c)
2125{
2126 return __builtin_altivec_vmsumshm(a, b, c);
2127}
2128
2129/* vec_vmsumuhm */
2130
2131static vector unsigned int __attribute__((__always_inline__))
2132vec_vmsumuhm(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2133{
2134 return __builtin_altivec_vmsumuhm(a, b, c);
2135}
2136
2137/* vec_msums */
2138
2139static vector int __ATTRS_o_ai
2140vec_msums(vector short a, vector short b, vector int c)
2141{
2142 return __builtin_altivec_vmsumshs(a, b, c);
2143}
2144
2145static vector unsigned int __ATTRS_o_ai
2146vec_msums(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2147{
2148 return __builtin_altivec_vmsumuhs(a, b, c);
2149}
2150
2151/* vec_vmsumshs */
2152
2153static vector int __attribute__((__always_inline__))
2154vec_vmsumshs(vector short a, vector short b, vector int c)
2155{
2156 return __builtin_altivec_vmsumshs(a, b, c);
2157}
2158
2159/* vec_vmsumuhs */
2160
2161static vector unsigned int __attribute__((__always_inline__))
2162vec_vmsumuhs(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2163{
2164 return __builtin_altivec_vmsumuhs(a, b, c);
2165}
2166
Chris Lattnerdd173942010-04-14 03:54:58 +00002167/* vec_mtvscr */
2168
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002169static void __ATTRS_o_ai
2170vec_mtvscr(vector signed char a)
2171{
2172 __builtin_altivec_mtvscr((vector int)a);
2173}
2174
2175static void __ATTRS_o_ai
2176vec_mtvscr(vector unsigned char a)
2177{
2178 __builtin_altivec_mtvscr((vector int)a);
2179}
2180
2181static void __ATTRS_o_ai
2182vec_mtvscr(vector short a)
2183{
2184 __builtin_altivec_mtvscr((vector int)a);
2185}
2186
2187static void __ATTRS_o_ai
2188vec_mtvscr(vector unsigned short a)
2189{
2190 __builtin_altivec_mtvscr((vector int)a);
2191}
2192
2193static void __ATTRS_o_ai
2194vec_mtvscr(vector int a)
2195{
2196 __builtin_altivec_mtvscr((vector int)a);
2197}
2198
2199static void __ATTRS_o_ai
2200vec_mtvscr(vector unsigned int a)
2201{
2202 __builtin_altivec_mtvscr((vector int)a);
2203}
2204
2205static void __ATTRS_o_ai
2206vec_mtvscr(vector float a)
2207{
2208 __builtin_altivec_mtvscr((vector int)a);
2209}
2210
2211/* vec_mule */
2212
2213static vector short __ATTRS_o_ai
2214vec_mule(vector signed char a, vector signed char b)
2215{
2216 return __builtin_altivec_vmulesb(a, b);
2217}
2218
2219static vector unsigned short __ATTRS_o_ai
2220vec_mule(vector unsigned char a, vector unsigned char b)
2221{
2222 return __builtin_altivec_vmuleub(a, b);
2223}
2224
2225static vector int __ATTRS_o_ai
2226vec_mule(vector short a, vector short b)
2227{
2228 return __builtin_altivec_vmulesh(a, b);
2229}
2230
2231static vector unsigned int __ATTRS_o_ai
2232vec_mule(vector unsigned short a, vector unsigned short b)
2233{
2234 return __builtin_altivec_vmuleuh(a, b);
2235}
2236
2237/* vec_vmulesb */
2238
2239static vector short __attribute__((__always_inline__))
2240vec_vmulesb(vector signed char a, vector signed char b)
2241{
2242 return __builtin_altivec_vmulesb(a, b);
2243}
2244
2245/* vec_vmuleub */
2246
2247static vector unsigned short __attribute__((__always_inline__))
2248vec_vmuleub(vector unsigned char a, vector unsigned char b)
2249{
2250 return __builtin_altivec_vmuleub(a, b);
2251}
2252
2253/* vec_vmulesh */
2254
2255static vector int __attribute__((__always_inline__))
2256vec_vmulesh(vector short a, vector short b)
2257{
2258 return __builtin_altivec_vmulesh(a, b);
2259}
2260
2261/* vec_vmuleuh */
2262
2263static vector unsigned int __attribute__((__always_inline__))
2264vec_vmuleuh(vector unsigned short a, vector unsigned short b)
2265{
2266 return __builtin_altivec_vmuleuh(a, b);
2267}
2268
2269/* vec_mulo */
2270
2271static vector short __ATTRS_o_ai
2272vec_mulo(vector signed char a, vector signed char b)
2273{
2274 return __builtin_altivec_vmulosb(a, b);
2275}
2276
2277static vector unsigned short __ATTRS_o_ai
2278vec_mulo(vector unsigned char a, vector unsigned char b)
2279{
2280 return __builtin_altivec_vmuloub(a, b);
2281}
2282
2283static vector int __ATTRS_o_ai
2284vec_mulo(vector short a, vector short b)
2285{
2286 return __builtin_altivec_vmulosh(a, b);
2287}
2288
2289static vector unsigned int __ATTRS_o_ai
2290vec_mulo(vector unsigned short a, vector unsigned short b)
2291{
2292 return __builtin_altivec_vmulouh(a, b);
2293}
2294
2295/* vec_vmulosb */
2296
2297static vector short __attribute__((__always_inline__))
2298vec_vmulosb(vector signed char a, vector signed char b)
2299{
2300 return __builtin_altivec_vmulosb(a, b);
2301}
2302
2303/* vec_vmuloub */
2304
2305static vector unsigned short __attribute__((__always_inline__))
2306vec_vmuloub(vector unsigned char a, vector unsigned char b)
2307{
2308 return __builtin_altivec_vmuloub(a, b);
2309}
2310
2311/* vec_vmulosh */
2312
2313static vector int __attribute__((__always_inline__))
2314vec_vmulosh(vector short a, vector short b)
2315{
2316 return __builtin_altivec_vmulosh(a, b);
2317}
2318
2319/* vec_vmulouh */
2320
2321static vector unsigned int __attribute__((__always_inline__))
2322vec_vmulouh(vector unsigned short a, vector unsigned short b)
2323{
2324 return __builtin_altivec_vmulouh(a, b);
2325}
2326
2327/* vec_nmsub */
2328
2329static vector float __attribute__((__always_inline__))
2330vec_nmsub(vector float a, vector float b, vector float c)
2331{
2332 return __builtin_altivec_vnmsubfp(a, b, c);
2333}
2334
2335/* vec_vnmsubfp */
2336
2337static vector float __attribute__((__always_inline__))
2338vec_vnmsubfp(vector float a, vector float b, vector float c)
2339{
2340 return __builtin_altivec_vnmsubfp(a, b, c);
2341}
2342
2343/* vec_nor */
2344
2345#define __builtin_altivec_vnor vec_nor
2346
2347static vector signed char __ATTRS_o_ai
2348vec_nor(vector signed char a, vector signed char b)
2349{
2350 return ~(a | b);
2351}
2352
2353static vector unsigned char __ATTRS_o_ai
2354vec_nor(vector unsigned char a, vector unsigned char b)
2355{
2356 return ~(a | b);
2357}
2358
2359static vector short __ATTRS_o_ai
2360vec_nor(vector short a, vector short b)
2361{
2362 return ~(a | b);
2363}
2364
2365static vector unsigned short __ATTRS_o_ai
2366vec_nor(vector unsigned short a, vector unsigned short b)
2367{
2368 return ~(a | b);
2369}
2370
2371static vector int __ATTRS_o_ai
2372vec_nor(vector int a, vector int b)
2373{
2374 return ~(a | b);
2375}
2376
2377static vector unsigned int __ATTRS_o_ai
2378vec_nor(vector unsigned int a, vector unsigned int b)
2379{
2380 return ~(a | b);
2381}
2382
2383static vector float __ATTRS_o_ai
2384vec_nor(vector float a, vector float b)
2385{
2386 vector unsigned int res = ~((vector unsigned int)a | (vector unsigned int)b);
2387 return (vector float)res;
2388}
2389
2390/* vec_vnor */
2391
2392static vector signed char __ATTRS_o_ai
2393vec_vnor(vector signed char a, vector signed char b)
2394{
2395 return ~(a | b);
2396}
2397
2398static vector unsigned char __ATTRS_o_ai
2399vec_vnor(vector unsigned char a, vector unsigned char b)
2400{
2401 return ~(a | b);
2402}
2403
2404static vector short __ATTRS_o_ai
2405vec_vnor(vector short a, vector short b)
2406{
2407 return ~(a | b);
2408}
2409
2410static vector unsigned short __ATTRS_o_ai
2411vec_vnor(vector unsigned short a, vector unsigned short b)
2412{
2413 return ~(a | b);
2414}
2415
2416static vector int __ATTRS_o_ai
2417vec_vnor(vector int a, vector int b)
2418{
2419 return ~(a | b);
2420}
2421
2422static vector unsigned int __ATTRS_o_ai
2423vec_vnor(vector unsigned int a, vector unsigned int b)
2424{
2425 return ~(a | b);
2426}
2427
2428static vector float __ATTRS_o_ai
2429vec_vnor(vector float a, vector float b)
2430{
2431 vector unsigned int res = ~((vector unsigned int)a | (vector unsigned int)b);
2432 return (vector float)res;
2433}
2434
2435/* vec_or */
2436
2437#define __builtin_altivec_vor vec_or
2438
2439static vector signed char __ATTRS_o_ai
2440vec_or(vector signed char a, vector signed char b)
2441{
2442 return a | b;
2443}
2444
2445static vector unsigned char __ATTRS_o_ai
2446vec_or(vector unsigned char a, vector unsigned char b)
2447{
2448 return a | b;
2449}
2450
2451static vector short __ATTRS_o_ai
2452vec_or(vector short a, vector short b)
2453{
2454 return a | b;
2455}
2456
2457static vector unsigned short __ATTRS_o_ai
2458vec_or(vector unsigned short a, vector unsigned short b)
2459{
2460 return a | b;
2461}
2462
2463static vector int __ATTRS_o_ai
2464vec_or(vector int a, vector int b)
2465{
2466 return a | b;
2467}
2468
2469static vector unsigned int __ATTRS_o_ai
2470vec_or(vector unsigned int a, vector unsigned int b)
2471{
2472 return a | b;
2473}
2474
2475static vector float __ATTRS_o_ai
2476vec_or(vector float a, vector float b)
2477{
2478 vector unsigned int res = (vector unsigned int)a | (vector unsigned int)b;
2479 return (vector float)res;
2480}
2481
2482/* vec_vor */
2483
2484static vector signed char __ATTRS_o_ai
2485vec_vor(vector signed char a, vector signed char b)
2486{
2487 return a | b;
2488}
2489
2490static vector unsigned char __ATTRS_o_ai
2491vec_vor(vector unsigned char a, vector unsigned char b)
2492{
2493 return a | b;
2494}
2495
2496static vector short __ATTRS_o_ai
2497vec_vor(vector short a, vector short b)
2498{
2499 return a | b;
2500}
2501
2502static vector unsigned short __ATTRS_o_ai
2503vec_vor(vector unsigned short a, vector unsigned short b)
2504{
2505 return a | b;
2506}
2507
2508static vector int __ATTRS_o_ai
2509vec_vor(vector int a, vector int b)
2510{
2511 return a | b;
2512}
2513
2514static vector unsigned int __ATTRS_o_ai
2515vec_vor(vector unsigned int a, vector unsigned int b)
2516{
2517 return a | b;
2518}
2519
2520static vector float __ATTRS_o_ai
2521vec_vor(vector float a, vector float b)
2522{
2523 vector unsigned int res = (vector unsigned int)a | (vector unsigned int)b;
2524 return (vector float)res;
2525}
2526
2527/* vec_pack */
2528
2529static vector signed char __ATTRS_o_ai
2530vec_pack(vector signed short a, vector signed short b)
2531{
2532 return (vector signed char)vec_perm(a, b, (vector unsigned char)
2533 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
2534 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
2535}
2536
2537static vector unsigned char __ATTRS_o_ai
2538vec_pack(vector unsigned short a, vector unsigned short b)
2539{
2540 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
2541 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
2542 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
2543}
2544
2545static vector short __ATTRS_o_ai
2546vec_pack(vector int a, vector int b)
2547{
2548 return (vector short)vec_perm(a, b, (vector unsigned char)
2549 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
2550 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
2551}
2552
2553static vector unsigned short __ATTRS_o_ai
2554vec_pack(vector unsigned int a, vector unsigned int b)
2555{
2556 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
2557 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
2558 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
2559}
2560
2561/* vec_vpkuhum */
2562
2563#define __builtin_altivec_vpkuhum vec_vpkuhum
2564
2565static vector signed char __ATTRS_o_ai
2566vec_vpkuhum(vector signed short a, vector signed short b)
2567{
2568 return (vector signed char)vec_perm(a, b, (vector unsigned char)
2569 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
2570 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
2571}
2572
2573static vector unsigned char __ATTRS_o_ai
2574vec_vpkuhum(vector unsigned short a, vector unsigned short b)
2575{
2576 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
2577 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
2578 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
2579}
2580
2581/* vec_vpkuwum */
2582
2583#define __builtin_altivec_vpkuwum vec_vpkuwum
2584
2585static vector short __ATTRS_o_ai
2586vec_vpkuwum(vector int a, vector int b)
2587{
2588 return (vector short)vec_perm(a, b, (vector unsigned char)
2589 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
2590 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
2591}
2592
2593static vector unsigned short __ATTRS_o_ai
2594vec_vpkuwum(vector unsigned int a, vector unsigned int b)
2595{
2596 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
2597 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
2598 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
2599}
2600
2601/* vec_packpx */
2602
2603static vector pixel __attribute__((__always_inline__))
2604vec_packpx(vector unsigned int a, vector unsigned int b)
2605{
2606 return (vector pixel)__builtin_altivec_vpkpx(a, b);
2607}
2608
2609/* vec_vpkpx */
2610
2611static vector pixel __attribute__((__always_inline__))
2612vec_vpkpx(vector unsigned int a, vector unsigned int b)
2613{
2614 return (vector pixel)__builtin_altivec_vpkpx(a, b);
2615}
2616
2617/* vec_packs */
2618
2619static vector signed char __ATTRS_o_ai
2620vec_packs(vector short a, vector short b)
2621{
2622 return __builtin_altivec_vpkshss(a, b);
2623}
2624
2625static vector unsigned char __ATTRS_o_ai
2626vec_packs(vector unsigned short a, vector unsigned short b)
2627{
2628 return __builtin_altivec_vpkuhus(a, b);
2629}
2630
2631static vector signed short __ATTRS_o_ai
2632vec_packs(vector int a, vector int b)
2633{
2634 return __builtin_altivec_vpkswss(a, b);
2635}
2636
2637static vector unsigned short __ATTRS_o_ai
2638vec_packs(vector unsigned int a, vector unsigned int b)
2639{
2640 return __builtin_altivec_vpkuwus(a, b);
2641}
2642
2643/* vec_vpkshss */
2644
2645static vector signed char __attribute__((__always_inline__))
2646vec_vpkshss(vector short a, vector short b)
2647{
2648 return __builtin_altivec_vpkshss(a, b);
2649}
2650
2651/* vec_vpkuhus */
2652
2653static vector unsigned char __attribute__((__always_inline__))
2654vec_vpkuhus(vector unsigned short a, vector unsigned short b)
2655{
2656 return __builtin_altivec_vpkuhus(a, b);
2657}
2658
2659/* vec_vpkswss */
2660
2661static vector signed short __attribute__((__always_inline__))
2662vec_vpkswss(vector int a, vector int b)
2663{
2664 return __builtin_altivec_vpkswss(a, b);
2665}
2666
2667/* vec_vpkuwus */
2668
2669static vector unsigned short __attribute__((__always_inline__))
2670vec_vpkuwus(vector unsigned int a, vector unsigned int b)
2671{
2672 return __builtin_altivec_vpkuwus(a, b);
2673}
2674
2675/* vec_packsu */
2676
2677static vector unsigned char __ATTRS_o_ai
2678vec_packsu(vector short a, vector short b)
2679{
2680 return __builtin_altivec_vpkshus(a, b);
2681}
2682
2683static vector unsigned char __ATTRS_o_ai
2684vec_packsu(vector unsigned short a, vector unsigned short b)
2685{
2686 return __builtin_altivec_vpkuhus(a, b);
2687}
2688
2689static vector unsigned short __ATTRS_o_ai
2690vec_packsu(vector int a, vector int b)
2691{
2692 return __builtin_altivec_vpkswus(a, b);
2693}
2694
2695static vector unsigned short __ATTRS_o_ai
2696vec_packsu(vector unsigned int a, vector unsigned int b)
2697{
2698 return __builtin_altivec_vpkuwus(a, b);
2699}
2700
2701/* vec_vpkshus */
2702
2703static vector unsigned char __ATTRS_o_ai
2704vec_vpkshus(vector short a, vector short b)
2705{
2706 return __builtin_altivec_vpkshus(a, b);
2707}
2708
2709static vector unsigned char __ATTRS_o_ai
2710vec_vpkshus(vector unsigned short a, vector unsigned short b)
2711{
2712 return __builtin_altivec_vpkuhus(a, b);
2713}
2714
2715/* vec_vpkswus */
2716
2717static vector unsigned short __ATTRS_o_ai
2718vec_vpkswus(vector int a, vector int b)
2719{
2720 return __builtin_altivec_vpkswus(a, b);
2721}
2722
2723static vector unsigned short __ATTRS_o_ai
2724vec_vpkswus(vector unsigned int a, vector unsigned int b)
2725{
2726 return __builtin_altivec_vpkuwus(a, b);
2727}
2728
2729/* vec_perm */
2730
2731vector signed char __ATTRS_o_ai
2732vec_perm(vector signed char a, vector signed char b, vector unsigned char c)
2733{
2734 return (vector signed char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2735}
2736
2737vector unsigned char __ATTRS_o_ai
2738vec_perm(vector unsigned char a, vector unsigned char b, vector unsigned char c)
2739{
2740 return (vector unsigned char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2741}
2742
2743vector short __ATTRS_o_ai
2744vec_perm(vector short a, vector short b, vector unsigned char c)
2745{
2746 return (vector short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2747}
2748
2749vector unsigned short __ATTRS_o_ai
2750vec_perm(vector unsigned short a, vector unsigned short b, vector unsigned char c)
2751{
2752 return (vector unsigned short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2753}
2754
2755vector int __ATTRS_o_ai
2756vec_perm(vector int a, vector int b, vector unsigned char c)
2757{
2758 return (vector int)__builtin_altivec_vperm_4si(a, b, c);
2759}
2760
2761vector unsigned int __ATTRS_o_ai
2762vec_perm(vector unsigned int a, vector unsigned int b, vector unsigned char c)
2763{
2764 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2765}
2766
2767vector float __ATTRS_o_ai
2768vec_perm(vector float a, vector float b, vector unsigned char c)
2769{
2770 return (vector float)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2771}
2772
2773/* vec_vperm */
2774
2775vector signed char __ATTRS_o_ai
2776vec_vperm(vector signed char a, vector signed char b, vector unsigned char c)
2777{
2778 return (vector signed char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2779}
2780
2781vector unsigned char __ATTRS_o_ai
2782vec_vperm(vector unsigned char a, vector unsigned char b, vector unsigned char c)
2783{
2784 return (vector unsigned char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2785}
2786
2787vector short __ATTRS_o_ai
2788vec_vperm(vector short a, vector short b, vector unsigned char c)
2789{
2790 return (vector short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2791}
2792
2793vector unsigned short __ATTRS_o_ai
2794vec_vperm(vector unsigned short a, vector unsigned short b, vector unsigned char c)
2795{
2796 return (vector unsigned short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2797}
2798
2799vector int __ATTRS_o_ai
2800vec_vperm(vector int a, vector int b, vector unsigned char c)
2801{
2802 return (vector int)__builtin_altivec_vperm_4si(a, b, c);
2803}
2804
2805vector unsigned int __ATTRS_o_ai
2806vec_vperm(vector unsigned int a, vector unsigned int b, vector unsigned char c)
2807{
2808 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2809}
2810
2811vector float __ATTRS_o_ai
2812vec_vperm(vector float a, vector float b, vector unsigned char c)
2813{
2814 return (vector float)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
2815}
2816
2817/* vec_re */
2818
2819vector float __attribute__((__always_inline__))
2820vec_re(vector float a)
2821{
2822 return __builtin_altivec_vrefp(a);
2823}
2824
2825/* vec_vrefp */
2826
2827vector float __attribute__((__always_inline__))
2828vec_vrefp(vector float a)
2829{
2830 return __builtin_altivec_vrefp(a);
2831}
2832
2833/* vec_rl */
2834
2835static vector signed char __ATTRS_o_ai
2836vec_rl(vector signed char a, vector unsigned char b)
2837{
2838 return (vector signed char)__builtin_altivec_vrlb((vector char)a, b);
2839}
2840
2841static vector unsigned char __ATTRS_o_ai
2842vec_rl(vector unsigned char a, vector unsigned char b)
2843{
2844 return (vector unsigned char)__builtin_altivec_vrlb((vector char)a, b);
2845}
2846
2847static vector short __ATTRS_o_ai
2848vec_rl(vector short a, vector unsigned short b)
2849{
2850 return __builtin_altivec_vrlh(a, b);
2851}
2852
2853static vector unsigned short __ATTRS_o_ai
2854vec_rl(vector unsigned short a, vector unsigned short b)
2855{
2856 return (vector unsigned short)__builtin_altivec_vrlh((vector short)a, b);
2857}
2858
2859static vector int __ATTRS_o_ai
2860vec_rl(vector int a, vector unsigned int b)
2861{
2862 return __builtin_altivec_vrlw(a, b);
2863}
2864
2865static vector unsigned int __ATTRS_o_ai
2866vec_rl(vector unsigned int a, vector unsigned int b)
2867{
2868 return (vector unsigned int)__builtin_altivec_vrlw((vector int)a, b);
2869}
2870
2871/* vec_vrlb */
2872
2873static vector signed char __ATTRS_o_ai
2874vec_vrlb(vector signed char a, vector unsigned char b)
2875{
2876 return (vector signed char)__builtin_altivec_vrlb((vector char)a, b);
2877}
2878
2879static vector unsigned char __ATTRS_o_ai
2880vec_vrlb(vector unsigned char a, vector unsigned char b)
2881{
2882 return (vector unsigned char)__builtin_altivec_vrlb((vector char)a, b);
2883}
2884
2885/* vec_vrlh */
2886
2887static vector short __ATTRS_o_ai
2888vec_vrlh(vector short a, vector unsigned short b)
2889{
2890 return __builtin_altivec_vrlh(a, b);
2891}
2892
2893static vector unsigned short __ATTRS_o_ai
2894vec_vrlh(vector unsigned short a, vector unsigned short b)
2895{
2896 return (vector unsigned short)__builtin_altivec_vrlh((vector short)a, b);
2897}
2898
2899/* vec_vrlw */
2900
2901static vector int __ATTRS_o_ai
2902vec_vrlw(vector int a, vector unsigned int b)
2903{
2904 return __builtin_altivec_vrlw(a, b);
2905}
2906
2907static vector unsigned int __ATTRS_o_ai
2908vec_vrlw(vector unsigned int a, vector unsigned int b)
2909{
2910 return (vector unsigned int)__builtin_altivec_vrlw((vector int)a, b);
2911}
2912
2913/* vec_round */
2914
2915static vector float __attribute__((__always_inline__))
2916vec_round(vector float a)
2917{
2918 return __builtin_altivec_vrfin(a);
2919}
2920
2921/* vec_vrfin */
2922
2923static vector float __attribute__((__always_inline__))
2924vec_vrfin(vector float a)
2925{
2926 return __builtin_altivec_vrfin(a);
2927}
2928
2929/* vec_rsqrte */
2930
2931static __vector float __attribute__((__always_inline__))
2932vec_rsqrte(vector float a)
2933{
2934 return __builtin_altivec_vrsqrtefp(a);
2935}
2936
2937/* vec_vrsqrtefp */
2938
2939static __vector float __attribute__((__always_inline__))
2940vec_vrsqrtefp(vector float a)
2941{
2942 return __builtin_altivec_vrsqrtefp(a);
2943}
2944
2945/* vec_sel */
2946
2947#define __builtin_altivec_vsel_4si vec_sel
2948
2949static vector signed char __ATTRS_o_ai
2950vec_sel(vector signed char a, vector signed char b, vector unsigned char c)
2951{
2952 return (a & ~(vector signed char)c) | (b & (vector signed char)c);
2953}
2954
2955static vector unsigned char __ATTRS_o_ai
2956vec_sel(vector unsigned char a, vector unsigned char b, vector unsigned char c)
2957{
2958 return (a & ~c) | (b & c);
2959}
2960
2961static vector short __ATTRS_o_ai
2962vec_sel(vector short a, vector short b, vector unsigned short c)
2963{
2964 return (a & ~(vector short)c) | (b & (vector short)c);
2965}
2966
2967static vector unsigned short __ATTRS_o_ai
2968vec_sel(vector unsigned short a, vector unsigned short b, vector unsigned short c)
2969{
2970 return (a & ~c) | (b & c);
2971}
2972
2973static vector int __ATTRS_o_ai
2974vec_sel(vector int a, vector int b, vector unsigned int c)
2975{
2976 return (a & ~(vector int)c) | (b & (vector int)c);
2977}
2978
2979static vector unsigned int __ATTRS_o_ai
2980vec_sel(vector unsigned int a, vector unsigned int b, vector unsigned int c)
2981{
2982 return (a & ~c) | (b & c);
2983}
2984
2985static vector float __ATTRS_o_ai
2986vec_sel(vector float a, vector float b, vector unsigned int c)
2987{
2988 vector int res = ((vector int)a & ~(vector int)c) | ((vector int)b & (vector int)c);
2989 return (vector float)res;
2990}
2991
2992/* vec_vsel */
2993
2994static vector signed char __ATTRS_o_ai
2995vec_vsel(vector signed char a, vector signed char b, vector unsigned char c)
2996{
2997 return (a & ~(vector signed char)c) | (b & (vector signed char)c);
2998}
2999
3000static vector unsigned char __ATTRS_o_ai
3001vec_vsel(vector unsigned char a, vector unsigned char b, vector unsigned char c)
3002{
3003 return (a & ~c) | (b & c);
3004}
3005
3006static vector short __ATTRS_o_ai
3007vec_vsel(vector short a, vector short b, vector unsigned short c)
3008{
3009 return (a & ~(vector short)c) | (b & (vector short)c);
3010}
3011
3012static vector unsigned short __ATTRS_o_ai
3013vec_vsel(vector unsigned short a, vector unsigned short b, vector unsigned short c)
3014{
3015 return (a & ~c) | (b & c);
3016}
3017
3018static vector int __ATTRS_o_ai
3019vec_vsel(vector int a, vector int b, vector unsigned int c)
3020{
3021 return (a & ~(vector int)c) | (b & (vector int)c);
3022}
3023
3024static vector unsigned int __ATTRS_o_ai
3025vec_vsel(vector unsigned int a, vector unsigned int b, vector unsigned int c)
3026{
3027 return (a & ~c) | (b & c);
3028}
3029
3030static vector float __ATTRS_o_ai
3031vec_vsel(vector float a, vector float b, vector unsigned int c)
3032{
3033 vector int res = ((vector int)a & ~(vector int)c) | ((vector int)b & (vector int)c);
3034 return (vector float)res;
3035}
3036
3037/* vec_sl */
3038
3039static vector signed char __ATTRS_o_ai
3040vec_sl(vector signed char a, vector unsigned char b)
3041{
3042 return a << (vector signed char)b;
3043}
3044
3045static vector unsigned char __ATTRS_o_ai
3046vec_sl(vector unsigned char a, vector unsigned char b)
3047{
3048 return a << b;
3049}
3050
3051static vector short __ATTRS_o_ai
3052vec_sl(vector short a, vector unsigned short b)
3053{
3054 return a << (vector short)b;
3055}
3056
3057static vector unsigned short __ATTRS_o_ai
3058vec_sl(vector unsigned short a, vector unsigned short b)
3059{
3060 return a << b;
3061}
3062
3063static vector int __ATTRS_o_ai
3064vec_sl(vector int a, vector unsigned int b)
3065{
3066 return a << (vector int)b;
3067}
3068
3069static vector unsigned int __ATTRS_o_ai
3070vec_sl(vector unsigned int a, vector unsigned int b)
3071{
3072 return a << b;
3073}
3074
3075/* vec_vslb */
3076
3077#define __builtin_altivec_vslb vec_vslb
3078
3079static vector signed char __ATTRS_o_ai
3080vec_vslb(vector signed char a, vector unsigned char b)
3081{
3082 return vec_sl(a, b);
3083}
3084
3085static vector unsigned char __ATTRS_o_ai
3086vec_vslb(vector unsigned char a, vector unsigned char b)
3087{
3088 return vec_sl(a, b);
3089}
3090
3091/* vec_vslh */
3092
3093#define __builtin_altivec_vslh vec_vslh
3094
3095static vector short __ATTRS_o_ai
3096vec_vslh(vector short a, vector unsigned short b)
3097{
3098 return vec_sl(a, b);
3099}
3100
3101static vector unsigned short __ATTRS_o_ai
3102vec_vslh(vector unsigned short a, vector unsigned short b)
3103{
3104 return vec_sl(a, b);
3105}
3106
3107/* vec_vslw */
3108
3109#define __builtin_altivec_vslw vec_vslw
3110
3111static vector int __ATTRS_o_ai
3112vec_vslw(vector int a, vector unsigned int b)
3113{
3114 return vec_sl(a, b);
3115}
3116
3117static vector unsigned int __ATTRS_o_ai
3118vec_vslw(vector unsigned int a, vector unsigned int b)
3119{
3120 return vec_sl(a, b);
3121}
3122
3123/* vec_sld */
3124
3125#define __builtin_altivec_vsldoi_4si vec_sld
3126
3127static vector signed char __ATTRS_o_ai
3128vec_sld(vector signed char a, vector signed char b, unsigned char c)
3129{
3130 return (vector signed char)vec_perm(a, b, (vector unsigned char)
3131 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3132 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3133}
3134
3135static vector unsigned char __ATTRS_o_ai
3136vec_sld(vector unsigned char a, vector unsigned char b, unsigned char c)
3137{
3138 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
3139 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3140 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3141}
3142
3143static vector short __ATTRS_o_ai
3144vec_sld(vector short a, vector short b, unsigned char c)
3145{
3146 return (vector short)vec_perm(a, b, (vector unsigned char)
3147 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3148 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3149}
3150
3151static vector unsigned short __ATTRS_o_ai
3152vec_sld(vector unsigned short a, vector unsigned short b, unsigned char c)
3153{
3154 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
3155 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3156 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3157}
3158
3159static vector int __ATTRS_o_ai
3160vec_sld(vector int a, vector int b, unsigned char c)
3161{
3162 return vec_perm(a, b, (vector unsigned char)
3163 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3164 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3165}
3166
3167static vector unsigned int __ATTRS_o_ai
3168vec_sld(vector unsigned int a, vector unsigned int b, unsigned char c)
3169{
3170 return (vector unsigned int)vec_perm(a, b, (vector unsigned char)
3171 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3172 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3173}
3174
3175static vector float __ATTRS_o_ai
3176vec_sld(vector float a, vector float b, unsigned char c)
3177{
3178 return (vector float)vec_perm(a, b, (vector unsigned char)
3179 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3180 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3181}
3182
3183/* vec_vsldoi */
3184
3185static vector signed char __ATTRS_o_ai
3186vec_vsldoi(vector signed char a, vector signed char b, unsigned char c)
3187{
3188 return (vector signed char)vec_perm(a, b, (vector unsigned char)
3189 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3190 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3191}
3192
3193static vector unsigned char __ATTRS_o_ai
3194vec_vsldoi(vector unsigned char a, vector unsigned char b, unsigned char c)
3195{
3196 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
3197 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3198 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3199}
3200
3201static vector short __ATTRS_o_ai
3202vec_vsldoi(vector short a, vector short b, unsigned char c)
3203{
3204 return (vector short)vec_perm(a, b, (vector unsigned char)
3205 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3206 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3207}
3208
3209static vector unsigned short __ATTRS_o_ai
3210vec_vsldoi(vector unsigned short a, vector unsigned short b, unsigned char c)
3211{
3212 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
3213 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3214 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3215}
3216
3217static vector int __ATTRS_o_ai
3218vec_vsldoi(vector int a, vector int b, unsigned char c)
3219{
3220 return vec_perm(a, b, (vector unsigned char)
3221 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3222 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3223}
3224
3225static vector unsigned int __ATTRS_o_ai
3226vec_vsldoi(vector unsigned int a, vector unsigned int b, unsigned char c)
3227{
3228 return (vector unsigned int)vec_perm(a, b, (vector unsigned char)
3229 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3230 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3231}
3232
3233static vector float __ATTRS_o_ai
3234vec_vsldoi(vector float a, vector float b, unsigned char c)
3235{
3236 return (vector float)vec_perm(a, b, (vector unsigned char)
3237 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
3238 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
3239}
3240
3241/* vec_sll */
3242
3243static vector signed char __ATTRS_o_ai
3244vec_sll(vector signed char a, vector unsigned char b)
3245{
3246 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3247}
3248
3249static vector signed char __ATTRS_o_ai
3250vec_sll(vector signed char a, vector unsigned short b)
3251{
3252 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3253}
3254
3255static vector signed char __ATTRS_o_ai
3256vec_sll(vector signed char a, vector unsigned int b)
3257{
3258 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3259}
3260
3261static vector unsigned char __ATTRS_o_ai
3262vec_sll(vector unsigned char a, vector unsigned char b)
3263{
3264 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3265}
3266
3267static vector unsigned char __ATTRS_o_ai
3268vec_sll(vector unsigned char a, vector unsigned short b)
3269{
3270 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3271}
3272
3273static vector unsigned char __ATTRS_o_ai
3274vec_sll(vector unsigned char a, vector unsigned int b)
3275{
3276 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3277}
3278
3279static vector short __ATTRS_o_ai
3280vec_sll(vector short a, vector unsigned char b)
3281{
3282 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3283}
3284
3285static vector short __ATTRS_o_ai
3286vec_sll(vector short a, vector unsigned short b)
3287{
3288 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3289}
3290
3291static vector short __ATTRS_o_ai
3292vec_sll(vector short a, vector unsigned int b)
3293{
3294 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3295}
3296
3297static vector unsigned short __ATTRS_o_ai
3298vec_sll(vector unsigned short a, vector unsigned char b)
3299{
3300 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3301}
3302
3303static vector unsigned short __ATTRS_o_ai
3304vec_sll(vector unsigned short a, vector unsigned short b)
3305{
3306 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3307}
3308
3309static vector unsigned short __ATTRS_o_ai
3310vec_sll(vector unsigned short a, vector unsigned int b)
3311{
3312 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3313}
3314
3315static vector int __ATTRS_o_ai
3316vec_sll(vector int a, vector unsigned char b)
3317{
3318 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3319}
3320
3321static vector int __ATTRS_o_ai
3322vec_sll(vector int a, vector unsigned short b)
3323{
3324 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3325}
3326
3327static vector int __ATTRS_o_ai
3328vec_sll(vector int a, vector unsigned int b)
3329{
3330 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3331}
3332
3333static vector unsigned int __ATTRS_o_ai
3334vec_sll(vector unsigned int a, vector unsigned char b)
3335{
3336 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3337}
3338
3339static vector unsigned int __ATTRS_o_ai
3340vec_sll(vector unsigned int a, vector unsigned short b)
3341{
3342 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3343}
3344
3345static vector unsigned int __ATTRS_o_ai
3346vec_sll(vector unsigned int a, vector unsigned int b)
3347{
3348 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3349}
3350
3351/* vec_vsl */
3352
3353static vector signed char __ATTRS_o_ai
3354vec_vsl(vector signed char a, vector unsigned char b)
3355{
3356 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3357}
3358
3359static vector signed char __ATTRS_o_ai
3360vec_vsl(vector signed char a, vector unsigned short b)
3361{
3362 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3363}
3364
3365static vector signed char __ATTRS_o_ai
3366vec_vsl(vector signed char a, vector unsigned int b)
3367{
3368 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3369}
3370
3371static vector unsigned char __ATTRS_o_ai
3372vec_vsl(vector unsigned char a, vector unsigned char b)
3373{
3374 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3375}
3376
3377static vector unsigned char __ATTRS_o_ai
3378vec_vsl(vector unsigned char a, vector unsigned short b)
3379{
3380 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3381}
3382
3383static vector unsigned char __ATTRS_o_ai
3384vec_vsl(vector unsigned char a, vector unsigned int b)
3385{
3386 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
3387}
3388
3389static vector short __ATTRS_o_ai
3390vec_vsl(vector short a, vector unsigned char b)
3391{
3392 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3393}
3394
3395static vector short __ATTRS_o_ai
3396vec_vsl(vector short a, vector unsigned short b)
3397{
3398 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3399}
3400
3401static vector short __ATTRS_o_ai
3402vec_vsl(vector short a, vector unsigned int b)
3403{
3404 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3405}
3406
3407static vector unsigned short __ATTRS_o_ai
3408vec_vsl(vector unsigned short a, vector unsigned char b)
3409{
3410 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3411}
3412
3413static vector unsigned short __ATTRS_o_ai
3414vec_vsl(vector unsigned short a, vector unsigned short b)
3415{
3416 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3417}
3418
3419static vector unsigned short __ATTRS_o_ai
3420vec_vsl(vector unsigned short a, vector unsigned int b)
3421{
3422 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
3423}
3424
3425static vector int __ATTRS_o_ai
3426vec_vsl(vector int a, vector unsigned char b)
3427{
3428 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3429}
3430
3431static vector int __ATTRS_o_ai
3432vec_vsl(vector int a, vector unsigned short b)
3433{
3434 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3435}
3436
3437static vector int __ATTRS_o_ai
3438vec_vsl(vector int a, vector unsigned int b)
3439{
3440 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
3441}
3442
3443static vector unsigned int __ATTRS_o_ai
3444vec_vsl(vector unsigned int a, vector unsigned char b)
3445{
3446 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3447}
3448
3449static vector unsigned int __ATTRS_o_ai
3450vec_vsl(vector unsigned int a, vector unsigned short b)
3451{
3452 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3453}
3454
3455static vector unsigned int __ATTRS_o_ai
3456vec_vsl(vector unsigned int a, vector unsigned int b)
3457{
3458 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
3459}
3460
3461/* vec_slo */
3462
3463static vector signed char __ATTRS_o_ai
3464vec_slo(vector signed char a, vector signed char b)
3465{
3466 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3467}
3468
3469static vector signed char __ATTRS_o_ai
3470vec_slo(vector signed char a, vector unsigned char b)
3471{
3472 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3473}
3474
3475static vector unsigned char __ATTRS_o_ai
3476vec_slo(vector unsigned char a, vector signed char b)
3477{
3478 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3479}
3480
3481static vector unsigned char __ATTRS_o_ai
3482vec_slo(vector unsigned char a, vector unsigned char b)
3483{
3484 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3485}
3486
3487static vector short __ATTRS_o_ai
3488vec_slo(vector short a, vector signed char b)
3489{
3490 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3491}
3492
3493static vector short __ATTRS_o_ai
3494vec_slo(vector short a, vector unsigned char b)
3495{
3496 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3497}
3498
3499static vector unsigned short __ATTRS_o_ai
3500vec_slo(vector unsigned short a, vector signed char b)
3501{
3502 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3503}
3504
3505static vector unsigned short __ATTRS_o_ai
3506vec_slo(vector unsigned short a, vector unsigned char b)
3507{
3508 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3509}
3510
3511static vector int __ATTRS_o_ai
3512vec_slo(vector int a, vector signed char b)
3513{
3514 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
3515}
3516
3517static vector int __ATTRS_o_ai
3518vec_slo(vector int a, vector unsigned char b)
3519{
3520 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
3521}
3522
3523static vector unsigned int __ATTRS_o_ai
3524vec_slo(vector unsigned int a, vector signed char b)
3525{
3526 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
3527}
3528
3529static vector unsigned int __ATTRS_o_ai
3530vec_slo(vector unsigned int a, vector unsigned char b)
3531{
3532 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
3533}
3534
3535static vector float __ATTRS_o_ai
3536vec_slo(vector float a, vector signed char b)
3537{
3538 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
3539}
3540
3541static vector float __ATTRS_o_ai
3542vec_slo(vector float a, vector unsigned char b)
3543{
3544 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
3545}
3546
3547/* vec_vslo */
3548
3549static vector signed char __ATTRS_o_ai
3550vec_vslo(vector signed char a, vector signed char b)
3551{
3552 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3553}
3554
3555static vector signed char __ATTRS_o_ai
3556vec_vslo(vector signed char a, vector unsigned char b)
3557{
3558 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3559}
3560
3561static vector unsigned char __ATTRS_o_ai
3562vec_vslo(vector unsigned char a, vector signed char b)
3563{
3564 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3565}
3566
3567static vector unsigned char __ATTRS_o_ai
3568vec_vslo(vector unsigned char a, vector unsigned char b)
3569{
3570 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
3571}
3572
3573static vector short __ATTRS_o_ai
3574vec_vslo(vector short a, vector signed char b)
3575{
3576 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3577}
3578
3579static vector short __ATTRS_o_ai
3580vec_vslo(vector short a, vector unsigned char b)
3581{
3582 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3583}
3584
3585static vector unsigned short __ATTRS_o_ai
3586vec_vslo(vector unsigned short a, vector signed char b)
3587{
3588 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3589}
3590
3591static vector unsigned short __ATTRS_o_ai
3592vec_vslo(vector unsigned short a, vector unsigned char b)
3593{
3594 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
3595}
3596
3597static vector int __ATTRS_o_ai
3598vec_vslo(vector int a, vector signed char b)
3599{
3600 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
3601}
3602
3603static vector int __ATTRS_o_ai
3604vec_vslo(vector int a, vector unsigned char b)
3605{
3606 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
3607}
3608
3609static vector unsigned int __ATTRS_o_ai
3610vec_vslo(vector unsigned int a, vector signed char b)
3611{
3612 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
3613}
3614
3615static vector unsigned int __ATTRS_o_ai
3616vec_vslo(vector unsigned int a, vector unsigned char b)
3617{
3618 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
3619}
3620
3621static vector float __ATTRS_o_ai
3622vec_vslo(vector float a, vector signed char b)
3623{
3624 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
3625}
3626
3627static vector float __ATTRS_o_ai
3628vec_vslo(vector float a, vector unsigned char b)
3629{
3630 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
3631}
3632
3633/* vec_splat */
3634
3635static vector signed char __ATTRS_o_ai
3636vec_splat(vector signed char a, unsigned char b)
3637{
3638 return (vector signed char)vec_perm(a, a, (vector unsigned char)(b));
3639}
3640
3641static vector unsigned char __ATTRS_o_ai
3642vec_splat(vector unsigned char a, unsigned char b)
3643{
3644 return (vector unsigned char)vec_perm(a, a, (vector unsigned char)(b));
3645}
3646
3647static vector short __ATTRS_o_ai
3648vec_splat(vector short a, unsigned char b)
3649{
3650 b *= 2;
3651 return (vector short)vec_perm(a, a, (vector unsigned char)
3652 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
3653}
3654
3655static vector unsigned short __ATTRS_o_ai
3656vec_splat(vector unsigned short a, unsigned char b)
3657{
3658 b *= 2;
3659 return (vector unsigned short)vec_perm(a, a, (vector unsigned char)
3660 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
3661}
3662
3663static vector int __ATTRS_o_ai
3664vec_splat(vector int a, unsigned char b)
3665{
3666 b *= 4;
3667 return vec_perm(a, a, (vector unsigned char)
3668 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3669}
3670
3671static vector unsigned int __ATTRS_o_ai
3672vec_splat(vector unsigned int a, unsigned char b)
3673{
3674 b *= 4;
3675 return (vector unsigned int)vec_perm(a, a, (vector unsigned char)
3676 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3677}
3678
3679static vector float __ATTRS_o_ai
3680vec_splat(vector float a, unsigned char b)
3681{
3682 b *= 4;
3683 return (vector float)vec_perm(a, a, (vector unsigned char)
3684 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3685}
3686
3687/* vec_vspltb */
3688
3689#define __builtin_altivec_vspltb vec_vspltb
3690
3691static vector signed char __ATTRS_o_ai
3692vec_vspltb(vector signed char a, unsigned char b)
3693{
3694 return (vector signed char)vec_perm(a, a, (vector unsigned char)(b));
3695}
3696
3697static vector unsigned char __ATTRS_o_ai
3698vec_vspltb(vector unsigned char a, unsigned char b)
3699{
3700 return (vector unsigned char)vec_perm(a, a, (vector unsigned char)(b));
3701}
3702
3703/* vec_vsplth */
3704
3705#define __builtin_altivec_vsplth vec_vsplth
3706
3707static vector short __ATTRS_o_ai
3708vec_vsplth(vector short a, unsigned char b)
3709{
3710 b *= 2;
3711 return (vector short)vec_perm(a, a, (vector unsigned char)
3712 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
3713}
3714
3715static vector unsigned short __ATTRS_o_ai
3716vec_vsplth(vector unsigned short a, unsigned char b)
3717{
3718 b *= 2;
3719 return (vector unsigned short)vec_perm(a, a, (vector unsigned char)
3720 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
3721}
3722
3723/* vec_vspltw */
3724
3725#define __builtin_altivec_vspltw vec_vspltw
3726
3727static vector int __ATTRS_o_ai
3728vec_vspltw(vector int a, unsigned char b)
3729{
3730 b *= 4;
3731 return (vector int)vec_perm(a, a, (vector unsigned char)
3732 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3733}
3734
3735static vector unsigned int __ATTRS_o_ai
3736vec_vspltw(vector unsigned int a, unsigned char b)
3737{
3738 b *= 4;
3739 return (vector unsigned int)vec_perm(a, a, (vector unsigned char)
3740 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3741}
3742
3743static vector float __ATTRS_o_ai
3744vec_vspltw(vector float a, unsigned char b)
3745{
3746 b *= 4;
3747 return (vector float)vec_perm(a, a, (vector unsigned char)
3748 (b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3, b, b+1, b+2, b+3));
3749}
3750
3751/* vec_splat_s8 */
3752
3753#define __builtin_altivec_vspltisb vec_splat_s8
3754
3755// FIXME: parameter should be treated as 5-bit signed literal
3756static vector signed char __ATTRS_o_ai
3757vec_splat_s8(signed char a)
3758{
3759 return (vector signed char)(a);
3760}
3761
3762/* vec_vspltisb */
3763
3764// FIXME: parameter should be treated as 5-bit signed literal
3765static vector signed char __ATTRS_o_ai
3766vec_vspltisb(signed char a)
3767{
3768 return (vector signed char)(a);
3769}
3770
3771/* vec_splat_s16 */
3772
3773#define __builtin_altivec_vspltish vec_splat_s16
3774
3775// FIXME: parameter should be treated as 5-bit signed literal
3776static vector short __ATTRS_o_ai
3777vec_splat_s16(signed char a)
3778{
3779 return (vector short)(a);
3780}
3781
3782/* vec_vspltish */
3783
3784// FIXME: parameter should be treated as 5-bit signed literal
3785static vector short __ATTRS_o_ai
3786vec_vspltish(signed char a)
3787{
3788 return (vector short)(a);
3789}
3790
3791/* vec_splat_s32 */
3792
3793#define __builtin_altivec_vspltisw vec_splat_s32
3794
3795// FIXME: parameter should be treated as 5-bit signed literal
3796static vector int __ATTRS_o_ai
3797vec_splat_s32(signed char a)
3798{
3799 return (vector int)(a);
3800}
3801
3802/* vec_vspltisw */
3803
3804// FIXME: parameter should be treated as 5-bit signed literal
3805static vector int __ATTRS_o_ai
3806vec_vspltisw(signed char a)
3807{
3808 return (vector int)(a);
3809}
3810
3811/* vec_splat_u8 */
3812
3813// FIXME: parameter should be treated as 5-bit signed literal
3814static vector unsigned char __ATTRS_o_ai
3815vec_splat_u8(unsigned char a)
3816{
3817 return (vector unsigned char)(a);
3818}
3819
3820/* vec_splat_u16 */
3821
3822// FIXME: parameter should be treated as 5-bit signed literal
3823static vector unsigned short __ATTRS_o_ai
3824vec_splat_u16(signed char a)
3825{
3826 return (vector unsigned short)(a);
3827}
3828
3829/* vec_splat_u32 */
3830
3831// FIXME: parameter should be treated as 5-bit signed literal
3832static vector unsigned int __ATTRS_o_ai
3833vec_splat_u32(signed char a)
3834{
3835 return (vector unsigned int)(a);
3836}
3837
3838/* vec_sr */
3839
3840static vector signed char __ATTRS_o_ai
3841vec_sr(vector signed char a, vector unsigned char b)
3842{
3843 return a >> (vector signed char)b;
3844}
3845
3846static vector unsigned char __ATTRS_o_ai
3847vec_sr(vector unsigned char a, vector unsigned char b)
3848{
3849 return a >> b;
3850}
3851
3852static vector short __ATTRS_o_ai
3853vec_sr(vector short a, vector unsigned short b)
3854{
3855 return a >> (vector short)b;
3856}
3857
3858static vector unsigned short __ATTRS_o_ai
3859vec_sr(vector unsigned short a, vector unsigned short b)
3860{
3861 return a >> b;
3862}
3863
3864static vector int __ATTRS_o_ai
3865vec_sr(vector int a, vector unsigned int b)
3866{
3867 return a >> (vector int)b;
3868}
3869
3870static vector unsigned int __ATTRS_o_ai
3871vec_sr(vector unsigned int a, vector unsigned int b)
3872{
3873 return a >> b;
3874}
3875
3876/* vec_vsrb */
3877
3878#define __builtin_altivec_vsrb vec_vsrb
3879
3880static vector signed char __ATTRS_o_ai
3881vec_vsrb(vector signed char a, vector unsigned char b)
3882{
3883 return a >> (vector signed char)b;
3884}
3885
3886static vector unsigned char __ATTRS_o_ai
3887vec_vsrb(vector unsigned char a, vector unsigned char b)
3888{
3889 return a >> b;
3890}
3891
3892/* vec_vsrh */
3893
3894#define __builtin_altivec_vsrh vec_vsrh
3895
3896static vector short __ATTRS_o_ai
3897vec_vsrh(vector short a, vector unsigned short b)
3898{
3899 return a >> (vector short)b;
3900}
3901
3902static vector unsigned short __ATTRS_o_ai
3903vec_vsrh(vector unsigned short a, vector unsigned short b)
3904{
3905 return a >> b;
3906}
3907
3908/* vec_vsrw */
3909
3910#define __builtin_altivec_vsrw vec_vsrw
3911
3912static vector int __ATTRS_o_ai
3913vec_vsrw(vector int a, vector unsigned int b)
3914{
3915 return a >> (vector int)b;
3916}
3917
3918static vector unsigned int __ATTRS_o_ai
3919vec_vsrw(vector unsigned int a, vector unsigned int b)
3920{
3921 return a >> b;
3922}
3923
3924/* vec_sra */
3925
3926static vector signed char __ATTRS_o_ai
3927vec_sra(vector signed char a, vector unsigned char b)
3928{
3929 return (vector signed char)__builtin_altivec_vsrab((vector char)a, b);
3930}
3931
3932static vector unsigned char __ATTRS_o_ai
3933vec_sra(vector unsigned char a, vector unsigned char b)
3934{
3935 return (vector unsigned char)__builtin_altivec_vsrab((vector char)a, b);
3936}
3937
3938static vector short __ATTRS_o_ai
3939vec_sra(vector short a, vector unsigned short b)
3940{
3941 return __builtin_altivec_vsrah(a, (vector unsigned short)b);
3942}
3943
3944static vector unsigned short __ATTRS_o_ai
3945vec_sra(vector unsigned short a, vector unsigned short b)
3946{
3947 return (vector unsigned short)__builtin_altivec_vsrah((vector short)a, b);
3948}
3949
3950static vector int __ATTRS_o_ai
3951vec_sra(vector int a, vector unsigned int b)
3952{
3953 return __builtin_altivec_vsraw(a, b);
3954}
3955
3956static vector unsigned int __ATTRS_o_ai
3957vec_sra(vector unsigned int a, vector unsigned int b)
3958{
3959 return (vector unsigned int)__builtin_altivec_vsraw((vector int)a, b);
3960}
3961
3962/* vec_vsrab */
3963
3964static vector signed char __ATTRS_o_ai
3965vec_vsrab(vector signed char a, vector unsigned char b)
3966{
3967 return (vector signed char)__builtin_altivec_vsrab((vector char)a, b);
3968}
3969
3970static vector unsigned char __ATTRS_o_ai
3971vec_vsrab(vector unsigned char a, vector unsigned char b)
3972{
3973 return (vector unsigned char)__builtin_altivec_vsrab((vector char)a, b);
3974}
3975
3976/* vec_vsrah */
3977
3978static vector short __ATTRS_o_ai
3979vec_vsrah(vector short a, vector unsigned short b)
3980{
3981 return __builtin_altivec_vsrah(a, (vector unsigned short)b);
3982}
3983
3984static vector unsigned short __ATTRS_o_ai
3985vec_vsrah(vector unsigned short a, vector unsigned short b)
3986{
3987 return (vector unsigned short)__builtin_altivec_vsrah((vector short)a, b);
3988}
3989
3990/* vec_vsraw */
3991
3992static vector int __ATTRS_o_ai
3993vec_vsraw(vector int a, vector unsigned int b)
3994{
3995 return __builtin_altivec_vsraw(a, b);
3996}
3997
3998static vector unsigned int __ATTRS_o_ai
3999vec_vsraw(vector unsigned int a, vector unsigned int b)
4000{
4001 return (vector unsigned int)__builtin_altivec_vsraw((vector int)a, b);
4002}
4003
4004/* vec_srl */
4005
4006static vector signed char __ATTRS_o_ai
4007vec_srl(vector signed char a, vector unsigned char b)
4008{
4009 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4010}
4011
4012static vector signed char __ATTRS_o_ai
4013vec_srl(vector signed char a, vector unsigned short b)
4014{
4015 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4016}
4017
4018static vector signed char __ATTRS_o_ai
4019vec_srl(vector signed char a, vector unsigned int b)
4020{
4021 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4022}
4023
4024static vector unsigned char __ATTRS_o_ai
4025vec_srl(vector unsigned char a, vector unsigned char b)
4026{
4027 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4028}
4029
4030static vector unsigned char __ATTRS_o_ai
4031vec_srl(vector unsigned char a, vector unsigned short b)
4032{
4033 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4034}
4035
4036static vector unsigned char __ATTRS_o_ai
4037vec_srl(vector unsigned char a, vector unsigned int b)
4038{
4039 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4040}
4041
4042static vector short __ATTRS_o_ai
4043vec_srl(vector short a, vector unsigned char b)
4044{
4045 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4046}
4047
4048static vector short __ATTRS_o_ai
4049vec_srl(vector short a, vector unsigned short b)
4050{
4051 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4052}
4053
4054static vector short __ATTRS_o_ai
4055vec_srl(vector short a, vector unsigned int b)
4056{
4057 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4058}
4059
4060static vector unsigned short __ATTRS_o_ai
4061vec_srl(vector unsigned short a, vector unsigned char b)
4062{
4063 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4064}
4065
4066static vector unsigned short __ATTRS_o_ai
4067vec_srl(vector unsigned short a, vector unsigned short b)
4068{
4069 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4070}
4071
4072static vector unsigned short __ATTRS_o_ai
4073vec_srl(vector unsigned short a, vector unsigned int b)
4074{
4075 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4076}
4077
4078static vector int __ATTRS_o_ai
4079vec_srl(vector int a, vector unsigned char b)
4080{
4081 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4082}
4083
4084static vector int __ATTRS_o_ai
4085vec_srl(vector int a, vector unsigned short b)
4086{
4087 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4088}
4089
4090static vector int __ATTRS_o_ai
4091vec_srl(vector int a, vector unsigned int b)
4092{
4093 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4094}
4095
4096static vector unsigned int __ATTRS_o_ai
4097vec_srl(vector unsigned int a, vector unsigned char b)
4098{
4099 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4100}
4101
4102static vector unsigned int __ATTRS_o_ai
4103vec_srl(vector unsigned int a, vector unsigned short b)
4104{
4105 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4106}
4107
4108static vector unsigned int __ATTRS_o_ai
4109vec_srl(vector unsigned int a, vector unsigned int b)
4110{
4111 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4112}
4113
4114/* vec_vsr */
4115
4116static vector signed char __ATTRS_o_ai
4117vec_vsr(vector signed char a, vector unsigned char b)
4118{
4119 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4120}
4121
4122static vector signed char __ATTRS_o_ai
4123vec_vsr(vector signed char a, vector unsigned short b)
4124{
4125 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4126}
4127
4128static vector signed char __ATTRS_o_ai
4129vec_vsr(vector signed char a, vector unsigned int b)
4130{
4131 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4132}
4133
4134static vector unsigned char __ATTRS_o_ai
4135vec_vsr(vector unsigned char a, vector unsigned char b)
4136{
4137 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4138}
4139
4140static vector unsigned char __ATTRS_o_ai
4141vec_vsr(vector unsigned char a, vector unsigned short b)
4142{
4143 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4144}
4145
4146static vector unsigned char __ATTRS_o_ai
4147vec_vsr(vector unsigned char a, vector unsigned int b)
4148{
4149 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
4150}
4151
4152static vector short __ATTRS_o_ai
4153vec_vsr(vector short a, vector unsigned char b)
4154{
4155 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4156}
4157
4158static vector short __ATTRS_o_ai
4159vec_vsr(vector short a, vector unsigned short b)
4160{
4161 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4162}
4163
4164static vector short __ATTRS_o_ai
4165vec_vsr(vector short a, vector unsigned int b)
4166{
4167 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4168}
4169
4170static vector unsigned short __ATTRS_o_ai
4171vec_vsr(vector unsigned short a, vector unsigned char b)
4172{
4173 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4174}
4175
4176static vector unsigned short __ATTRS_o_ai
4177vec_vsr(vector unsigned short a, vector unsigned short b)
4178{
4179 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4180}
4181
4182static vector unsigned short __ATTRS_o_ai
4183vec_vsr(vector unsigned short a, vector unsigned int b)
4184{
4185 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
4186}
4187
4188static vector int __ATTRS_o_ai
4189vec_vsr(vector int a, vector unsigned char b)
4190{
4191 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4192}
4193
4194static vector int __ATTRS_o_ai
4195vec_vsr(vector int a, vector unsigned short b)
4196{
4197 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4198}
4199
4200static vector int __ATTRS_o_ai
4201vec_vsr(vector int a, vector unsigned int b)
4202{
4203 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
4204}
4205
4206static vector unsigned int __ATTRS_o_ai
4207vec_vsr(vector unsigned int a, vector unsigned char b)
4208{
4209 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4210}
4211
4212static vector unsigned int __ATTRS_o_ai
4213vec_vsr(vector unsigned int a, vector unsigned short b)
4214{
4215 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4216}
4217
4218static vector unsigned int __ATTRS_o_ai
4219vec_vsr(vector unsigned int a, vector unsigned int b)
4220{
4221 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
4222}
4223
4224/* vec_sro */
4225
4226static vector signed char __ATTRS_o_ai
4227vec_sro(vector signed char a, vector signed char b)
4228{
4229 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4230}
4231
4232static vector signed char __ATTRS_o_ai
4233vec_sro(vector signed char a, vector unsigned char b)
4234{
4235 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4236}
4237
4238static vector unsigned char __ATTRS_o_ai
4239vec_sro(vector unsigned char a, vector signed char b)
4240{
4241 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4242}
4243
4244static vector unsigned char __ATTRS_o_ai
4245vec_sro(vector unsigned char a, vector unsigned char b)
4246{
4247 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4248}
4249
4250static vector short __ATTRS_o_ai
4251vec_sro(vector short a, vector signed char b)
4252{
4253 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4254}
4255
4256static vector short __ATTRS_o_ai
4257vec_sro(vector short a, vector unsigned char b)
4258{
4259 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4260}
4261
4262static vector unsigned short __ATTRS_o_ai
4263vec_sro(vector unsigned short a, vector signed char b)
4264{
4265 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4266}
4267
4268static vector unsigned short __ATTRS_o_ai
4269vec_sro(vector unsigned short a, vector unsigned char b)
4270{
4271 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4272}
4273
4274static vector int __ATTRS_o_ai
4275vec_sro(vector int a, vector signed char b)
4276{
4277 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
4278}
4279
4280static vector int __ATTRS_o_ai
4281vec_sro(vector int a, vector unsigned char b)
4282{
4283 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
4284}
4285
4286static vector unsigned int __ATTRS_o_ai
4287vec_sro(vector unsigned int a, vector signed char b)
4288{
4289 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
4290}
4291
4292static vector unsigned int __ATTRS_o_ai
4293vec_sro(vector unsigned int a, vector unsigned char b)
4294{
4295 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
4296}
4297
4298static vector float __ATTRS_o_ai
4299vec_sro(vector float a, vector signed char b)
4300{
4301 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
4302}
4303
4304static vector float __ATTRS_o_ai
4305vec_sro(vector float a, vector unsigned char b)
4306{
4307 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
4308}
4309
4310/* vec_vsro */
4311
4312static vector signed char __ATTRS_o_ai
4313vec_vsro(vector signed char a, vector signed char b)
4314{
4315 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4316}
4317
4318static vector signed char __ATTRS_o_ai
4319vec_vsro(vector signed char a, vector unsigned char b)
4320{
4321 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4322}
4323
4324static vector unsigned char __ATTRS_o_ai
4325vec_vsro(vector unsigned char a, vector signed char b)
4326{
4327 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4328}
4329
4330static vector unsigned char __ATTRS_o_ai
4331vec_vsro(vector unsigned char a, vector unsigned char b)
4332{
4333 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
4334}
4335
4336static vector short __ATTRS_o_ai
4337vec_vsro(vector short a, vector signed char b)
4338{
4339 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4340}
4341
4342static vector short __ATTRS_o_ai
4343vec_vsro(vector short a, vector unsigned char b)
4344{
4345 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4346}
4347
4348static vector unsigned short __ATTRS_o_ai
4349vec_vsro(vector unsigned short a, vector signed char b)
4350{
4351 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4352}
4353
4354static vector unsigned short __ATTRS_o_ai
4355vec_vsro(vector unsigned short a, vector unsigned char b)
4356{
4357 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
4358}
4359
4360static vector int __ATTRS_o_ai
4361vec_vsro(vector int a, vector signed char b)
4362{
4363 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
4364}
4365
4366static vector int __ATTRS_o_ai
4367vec_vsro(vector int a, vector unsigned char b)
4368{
4369 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
4370}
4371
4372static vector unsigned int __ATTRS_o_ai
4373vec_vsro(vector unsigned int a, vector signed char b)
4374{
4375 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
4376}
4377
4378static vector unsigned int __ATTRS_o_ai
4379vec_vsro(vector unsigned int a, vector unsigned char b)
4380{
4381 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
4382}
4383
4384static vector float __ATTRS_o_ai
4385vec_vsro(vector float a, vector signed char b)
4386{
4387 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
4388}
4389
4390static vector float __ATTRS_o_ai
4391vec_vsro(vector float a, vector unsigned char b)
4392{
4393 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
4394}
4395
4396/* vec_st */
4397
4398static void __ATTRS_o_ai
4399vec_st(vector signed char a, int b, vector signed char *c)
4400{
4401 __builtin_altivec_stvx((vector int)a, b, c);
4402}
4403
4404static void __ATTRS_o_ai
4405vec_st(vector signed char a, int b, signed char *c)
4406{
4407 __builtin_altivec_stvx((vector int)a, b, c);
4408}
4409
4410static void __ATTRS_o_ai
4411vec_st(vector unsigned char a, int b, vector unsigned char *c)
4412{
4413 __builtin_altivec_stvx((vector int)a, b, c);
4414}
4415
4416static void __ATTRS_o_ai
4417vec_st(vector unsigned char a, int b, unsigned char *c)
4418{
4419 __builtin_altivec_stvx((vector int)a, b, c);
4420}
4421
4422static void __ATTRS_o_ai
4423vec_st(vector short a, int b, vector short *c)
4424{
4425 __builtin_altivec_stvx((vector int)a, b, c);
4426}
4427
4428static void __ATTRS_o_ai
4429vec_st(vector short a, int b, short *c)
4430{
4431 __builtin_altivec_stvx((vector int)a, b, c);
4432}
4433
4434static void __ATTRS_o_ai
4435vec_st(vector unsigned short a, int b, vector unsigned short *c)
4436{
4437 __builtin_altivec_stvx((vector int)a, b, c);
4438}
4439
4440static void __ATTRS_o_ai
4441vec_st(vector unsigned short a, int b, unsigned short *c)
4442{
4443 __builtin_altivec_stvx((vector int)a, b, c);
4444}
4445
4446static void __ATTRS_o_ai
4447vec_st(vector int a, int b, vector int *c)
4448{
4449 __builtin_altivec_stvx(a, b, c);
4450}
4451
4452static void __ATTRS_o_ai
4453vec_st(vector int a, int b, int *c)
4454{
4455 __builtin_altivec_stvx(a, b, c);
4456}
4457
4458static void __ATTRS_o_ai
4459vec_st(vector unsigned int a, int b, vector unsigned int *c)
4460{
4461 __builtin_altivec_stvx((vector int)a, b, c);
4462}
4463
4464static void __ATTRS_o_ai
4465vec_st(vector unsigned int a, int b, unsigned int *c)
4466{
4467 __builtin_altivec_stvx((vector int)a, b, c);
4468}
4469
4470static void __ATTRS_o_ai
4471vec_st(vector float a, int b, vector float *c)
4472{
4473 __builtin_altivec_stvx((vector int)a, b, c);
4474}
4475
4476static void __ATTRS_o_ai
4477vec_st(vector float a, int b, float *c)
4478{
4479 __builtin_altivec_stvx((vector int)a, b, c);
4480}
4481
4482/* vec_stvx */
4483
4484static void __ATTRS_o_ai
4485vec_stvx(vector signed char a, int b, vector signed char *c)
4486{
4487 __builtin_altivec_stvx((vector int)a, b, c);
4488}
4489
4490static void __ATTRS_o_ai
4491vec_stvx(vector signed char a, int b, signed char *c)
4492{
4493 __builtin_altivec_stvx((vector int)a, b, c);
4494}
4495
4496static void __ATTRS_o_ai
4497vec_stvx(vector unsigned char a, int b, vector unsigned char *c)
4498{
4499 __builtin_altivec_stvx((vector int)a, b, c);
4500}
4501
4502static void __ATTRS_o_ai
4503vec_stvx(vector unsigned char a, int b, unsigned char *c)
4504{
4505 __builtin_altivec_stvx((vector int)a, b, c);
4506}
4507
4508static void __ATTRS_o_ai
4509vec_stvx(vector short a, int b, vector short *c)
4510{
4511 __builtin_altivec_stvx((vector int)a, b, c);
4512}
4513
4514static void __ATTRS_o_ai
4515vec_stvx(vector short a, int b, short *c)
4516{
4517 __builtin_altivec_stvx((vector int)a, b, c);
4518}
4519
4520static void __ATTRS_o_ai
4521vec_stvx(vector unsigned short a, int b, vector unsigned short *c)
4522{
4523 __builtin_altivec_stvx((vector int)a, b, c);
4524}
4525
4526static void __ATTRS_o_ai
4527vec_stvx(vector unsigned short a, int b, unsigned short *c)
4528{
4529 __builtin_altivec_stvx((vector int)a, b, c);
4530}
4531
4532static void __ATTRS_o_ai
4533vec_stvx(vector int a, int b, vector int *c)
4534{
4535 __builtin_altivec_stvx(a, b, c);
4536}
4537
4538static void __ATTRS_o_ai
4539vec_stvx(vector int a, int b, int *c)
4540{
4541 __builtin_altivec_stvx(a, b, c);
4542}
4543
4544static void __ATTRS_o_ai
4545vec_stvx(vector unsigned int a, int b, vector unsigned int *c)
4546{
4547 __builtin_altivec_stvx((vector int)a, b, c);
4548}
4549
4550static void __ATTRS_o_ai
4551vec_stvx(vector unsigned int a, int b, unsigned int *c)
4552{
4553 __builtin_altivec_stvx((vector int)a, b, c);
4554}
4555
4556static void __ATTRS_o_ai
4557vec_stvx(vector float a, int b, vector float *c)
4558{
4559 __builtin_altivec_stvx((vector int)a, b, c);
4560}
4561
4562static void __ATTRS_o_ai
4563vec_stvx(vector float a, int b, float *c)
4564{
4565 __builtin_altivec_stvx((vector int)a, b, c);
4566}
4567
4568/* vec_ste */
4569
4570static void __ATTRS_o_ai
4571vec_ste(vector signed char a, int b, signed char *c)
4572{
4573 __builtin_altivec_stvebx((vector char)a, b, c);
4574}
4575
4576static void __ATTRS_o_ai
4577vec_ste(vector unsigned char a, int b, unsigned char *c)
4578{
4579 __builtin_altivec_stvebx((vector char)a, b, c);
4580}
4581
4582static void __ATTRS_o_ai
4583vec_ste(vector short a, int b, short *c)
4584{
4585 __builtin_altivec_stvehx(a, b, c);
4586}
4587
4588static void __ATTRS_o_ai
4589vec_ste(vector unsigned short a, int b, unsigned short *c)
4590{
4591 __builtin_altivec_stvehx((vector short)a, b, c);
4592}
4593
4594static void __ATTRS_o_ai
4595vec_ste(vector int a, int b, int *c)
4596{
4597 __builtin_altivec_stvewx(a, b, c);
4598}
4599
4600static void __ATTRS_o_ai
4601vec_ste(vector unsigned int a, int b, unsigned int *c)
4602{
4603 __builtin_altivec_stvewx((vector int)a, b, c);
4604}
4605
4606static void __ATTRS_o_ai
4607vec_ste(vector float a, int b, float *c)
4608{
4609 __builtin_altivec_stvewx((vector int)a, b, c);
4610}
4611
4612/* vec_stvebx */
4613
4614static void __ATTRS_o_ai
4615vec_stvebx(vector signed char a, int b, signed char *c)
4616{
4617 __builtin_altivec_stvebx((vector char)a, b, c);
4618}
4619
4620static void __ATTRS_o_ai
4621vec_stvebx(vector unsigned char a, int b, unsigned char *c)
4622{
4623 __builtin_altivec_stvebx((vector char)a, b, c);
4624}
4625
4626/* vec_stvehx */
4627
4628static void __ATTRS_o_ai
4629vec_stvehx(vector short a, int b, short *c)
4630{
4631 __builtin_altivec_stvehx(a, b, c);
4632}
4633
4634static void __ATTRS_o_ai
4635vec_stvehx(vector unsigned short a, int b, unsigned short *c)
4636{
4637 __builtin_altivec_stvehx((vector short)a, b, c);
4638}
4639
4640/* vec_stvewx */
4641
4642static void __ATTRS_o_ai
4643vec_stvewx(vector int a, int b, int *c)
4644{
4645 __builtin_altivec_stvewx(a, b, c);
4646}
4647
4648static void __ATTRS_o_ai
4649vec_stvewx(vector unsigned int a, int b, unsigned int *c)
4650{
4651 __builtin_altivec_stvewx((vector int)a, b, c);
4652}
4653
4654static void __ATTRS_o_ai
4655vec_stvewx(vector float a, int b, float *c)
4656{
4657 __builtin_altivec_stvewx((vector int)a, b, c);
4658}
4659
4660/* vec_stl */
4661
4662static void __ATTRS_o_ai
4663vec_stl(vector signed char a, int b, vector signed char *c)
4664{
4665 __builtin_altivec_stvxl((vector int)a, b, c);
4666}
4667
4668static void __ATTRS_o_ai
4669vec_stl(vector signed char a, int b, signed char *c)
4670{
4671 __builtin_altivec_stvxl((vector int)a, b, c);
4672}
4673
4674static void __ATTRS_o_ai
4675vec_stl(vector unsigned char a, int b, vector unsigned char *c)
4676{
4677 __builtin_altivec_stvxl((vector int)a, b, c);
4678}
4679
4680static void __ATTRS_o_ai
4681vec_stl(vector unsigned char a, int b, unsigned char *c)
4682{
4683 __builtin_altivec_stvxl((vector int)a, b, c);
4684}
4685
4686static void __ATTRS_o_ai
4687vec_stl(vector short a, int b, vector short *c)
4688{
4689 __builtin_altivec_stvxl((vector int)a, b, c);
4690}
4691
4692static void __ATTRS_o_ai
4693vec_stl(vector short a, int b, short *c)
4694{
4695 __builtin_altivec_stvxl((vector int)a, b, c);
4696}
4697
4698static void __ATTRS_o_ai
4699vec_stl(vector unsigned short a, int b, vector unsigned short *c)
4700{
4701 __builtin_altivec_stvxl((vector int)a, b, c);
4702}
4703
4704static void __ATTRS_o_ai
4705vec_stl(vector unsigned short a, int b, unsigned short *c)
4706{
4707 __builtin_altivec_stvxl((vector int)a, b, c);
4708}
4709
4710static void __ATTRS_o_ai
4711vec_stl(vector int a, int b, vector int *c)
4712{
4713 __builtin_altivec_stvxl(a, b, c);
4714}
4715
4716static void __ATTRS_o_ai
4717vec_stl(vector int a, int b, int *c)
4718{
4719 __builtin_altivec_stvxl(a, b, c);
4720}
4721
4722static void __ATTRS_o_ai
4723vec_stl(vector unsigned int a, int b, vector unsigned int *c)
4724{
4725 __builtin_altivec_stvxl((vector int)a, b, c);
4726}
4727
4728static void __ATTRS_o_ai
4729vec_stl(vector unsigned int a, int b, unsigned int *c)
4730{
4731 __builtin_altivec_stvxl((vector int)a, b, c);
4732}
4733
4734static void __ATTRS_o_ai
4735vec_stl(vector float a, int b, vector float *c)
4736{
4737 __builtin_altivec_stvxl((vector int)a, b, c);
4738}
4739
4740static void __ATTRS_o_ai
4741vec_stl(vector float a, int b, float *c)
4742{
4743 __builtin_altivec_stvxl((vector int)a, b, c);
4744}
4745
4746/* vec_stvxl */
4747
4748static void __ATTRS_o_ai
4749vec_stvxl(vector signed char a, int b, vector signed char *c)
4750{
4751 __builtin_altivec_stvxl((vector int)a, b, c);
4752}
4753
4754static void __ATTRS_o_ai
4755vec_stvxl(vector signed char a, int b, signed char *c)
4756{
4757 __builtin_altivec_stvxl((vector int)a, b, c);
4758}
4759
4760static void __ATTRS_o_ai
4761vec_stvxl(vector unsigned char a, int b, vector unsigned char *c)
4762{
4763 __builtin_altivec_stvxl((vector int)a, b, c);
4764}
4765
4766static void __ATTRS_o_ai
4767vec_stvxl(vector unsigned char a, int b, unsigned char *c)
4768{
4769 __builtin_altivec_stvxl((vector int)a, b, c);
4770}
4771
4772static void __ATTRS_o_ai
4773vec_stvxl(vector short a, int b, vector short *c)
4774{
4775 __builtin_altivec_stvxl((vector int)a, b, c);
4776}
4777
4778static void __ATTRS_o_ai
4779vec_stvxl(vector short a, int b, short *c)
4780{
4781 __builtin_altivec_stvxl((vector int)a, b, c);
4782}
4783
4784static void __ATTRS_o_ai
4785vec_stvxl(vector unsigned short a, int b, vector unsigned short *c)
4786{
4787 __builtin_altivec_stvxl((vector int)a, b, c);
4788}
4789
4790static void __ATTRS_o_ai
4791vec_stvxl(vector unsigned short a, int b, unsigned short *c)
4792{
4793 __builtin_altivec_stvxl((vector int)a, b, c);
4794}
4795
4796static void __ATTRS_o_ai
4797vec_stvxl(vector int a, int b, vector int *c)
4798{
4799 __builtin_altivec_stvxl(a, b, c);
4800}
4801
4802static void __ATTRS_o_ai
4803vec_stvxl(vector int a, int b, int *c)
4804{
4805 __builtin_altivec_stvxl(a, b, c);
4806}
4807
4808static void __ATTRS_o_ai
4809vec_stvxl(vector unsigned int a, int b, vector unsigned int *c)
4810{
4811 __builtin_altivec_stvxl((vector int)a, b, c);
4812}
4813
4814static void __ATTRS_o_ai
4815vec_stvxl(vector unsigned int a, int b, unsigned int *c)
4816{
4817 __builtin_altivec_stvxl((vector int)a, b, c);
4818}
4819
4820static void __ATTRS_o_ai
4821vec_stvxl(vector float a, int b, vector float *c)
4822{
4823 __builtin_altivec_stvxl((vector int)a, b, c);
4824}
4825
4826static void __ATTRS_o_ai
4827vec_stvxl(vector float a, int b, float *c)
4828{
4829 __builtin_altivec_stvxl((vector int)a, b, c);
4830}
4831
4832/* vec_sub */
4833
4834static vector signed char __ATTRS_o_ai
4835vec_sub(vector signed char a, vector signed char b)
4836{
4837 return a - b;
4838}
4839
4840static vector unsigned char __ATTRS_o_ai
4841vec_sub(vector unsigned char a, vector unsigned char b)
4842{
4843 return a - b;
4844}
4845
4846static vector short __ATTRS_o_ai
4847vec_sub(vector short a, vector short b)
4848{
4849 return a - b;
4850}
4851
4852static vector unsigned short __ATTRS_o_ai
4853vec_sub(vector unsigned short a, vector unsigned short b)
4854{
4855 return a - b;
4856}
4857
4858static vector int __ATTRS_o_ai
4859vec_sub(vector int a, vector int b)
4860{
4861 return a - b;
4862}
4863
4864static vector unsigned int __ATTRS_o_ai
4865vec_sub(vector unsigned int a, vector unsigned int b)
4866{
4867 return a - b;
4868}
4869
4870static vector float __ATTRS_o_ai
4871vec_sub(vector float a, vector float b)
4872{
4873 return a - b;
4874}
4875
4876/* vec_vsububm */
4877
4878#define __builtin_altivec_vsububm vec_vsububm
4879
4880static vector signed char __ATTRS_o_ai
4881vec_vsububm(vector signed char a, vector signed char b)
4882{
4883 return a - b;
4884}
4885
4886static vector unsigned char __ATTRS_o_ai
4887vec_vsububm(vector unsigned char a, vector unsigned char b)
4888{
4889 return a - b;
4890}
4891
4892/* vec_vsubuhm */
4893
4894#define __builtin_altivec_vsubuhm vec_vsubuhm
4895
4896static vector short __ATTRS_o_ai
4897vec_vsubuhm(vector short a, vector short b)
4898{
4899 return a - b;
4900}
4901
4902static vector unsigned short __ATTRS_o_ai
4903vec_vsubuhm(vector unsigned short a, vector unsigned short b)
4904{
4905 return a - b;
4906}
4907
4908/* vec_vsubuwm */
4909
4910#define __builtin_altivec_vsubuwm vec_vsubuwm
4911
4912static vector int __ATTRS_o_ai
4913vec_vsubuwm(vector int a, vector int b)
4914{
4915 return a - b;
4916}
4917
4918static vector unsigned int __ATTRS_o_ai
4919vec_vsubuwm(vector unsigned int a, vector unsigned int b)
4920{
4921 return a - b;
4922}
4923
4924/* vec_vsubfp */
4925
4926#define __builtin_altivec_vsubfp vec_vsubfp
4927
4928static vector float __attribute__((__always_inline__))
4929vec_vsubfp(vector float a, vector float b)
4930{
4931 return a - b;
4932}
4933
4934/* vec_subc */
4935
4936static vector unsigned int __attribute__((__always_inline__))
4937vec_subc(vector unsigned int a, vector unsigned int b)
4938{
4939 return __builtin_altivec_vsubcuw(a, b);
4940}
4941
4942/* vec_vsubcuw */
4943
4944static vector unsigned int __attribute__((__always_inline__))
4945vec_vsubcuw(vector unsigned int a, vector unsigned int b)
4946{
4947 return __builtin_altivec_vsubcuw(a, b);
4948}
4949
4950/* vec_subs */
4951
4952static vector signed char __ATTRS_o_ai
4953vec_subs(vector signed char a, vector signed char b)
4954{
4955 return __builtin_altivec_vsubsbs(a, b);
4956}
4957
4958static vector unsigned char __ATTRS_o_ai
4959vec_subs(vector unsigned char a, vector unsigned char b)
4960{
4961 return __builtin_altivec_vsububs(a, b);
4962}
4963
4964static vector short __ATTRS_o_ai
4965vec_subs(vector short a, vector short b)
4966{
4967 return __builtin_altivec_vsubshs(a, b);
4968}
4969
4970static vector unsigned short __ATTRS_o_ai
4971vec_subs(vector unsigned short a, vector unsigned short b)
4972{
4973 return __builtin_altivec_vsubuhs(a, b);
4974}
4975
4976static vector int __ATTRS_o_ai
4977vec_subs(vector int a, vector int b)
4978{
4979 return __builtin_altivec_vsubsws(a, b);
4980}
4981
4982static vector unsigned int __ATTRS_o_ai
4983vec_subs(vector unsigned int a, vector unsigned int b)
4984{
4985 return __builtin_altivec_vsubuws(a, b);
4986}
4987
4988/* vec_vsubsbs */
4989
4990static vector signed char __attribute__((__always_inline__))
4991vec_vsubsbs(vector signed char a, vector signed char b)
4992{
4993 return __builtin_altivec_vsubsbs(a, b);
4994}
4995
4996/* vec_vsububs */
4997
4998static vector unsigned char __attribute__((__always_inline__))
4999vec_vsububs(vector unsigned char a, vector unsigned char b)
5000{
5001 return __builtin_altivec_vsububs(a, b);
5002}
5003
5004/* vec_vsubshs */
5005
5006static vector short __attribute__((__always_inline__))
5007vec_vsubshs(vector short a, vector short b)
5008{
5009 return __builtin_altivec_vsubshs(a, b);
5010}
5011
5012/* vec_vsubuhs */
5013
5014static vector unsigned short __attribute__((__always_inline__))
5015vec_vsubuhs(vector unsigned short a, vector unsigned short b)
5016{
5017 return __builtin_altivec_vsubuhs(a, b);
5018}
5019
5020/* vec_vsubsws */
5021
5022static vector int __attribute__((__always_inline__))
5023vec_vsubsws(vector int a, vector int b)
5024{
5025 return __builtin_altivec_vsubsws(a, b);
5026}
5027
5028/* vec_vsubuws */
5029
5030static vector unsigned int __attribute__((__always_inline__))
5031vec_vsubuws(vector unsigned int a, vector unsigned int b)
5032{
5033 return __builtin_altivec_vsubuws(a, b);
5034}
5035
5036/* vec_sum4s */
5037
5038static vector int __ATTRS_o_ai
5039vec_sum4s(vector signed char a, vector int b)
5040{
5041 return __builtin_altivec_vsum4sbs(a, b);
5042}
5043
5044static vector unsigned int __ATTRS_o_ai
5045vec_sum4s(vector unsigned char a, vector unsigned int b)
5046{
5047 return __builtin_altivec_vsum4ubs(a, b);
5048}
5049
5050static vector int __ATTRS_o_ai
5051vec_sum4s(vector signed short a, vector int b)
5052{
5053 return __builtin_altivec_vsum4shs(a, b);
5054}
5055
5056/* vec_vsum4sbs */
5057
5058static vector int __attribute__((__always_inline__))
5059vec_vsum4sbs(vector signed char a, vector int b)
5060{
5061 return __builtin_altivec_vsum4sbs(a, b);
5062}
5063
5064/* vec_vsum4ubs */
5065
5066static vector unsigned int __attribute__((__always_inline__))
5067vec_vsum4ubs(vector unsigned char a, vector unsigned int b)
5068{
5069 return __builtin_altivec_vsum4ubs(a, b);
5070}
5071
5072/* vec_vsum4shs */
5073
5074static vector int __attribute__((__always_inline__))
5075vec_vsum4shs(vector signed short a, vector int b)
5076{
5077 return __builtin_altivec_vsum4shs(a, b);
5078}
5079
5080/* vec_sum2s */
5081
5082static vector signed int __attribute__((__always_inline__))
5083vec_sum2s(vector int a, vector int b)
5084{
5085 return __builtin_altivec_vsum2sws(a, b);
5086}
5087
5088/* vec_vsum2sws */
5089
5090static vector signed int __attribute__((__always_inline__))
5091vec_vsum2sws(vector int a, vector int b)
5092{
5093 return __builtin_altivec_vsum2sws(a, b);
5094}
5095
5096/* vec_sums */
5097
5098static vector signed int __attribute__((__always_inline__))
5099vec_sums(vector signed int a, vector signed int b)
5100{
5101 return __builtin_altivec_vsumsws(a, b);
5102}
5103
5104/* vec_vsumsws */
5105
5106static vector signed int __attribute__((__always_inline__))
5107vec_vsumsws(vector signed int a, vector signed int b)
5108{
5109 return __builtin_altivec_vsumsws(a, b);
5110}
5111
5112/* vec_trunc */
5113
5114static vector float __attribute__((__always_inline__))
5115vec_trunc(vector float a)
5116{
5117 return __builtin_altivec_vrfiz(a);
5118}
5119
5120/* vec_vrfiz */
5121
5122static vector float __attribute__((__always_inline__))
5123vec_vrfiz(vector float a)
5124{
5125 return __builtin_altivec_vrfiz(a);
5126}
5127
5128/* vec_unpackh */
5129
5130static vector short __ATTRS_o_ai
5131vec_unpackh(vector signed char a)
5132{
5133 return __builtin_altivec_vupkhsb((vector char)a);
5134}
5135
5136static vector int __ATTRS_o_ai
5137vec_unpackh(vector short a)
5138{
5139 return __builtin_altivec_vupkhsh(a);
5140}
5141
5142/* vec_vupkhsb */
5143
5144static vector short __attribute__((__always_inline__))
5145vec_vupkhsb(vector signed char a)
5146{
5147 return __builtin_altivec_vupkhsb((vector char)a);
5148}
5149
5150/* vec_vupkhsh */
5151
5152static vector int __attribute__((__always_inline__))
5153vec_vupkhsh(vector short a)
5154{
5155 return __builtin_altivec_vupkhsh(a);
5156}
5157
5158/* vec_unpackl */
5159
5160static vector short __ATTRS_o_ai
5161vec_unpackl(vector signed char a)
5162{
5163 return __builtin_altivec_vupklsb((vector char)a);
5164}
5165
5166static vector int __ATTRS_o_ai
5167vec_unpackl(vector short a)
5168{
5169 return __builtin_altivec_vupklsh(a);
5170}
5171
5172/* vec_vupklsb */
5173
5174static vector short __attribute__((__always_inline__))
5175vec_vupklsb(vector signed char a)
5176{
5177 return __builtin_altivec_vupklsb((vector char)a);
5178}
5179
5180/* vec_vupklsh */
5181
5182static vector int __attribute__((__always_inline__))
5183vec_vupklsh(vector short a)
5184{
5185 return __builtin_altivec_vupklsh(a);
5186}
5187
5188/* vec_xor */
5189
5190#define __builtin_altivec_vxor vec_xor
5191
5192static vector signed char __ATTRS_o_ai
5193vec_xor(vector signed char a, vector signed char b)
5194{
5195 return a ^ b;
5196}
5197
5198static vector unsigned char __ATTRS_o_ai
5199vec_xor(vector unsigned char a, vector unsigned char b)
5200{
5201 return a ^ b;
5202}
5203
5204static vector short __ATTRS_o_ai
5205vec_xor(vector short a, vector short b)
5206{
5207 return a ^ b;
5208}
5209
5210static vector unsigned short __ATTRS_o_ai
5211vec_xor(vector unsigned short a, vector unsigned short b)
5212{
5213 return a ^ b;
5214}
5215
5216static vector int __ATTRS_o_ai
5217vec_xor(vector int a, vector int b)
5218{
5219 return a ^ b;
5220}
5221
5222static vector unsigned int __ATTRS_o_ai
5223vec_xor(vector unsigned int a, vector unsigned int b)
5224{
5225 return a ^ b;
5226}
5227
5228static vector float __ATTRS_o_ai
5229vec_xor(vector float a, vector float b)
5230{
5231 vector unsigned int res = (vector unsigned int)a ^ (vector unsigned int)b;
5232 return (vector float)res;
5233}
5234
5235/* vec_vxor */
5236
5237static vector signed char __ATTRS_o_ai
5238vec_vxor(vector signed char a, vector signed char b)
5239{
5240 return a ^ b;
5241}
5242
5243static vector unsigned char __ATTRS_o_ai
5244vec_vxor(vector unsigned char a, vector unsigned char b)
5245{
5246 return a ^ b;
5247}
5248
5249static vector short __ATTRS_o_ai
5250vec_vxor(vector short a, vector short b)
5251{
5252 return a ^ b;
5253}
5254
5255static vector unsigned short __ATTRS_o_ai
5256vec_vxor(vector unsigned short a, vector unsigned short b)
5257{
5258 return a ^ b;
5259}
5260
5261static vector int __ATTRS_o_ai
5262vec_vxor(vector int a, vector int b)
5263{
5264 return a ^ b;
5265}
5266
5267static vector unsigned int __ATTRS_o_ai
5268vec_vxor(vector unsigned int a, vector unsigned int b)
5269{
5270 return a ^ b;
5271}
5272
5273static vector float __ATTRS_o_ai
5274vec_vxor(vector float a, vector float b)
5275{
5276 vector unsigned int res = (vector unsigned int)a ^ (vector unsigned int)b;
5277 return (vector float)res;
5278}
Chris Lattnerdd173942010-04-14 03:54:58 +00005279
5280/* ------------------------------ predicates ------------------------------------ */
5281
Chris Lattnerdd173942010-04-14 03:54:58 +00005282/* vec_all_eq */
5283
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005284static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005285vec_all_eq(vector signed char a, vector signed char b)
5286{
Chris Lattnerab866b42010-04-14 20:35:39 +00005287 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005288}
5289
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005290static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005291vec_all_eq(vector unsigned char a, vector unsigned char b)
5292{
Chris Lattnerab866b42010-04-14 20:35:39 +00005293 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005294}
5295
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005296static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005297vec_all_eq(vector short a, vector short b)
5298{
5299 return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b);
5300}
5301
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005302static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005303vec_all_eq(vector unsigned short a, vector unsigned short b)
5304{
Chris Lattnerab866b42010-04-14 20:35:39 +00005305 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005306}
5307
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005308static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005309vec_all_eq(vector int a, vector int b)
5310{
5311 return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b);
5312}
5313
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005314static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005315vec_all_eq(vector unsigned int a, vector unsigned int b)
5316{
Chris Lattnerab866b42010-04-14 20:35:39 +00005317 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005318}
5319
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005320static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005321vec_all_eq(vector float a, vector float b)
5322{
5323 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, b);
5324}
5325
5326/* vec_all_ge */
5327
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005328static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005329vec_all_ge(vector signed char a, vector signed char b)
5330{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005331 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005332}
5333
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005334static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005335vec_all_ge(vector unsigned char a, vector unsigned char b)
5336{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005337 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005338}
5339
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005340static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005341vec_all_ge(vector short a, vector short b)
5342{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005343 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005344}
5345
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005346static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005347vec_all_ge(vector unsigned short a, vector unsigned short b)
5348{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005349 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005350}
5351
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005352static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005353vec_all_ge(vector int a, vector int b)
5354{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005355 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005356}
5357
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005358static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005359vec_all_ge(vector unsigned int a, vector unsigned int b)
5360{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005361 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005362}
5363
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005364static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005365vec_all_ge(vector float a, vector float b)
5366{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005367 return __builtin_altivec_vcmpgefp_p(__CR6_LT, a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005368}
5369
5370/* vec_all_gt */
5371
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005372static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005373vec_all_gt(vector signed char a, vector signed char b)
5374{
5375 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b);
5376}
5377
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005378static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005379vec_all_gt(vector unsigned char a, vector unsigned char b)
5380{
5381 return __builtin_altivec_vcmpgtub_p(__CR6_LT, a, b);
5382}
5383
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005384static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005385vec_all_gt(vector short a, vector short b)
5386{
5387 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, a, b);
5388}
5389
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005390static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005391vec_all_gt(vector unsigned short a, vector unsigned short b)
5392{
5393 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, a, b);
5394}
5395
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005396static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005397vec_all_gt(vector int a, vector int b)
5398{
5399 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, a, b);
5400}
5401
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005402static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005403vec_all_gt(vector unsigned int a, vector unsigned int b)
5404{
5405 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, a, b);
5406}
5407
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005408static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005409vec_all_gt(vector float a, vector float b)
5410{
5411 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, a, b);
5412}
5413
5414/* vec_all_in */
5415
5416static int __attribute__((__always_inline__))
5417vec_all_in(vector float a, vector float b)
5418{
5419 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, a, b);
5420}
5421
5422/* vec_all_le */
5423
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005424static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005425vec_all_le(vector signed char a, vector signed char b)
5426{
5427 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b);
5428}
5429
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005430static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005431vec_all_le(vector unsigned char a, vector unsigned char b)
5432{
5433 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, a, b);
5434}
5435
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005436static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005437vec_all_le(vector short a, vector short b)
5438{
5439 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, a, b);
5440}
5441
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005442static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005443vec_all_le(vector unsigned short a, vector unsigned short b)
5444{
5445 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, a, b);
5446}
5447
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005448static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005449vec_all_le(vector int a, vector int b)
5450{
5451 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, a, b);
5452}
5453
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005454static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005455vec_all_le(vector unsigned int a, vector unsigned int b)
5456{
5457 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, a, b);
5458}
5459
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005460static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005461vec_all_le(vector float a, vector float b)
5462{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005463 return __builtin_altivec_vcmpgefp_p(__CR6_LT, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005464}
5465
5466/* vec_all_lt */
5467
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005468static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005469vec_all_lt(vector signed char a, vector signed char b)
5470{
5471 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a);
5472}
5473
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005474static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005475vec_all_lt(vector unsigned char a, vector unsigned char b)
5476{
5477 return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a);
5478}
5479
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005480static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005481vec_all_lt(vector short a, vector short b)
5482{
5483 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a);
5484}
5485
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005486static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005487vec_all_lt(vector unsigned short a, vector unsigned short b)
5488{
5489 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a);
5490}
5491
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005492static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005493vec_all_lt(vector int a, vector int b)
5494{
5495 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a);
5496}
5497
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005498static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005499vec_all_lt(vector unsigned int a, vector unsigned int b)
5500{
5501 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a);
5502}
5503
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005504static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005505vec_all_lt(vector float a, vector float b)
5506{
5507 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a);
5508}
5509
5510/* vec_all_nan */
5511
5512static int __attribute__((__always_inline__))
5513vec_all_nan(vector float a)
5514{
5515 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, a);
5516}
5517
5518/* vec_all_ne */
5519
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005520static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005521vec_all_ne(vector signed char a, vector signed char b)
5522{
Chris Lattnerab866b42010-04-14 20:35:39 +00005523 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005524}
5525
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005526static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005527vec_all_ne(vector unsigned char a, vector unsigned char b)
5528{
Chris Lattnerab866b42010-04-14 20:35:39 +00005529 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005530}
5531
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005532static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005533vec_all_ne(vector short a, vector short b)
5534{
5535 return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b);
5536}
5537
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005538static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005539vec_all_ne(vector unsigned short a, vector unsigned short b)
5540{
Chris Lattnerab866b42010-04-14 20:35:39 +00005541 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005542}
5543
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005544static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005545vec_all_ne(vector int a, vector int b)
5546{
5547 return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b);
5548}
5549
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005550static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005551vec_all_ne(vector unsigned int a, vector unsigned int b)
5552{
Chris Lattnerab866b42010-04-14 20:35:39 +00005553 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005554}
5555
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005556static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005557vec_all_ne(vector float a, vector float b)
5558{
5559 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, b);
5560}
5561
5562/* vec_all_nge */
5563
5564static int __attribute__((__always_inline__))
5565vec_all_nge(vector float a, vector float b)
5566{
5567 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, a, b);
5568}
5569
5570/* vec_all_ngt */
5571
5572static int __attribute__((__always_inline__))
5573vec_all_ngt(vector float a, vector float b)
5574{
5575 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b);
5576}
5577
5578/* vec_all_nle */
5579
5580static int __attribute__((__always_inline__))
5581vec_all_nle(vector float a, vector float b)
5582{
5583 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, b, a);
5584}
5585
5586/* vec_all_nlt */
5587
5588static int __attribute__((__always_inline__))
5589vec_all_nlt(vector float a, vector float b)
5590{
5591 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, b, a);
5592}
5593
5594/* vec_all_numeric */
5595
5596static int __attribute__((__always_inline__))
5597vec_all_numeric(vector float a)
5598{
5599 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, a);
5600}
5601
5602/* vec_any_eq */
5603
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005604static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005605vec_any_eq(vector signed char a, vector signed char b)
5606{
Chris Lattnerab866b42010-04-14 20:35:39 +00005607 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005608}
5609
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005610static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005611vec_any_eq(vector unsigned char a, vector unsigned char b)
5612{
Chris Lattnerab866b42010-04-14 20:35:39 +00005613 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005614}
5615
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005616static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005617vec_any_eq(vector short a, vector short b)
5618{
5619 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b);
5620}
5621
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005622static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005623vec_any_eq(vector unsigned short a, vector unsigned short b)
5624{
Chris Lattnerab866b42010-04-14 20:35:39 +00005625 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005626}
5627
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005628static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005629vec_any_eq(vector int a, vector int b)
5630{
5631 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b);
5632}
5633
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005634static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005635vec_any_eq(vector unsigned int a, vector unsigned int b)
5636{
Chris Lattnerab866b42010-04-14 20:35:39 +00005637 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005638}
5639
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005640static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005641vec_any_eq(vector float a, vector float b)
5642{
5643 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, b);
5644}
5645
5646/* vec_any_ge */
5647
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005648static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005649vec_any_ge(vector signed char a, vector signed char b)
5650{
5651 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a);
5652}
5653
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005654static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005655vec_any_ge(vector unsigned char a, vector unsigned char b)
5656{
5657 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, b, a);
5658}
5659
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005660static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005661vec_any_ge(vector short a, vector short b)
5662{
5663 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, b, a);
5664}
5665
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005666static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005667vec_any_ge(vector unsigned short a, vector unsigned short b)
5668{
5669 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, b, a);
5670}
5671
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005672static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005673vec_any_ge(vector int a, vector int b)
5674{
5675 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, b, a);
5676}
5677
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005678static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005679vec_any_ge(vector unsigned int a, vector unsigned int b)
5680{
5681 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, b, a);
5682}
5683
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005684static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005685vec_any_ge(vector float a, vector float b)
5686{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005687 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005688}
5689
5690/* vec_any_gt */
5691
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005692static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005693vec_any_gt(vector signed char a, vector signed char b)
5694{
5695 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b);
5696}
5697
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005698static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005699vec_any_gt(vector unsigned char a, vector unsigned char b)
5700{
5701 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, a, b);
5702}
5703
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005704static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005705vec_any_gt(vector short a, vector short b)
5706{
5707 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, a, b);
5708}
5709
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005710static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005711vec_any_gt(vector unsigned short a, vector unsigned short b)
5712{
5713 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, a, b);
5714}
5715
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005716static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005717vec_any_gt(vector int a, vector int b)
5718{
5719 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, a, b);
5720}
5721
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005722static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005723vec_any_gt(vector unsigned int a, vector unsigned int b)
5724{
5725 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, a, b);
5726}
5727
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005728static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005729vec_any_gt(vector float a, vector float b)
5730{
5731 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, a, b);
5732}
5733
5734/* vec_any_le */
5735
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005736static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005737vec_any_le(vector signed char a, vector signed char b)
5738{
5739 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b);
5740}
5741
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005742static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005743vec_any_le(vector unsigned char a, vector unsigned char b)
5744{
5745 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, a, b);
5746}
5747
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005748static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005749vec_any_le(vector short a, vector short b)
5750{
5751 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, a, b);
5752}
5753
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005754static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005755vec_any_le(vector unsigned short a, vector unsigned short b)
5756{
5757 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, a, b);
5758}
5759
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005760static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005761vec_any_le(vector int a, vector int b)
5762{
5763 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, a, b);
5764}
5765
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005766static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005767vec_any_le(vector unsigned int a, vector unsigned int b)
5768{
5769 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, a, b);
5770}
5771
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005772static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005773vec_any_le(vector float a, vector float b)
5774{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005775 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00005776}
5777
5778/* vec_any_lt */
5779
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005780static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005781vec_any_lt(vector signed char a, vector signed char b)
5782{
5783 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a);
5784}
5785
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005786static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005787vec_any_lt(vector unsigned char a, vector unsigned char b)
5788{
5789 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, b, a);
5790}
5791
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005792static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005793vec_any_lt(vector short a, vector short b)
5794{
5795 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, b, a);
5796}
5797
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005798static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005799vec_any_lt(vector unsigned short a, vector unsigned short b)
5800{
5801 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, b, a);
5802}
5803
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005804static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005805vec_any_lt(vector int a, vector int b)
5806{
5807 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, b, a);
5808}
5809
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005810static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005811vec_any_lt(vector unsigned int a, vector unsigned int b)
5812{
5813 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, b, a);
5814}
5815
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005816static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005817vec_any_lt(vector float a, vector float b)
5818{
5819 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, b, a);
5820}
5821
5822/* vec_any_nan */
5823
5824static int __attribute__((__always_inline__))
5825vec_any_nan(vector float a)
5826{
5827 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, a);
5828}
5829
5830/* vec_any_ne */
5831
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005832static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005833vec_any_ne(vector signed char a, vector signed char b)
5834{
Chris Lattnerab866b42010-04-14 20:35:39 +00005835 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005836}
5837
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005838static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005839vec_any_ne(vector unsigned char a, vector unsigned char b)
5840{
Chris Lattnerab866b42010-04-14 20:35:39 +00005841 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005842}
5843
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005844static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005845vec_any_ne(vector short a, vector short b)
5846{
5847 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b);
5848}
5849
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005850static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005851vec_any_ne(vector unsigned short a, vector unsigned short b)
5852{
Chris Lattnerab866b42010-04-14 20:35:39 +00005853 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005854}
5855
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005856static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005857vec_any_ne(vector int a, vector int b)
5858{
5859 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b);
5860}
5861
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005862static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005863vec_any_ne(vector unsigned int a, vector unsigned int b)
5864{
Chris Lattnerab866b42010-04-14 20:35:39 +00005865 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00005866}
5867
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005868static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005869vec_any_ne(vector float a, vector float b)
5870{
5871 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, b);
5872}
5873
5874/* vec_any_nge */
5875
5876static int __attribute__((__always_inline__))
5877vec_any_nge(vector float a, vector float b)
5878{
5879 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, a, b);
5880}
5881
5882/* vec_any_ngt */
5883
5884static int __attribute__((__always_inline__))
5885vec_any_ngt(vector float a, vector float b)
5886{
5887 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b);
5888}
5889
5890/* vec_any_nle */
5891
5892static int __attribute__((__always_inline__))
5893vec_any_nle(vector float a, vector float b)
5894{
5895 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, b, a);
5896}
5897
5898/* vec_any_nlt */
5899
5900static int __attribute__((__always_inline__))
5901vec_any_nlt(vector float a, vector float b)
5902{
5903 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a);
5904}
5905
5906/* vec_any_numeric */
5907
5908static int __attribute__((__always_inline__))
5909vec_any_numeric(vector float a)
5910{
5911 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, a);
5912}
5913
5914/* vec_any_out */
5915
5916static int __attribute__((__always_inline__))
5917vec_any_out(vector float a, vector float b)
5918{
5919 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, a, b);
5920}
5921
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00005922#undef __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00005923
5924#endif /* __ALTIVEC_H */