blob: 1350eb5bd1ff16393987a844404c472481f5e50b [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
Anton Yartsevf54dbfd2010-08-19 03:00:09 +000048static vector bool char __ATTRS_o_ai
49vec_perm(vector bool char a, vector bool char b, vector unsigned char c);
50
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000051static vector short __ATTRS_o_ai
52vec_perm(vector short a, vector short b, vector unsigned char c);
53
54static vector unsigned short __ATTRS_o_ai
55vec_perm(vector unsigned short a, vector unsigned short b, vector unsigned char c);
56
Anton Yartsevf54dbfd2010-08-19 03:00:09 +000057static vector bool short __ATTRS_o_ai
58vec_perm(vector bool short a, vector bool short b, vector unsigned char c);
59
60static vector pixel __ATTRS_o_ai
61vec_perm(vector pixel a, vector pixel b, vector unsigned char c);
62
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000063static vector int __ATTRS_o_ai
64vec_perm(vector int a, vector int b, vector unsigned char c);
65
66static vector unsigned int __ATTRS_o_ai
67vec_perm(vector unsigned int a, vector unsigned int b, vector unsigned char c);
68
Anton Yartsevf54dbfd2010-08-19 03:00:09 +000069static vector bool int __ATTRS_o_ai
70vec_perm(vector bool int a, vector bool int b, vector unsigned char c);
71
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000072static vector float __ATTRS_o_ai
73vec_perm(vector float a, vector float b, vector unsigned char c);
Chris Lattnerdd173942010-04-14 03:54:58 +000074
75/* vec_abs */
76
Chris Lattnerdd173942010-04-14 03:54:58 +000077#define __builtin_altivec_abs_v16qi vec_abs
78#define __builtin_altivec_abs_v8hi vec_abs
79#define __builtin_altivec_abs_v4si vec_abs
80
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000081static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000082vec_abs(vector signed char a)
83{
84 return __builtin_altivec_vmaxsb(a, -a);
85}
86
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000087static vector signed short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000088vec_abs(vector signed short a)
89{
90 return __builtin_altivec_vmaxsh(a, -a);
91}
92
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000093static vector signed int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +000094vec_abs(vector signed int a)
95{
96 return __builtin_altivec_vmaxsw(a, -a);
97}
98
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +000099static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000100vec_abs(vector float a)
101{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000102 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)(0x7FFFFFFF);
Chris Lattnerab866b42010-04-14 20:35:39 +0000103 return (vector float)res;
Chris Lattnerdd173942010-04-14 03:54:58 +0000104}
105
106/* vec_abss */
107
Chris Lattnerdd173942010-04-14 03:54:58 +0000108#define __builtin_altivec_abss_v16qi vec_abss
109#define __builtin_altivec_abss_v8hi vec_abss
110#define __builtin_altivec_abss_v4si vec_abss
111
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000112static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000113vec_abss(vector signed char a)
114{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000115 return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs((vector signed char)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000116}
117
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000118static vector signed short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000119vec_abss(vector signed short a)
120{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000121 return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs((vector signed short)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000122}
123
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000124static vector signed int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000125vec_abss(vector signed int a)
126{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000127 return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws((vector signed int)(0), a));
Chris Lattnerdd173942010-04-14 03:54:58 +0000128}
129
130/* vec_add */
131
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000132static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000133vec_add(vector signed char a, vector signed char b)
134{
135 return a + b;
136}
137
Anton Yartsev05e35552010-08-16 16:22:12 +0000138static vector signed char __ATTRS_o_ai
139vec_add(vector bool char a, vector signed char b)
140{
141 return (vector signed char)a + b;
142}
143
144static vector signed char __ATTRS_o_ai
145vec_add(vector signed char a, vector bool char b)
146{
147 return a + (vector signed char)b;
148}
149
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000150static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000151vec_add(vector unsigned char a, vector unsigned char b)
152{
153 return a + b;
154}
155
Anton Yartsev05e35552010-08-16 16:22:12 +0000156static vector unsigned char __ATTRS_o_ai
157vec_add(vector bool char a, vector unsigned char b)
158{
159 return (vector unsigned char)a + b;
160}
161
162static vector unsigned char __ATTRS_o_ai
163vec_add(vector unsigned char a, vector bool char b)
164{
165 return a + (vector unsigned char)b;
166}
167
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000168static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000169vec_add(vector short a, vector short b)
170{
171 return a + b;
172}
173
Anton Yartsev05e35552010-08-16 16:22:12 +0000174static vector short __ATTRS_o_ai
175vec_add(vector bool short a, vector short b)
176{
177 return (vector short)a + b;
178}
179
180static vector short __ATTRS_o_ai
181vec_add(vector short a, vector bool short b)
182{
183 return a + (vector short)b;
184}
185
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000186static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000187vec_add(vector unsigned short a, vector unsigned short b)
188{
189 return a + b;
190}
191
Anton Yartsev05e35552010-08-16 16:22:12 +0000192static vector unsigned short __ATTRS_o_ai
193vec_add(vector bool short a, vector unsigned short b)
194{
195 return (vector unsigned short)a + b;
196}
197
198static vector unsigned short __ATTRS_o_ai
199vec_add(vector unsigned short a, vector bool short b)
200{
201 return a + (vector unsigned short)b;
202}
203
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000204static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000205vec_add(vector int a, vector int b)
206{
207 return a + b;
208}
209
Anton Yartsev05e35552010-08-16 16:22:12 +0000210static vector int __ATTRS_o_ai
211vec_add(vector bool int a, vector int b)
212{
213 return (vector int)a + b;
214}
215
216static vector int __ATTRS_o_ai
217vec_add(vector int a, vector bool int b)
218{
219 return a + (vector int)b;
220}
221
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000222static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000223vec_add(vector unsigned int a, vector unsigned int b)
224{
225 return a + b;
226}
227
Anton Yartsev05e35552010-08-16 16:22:12 +0000228static vector unsigned int __ATTRS_o_ai
229vec_add(vector bool int a, vector unsigned int b)
230{
231 return (vector unsigned int)a + b;
232}
233
234static vector unsigned int __ATTRS_o_ai
235vec_add(vector unsigned int a, vector bool int b)
236{
237 return a + (vector unsigned int)b;
238}
239
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000240static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000241vec_add(vector float a, vector float b)
242{
243 return a + b;
244}
245
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000246/* vec_vaddubm */
247
248#define __builtin_altivec_vaddubm vec_vaddubm
249
250static vector signed char __ATTRS_o_ai
251vec_vaddubm(vector signed char a, vector signed char b)
252{
253 return a + b;
254}
255
Anton Yartsev05e35552010-08-16 16:22:12 +0000256static vector signed char __ATTRS_o_ai
257vec_vaddubm(vector bool char a, vector signed char b)
258{
259 return (vector signed char)a + b;
260}
261
262static vector signed char __ATTRS_o_ai
263vec_vaddubm(vector signed char a, vector bool char b)
264{
265 return a + (vector signed char)b;
266}
267
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000268static vector unsigned char __ATTRS_o_ai
269vec_vaddubm(vector unsigned char a, vector unsigned char b)
270{
271 return a + b;
272}
273
Anton Yartsev05e35552010-08-16 16:22:12 +0000274static vector unsigned char __ATTRS_o_ai
275vec_vaddubm(vector bool char a, vector unsigned char b)
276{
277 return (vector unsigned char)a + b;
278}
279
280static vector unsigned char __ATTRS_o_ai
281vec_vaddubm(vector unsigned char a, vector bool char b)
282{
283 return a + (vector unsigned char)b;
284}
285
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000286/* vec_vadduhm */
287
288#define __builtin_altivec_vadduhm vec_vadduhm
289
290static vector short __ATTRS_o_ai
291vec_vadduhm(vector short a, vector short b)
292{
293 return a + b;
294}
295
Anton Yartsev05e35552010-08-16 16:22:12 +0000296static vector short __ATTRS_o_ai
297vec_vadduhm(vector bool short a, vector short b)
298{
299 return (vector short)a + b;
300}
301
302static vector short __ATTRS_o_ai
303vec_vadduhm(vector short a, vector bool short b)
304{
305 return a + (vector short)b;
306}
307
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000308static vector unsigned short __ATTRS_o_ai
309vec_vadduhm(vector unsigned short a, vector unsigned short b)
310{
311 return a + b;
312}
313
Anton Yartsev05e35552010-08-16 16:22:12 +0000314static vector unsigned short __ATTRS_o_ai
315vec_vadduhm(vector bool short a, vector unsigned short b)
316{
317 return (vector unsigned short)a + b;
318}
319
320static vector unsigned short __ATTRS_o_ai
321vec_vadduhm(vector unsigned short a, vector bool short b)
322{
323 return a + (vector unsigned short)b;
324}
325
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000326/* vec_vadduwm */
327
328#define __builtin_altivec_vadduwm vec_vadduwm
329
330static vector int __ATTRS_o_ai
331vec_vadduwm(vector int a, vector int b)
332{
333 return a + b;
334}
335
Anton Yartsev05e35552010-08-16 16:22:12 +0000336static vector int __ATTRS_o_ai
337vec_vadduwm(vector bool int a, vector int b)
338{
339 return (vector int)a + b;
340}
341
342static vector int __ATTRS_o_ai
343vec_vadduwm(vector int a, vector bool int b)
344{
345 return a + (vector int)b;
346}
347
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000348static vector unsigned int __ATTRS_o_ai
349vec_vadduwm(vector unsigned int a, vector unsigned int b)
350{
351 return a + b;
352}
353
Anton Yartsev05e35552010-08-16 16:22:12 +0000354static vector unsigned int __ATTRS_o_ai
355vec_vadduwm(vector bool int a, vector unsigned int b)
356{
357 return (vector unsigned int)a + b;
358}
359
360static vector unsigned int __ATTRS_o_ai
361vec_vadduwm(vector unsigned int a, vector bool int b)
362{
363 return a + (vector unsigned int)b;
364}
365
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000366/* vec_vaddfp */
367
368#define __builtin_altivec_vaddfp vec_vaddfp
369
370static vector float __attribute__((__always_inline__))
371vec_vaddfp(vector float a, vector float b)
372{
373 return a + b;
374}
375
Chris Lattnerdd173942010-04-14 03:54:58 +0000376/* vec_addc */
377
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000378static vector unsigned int __attribute__((__always_inline__))
379vec_addc(vector unsigned int a, vector unsigned int b)
380{
381 return __builtin_altivec_vaddcuw(a, b);
382}
383
384/* vec_vaddcuw */
385
386static vector unsigned int __attribute__((__always_inline__))
387vec_vaddcuw(vector unsigned int a, vector unsigned int b)
388{
389 return __builtin_altivec_vaddcuw(a, b);
390}
Chris Lattnerdd173942010-04-14 03:54:58 +0000391
392/* vec_adds */
393
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000394static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000395vec_adds(vector signed char a, vector signed char b)
396{
397 return __builtin_altivec_vaddsbs(a, b);
398}
399
Anton Yartsev05e35552010-08-16 16:22:12 +0000400static vector signed char __ATTRS_o_ai
401vec_adds(vector bool char a, vector signed char b)
402{
403 return __builtin_altivec_vaddsbs((vector signed char)a, b);
404}
405
406static vector signed char __ATTRS_o_ai
407vec_adds(vector signed char a, vector bool char b)
408{
409 return __builtin_altivec_vaddsbs(a, (vector signed char)b);
410}
411
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000412static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000413vec_adds(vector unsigned char a, vector unsigned char b)
414{
415 return __builtin_altivec_vaddubs(a, b);
416}
417
Anton Yartsev05e35552010-08-16 16:22:12 +0000418static vector unsigned char __ATTRS_o_ai
419vec_adds(vector bool char a, vector unsigned char b)
420{
421 return __builtin_altivec_vaddubs((vector unsigned char)a, b);
422}
423
424static vector unsigned char __ATTRS_o_ai
425vec_adds(vector unsigned char a, vector bool char b)
426{
427 return __builtin_altivec_vaddubs(a, (vector unsigned char)b);
428}
429
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000430static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000431vec_adds(vector short a, vector short b)
432{
433 return __builtin_altivec_vaddshs(a, b);
434}
435
Anton Yartsev05e35552010-08-16 16:22:12 +0000436static vector short __ATTRS_o_ai
437vec_adds(vector bool short a, vector short b)
438{
439 return __builtin_altivec_vaddshs((vector short)a, b);
440}
441
442static vector short __ATTRS_o_ai
443vec_adds(vector short a, vector bool short b)
444{
445 return __builtin_altivec_vaddshs(a, (vector short)b);
446}
447
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000448static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000449vec_adds(vector unsigned short a, vector unsigned short b)
450{
451 return __builtin_altivec_vadduhs(a, b);
452}
453
Anton Yartsev05e35552010-08-16 16:22:12 +0000454static vector unsigned short __ATTRS_o_ai
455vec_adds(vector bool short a, vector unsigned short b)
456{
457 return __builtin_altivec_vadduhs((vector unsigned short)a, b);
458}
459
460static vector unsigned short __ATTRS_o_ai
461vec_adds(vector unsigned short a, vector bool short b)
462{
463 return __builtin_altivec_vadduhs(a, (vector unsigned short)b);
464}
465
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000466static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000467vec_adds(vector int a, vector int b)
468{
469 return __builtin_altivec_vaddsws(a, b);
470}
471
Anton Yartsev05e35552010-08-16 16:22:12 +0000472static vector int __ATTRS_o_ai
473vec_adds(vector bool int a, vector int b)
474{
475 return __builtin_altivec_vaddsws((vector int)a, b);
476}
477
478static vector int __ATTRS_o_ai
479vec_adds(vector int a, vector bool int b)
480{
481 return __builtin_altivec_vaddsws(a, (vector int)b);
482}
483
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000484static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +0000485vec_adds(vector unsigned int a, vector unsigned int b)
486{
487 return __builtin_altivec_vadduws(a, b);
488}
489
Anton Yartsev05e35552010-08-16 16:22:12 +0000490static vector unsigned int __ATTRS_o_ai
491vec_adds(vector bool int a, vector unsigned int b)
492{
493 return __builtin_altivec_vadduws((vector unsigned int)a, b);
494}
495
496static vector unsigned int __ATTRS_o_ai
497vec_adds(vector unsigned int a, vector bool int b)
498{
499 return __builtin_altivec_vadduws(a, (vector unsigned int)b);
500}
501
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000502/* vec_vaddsbs */
Chris Lattnerdd173942010-04-14 03:54:58 +0000503
Anton Yartsev05e35552010-08-16 16:22:12 +0000504static vector signed char __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000505vec_vaddsbs(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000506{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000507 return __builtin_altivec_vaddsbs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000508}
509
Anton Yartsev05e35552010-08-16 16:22:12 +0000510static vector signed char __ATTRS_o_ai
511vec_vaddsbs(vector bool char a, vector signed char b)
512{
513 return __builtin_altivec_vaddsbs((vector signed char)a, b);
514}
515
516static vector signed char __ATTRS_o_ai
517vec_vaddsbs(vector signed char a, vector bool char b)
518{
519 return __builtin_altivec_vaddsbs(a, (vector signed char)b);
520}
521
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000522/* vec_vaddubs */
523
Anton Yartsev05e35552010-08-16 16:22:12 +0000524static vector unsigned char __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000525vec_vaddubs(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000526{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000527 return __builtin_altivec_vaddubs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000528}
529
Anton Yartsev05e35552010-08-16 16:22:12 +0000530static vector unsigned char __ATTRS_o_ai
531vec_vaddubs(vector bool char a, vector unsigned char b)
532{
533 return __builtin_altivec_vaddubs((vector unsigned char)a, b);
534}
535
536static vector unsigned char __ATTRS_o_ai
537vec_vaddubs(vector unsigned char a, vector bool char b)
538{
539 return __builtin_altivec_vaddubs(a, (vector unsigned char)b);
540}
541
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000542/* vec_vaddshs */
543
Anton Yartsev05e35552010-08-16 16:22:12 +0000544static vector short __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000545vec_vaddshs(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000546{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000547 return __builtin_altivec_vaddshs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000548}
549
Anton Yartsev05e35552010-08-16 16:22:12 +0000550static vector short __ATTRS_o_ai
551vec_vaddshs(vector bool short a, vector short b)
552{
553 return __builtin_altivec_vaddshs((vector short)a, b);
554}
555
556static vector short __ATTRS_o_ai
557vec_vaddshs(vector short a, vector bool short b)
558{
559 return __builtin_altivec_vaddshs(a, (vector short)b);
560}
561
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000562/* vec_vadduhs */
563
Anton Yartsev05e35552010-08-16 16:22:12 +0000564static vector unsigned short __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000565vec_vadduhs(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000566{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000567 return __builtin_altivec_vadduhs(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000568}
569
Anton Yartsev05e35552010-08-16 16:22:12 +0000570static vector unsigned short __ATTRS_o_ai
571vec_vadduhs(vector bool short a, vector unsigned short b)
572{
573 return __builtin_altivec_vadduhs((vector unsigned short)a, b);
574}
575
576static vector unsigned short __ATTRS_o_ai
577vec_vadduhs(vector unsigned short a, vector bool short b)
578{
579 return __builtin_altivec_vadduhs(a, (vector unsigned short)b);
580}
581
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000582/* vec_vaddsws */
583
Anton Yartsev05e35552010-08-16 16:22:12 +0000584static vector int __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000585vec_vaddsws(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000586{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000587 return __builtin_altivec_vaddsws(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000588}
589
Anton Yartsev05e35552010-08-16 16:22:12 +0000590static vector int __ATTRS_o_ai
591vec_vaddsws(vector bool int a, vector int b)
592{
593 return __builtin_altivec_vaddsws((vector int)a, b);
594}
595
596static vector int __ATTRS_o_ai
597vec_vaddsws(vector int a, vector bool int b)
598{
599 return __builtin_altivec_vaddsws(a, (vector int)b);
600}
601
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000602/* vec_vadduws */
603
Anton Yartsev05e35552010-08-16 16:22:12 +0000604static vector unsigned int __ATTRS_o_ai
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000605vec_vadduws(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000606{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000607 return __builtin_altivec_vadduws(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +0000608}
609
Anton Yartsev05e35552010-08-16 16:22:12 +0000610static vector unsigned int __ATTRS_o_ai
611vec_vadduws(vector bool int a, vector unsigned int b)
612{
613 return __builtin_altivec_vadduws((vector unsigned int)a, b);
614}
615
616static vector unsigned int __ATTRS_o_ai
617vec_vadduws(vector unsigned int a, vector bool int b)
618{
619 return __builtin_altivec_vadduws(a, (vector unsigned int)b);
620}
621
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000622/* vec_and */
623
624#define __builtin_altivec_vand vec_and
625
626static vector signed char __ATTRS_o_ai
627vec_and(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000628{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000629 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000630}
631
Anton Yartsev05e35552010-08-16 16:22:12 +0000632static vector signed char __ATTRS_o_ai
633vec_and(vector bool char a, vector signed char b)
634{
635 return (vector signed char)a & b;
636}
637
638static vector signed char __ATTRS_o_ai
639vec_and(vector signed char a, vector bool char b)
640{
641 return a & (vector signed char)b;
642}
643
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000644static vector unsigned char __ATTRS_o_ai
645vec_and(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000646{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000647 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000648}
649
Anton Yartsev05e35552010-08-16 16:22:12 +0000650static vector unsigned char __ATTRS_o_ai
651vec_and(vector bool char a, vector unsigned char b)
652{
653 return (vector unsigned char)a & b;
654}
655
656static vector unsigned char __ATTRS_o_ai
657vec_and(vector unsigned char a, vector bool char b)
658{
659 return a & (vector unsigned char)b;
660}
661
662static vector bool char __ATTRS_o_ai
663vec_and(vector bool char a, vector bool char b)
664{
665 return a & b;
666}
667
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000668static vector short __ATTRS_o_ai
669vec_and(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000670{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000671 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000672}
673
Anton Yartsev05e35552010-08-16 16:22:12 +0000674static vector short __ATTRS_o_ai
675vec_and(vector bool short a, vector short b)
676{
677 return (vector short)a & b;
678}
679
680static vector short __ATTRS_o_ai
681vec_and(vector short a, vector bool short b)
682{
683 return a & (vector short)b;
684}
685
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000686static vector unsigned short __ATTRS_o_ai
687vec_and(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000688{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000689 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000690}
691
Anton Yartsev05e35552010-08-16 16:22:12 +0000692static vector unsigned short __ATTRS_o_ai
693vec_and(vector bool short a, vector unsigned short b)
694{
695 return (vector unsigned short)a & b;
696}
697
698static vector unsigned short __ATTRS_o_ai
699vec_and(vector unsigned short a, vector bool short b)
700{
701 return a & (vector unsigned short)b;
702}
703
704static vector bool short __ATTRS_o_ai
705vec_and(vector bool short a, vector bool short b)
706{
707 return a & b;
708}
709
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000710static vector int __ATTRS_o_ai
711vec_and(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000712{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000713 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000714}
715
Anton Yartsev05e35552010-08-16 16:22:12 +0000716static vector int __ATTRS_o_ai
717vec_and(vector bool int a, vector int b)
718{
719 return (vector int)a & b;
720}
721
722static vector int __ATTRS_o_ai
723vec_and(vector int a, vector bool int b)
724{
725 return a & (vector int)b;
726}
727
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000728static vector unsigned int __ATTRS_o_ai
729vec_and(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000730{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000731 return a & b;
Chris Lattnerdd173942010-04-14 03:54:58 +0000732}
733
Anton Yartsev05e35552010-08-16 16:22:12 +0000734static vector unsigned int __ATTRS_o_ai
735vec_and(vector bool int a, vector unsigned int b)
736{
737 return (vector unsigned int)a & b;
738}
739
740static vector unsigned int __ATTRS_o_ai
741vec_and(vector unsigned int a, vector bool int b)
742{
743 return a & (vector unsigned int)b;
744}
745
746static vector bool int __ATTRS_o_ai
747vec_and(vector bool int a, vector bool int b)
748{
749 return a & b;
750}
751
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000752static vector float __ATTRS_o_ai
753vec_and(vector float a, vector float b)
Chris Lattnerdd173942010-04-14 03:54:58 +0000754{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000755 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
756 return (vector float)res;
757}
758
Anton Yartsev05e35552010-08-16 16:22:12 +0000759static vector float __ATTRS_o_ai
760vec_and(vector bool int a, vector float b)
761{
762 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
763 return (vector float)res;
764}
765
766static vector float __ATTRS_o_ai
767vec_and(vector float a, vector bool int b)
768{
769 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
770 return (vector float)res;
771}
772
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000773/* vec_vand */
774
775static vector signed char __ATTRS_o_ai
776vec_vand(vector signed char a, vector signed char b)
777{
778 return a & b;
779}
780
Anton Yartsev05e35552010-08-16 16:22:12 +0000781static vector signed char __ATTRS_o_ai
782vec_vand(vector bool char a, vector signed char b)
783{
784 return (vector signed char)a & b;
785}
786
787static vector signed char __ATTRS_o_ai
788vec_vand(vector signed char a, vector bool char b)
789{
790 return a & (vector signed char)b;
791}
792
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000793static vector unsigned char __ATTRS_o_ai
794vec_vand(vector unsigned char a, vector unsigned char b)
795{
796 return a & b;
797}
798
Anton Yartsev05e35552010-08-16 16:22:12 +0000799static vector unsigned char __ATTRS_o_ai
800vec_vand(vector bool char a, vector unsigned char b)
801{
802 return (vector unsigned char)a & b;
803}
804
805static vector unsigned char __ATTRS_o_ai
806vec_vand(vector unsigned char a, vector bool char b)
807{
808 return a & (vector unsigned char)b;
809}
810
811static vector bool char __ATTRS_o_ai
812vec_vand(vector bool char a, vector bool char b)
813{
814 return a & b;
815}
816
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000817static vector short __ATTRS_o_ai
818vec_vand(vector short a, vector short b)
819{
820 return a & b;
821}
822
Anton Yartsev05e35552010-08-16 16:22:12 +0000823static vector short __ATTRS_o_ai
824vec_vand(vector bool short a, vector short b)
825{
826 return (vector short)a & b;
827}
828
829static vector short __ATTRS_o_ai
830vec_vand(vector short a, vector bool short b)
831{
832 return a & (vector short)b;
833}
834
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000835static vector unsigned short __ATTRS_o_ai
836vec_vand(vector unsigned short a, vector unsigned short b)
837{
838 return a & b;
839}
840
Anton Yartsev05e35552010-08-16 16:22:12 +0000841static vector unsigned short __ATTRS_o_ai
842vec_vand(vector bool short a, vector unsigned short b)
843{
844 return (vector unsigned short)a & b;
845}
846
847static vector unsigned short __ATTRS_o_ai
848vec_vand(vector unsigned short a, vector bool short b)
849{
850 return a & (vector unsigned short)b;
851}
852
853static vector bool short __ATTRS_o_ai
854vec_vand(vector bool short a, vector bool short b)
855{
856 return a & b;
857}
858
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000859static vector int __ATTRS_o_ai
860vec_vand(vector int a, vector int b)
861{
862 return a & b;
863}
864
Anton Yartsev05e35552010-08-16 16:22:12 +0000865static vector int __ATTRS_o_ai
866vec_vand(vector bool int a, vector int b)
867{
868 return (vector int)a & b;
869}
870
871static vector int __ATTRS_o_ai
872vec_vand(vector int a, vector bool int b)
873{
874 return a & (vector int)b;
875}
876
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000877static vector unsigned int __ATTRS_o_ai
878vec_vand(vector unsigned int a, vector unsigned int b)
879{
880 return a & b;
881}
882
Anton Yartsev05e35552010-08-16 16:22:12 +0000883static vector unsigned int __ATTRS_o_ai
884vec_vand(vector bool int a, vector unsigned int b)
885{
886 return (vector unsigned int)a & b;
887}
888
889static vector unsigned int __ATTRS_o_ai
890vec_vand(vector unsigned int a, vector bool int b)
891{
892 return a & (vector unsigned int)b;
893}
894
895static vector bool int __ATTRS_o_ai
896vec_vand(vector bool int a, vector bool int b)
897{
898 return a & b;
899}
900
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000901static vector float __ATTRS_o_ai
902vec_vand(vector float a, vector float b)
903{
904 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
905 return (vector float)res;
906}
907
Anton Yartsev05e35552010-08-16 16:22:12 +0000908static vector float __ATTRS_o_ai
909vec_vand(vector bool int a, vector float b)
910{
911 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
912 return (vector float)res;
913}
914
915static vector float __ATTRS_o_ai
916vec_vand(vector float a, vector bool int b)
917{
918 vector unsigned int res = (vector unsigned int)a & (vector unsigned int)b;
919 return (vector float)res;
920}
921
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000922/* vec_andc */
923
924#define __builtin_altivec_vandc vec_andc
925
926static vector signed char __ATTRS_o_ai
927vec_andc(vector signed char a, vector signed char b)
928{
929 return a & ~b;
930}
931
Anton Yartsev05e35552010-08-16 16:22:12 +0000932static vector signed char __ATTRS_o_ai
933vec_andc(vector bool char a, vector signed char b)
934{
935 return (vector signed char)a & ~b;
936}
937
938static vector signed char __ATTRS_o_ai
939vec_andc(vector signed char a, vector bool char b)
940{
941 return a & ~(vector signed char)b;
942}
943
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000944static vector unsigned char __ATTRS_o_ai
945vec_andc(vector unsigned char a, vector unsigned char b)
946{
947 return a & ~b;
948}
949
Anton Yartsev05e35552010-08-16 16:22:12 +0000950static vector unsigned char __ATTRS_o_ai
951vec_andc(vector bool char a, vector unsigned char b)
952{
953 return (vector unsigned char)a & ~b;
954}
955
956static vector unsigned char __ATTRS_o_ai
957vec_andc(vector unsigned char a, vector bool char b)
958{
959 return a & ~(vector unsigned char)b;
960}
961
962static vector bool char __ATTRS_o_ai
963vec_andc(vector bool char a, vector bool char b)
964{
965 return a & ~b;
966}
967
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000968static vector short __ATTRS_o_ai
969vec_andc(vector short a, vector short b)
970{
971 return a & ~b;
972}
973
Anton Yartsev05e35552010-08-16 16:22:12 +0000974static vector short __ATTRS_o_ai
975vec_andc(vector bool short a, vector short b)
976{
977 return (vector short)a & ~b;
978}
979
980static vector short __ATTRS_o_ai
981vec_andc(vector short a, vector bool short b)
982{
983 return a & ~(vector short)b;
984}
985
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +0000986static vector unsigned short __ATTRS_o_ai
987vec_andc(vector unsigned short a, vector unsigned short b)
988{
989 return a & ~b;
990}
991
Anton Yartsev05e35552010-08-16 16:22:12 +0000992static vector unsigned short __ATTRS_o_ai
993vec_andc(vector bool short a, vector unsigned short b)
994{
995 return (vector unsigned short)a & ~b;
996}
997
998static vector unsigned short __ATTRS_o_ai
999vec_andc(vector unsigned short a, vector bool short b)
1000{
1001 return a & ~(vector unsigned short)b;
1002}
1003
1004static vector bool short __ATTRS_o_ai
1005vec_andc(vector bool short a, vector bool short b)
1006{
1007 return a & ~b;
1008}
1009
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001010static vector int __ATTRS_o_ai
1011vec_andc(vector int a, vector int b)
1012{
1013 return a & ~b;
1014}
1015
Anton Yartsev05e35552010-08-16 16:22:12 +00001016static vector int __ATTRS_o_ai
1017vec_andc(vector bool int a, vector int b)
1018{
1019 return (vector int)a & ~b;
1020}
1021
1022static vector int __ATTRS_o_ai
1023vec_andc(vector int a, vector bool int b)
1024{
1025 return a & ~(vector int)b;
1026}
1027
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001028static vector unsigned int __ATTRS_o_ai
1029vec_andc(vector unsigned int a, vector unsigned int b)
1030{
1031 return a & ~b;
1032}
1033
Anton Yartsev05e35552010-08-16 16:22:12 +00001034static vector unsigned int __ATTRS_o_ai
1035vec_andc(vector bool int a, vector unsigned int b)
1036{
1037 return (vector unsigned int)a & ~b;
1038}
1039
1040static vector unsigned int __ATTRS_o_ai
1041vec_andc(vector unsigned int a, vector bool int b)
1042{
1043 return a & ~(vector unsigned int)b;
1044}
1045
1046static vector bool int __ATTRS_o_ai
1047vec_andc(vector bool int a, vector bool int b)
1048{
1049 return a & ~b;
1050}
1051
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001052static vector float __ATTRS_o_ai
1053vec_andc(vector float a, vector float b)
1054{
1055 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1056 return (vector float)res;
1057}
1058
Anton Yartsev05e35552010-08-16 16:22:12 +00001059static vector float __ATTRS_o_ai
1060vec_andc(vector bool int a, vector float b)
1061{
1062 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1063 return (vector float)res;
1064}
1065
1066static vector float __ATTRS_o_ai
1067vec_andc(vector float a, vector bool int b)
1068{
1069 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1070 return (vector float)res;
1071}
1072
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001073/* vec_vandc */
1074
1075static vector signed char __ATTRS_o_ai
1076vec_vandc(vector signed char a, vector signed char b)
1077{
1078 return a & ~b;
1079}
1080
Anton Yartsev05e35552010-08-16 16:22:12 +00001081static vector signed char __ATTRS_o_ai
1082vec_vandc(vector bool char a, vector signed char b)
1083{
1084 return (vector signed char)a & ~b;
1085}
1086
1087static vector signed char __ATTRS_o_ai
1088vec_vandc(vector signed char a, vector bool char b)
1089{
1090 return a & ~(vector signed char)b;
1091}
1092
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001093static vector unsigned char __ATTRS_o_ai
1094vec_vandc(vector unsigned char a, vector unsigned char b)
1095{
1096 return a & ~b;
1097}
1098
Anton Yartsev05e35552010-08-16 16:22:12 +00001099static vector unsigned char __ATTRS_o_ai
1100vec_vandc(vector bool char a, vector unsigned char b)
1101{
1102 return (vector unsigned char)a & ~b;
1103}
1104
1105static vector unsigned char __ATTRS_o_ai
1106vec_vandc(vector unsigned char a, vector bool char b)
1107{
1108 return a & ~(vector unsigned char)b;
1109}
1110
1111static vector bool char __ATTRS_o_ai
1112vec_vandc(vector bool char a, vector bool char b)
1113{
1114 return a & ~b;
1115}
1116
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001117static vector short __ATTRS_o_ai
1118vec_vandc(vector short a, vector short b)
1119{
1120 return a & ~b;
1121}
1122
Anton Yartsev05e35552010-08-16 16:22:12 +00001123static vector short __ATTRS_o_ai
1124vec_vandc(vector bool short a, vector short b)
1125{
1126 return (vector short)a & ~b;
1127}
1128
1129static vector short __ATTRS_o_ai
1130vec_vandc(vector short a, vector bool short b)
1131{
1132 return a & ~(vector short)b;
1133}
1134
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001135static vector unsigned short __ATTRS_o_ai
1136vec_vandc(vector unsigned short a, vector unsigned short b)
1137{
1138 return a & ~b;
1139}
1140
Anton Yartsev05e35552010-08-16 16:22:12 +00001141static vector unsigned short __ATTRS_o_ai
1142vec_vandc(vector bool short a, vector unsigned short b)
1143{
1144 return (vector unsigned short)a & ~b;
1145}
1146
1147static vector unsigned short __ATTRS_o_ai
1148vec_vandc(vector unsigned short a, vector bool short b)
1149{
1150 return a & ~(vector unsigned short)b;
1151}
1152
1153static vector bool short __ATTRS_o_ai
1154vec_vandc(vector bool short a, vector bool short b)
1155{
1156 return a & ~b;
1157}
1158
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001159static vector int __ATTRS_o_ai
1160vec_vandc(vector int a, vector int b)
1161{
1162 return a & ~b;
1163}
1164
Anton Yartsev05e35552010-08-16 16:22:12 +00001165static vector int __ATTRS_o_ai
1166vec_vandc(vector bool int a, vector int b)
1167{
1168 return (vector int)a & ~b;
1169}
1170
1171static vector int __ATTRS_o_ai
1172vec_vandc(vector int a, vector bool int b)
1173{
1174 return a & ~(vector int)b;
1175}
1176
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001177static vector unsigned int __ATTRS_o_ai
1178vec_vandc(vector unsigned int a, vector unsigned int b)
1179{
1180 return a & ~b;
1181}
1182
Anton Yartsev05e35552010-08-16 16:22:12 +00001183static vector unsigned int __ATTRS_o_ai
1184vec_vandc(vector bool int a, vector unsigned int b)
1185{
1186 return (vector unsigned int)a & ~b;
1187}
1188
1189static vector unsigned int __ATTRS_o_ai
1190vec_vandc(vector unsigned int a, vector bool int b)
1191{
1192 return a & ~(vector unsigned int)b;
1193}
1194
1195static vector bool int __ATTRS_o_ai
1196vec_vandc(vector bool int a, vector bool int b)
1197{
1198 return a & ~b;
1199}
1200
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001201static vector float __ATTRS_o_ai
1202vec_vandc(vector float a, vector float b)
1203{
1204 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1205 return (vector float)res;
Chris Lattnerdd173942010-04-14 03:54:58 +00001206}
1207
Anton Yartsev05e35552010-08-16 16:22:12 +00001208static vector float __ATTRS_o_ai
1209vec_vandc(vector bool int a, vector float b)
1210{
1211 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1212 return (vector float)res;
1213}
1214
1215static vector float __ATTRS_o_ai
1216vec_vandc(vector float a, vector bool int b)
1217{
1218 vector unsigned int res = (vector unsigned int)a & ~(vector unsigned int)b;
1219 return (vector float)res;
1220}
1221
Chris Lattnerdd173942010-04-14 03:54:58 +00001222/* vec_avg */
1223
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001224static vector signed char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001225vec_avg(vector signed char a, vector signed char b)
1226{
1227 return __builtin_altivec_vavgsb(a, b);
1228}
1229
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001230static vector unsigned char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001231vec_avg(vector unsigned char a, vector unsigned char b)
1232{
1233 return __builtin_altivec_vavgub(a, b);
1234}
1235
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001236static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001237vec_avg(vector short a, vector short b)
1238{
1239 return __builtin_altivec_vavgsh(a, b);
1240}
1241
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001242static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001243vec_avg(vector unsigned short a, vector unsigned short b)
1244{
1245 return __builtin_altivec_vavguh(a, b);
1246}
1247
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001248static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001249vec_avg(vector int a, vector int b)
1250{
1251 return __builtin_altivec_vavgsw(a, b);
1252}
1253
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001254static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001255vec_avg(vector unsigned int a, vector unsigned int b)
1256{
1257 return __builtin_altivec_vavguw(a, b);
1258}
1259
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001260/* vec_vavgsb */
Chris Lattnerdd173942010-04-14 03:54:58 +00001261
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001262static vector signed char __attribute__((__always_inline__))
1263vec_vavgsb(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001264{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001265 return __builtin_altivec_vavgsb(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001266}
1267
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001268/* vec_vavgub */
1269
1270static vector unsigned char __attribute__((__always_inline__))
1271vec_vavgub(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001272{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001273 return __builtin_altivec_vavgub(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001274}
1275
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001276/* vec_vavgsh */
1277
1278static vector short __attribute__((__always_inline__))
1279vec_vavgsh(vector short a, vector short b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001280{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001281 return __builtin_altivec_vavgsh(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001282}
1283
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001284/* vec_vavguh */
1285
1286static vector unsigned short __attribute__((__always_inline__))
1287vec_vavguh(vector unsigned short a, vector unsigned short b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001288{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001289 return __builtin_altivec_vavguh(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001290}
1291
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001292/* vec_vavgsw */
1293
1294static vector int __attribute__((__always_inline__))
1295vec_vavgsw(vector int a, vector int b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001296{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001297 return __builtin_altivec_vavgsw(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001298}
1299
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001300/* vec_vavguw */
1301
1302static vector unsigned int __attribute__((__always_inline__))
1303vec_vavguw(vector unsigned int a, vector unsigned int b)
Chris Lattnerdd173942010-04-14 03:54:58 +00001304{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001305 return __builtin_altivec_vavguw(a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001306}
1307
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001308/* vec_ceil */
1309
1310static vector float __attribute__((__always_inline__))
1311vec_ceil(vector float a)
Chris Lattnerdd173942010-04-14 03:54:58 +00001312{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001313 return __builtin_altivec_vrfip(a);
Chris Lattnerdd173942010-04-14 03:54:58 +00001314}
1315
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001316/* vec_vrfip */
Chris Lattnerdd173942010-04-14 03:54:58 +00001317
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001318static vector float __attribute__((__always_inline__))
1319vec_vrfip(vector float a)
Chris Lattnerdd173942010-04-14 03:54:58 +00001320{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001321 return __builtin_altivec_vrfip(a);
Chris Lattnerdd173942010-04-14 03:54:58 +00001322}
1323
1324/* vec_cmpb */
1325
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001326static vector int __attribute__((__always_inline__))
1327vec_cmpb(vector float a, vector float b)
1328{
1329 return __builtin_altivec_vcmpbfp(a, b);
1330}
1331
1332/* vec_vcmpbfp */
1333
1334static vector int __attribute__((__always_inline__))
1335vec_vcmpbfp(vector float a, vector float b)
1336{
1337 return __builtin_altivec_vcmpbfp(a, b);
1338}
Chris Lattnerdd173942010-04-14 03:54:58 +00001339
1340/* vec_cmpeq */
1341
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001342static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001343vec_cmpeq(vector signed char a, vector signed char b)
1344{
Chris Lattnerab866b42010-04-14 20:35:39 +00001345 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001346}
1347
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001348static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001349vec_cmpeq(vector unsigned char a, vector unsigned char b)
1350{
Chris Lattnerab866b42010-04-14 20:35:39 +00001351 return __builtin_altivec_vcmpequb((vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001352}
1353
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001354static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001355vec_cmpeq(vector short a, vector short b)
1356{
1357 return __builtin_altivec_vcmpequh(a, b);
1358}
1359
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001360static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001361vec_cmpeq(vector unsigned short a, vector unsigned short b)
1362{
Chris Lattnerab866b42010-04-14 20:35:39 +00001363 return __builtin_altivec_vcmpequh((vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001364}
1365
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001366static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001367vec_cmpeq(vector int a, vector int b)
1368{
1369 return __builtin_altivec_vcmpequw(a, b);
1370}
1371
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001372static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001373vec_cmpeq(vector unsigned int a, vector unsigned int b)
1374{
Chris Lattnerab866b42010-04-14 20:35:39 +00001375 return __builtin_altivec_vcmpequw((vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00001376}
1377
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001378static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001379vec_cmpeq(vector float a, vector float b)
1380{
1381 return __builtin_altivec_vcmpeqfp(a, b);
1382}
1383
1384/* vec_cmpge */
1385
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001386static vector /*bool*/ int __attribute__((__always_inline__))
1387vec_cmpge(vector float a, vector float b)
1388{
1389 return __builtin_altivec_vcmpgefp(a, b);
1390}
1391
1392/* vec_vcmpgefp */
1393
1394static vector /*bool*/ int __attribute__((__always_inline__))
1395vec_vcmpgefp(vector float a, vector float b)
1396{
1397 return __builtin_altivec_vcmpgefp(a, b);
1398}
Chris Lattnerdd173942010-04-14 03:54:58 +00001399
1400/* vec_cmpgt */
1401
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001402static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001403vec_cmpgt(vector signed char a, vector signed char b)
1404{
1405 return __builtin_altivec_vcmpgtsb(a, b);
1406}
1407
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001408static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001409vec_cmpgt(vector unsigned char a, vector unsigned char b)
1410{
1411 return __builtin_altivec_vcmpgtub(a, b);
1412}
1413
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001414static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001415vec_cmpgt(vector short a, vector short b)
1416{
1417 return __builtin_altivec_vcmpgtsh(a, b);
1418}
1419
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001420static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001421vec_cmpgt(vector unsigned short a, vector unsigned short b)
1422{
1423 return __builtin_altivec_vcmpgtuh(a, b);
1424}
1425
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001426static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001427vec_cmpgt(vector int a, vector int b)
1428{
1429 return __builtin_altivec_vcmpgtsw(a, b);
1430}
1431
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001432static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001433vec_cmpgt(vector unsigned int a, vector unsigned int b)
1434{
1435 return __builtin_altivec_vcmpgtuw(a, b);
1436}
1437
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001438static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001439vec_cmpgt(vector float a, vector float b)
1440{
1441 return __builtin_altivec_vcmpgtfp(a, b);
1442}
1443
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001444/* vec_vcmpgtsb */
Chris Lattnerdd173942010-04-14 03:54:58 +00001445
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001446static vector /*bool*/ char __attribute__((__always_inline__))
1447vec_vcmpgtsb(vector signed char a, vector signed char b)
1448{
1449 return __builtin_altivec_vcmpgtsb(a, b);
1450}
1451
1452/* vec_vcmpgtub */
1453
1454static vector /*bool*/ char __attribute__((__always_inline__))
1455vec_vcmpgtub(vector unsigned char a, vector unsigned char b)
1456{
1457 return __builtin_altivec_vcmpgtub(a, b);
1458}
1459
1460/* vec_vcmpgtsh */
1461
1462static vector /*bool*/ short __attribute__((__always_inline__))
1463vec_vcmpgtsh(vector short a, vector short b)
1464{
1465 return __builtin_altivec_vcmpgtsh(a, b);
1466}
1467
1468/* vec_vcmpgtuh */
1469
1470static vector /*bool*/ short __attribute__((__always_inline__))
1471vec_vcmpgtuh(vector unsigned short a, vector unsigned short b)
1472{
1473 return __builtin_altivec_vcmpgtuh(a, b);
1474}
1475
1476/* vec_vcmpgtsw */
1477
1478static vector /*bool*/ int __attribute__((__always_inline__))
1479vec_vcmpgtsw(vector int a, vector int b)
1480{
1481 return __builtin_altivec_vcmpgtsw(a, b);
1482}
1483
1484/* vec_vcmpgtuw */
1485
1486static vector /*bool*/ int __attribute__((__always_inline__))
1487vec_vcmpgtuw(vector unsigned int a, vector unsigned int b)
1488{
1489 return __builtin_altivec_vcmpgtuw(a, b);
1490}
1491
1492/* vec_vcmpgtfp */
1493
1494static vector /*bool*/ int __attribute__((__always_inline__))
1495vec_vcmpgtfp(vector float a, vector float b)
1496{
1497 return __builtin_altivec_vcmpgtfp(a, b);
1498}
1499
1500/* vec_cmple */
Chris Lattnerdd173942010-04-14 03:54:58 +00001501
Chris Lattnerab866b42010-04-14 20:35:39 +00001502static vector /*bool*/ int __attribute__((__always_inline__))
Chris Lattnerdd173942010-04-14 03:54:58 +00001503vec_cmple(vector float a, vector float b)
1504{
1505 return __builtin_altivec_vcmpgefp(b, a);
1506}
1507
1508/* vec_cmplt */
1509
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001510static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001511vec_cmplt(vector signed char a, vector signed char b)
1512{
1513 return __builtin_altivec_vcmpgtsb(b, a);
1514}
1515
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001516static vector /*bool*/ char __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001517vec_cmplt(vector unsigned char a, vector unsigned char b)
1518{
1519 return __builtin_altivec_vcmpgtub(b, a);
1520}
1521
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001522static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001523vec_cmplt(vector short a, vector short b)
1524{
1525 return __builtin_altivec_vcmpgtsh(b, a);
1526}
1527
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001528static vector /*bool*/ short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001529vec_cmplt(vector unsigned short a, vector unsigned short b)
1530{
1531 return __builtin_altivec_vcmpgtuh(b, a);
1532}
1533
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001534static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001535vec_cmplt(vector int a, vector int b)
1536{
1537 return __builtin_altivec_vcmpgtsw(b, a);
1538}
1539
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001540static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001541vec_cmplt(vector unsigned int a, vector unsigned int b)
1542{
1543 return __builtin_altivec_vcmpgtuw(b, a);
1544}
1545
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001546static vector /*bool*/ int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00001547vec_cmplt(vector float a, vector float b)
1548{
1549 return __builtin_altivec_vcmpgtfp(b, a);
1550}
1551
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00001552/* vec_ctf */
1553
1554static vector float __ATTRS_o_ai
1555vec_ctf(vector int a, int b)
1556{
1557 return __builtin_altivec_vcfsx(a, b);
1558}
1559
1560static vector float __ATTRS_o_ai
1561vec_ctf(vector unsigned int a, int b)
1562{
1563 return __builtin_altivec_vcfux((vector int)a, b);
1564}
1565
1566/* vec_vcfsx */
1567
1568static vector float __attribute__((__always_inline__))
1569vec_vcfsx(vector int a, int b)
1570{
1571 return __builtin_altivec_vcfsx(a, b);
1572}
1573
1574/* vec_vcfux */
1575
1576static vector float __attribute__((__always_inline__))
1577vec_vcfux(vector unsigned int a, int b)
1578{
1579 return __builtin_altivec_vcfux((vector int)a, b);
1580}
1581
1582/* vec_cts */
1583
1584static vector int __attribute__((__always_inline__))
1585vec_cts(vector float a, int b)
1586{
1587 return __builtin_altivec_vctsxs(a, b);
1588}
1589
1590/* vec_vctsxs */
1591
1592static vector int __attribute__((__always_inline__))
1593vec_vctsxs(vector float a, int b)
1594{
1595 return __builtin_altivec_vctsxs(a, b);
1596}
1597
1598/* vec_ctu */
1599
1600static vector unsigned int __attribute__((__always_inline__))
1601vec_ctu(vector float a, int b)
1602{
1603 return __builtin_altivec_vctuxs(a, b);
1604}
1605
1606/* vec_vctuxs */
1607
1608static vector unsigned int __attribute__((__always_inline__))
1609vec_vctuxs(vector float a, int b)
1610{
1611 return __builtin_altivec_vctuxs(a, b);
1612}
1613
1614/* vec_dss */
1615
1616static void __attribute__((__always_inline__))
1617vec_dss(int a)
1618{
1619 __builtin_altivec_dss(a);
1620}
1621
1622/* vec_dssall */
1623
1624static void __attribute__((__always_inline__))
1625vec_dssall(void)
1626{
1627 __builtin_altivec_dssall();
1628}
1629
1630/* vec_dst */
1631
1632static void __attribute__((__always_inline__))
1633vec_dst(void *a, int b, int c)
1634{
1635 __builtin_altivec_dst(a, b, c);
1636}
1637
1638/* vec_dstst */
1639
1640static void __attribute__((__always_inline__))
1641vec_dstst(void *a, int b, int c)
1642{
1643 __builtin_altivec_dstst(a, b, c);
1644}
1645
1646/* vec_dststt */
1647
1648static void __attribute__((__always_inline__))
1649vec_dststt(void *a, int b, int c)
1650{
1651 __builtin_altivec_dststt(a, b, c);
1652}
1653
1654/* vec_dstt */
1655
1656static void __attribute__((__always_inline__))
1657vec_dstt(void *a, int b, int c)
1658{
1659 __builtin_altivec_dstt(a, b, c);
1660}
1661
1662/* vec_expte */
1663
1664static vector float __attribute__((__always_inline__))
1665vec_expte(vector float a)
1666{
1667 return __builtin_altivec_vexptefp(a);
1668}
1669
1670/* vec_vexptefp */
1671
1672static vector float __attribute__((__always_inline__))
1673vec_vexptefp(vector float a)
1674{
1675 return __builtin_altivec_vexptefp(a);
1676}
1677
1678/* vec_floor */
1679
1680static vector float __attribute__((__always_inline__))
1681vec_floor(vector float a)
1682{
1683 return __builtin_altivec_vrfim(a);
1684}
1685
1686/* vec_vrfim */
1687
1688static vector float __attribute__((__always_inline__))
1689vec_vrfim(vector float a)
1690{
1691 return __builtin_altivec_vrfim(a);
1692}
1693
1694/* vec_ld */
1695
1696static vector signed char __ATTRS_o_ai
1697vec_ld(int a, vector signed char *b)
1698{
1699 return (vector signed char)__builtin_altivec_lvx(a, b);
1700}
1701
1702static vector signed char __ATTRS_o_ai
1703vec_ld(int a, signed char *b)
1704{
1705 return (vector signed char)__builtin_altivec_lvx(a, b);
1706}
1707
1708static vector unsigned char __ATTRS_o_ai
1709vec_ld(int a, vector unsigned char *b)
1710{
1711 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1712}
1713
1714static vector unsigned char __ATTRS_o_ai
1715vec_ld(int a, unsigned char *b)
1716{
1717 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1718}
1719
1720static vector short __ATTRS_o_ai
1721vec_ld(int a, vector short *b)
1722{
1723 return (vector short)__builtin_altivec_lvx(a, b);
1724}
1725
1726static vector short __ATTRS_o_ai
1727vec_ld(int a, short *b)
1728{
1729 return (vector short)__builtin_altivec_lvx(a, b);
1730}
1731
1732static vector unsigned short __ATTRS_o_ai
1733vec_ld(int a, vector unsigned short *b)
1734{
1735 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1736}
1737
1738static vector unsigned short __ATTRS_o_ai
1739vec_ld(int a, unsigned short *b)
1740{
1741 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1742}
1743
1744static vector int __ATTRS_o_ai
1745vec_ld(int a, vector int *b)
1746{
1747 return (vector int)__builtin_altivec_lvx(a, b);
1748}
1749
1750static vector int __ATTRS_o_ai
1751vec_ld(int a, int *b)
1752{
1753 return (vector int)__builtin_altivec_lvx(a, b);
1754}
1755
1756static vector unsigned int __ATTRS_o_ai
1757vec_ld(int a, vector unsigned int *b)
1758{
1759 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1760}
1761
1762static vector unsigned int __ATTRS_o_ai
1763vec_ld(int a, unsigned int *b)
1764{
1765 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1766}
1767
1768static vector float __ATTRS_o_ai
1769vec_ld(int a, vector float *b)
1770{
1771 return (vector float)__builtin_altivec_lvx(a, b);
1772}
1773
1774static vector float __ATTRS_o_ai
1775vec_ld(int a, float *b)
1776{
1777 return (vector float)__builtin_altivec_lvx(a, b);
1778}
1779
1780/* vec_lvx */
1781
1782static vector signed char __ATTRS_o_ai
1783vec_lvx(int a, vector signed char *b)
1784{
1785 return (vector signed char)__builtin_altivec_lvx(a, b);
1786}
1787
1788static vector signed char __ATTRS_o_ai
1789vec_lvx(int a, signed char *b)
1790{
1791 return (vector signed char)__builtin_altivec_lvx(a, b);
1792}
1793
1794static vector unsigned char __ATTRS_o_ai
1795vec_lvx(int a, vector unsigned char *b)
1796{
1797 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1798}
1799
1800static vector unsigned char __ATTRS_o_ai
1801vec_lvx(int a, unsigned char *b)
1802{
1803 return (vector unsigned char)__builtin_altivec_lvx(a, b);
1804}
1805
1806static vector short __ATTRS_o_ai
1807vec_lvx(int a, vector short *b)
1808{
1809 return (vector short)__builtin_altivec_lvx(a, b);
1810}
1811
1812static vector short __ATTRS_o_ai
1813vec_lvx(int a, short *b)
1814{
1815 return (vector short)__builtin_altivec_lvx(a, b);
1816}
1817
1818static vector unsigned short __ATTRS_o_ai
1819vec_lvx(int a, vector unsigned short *b)
1820{
1821 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1822}
1823
1824static vector unsigned short __ATTRS_o_ai
1825vec_lvx(int a, unsigned short *b)
1826{
1827 return (vector unsigned short)__builtin_altivec_lvx(a, b);
1828}
1829
1830static vector int __ATTRS_o_ai
1831vec_lvx(int a, vector int *b)
1832{
1833 return (vector int)__builtin_altivec_lvx(a, b);
1834}
1835
1836static vector int __ATTRS_o_ai
1837vec_lvx(int a, int *b)
1838{
1839 return (vector int)__builtin_altivec_lvx(a, b);
1840}
1841
1842static vector unsigned int __ATTRS_o_ai
1843vec_lvx(int a, vector unsigned int *b)
1844{
1845 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1846}
1847
1848static vector unsigned int __ATTRS_o_ai
1849vec_lvx(int a, unsigned int *b)
1850{
1851 return (vector unsigned int)__builtin_altivec_lvx(a, b);
1852}
1853
1854static vector float __ATTRS_o_ai
1855vec_lvx(int a, vector float *b)
1856{
1857 return (vector float)__builtin_altivec_lvx(a, b);
1858}
1859
1860static vector float __ATTRS_o_ai
1861vec_lvx(int a, float *b)
1862{
1863 return (vector float)__builtin_altivec_lvx(a, b);
1864}
1865
1866/* vec_lde */
1867
1868static vector signed char __ATTRS_o_ai
1869vec_lde(int a, vector signed char *b)
1870{
1871 return (vector signed char)__builtin_altivec_lvebx(a, b);
1872}
1873
1874static vector unsigned char __ATTRS_o_ai
1875vec_lde(int a, vector unsigned char *b)
1876{
1877 return (vector unsigned char)__builtin_altivec_lvebx(a, b);
1878}
1879
1880static vector short __ATTRS_o_ai
1881vec_lde(int a, vector short *b)
1882{
1883 return (vector short)__builtin_altivec_lvehx(a, b);
1884}
1885
1886static vector unsigned short __ATTRS_o_ai
1887vec_lde(int a, vector unsigned short *b)
1888{
1889 return (vector unsigned short)__builtin_altivec_lvehx(a, b);
1890}
1891
1892static vector int __ATTRS_o_ai
1893vec_lde(int a, vector int *b)
1894{
1895 return (vector int)__builtin_altivec_lvewx(a, b);
1896}
1897
1898static vector unsigned int __ATTRS_o_ai
1899vec_lde(int a, vector unsigned int *b)
1900{
1901 return (vector unsigned int)__builtin_altivec_lvewx(a, b);
1902}
1903
1904static vector float __ATTRS_o_ai
1905vec_lde(int a, vector float *b)
1906{
1907 return (vector float)__builtin_altivec_lvewx(a, b);
1908}
1909
1910/* vec_lvebx */
1911
1912static vector signed char __ATTRS_o_ai
1913vec_lvebx(int a, vector signed char *b)
1914{
1915 return (vector signed char)__builtin_altivec_lvebx(a, b);
1916}
1917
1918static vector unsigned char __ATTRS_o_ai
1919vec_lvebx(int a, vector unsigned char *b)
1920{
1921 return (vector unsigned char)__builtin_altivec_lvebx(a, b);
1922}
1923
1924/* vec_lvehx */
1925
1926static vector short __ATTRS_o_ai
1927vec_lvehx(int a, vector short *b)
1928{
1929 return (vector short)__builtin_altivec_lvehx(a, b);
1930}
1931
1932static vector unsigned short __ATTRS_o_ai
1933vec_lvehx(int a, vector unsigned short *b)
1934{
1935 return (vector unsigned short)__builtin_altivec_lvehx(a, b);
1936}
1937
1938/* vec_lvewx */
1939
1940static vector int __ATTRS_o_ai
1941vec_lvewx(int a, vector int *b)
1942{
1943 return (vector int)__builtin_altivec_lvewx(a, b);
1944}
1945
1946static vector unsigned int __ATTRS_o_ai
1947vec_lvewx(int a, vector unsigned int *b)
1948{
1949 return (vector unsigned int)__builtin_altivec_lvewx(a, b);
1950}
1951
1952static vector float __ATTRS_o_ai
1953vec_lvewx(int a, vector float *b)
1954{
1955 return (vector float)__builtin_altivec_lvewx(a, b);
1956}
1957
1958/* vec_ldl */
1959
1960static vector signed char __ATTRS_o_ai
1961vec_ldl(int a, vector signed char *b)
1962{
1963 return (vector signed char)__builtin_altivec_lvxl(a, b);
1964}
1965
1966static vector signed char __ATTRS_o_ai
1967vec_ldl(int a, signed char *b)
1968{
1969 return (vector signed char)__builtin_altivec_lvxl(a, b);
1970}
1971
1972static vector unsigned char __ATTRS_o_ai
1973vec_ldl(int a, vector unsigned char *b)
1974{
1975 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1976}
1977
1978static vector unsigned char __ATTRS_o_ai
1979vec_ldl(int a, unsigned char *b)
1980{
1981 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
1982}
1983
1984static vector short __ATTRS_o_ai
1985vec_ldl(int a, vector short *b)
1986{
1987 return (vector short)__builtin_altivec_lvxl(a, b);
1988}
1989
1990static vector short __ATTRS_o_ai
1991vec_ldl(int a, short *b)
1992{
1993 return (vector short)__builtin_altivec_lvxl(a, b);
1994}
1995
1996static vector unsigned short __ATTRS_o_ai
1997vec_ldl(int a, vector unsigned short *b)
1998{
1999 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
2000}
2001
2002static vector unsigned short __ATTRS_o_ai
2003vec_ldl(int a, unsigned short *b)
2004{
2005 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
2006}
2007
2008static vector int __ATTRS_o_ai
2009vec_ldl(int a, vector int *b)
2010{
2011 return (vector int)__builtin_altivec_lvxl(a, b);
2012}
2013
2014static vector int __ATTRS_o_ai
2015vec_ldl(int a, int *b)
2016{
2017 return (vector int)__builtin_altivec_lvxl(a, b);
2018}
2019
2020static vector unsigned int __ATTRS_o_ai
2021vec_ldl(int a, vector unsigned int *b)
2022{
2023 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
2024}
2025
2026static vector unsigned int __ATTRS_o_ai
2027vec_ldl(int a, unsigned int *b)
2028{
2029 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
2030}
2031
2032static vector float __ATTRS_o_ai
2033vec_ldl(int a, vector float *b)
2034{
2035 return (vector float)__builtin_altivec_lvxl(a, b);
2036}
2037
2038static vector float __ATTRS_o_ai
2039vec_ldl(int a, float *b)
2040{
2041 return (vector float)__builtin_altivec_lvxl(a, b);
2042}
2043
2044/* vec_lvxl */
2045
2046static vector signed char __ATTRS_o_ai
2047vec_lvxl(int a, vector signed char *b)
2048{
2049 return (vector signed char)__builtin_altivec_lvxl(a, b);
2050}
2051
2052static vector signed char __ATTRS_o_ai
2053vec_lvxl(int a, signed char *b)
2054{
2055 return (vector signed char)__builtin_altivec_lvxl(a, b);
2056}
2057
2058static vector unsigned char __ATTRS_o_ai
2059vec_lvxl(int a, vector unsigned char *b)
2060{
2061 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
2062}
2063
2064static vector unsigned char __ATTRS_o_ai
2065vec_lvxl(int a, unsigned char *b)
2066{
2067 return (vector unsigned char)__builtin_altivec_lvxl(a, b);
2068}
2069
2070static vector short __ATTRS_o_ai
2071vec_lvxl(int a, vector short *b)
2072{
2073 return (vector short)__builtin_altivec_lvxl(a, b);
2074}
2075
2076static vector short __ATTRS_o_ai
2077vec_lvxl(int a, short *b)
2078{
2079 return (vector short)__builtin_altivec_lvxl(a, b);
2080}
2081
2082static vector unsigned short __ATTRS_o_ai
2083vec_lvxl(int a, vector unsigned short *b)
2084{
2085 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
2086}
2087
2088static vector unsigned short __ATTRS_o_ai
2089vec_lvxl(int a, unsigned short *b)
2090{
2091 return (vector unsigned short)__builtin_altivec_lvxl(a, b);
2092}
2093
2094static vector int __ATTRS_o_ai
2095vec_lvxl(int a, vector int *b)
2096{
2097 return (vector int)__builtin_altivec_lvxl(a, b);
2098}
2099
2100static vector int __ATTRS_o_ai
2101vec_lvxl(int a, int *b)
2102{
2103 return (vector int)__builtin_altivec_lvxl(a, b);
2104}
2105
2106static vector unsigned int __ATTRS_o_ai
2107vec_lvxl(int a, vector unsigned int *b)
2108{
2109 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
2110}
2111
2112static vector unsigned int __ATTRS_o_ai
2113vec_lvxl(int a, unsigned int *b)
2114{
2115 return (vector unsigned int)__builtin_altivec_lvxl(a, b);
2116}
2117
2118static vector float __ATTRS_o_ai
2119vec_lvxl(int a, vector float *b)
2120{
2121 return (vector float)__builtin_altivec_lvxl(a, b);
2122}
2123
2124static vector float __ATTRS_o_ai
2125vec_lvxl(int a, float *b)
2126{
2127 return (vector float)__builtin_altivec_lvxl(a, b);
2128}
2129
2130/* vec_loge */
2131
2132static vector float __attribute__((__always_inline__))
2133vec_loge(vector float a)
2134{
2135 return __builtin_altivec_vlogefp(a);
2136}
2137
2138/* vec_vlogefp */
2139
2140static vector float __attribute__((__always_inline__))
2141vec_vlogefp(vector float a)
2142{
2143 return __builtin_altivec_vlogefp(a);
2144}
2145
2146/* vec_lvsl */
2147
2148static vector unsigned char __ATTRS_o_ai
2149vec_lvsl(int a, signed char *b)
2150{
2151 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2152}
2153
2154static vector unsigned char __ATTRS_o_ai
2155vec_lvsl(int a, unsigned char *b)
2156{
2157 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2158}
2159
2160static vector unsigned char __ATTRS_o_ai
2161vec_lvsl(int a, short *b)
2162{
2163 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2164}
2165
2166static vector unsigned char __ATTRS_o_ai
2167vec_lvsl(int a, unsigned short *b)
2168{
2169 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2170}
2171
2172static vector unsigned char __ATTRS_o_ai
2173vec_lvsl(int a, int *b)
2174{
2175 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2176}
2177
2178static vector unsigned char __ATTRS_o_ai
2179vec_lvsl(int a, unsigned int *b)
2180{
2181 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2182}
2183
2184static vector unsigned char __ATTRS_o_ai
2185vec_lvsl(int a, float *b)
2186{
2187 return (vector unsigned char)__builtin_altivec_lvsl(a, b);
2188}
2189
2190/* vec_lvsr */
2191
2192static vector unsigned char __ATTRS_o_ai
2193vec_lvsr(int a, signed char *b)
2194{
2195 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2196}
2197
2198static vector unsigned char __ATTRS_o_ai
2199vec_lvsr(int a, unsigned char *b)
2200{
2201 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2202}
2203
2204static vector unsigned char __ATTRS_o_ai
2205vec_lvsr(int a, short *b)
2206{
2207 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2208}
2209
2210static vector unsigned char __ATTRS_o_ai
2211vec_lvsr(int a, unsigned short *b)
2212{
2213 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2214}
2215
2216static vector unsigned char __ATTRS_o_ai
2217vec_lvsr(int a, int *b)
2218{
2219 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2220}
2221
2222static vector unsigned char __ATTRS_o_ai
2223vec_lvsr(int a, unsigned int *b)
2224{
2225 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2226}
2227
2228static vector unsigned char __ATTRS_o_ai
2229vec_lvsr(int a, float *b)
2230{
2231 return (vector unsigned char)__builtin_altivec_lvsr(a, b);
2232}
2233
2234/* vec_madd */
2235
2236static vector float __attribute__((__always_inline__))
2237vec_madd(vector float a, vector float b, vector float c)
2238{
2239 return __builtin_altivec_vmaddfp(a, b, c);
2240}
2241
2242/* vec_vmaddfp */
2243
2244static vector float __attribute__((__always_inline__))
2245vec_vmaddfp(vector float a, vector float b, vector float c)
2246{
2247 return __builtin_altivec_vmaddfp(a, b, c);
2248}
2249
2250/* vec_madds */
2251
2252static vector signed short __attribute__((__always_inline__))
2253vec_madds(vector signed short a, vector signed short b, vector signed short c)
2254{
2255 return __builtin_altivec_vmhaddshs(a, b, c);
2256}
2257
2258/* vec_vmhaddshs */
2259static vector signed short __attribute__((__always_inline__))
2260vec_vmhaddshs(vector signed short a, vector signed short b, vector signed short c)
2261{
2262 return __builtin_altivec_vmhaddshs(a, b, c);
2263}
2264
Chris Lattnerdd173942010-04-14 03:54:58 +00002265/* vec_max */
2266
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002267static vector signed char __ATTRS_o_ai
Anton Yartseva816ec82010-08-12 18:51:55 +00002268vec_max(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00002269{
2270 return __builtin_altivec_vmaxsb(a, b);
2271}
2272
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002273static vector unsigned char __ATTRS_o_ai
Anton Yartseva816ec82010-08-12 18:51:55 +00002274vec_max(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00002275{
2276 return __builtin_altivec_vmaxub(a, b);
2277}
2278
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002279static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002280vec_max(vector short a, vector short b)
2281{
2282 return __builtin_altivec_vmaxsh(a, b);
2283}
2284
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002285static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002286vec_max(vector unsigned short a, vector unsigned short b)
2287{
2288 return __builtin_altivec_vmaxuh(a, b);
2289}
2290
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002291static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002292vec_max(vector int a, vector int b)
2293{
2294 return __builtin_altivec_vmaxsw(a, b);
2295}
2296
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002297static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002298vec_max(vector unsigned int a, vector unsigned int b)
2299{
2300 return __builtin_altivec_vmaxuw(a, b);
2301}
2302
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002303static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002304vec_max(vector float a, vector float b)
2305{
2306 return __builtin_altivec_vmaxfp(a, b);
2307}
2308
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002309/* vec_vmaxsb */
2310
2311static vector signed char __attribute__((__always_inline__))
Anton Yartseva816ec82010-08-12 18:51:55 +00002312vec_vmaxsb(vector signed char a, vector signed char b)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002313{
2314 return __builtin_altivec_vmaxsb(a, b);
2315}
2316
2317/* vec_vmaxub */
2318
2319static vector unsigned char __attribute__((__always_inline__))
Anton Yartseva816ec82010-08-12 18:51:55 +00002320vec_vmaxub(vector unsigned char a, vector unsigned char b)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002321{
2322 return __builtin_altivec_vmaxub(a, b);
2323}
2324
2325/* vec_vmaxsh */
2326
2327static vector short __attribute__((__always_inline__))
2328vec_vmaxsh(vector short a, vector short b)
2329{
2330 return __builtin_altivec_vmaxsh(a, b);
2331}
2332
2333/* vec_vmaxuh */
2334
2335static vector unsigned short __attribute__((__always_inline__))
2336vec_vmaxuh(vector unsigned short a, vector unsigned short b)
2337{
2338 return __builtin_altivec_vmaxuh(a, b);
2339}
2340
2341/* vec_vmaxsw */
2342
2343static vector int __attribute__((__always_inline__))
2344vec_vmaxsw(vector int a, vector int b)
2345{
2346 return __builtin_altivec_vmaxsw(a, b);
2347}
2348
2349/* vec_vmaxuw */
2350
2351static vector unsigned int __attribute__((__always_inline__))
2352vec_vmaxuw(vector unsigned int a, vector unsigned int b)
2353{
2354 return __builtin_altivec_vmaxuw(a, b);
2355}
2356
2357/* vec_vmaxfp */
2358
2359static vector float __attribute__((__always_inline__))
2360vec_vmaxfp(vector float a, vector float b)
2361{
2362 return __builtin_altivec_vmaxfp(a, b);
2363}
2364
2365/* vec_mergeh */
2366
2367static vector signed char __ATTRS_o_ai
2368vec_mergeh(vector signed char a, vector signed char b)
2369{
2370 return vec_perm(a, b, (vector unsigned char)
2371 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2372 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2373}
2374
2375static vector unsigned char __ATTRS_o_ai
2376vec_mergeh(vector unsigned char a, vector unsigned char b)
2377{
2378 return vec_perm(a, b, (vector unsigned char)
2379 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2380 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2381}
2382
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002383static vector bool char __ATTRS_o_ai
2384vec_mergeh(vector bool char a, vector bool char b)
2385{
2386 return vec_perm(a, b, (vector unsigned char)
2387 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2388 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2389}
2390
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002391static vector short __ATTRS_o_ai
2392vec_mergeh(vector short a, vector short b)
2393{
2394 return vec_perm(a, b, (vector unsigned char)
2395 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2396 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2397}
2398
2399static vector unsigned short __ATTRS_o_ai
2400vec_mergeh(vector unsigned short a, vector unsigned short b)
2401{
2402 return vec_perm(a, b, (vector unsigned char)
2403 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2404 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2405}
2406
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002407static vector bool short __ATTRS_o_ai
2408vec_mergeh(vector bool short a, vector bool short b)
2409{
2410 return vec_perm(a, b, (vector unsigned char)
2411 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2412 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2413}
2414
2415static vector pixel __ATTRS_o_ai
2416vec_mergeh(vector pixel a, vector pixel b)
2417{
2418 return vec_perm(a, b, (vector unsigned char)
2419 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2420 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2421}
2422
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002423static vector int __ATTRS_o_ai
2424vec_mergeh(vector int a, vector int b)
2425{
2426 return vec_perm(a, b, (vector unsigned char)
2427 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2428 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2429}
2430
2431static vector unsigned int __ATTRS_o_ai
2432vec_mergeh(vector unsigned int a, vector unsigned int b)
2433{
2434 return vec_perm(a, b, (vector unsigned char)
2435 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2436 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2437}
2438
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002439static vector bool int __ATTRS_o_ai
2440vec_mergeh(vector bool int a, vector bool int b)
2441{
2442 return vec_perm(a, b, (vector unsigned char)
2443 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2444 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2445}
2446
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002447static vector float __ATTRS_o_ai
2448vec_mergeh(vector float a, vector float b)
2449{
2450 return vec_perm(a, b, (vector unsigned char)
2451 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2452 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2453}
2454
2455/* vec_vmrghb */
2456
2457#define __builtin_altivec_vmrghb vec_vmrghb
2458
2459static vector signed char __ATTRS_o_ai
2460vec_vmrghb(vector signed char a, vector signed char b)
2461{
2462 return vec_perm(a, b, (vector unsigned char)
2463 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2464 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2465}
2466
2467static vector unsigned char __ATTRS_o_ai
2468vec_vmrghb(vector unsigned char a, vector unsigned char b)
2469{
2470 return vec_perm(a, b, (vector unsigned char)
2471 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2472 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2473}
2474
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002475static vector bool char __ATTRS_o_ai
2476vec_vmrghb(vector bool char a, vector bool char b)
2477{
2478 return vec_perm(a, b, (vector unsigned char)
2479 (0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13,
2480 0x04, 0x14, 0x05, 0x15, 0x06, 0x16, 0x07, 0x17));
2481}
2482
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002483/* vec_vmrghh */
2484
2485#define __builtin_altivec_vmrghh vec_vmrghh
2486
2487static vector short __ATTRS_o_ai
2488vec_vmrghh(vector short a, vector short b)
2489{
2490 return vec_perm(a, b, (vector unsigned char)
2491 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2492 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2493}
2494
2495static vector unsigned short __ATTRS_o_ai
2496vec_vmrghh(vector unsigned short a, vector unsigned short b)
2497{
2498 return vec_perm(a, b, (vector unsigned char)
2499 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2500 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2501}
2502
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002503static vector bool short __ATTRS_o_ai
2504vec_vmrghh(vector bool short a, vector bool short b)
2505{
2506 return vec_perm(a, b, (vector unsigned char)
2507 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2508 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2509}
2510
2511static vector pixel __ATTRS_o_ai
2512vec_vmrghh(vector pixel a, vector pixel b)
2513{
2514 return vec_perm(a, b, (vector unsigned char)
2515 (0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
2516 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17));
2517}
2518
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002519/* vec_vmrghw */
2520
2521#define __builtin_altivec_vmrghw vec_vmrghw
2522
2523static vector int __ATTRS_o_ai
2524vec_vmrghw(vector int a, vector int b)
2525{
2526 return vec_perm(a, b, (vector unsigned char)
2527 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2528 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2529}
2530
2531static vector unsigned int __ATTRS_o_ai
2532vec_vmrghw(vector unsigned int a, vector unsigned int b)
2533{
2534 return vec_perm(a, b, (vector unsigned char)
2535 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2536 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2537}
2538
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002539static vector bool int __ATTRS_o_ai
2540vec_vmrghw(vector bool int a, vector bool int b)
2541{
2542 return vec_perm(a, b, (vector unsigned char)
2543 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2544 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2545}
2546
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002547static vector float __ATTRS_o_ai
2548vec_vmrghw(vector float a, vector float b)
2549{
2550 return vec_perm(a, b, (vector unsigned char)
2551 (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
2552 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17));
2553}
2554
2555/* vec_mergel */
2556
2557static vector signed char __ATTRS_o_ai
2558vec_mergel(vector signed char a, vector signed char b)
2559{
2560 return vec_perm(a, b, (vector unsigned char)
2561 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2562 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2563}
2564
2565static vector unsigned char __ATTRS_o_ai
2566vec_mergel(vector unsigned char a, vector unsigned char b)
2567{
2568 return vec_perm(a, b, (vector unsigned char)
2569 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2570 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2571}
2572
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002573static vector bool char __ATTRS_o_ai
2574vec_mergel(vector bool char a, vector bool char b)
2575{
2576 return vec_perm(a, b, (vector unsigned char)
2577 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2578 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2579}
2580
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002581static vector short __ATTRS_o_ai
2582vec_mergel(vector short a, vector short b)
2583{
2584 return vec_perm(a, b, (vector unsigned char)
2585 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2586 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2587}
2588
2589static vector unsigned short __ATTRS_o_ai
2590vec_mergel(vector unsigned short a, vector unsigned short b)
2591{
2592 return vec_perm(a, b, (vector unsigned char)
2593 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2594 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2595}
2596
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002597static vector bool short __ATTRS_o_ai
2598vec_mergel(vector bool short a, vector bool short b)
2599{
2600 return vec_perm(a, b, (vector unsigned char)
2601 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2602 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2603}
2604
2605static vector pixel __ATTRS_o_ai
2606vec_mergel(vector pixel a, vector pixel b)
2607{
2608 return vec_perm(a, b, (vector unsigned char)
2609 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2610 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2611}
2612
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002613static vector int __ATTRS_o_ai
2614vec_mergel(vector int a, vector int b)
2615{
2616 return vec_perm(a, b, (vector unsigned char)
2617 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2618 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2619}
2620
2621static vector unsigned int __ATTRS_o_ai
2622vec_mergel(vector unsigned int a, vector unsigned int b)
2623{
2624 return vec_perm(a, b, (vector unsigned char)
2625 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2626 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2627}
2628
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002629static vector bool int __ATTRS_o_ai
2630vec_mergel(vector bool int a, vector bool int b)
2631{
2632 return vec_perm(a, b, (vector unsigned char)
2633 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2634 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2635}
2636
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002637static vector float __ATTRS_o_ai
2638vec_mergel(vector float a, vector float b)
2639{
2640 return vec_perm(a, b, (vector unsigned char)
2641 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2642 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2643}
2644
2645/* vec_vmrglb */
2646
2647#define __builtin_altivec_vmrglb vec_vmrglb
2648
2649static vector signed char __ATTRS_o_ai
2650vec_vmrglb(vector signed char a, vector signed char b)
2651{
2652 return vec_perm(a, b, (vector unsigned char)
2653 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2654 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2655}
2656
2657static vector unsigned char __ATTRS_o_ai
2658vec_vmrglb(vector unsigned char a, vector unsigned char b)
2659{
2660 return vec_perm(a, b, (vector unsigned char)
2661 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2662 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2663}
2664
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002665static vector bool char __ATTRS_o_ai
2666vec_vmrglb(vector bool char a, vector bool char b)
2667{
2668 return vec_perm(a, b, (vector unsigned char)
2669 (0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B,
2670 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E, 0x0F, 0x1F));
2671}
2672
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002673/* vec_vmrglh */
2674
2675#define __builtin_altivec_vmrglh vec_vmrglh
2676
2677static vector short __ATTRS_o_ai
2678vec_vmrglh(vector short a, vector short b)
2679{
2680 return vec_perm(a, b, (vector unsigned char)
2681 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2682 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2683}
2684
2685static vector unsigned short __ATTRS_o_ai
2686vec_vmrglh(vector unsigned short a, vector unsigned short b)
2687{
2688 return vec_perm(a, b, (vector unsigned char)
2689 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2690 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2691}
2692
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002693static vector bool short __ATTRS_o_ai
2694vec_vmrglh(vector bool short a, vector bool short b)
2695{
2696 return vec_perm(a, b, (vector unsigned char)
2697 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2698 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2699}
2700
2701static vector pixel __ATTRS_o_ai
2702vec_vmrglh(vector pixel a, vector pixel b)
2703{
2704 return vec_perm(a, b, (vector unsigned char)
2705 (0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B,
2706 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F, 0x1E, 0x1F));
2707}
2708
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002709/* vec_vmrglw */
2710
2711#define __builtin_altivec_vmrglw vec_vmrglw
2712
2713static vector int __ATTRS_o_ai
2714vec_vmrglw(vector int a, vector int b)
2715{
2716 return vec_perm(a, b, (vector unsigned char)
2717 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2718 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2719}
2720
2721static vector unsigned int __ATTRS_o_ai
2722vec_vmrglw(vector unsigned int a, vector unsigned int b)
2723{
2724 return vec_perm(a, b, (vector unsigned char)
2725 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2726 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2727}
2728
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00002729static vector bool int __ATTRS_o_ai
2730vec_vmrglw(vector bool int a, vector bool int b)
2731{
2732 return vec_perm(a, b, (vector unsigned char)
2733 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2734 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2735}
2736
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002737static vector float __ATTRS_o_ai
2738vec_vmrglw(vector float a, vector float b)
2739{
2740 return vec_perm(a, b, (vector unsigned char)
2741 (0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B,
2742 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D, 0x1E, 0x1F));
2743}
2744
Chris Lattnerdd173942010-04-14 03:54:58 +00002745/* vec_mfvscr */
2746
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002747static vector unsigned short __attribute__((__always_inline__))
2748vec_mfvscr(void)
2749{
2750 return __builtin_altivec_mfvscr();
2751}
Chris Lattnerdd173942010-04-14 03:54:58 +00002752
2753/* vec_min */
2754
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002755static vector signed char __ATTRS_o_ai
Anton Yartseva816ec82010-08-12 18:51:55 +00002756vec_min(vector signed char a, vector signed char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00002757{
2758 return __builtin_altivec_vminsb(a, b);
2759}
2760
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002761static vector unsigned char __ATTRS_o_ai
Anton Yartseva816ec82010-08-12 18:51:55 +00002762vec_min(vector unsigned char a, vector unsigned char b)
Chris Lattnerdd173942010-04-14 03:54:58 +00002763{
2764 return __builtin_altivec_vminub(a, b);
2765}
2766
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002767static vector short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002768vec_min(vector short a, vector short b)
2769{
2770 return __builtin_altivec_vminsh(a, b);
2771}
2772
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002773static vector unsigned short __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002774vec_min(vector unsigned short a, vector unsigned short b)
2775{
2776 return __builtin_altivec_vminuh(a, b);
2777}
2778
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002779static vector int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002780vec_min(vector int a, vector int b)
2781{
2782 return __builtin_altivec_vminsw(a, b);
2783}
2784
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002785static vector unsigned int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002786vec_min(vector unsigned int a, vector unsigned int b)
2787{
2788 return __builtin_altivec_vminuw(a, b);
2789}
2790
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002791static vector float __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00002792vec_min(vector float a, vector float b)
2793{
2794 return __builtin_altivec_vminfp(a, b);
2795}
2796
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002797/* vec_vminsb */
2798
2799static vector signed char __attribute__((__always_inline__))
Anton Yartseva816ec82010-08-12 18:51:55 +00002800vec_vminsb(vector signed char a, vector signed char b)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002801{
2802 return __builtin_altivec_vminsb(a, b);
2803}
2804
2805/* vec_vminub */
2806
2807static vector unsigned char __attribute__((__always_inline__))
Anton Yartseva816ec82010-08-12 18:51:55 +00002808vec_vminub(vector unsigned char a, vector unsigned char b)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00002809{
2810 return __builtin_altivec_vminub(a, b);
2811}
2812
2813/* vec_vminsh */
2814
2815static vector short __attribute__((__always_inline__))
2816vec_vminsh(vector short a, vector short b)
2817{
2818 return __builtin_altivec_vminsh(a, b);
2819}
2820
2821/* vec_vminuh */
2822
2823static vector unsigned short __attribute__((__always_inline__))
2824vec_vminuh(vector unsigned short a, vector unsigned short b)
2825{
2826 return __builtin_altivec_vminuh(a, b);
2827}
2828
2829/* vec_vminsw */
2830
2831static vector int __attribute__((__always_inline__))
2832vec_vminsw(vector int a, vector int b)
2833{
2834 return __builtin_altivec_vminsw(a, b);
2835}
2836
2837/* vec_vminuw */
2838
2839static vector unsigned int __attribute__((__always_inline__))
2840vec_vminuw(vector unsigned int a, vector unsigned int b)
2841{
2842 return __builtin_altivec_vminuw(a, b);
2843}
2844
2845/* vec_vminfp */
2846
2847static vector float __attribute__((__always_inline__))
2848vec_vminfp(vector float a, vector float b)
2849{
2850 return __builtin_altivec_vminfp(a, b);
2851}
2852
2853/* vec_mladd */
2854
2855#define __builtin_altivec_vmladduhm vec_mladd
2856
2857static vector short __ATTRS_o_ai
2858vec_mladd(vector short a, vector short b, vector short c)
2859{
2860 return a * b + c;
2861}
2862
2863static vector short __ATTRS_o_ai
2864vec_mladd(vector short a, vector unsigned short b, vector unsigned short c)
2865{
2866 return a * (vector short)b + (vector short)c;
2867}
2868
2869static vector short __ATTRS_o_ai
2870vec_mladd(vector unsigned short a, vector short b, vector short c)
2871{
2872 return (vector short)a * b + c;
2873}
2874
2875static vector unsigned short __ATTRS_o_ai
2876vec_mladd(vector unsigned short a, vector unsigned short b, vector unsigned short c)
2877{
2878 return a * b + c;
2879}
2880
2881/* vec_vmladduhm */
2882
2883static vector short __ATTRS_o_ai
2884vec_vmladduhm(vector short a, vector short b, vector short c)
2885{
2886 return a * b + c;
2887}
2888
2889static vector short __ATTRS_o_ai
2890vec_vmladduhm(vector short a, vector unsigned short b, vector unsigned short c)
2891{
2892 return a * (vector short)b + (vector short)c;
2893}
2894
2895static vector short __ATTRS_o_ai
2896vec_vmladduhm(vector unsigned short a, vector short b, vector short c)
2897{
2898 return (vector short)a * b + c;
2899}
2900
2901static vector unsigned short __ATTRS_o_ai
2902vec_vmladduhm(vector unsigned short a, vector unsigned short b, vector unsigned short c)
2903{
2904 return a * b + c;
2905}
2906
2907/* vec_mradds */
2908
2909static vector short __attribute__((__always_inline__))
2910vec_mradds(vector short a, vector short b, vector short c)
2911{
2912 return __builtin_altivec_vmhraddshs(a, b, c);
2913}
2914
2915/* vec_vmhraddshs */
2916
2917static vector short __attribute__((__always_inline__))
2918vec_vmhraddshs(vector short a, vector short b, vector short c)
2919{
2920 return __builtin_altivec_vmhraddshs(a, b, c);
2921}
2922
2923/* vec_msum */
2924
2925static vector int __ATTRS_o_ai
2926vec_msum(vector signed char a, vector unsigned char b, vector int c)
2927{
2928 return __builtin_altivec_vmsummbm(a, b, c);
2929}
2930
2931static vector unsigned int __ATTRS_o_ai
2932vec_msum(vector unsigned char a, vector unsigned char b, vector unsigned int c)
2933{
2934 return __builtin_altivec_vmsumubm(a, b, c);
2935}
2936
2937static vector int __ATTRS_o_ai
2938vec_msum(vector short a, vector short b, vector int c)
2939{
2940 return __builtin_altivec_vmsumshm(a, b, c);
2941}
2942
2943static vector unsigned int __ATTRS_o_ai
2944vec_msum(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2945{
2946 return __builtin_altivec_vmsumuhm(a, b, c);
2947}
2948
2949/* vec_vmsummbm */
2950
2951static vector int __attribute__((__always_inline__))
2952vec_vmsummbm(vector signed char a, vector unsigned char b, vector int c)
2953{
2954 return __builtin_altivec_vmsummbm(a, b, c);
2955}
2956
2957/* vec_vmsumubm */
2958
2959static vector unsigned int __attribute__((__always_inline__))
2960vec_vmsumubm(vector unsigned char a, vector unsigned char b, vector unsigned int c)
2961{
2962 return __builtin_altivec_vmsumubm(a, b, c);
2963}
2964
2965/* vec_vmsumshm */
2966
2967static vector int __attribute__((__always_inline__))
2968vec_vmsumshm(vector short a, vector short b, vector int c)
2969{
2970 return __builtin_altivec_vmsumshm(a, b, c);
2971}
2972
2973/* vec_vmsumuhm */
2974
2975static vector unsigned int __attribute__((__always_inline__))
2976vec_vmsumuhm(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2977{
2978 return __builtin_altivec_vmsumuhm(a, b, c);
2979}
2980
2981/* vec_msums */
2982
2983static vector int __ATTRS_o_ai
2984vec_msums(vector short a, vector short b, vector int c)
2985{
2986 return __builtin_altivec_vmsumshs(a, b, c);
2987}
2988
2989static vector unsigned int __ATTRS_o_ai
2990vec_msums(vector unsigned short a, vector unsigned short b, vector unsigned int c)
2991{
2992 return __builtin_altivec_vmsumuhs(a, b, c);
2993}
2994
2995/* vec_vmsumshs */
2996
2997static vector int __attribute__((__always_inline__))
2998vec_vmsumshs(vector short a, vector short b, vector int c)
2999{
3000 return __builtin_altivec_vmsumshs(a, b, c);
3001}
3002
3003/* vec_vmsumuhs */
3004
3005static vector unsigned int __attribute__((__always_inline__))
3006vec_vmsumuhs(vector unsigned short a, vector unsigned short b, vector unsigned int c)
3007{
3008 return __builtin_altivec_vmsumuhs(a, b, c);
3009}
3010
Chris Lattnerdd173942010-04-14 03:54:58 +00003011/* vec_mtvscr */
3012
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003013static void __ATTRS_o_ai
3014vec_mtvscr(vector signed char a)
3015{
3016 __builtin_altivec_mtvscr((vector int)a);
3017}
3018
3019static void __ATTRS_o_ai
3020vec_mtvscr(vector unsigned char a)
3021{
3022 __builtin_altivec_mtvscr((vector int)a);
3023}
3024
3025static void __ATTRS_o_ai
3026vec_mtvscr(vector short a)
3027{
3028 __builtin_altivec_mtvscr((vector int)a);
3029}
3030
3031static void __ATTRS_o_ai
3032vec_mtvscr(vector unsigned short a)
3033{
3034 __builtin_altivec_mtvscr((vector int)a);
3035}
3036
3037static void __ATTRS_o_ai
3038vec_mtvscr(vector int a)
3039{
3040 __builtin_altivec_mtvscr((vector int)a);
3041}
3042
3043static void __ATTRS_o_ai
3044vec_mtvscr(vector unsigned int a)
3045{
3046 __builtin_altivec_mtvscr((vector int)a);
3047}
3048
3049static void __ATTRS_o_ai
3050vec_mtvscr(vector float a)
3051{
3052 __builtin_altivec_mtvscr((vector int)a);
3053}
3054
3055/* vec_mule */
3056
3057static vector short __ATTRS_o_ai
3058vec_mule(vector signed char a, vector signed char b)
3059{
3060 return __builtin_altivec_vmulesb(a, b);
3061}
3062
3063static vector unsigned short __ATTRS_o_ai
3064vec_mule(vector unsigned char a, vector unsigned char b)
3065{
3066 return __builtin_altivec_vmuleub(a, b);
3067}
3068
3069static vector int __ATTRS_o_ai
3070vec_mule(vector short a, vector short b)
3071{
3072 return __builtin_altivec_vmulesh(a, b);
3073}
3074
3075static vector unsigned int __ATTRS_o_ai
3076vec_mule(vector unsigned short a, vector unsigned short b)
3077{
3078 return __builtin_altivec_vmuleuh(a, b);
3079}
3080
3081/* vec_vmulesb */
3082
3083static vector short __attribute__((__always_inline__))
3084vec_vmulesb(vector signed char a, vector signed char b)
3085{
3086 return __builtin_altivec_vmulesb(a, b);
3087}
3088
3089/* vec_vmuleub */
3090
3091static vector unsigned short __attribute__((__always_inline__))
3092vec_vmuleub(vector unsigned char a, vector unsigned char b)
3093{
3094 return __builtin_altivec_vmuleub(a, b);
3095}
3096
3097/* vec_vmulesh */
3098
3099static vector int __attribute__((__always_inline__))
3100vec_vmulesh(vector short a, vector short b)
3101{
3102 return __builtin_altivec_vmulesh(a, b);
3103}
3104
3105/* vec_vmuleuh */
3106
3107static vector unsigned int __attribute__((__always_inline__))
3108vec_vmuleuh(vector unsigned short a, vector unsigned short b)
3109{
3110 return __builtin_altivec_vmuleuh(a, b);
3111}
3112
3113/* vec_mulo */
3114
3115static vector short __ATTRS_o_ai
3116vec_mulo(vector signed char a, vector signed char b)
3117{
3118 return __builtin_altivec_vmulosb(a, b);
3119}
3120
3121static vector unsigned short __ATTRS_o_ai
3122vec_mulo(vector unsigned char a, vector unsigned char b)
3123{
3124 return __builtin_altivec_vmuloub(a, b);
3125}
3126
3127static vector int __ATTRS_o_ai
3128vec_mulo(vector short a, vector short b)
3129{
3130 return __builtin_altivec_vmulosh(a, b);
3131}
3132
3133static vector unsigned int __ATTRS_o_ai
3134vec_mulo(vector unsigned short a, vector unsigned short b)
3135{
3136 return __builtin_altivec_vmulouh(a, b);
3137}
3138
3139/* vec_vmulosb */
3140
3141static vector short __attribute__((__always_inline__))
3142vec_vmulosb(vector signed char a, vector signed char b)
3143{
3144 return __builtin_altivec_vmulosb(a, b);
3145}
3146
3147/* vec_vmuloub */
3148
3149static vector unsigned short __attribute__((__always_inline__))
3150vec_vmuloub(vector unsigned char a, vector unsigned char b)
3151{
3152 return __builtin_altivec_vmuloub(a, b);
3153}
3154
3155/* vec_vmulosh */
3156
3157static vector int __attribute__((__always_inline__))
3158vec_vmulosh(vector short a, vector short b)
3159{
3160 return __builtin_altivec_vmulosh(a, b);
3161}
3162
3163/* vec_vmulouh */
3164
3165static vector unsigned int __attribute__((__always_inline__))
3166vec_vmulouh(vector unsigned short a, vector unsigned short b)
3167{
3168 return __builtin_altivec_vmulouh(a, b);
3169}
3170
3171/* vec_nmsub */
3172
3173static vector float __attribute__((__always_inline__))
3174vec_nmsub(vector float a, vector float b, vector float c)
3175{
3176 return __builtin_altivec_vnmsubfp(a, b, c);
3177}
3178
3179/* vec_vnmsubfp */
3180
3181static vector float __attribute__((__always_inline__))
3182vec_vnmsubfp(vector float a, vector float b, vector float c)
3183{
3184 return __builtin_altivec_vnmsubfp(a, b, c);
3185}
3186
3187/* vec_nor */
3188
3189#define __builtin_altivec_vnor vec_nor
3190
3191static vector signed char __ATTRS_o_ai
3192vec_nor(vector signed char a, vector signed char b)
3193{
3194 return ~(a | b);
3195}
3196
3197static vector unsigned char __ATTRS_o_ai
3198vec_nor(vector unsigned char a, vector unsigned char b)
3199{
3200 return ~(a | b);
3201}
3202
3203static vector short __ATTRS_o_ai
3204vec_nor(vector short a, vector short b)
3205{
3206 return ~(a | b);
3207}
3208
3209static vector unsigned short __ATTRS_o_ai
3210vec_nor(vector unsigned short a, vector unsigned short b)
3211{
3212 return ~(a | b);
3213}
3214
3215static vector int __ATTRS_o_ai
3216vec_nor(vector int a, vector int b)
3217{
3218 return ~(a | b);
3219}
3220
3221static vector unsigned int __ATTRS_o_ai
3222vec_nor(vector unsigned int a, vector unsigned int b)
3223{
3224 return ~(a | b);
3225}
3226
3227static vector float __ATTRS_o_ai
3228vec_nor(vector float a, vector float b)
3229{
3230 vector unsigned int res = ~((vector unsigned int)a | (vector unsigned int)b);
3231 return (vector float)res;
3232}
3233
3234/* vec_vnor */
3235
3236static vector signed char __ATTRS_o_ai
3237vec_vnor(vector signed char a, vector signed char b)
3238{
3239 return ~(a | b);
3240}
3241
3242static vector unsigned char __ATTRS_o_ai
3243vec_vnor(vector unsigned char a, vector unsigned char b)
3244{
3245 return ~(a | b);
3246}
3247
3248static vector short __ATTRS_o_ai
3249vec_vnor(vector short a, vector short b)
3250{
3251 return ~(a | b);
3252}
3253
3254static vector unsigned short __ATTRS_o_ai
3255vec_vnor(vector unsigned short a, vector unsigned short b)
3256{
3257 return ~(a | b);
3258}
3259
3260static vector int __ATTRS_o_ai
3261vec_vnor(vector int a, vector int b)
3262{
3263 return ~(a | b);
3264}
3265
3266static vector unsigned int __ATTRS_o_ai
3267vec_vnor(vector unsigned int a, vector unsigned int b)
3268{
3269 return ~(a | b);
3270}
3271
3272static vector float __ATTRS_o_ai
3273vec_vnor(vector float a, vector float b)
3274{
3275 vector unsigned int res = ~((vector unsigned int)a | (vector unsigned int)b);
3276 return (vector float)res;
3277}
3278
3279/* vec_or */
3280
3281#define __builtin_altivec_vor vec_or
3282
3283static vector signed char __ATTRS_o_ai
3284vec_or(vector signed char a, vector signed char b)
3285{
3286 return a | b;
3287}
3288
3289static vector unsigned char __ATTRS_o_ai
3290vec_or(vector unsigned char a, vector unsigned char b)
3291{
3292 return a | b;
3293}
3294
3295static vector short __ATTRS_o_ai
3296vec_or(vector short a, vector short b)
3297{
3298 return a | b;
3299}
3300
3301static vector unsigned short __ATTRS_o_ai
3302vec_or(vector unsigned short a, vector unsigned short b)
3303{
3304 return a | b;
3305}
3306
3307static vector int __ATTRS_o_ai
3308vec_or(vector int a, vector int b)
3309{
3310 return a | b;
3311}
3312
3313static vector unsigned int __ATTRS_o_ai
3314vec_or(vector unsigned int a, vector unsigned int b)
3315{
3316 return a | b;
3317}
3318
3319static vector float __ATTRS_o_ai
3320vec_or(vector float a, vector float b)
3321{
3322 vector unsigned int res = (vector unsigned int)a | (vector unsigned int)b;
3323 return (vector float)res;
3324}
3325
3326/* vec_vor */
3327
3328static vector signed char __ATTRS_o_ai
3329vec_vor(vector signed char a, vector signed char b)
3330{
3331 return a | b;
3332}
3333
3334static vector unsigned char __ATTRS_o_ai
3335vec_vor(vector unsigned char a, vector unsigned char b)
3336{
3337 return a | b;
3338}
3339
3340static vector short __ATTRS_o_ai
3341vec_vor(vector short a, vector short b)
3342{
3343 return a | b;
3344}
3345
3346static vector unsigned short __ATTRS_o_ai
3347vec_vor(vector unsigned short a, vector unsigned short b)
3348{
3349 return a | b;
3350}
3351
3352static vector int __ATTRS_o_ai
3353vec_vor(vector int a, vector int b)
3354{
3355 return a | b;
3356}
3357
3358static vector unsigned int __ATTRS_o_ai
3359vec_vor(vector unsigned int a, vector unsigned int b)
3360{
3361 return a | b;
3362}
3363
3364static vector float __ATTRS_o_ai
3365vec_vor(vector float a, vector float b)
3366{
3367 vector unsigned int res = (vector unsigned int)a | (vector unsigned int)b;
3368 return (vector float)res;
3369}
3370
3371/* vec_pack */
3372
3373static vector signed char __ATTRS_o_ai
3374vec_pack(vector signed short a, vector signed short b)
3375{
3376 return (vector signed char)vec_perm(a, b, (vector unsigned char)
3377 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3378 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3379}
3380
3381static vector unsigned char __ATTRS_o_ai
3382vec_pack(vector unsigned short a, vector unsigned short b)
3383{
3384 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
3385 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3386 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3387}
3388
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003389static vector bool char __ATTRS_o_ai
3390vec_pack(vector bool short a, vector bool short b)
3391{
3392 return (vector bool char)vec_perm(a, b, (vector unsigned char)
3393 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3394 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3395}
3396
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003397static vector short __ATTRS_o_ai
3398vec_pack(vector int a, vector int b)
3399{
3400 return (vector short)vec_perm(a, b, (vector unsigned char)
3401 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3402 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3403}
3404
3405static vector unsigned short __ATTRS_o_ai
3406vec_pack(vector unsigned int a, vector unsigned int b)
3407{
3408 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
3409 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3410 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3411}
3412
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003413static vector bool short __ATTRS_o_ai
3414vec_pack(vector bool int a, vector bool int b)
3415{
3416 return (vector bool short)vec_perm(a, b, (vector unsigned char)
3417 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3418 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3419}
3420
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003421/* vec_vpkuhum */
3422
3423#define __builtin_altivec_vpkuhum vec_vpkuhum
3424
3425static vector signed char __ATTRS_o_ai
3426vec_vpkuhum(vector signed short a, vector signed short b)
3427{
3428 return (vector signed char)vec_perm(a, b, (vector unsigned char)
3429 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3430 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3431}
3432
3433static vector unsigned char __ATTRS_o_ai
3434vec_vpkuhum(vector unsigned short a, vector unsigned short b)
3435{
3436 return (vector unsigned char)vec_perm(a, b, (vector unsigned char)
3437 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3438 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3439}
3440
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003441static vector bool char __ATTRS_o_ai
3442vec_vpkuhum(vector bool short a, vector bool short b)
3443{
3444 return (vector bool char)vec_perm(a, b, (vector unsigned char)
3445 (0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
3446 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
3447}
3448
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003449/* vec_vpkuwum */
3450
3451#define __builtin_altivec_vpkuwum vec_vpkuwum
3452
3453static vector short __ATTRS_o_ai
3454vec_vpkuwum(vector int a, vector int b)
3455{
3456 return (vector short)vec_perm(a, b, (vector unsigned char)
3457 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3458 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3459}
3460
3461static vector unsigned short __ATTRS_o_ai
3462vec_vpkuwum(vector unsigned int a, vector unsigned int b)
3463{
3464 return (vector unsigned short)vec_perm(a, b, (vector unsigned char)
3465 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3466 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3467}
3468
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003469static vector bool short __ATTRS_o_ai
3470vec_vpkuwum(vector bool int a, vector bool int b)
3471{
3472 return (vector bool short)vec_perm(a, b, (vector unsigned char)
3473 (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
3474 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
3475}
3476
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003477/* vec_packpx */
3478
3479static vector pixel __attribute__((__always_inline__))
3480vec_packpx(vector unsigned int a, vector unsigned int b)
3481{
3482 return (vector pixel)__builtin_altivec_vpkpx(a, b);
3483}
3484
3485/* vec_vpkpx */
3486
3487static vector pixel __attribute__((__always_inline__))
3488vec_vpkpx(vector unsigned int a, vector unsigned int b)
3489{
3490 return (vector pixel)__builtin_altivec_vpkpx(a, b);
3491}
3492
3493/* vec_packs */
3494
3495static vector signed char __ATTRS_o_ai
3496vec_packs(vector short a, vector short b)
3497{
3498 return __builtin_altivec_vpkshss(a, b);
3499}
3500
3501static vector unsigned char __ATTRS_o_ai
3502vec_packs(vector unsigned short a, vector unsigned short b)
3503{
3504 return __builtin_altivec_vpkuhus(a, b);
3505}
3506
3507static vector signed short __ATTRS_o_ai
3508vec_packs(vector int a, vector int b)
3509{
3510 return __builtin_altivec_vpkswss(a, b);
3511}
3512
3513static vector unsigned short __ATTRS_o_ai
3514vec_packs(vector unsigned int a, vector unsigned int b)
3515{
3516 return __builtin_altivec_vpkuwus(a, b);
3517}
3518
3519/* vec_vpkshss */
3520
3521static vector signed char __attribute__((__always_inline__))
3522vec_vpkshss(vector short a, vector short b)
3523{
3524 return __builtin_altivec_vpkshss(a, b);
3525}
3526
3527/* vec_vpkuhus */
3528
3529static vector unsigned char __attribute__((__always_inline__))
3530vec_vpkuhus(vector unsigned short a, vector unsigned short b)
3531{
3532 return __builtin_altivec_vpkuhus(a, b);
3533}
3534
3535/* vec_vpkswss */
3536
3537static vector signed short __attribute__((__always_inline__))
3538vec_vpkswss(vector int a, vector int b)
3539{
3540 return __builtin_altivec_vpkswss(a, b);
3541}
3542
3543/* vec_vpkuwus */
3544
3545static vector unsigned short __attribute__((__always_inline__))
3546vec_vpkuwus(vector unsigned int a, vector unsigned int b)
3547{
3548 return __builtin_altivec_vpkuwus(a, b);
3549}
3550
3551/* vec_packsu */
3552
3553static vector unsigned char __ATTRS_o_ai
3554vec_packsu(vector short a, vector short b)
3555{
3556 return __builtin_altivec_vpkshus(a, b);
3557}
3558
3559static vector unsigned char __ATTRS_o_ai
3560vec_packsu(vector unsigned short a, vector unsigned short b)
3561{
3562 return __builtin_altivec_vpkuhus(a, b);
3563}
3564
3565static vector unsigned short __ATTRS_o_ai
3566vec_packsu(vector int a, vector int b)
3567{
3568 return __builtin_altivec_vpkswus(a, b);
3569}
3570
3571static vector unsigned short __ATTRS_o_ai
3572vec_packsu(vector unsigned int a, vector unsigned int b)
3573{
3574 return __builtin_altivec_vpkuwus(a, b);
3575}
3576
3577/* vec_vpkshus */
3578
3579static vector unsigned char __ATTRS_o_ai
3580vec_vpkshus(vector short a, vector short b)
3581{
3582 return __builtin_altivec_vpkshus(a, b);
3583}
3584
3585static vector unsigned char __ATTRS_o_ai
3586vec_vpkshus(vector unsigned short a, vector unsigned short b)
3587{
3588 return __builtin_altivec_vpkuhus(a, b);
3589}
3590
3591/* vec_vpkswus */
3592
3593static vector unsigned short __ATTRS_o_ai
3594vec_vpkswus(vector int a, vector int b)
3595{
3596 return __builtin_altivec_vpkswus(a, b);
3597}
3598
3599static vector unsigned short __ATTRS_o_ai
3600vec_vpkswus(vector unsigned int a, vector unsigned int b)
3601{
3602 return __builtin_altivec_vpkuwus(a, b);
3603}
3604
3605/* vec_perm */
3606
3607vector signed char __ATTRS_o_ai
3608vec_perm(vector signed char a, vector signed char b, vector unsigned char c)
3609{
3610 return (vector signed char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3611}
3612
3613vector unsigned char __ATTRS_o_ai
3614vec_perm(vector unsigned char a, vector unsigned char b, vector unsigned char c)
3615{
3616 return (vector unsigned char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3617}
3618
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003619vector bool char __ATTRS_o_ai
3620vec_perm(vector bool char a, vector bool char b, vector unsigned char c)
3621{
3622 return (vector bool char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3623}
3624
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003625vector short __ATTRS_o_ai
3626vec_perm(vector short a, vector short b, vector unsigned char c)
3627{
3628 return (vector short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3629}
3630
3631vector unsigned short __ATTRS_o_ai
3632vec_perm(vector unsigned short a, vector unsigned short b, vector unsigned char c)
3633{
3634 return (vector unsigned short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3635}
3636
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003637vector bool short __ATTRS_o_ai
3638vec_perm(vector bool short a, vector bool short b, vector unsigned char c)
3639{
3640 return (vector bool short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3641}
3642
3643vector pixel __ATTRS_o_ai
3644vec_perm(vector pixel a, vector pixel b, vector unsigned char c)
3645{
3646 return (vector pixel)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3647}
3648
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003649vector int __ATTRS_o_ai
3650vec_perm(vector int a, vector int b, vector unsigned char c)
3651{
3652 return (vector int)__builtin_altivec_vperm_4si(a, b, c);
3653}
3654
3655vector unsigned int __ATTRS_o_ai
3656vec_perm(vector unsigned int a, vector unsigned int b, vector unsigned char c)
3657{
3658 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3659}
3660
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003661vector bool int __ATTRS_o_ai
3662vec_perm(vector bool int a, vector bool int b, vector unsigned char c)
3663{
3664 return (vector bool int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3665}
3666
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003667vector float __ATTRS_o_ai
3668vec_perm(vector float a, vector float b, vector unsigned char c)
3669{
3670 return (vector float)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3671}
3672
3673/* vec_vperm */
3674
3675vector signed char __ATTRS_o_ai
3676vec_vperm(vector signed char a, vector signed char b, vector unsigned char c)
3677{
3678 return (vector signed char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3679}
3680
3681vector unsigned char __ATTRS_o_ai
3682vec_vperm(vector unsigned char a, vector unsigned char b, vector unsigned char c)
3683{
3684 return (vector unsigned char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3685}
3686
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003687vector bool char __ATTRS_o_ai
3688vec_vperm(vector bool char a, vector bool char b, vector unsigned char c)
3689{
3690 return (vector bool char)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3691}
3692
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003693vector short __ATTRS_o_ai
3694vec_vperm(vector short a, vector short b, vector unsigned char c)
3695{
3696 return (vector short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3697}
3698
3699vector unsigned short __ATTRS_o_ai
3700vec_vperm(vector unsigned short a, vector unsigned short b, vector unsigned char c)
3701{
3702 return (vector unsigned short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3703}
3704
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003705vector bool short __ATTRS_o_ai
3706vec_vperm(vector bool short a, vector bool short b, vector unsigned char c)
3707{
3708 return (vector bool short)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3709}
3710
3711vector pixel __ATTRS_o_ai
3712vec_vperm(vector pixel a, vector pixel b, vector unsigned char c)
3713{
3714 return (vector pixel)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3715}
3716
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003717vector int __ATTRS_o_ai
3718vec_vperm(vector int a, vector int b, vector unsigned char c)
3719{
3720 return (vector int)__builtin_altivec_vperm_4si(a, b, c);
3721}
3722
3723vector unsigned int __ATTRS_o_ai
3724vec_vperm(vector unsigned int a, vector unsigned int b, vector unsigned char c)
3725{
3726 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3727}
3728
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00003729vector bool int __ATTRS_o_ai
3730vec_vperm(vector bool int a, vector bool int b, vector unsigned char c)
3731{
3732 return (vector bool int)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3733}
3734
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00003735vector float __ATTRS_o_ai
3736vec_vperm(vector float a, vector float b, vector unsigned char c)
3737{
3738 return (vector float)__builtin_altivec_vperm_4si((vector int)a, (vector int)b, c);
3739}
3740
3741/* vec_re */
3742
3743vector float __attribute__((__always_inline__))
3744vec_re(vector float a)
3745{
3746 return __builtin_altivec_vrefp(a);
3747}
3748
3749/* vec_vrefp */
3750
3751vector float __attribute__((__always_inline__))
3752vec_vrefp(vector float a)
3753{
3754 return __builtin_altivec_vrefp(a);
3755}
3756
3757/* vec_rl */
3758
3759static vector signed char __ATTRS_o_ai
3760vec_rl(vector signed char a, vector unsigned char b)
3761{
3762 return (vector signed char)__builtin_altivec_vrlb((vector char)a, b);
3763}
3764
3765static vector unsigned char __ATTRS_o_ai
3766vec_rl(vector unsigned char a, vector unsigned char b)
3767{
3768 return (vector unsigned char)__builtin_altivec_vrlb((vector char)a, b);
3769}
3770
3771static vector short __ATTRS_o_ai
3772vec_rl(vector short a, vector unsigned short b)
3773{
3774 return __builtin_altivec_vrlh(a, b);
3775}
3776
3777static vector unsigned short __ATTRS_o_ai
3778vec_rl(vector unsigned short a, vector unsigned short b)
3779{
3780 return (vector unsigned short)__builtin_altivec_vrlh((vector short)a, b);
3781}
3782
3783static vector int __ATTRS_o_ai
3784vec_rl(vector int a, vector unsigned int b)
3785{
3786 return __builtin_altivec_vrlw(a, b);
3787}
3788
3789static vector unsigned int __ATTRS_o_ai
3790vec_rl(vector unsigned int a, vector unsigned int b)
3791{
3792 return (vector unsigned int)__builtin_altivec_vrlw((vector int)a, b);
3793}
3794
3795/* vec_vrlb */
3796
3797static vector signed char __ATTRS_o_ai
3798vec_vrlb(vector signed char a, vector unsigned char b)
3799{
3800 return (vector signed char)__builtin_altivec_vrlb((vector char)a, b);
3801}
3802
3803static vector unsigned char __ATTRS_o_ai
3804vec_vrlb(vector unsigned char a, vector unsigned char b)
3805{
3806 return (vector unsigned char)__builtin_altivec_vrlb((vector char)a, b);
3807}
3808
3809/* vec_vrlh */
3810
3811static vector short __ATTRS_o_ai
3812vec_vrlh(vector short a, vector unsigned short b)
3813{
3814 return __builtin_altivec_vrlh(a, b);
3815}
3816
3817static vector unsigned short __ATTRS_o_ai
3818vec_vrlh(vector unsigned short a, vector unsigned short b)
3819{
3820 return (vector unsigned short)__builtin_altivec_vrlh((vector short)a, b);
3821}
3822
3823/* vec_vrlw */
3824
3825static vector int __ATTRS_o_ai
3826vec_vrlw(vector int a, vector unsigned int b)
3827{
3828 return __builtin_altivec_vrlw(a, b);
3829}
3830
3831static vector unsigned int __ATTRS_o_ai
3832vec_vrlw(vector unsigned int a, vector unsigned int b)
3833{
3834 return (vector unsigned int)__builtin_altivec_vrlw((vector int)a, b);
3835}
3836
3837/* vec_round */
3838
3839static vector float __attribute__((__always_inline__))
3840vec_round(vector float a)
3841{
3842 return __builtin_altivec_vrfin(a);
3843}
3844
3845/* vec_vrfin */
3846
3847static vector float __attribute__((__always_inline__))
3848vec_vrfin(vector float a)
3849{
3850 return __builtin_altivec_vrfin(a);
3851}
3852
3853/* vec_rsqrte */
3854
3855static __vector float __attribute__((__always_inline__))
3856vec_rsqrte(vector float a)
3857{
3858 return __builtin_altivec_vrsqrtefp(a);
3859}
3860
3861/* vec_vrsqrtefp */
3862
3863static __vector float __attribute__((__always_inline__))
3864vec_vrsqrtefp(vector float a)
3865{
3866 return __builtin_altivec_vrsqrtefp(a);
3867}
3868
3869/* vec_sel */
3870
3871#define __builtin_altivec_vsel_4si vec_sel
3872
3873static vector signed char __ATTRS_o_ai
3874vec_sel(vector signed char a, vector signed char b, vector unsigned char c)
3875{
3876 return (a & ~(vector signed char)c) | (b & (vector signed char)c);
3877}
3878
3879static vector unsigned char __ATTRS_o_ai
3880vec_sel(vector unsigned char a, vector unsigned char b, vector unsigned char c)
3881{
3882 return (a & ~c) | (b & c);
3883}
3884
3885static vector short __ATTRS_o_ai
3886vec_sel(vector short a, vector short b, vector unsigned short c)
3887{
3888 return (a & ~(vector short)c) | (b & (vector short)c);
3889}
3890
3891static vector unsigned short __ATTRS_o_ai
3892vec_sel(vector unsigned short a, vector unsigned short b, vector unsigned short c)
3893{
3894 return (a & ~c) | (b & c);
3895}
3896
3897static vector int __ATTRS_o_ai
3898vec_sel(vector int a, vector int b, vector unsigned int c)
3899{
3900 return (a & ~(vector int)c) | (b & (vector int)c);
3901}
3902
3903static vector unsigned int __ATTRS_o_ai
3904vec_sel(vector unsigned int a, vector unsigned int b, vector unsigned int c)
3905{
3906 return (a & ~c) | (b & c);
3907}
3908
3909static vector float __ATTRS_o_ai
3910vec_sel(vector float a, vector float b, vector unsigned int c)
3911{
3912 vector int res = ((vector int)a & ~(vector int)c) | ((vector int)b & (vector int)c);
3913 return (vector float)res;
3914}
3915
3916/* vec_vsel */
3917
3918static vector signed char __ATTRS_o_ai
3919vec_vsel(vector signed char a, vector signed char b, vector unsigned char c)
3920{
3921 return (a & ~(vector signed char)c) | (b & (vector signed char)c);
3922}
3923
3924static vector unsigned char __ATTRS_o_ai
3925vec_vsel(vector unsigned char a, vector unsigned char b, vector unsigned char c)
3926{
3927 return (a & ~c) | (b & c);
3928}
3929
3930static vector short __ATTRS_o_ai
3931vec_vsel(vector short a, vector short b, vector unsigned short c)
3932{
3933 return (a & ~(vector short)c) | (b & (vector short)c);
3934}
3935
3936static vector unsigned short __ATTRS_o_ai
3937vec_vsel(vector unsigned short a, vector unsigned short b, vector unsigned short c)
3938{
3939 return (a & ~c) | (b & c);
3940}
3941
3942static vector int __ATTRS_o_ai
3943vec_vsel(vector int a, vector int b, vector unsigned int c)
3944{
3945 return (a & ~(vector int)c) | (b & (vector int)c);
3946}
3947
3948static vector unsigned int __ATTRS_o_ai
3949vec_vsel(vector unsigned int a, vector unsigned int b, vector unsigned int c)
3950{
3951 return (a & ~c) | (b & c);
3952}
3953
3954static vector float __ATTRS_o_ai
3955vec_vsel(vector float a, vector float b, vector unsigned int c)
3956{
3957 vector int res = ((vector int)a & ~(vector int)c) | ((vector int)b & (vector int)c);
3958 return (vector float)res;
3959}
3960
3961/* vec_sl */
3962
3963static vector signed char __ATTRS_o_ai
3964vec_sl(vector signed char a, vector unsigned char b)
3965{
3966 return a << (vector signed char)b;
3967}
3968
3969static vector unsigned char __ATTRS_o_ai
3970vec_sl(vector unsigned char a, vector unsigned char b)
3971{
3972 return a << b;
3973}
3974
3975static vector short __ATTRS_o_ai
3976vec_sl(vector short a, vector unsigned short b)
3977{
3978 return a << (vector short)b;
3979}
3980
3981static vector unsigned short __ATTRS_o_ai
3982vec_sl(vector unsigned short a, vector unsigned short b)
3983{
3984 return a << b;
3985}
3986
3987static vector int __ATTRS_o_ai
3988vec_sl(vector int a, vector unsigned int b)
3989{
3990 return a << (vector int)b;
3991}
3992
3993static vector unsigned int __ATTRS_o_ai
3994vec_sl(vector unsigned int a, vector unsigned int b)
3995{
3996 return a << b;
3997}
3998
3999/* vec_vslb */
4000
4001#define __builtin_altivec_vslb vec_vslb
4002
4003static vector signed char __ATTRS_o_ai
4004vec_vslb(vector signed char a, vector unsigned char b)
4005{
4006 return vec_sl(a, b);
4007}
4008
4009static vector unsigned char __ATTRS_o_ai
4010vec_vslb(vector unsigned char a, vector unsigned char b)
4011{
4012 return vec_sl(a, b);
4013}
4014
4015/* vec_vslh */
4016
4017#define __builtin_altivec_vslh vec_vslh
4018
4019static vector short __ATTRS_o_ai
4020vec_vslh(vector short a, vector unsigned short b)
4021{
4022 return vec_sl(a, b);
4023}
4024
4025static vector unsigned short __ATTRS_o_ai
4026vec_vslh(vector unsigned short a, vector unsigned short b)
4027{
4028 return vec_sl(a, b);
4029}
4030
4031/* vec_vslw */
4032
4033#define __builtin_altivec_vslw vec_vslw
4034
4035static vector int __ATTRS_o_ai
4036vec_vslw(vector int a, vector unsigned int b)
4037{
4038 return vec_sl(a, b);
4039}
4040
4041static vector unsigned int __ATTRS_o_ai
4042vec_vslw(vector unsigned int a, vector unsigned int b)
4043{
4044 return vec_sl(a, b);
4045}
4046
4047/* vec_sld */
4048
4049#define __builtin_altivec_vsldoi_4si vec_sld
4050
4051static vector signed char __ATTRS_o_ai
4052vec_sld(vector signed char a, vector signed char b, unsigned char c)
4053{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004054 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004055 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4056 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4057}
4058
4059static vector unsigned char __ATTRS_o_ai
4060vec_sld(vector unsigned char a, vector unsigned char b, unsigned char c)
4061{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004062 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004063 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4064 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4065}
4066
4067static vector short __ATTRS_o_ai
4068vec_sld(vector short a, vector short b, unsigned char c)
4069{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004070 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004071 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4072 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4073}
4074
4075static vector unsigned short __ATTRS_o_ai
4076vec_sld(vector unsigned short a, vector unsigned short b, unsigned char c)
4077{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004078 return vec_perm(a, b, (vector unsigned char)
4079 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4080 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4081}
4082
4083static vector pixel __ATTRS_o_ai
4084vec_sld(vector pixel a, vector pixel b, unsigned char c)
4085{
4086 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004087 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4088 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4089}
4090
4091static vector int __ATTRS_o_ai
4092vec_sld(vector int a, vector int b, unsigned char c)
4093{
4094 return vec_perm(a, b, (vector unsigned char)
4095 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4096 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4097}
4098
4099static vector unsigned int __ATTRS_o_ai
4100vec_sld(vector unsigned int a, vector unsigned int b, unsigned char c)
4101{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004102 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004103 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4104 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4105}
4106
4107static vector float __ATTRS_o_ai
4108vec_sld(vector float a, vector float b, unsigned char c)
4109{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004110 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004111 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4112 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4113}
4114
4115/* vec_vsldoi */
4116
4117static vector signed char __ATTRS_o_ai
4118vec_vsldoi(vector signed char a, vector signed char b, unsigned char c)
4119{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004120 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004121 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4122 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4123}
4124
4125static vector unsigned char __ATTRS_o_ai
4126vec_vsldoi(vector unsigned char a, vector unsigned char b, unsigned char c)
4127{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004128 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004129 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4130 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4131}
4132
4133static vector short __ATTRS_o_ai
4134vec_vsldoi(vector short a, vector short b, unsigned char c)
4135{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004136 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004137 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4138 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4139}
4140
4141static vector unsigned short __ATTRS_o_ai
4142vec_vsldoi(vector unsigned short a, vector unsigned short b, unsigned char c)
4143{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004144 return vec_perm(a, b, (vector unsigned char)
4145 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4146 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4147}
4148
4149static vector pixel __ATTRS_o_ai
4150vec_vsldoi(vector pixel a, vector pixel b, unsigned char c)
4151{
4152 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004153 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4154 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4155}
4156
4157static vector int __ATTRS_o_ai
4158vec_vsldoi(vector int a, vector int b, unsigned char c)
4159{
4160 return vec_perm(a, b, (vector unsigned char)
4161 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4162 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4163}
4164
4165static vector unsigned int __ATTRS_o_ai
4166vec_vsldoi(vector unsigned int a, vector unsigned int b, unsigned char c)
4167{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004168 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004169 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4170 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4171}
4172
4173static vector float __ATTRS_o_ai
4174vec_vsldoi(vector float a, vector float b, unsigned char c)
4175{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004176 return vec_perm(a, b, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004177 (c, c+1, c+2, c+3, c+4, c+5, c+6, c+7,
4178 c+8, c+9, c+10, c+11, c+12, c+13, c+14, c+15));
4179}
4180
4181/* vec_sll */
4182
4183static vector signed char __ATTRS_o_ai
4184vec_sll(vector signed char a, vector unsigned char b)
4185{
4186 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4187}
4188
4189static vector signed char __ATTRS_o_ai
4190vec_sll(vector signed char a, vector unsigned short b)
4191{
4192 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4193}
4194
4195static vector signed char __ATTRS_o_ai
4196vec_sll(vector signed char a, vector unsigned int b)
4197{
4198 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4199}
4200
4201static vector unsigned char __ATTRS_o_ai
4202vec_sll(vector unsigned char a, vector unsigned char b)
4203{
4204 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4205}
4206
4207static vector unsigned char __ATTRS_o_ai
4208vec_sll(vector unsigned char a, vector unsigned short b)
4209{
4210 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4211}
4212
4213static vector unsigned char __ATTRS_o_ai
4214vec_sll(vector unsigned char a, vector unsigned int b)
4215{
4216 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4217}
4218
4219static vector short __ATTRS_o_ai
4220vec_sll(vector short a, vector unsigned char b)
4221{
4222 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4223}
4224
4225static vector short __ATTRS_o_ai
4226vec_sll(vector short a, vector unsigned short b)
4227{
4228 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4229}
4230
4231static vector short __ATTRS_o_ai
4232vec_sll(vector short a, vector unsigned int b)
4233{
4234 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4235}
4236
4237static vector unsigned short __ATTRS_o_ai
4238vec_sll(vector unsigned short a, vector unsigned char b)
4239{
4240 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4241}
4242
4243static vector unsigned short __ATTRS_o_ai
4244vec_sll(vector unsigned short a, vector unsigned short b)
4245{
4246 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4247}
4248
4249static vector unsigned short __ATTRS_o_ai
4250vec_sll(vector unsigned short a, vector unsigned int b)
4251{
4252 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4253}
4254
4255static vector int __ATTRS_o_ai
4256vec_sll(vector int a, vector unsigned char b)
4257{
4258 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4259}
4260
4261static vector int __ATTRS_o_ai
4262vec_sll(vector int a, vector unsigned short b)
4263{
4264 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4265}
4266
4267static vector int __ATTRS_o_ai
4268vec_sll(vector int a, vector unsigned int b)
4269{
4270 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4271}
4272
4273static vector unsigned int __ATTRS_o_ai
4274vec_sll(vector unsigned int a, vector unsigned char b)
4275{
4276 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4277}
4278
4279static vector unsigned int __ATTRS_o_ai
4280vec_sll(vector unsigned int a, vector unsigned short b)
4281{
4282 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4283}
4284
4285static vector unsigned int __ATTRS_o_ai
4286vec_sll(vector unsigned int a, vector unsigned int b)
4287{
4288 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4289}
4290
4291/* vec_vsl */
4292
4293static vector signed char __ATTRS_o_ai
4294vec_vsl(vector signed char a, vector unsigned char b)
4295{
4296 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4297}
4298
4299static vector signed char __ATTRS_o_ai
4300vec_vsl(vector signed char a, vector unsigned short b)
4301{
4302 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4303}
4304
4305static vector signed char __ATTRS_o_ai
4306vec_vsl(vector signed char a, vector unsigned int b)
4307{
4308 return (vector signed char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4309}
4310
4311static vector unsigned char __ATTRS_o_ai
4312vec_vsl(vector unsigned char a, vector unsigned char b)
4313{
4314 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4315}
4316
4317static vector unsigned char __ATTRS_o_ai
4318vec_vsl(vector unsigned char a, vector unsigned short b)
4319{
4320 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4321}
4322
4323static vector unsigned char __ATTRS_o_ai
4324vec_vsl(vector unsigned char a, vector unsigned int b)
4325{
4326 return (vector unsigned char)__builtin_altivec_vsl((vector int)a, (vector int)b);
4327}
4328
4329static vector short __ATTRS_o_ai
4330vec_vsl(vector short a, vector unsigned char b)
4331{
4332 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4333}
4334
4335static vector short __ATTRS_o_ai
4336vec_vsl(vector short a, vector unsigned short b)
4337{
4338 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4339}
4340
4341static vector short __ATTRS_o_ai
4342vec_vsl(vector short a, vector unsigned int b)
4343{
4344 return (vector short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4345}
4346
4347static vector unsigned short __ATTRS_o_ai
4348vec_vsl(vector unsigned short a, vector unsigned char b)
4349{
4350 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4351}
4352
4353static vector unsigned short __ATTRS_o_ai
4354vec_vsl(vector unsigned short a, vector unsigned short b)
4355{
4356 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4357}
4358
4359static vector unsigned short __ATTRS_o_ai
4360vec_vsl(vector unsigned short a, vector unsigned int b)
4361{
4362 return (vector unsigned short)__builtin_altivec_vsl((vector int)a, (vector int)b);
4363}
4364
4365static vector int __ATTRS_o_ai
4366vec_vsl(vector int a, vector unsigned char b)
4367{
4368 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4369}
4370
4371static vector int __ATTRS_o_ai
4372vec_vsl(vector int a, vector unsigned short b)
4373{
4374 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4375}
4376
4377static vector int __ATTRS_o_ai
4378vec_vsl(vector int a, vector unsigned int b)
4379{
4380 return (vector int)__builtin_altivec_vsl(a, (vector int)b);
4381}
4382
4383static vector unsigned int __ATTRS_o_ai
4384vec_vsl(vector unsigned int a, vector unsigned char b)
4385{
4386 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4387}
4388
4389static vector unsigned int __ATTRS_o_ai
4390vec_vsl(vector unsigned int a, vector unsigned short b)
4391{
4392 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4393}
4394
4395static vector unsigned int __ATTRS_o_ai
4396vec_vsl(vector unsigned int a, vector unsigned int b)
4397{
4398 return (vector unsigned int)__builtin_altivec_vsl((vector int)a, (vector int)b);
4399}
4400
4401/* vec_slo */
4402
4403static vector signed char __ATTRS_o_ai
4404vec_slo(vector signed char a, vector signed char b)
4405{
4406 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4407}
4408
4409static vector signed char __ATTRS_o_ai
4410vec_slo(vector signed char a, vector unsigned char b)
4411{
4412 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4413}
4414
4415static vector unsigned char __ATTRS_o_ai
4416vec_slo(vector unsigned char a, vector signed char b)
4417{
4418 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4419}
4420
4421static vector unsigned char __ATTRS_o_ai
4422vec_slo(vector unsigned char a, vector unsigned char b)
4423{
4424 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4425}
4426
4427static vector short __ATTRS_o_ai
4428vec_slo(vector short a, vector signed char b)
4429{
4430 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4431}
4432
4433static vector short __ATTRS_o_ai
4434vec_slo(vector short a, vector unsigned char b)
4435{
4436 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4437}
4438
4439static vector unsigned short __ATTRS_o_ai
4440vec_slo(vector unsigned short a, vector signed char b)
4441{
4442 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4443}
4444
4445static vector unsigned short __ATTRS_o_ai
4446vec_slo(vector unsigned short a, vector unsigned char b)
4447{
4448 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4449}
4450
4451static vector int __ATTRS_o_ai
4452vec_slo(vector int a, vector signed char b)
4453{
4454 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
4455}
4456
4457static vector int __ATTRS_o_ai
4458vec_slo(vector int a, vector unsigned char b)
4459{
4460 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
4461}
4462
4463static vector unsigned int __ATTRS_o_ai
4464vec_slo(vector unsigned int a, vector signed char b)
4465{
4466 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
4467}
4468
4469static vector unsigned int __ATTRS_o_ai
4470vec_slo(vector unsigned int a, vector unsigned char b)
4471{
4472 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
4473}
4474
4475static vector float __ATTRS_o_ai
4476vec_slo(vector float a, vector signed char b)
4477{
4478 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
4479}
4480
4481static vector float __ATTRS_o_ai
4482vec_slo(vector float a, vector unsigned char b)
4483{
4484 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
4485}
4486
4487/* vec_vslo */
4488
4489static vector signed char __ATTRS_o_ai
4490vec_vslo(vector signed char a, vector signed char b)
4491{
4492 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4493}
4494
4495static vector signed char __ATTRS_o_ai
4496vec_vslo(vector signed char a, vector unsigned char b)
4497{
4498 return (vector signed char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4499}
4500
4501static vector unsigned char __ATTRS_o_ai
4502vec_vslo(vector unsigned char a, vector signed char b)
4503{
4504 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4505}
4506
4507static vector unsigned char __ATTRS_o_ai
4508vec_vslo(vector unsigned char a, vector unsigned char b)
4509{
4510 return (vector unsigned char)__builtin_altivec_vslo((vector int)a, (vector int)b);
4511}
4512
4513static vector short __ATTRS_o_ai
4514vec_vslo(vector short a, vector signed char b)
4515{
4516 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4517}
4518
4519static vector short __ATTRS_o_ai
4520vec_vslo(vector short a, vector unsigned char b)
4521{
4522 return (vector short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4523}
4524
4525static vector unsigned short __ATTRS_o_ai
4526vec_vslo(vector unsigned short a, vector signed char b)
4527{
4528 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4529}
4530
4531static vector unsigned short __ATTRS_o_ai
4532vec_vslo(vector unsigned short a, vector unsigned char b)
4533{
4534 return (vector unsigned short)__builtin_altivec_vslo((vector int)a, (vector int)b);
4535}
4536
4537static vector int __ATTRS_o_ai
4538vec_vslo(vector int a, vector signed char b)
4539{
4540 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
4541}
4542
4543static vector int __ATTRS_o_ai
4544vec_vslo(vector int a, vector unsigned char b)
4545{
4546 return (vector int)__builtin_altivec_vslo(a, (vector int)b);
4547}
4548
4549static vector unsigned int __ATTRS_o_ai
4550vec_vslo(vector unsigned int a, vector signed char b)
4551{
4552 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
4553}
4554
4555static vector unsigned int __ATTRS_o_ai
4556vec_vslo(vector unsigned int a, vector unsigned char b)
4557{
4558 return (vector unsigned int)__builtin_altivec_vslo((vector int)a, (vector int)b);
4559}
4560
4561static vector float __ATTRS_o_ai
4562vec_vslo(vector float a, vector signed char b)
4563{
4564 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
4565}
4566
4567static vector float __ATTRS_o_ai
4568vec_vslo(vector float a, vector unsigned char b)
4569{
4570 return (vector float)__builtin_altivec_vslo((vector int)a, (vector int)b);
4571}
4572
4573/* vec_splat */
4574
4575static vector signed char __ATTRS_o_ai
4576vec_splat(vector signed char a, unsigned char b)
4577{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004578 return vec_perm(a, a, (vector unsigned char)(b));
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004579}
4580
4581static vector unsigned char __ATTRS_o_ai
4582vec_splat(vector unsigned char a, unsigned char b)
4583{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004584 return vec_perm(a, a, (vector unsigned char)(b));
4585}
4586
4587static vector bool char __ATTRS_o_ai
4588vec_splat(vector bool char a, unsigned char b)
4589{
4590 return vec_perm(a, a, (vector unsigned char)(b));
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004591}
4592
4593static vector short __ATTRS_o_ai
4594vec_splat(vector short a, unsigned char b)
4595{
4596 b *= 2;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004597 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004598 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4599}
4600
4601static vector unsigned short __ATTRS_o_ai
4602vec_splat(vector unsigned short a, unsigned char b)
4603{
4604 b *= 2;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004605 return vec_perm(a, a, (vector unsigned char)
4606 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4607}
4608
4609static vector bool short __ATTRS_o_ai
4610vec_splat(vector bool short a, unsigned char b)
4611{
4612 b *= 2;
4613 return vec_perm(a, a, (vector unsigned char)
4614 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4615}
4616
4617static vector pixel __ATTRS_o_ai
4618vec_splat(vector pixel a, unsigned char b)
4619{
4620 b *= 2;
4621 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004622 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4623}
4624
4625static vector int __ATTRS_o_ai
4626vec_splat(vector int a, unsigned char b)
4627{
4628 b *= 4;
4629 return vec_perm(a, a, (vector unsigned char)
4630 (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));
4631}
4632
4633static vector unsigned int __ATTRS_o_ai
4634vec_splat(vector unsigned int a, unsigned char b)
4635{
4636 b *= 4;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004637 return vec_perm(a, a, (vector unsigned char)
4638 (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));
4639}
4640
4641static vector bool int __ATTRS_o_ai
4642vec_splat(vector bool int a, unsigned char b)
4643{
4644 b *= 4;
4645 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004646 (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));
4647}
4648
4649static vector float __ATTRS_o_ai
4650vec_splat(vector float a, unsigned char b)
4651{
4652 b *= 4;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004653 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004654 (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));
4655}
4656
4657/* vec_vspltb */
4658
4659#define __builtin_altivec_vspltb vec_vspltb
4660
4661static vector signed char __ATTRS_o_ai
4662vec_vspltb(vector signed char a, unsigned char b)
4663{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004664 return vec_perm(a, a, (vector unsigned char)(b));
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004665}
4666
4667static vector unsigned char __ATTRS_o_ai
4668vec_vspltb(vector unsigned char a, unsigned char b)
4669{
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004670 return vec_perm(a, a, (vector unsigned char)(b));
4671}
4672
4673static vector bool char __ATTRS_o_ai
4674vec_vspltb(vector bool char a, unsigned char b)
4675{
4676 return vec_perm(a, a, (vector unsigned char)(b));
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004677}
4678
4679/* vec_vsplth */
4680
4681#define __builtin_altivec_vsplth vec_vsplth
4682
4683static vector short __ATTRS_o_ai
4684vec_vsplth(vector short a, unsigned char b)
4685{
4686 b *= 2;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004687 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004688 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4689}
4690
4691static vector unsigned short __ATTRS_o_ai
4692vec_vsplth(vector unsigned short a, unsigned char b)
4693{
4694 b *= 2;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004695 return vec_perm(a, a, (vector unsigned char)
4696 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4697}
4698
4699static vector bool short __ATTRS_o_ai
4700vec_vsplth(vector bool short a, unsigned char b)
4701{
4702 b *= 2;
4703 return vec_perm(a, a, (vector unsigned char)
4704 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4705}
4706
4707static vector pixel __ATTRS_o_ai
4708vec_vsplth(vector pixel a, unsigned char b)
4709{
4710 b *= 2;
4711 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004712 (b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1, b, b+1));
4713}
4714
4715/* vec_vspltw */
4716
4717#define __builtin_altivec_vspltw vec_vspltw
4718
4719static vector int __ATTRS_o_ai
4720vec_vspltw(vector int a, unsigned char b)
4721{
4722 b *= 4;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004723 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004724 (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));
4725}
4726
4727static vector unsigned int __ATTRS_o_ai
4728vec_vspltw(vector unsigned int a, unsigned char b)
4729{
4730 b *= 4;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004731 return vec_perm(a, a, (vector unsigned char)
4732 (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));
4733}
4734
4735static vector bool int __ATTRS_o_ai
4736vec_vspltw(vector bool int a, unsigned char b)
4737{
4738 b *= 4;
4739 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004740 (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));
4741}
4742
4743static vector float __ATTRS_o_ai
4744vec_vspltw(vector float a, unsigned char b)
4745{
4746 b *= 4;
Anton Yartsevf54dbfd2010-08-19 03:00:09 +00004747 return vec_perm(a, a, (vector unsigned char)
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00004748 (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));
4749}
4750
4751/* vec_splat_s8 */
4752
4753#define __builtin_altivec_vspltisb vec_splat_s8
4754
4755// FIXME: parameter should be treated as 5-bit signed literal
4756static vector signed char __ATTRS_o_ai
4757vec_splat_s8(signed char a)
4758{
4759 return (vector signed char)(a);
4760}
4761
4762/* vec_vspltisb */
4763
4764// FIXME: parameter should be treated as 5-bit signed literal
4765static vector signed char __ATTRS_o_ai
4766vec_vspltisb(signed char a)
4767{
4768 return (vector signed char)(a);
4769}
4770
4771/* vec_splat_s16 */
4772
4773#define __builtin_altivec_vspltish vec_splat_s16
4774
4775// FIXME: parameter should be treated as 5-bit signed literal
4776static vector short __ATTRS_o_ai
4777vec_splat_s16(signed char a)
4778{
4779 return (vector short)(a);
4780}
4781
4782/* vec_vspltish */
4783
4784// FIXME: parameter should be treated as 5-bit signed literal
4785static vector short __ATTRS_o_ai
4786vec_vspltish(signed char a)
4787{
4788 return (vector short)(a);
4789}
4790
4791/* vec_splat_s32 */
4792
4793#define __builtin_altivec_vspltisw vec_splat_s32
4794
4795// FIXME: parameter should be treated as 5-bit signed literal
4796static vector int __ATTRS_o_ai
4797vec_splat_s32(signed char a)
4798{
4799 return (vector int)(a);
4800}
4801
4802/* vec_vspltisw */
4803
4804// FIXME: parameter should be treated as 5-bit signed literal
4805static vector int __ATTRS_o_ai
4806vec_vspltisw(signed char a)
4807{
4808 return (vector int)(a);
4809}
4810
4811/* vec_splat_u8 */
4812
4813// FIXME: parameter should be treated as 5-bit signed literal
4814static vector unsigned char __ATTRS_o_ai
4815vec_splat_u8(unsigned char a)
4816{
4817 return (vector unsigned char)(a);
4818}
4819
4820/* vec_splat_u16 */
4821
4822// FIXME: parameter should be treated as 5-bit signed literal
4823static vector unsigned short __ATTRS_o_ai
4824vec_splat_u16(signed char a)
4825{
4826 return (vector unsigned short)(a);
4827}
4828
4829/* vec_splat_u32 */
4830
4831// FIXME: parameter should be treated as 5-bit signed literal
4832static vector unsigned int __ATTRS_o_ai
4833vec_splat_u32(signed char a)
4834{
4835 return (vector unsigned int)(a);
4836}
4837
4838/* vec_sr */
4839
4840static vector signed char __ATTRS_o_ai
4841vec_sr(vector signed char a, vector unsigned char b)
4842{
4843 return a >> (vector signed char)b;
4844}
4845
4846static vector unsigned char __ATTRS_o_ai
4847vec_sr(vector unsigned char a, vector unsigned char b)
4848{
4849 return a >> b;
4850}
4851
4852static vector short __ATTRS_o_ai
4853vec_sr(vector short a, vector unsigned short b)
4854{
4855 return a >> (vector short)b;
4856}
4857
4858static vector unsigned short __ATTRS_o_ai
4859vec_sr(vector unsigned short a, vector unsigned short b)
4860{
4861 return a >> b;
4862}
4863
4864static vector int __ATTRS_o_ai
4865vec_sr(vector int a, vector unsigned int b)
4866{
4867 return a >> (vector int)b;
4868}
4869
4870static vector unsigned int __ATTRS_o_ai
4871vec_sr(vector unsigned int a, vector unsigned int b)
4872{
4873 return a >> b;
4874}
4875
4876/* vec_vsrb */
4877
4878#define __builtin_altivec_vsrb vec_vsrb
4879
4880static vector signed char __ATTRS_o_ai
4881vec_vsrb(vector signed char a, vector unsigned char b)
4882{
4883 return a >> (vector signed char)b;
4884}
4885
4886static vector unsigned char __ATTRS_o_ai
4887vec_vsrb(vector unsigned char a, vector unsigned char b)
4888{
4889 return a >> b;
4890}
4891
4892/* vec_vsrh */
4893
4894#define __builtin_altivec_vsrh vec_vsrh
4895
4896static vector short __ATTRS_o_ai
4897vec_vsrh(vector short a, vector unsigned short b)
4898{
4899 return a >> (vector short)b;
4900}
4901
4902static vector unsigned short __ATTRS_o_ai
4903vec_vsrh(vector unsigned short a, vector unsigned short b)
4904{
4905 return a >> b;
4906}
4907
4908/* vec_vsrw */
4909
4910#define __builtin_altivec_vsrw vec_vsrw
4911
4912static vector int __ATTRS_o_ai
4913vec_vsrw(vector int a, vector unsigned int b)
4914{
4915 return a >> (vector int)b;
4916}
4917
4918static vector unsigned int __ATTRS_o_ai
4919vec_vsrw(vector unsigned int a, vector unsigned int b)
4920{
4921 return a >> b;
4922}
4923
4924/* vec_sra */
4925
4926static vector signed char __ATTRS_o_ai
4927vec_sra(vector signed char a, vector unsigned char b)
4928{
4929 return (vector signed char)__builtin_altivec_vsrab((vector char)a, b);
4930}
4931
4932static vector unsigned char __ATTRS_o_ai
4933vec_sra(vector unsigned char a, vector unsigned char b)
4934{
4935 return (vector unsigned char)__builtin_altivec_vsrab((vector char)a, b);
4936}
4937
4938static vector short __ATTRS_o_ai
4939vec_sra(vector short a, vector unsigned short b)
4940{
4941 return __builtin_altivec_vsrah(a, (vector unsigned short)b);
4942}
4943
4944static vector unsigned short __ATTRS_o_ai
4945vec_sra(vector unsigned short a, vector unsigned short b)
4946{
4947 return (vector unsigned short)__builtin_altivec_vsrah((vector short)a, b);
4948}
4949
4950static vector int __ATTRS_o_ai
4951vec_sra(vector int a, vector unsigned int b)
4952{
4953 return __builtin_altivec_vsraw(a, b);
4954}
4955
4956static vector unsigned int __ATTRS_o_ai
4957vec_sra(vector unsigned int a, vector unsigned int b)
4958{
4959 return (vector unsigned int)__builtin_altivec_vsraw((vector int)a, b);
4960}
4961
4962/* vec_vsrab */
4963
4964static vector signed char __ATTRS_o_ai
4965vec_vsrab(vector signed char a, vector unsigned char b)
4966{
4967 return (vector signed char)__builtin_altivec_vsrab((vector char)a, b);
4968}
4969
4970static vector unsigned char __ATTRS_o_ai
4971vec_vsrab(vector unsigned char a, vector unsigned char b)
4972{
4973 return (vector unsigned char)__builtin_altivec_vsrab((vector char)a, b);
4974}
4975
4976/* vec_vsrah */
4977
4978static vector short __ATTRS_o_ai
4979vec_vsrah(vector short a, vector unsigned short b)
4980{
4981 return __builtin_altivec_vsrah(a, (vector unsigned short)b);
4982}
4983
4984static vector unsigned short __ATTRS_o_ai
4985vec_vsrah(vector unsigned short a, vector unsigned short b)
4986{
4987 return (vector unsigned short)__builtin_altivec_vsrah((vector short)a, b);
4988}
4989
4990/* vec_vsraw */
4991
4992static vector int __ATTRS_o_ai
4993vec_vsraw(vector int a, vector unsigned int b)
4994{
4995 return __builtin_altivec_vsraw(a, b);
4996}
4997
4998static vector unsigned int __ATTRS_o_ai
4999vec_vsraw(vector unsigned int a, vector unsigned int b)
5000{
5001 return (vector unsigned int)__builtin_altivec_vsraw((vector int)a, b);
5002}
5003
5004/* vec_srl */
5005
5006static vector signed char __ATTRS_o_ai
5007vec_srl(vector signed char a, vector unsigned char b)
5008{
5009 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5010}
5011
5012static vector signed char __ATTRS_o_ai
5013vec_srl(vector signed char a, vector unsigned short b)
5014{
5015 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5016}
5017
5018static vector signed char __ATTRS_o_ai
5019vec_srl(vector signed char a, vector unsigned int b)
5020{
5021 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5022}
5023
5024static vector unsigned char __ATTRS_o_ai
5025vec_srl(vector unsigned char a, vector unsigned char b)
5026{
5027 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5028}
5029
5030static vector unsigned char __ATTRS_o_ai
5031vec_srl(vector unsigned char a, vector unsigned short b)
5032{
5033 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5034}
5035
5036static vector unsigned char __ATTRS_o_ai
5037vec_srl(vector unsigned char a, vector unsigned int b)
5038{
5039 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5040}
5041
5042static vector short __ATTRS_o_ai
5043vec_srl(vector short a, vector unsigned char b)
5044{
5045 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5046}
5047
5048static vector short __ATTRS_o_ai
5049vec_srl(vector short a, vector unsigned short b)
5050{
5051 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5052}
5053
5054static vector short __ATTRS_o_ai
5055vec_srl(vector short a, vector unsigned int b)
5056{
5057 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5058}
5059
5060static vector unsigned short __ATTRS_o_ai
5061vec_srl(vector unsigned short a, vector unsigned char b)
5062{
5063 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5064}
5065
5066static vector unsigned short __ATTRS_o_ai
5067vec_srl(vector unsigned short a, vector unsigned short b)
5068{
5069 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5070}
5071
5072static vector unsigned short __ATTRS_o_ai
5073vec_srl(vector unsigned short a, vector unsigned int b)
5074{
5075 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5076}
5077
5078static vector int __ATTRS_o_ai
5079vec_srl(vector int a, vector unsigned char b)
5080{
5081 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5082}
5083
5084static vector int __ATTRS_o_ai
5085vec_srl(vector int a, vector unsigned short b)
5086{
5087 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5088}
5089
5090static vector int __ATTRS_o_ai
5091vec_srl(vector int a, vector unsigned int b)
5092{
5093 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5094}
5095
5096static vector unsigned int __ATTRS_o_ai
5097vec_srl(vector unsigned int a, vector unsigned char b)
5098{
5099 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5100}
5101
5102static vector unsigned int __ATTRS_o_ai
5103vec_srl(vector unsigned int a, vector unsigned short b)
5104{
5105 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5106}
5107
5108static vector unsigned int __ATTRS_o_ai
5109vec_srl(vector unsigned int a, vector unsigned int b)
5110{
5111 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5112}
5113
5114/* vec_vsr */
5115
5116static vector signed char __ATTRS_o_ai
5117vec_vsr(vector signed char a, vector unsigned char b)
5118{
5119 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5120}
5121
5122static vector signed char __ATTRS_o_ai
5123vec_vsr(vector signed char a, vector unsigned short b)
5124{
5125 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5126}
5127
5128static vector signed char __ATTRS_o_ai
5129vec_vsr(vector signed char a, vector unsigned int b)
5130{
5131 return (vector signed char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5132}
5133
5134static vector unsigned char __ATTRS_o_ai
5135vec_vsr(vector unsigned char a, vector unsigned char b)
5136{
5137 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5138}
5139
5140static vector unsigned char __ATTRS_o_ai
5141vec_vsr(vector unsigned char a, vector unsigned short b)
5142{
5143 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5144}
5145
5146static vector unsigned char __ATTRS_o_ai
5147vec_vsr(vector unsigned char a, vector unsigned int b)
5148{
5149 return (vector unsigned char)__builtin_altivec_vsr((vector int)a, (vector int)b);
5150}
5151
5152static vector short __ATTRS_o_ai
5153vec_vsr(vector short a, vector unsigned char b)
5154{
5155 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5156}
5157
5158static vector short __ATTRS_o_ai
5159vec_vsr(vector short a, vector unsigned short b)
5160{
5161 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5162}
5163
5164static vector short __ATTRS_o_ai
5165vec_vsr(vector short a, vector unsigned int b)
5166{
5167 return (vector short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5168}
5169
5170static vector unsigned short __ATTRS_o_ai
5171vec_vsr(vector unsigned short a, vector unsigned char b)
5172{
5173 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5174}
5175
5176static vector unsigned short __ATTRS_o_ai
5177vec_vsr(vector unsigned short a, vector unsigned short b)
5178{
5179 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5180}
5181
5182static vector unsigned short __ATTRS_o_ai
5183vec_vsr(vector unsigned short a, vector unsigned int b)
5184{
5185 return (vector unsigned short)__builtin_altivec_vsr((vector int)a, (vector int)b);
5186}
5187
5188static vector int __ATTRS_o_ai
5189vec_vsr(vector int a, vector unsigned char b)
5190{
5191 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5192}
5193
5194static vector int __ATTRS_o_ai
5195vec_vsr(vector int a, vector unsigned short b)
5196{
5197 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5198}
5199
5200static vector int __ATTRS_o_ai
5201vec_vsr(vector int a, vector unsigned int b)
5202{
5203 return (vector int)__builtin_altivec_vsr(a, (vector int)b);
5204}
5205
5206static vector unsigned int __ATTRS_o_ai
5207vec_vsr(vector unsigned int a, vector unsigned char b)
5208{
5209 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5210}
5211
5212static vector unsigned int __ATTRS_o_ai
5213vec_vsr(vector unsigned int a, vector unsigned short b)
5214{
5215 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5216}
5217
5218static vector unsigned int __ATTRS_o_ai
5219vec_vsr(vector unsigned int a, vector unsigned int b)
5220{
5221 return (vector unsigned int)__builtin_altivec_vsr((vector int)a, (vector int)b);
5222}
5223
5224/* vec_sro */
5225
5226static vector signed char __ATTRS_o_ai
5227vec_sro(vector signed char a, vector signed char b)
5228{
5229 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5230}
5231
5232static vector signed char __ATTRS_o_ai
5233vec_sro(vector signed char a, vector unsigned char b)
5234{
5235 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5236}
5237
5238static vector unsigned char __ATTRS_o_ai
5239vec_sro(vector unsigned char a, vector signed char b)
5240{
5241 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5242}
5243
5244static vector unsigned char __ATTRS_o_ai
5245vec_sro(vector unsigned char a, vector unsigned char b)
5246{
5247 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5248}
5249
5250static vector short __ATTRS_o_ai
5251vec_sro(vector short a, vector signed char b)
5252{
5253 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5254}
5255
5256static vector short __ATTRS_o_ai
5257vec_sro(vector short a, vector unsigned char b)
5258{
5259 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5260}
5261
5262static vector unsigned short __ATTRS_o_ai
5263vec_sro(vector unsigned short a, vector signed char b)
5264{
5265 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5266}
5267
5268static vector unsigned short __ATTRS_o_ai
5269vec_sro(vector unsigned short a, vector unsigned char b)
5270{
5271 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5272}
5273
5274static vector int __ATTRS_o_ai
5275vec_sro(vector int a, vector signed char b)
5276{
5277 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
5278}
5279
5280static vector int __ATTRS_o_ai
5281vec_sro(vector int a, vector unsigned char b)
5282{
5283 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
5284}
5285
5286static vector unsigned int __ATTRS_o_ai
5287vec_sro(vector unsigned int a, vector signed char b)
5288{
5289 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
5290}
5291
5292static vector unsigned int __ATTRS_o_ai
5293vec_sro(vector unsigned int a, vector unsigned char b)
5294{
5295 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
5296}
5297
5298static vector float __ATTRS_o_ai
5299vec_sro(vector float a, vector signed char b)
5300{
5301 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
5302}
5303
5304static vector float __ATTRS_o_ai
5305vec_sro(vector float a, vector unsigned char b)
5306{
5307 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
5308}
5309
5310/* vec_vsro */
5311
5312static vector signed char __ATTRS_o_ai
5313vec_vsro(vector signed char a, vector signed char b)
5314{
5315 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5316}
5317
5318static vector signed char __ATTRS_o_ai
5319vec_vsro(vector signed char a, vector unsigned char b)
5320{
5321 return (vector signed char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5322}
5323
5324static vector unsigned char __ATTRS_o_ai
5325vec_vsro(vector unsigned char a, vector signed char b)
5326{
5327 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5328}
5329
5330static vector unsigned char __ATTRS_o_ai
5331vec_vsro(vector unsigned char a, vector unsigned char b)
5332{
5333 return (vector unsigned char)__builtin_altivec_vsro((vector int)a, (vector int)b);
5334}
5335
5336static vector short __ATTRS_o_ai
5337vec_vsro(vector short a, vector signed char b)
5338{
5339 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5340}
5341
5342static vector short __ATTRS_o_ai
5343vec_vsro(vector short a, vector unsigned char b)
5344{
5345 return (vector short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5346}
5347
5348static vector unsigned short __ATTRS_o_ai
5349vec_vsro(vector unsigned short a, vector signed char b)
5350{
5351 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5352}
5353
5354static vector unsigned short __ATTRS_o_ai
5355vec_vsro(vector unsigned short a, vector unsigned char b)
5356{
5357 return (vector unsigned short)__builtin_altivec_vsro((vector int)a, (vector int)b);
5358}
5359
5360static vector int __ATTRS_o_ai
5361vec_vsro(vector int a, vector signed char b)
5362{
5363 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
5364}
5365
5366static vector int __ATTRS_o_ai
5367vec_vsro(vector int a, vector unsigned char b)
5368{
5369 return (vector int)__builtin_altivec_vsro(a, (vector int)b);
5370}
5371
5372static vector unsigned int __ATTRS_o_ai
5373vec_vsro(vector unsigned int a, vector signed char b)
5374{
5375 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
5376}
5377
5378static vector unsigned int __ATTRS_o_ai
5379vec_vsro(vector unsigned int a, vector unsigned char b)
5380{
5381 return (vector unsigned int)__builtin_altivec_vsro((vector int)a, (vector int)b);
5382}
5383
5384static vector float __ATTRS_o_ai
5385vec_vsro(vector float a, vector signed char b)
5386{
5387 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
5388}
5389
5390static vector float __ATTRS_o_ai
5391vec_vsro(vector float a, vector unsigned char b)
5392{
5393 return (vector float)__builtin_altivec_vsro((vector int)a, (vector int)b);
5394}
5395
5396/* vec_st */
5397
5398static void __ATTRS_o_ai
5399vec_st(vector signed char a, int b, vector signed char *c)
5400{
5401 __builtin_altivec_stvx((vector int)a, b, c);
5402}
5403
5404static void __ATTRS_o_ai
5405vec_st(vector signed char a, int b, signed char *c)
5406{
5407 __builtin_altivec_stvx((vector int)a, b, c);
5408}
5409
5410static void __ATTRS_o_ai
5411vec_st(vector unsigned char a, int b, vector unsigned char *c)
5412{
5413 __builtin_altivec_stvx((vector int)a, b, c);
5414}
5415
5416static void __ATTRS_o_ai
5417vec_st(vector unsigned char a, int b, unsigned char *c)
5418{
5419 __builtin_altivec_stvx((vector int)a, b, c);
5420}
5421
5422static void __ATTRS_o_ai
5423vec_st(vector short a, int b, vector short *c)
5424{
5425 __builtin_altivec_stvx((vector int)a, b, c);
5426}
5427
5428static void __ATTRS_o_ai
5429vec_st(vector short a, int b, short *c)
5430{
5431 __builtin_altivec_stvx((vector int)a, b, c);
5432}
5433
5434static void __ATTRS_o_ai
5435vec_st(vector unsigned short a, int b, vector unsigned short *c)
5436{
5437 __builtin_altivec_stvx((vector int)a, b, c);
5438}
5439
5440static void __ATTRS_o_ai
5441vec_st(vector unsigned short a, int b, unsigned short *c)
5442{
5443 __builtin_altivec_stvx((vector int)a, b, c);
5444}
5445
5446static void __ATTRS_o_ai
5447vec_st(vector int a, int b, vector int *c)
5448{
5449 __builtin_altivec_stvx(a, b, c);
5450}
5451
5452static void __ATTRS_o_ai
5453vec_st(vector int a, int b, int *c)
5454{
5455 __builtin_altivec_stvx(a, b, c);
5456}
5457
5458static void __ATTRS_o_ai
5459vec_st(vector unsigned int a, int b, vector unsigned int *c)
5460{
5461 __builtin_altivec_stvx((vector int)a, b, c);
5462}
5463
5464static void __ATTRS_o_ai
5465vec_st(vector unsigned int a, int b, unsigned int *c)
5466{
5467 __builtin_altivec_stvx((vector int)a, b, c);
5468}
5469
5470static void __ATTRS_o_ai
5471vec_st(vector float a, int b, vector float *c)
5472{
5473 __builtin_altivec_stvx((vector int)a, b, c);
5474}
5475
5476static void __ATTRS_o_ai
5477vec_st(vector float a, int b, float *c)
5478{
5479 __builtin_altivec_stvx((vector int)a, b, c);
5480}
5481
5482/* vec_stvx */
5483
5484static void __ATTRS_o_ai
5485vec_stvx(vector signed char a, int b, vector signed char *c)
5486{
5487 __builtin_altivec_stvx((vector int)a, b, c);
5488}
5489
5490static void __ATTRS_o_ai
5491vec_stvx(vector signed char a, int b, signed char *c)
5492{
5493 __builtin_altivec_stvx((vector int)a, b, c);
5494}
5495
5496static void __ATTRS_o_ai
5497vec_stvx(vector unsigned char a, int b, vector unsigned char *c)
5498{
5499 __builtin_altivec_stvx((vector int)a, b, c);
5500}
5501
5502static void __ATTRS_o_ai
5503vec_stvx(vector unsigned char a, int b, unsigned char *c)
5504{
5505 __builtin_altivec_stvx((vector int)a, b, c);
5506}
5507
5508static void __ATTRS_o_ai
5509vec_stvx(vector short a, int b, vector short *c)
5510{
5511 __builtin_altivec_stvx((vector int)a, b, c);
5512}
5513
5514static void __ATTRS_o_ai
5515vec_stvx(vector short a, int b, short *c)
5516{
5517 __builtin_altivec_stvx((vector int)a, b, c);
5518}
5519
5520static void __ATTRS_o_ai
5521vec_stvx(vector unsigned short a, int b, vector unsigned short *c)
5522{
5523 __builtin_altivec_stvx((vector int)a, b, c);
5524}
5525
5526static void __ATTRS_o_ai
5527vec_stvx(vector unsigned short a, int b, unsigned short *c)
5528{
5529 __builtin_altivec_stvx((vector int)a, b, c);
5530}
5531
5532static void __ATTRS_o_ai
5533vec_stvx(vector int a, int b, vector int *c)
5534{
5535 __builtin_altivec_stvx(a, b, c);
5536}
5537
5538static void __ATTRS_o_ai
5539vec_stvx(vector int a, int b, int *c)
5540{
5541 __builtin_altivec_stvx(a, b, c);
5542}
5543
5544static void __ATTRS_o_ai
5545vec_stvx(vector unsigned int a, int b, vector unsigned int *c)
5546{
5547 __builtin_altivec_stvx((vector int)a, b, c);
5548}
5549
5550static void __ATTRS_o_ai
5551vec_stvx(vector unsigned int a, int b, unsigned int *c)
5552{
5553 __builtin_altivec_stvx((vector int)a, b, c);
5554}
5555
5556static void __ATTRS_o_ai
5557vec_stvx(vector float a, int b, vector float *c)
5558{
5559 __builtin_altivec_stvx((vector int)a, b, c);
5560}
5561
5562static void __ATTRS_o_ai
5563vec_stvx(vector float a, int b, float *c)
5564{
5565 __builtin_altivec_stvx((vector int)a, b, c);
5566}
5567
5568/* vec_ste */
5569
5570static void __ATTRS_o_ai
5571vec_ste(vector signed char a, int b, signed char *c)
5572{
5573 __builtin_altivec_stvebx((vector char)a, b, c);
5574}
5575
5576static void __ATTRS_o_ai
5577vec_ste(vector unsigned char a, int b, unsigned char *c)
5578{
5579 __builtin_altivec_stvebx((vector char)a, b, c);
5580}
5581
5582static void __ATTRS_o_ai
5583vec_ste(vector short a, int b, short *c)
5584{
5585 __builtin_altivec_stvehx(a, b, c);
5586}
5587
5588static void __ATTRS_o_ai
5589vec_ste(vector unsigned short a, int b, unsigned short *c)
5590{
5591 __builtin_altivec_stvehx((vector short)a, b, c);
5592}
5593
5594static void __ATTRS_o_ai
5595vec_ste(vector int a, int b, int *c)
5596{
5597 __builtin_altivec_stvewx(a, b, c);
5598}
5599
5600static void __ATTRS_o_ai
5601vec_ste(vector unsigned int a, int b, unsigned int *c)
5602{
5603 __builtin_altivec_stvewx((vector int)a, b, c);
5604}
5605
5606static void __ATTRS_o_ai
5607vec_ste(vector float a, int b, float *c)
5608{
5609 __builtin_altivec_stvewx((vector int)a, b, c);
5610}
5611
5612/* vec_stvebx */
5613
5614static void __ATTRS_o_ai
5615vec_stvebx(vector signed char a, int b, signed char *c)
5616{
5617 __builtin_altivec_stvebx((vector char)a, b, c);
5618}
5619
5620static void __ATTRS_o_ai
5621vec_stvebx(vector unsigned char a, int b, unsigned char *c)
5622{
5623 __builtin_altivec_stvebx((vector char)a, b, c);
5624}
5625
5626/* vec_stvehx */
5627
5628static void __ATTRS_o_ai
5629vec_stvehx(vector short a, int b, short *c)
5630{
5631 __builtin_altivec_stvehx(a, b, c);
5632}
5633
5634static void __ATTRS_o_ai
5635vec_stvehx(vector unsigned short a, int b, unsigned short *c)
5636{
5637 __builtin_altivec_stvehx((vector short)a, b, c);
5638}
5639
5640/* vec_stvewx */
5641
5642static void __ATTRS_o_ai
5643vec_stvewx(vector int a, int b, int *c)
5644{
5645 __builtin_altivec_stvewx(a, b, c);
5646}
5647
5648static void __ATTRS_o_ai
5649vec_stvewx(vector unsigned int a, int b, unsigned int *c)
5650{
5651 __builtin_altivec_stvewx((vector int)a, b, c);
5652}
5653
5654static void __ATTRS_o_ai
5655vec_stvewx(vector float a, int b, float *c)
5656{
5657 __builtin_altivec_stvewx((vector int)a, b, c);
5658}
5659
5660/* vec_stl */
5661
5662static void __ATTRS_o_ai
5663vec_stl(vector signed char a, int b, vector signed char *c)
5664{
5665 __builtin_altivec_stvxl((vector int)a, b, c);
5666}
5667
5668static void __ATTRS_o_ai
5669vec_stl(vector signed char a, int b, signed char *c)
5670{
5671 __builtin_altivec_stvxl((vector int)a, b, c);
5672}
5673
5674static void __ATTRS_o_ai
5675vec_stl(vector unsigned char a, int b, vector unsigned char *c)
5676{
5677 __builtin_altivec_stvxl((vector int)a, b, c);
5678}
5679
5680static void __ATTRS_o_ai
5681vec_stl(vector unsigned char a, int b, unsigned char *c)
5682{
5683 __builtin_altivec_stvxl((vector int)a, b, c);
5684}
5685
5686static void __ATTRS_o_ai
5687vec_stl(vector short a, int b, vector short *c)
5688{
5689 __builtin_altivec_stvxl((vector int)a, b, c);
5690}
5691
5692static void __ATTRS_o_ai
5693vec_stl(vector short a, int b, short *c)
5694{
5695 __builtin_altivec_stvxl((vector int)a, b, c);
5696}
5697
5698static void __ATTRS_o_ai
5699vec_stl(vector unsigned short a, int b, vector unsigned short *c)
5700{
5701 __builtin_altivec_stvxl((vector int)a, b, c);
5702}
5703
5704static void __ATTRS_o_ai
5705vec_stl(vector unsigned short a, int b, unsigned short *c)
5706{
5707 __builtin_altivec_stvxl((vector int)a, b, c);
5708}
5709
5710static void __ATTRS_o_ai
5711vec_stl(vector int a, int b, vector int *c)
5712{
5713 __builtin_altivec_stvxl(a, b, c);
5714}
5715
5716static void __ATTRS_o_ai
5717vec_stl(vector int a, int b, int *c)
5718{
5719 __builtin_altivec_stvxl(a, b, c);
5720}
5721
5722static void __ATTRS_o_ai
5723vec_stl(vector unsigned int a, int b, vector unsigned int *c)
5724{
5725 __builtin_altivec_stvxl((vector int)a, b, c);
5726}
5727
5728static void __ATTRS_o_ai
5729vec_stl(vector unsigned int a, int b, unsigned int *c)
5730{
5731 __builtin_altivec_stvxl((vector int)a, b, c);
5732}
5733
5734static void __ATTRS_o_ai
5735vec_stl(vector float a, int b, vector float *c)
5736{
5737 __builtin_altivec_stvxl((vector int)a, b, c);
5738}
5739
5740static void __ATTRS_o_ai
5741vec_stl(vector float a, int b, float *c)
5742{
5743 __builtin_altivec_stvxl((vector int)a, b, c);
5744}
5745
5746/* vec_stvxl */
5747
5748static void __ATTRS_o_ai
5749vec_stvxl(vector signed char a, int b, vector signed char *c)
5750{
5751 __builtin_altivec_stvxl((vector int)a, b, c);
5752}
5753
5754static void __ATTRS_o_ai
5755vec_stvxl(vector signed char a, int b, signed char *c)
5756{
5757 __builtin_altivec_stvxl((vector int)a, b, c);
5758}
5759
5760static void __ATTRS_o_ai
5761vec_stvxl(vector unsigned char a, int b, vector unsigned char *c)
5762{
5763 __builtin_altivec_stvxl((vector int)a, b, c);
5764}
5765
5766static void __ATTRS_o_ai
5767vec_stvxl(vector unsigned char a, int b, unsigned char *c)
5768{
5769 __builtin_altivec_stvxl((vector int)a, b, c);
5770}
5771
5772static void __ATTRS_o_ai
5773vec_stvxl(vector short a, int b, vector short *c)
5774{
5775 __builtin_altivec_stvxl((vector int)a, b, c);
5776}
5777
5778static void __ATTRS_o_ai
5779vec_stvxl(vector short a, int b, short *c)
5780{
5781 __builtin_altivec_stvxl((vector int)a, b, c);
5782}
5783
5784static void __ATTRS_o_ai
5785vec_stvxl(vector unsigned short a, int b, vector unsigned short *c)
5786{
5787 __builtin_altivec_stvxl((vector int)a, b, c);
5788}
5789
5790static void __ATTRS_o_ai
5791vec_stvxl(vector unsigned short a, int b, unsigned short *c)
5792{
5793 __builtin_altivec_stvxl((vector int)a, b, c);
5794}
5795
5796static void __ATTRS_o_ai
5797vec_stvxl(vector int a, int b, vector int *c)
5798{
5799 __builtin_altivec_stvxl(a, b, c);
5800}
5801
5802static void __ATTRS_o_ai
5803vec_stvxl(vector int a, int b, int *c)
5804{
5805 __builtin_altivec_stvxl(a, b, c);
5806}
5807
5808static void __ATTRS_o_ai
5809vec_stvxl(vector unsigned int a, int b, vector unsigned int *c)
5810{
5811 __builtin_altivec_stvxl((vector int)a, b, c);
5812}
5813
5814static void __ATTRS_o_ai
5815vec_stvxl(vector unsigned int a, int b, unsigned int *c)
5816{
5817 __builtin_altivec_stvxl((vector int)a, b, c);
5818}
5819
5820static void __ATTRS_o_ai
5821vec_stvxl(vector float a, int b, vector float *c)
5822{
5823 __builtin_altivec_stvxl((vector int)a, b, c);
5824}
5825
5826static void __ATTRS_o_ai
5827vec_stvxl(vector float a, int b, float *c)
5828{
5829 __builtin_altivec_stvxl((vector int)a, b, c);
5830}
5831
5832/* vec_sub */
5833
5834static vector signed char __ATTRS_o_ai
5835vec_sub(vector signed char a, vector signed char b)
5836{
5837 return a - b;
5838}
5839
5840static vector unsigned char __ATTRS_o_ai
5841vec_sub(vector unsigned char a, vector unsigned char b)
5842{
5843 return a - b;
5844}
5845
5846static vector short __ATTRS_o_ai
5847vec_sub(vector short a, vector short b)
5848{
5849 return a - b;
5850}
5851
5852static vector unsigned short __ATTRS_o_ai
5853vec_sub(vector unsigned short a, vector unsigned short b)
5854{
5855 return a - b;
5856}
5857
5858static vector int __ATTRS_o_ai
5859vec_sub(vector int a, vector int b)
5860{
5861 return a - b;
5862}
5863
5864static vector unsigned int __ATTRS_o_ai
5865vec_sub(vector unsigned int a, vector unsigned int b)
5866{
5867 return a - b;
5868}
5869
5870static vector float __ATTRS_o_ai
5871vec_sub(vector float a, vector float b)
5872{
5873 return a - b;
5874}
5875
5876/* vec_vsububm */
5877
5878#define __builtin_altivec_vsububm vec_vsububm
5879
5880static vector signed char __ATTRS_o_ai
5881vec_vsububm(vector signed char a, vector signed char b)
5882{
5883 return a - b;
5884}
5885
5886static vector unsigned char __ATTRS_o_ai
5887vec_vsububm(vector unsigned char a, vector unsigned char b)
5888{
5889 return a - b;
5890}
5891
5892/* vec_vsubuhm */
5893
5894#define __builtin_altivec_vsubuhm vec_vsubuhm
5895
5896static vector short __ATTRS_o_ai
5897vec_vsubuhm(vector short a, vector short b)
5898{
5899 return a - b;
5900}
5901
5902static vector unsigned short __ATTRS_o_ai
5903vec_vsubuhm(vector unsigned short a, vector unsigned short b)
5904{
5905 return a - b;
5906}
5907
5908/* vec_vsubuwm */
5909
5910#define __builtin_altivec_vsubuwm vec_vsubuwm
5911
5912static vector int __ATTRS_o_ai
5913vec_vsubuwm(vector int a, vector int b)
5914{
5915 return a - b;
5916}
5917
5918static vector unsigned int __ATTRS_o_ai
5919vec_vsubuwm(vector unsigned int a, vector unsigned int b)
5920{
5921 return a - b;
5922}
5923
5924/* vec_vsubfp */
5925
5926#define __builtin_altivec_vsubfp vec_vsubfp
5927
5928static vector float __attribute__((__always_inline__))
5929vec_vsubfp(vector float a, vector float b)
5930{
5931 return a - b;
5932}
5933
5934/* vec_subc */
5935
5936static vector unsigned int __attribute__((__always_inline__))
5937vec_subc(vector unsigned int a, vector unsigned int b)
5938{
5939 return __builtin_altivec_vsubcuw(a, b);
5940}
5941
5942/* vec_vsubcuw */
5943
5944static vector unsigned int __attribute__((__always_inline__))
5945vec_vsubcuw(vector unsigned int a, vector unsigned int b)
5946{
5947 return __builtin_altivec_vsubcuw(a, b);
5948}
5949
5950/* vec_subs */
5951
5952static vector signed char __ATTRS_o_ai
5953vec_subs(vector signed char a, vector signed char b)
5954{
5955 return __builtin_altivec_vsubsbs(a, b);
5956}
5957
5958static vector unsigned char __ATTRS_o_ai
5959vec_subs(vector unsigned char a, vector unsigned char b)
5960{
5961 return __builtin_altivec_vsububs(a, b);
5962}
5963
5964static vector short __ATTRS_o_ai
5965vec_subs(vector short a, vector short b)
5966{
5967 return __builtin_altivec_vsubshs(a, b);
5968}
5969
5970static vector unsigned short __ATTRS_o_ai
5971vec_subs(vector unsigned short a, vector unsigned short b)
5972{
5973 return __builtin_altivec_vsubuhs(a, b);
5974}
5975
5976static vector int __ATTRS_o_ai
5977vec_subs(vector int a, vector int b)
5978{
5979 return __builtin_altivec_vsubsws(a, b);
5980}
5981
5982static vector unsigned int __ATTRS_o_ai
5983vec_subs(vector unsigned int a, vector unsigned int b)
5984{
5985 return __builtin_altivec_vsubuws(a, b);
5986}
5987
5988/* vec_vsubsbs */
5989
5990static vector signed char __attribute__((__always_inline__))
5991vec_vsubsbs(vector signed char a, vector signed char b)
5992{
5993 return __builtin_altivec_vsubsbs(a, b);
5994}
5995
5996/* vec_vsububs */
5997
5998static vector unsigned char __attribute__((__always_inline__))
5999vec_vsububs(vector unsigned char a, vector unsigned char b)
6000{
6001 return __builtin_altivec_vsububs(a, b);
6002}
6003
6004/* vec_vsubshs */
6005
6006static vector short __attribute__((__always_inline__))
6007vec_vsubshs(vector short a, vector short b)
6008{
6009 return __builtin_altivec_vsubshs(a, b);
6010}
6011
6012/* vec_vsubuhs */
6013
6014static vector unsigned short __attribute__((__always_inline__))
6015vec_vsubuhs(vector unsigned short a, vector unsigned short b)
6016{
6017 return __builtin_altivec_vsubuhs(a, b);
6018}
6019
6020/* vec_vsubsws */
6021
6022static vector int __attribute__((__always_inline__))
6023vec_vsubsws(vector int a, vector int b)
6024{
6025 return __builtin_altivec_vsubsws(a, b);
6026}
6027
6028/* vec_vsubuws */
6029
6030static vector unsigned int __attribute__((__always_inline__))
6031vec_vsubuws(vector unsigned int a, vector unsigned int b)
6032{
6033 return __builtin_altivec_vsubuws(a, b);
6034}
6035
6036/* vec_sum4s */
6037
6038static vector int __ATTRS_o_ai
6039vec_sum4s(vector signed char a, vector int b)
6040{
6041 return __builtin_altivec_vsum4sbs(a, b);
6042}
6043
6044static vector unsigned int __ATTRS_o_ai
6045vec_sum4s(vector unsigned char a, vector unsigned int b)
6046{
6047 return __builtin_altivec_vsum4ubs(a, b);
6048}
6049
6050static vector int __ATTRS_o_ai
6051vec_sum4s(vector signed short a, vector int b)
6052{
6053 return __builtin_altivec_vsum4shs(a, b);
6054}
6055
6056/* vec_vsum4sbs */
6057
6058static vector int __attribute__((__always_inline__))
6059vec_vsum4sbs(vector signed char a, vector int b)
6060{
6061 return __builtin_altivec_vsum4sbs(a, b);
6062}
6063
6064/* vec_vsum4ubs */
6065
6066static vector unsigned int __attribute__((__always_inline__))
6067vec_vsum4ubs(vector unsigned char a, vector unsigned int b)
6068{
6069 return __builtin_altivec_vsum4ubs(a, b);
6070}
6071
6072/* vec_vsum4shs */
6073
6074static vector int __attribute__((__always_inline__))
6075vec_vsum4shs(vector signed short a, vector int b)
6076{
6077 return __builtin_altivec_vsum4shs(a, b);
6078}
6079
6080/* vec_sum2s */
6081
6082static vector signed int __attribute__((__always_inline__))
6083vec_sum2s(vector int a, vector int b)
6084{
6085 return __builtin_altivec_vsum2sws(a, b);
6086}
6087
6088/* vec_vsum2sws */
6089
6090static vector signed int __attribute__((__always_inline__))
6091vec_vsum2sws(vector int a, vector int b)
6092{
6093 return __builtin_altivec_vsum2sws(a, b);
6094}
6095
6096/* vec_sums */
6097
6098static vector signed int __attribute__((__always_inline__))
6099vec_sums(vector signed int a, vector signed int b)
6100{
6101 return __builtin_altivec_vsumsws(a, b);
6102}
6103
6104/* vec_vsumsws */
6105
6106static vector signed int __attribute__((__always_inline__))
6107vec_vsumsws(vector signed int a, vector signed int b)
6108{
6109 return __builtin_altivec_vsumsws(a, b);
6110}
6111
6112/* vec_trunc */
6113
6114static vector float __attribute__((__always_inline__))
6115vec_trunc(vector float a)
6116{
6117 return __builtin_altivec_vrfiz(a);
6118}
6119
6120/* vec_vrfiz */
6121
6122static vector float __attribute__((__always_inline__))
6123vec_vrfiz(vector float a)
6124{
6125 return __builtin_altivec_vrfiz(a);
6126}
6127
6128/* vec_unpackh */
6129
6130static vector short __ATTRS_o_ai
6131vec_unpackh(vector signed char a)
6132{
6133 return __builtin_altivec_vupkhsb((vector char)a);
6134}
6135
6136static vector int __ATTRS_o_ai
6137vec_unpackh(vector short a)
6138{
6139 return __builtin_altivec_vupkhsh(a);
6140}
6141
6142/* vec_vupkhsb */
6143
6144static vector short __attribute__((__always_inline__))
6145vec_vupkhsb(vector signed char a)
6146{
6147 return __builtin_altivec_vupkhsb((vector char)a);
6148}
6149
6150/* vec_vupkhsh */
6151
6152static vector int __attribute__((__always_inline__))
6153vec_vupkhsh(vector short a)
6154{
6155 return __builtin_altivec_vupkhsh(a);
6156}
6157
6158/* vec_unpackl */
6159
6160static vector short __ATTRS_o_ai
6161vec_unpackl(vector signed char a)
6162{
6163 return __builtin_altivec_vupklsb((vector char)a);
6164}
6165
6166static vector int __ATTRS_o_ai
6167vec_unpackl(vector short a)
6168{
6169 return __builtin_altivec_vupklsh(a);
6170}
6171
6172/* vec_vupklsb */
6173
6174static vector short __attribute__((__always_inline__))
6175vec_vupklsb(vector signed char a)
6176{
6177 return __builtin_altivec_vupklsb((vector char)a);
6178}
6179
6180/* vec_vupklsh */
6181
6182static vector int __attribute__((__always_inline__))
6183vec_vupklsh(vector short a)
6184{
6185 return __builtin_altivec_vupklsh(a);
6186}
6187
6188/* vec_xor */
6189
6190#define __builtin_altivec_vxor vec_xor
6191
6192static vector signed char __ATTRS_o_ai
6193vec_xor(vector signed char a, vector signed char b)
6194{
6195 return a ^ b;
6196}
6197
6198static vector unsigned char __ATTRS_o_ai
6199vec_xor(vector unsigned char a, vector unsigned char b)
6200{
6201 return a ^ b;
6202}
6203
6204static vector short __ATTRS_o_ai
6205vec_xor(vector short a, vector short b)
6206{
6207 return a ^ b;
6208}
6209
6210static vector unsigned short __ATTRS_o_ai
6211vec_xor(vector unsigned short a, vector unsigned short b)
6212{
6213 return a ^ b;
6214}
6215
6216static vector int __ATTRS_o_ai
6217vec_xor(vector int a, vector int b)
6218{
6219 return a ^ b;
6220}
6221
6222static vector unsigned int __ATTRS_o_ai
6223vec_xor(vector unsigned int a, vector unsigned int b)
6224{
6225 return a ^ b;
6226}
6227
6228static vector float __ATTRS_o_ai
6229vec_xor(vector float a, vector float b)
6230{
6231 vector unsigned int res = (vector unsigned int)a ^ (vector unsigned int)b;
6232 return (vector float)res;
6233}
6234
6235/* vec_vxor */
6236
6237static vector signed char __ATTRS_o_ai
6238vec_vxor(vector signed char a, vector signed char b)
6239{
6240 return a ^ b;
6241}
6242
6243static vector unsigned char __ATTRS_o_ai
6244vec_vxor(vector unsigned char a, vector unsigned char b)
6245{
6246 return a ^ b;
6247}
6248
6249static vector short __ATTRS_o_ai
6250vec_vxor(vector short a, vector short b)
6251{
6252 return a ^ b;
6253}
6254
6255static vector unsigned short __ATTRS_o_ai
6256vec_vxor(vector unsigned short a, vector unsigned short b)
6257{
6258 return a ^ b;
6259}
6260
6261static vector int __ATTRS_o_ai
6262vec_vxor(vector int a, vector int b)
6263{
6264 return a ^ b;
6265}
6266
6267static vector unsigned int __ATTRS_o_ai
6268vec_vxor(vector unsigned int a, vector unsigned int b)
6269{
6270 return a ^ b;
6271}
6272
6273static vector float __ATTRS_o_ai
6274vec_vxor(vector float a, vector float b)
6275{
6276 vector unsigned int res = (vector unsigned int)a ^ (vector unsigned int)b;
6277 return (vector float)res;
6278}
Chris Lattnerdd173942010-04-14 03:54:58 +00006279
6280/* ------------------------------ predicates ------------------------------------ */
6281
Chris Lattnerdd173942010-04-14 03:54:58 +00006282/* vec_all_eq */
6283
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006284static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006285vec_all_eq(vector signed char a, vector signed char b)
6286{
Chris Lattnerab866b42010-04-14 20:35:39 +00006287 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006288}
6289
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006290static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006291vec_all_eq(vector unsigned char a, vector unsigned char b)
6292{
Chris Lattnerab866b42010-04-14 20:35:39 +00006293 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006294}
6295
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006296static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006297vec_all_eq(vector short a, vector short b)
6298{
6299 return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b);
6300}
6301
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006302static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006303vec_all_eq(vector unsigned short a, vector unsigned short b)
6304{
Chris Lattnerab866b42010-04-14 20:35:39 +00006305 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006306}
6307
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006308static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006309vec_all_eq(vector int a, vector int b)
6310{
6311 return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b);
6312}
6313
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006314static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006315vec_all_eq(vector unsigned int a, vector unsigned int b)
6316{
Chris Lattnerab866b42010-04-14 20:35:39 +00006317 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006318}
6319
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006320static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006321vec_all_eq(vector float a, vector float b)
6322{
6323 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, b);
6324}
6325
6326/* vec_all_ge */
6327
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006328static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006329vec_all_ge(vector signed char a, vector signed char b)
6330{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006331 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006332}
6333
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006334static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006335vec_all_ge(vector unsigned char a, vector unsigned char b)
6336{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006337 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006338}
6339
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006340static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006341vec_all_ge(vector short a, vector short b)
6342{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006343 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006344}
6345
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006346static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006347vec_all_ge(vector unsigned short a, vector unsigned short b)
6348{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006349 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006350}
6351
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006352static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006353vec_all_ge(vector int a, vector int b)
6354{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006355 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006356}
6357
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006358static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006359vec_all_ge(vector unsigned int a, vector unsigned int b)
6360{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006361 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006362}
6363
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006364static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006365vec_all_ge(vector float a, vector float b)
6366{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006367 return __builtin_altivec_vcmpgefp_p(__CR6_LT, a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006368}
6369
6370/* vec_all_gt */
6371
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006372static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006373vec_all_gt(vector signed char a, vector signed char b)
6374{
6375 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b);
6376}
6377
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006378static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006379vec_all_gt(vector unsigned char a, vector unsigned char b)
6380{
6381 return __builtin_altivec_vcmpgtub_p(__CR6_LT, a, b);
6382}
6383
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006384static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006385vec_all_gt(vector short a, vector short b)
6386{
6387 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, a, b);
6388}
6389
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006390static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006391vec_all_gt(vector unsigned short a, vector unsigned short b)
6392{
6393 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, a, b);
6394}
6395
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006396static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006397vec_all_gt(vector int a, vector int b)
6398{
6399 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, a, b);
6400}
6401
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006402static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006403vec_all_gt(vector unsigned int a, vector unsigned int b)
6404{
6405 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, a, b);
6406}
6407
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006408static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006409vec_all_gt(vector float a, vector float b)
6410{
6411 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, a, b);
6412}
6413
6414/* vec_all_in */
6415
6416static int __attribute__((__always_inline__))
6417vec_all_in(vector float a, vector float b)
6418{
6419 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, a, b);
6420}
6421
6422/* vec_all_le */
6423
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006424static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006425vec_all_le(vector signed char a, vector signed char b)
6426{
6427 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b);
6428}
6429
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006430static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006431vec_all_le(vector unsigned char a, vector unsigned char b)
6432{
6433 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, a, b);
6434}
6435
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006436static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006437vec_all_le(vector short a, vector short b)
6438{
6439 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, a, b);
6440}
6441
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006442static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006443vec_all_le(vector unsigned short a, vector unsigned short b)
6444{
6445 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, a, b);
6446}
6447
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006448static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006449vec_all_le(vector int a, vector int b)
6450{
6451 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, a, b);
6452}
6453
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006454static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006455vec_all_le(vector unsigned int a, vector unsigned int b)
6456{
6457 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, a, b);
6458}
6459
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006460static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006461vec_all_le(vector float a, vector float b)
6462{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006463 return __builtin_altivec_vcmpgefp_p(__CR6_LT, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006464}
6465
6466/* vec_all_lt */
6467
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006468static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006469vec_all_lt(vector signed char a, vector signed char b)
6470{
6471 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a);
6472}
6473
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006474static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006475vec_all_lt(vector unsigned char a, vector unsigned char b)
6476{
6477 return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a);
6478}
6479
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006480static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006481vec_all_lt(vector short a, vector short b)
6482{
6483 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a);
6484}
6485
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006486static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006487vec_all_lt(vector unsigned short a, vector unsigned short b)
6488{
6489 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a);
6490}
6491
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006492static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006493vec_all_lt(vector int a, vector int b)
6494{
6495 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a);
6496}
6497
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006498static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006499vec_all_lt(vector unsigned int a, vector unsigned int b)
6500{
6501 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a);
6502}
6503
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006504static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006505vec_all_lt(vector float a, vector float b)
6506{
6507 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a);
6508}
6509
6510/* vec_all_nan */
6511
6512static int __attribute__((__always_inline__))
6513vec_all_nan(vector float a)
6514{
6515 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, a);
6516}
6517
6518/* vec_all_ne */
6519
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006520static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006521vec_all_ne(vector signed char a, vector signed char b)
6522{
Chris Lattnerab866b42010-04-14 20:35:39 +00006523 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006524}
6525
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006526static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006527vec_all_ne(vector unsigned char a, vector unsigned char b)
6528{
Chris Lattnerab866b42010-04-14 20:35:39 +00006529 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006530}
6531
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006532static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006533vec_all_ne(vector short a, vector short b)
6534{
6535 return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b);
6536}
6537
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006538static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006539vec_all_ne(vector unsigned short a, vector unsigned short b)
6540{
Chris Lattnerab866b42010-04-14 20:35:39 +00006541 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006542}
6543
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006544static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006545vec_all_ne(vector int a, vector int b)
6546{
6547 return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b);
6548}
6549
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006550static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006551vec_all_ne(vector unsigned int a, vector unsigned int b)
6552{
Chris Lattnerab866b42010-04-14 20:35:39 +00006553 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006554}
6555
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006556static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006557vec_all_ne(vector float a, vector float b)
6558{
6559 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, b);
6560}
6561
6562/* vec_all_nge */
6563
6564static int __attribute__((__always_inline__))
6565vec_all_nge(vector float a, vector float b)
6566{
6567 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, a, b);
6568}
6569
6570/* vec_all_ngt */
6571
6572static int __attribute__((__always_inline__))
6573vec_all_ngt(vector float a, vector float b)
6574{
6575 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b);
6576}
6577
6578/* vec_all_nle */
6579
6580static int __attribute__((__always_inline__))
6581vec_all_nle(vector float a, vector float b)
6582{
6583 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, b, a);
6584}
6585
6586/* vec_all_nlt */
6587
6588static int __attribute__((__always_inline__))
6589vec_all_nlt(vector float a, vector float b)
6590{
6591 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, b, a);
6592}
6593
6594/* vec_all_numeric */
6595
6596static int __attribute__((__always_inline__))
6597vec_all_numeric(vector float a)
6598{
6599 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, a);
6600}
6601
6602/* vec_any_eq */
6603
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006604static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006605vec_any_eq(vector signed char a, vector signed char b)
6606{
Chris Lattnerab866b42010-04-14 20:35:39 +00006607 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006608}
6609
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006610static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006611vec_any_eq(vector unsigned char a, vector unsigned char b)
6612{
Chris Lattnerab866b42010-04-14 20:35:39 +00006613 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006614}
6615
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006616static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006617vec_any_eq(vector short a, vector short b)
6618{
6619 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b);
6620}
6621
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006622static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006623vec_any_eq(vector unsigned short a, vector unsigned short b)
6624{
Chris Lattnerab866b42010-04-14 20:35:39 +00006625 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006626}
6627
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006628static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006629vec_any_eq(vector int a, vector int b)
6630{
6631 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b);
6632}
6633
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006634static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006635vec_any_eq(vector unsigned int a, vector unsigned int b)
6636{
Chris Lattnerab866b42010-04-14 20:35:39 +00006637 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006638}
6639
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006640static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006641vec_any_eq(vector float a, vector float b)
6642{
6643 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, b);
6644}
6645
6646/* vec_any_ge */
6647
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006648static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006649vec_any_ge(vector signed char a, vector signed char b)
6650{
6651 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a);
6652}
6653
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006654static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006655vec_any_ge(vector unsigned char a, vector unsigned char b)
6656{
6657 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, b, a);
6658}
6659
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006660static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006661vec_any_ge(vector short a, vector short b)
6662{
6663 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, b, a);
6664}
6665
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006666static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006667vec_any_ge(vector unsigned short a, vector unsigned short b)
6668{
6669 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, b, a);
6670}
6671
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006672static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006673vec_any_ge(vector int a, vector int b)
6674{
6675 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, b, a);
6676}
6677
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006678static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006679vec_any_ge(vector unsigned int a, vector unsigned int b)
6680{
6681 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, b, a);
6682}
6683
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006684static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006685vec_any_ge(vector float a, vector float b)
6686{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006687 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, a, b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006688}
6689
6690/* vec_any_gt */
6691
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006692static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006693vec_any_gt(vector signed char a, vector signed char b)
6694{
6695 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b);
6696}
6697
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006698static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006699vec_any_gt(vector unsigned char a, vector unsigned char b)
6700{
6701 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, a, b);
6702}
6703
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006704static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006705vec_any_gt(vector short a, vector short b)
6706{
6707 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, a, b);
6708}
6709
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006710static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006711vec_any_gt(vector unsigned short a, vector unsigned short b)
6712{
6713 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, a, b);
6714}
6715
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006716static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006717vec_any_gt(vector int a, vector int b)
6718{
6719 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, a, b);
6720}
6721
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006722static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006723vec_any_gt(vector unsigned int a, vector unsigned int b)
6724{
6725 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, a, b);
6726}
6727
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006728static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006729vec_any_gt(vector float a, vector float b)
6730{
6731 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, a, b);
6732}
6733
6734/* vec_any_le */
6735
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006736static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006737vec_any_le(vector signed char a, vector signed char b)
6738{
6739 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b);
6740}
6741
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006742static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006743vec_any_le(vector unsigned char a, vector unsigned char b)
6744{
6745 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, a, b);
6746}
6747
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006748static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006749vec_any_le(vector short a, vector short b)
6750{
6751 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, a, b);
6752}
6753
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006754static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006755vec_any_le(vector unsigned short a, vector unsigned short b)
6756{
6757 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, a, b);
6758}
6759
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006760static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006761vec_any_le(vector int a, vector int b)
6762{
6763 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, a, b);
6764}
6765
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006766static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006767vec_any_le(vector unsigned int a, vector unsigned int b)
6768{
6769 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, a, b);
6770}
6771
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006772static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006773vec_any_le(vector float a, vector float b)
6774{
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006775 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, b, a);
Chris Lattnerdd173942010-04-14 03:54:58 +00006776}
6777
6778/* vec_any_lt */
6779
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006780static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006781vec_any_lt(vector signed char a, vector signed char b)
6782{
6783 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a);
6784}
6785
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006786static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006787vec_any_lt(vector unsigned char a, vector unsigned char b)
6788{
6789 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, b, a);
6790}
6791
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006792static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006793vec_any_lt(vector short a, vector short b)
6794{
6795 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, b, a);
6796}
6797
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006798static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006799vec_any_lt(vector unsigned short a, vector unsigned short b)
6800{
6801 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, b, a);
6802}
6803
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006804static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006805vec_any_lt(vector int a, vector int b)
6806{
6807 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, b, a);
6808}
6809
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006810static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006811vec_any_lt(vector unsigned int a, vector unsigned int b)
6812{
6813 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, b, a);
6814}
6815
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006816static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006817vec_any_lt(vector float a, vector float b)
6818{
6819 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, b, a);
6820}
6821
6822/* vec_any_nan */
6823
6824static int __attribute__((__always_inline__))
6825vec_any_nan(vector float a)
6826{
6827 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, a);
6828}
6829
6830/* vec_any_ne */
6831
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006832static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006833vec_any_ne(vector signed char a, vector signed char b)
6834{
Chris Lattnerab866b42010-04-14 20:35:39 +00006835 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006836}
6837
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006838static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006839vec_any_ne(vector unsigned char a, vector unsigned char b)
6840{
Chris Lattnerab866b42010-04-14 20:35:39 +00006841 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006842}
6843
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006844static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006845vec_any_ne(vector short a, vector short b)
6846{
6847 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b);
6848}
6849
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006850static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006851vec_any_ne(vector unsigned short a, vector unsigned short b)
6852{
Chris Lattnerab866b42010-04-14 20:35:39 +00006853 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)a, (vector short)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006854}
6855
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006856static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006857vec_any_ne(vector int a, vector int b)
6858{
6859 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b);
6860}
6861
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006862static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006863vec_any_ne(vector unsigned int a, vector unsigned int b)
6864{
Chris Lattnerab866b42010-04-14 20:35:39 +00006865 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)a, (vector int)b);
Chris Lattnerdd173942010-04-14 03:54:58 +00006866}
6867
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006868static int __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006869vec_any_ne(vector float a, vector float b)
6870{
6871 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, b);
6872}
6873
6874/* vec_any_nge */
6875
6876static int __attribute__((__always_inline__))
6877vec_any_nge(vector float a, vector float b)
6878{
6879 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, a, b);
6880}
6881
6882/* vec_any_ngt */
6883
6884static int __attribute__((__always_inline__))
6885vec_any_ngt(vector float a, vector float b)
6886{
6887 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b);
6888}
6889
6890/* vec_any_nle */
6891
6892static int __attribute__((__always_inline__))
6893vec_any_nle(vector float a, vector float b)
6894{
6895 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, b, a);
6896}
6897
6898/* vec_any_nlt */
6899
6900static int __attribute__((__always_inline__))
6901vec_any_nlt(vector float a, vector float b)
6902{
6903 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a);
6904}
6905
6906/* vec_any_numeric */
6907
6908static int __attribute__((__always_inline__))
6909vec_any_numeric(vector float a)
6910{
6911 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, a);
6912}
6913
6914/* vec_any_out */
6915
6916static int __attribute__((__always_inline__))
6917vec_any_out(vector float a, vector float b)
6918{
6919 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, a, b);
6920}
6921
Anton Korobeynikov4d3a7b02010-06-19 09:47:18 +00006922#undef __ATTRS_o_ai
Chris Lattnerdd173942010-04-14 03:54:58 +00006923
6924#endif /* __ALTIVEC_H */