Merged with mainline at revision 128810.
[official-gcc.git] / gcc / config / rs6000 / spu2vmx.h
blobb4a48102ae8b17a721bfb19ae46924c71d8bbeec
1 /* Cell SPU 2 VMX intrinsics header
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This file is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
7 any later version.
9 This file is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
14 You should have received a copy of the GNU General Public License
15 along with this file; see the file COPYING. If not, write to the Free
16 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA. */
19 /* As a special exception, if you include this header file into source files
20 compiled by GCC, this header file does not by itself cause the resulting
21 executable to be covered by the GNU General Public License. This exception
22 does not however invalidate any other reasons why the executable file might be
23 covered by the GNU General Public License. */
25 #ifndef _SPU2VMX_H_
26 #define _SPU2VMX_H_ 1
28 #ifdef __cplusplus
30 #ifndef __SPU__
32 #include <si2vmx.h>
34 /* spu_absd (absolute difference)
35 * ========
37 static __inline vec_uchar16 spu_absd(vec_uchar16 a, vec_uchar16 b)
39 return ((vec_uchar16)(si_absdb((qword)(a), (qword)(b))));
44 /* spu_add
45 * =======
47 static __inline vec_uint4 spu_add(vec_uint4 a, vec_uint4 b)
49 return ((vec_uint4)(si_a((qword)(a), (qword)(b))));
52 static __inline vec_int4 spu_add(vec_int4 a, vec_int4 b)
54 return ((vec_int4)(si_a((qword)(a), (qword)(b))));
57 static __inline vec_ushort8 spu_add(vec_ushort8 a, vec_ushort8 b)
59 return ((vec_ushort8)(si_ah((qword)(a), (qword)(b))));
62 static __inline vec_short8 spu_add(vec_short8 a, vec_short8 b)
64 return ((vec_short8)(si_ah((qword)(a), (qword)(b))));
67 static __inline vec_uint4 spu_add(vec_uint4 a, unsigned int b)
69 return ((vec_uint4)(si_ai((qword)(a), (int)(b))));
72 static __inline vec_int4 spu_add(vec_int4 a, int b)
74 return ((vec_int4)(si_ai((qword)(a), b)));
77 static __inline vec_ushort8 spu_add(vec_ushort8 a, unsigned short b)
79 return ((vec_ushort8)(si_ahi((qword)(a), (short)(b))));
82 static __inline vec_short8 spu_add(vec_short8 a, short b)
84 return ((vec_short8)(si_ahi((qword)(a), b)));
87 static __inline vec_float4 spu_add(vec_float4 a, vec_float4 b)
89 return ((vec_float4)(si_fa((qword)(a), (qword)(b))));
92 static __inline vec_double2 spu_add(vec_double2 a, vec_double2 b)
94 return ((vec_double2)(si_dfa((qword)(a), (qword)(b))));
98 /* spu_addx
99 * ========
101 static __inline vec_uint4 spu_addx(vec_uint4 a, vec_uint4 b, vec_uint4 c)
103 return ((vec_uint4)(si_addx((qword)(a), (qword)(b), (qword)(c))));
106 static __inline vec_int4 spu_addx(vec_int4 a, vec_int4 b, vec_int4 c)
108 return ((vec_int4)(si_addx((qword)(a), (qword)(b), (qword)(c))));
112 /* spu_and
113 * =======
115 static __inline vec_uchar16 spu_and(vec_uchar16 a, vec_uchar16 b)
117 return ((vec_uchar16)(si_and((qword)(a), (qword)(b))));
120 static __inline vec_char16 spu_and(vec_char16 a, vec_char16 b)
122 return ((vec_char16)(si_and((qword)(a), (qword)(b))));
125 static __inline vec_ushort8 spu_and(vec_ushort8 a, vec_ushort8 b)
127 return ((vec_ushort8)(si_and((qword)(a), (qword)(b))));
130 static __inline vec_short8 spu_and(vec_short8 a, vec_short8 b)
132 return ((vec_short8)(si_and((qword)(a), (qword)(b))));
135 static __inline vec_uint4 spu_and(vec_uint4 a, vec_uint4 b)
137 return ((vec_uint4)(si_and((qword)(a), (qword)(b))));
140 static __inline vec_int4 spu_and(vec_int4 a, vec_int4 b)
142 return ((vec_int4)(si_and((qword)(a), (qword)(b))));
145 static __inline vec_float4 spu_and(vec_float4 a, vec_float4 b)
147 return ((vec_float4)(si_and((qword)(a), (qword)(b))));
150 static __inline vec_ullong2 spu_and(vec_ullong2 a, vec_ullong2 b)
152 return ((vec_ullong2)(si_and((qword)(a), (qword)(b))));
155 static __inline vec_llong2 spu_and(vec_llong2 a, vec_llong2 b)
157 return ((vec_llong2)(si_and((qword)(a), (qword)(b))));
160 static __inline vec_double2 spu_and(vec_double2 a, vec_double2 b)
162 return ((vec_double2)(si_and((qword)(a), (qword)(b))));
165 static __inline vec_uchar16 spu_and(vec_uchar16 a, unsigned char b)
167 return ((vec_uchar16)(si_andbi((qword)(a), (signed char)(b))));
171 static __inline vec_char16 spu_and(vec_char16 a, signed char b)
173 return ((vec_char16)(si_andbi((qword)(a), b)));
176 static __inline vec_ushort8 spu_and(vec_ushort8 a, unsigned short b)
178 return ((vec_ushort8)(si_andhi((qword)(a), (signed short)(b))));
181 static __inline vec_short8 spu_and(vec_short8 a, signed short b)
183 return ((vec_short8)(si_andhi((qword)(a), b)));
186 static __inline vec_uint4 spu_and(vec_uint4 a, unsigned int b)
188 return ((vec_uint4)(si_andi((qword)(a), (signed int)(b))));
191 static __inline vec_int4 spu_and(vec_int4 a, signed int b)
193 return ((vec_int4)(si_andi((qword)(a), b)));
197 /* spu_andc
198 * ========
200 #define spu_andc(_a, _b) vec_andc(_a, _b)
203 /* spu_avg
204 * =======
206 #define spu_avg(_a, _b) vec_avg(_a, _b)
209 /* spu_bisled
210 * spu_bisled_d
211 * spu_bisled_e
212 * ============
214 #define spu_bisled(_func) /* not mappable */
215 #define spu_bisled_d(_func) /* not mappable */
216 #define spu_bisled_e(_func) /* not mappable */
218 /* spu_cmpabseq
219 * ============
221 static __inline vec_uint4 spu_cmpabseq(vec_float4 a, vec_float4 b)
223 return ((vec_uint4)(si_fcmeq((qword)(a), (qword)(b))));
227 static __inline vec_ullong2 spu_cmpabseq(vec_double2 a, vec_double2 b)
229 return ((vec_ullong2)(si_dfcmeq((qword)(a), (qword)(b))));
233 /* spu_cmpabsgt
234 * ============
236 static __inline vec_uint4 spu_cmpabsgt(vec_float4 a, vec_float4 b)
238 return ((vec_uint4)(si_fcmgt((qword)(a), (qword)(b))));
241 static __inline vec_ullong2 spu_cmpabsgt(vec_double2 a, vec_double2 b)
243 return ((vec_ullong2)(si_dfcmgt((qword)(a), (qword)(b))));
247 /* spu_cmpeq
248 * ========
250 static __inline vec_uchar16 spu_cmpeq(vec_uchar16 a, vec_uchar16 b)
252 return ((vec_uchar16)(si_ceqb((qword)(a), (qword)(b))));
255 static __inline vec_uchar16 spu_cmpeq(vec_char16 a, vec_char16 b)
257 return ((vec_uchar16)(si_ceqb((qword)(a), (qword)(b))));
260 static __inline vec_ushort8 spu_cmpeq(vec_ushort8 a, vec_ushort8 b)
262 return ((vec_ushort8)(si_ceqh((qword)(a), (qword)(b))));
265 static __inline vec_ushort8 spu_cmpeq(vec_short8 a, vec_short8 b)
267 return ((vec_ushort8)(si_ceqh((qword)(a), (qword)(b))));
270 static __inline vec_uint4 spu_cmpeq(vec_uint4 a, vec_uint4 b)
272 return ((vec_uint4)(si_ceq((qword)(a), (qword)(b))));
275 static __inline vec_uint4 spu_cmpeq(vec_int4 a, vec_int4 b)
277 return ((vec_uint4)(si_ceq((qword)(a), (qword)(b))));
280 static __inline vec_uint4 spu_cmpeq(vec_float4 a, vec_float4 b)
282 return ((vec_uint4)(si_fceq((qword)(a), (qword)(b))));
285 static __inline vec_uchar16 spu_cmpeq(vec_uchar16 a, unsigned char b)
287 return ((vec_uchar16)(si_ceqbi((qword)(a), (signed char)(b))));
290 static __inline vec_uchar16 spu_cmpeq(vec_char16 a, signed char b)
292 return ((vec_uchar16)(si_ceqbi((qword)(a), b)));
295 static __inline vec_ushort8 spu_cmpeq(vec_ushort8 a, unsigned short b)
297 return ((vec_ushort8)(si_ceqhi((qword)(a), (signed short)(b))));
300 static __inline vec_ushort8 spu_cmpeq(vec_short8 a, signed short b)
302 return ((vec_ushort8)(si_ceqhi((qword)(a), b)));
305 static __inline vec_uint4 spu_cmpeq(vec_uint4 a, unsigned int b)
307 return ((vec_uint4)(si_ceqi((qword)(a), (signed int)(b))));
310 static __inline vec_uint4 spu_cmpeq(vec_int4 a, signed int b)
312 return ((vec_uint4)(si_ceqi((qword)(a), b)));
315 static __inline vec_ullong2 spu_cmpeq(vec_double2 a, vec_double2 b)
317 return ((vec_ullong2)(si_dfceq((qword)(a), (qword)(b))));
321 /* spu_cmpgt
322 * ========
324 static __inline vec_uchar16 spu_cmpgt(vec_uchar16 a, vec_uchar16 b)
326 return ((vec_uchar16)(si_clgtb((qword)(a), (qword)(b))));
329 static __inline vec_uchar16 spu_cmpgt(vec_char16 a, vec_char16 b)
331 return ((vec_uchar16)(si_cgtb((qword)(a), (qword)(b))));
334 static __inline vec_ushort8 spu_cmpgt(vec_ushort8 a, vec_ushort8 b)
336 return ((vec_ushort8)(si_clgth((qword)(a), (qword)(b))));
339 static __inline vec_ushort8 spu_cmpgt(vec_short8 a, vec_short8 b)
341 return ((vec_ushort8)(si_cgth((qword)(a), (qword)(b))));
344 static __inline vec_uint4 spu_cmpgt(vec_uint4 a, vec_uint4 b)
346 return ((vec_uint4)(si_clgt((qword)(a), (qword)(b))));
349 static __inline vec_uint4 spu_cmpgt(vec_int4 a, vec_int4 b)
351 return ((vec_uint4)(si_cgt((qword)(a), (qword)(b))));
354 static __inline vec_uint4 spu_cmpgt(vec_float4 a, vec_float4 b)
356 return ((vec_uint4)(si_fcgt((qword)(a), (qword)(b))));
359 static __inline vec_uchar16 spu_cmpgt(vec_uchar16 a, unsigned char b)
361 return ((vec_uchar16)(si_clgtbi((qword)(a), b)));
364 static __inline vec_uchar16 spu_cmpgt(vec_char16 a, signed char b)
366 return ((vec_uchar16)(si_cgtbi((qword)(a), b)));
369 static __inline vec_ushort8 spu_cmpgt(vec_ushort8 a, unsigned short b)
371 return ((vec_ushort8)(si_clgthi((qword)(a), b)));
374 static __inline vec_ushort8 spu_cmpgt(vec_short8 a, signed short b)
376 return ((vec_ushort8)(si_cgthi((qword)(a), b)));
379 static __inline vec_uint4 spu_cmpgt(vec_uint4 a, unsigned int b)
381 return ((vec_uint4)(si_clgti((qword)(a), b)));
384 static __inline vec_uint4 spu_cmpgt(vec_int4 a, signed int b)
386 return ((vec_uint4)(si_cgti((qword)(a), b)));
389 static __inline vec_ullong2 spu_cmpgt(vec_double2 a, vec_double2 b)
391 return ((vec_ullong2)(si_dfcgt((qword)(a), (qword)(b))));
395 /* spu_cntb
396 * ========
398 static __inline vec_uchar16 spu_cntb(vec_uchar16 a)
400 return ((vec_uchar16)(si_cntb((qword)(a))));
404 static __inline vec_uchar16 spu_cntb(vec_char16 a)
406 return ((vec_uchar16)(si_cntb((qword)(a))));
409 /* spu_cntlz
410 * =========
412 static __inline vec_uint4 spu_cntlz(vec_uint4 a)
414 return ((vec_uint4)(si_clz((qword)(a))));
417 static __inline vec_uint4 spu_cntlz(vec_int4 a)
419 return ((vec_uint4)(si_clz((qword)(a))));
422 static __inline vec_uint4 spu_cntlz(vec_float4 a)
424 return ((vec_uint4)(si_clz((qword)(a))));
427 /* spu_testsv
428 * ==========
430 static __inline vec_ullong2 spu_testsv(vec_double2 a, char b)
432 return ((vec_ullong2)(si_dftsv((qword)(a), b)));
435 /* spu_convtf
436 * ==========
438 #define spu_convtf(_a, _b) (vec_ctf(_a, _b))
440 /* spu_convts
441 * ==========
443 #define spu_convts(_a, _b) (vec_cts(_a, _b))
445 /* spu_convtu
446 * ==========
448 #define spu_convtu(_a, _b) (vec_ctu(_a, _b))
451 /* spu_dsync
452 * ========
454 #define spu_dsync()
456 /* spu_eqv
457 * =======
459 static __inline vec_uchar16 spu_eqv(vec_uchar16 a, vec_uchar16 b)
461 return ((vec_uchar16)(si_eqv((qword)(a), (qword)(b))));
464 static __inline vec_char16 spu_eqv(vec_char16 a, vec_char16 b)
466 return ((vec_char16)(si_eqv((qword)(a), (qword)(b))));
469 static __inline vec_ushort8 spu_eqv(vec_ushort8 a, vec_ushort8 b)
471 return ((vec_ushort8)(si_eqv((qword)(a), (qword)(b))));
474 static __inline vec_short8 spu_eqv(vec_short8 a, vec_short8 b)
476 return ((vec_short8)(si_eqv((qword)(a), (qword)(b))));
479 static __inline vec_uint4 spu_eqv(vec_uint4 a, vec_uint4 b)
481 return ((vec_uint4)(si_eqv((qword)(a), (qword)(b))));
484 static __inline vec_int4 spu_eqv(vec_int4 a, vec_int4 b)
486 return ((vec_int4)(si_eqv((qword)(a), (qword)(b))));
489 static __inline vec_float4 spu_eqv(vec_float4 a, vec_float4 b)
491 return ((vec_float4)(si_eqv((qword)(a), (qword)(b))));
494 static __inline vec_ullong2 spu_eqv(vec_ullong2 a, vec_ullong2 b)
496 return ((vec_ullong2)(si_eqv((qword)(a), (qword)(b))));
499 static __inline vec_llong2 spu_eqv(vec_llong2 a, vec_llong2 b)
501 return ((vec_llong2)(si_eqv((qword)(a), (qword)(b))));
504 static __inline vec_double2 spu_eqv(vec_double2 a, vec_double2 b)
506 return ((vec_double2)(si_eqv((qword)(a), (qword)(b))));
509 /* spu_extend
510 * ========
512 static __inline vec_short8 spu_extend(vec_char16 a)
514 return ((vec_short8)(si_xsbh((qword)(a))));
518 static __inline vec_int4 spu_extend(vec_short8 a)
520 return ((vec_int4)(si_xshw((qword)(a))));
523 static __inline vec_llong2 spu_extend(vec_int4 a)
525 return ((vec_llong2)(si_xswd((qword)(a))));
529 static __inline vec_double2 spu_extend(vec_float4 a)
531 return ((vec_double2)(si_fesd((qword)(a))));
535 /* spu_extract
536 * ========
538 static __inline unsigned char spu_extract(vec_uchar16 a, int element)
540 union {
541 vec_uchar16 v;
542 unsigned char c[16];
543 } in;
545 in.v = a;
546 return (in.c[element & 15]);
549 static __inline signed char spu_extract(vec_char16 a, int element)
551 union {
552 vec_char16 v;
553 signed char c[16];
554 } in;
556 in.v = a;
557 return (in.c[element & 15]);
560 static __inline unsigned short spu_extract(vec_ushort8 a, int element)
562 union {
563 vec_ushort8 v;
564 unsigned short s[8];
565 } in;
567 in.v = a;
568 return (in.s[element & 7]);
571 static __inline signed short spu_extract(vec_short8 a, int element)
573 union {
574 vec_short8 v;
575 signed short s[8];
576 } in;
578 in.v = a;
579 return (in.s[element & 7]);
582 static __inline unsigned int spu_extract(vec_uint4 a, int element)
584 union {
585 vec_uint4 v;
586 unsigned int i[4];
587 } in;
589 in.v = a;
590 return (in.i[element & 3]);
593 static __inline signed int spu_extract(vec_int4 a, int element)
595 union {
596 vec_int4 v;
597 signed int i[4];
598 } in;
600 in.v = a;
601 return (in.i[element & 3]);
604 static __inline float spu_extract(vec_float4 a, int element)
606 union {
607 vec_float4 v;
608 float f[4];
609 } in;
611 in.v = a;
612 return (in.f[element & 3]);
615 static __inline unsigned long long spu_extract(vec_ullong2 a, int element)
617 union {
618 vec_ullong2 v;
619 unsigned long long l[2];
620 } in;
622 in.v = a;
623 return (in.l[element & 1]);
626 static __inline signed long long spu_extract(vec_llong2 a, int element)
628 union {
629 vec_llong2 v;
630 signed long long l[2];
631 } in;
633 in.v = a;
634 return (in.l[element & 1]);
637 static __inline double spu_extract(vec_double2 a, int element)
639 union {
640 vec_double2 v;
641 double d[2];
642 } in;
644 in.v = a;
645 return (in.d[element & 1]);
648 /* spu_gather
649 * ========
651 static __inline vec_uint4 spu_gather(vec_uchar16 a)
653 return ((vec_uint4)(si_gbb((qword)(a))));
657 static __inline vec_uint4 spu_gather(vec_char16 a)
659 return ((vec_uint4)(si_gbb((qword)(a))));
662 static __inline vec_uint4 spu_gather(vec_ushort8 a)
664 return ((vec_uint4)(si_gbh((qword)(a))));
667 static __inline vec_uint4 spu_gather(vec_short8 a)
669 return ((vec_uint4)(si_gbh((qword)(a))));
673 static __inline vec_uint4 spu_gather(vec_uint4 a)
675 return ((vec_uint4)(si_gb((qword)(a))));
678 static __inline vec_uint4 spu_gather(vec_int4 a)
680 return ((vec_uint4)(si_gb((qword)(a))));
683 static __inline vec_uint4 spu_gather(vec_float4 a)
685 return ((vec_uint4)(si_gb((qword)(a))));
688 /* spu_genb
689 * ========
691 static __inline vec_uint4 spu_genb(vec_uint4 a, vec_uint4 b)
693 return ((vec_uint4)(si_bg((qword)(b), (qword)(a))));
696 static __inline vec_int4 spu_genb(vec_int4 a, vec_int4 b)
698 return ((vec_int4)(si_bg((qword)(b), (qword)(a))));
701 /* spu_genbx
702 * =========
704 static __inline vec_uint4 spu_genbx(vec_uint4 a, vec_uint4 b, vec_uint4 c)
706 return ((vec_uint4)(si_bgx((qword)(b), (qword)(a), (qword)(c))));
709 static __inline vec_int4 spu_genbx(vec_int4 a, vec_int4 b, vec_int4 c)
711 return ((vec_int4)(si_bgx((qword)(b), (qword)(a), (qword)(c))));
715 /* spu_genc
716 * ========
718 static __inline vec_uint4 spu_genc(vec_uint4 a, vec_uint4 b)
720 return ((vec_uint4)(si_cg((qword)(a), (qword)(b))));
723 static __inline vec_int4 spu_genc(vec_int4 a, vec_int4 b)
725 return ((vec_int4)(si_cg((qword)(a), (qword)(b))));
728 /* spu_gencx
729 * =========
731 static __inline vec_uint4 spu_gencx(vec_uint4 a, vec_uint4 b, vec_uint4 c)
733 return ((vec_uint4)(si_cgx((qword)(a), (qword)(b), (qword)(c))));
736 static __inline vec_int4 spu_gencx(vec_int4 a, vec_int4 b, vec_int4 c)
738 return ((vec_int4)(si_cgx((qword)(a), (qword)(b), (qword)(c))));
742 /* spu_hcmpeq
743 * ========
745 #define spu_hcmpeq(_a, _b) if (_a == _b) { SPU_HALT_ACTION; };
748 /* spu_hcmpgt
749 * ========
751 #define spu_hcmpgt(_a, _b) if (_a > _b) { SPU_HALT_ACTION; };
754 /* spu_idisable
755 * ============
757 #define spu_idisable() SPU_UNSUPPORTED_ACTION
760 /* spu_ienable
761 * ===========
763 #define spu_ienable() SPU_UNSUPPORTED_ACTION
766 /* spu_insert
767 * ========
769 static __inline vec_uchar16 spu_insert(unsigned char a, vec_uchar16 b, int element)
771 union {
772 vec_uchar16 v;
773 unsigned char c[16];
774 } in;
776 in.v = b;
777 in.c[element & 15] = a;
778 return (in.v);
781 static __inline vec_char16 spu_insert(signed char a, vec_char16 b, int element)
783 return ((vec_char16)spu_insert((unsigned char)(a), (vec_uchar16)(b), element));
786 static __inline vec_ushort8 spu_insert(unsigned short a, vec_ushort8 b, int element)
788 union {
789 vec_ushort8 v;
790 unsigned short s[8];
791 } in;
793 in.v = b;
794 in.s[element & 7] = a;
795 return (in.v);
798 static __inline vec_short8 spu_insert(signed short a, vec_short8 b, int element)
800 return ((vec_short8)spu_insert((unsigned short)(a), (vec_ushort8)(b), element));
803 static __inline vec_uint4 spu_insert(unsigned int a, vec_uint4 b, int element)
805 union {
806 vec_uint4 v;
807 unsigned int i[4];
808 } in;
810 in.v = b;
811 in.i[element & 3] = a;
812 return (in.v);
815 static __inline vec_int4 spu_insert(signed int a, vec_int4 b, int element)
817 return ((vec_int4)spu_insert((unsigned int)(a), (vec_uint4)(b), element));
820 static __inline vec_float4 spu_insert(float a, vec_float4 b, int element)
822 union {
823 vec_float4 v;
824 float f[4];
825 } in;
827 in.v = b;
828 in.f[element & 3] = a;
829 return (in.v);
832 static __inline vec_ullong2 spu_insert(unsigned long long a, vec_ullong2 b, int element)
834 union {
835 vec_ullong2 v;
836 unsigned long long l[2];
837 } in;
839 in.v = b;
840 in.l[element & 1] = a;
841 return (in.v);
844 static __inline vec_llong2 spu_insert(signed long long a, vec_llong2 b, int element)
846 return ((vec_llong2)spu_insert((unsigned long long)(a), (vec_ullong2)(b), element));
849 static __inline vec_double2 spu_insert(double a, vec_double2 b, int element)
851 union {
852 vec_double2 v;
853 double d[2];
854 } in;
856 in.v = b;
857 in.d[element & 1] = a;
858 return (in.v);
862 /* spu_madd
863 * ========
865 static __inline vec_int4 spu_madd(vec_short8 a, vec_short8 b, vec_int4 c)
867 return ((vec_int4)(si_mpya((qword)(a), (qword)(b), (qword)(c))));
870 static __inline vec_float4 spu_madd(vec_float4 a, vec_float4 b, vec_float4 c)
872 return ((vec_float4)(si_fma((qword)(a), (qword)(b), (qword)(c))));
875 static __inline vec_double2 spu_madd(vec_double2 a, vec_double2 b, vec_double2 c)
877 return ((vec_double2)(si_dfma((qword)(a), (qword)(b), (qword)(c))));
881 /* spu_maskb
882 * ========
884 #define spu_maskb(_a) (vec_uchar16)(si_fsmb(si_from_int((int)(_a))))
886 /* spu_maskh
887 * ========
889 #define spu_maskh(_a) (vec_ushort8)(si_fsmh(si_from_int((int)(_a))))
892 /* spu_maskw
893 * ========
895 #define spu_maskw(_a) (vec_uint4)(si_fsm(si_from_int((int)(_a))))
898 /* spu_mfcdma32
899 * ========
901 #define spu_mfcdma32(_ls, _ea, _size, _tagid, _cmd)
904 /* spu_mfcdma64
905 * ========
907 #define spu_mfcdma64(_ls, _eahi, _ealow, _size, _tagid, _cmd)
909 /* spu_mfcstat
910 * ========
912 #define spu_mfcstat(_type) 0xFFFFFFFF
916 /* spu_mffpscr
917 * ===========
919 #define spu_mffpscr() (vec_uint4)(si_fscrrd())
922 /* spu_mfspr
923 * ========
926 #define spu_mfspr(_reg) si_to_uint(si_mfspr(_reg))
930 /* spu_mhhadd
931 * ==========
933 static __inline vec_int4 spu_mhhadd(vec_short8 a, vec_short8 b, vec_int4 c)
935 return ((vec_int4)(si_mpyhha((qword)(a), (qword)(b), (qword)(c))));
939 static __inline vec_uint4 spu_mhhadd(vec_ushort8 a, vec_ushort8 b, vec_uint4 c)
941 return ((vec_uint4)(si_mpyhhau((qword)(a), (qword)(b), (qword)(c))));
945 /* spu_msub
946 * ========
948 static __inline vec_float4 spu_msub(vec_float4 a, vec_float4 b, vec_float4 c)
950 return ((vec_float4)(si_fms((qword)(a), (qword)(b), (qword)(c))));
953 static __inline vec_double2 spu_msub(vec_double2 a, vec_double2 b, vec_double2 c)
955 return ((vec_double2)(si_dfms((qword)(a), (qword)(b), (qword)(c))));
959 /* spu_mtfpscr
960 * ===========
962 #define spu_mtfpscr(_a)
965 /* spu_mtspr
966 * ========
968 #define spu_mtspr(_reg, _a)
971 /* spu_mul
972 * ========
974 static __inline vec_float4 spu_mul(vec_float4 a, vec_float4 b)
976 return ((vec_float4)(si_fm((qword)(a), (qword)(b))));
979 static __inline vec_double2 spu_mul(vec_double2 a, vec_double2 b)
981 return ((vec_double2)(si_dfm((qword)(a), (qword)(b))));
985 /* spu_mulh
986 * ========
988 static __inline vec_int4 spu_mulh(vec_short8 a, vec_short8 b)
990 return ((vec_int4)(si_mpyh((qword)(a), (qword)(b))));
993 /* spu_mule
994 * =========
996 #define spu_mule(_a, _b) vec_mule(_a, _b)
1000 /* spu_mulo
1001 * ========
1003 static __inline vec_int4 spu_mulo(vec_short8 a, vec_short8 b)
1005 return ((vec_int4)(si_mpy((qword)(a), (qword)(b))));
1009 static __inline vec_uint4 spu_mulo(vec_ushort8 a, vec_ushort8 b)
1011 return ((vec_uint4)(si_mpyu((qword)(a), (qword)(b))));
1015 static __inline vec_int4 spu_mulo(vec_short8 a, short b)
1017 return ((vec_int4)(si_mpyi((qword)(a), b)));
1020 static __inline vec_uint4 spu_mulo(vec_ushort8 a, unsigned short b)
1022 return ((vec_uint4)(si_mpyui((qword)(a), b)));
1026 /* spu_mulsr
1027 * =========
1029 static __inline vec_int4 spu_mulsr(vec_short8 a, vec_short8 b)
1031 return ((vec_int4)(si_mpys((qword)(a), (qword)(b))));
1035 /* spu_nand
1036 * ========
1038 static __inline vec_uchar16 spu_nand(vec_uchar16 a, vec_uchar16 b)
1040 return ((vec_uchar16)(si_nand((qword)(a), (qword)(b))));
1043 static __inline vec_char16 spu_nand(vec_char16 a, vec_char16 b)
1045 return ((vec_char16)(si_nand((qword)(a), (qword)(b))));
1048 static __inline vec_ushort8 spu_nand(vec_ushort8 a, vec_ushort8 b)
1050 return ((vec_ushort8)(si_nand((qword)(a), (qword)(b))));
1053 static __inline vec_short8 spu_nand(vec_short8 a, vec_short8 b)
1055 return ((vec_short8)(si_nand((qword)(a), (qword)(b))));
1058 static __inline vec_uint4 spu_nand(vec_uint4 a, vec_uint4 b)
1060 return ((vec_uint4)(si_nand((qword)(a), (qword)(b))));
1063 static __inline vec_int4 spu_nand(vec_int4 a, vec_int4 b)
1065 return ((vec_int4)(si_nand((qword)(a), (qword)(b))));
1068 static __inline vec_float4 spu_nand(vec_float4 a, vec_float4 b)
1070 return ((vec_float4)(si_nand((qword)(a), (qword)(b))));
1073 static __inline vec_ullong2 spu_nand(vec_ullong2 a, vec_ullong2 b)
1075 return ((vec_ullong2)(si_nand((qword)(a), (qword)(b))));
1078 static __inline vec_llong2 spu_nand(vec_llong2 a, vec_llong2 b)
1080 return ((vec_llong2)(si_nand((qword)(a), (qword)(b))));
1083 static __inline vec_double2 spu_nand(vec_double2 a, vec_double2 b)
1085 return ((vec_double2)(si_nand((qword)(a), (qword)(b))));
1089 /* spu_nmadd
1090 * =========
1092 static __inline vec_double2 spu_nmadd(vec_double2 a, vec_double2 b, vec_double2 c)
1094 return ((vec_double2)(si_dfnma((qword)(a), (qword)(b), (qword)(c))));
1098 /* spu_nmsub
1099 * =========
1101 static __inline vec_float4 spu_nmsub(vec_float4 a, vec_float4 b, vec_float4 c)
1103 return ((vec_float4)(si_fnms((qword)(a), (qword)(b), (qword)(c))));
1106 static __inline vec_double2 spu_nmsub(vec_double2 a, vec_double2 b, vec_double2 c)
1108 return ((vec_double2)(si_dfnms((qword)(a), (qword)(b), (qword)(c))));
1112 /* spu_nor
1113 * =======
1115 #define spu_nor(_a, _b) vec_nor(_a, _b)
1118 /* spu_or
1119 * ======
1121 static __inline vec_uchar16 spu_or(vec_uchar16 a, vec_uchar16 b)
1123 return ((vec_uchar16)(si_or((qword)(a), (qword)(b))));
1126 static __inline vec_char16 spu_or(vec_char16 a, vec_char16 b)
1128 return ((vec_char16)(si_or((qword)(a), (qword)(b))));
1131 static __inline vec_ushort8 spu_or(vec_ushort8 a, vec_ushort8 b)
1133 return ((vec_ushort8)(si_or((qword)(a), (qword)(b))));
1136 static __inline vec_short8 spu_or(vec_short8 a, vec_short8 b)
1138 return ((vec_short8)(si_or((qword)(a), (qword)(b))));
1141 static __inline vec_uint4 spu_or(vec_uint4 a, vec_uint4 b)
1143 return ((vec_uint4)(si_or((qword)(a), (qword)(b))));
1146 static __inline vec_int4 spu_or(vec_int4 a, vec_int4 b)
1148 return ((vec_int4)(si_or((qword)(a), (qword)(b))));
1151 static __inline vec_float4 spu_or(vec_float4 a, vec_float4 b)
1153 return ((vec_float4)(si_or((qword)(a), (qword)(b))));
1156 static __inline vec_ullong2 spu_or(vec_ullong2 a, vec_ullong2 b)
1158 return ((vec_ullong2)(si_or((qword)(a), (qword)(b))));
1161 static __inline vec_llong2 spu_or(vec_llong2 a, vec_llong2 b)
1163 return ((vec_llong2)(si_or((qword)(a), (qword)(b))));
1166 static __inline vec_double2 spu_or(vec_double2 a, vec_double2 b)
1168 return ((vec_double2)(si_or((qword)(a), (qword)(b))));
1172 static __inline vec_uchar16 spu_or(vec_uchar16 a, unsigned char b)
1174 return ((vec_uchar16)(si_orbi((qword)(a), b)));
1177 static __inline vec_char16 spu_or(vec_char16 a, signed char b)
1179 return ((vec_char16)(si_orbi((qword)(a), (unsigned char)(b))));
1182 static __inline vec_ushort8 spu_or(vec_ushort8 a, unsigned short b)
1184 return ((vec_ushort8)(si_orhi((qword)(a), b)));
1187 static __inline vec_short8 spu_or(vec_short8 a, signed short b)
1189 return ((vec_short8)(si_orhi((qword)(a), (unsigned short)(b))));
1192 static __inline vec_uint4 spu_or(vec_uint4 a, unsigned int b)
1194 return ((vec_uint4)(si_ori((qword)(a), b)));
1197 static __inline vec_int4 spu_or(vec_int4 a, signed int b)
1199 return ((vec_int4)(si_ori((qword)(a), (unsigned int)(b))));
1203 /* spu_orc
1204 * =======
1206 #define spu_orc(_a, _b) vec_or(_a, vec_nor(_b, _b))
1209 /* spu_orx
1210 * =======
1212 static __inline vec_uint4 spu_orx(vec_uint4 a)
1214 return ((vec_uint4)(si_orx((qword)(a))));
1217 static __inline vec_int4 spu_orx(vec_int4 a)
1219 return ((vec_int4)(si_orx((qword)(a))));
1223 /* spu_promote
1224 * ===========
1226 static __inline vec_uchar16 spu_promote(unsigned char a, int element)
1228 union {
1229 vec_uchar16 v;
1230 unsigned char c[16];
1231 } in;
1233 in.c[element & 15] = a;
1234 return (in.v);
1237 static __inline vec_char16 spu_promote(signed char a, int element)
1239 union {
1240 vec_char16 v;
1241 signed char c[16];
1242 } in;
1244 in.c[element & 15] = a;
1245 return (in.v);
1248 static __inline vec_ushort8 spu_promote(unsigned short a, int element)
1250 union {
1251 vec_ushort8 v;
1252 unsigned short s[8];
1253 } in;
1255 in.s[element & 7] = a;
1256 return (in.v);
1259 static __inline vec_short8 spu_promote(signed short a, int element)
1261 union {
1262 vec_short8 v;
1263 signed short s[8];
1264 } in;
1266 in.s[element & 7] = a;
1267 return (in.v);
1270 static __inline vec_uint4 spu_promote(unsigned int a, int element)
1272 union {
1273 vec_uint4 v;
1274 unsigned int i[4];
1275 } in;
1277 in.i[element & 3] = a;
1278 return (in.v);
1281 static __inline vec_int4 spu_promote(signed int a, int element)
1283 union {
1284 vec_int4 v;
1285 signed int i[4];
1286 } in;
1288 in.i[element & 3] = a;
1289 return (in.v);
1292 static __inline vec_float4 spu_promote(float a, int element)
1294 union {
1295 vec_float4 v;
1296 float f[4];
1297 } in;
1299 in.f[element & 3] = a;
1300 return (in.v);
1303 static __inline vec_ullong2 spu_promote(unsigned long long a, int element)
1305 union {
1306 vec_ullong2 v;
1307 unsigned long long l[2];
1308 } in;
1310 in.l[element & 1] = a;
1311 return (in.v);
1314 static __inline vec_llong2 spu_promote(signed long long a, int element)
1316 union {
1317 vec_llong2 v;
1318 signed long long l[2];
1319 } in;
1321 in.l[element & 1] = a;
1322 return (in.v);
1325 static __inline vec_double2 spu_promote(double a, int element)
1327 union {
1328 vec_double2 v;
1329 double d[2];
1330 } in;
1332 in.d[element & 1] = a;
1333 return (in.v);
1336 /* spu_re
1337 * ======
1339 #define spu_re(_a) vec_re(_a)
1342 /* spu_readch
1343 * ==========
1345 #define spu_readch(_channel) 0 /* not mappable */
1348 /* spu_readchcnt
1349 * =============
1351 #define spu_readchcnt(_channel) 0 /* not mappable */
1354 /* spu_readchqw
1355 * ============
1357 #define spu_readchqw(_channel) __extension__ ({ vec_uint4 result = { 0, 0, 0, 0 }; result; })
1359 /* spu_rl
1360 * ======
1362 static __inline vec_ushort8 spu_rl(vec_ushort8 a, vec_short8 b)
1364 return ((vec_ushort8)(si_roth((qword)(a), (qword)(b))));
1367 static __inline vec_short8 spu_rl(vec_short8 a, vec_short8 b)
1369 return ((vec_short8)(si_roth((qword)(a), (qword)(b))));
1372 static __inline vec_uint4 spu_rl(vec_uint4 a, vec_int4 b)
1374 return ((vec_uint4)(si_rot((qword)(a), (qword)(b))));
1377 static __inline vec_int4 spu_rl(vec_int4 a, vec_int4 b)
1379 return ((vec_int4)(si_rot((qword)(a), (qword)(b))));
1382 static __inline vec_ushort8 spu_rl(vec_ushort8 a, int b)
1384 return ((vec_ushort8)(si_rothi((qword)(a), b)));
1387 static __inline vec_short8 spu_rl(vec_short8 a, int b)
1389 return ((vec_short8)(si_rothi((qword)(a), b)));
1392 static __inline vec_uint4 spu_rl(vec_uint4 a, int b)
1394 return ((vec_uint4)(si_roti((qword)(a), b)));
1397 static __inline vec_int4 spu_rl(vec_int4 a, int b)
1399 return ((vec_int4)(si_roti((qword)(a), b)));
1403 /* spu_rlmask
1404 * ==========
1406 static __inline vec_ushort8 spu_rlmask(vec_ushort8 a, vec_short8 b)
1408 return ((vec_ushort8)(si_rothm((qword)(a), (qword)(b))));
1411 static __inline vec_short8 spu_rlmask(vec_short8 a, vec_short8 b)
1413 return ((vec_short8)(si_rothm((qword)(a), (qword)(b))));
1416 static __inline vec_uint4 spu_rlmask(vec_uint4 a, vec_int4 b)
1418 return ((vec_uint4)(si_rotm((qword)(a), (qword)(b))));
1421 static __inline vec_int4 spu_rlmask(vec_int4 a, vec_int4 b)
1423 return ((vec_int4)(si_rotm((qword)(a), (qword)(b))));
1426 static __inline vec_ushort8 spu_rlmask(vec_ushort8 a, int b)
1428 return ((vec_ushort8)(si_rothmi((qword)(a), b)));
1431 static __inline vec_short8 spu_rlmask(vec_short8 a, int b)
1433 return ((vec_short8)(si_rothmi((qword)(a), b)));
1437 static __inline vec_uint4 spu_rlmask(vec_uint4 a, int b)
1439 return ((vec_uint4)(si_rotmi((qword)(a), b)));
1442 static __inline vec_int4 spu_rlmask(vec_int4 a, int b)
1444 return ((vec_int4)(si_rotmi((qword)(a), b)));
1447 /* spu_rlmaska
1448 * ===========
1450 static __inline vec_short8 spu_rlmaska(vec_short8 a, vec_short8 b)
1452 return ((vec_short8)(si_rotmah((qword)(a), (qword)(b))));
1455 static __inline vec_ushort8 spu_rlmaska(vec_ushort8 a, vec_short8 b)
1457 return ((vec_ushort8)(si_rotmah((qword)(a), (qword)(b))));
1461 static __inline vec_int4 spu_rlmaska(vec_int4 a, vec_int4 b)
1463 return ((vec_int4)(si_rotma((qword)(a), (qword)(b))));
1466 static __inline vec_uint4 spu_rlmaska(vec_uint4 a, vec_int4 b)
1468 return ((vec_uint4)(si_rotma((qword)(a), (qword)(b))));
1471 static __inline vec_ushort8 spu_rlmaska(vec_ushort8 a, int b)
1473 return ((vec_ushort8)(si_rotmahi((qword)(a), b)));
1476 static __inline vec_short8 spu_rlmaska(vec_short8 a, int b)
1478 return ((vec_short8)(si_rotmahi((qword)(a), b)));
1481 static __inline vec_uint4 spu_rlmaska(vec_uint4 a, int b)
1483 return ((vec_uint4)(si_rotmai((qword)(a), b)));
1486 static __inline vec_int4 spu_rlmaska(vec_int4 a, int b)
1488 return ((vec_int4)(si_rotmai((qword)(a), b)));
1492 /* spu_rlmaskqw
1493 * ============
1495 static __inline vec_uchar16 spu_rlmaskqw(vec_uchar16 a, int count)
1497 return ((vec_uchar16)(si_rotqmbi((qword)(a), si_from_int(count))));
1500 static __inline vec_char16 spu_rlmaskqw(vec_char16 a, int count)
1502 return ((vec_char16)(si_rotqmbi((qword)(a), si_from_int(count))));
1505 static __inline vec_ushort8 spu_rlmaskqw(vec_ushort8 a, int count)
1507 return ((vec_ushort8)(si_rotqmbi((qword)(a), si_from_int(count))));
1510 static __inline vec_short8 spu_rlmaskqw(vec_short8 a, int count)
1512 return ((vec_short8)(si_rotqmbi((qword)(a), si_from_int(count))));
1515 static __inline vec_uint4 spu_rlmaskqw(vec_uint4 a, int count)
1517 return ((vec_uint4)(si_rotqmbi((qword)(a), si_from_int(count))));
1520 static __inline vec_int4 spu_rlmaskqw(vec_int4 a, int count)
1522 return ((vec_int4)(si_rotqmbi((qword)(a), si_from_int(count))));
1525 static __inline vec_float4 spu_rlmaskqw(vec_float4 a, int count)
1527 return ((vec_float4)(si_rotqmbi((qword)(a), si_from_int(count))));
1530 static __inline vec_ullong2 spu_rlmaskqw(vec_ullong2 a, int count)
1532 return ((vec_ullong2)(si_rotqmbi((qword)(a), si_from_int(count))));
1535 static __inline vec_llong2 spu_rlmaskqw(vec_llong2 a, int count)
1537 return ((vec_llong2)(si_rotqmbi((qword)(a), si_from_int(count))));
1540 static __inline vec_double2 spu_rlmaskqw(vec_double2 a, int count)
1542 return ((vec_double2)(si_rotqmbi((qword)(a), si_from_int(count))));
1545 /* spu_rlmaskqwbyte
1546 * ================
1548 static __inline vec_uchar16 spu_rlmaskqwbyte(vec_uchar16 a, int count)
1550 return ((vec_uchar16)(si_rotqmby((qword)(a), si_from_int(count))));
1553 static __inline vec_char16 spu_rlmaskqwbyte(vec_char16 a, int count)
1555 return ((vec_char16)(si_rotqmby((qword)(a), si_from_int(count))));
1558 static __inline vec_ushort8 spu_rlmaskqwbyte(vec_ushort8 a, int count)
1560 return ((vec_ushort8)(si_rotqmby((qword)(a), si_from_int(count))));
1563 static __inline vec_short8 spu_rlmaskqwbyte(vec_short8 a, int count)
1565 return ((vec_short8)(si_rotqmby((qword)(a), si_from_int(count))));
1568 static __inline vec_uint4 spu_rlmaskqwbyte(vec_uint4 a, int count)
1570 return ((vec_uint4)(si_rotqmby((qword)(a), si_from_int(count))));
1573 static __inline vec_int4 spu_rlmaskqwbyte(vec_int4 a, int count)
1575 return ((vec_int4)(si_rotqmby((qword)(a), si_from_int(count))));
1578 static __inline vec_float4 spu_rlmaskqwbyte(vec_float4 a, int count)
1580 return ((vec_float4)(si_rotqmby((qword)(a), si_from_int(count))));
1583 static __inline vec_ullong2 spu_rlmaskqwbyte(vec_ullong2 a, int count)
1585 return ((vec_ullong2)(si_rotqmby((qword)(a), si_from_int(count))));
1588 static __inline vec_llong2 spu_rlmaskqwbyte(vec_llong2 a, int count)
1590 return ((vec_llong2)(si_rotqmby((qword)(a), si_from_int(count))));
1593 static __inline vec_double2 spu_rlmaskqwbyte(vec_double2 a, int count)
1595 return ((vec_double2)(si_rotqmby((qword)(a), si_from_int(count))));
1598 /* spu_rlmaskqwbytebc
1599 * ==================
1601 static __inline vec_uchar16 spu_rlmaskqwbytebc(vec_uchar16 a, int count)
1603 return ((vec_uchar16)(si_rotqmbybi((qword)(a), si_from_int(count))));
1606 static __inline vec_char16 spu_rlmaskqwbytebc(vec_char16 a, int count)
1608 return ((vec_char16)(si_rotqmbybi((qword)(a), si_from_int(count))));
1611 static __inline vec_ushort8 spu_rlmaskqwbytebc(vec_ushort8 a, int count)
1613 return ((vec_ushort8)(si_rotqmbybi((qword)(a), si_from_int(count))));
1616 static __inline vec_short8 spu_rlmaskqwbytebc(vec_short8 a, int count)
1618 return ((vec_short8)(si_rotqmbybi((qword)(a), si_from_int(count))));
1621 static __inline vec_uint4 spu_rlmaskqwbytebc(vec_uint4 a, int count)
1623 return ((vec_uint4)(si_rotqmbybi((qword)(a), si_from_int(count))));
1626 static __inline vec_int4 spu_rlmaskqwbytebc(vec_int4 a, int count)
1628 return ((vec_int4)(si_rotqmbybi((qword)(a), si_from_int(count))));
1631 static __inline vec_float4 spu_rlmaskqwbytebc(vec_float4 a, int count)
1633 return ((vec_float4)(si_rotqmbybi((qword)(a), si_from_int(count))));
1636 static __inline vec_ullong2 spu_rlmaskqwbytebc(vec_ullong2 a, int count)
1638 return ((vec_ullong2)(si_rotqmbybi((qword)(a), si_from_int(count))));
1641 static __inline vec_llong2 spu_rlmaskqwbytebc(vec_llong2 a, int count)
1643 return ((vec_llong2)(si_rotqmbybi((qword)(a), si_from_int(count))));
1646 static __inline vec_double2 spu_rlmaskqwbytebc(vec_double2 a, int count)
1648 return ((vec_double2)(si_rotqmbybi((qword)(a), si_from_int(count))));
1652 /* spu_rlqwbyte
1653 * ============
1655 static __inline vec_uchar16 spu_rlqwbyte(vec_uchar16 a, int count)
1657 return ((vec_uchar16)(si_rotqby((qword)(a), si_from_int(count))));
1660 static __inline vec_char16 spu_rlqwbyte(vec_char16 a, int count)
1662 return ((vec_char16)(si_rotqby((qword)(a), si_from_int(count))));
1665 static __inline vec_ushort8 spu_rlqwbyte(vec_ushort8 a, int count)
1667 return ((vec_ushort8)(si_rotqby((qword)(a), si_from_int(count))));
1670 static __inline vec_short8 spu_rlqwbyte(vec_short8 a, int count)
1672 return ((vec_short8)(si_rotqby((qword)(a), si_from_int(count))));
1675 static __inline vec_uint4 spu_rlqwbyte(vec_uint4 a, int count)
1677 return ((vec_uint4)(si_rotqby((qword)(a), si_from_int(count))));
1680 static __inline vec_int4 spu_rlqwbyte(vec_int4 a, int count)
1682 return ((vec_int4)(si_rotqby((qword)(a), si_from_int(count))));
1685 static __inline vec_float4 spu_rlqwbyte(vec_float4 a, int count)
1687 return ((vec_float4)(si_rotqby((qword)(a), si_from_int(count))));
1690 static __inline vec_ullong2 spu_rlqwbyte(vec_ullong2 a, int count)
1692 return ((vec_ullong2)(si_rotqby((qword)(a), si_from_int(count))));
1695 static __inline vec_llong2 spu_rlqwbyte(vec_llong2 a, int count)
1697 return ((vec_llong2)(si_rotqby((qword)(a), si_from_int(count))));
1700 static __inline vec_double2 spu_rlqwbyte(vec_double2 a, int count)
1702 return ((vec_double2)(si_rotqby((qword)(a), si_from_int(count))));
1706 /* spu_rlqwbytebc
1707 * ==============
1709 static __inline vec_uchar16 spu_rlqwbytebc(vec_uchar16 a, int count)
1711 return ((vec_uchar16)(si_rotqbybi((qword)(a), si_from_int(count))));
1714 static __inline vec_char16 spu_rlqwbytebc(vec_char16 a, int count)
1716 return ((vec_char16)(si_rotqbybi((qword)(a), si_from_int(count))));
1719 static __inline vec_ushort8 spu_rlqwbytebc(vec_ushort8 a, int count)
1721 return ((vec_ushort8)(si_rotqbybi((qword)(a), si_from_int(count))));
1724 static __inline vec_short8 spu_rlqwbytebc(vec_short8 a, int count)
1726 return ((vec_short8)(si_rotqbybi((qword)(a), si_from_int(count))));
1729 static __inline vec_uint4 spu_rlqwbytebc(vec_uint4 a, int count)
1731 return ((vec_uint4)(si_rotqbybi((qword)(a), si_from_int(count))));
1734 static __inline vec_int4 spu_rlqwbytebc(vec_int4 a, int count)
1736 return ((vec_int4)(si_rotqbybi((qword)(a), si_from_int(count))));
1739 static __inline vec_float4 spu_rlqwbytebc(vec_float4 a, int count)
1741 return ((vec_float4)(si_rotqbybi((qword)(a), si_from_int(count))));
1744 static __inline vec_ullong2 spu_rlqwbytebc(vec_ullong2 a, int count)
1746 return ((vec_ullong2)(si_rotqbybi((qword)(a), si_from_int(count))));
1749 static __inline vec_llong2 spu_rlqwbytebc(vec_llong2 a, int count)
1751 return ((vec_llong2)(si_rotqbybi((qword)(a), si_from_int(count))));
1754 static __inline vec_double2 spu_rlqwbytebc(vec_double2 a, int count)
1756 return ((vec_double2)(si_rotqbybi((qword)(a), si_from_int(count))));
1759 /* spu_rlqw
1760 * ========
1762 static __inline vec_uchar16 spu_rlqw(vec_uchar16 a, int count)
1764 return ((vec_uchar16)(si_rotqbi((qword)(a), si_from_int(count))));
1767 static __inline vec_char16 spu_rlqw(vec_char16 a, int count)
1769 return ((vec_char16)(si_rotqbi((qword)(a), si_from_int(count))));
1772 static __inline vec_ushort8 spu_rlqw(vec_ushort8 a, int count)
1774 return ((vec_ushort8)(si_rotqbi((qword)(a), si_from_int(count))));
1777 static __inline vec_short8 spu_rlqw(vec_short8 a, int count)
1779 return ((vec_short8)(si_rotqbi((qword)(a), si_from_int(count))));
1782 static __inline vec_uint4 spu_rlqw(vec_uint4 a, int count)
1784 return ((vec_uint4)(si_rotqbi((qword)(a), si_from_int(count))));
1787 static __inline vec_int4 spu_rlqw(vec_int4 a, int count)
1789 return ((vec_int4)(si_rotqbi((qword)(a), si_from_int(count))));
1792 static __inline vec_float4 spu_rlqw(vec_float4 a, int count)
1794 return ((vec_float4)(si_rotqbi((qword)(a), si_from_int(count))));
1797 static __inline vec_ullong2 spu_rlqw(vec_ullong2 a, int count)
1799 return ((vec_ullong2)(si_rotqbi((qword)(a), si_from_int(count))));
1802 static __inline vec_llong2 spu_rlqw(vec_llong2 a, int count)
1804 return ((vec_llong2)(si_rotqbi((qword)(a), si_from_int(count))));
1807 static __inline vec_double2 spu_rlqw(vec_double2 a, int count)
1809 return ((vec_double2)(si_rotqbi((qword)(a), si_from_int(count))));
1812 /* spu_roundtf
1813 * ===========
1815 static __inline vec_float4 spu_roundtf(vec_double2 a)
1817 return ((vec_float4)(si_frds((qword)(a))));
1821 /* spu_rsqrte
1822 * ==========
1824 #define spu_rsqrte(_a) vec_rsqrte(_a)
1827 /* spu_sel
1828 * =======
1830 static __inline vec_uchar16 spu_sel(vec_uchar16 a, vec_uchar16 b, vec_uchar16 pattern)
1832 return ((vec_uchar16)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1835 static __inline vec_char16 spu_sel(vec_char16 a, vec_char16 b, vec_uchar16 pattern)
1837 return ((vec_char16)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1840 static __inline vec_ushort8 spu_sel(vec_ushort8 a, vec_ushort8 b, vec_ushort8 pattern)
1842 return ((vec_ushort8)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1845 static __inline vec_short8 spu_sel(vec_short8 a, vec_short8 b, vec_ushort8 pattern)
1847 return ((vec_short8)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1850 static __inline vec_uint4 spu_sel(vec_uint4 a, vec_uint4 b, vec_uint4 pattern)
1852 return ((vec_uint4)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1855 static __inline vec_int4 spu_sel(vec_int4 a, vec_int4 b, vec_uint4 pattern)
1857 return ((vec_int4)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1860 static __inline vec_float4 spu_sel(vec_float4 a, vec_float4 b, vec_uint4 pattern)
1862 return ((vec_float4)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1865 static __inline vec_ullong2 spu_sel(vec_ullong2 a, vec_ullong2 b, vec_ullong2 pattern)
1867 return ((vec_ullong2)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1870 static __inline vec_llong2 spu_sel(vec_llong2 a, vec_llong2 b, vec_ullong2 pattern)
1872 return ((vec_llong2)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1875 static __inline vec_double2 spu_sel(vec_double2 a, vec_double2 b, vec_ullong2 pattern)
1877 return ((vec_double2)(si_selb((qword)(a), (qword)(b), (qword)(pattern))));
1882 /* spu_shuffle
1883 * ===========
1885 static __inline vec_uchar16 spu_shuffle(vec_uchar16 a, vec_uchar16 b, vec_uchar16 pattern)
1887 return ((vec_uchar16)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1890 static __inline vec_char16 spu_shuffle(vec_char16 a, vec_char16 b, vec_uchar16 pattern)
1892 return ((vec_char16)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1895 static __inline vec_ushort8 spu_shuffle(vec_ushort8 a, vec_ushort8 b, vec_uchar16 pattern)
1897 return ((vec_ushort8)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1900 static __inline vec_short8 spu_shuffle(vec_short8 a, vec_short8 b, vec_uchar16 pattern)
1902 return ((vec_short8)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1905 static __inline vec_uint4 spu_shuffle(vec_uint4 a, vec_uint4 b, vec_uchar16 pattern)
1907 return ((vec_uint4)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1910 static __inline vec_int4 spu_shuffle(vec_int4 a, vec_int4 b, vec_uchar16 pattern)
1912 return ((vec_int4)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1915 static __inline vec_float4 spu_shuffle(vec_float4 a, vec_float4 b, vec_uchar16 pattern)
1917 return ((vec_float4)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1920 static __inline vec_ullong2 spu_shuffle(vec_ullong2 a, vec_ullong2 b, vec_uchar16 pattern)
1922 return ((vec_ullong2)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1925 static __inline vec_llong2 spu_shuffle(vec_llong2 a, vec_llong2 b, vec_uchar16 pattern)
1927 return ((vec_llong2)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1930 static __inline vec_double2 spu_shuffle(vec_double2 a, vec_double2 b, vec_uchar16 pattern)
1932 return ((vec_double2)(si_shufb((qword)(a), (qword)(b), (qword)(pattern))));
1936 /* spu_sl
1937 * ======
1939 static __inline vec_ushort8 spu_sl(vec_ushort8 a, vec_ushort8 b)
1941 return ((vec_ushort8)(si_shlh((qword)(a), (qword)(b))));
1944 static __inline vec_short8 spu_sl(vec_short8 a, vec_ushort8 b)
1946 return ((vec_short8)(si_shlh((qword)(a), (qword)(b))));
1949 static __inline vec_uint4 spu_sl(vec_uint4 a, vec_uint4 b)
1951 return ((vec_uint4)(si_shl((qword)(a), (qword)(b))));
1954 static __inline vec_int4 spu_sl(vec_int4 a, vec_uint4 b)
1956 return ((vec_int4)(si_shl((qword)(a), (qword)(b))));
1959 static __inline vec_ushort8 spu_sl(vec_ushort8 a, unsigned int b)
1961 return ((vec_ushort8)(si_shlhi((qword)(a), b)));
1964 static __inline vec_short8 spu_sl(vec_short8 a, unsigned int b)
1966 return ((vec_short8)(si_shlhi((qword)(a), b)));
1969 static __inline vec_uint4 spu_sl(vec_uint4 a, unsigned int b)
1971 return ((vec_uint4)(si_shli((qword)(a), b)));
1974 static __inline vec_int4 spu_sl(vec_int4 a, unsigned int b)
1976 return ((vec_int4)(si_shli((qword)(a), b)));
1980 /* spu_slqw
1981 * ========
1983 static __inline vec_uchar16 spu_slqw(vec_uchar16 a, unsigned int count)
1985 return ((vec_uchar16)(si_shlqbi((qword)(a), si_from_uint(count))));
1988 static __inline vec_char16 spu_slqw(vec_char16 a, unsigned int count)
1990 return ((vec_char16)(si_shlqbi((qword)(a), si_from_uint(count))));
1993 static __inline vec_ushort8 spu_slqw(vec_ushort8 a, unsigned int count)
1995 return ((vec_ushort8)(si_shlqbi((qword)(a), si_from_uint(count))));
1998 static __inline vec_short8 spu_slqw(vec_short8 a, unsigned int count)
2000 return ((vec_short8)(si_shlqbi((qword)(a), si_from_uint(count))));
2003 static __inline vec_uint4 spu_slqw(vec_uint4 a, unsigned int count)
2005 return ((vec_uint4)(si_shlqbi((qword)(a), si_from_uint(count))));
2008 static __inline vec_int4 spu_slqw(vec_int4 a, unsigned int count)
2010 return ((vec_int4)(si_shlqbi((qword)(a), si_from_uint(count))));
2013 static __inline vec_float4 spu_slqw(vec_float4 a, unsigned int count)
2015 return ((vec_float4)(si_shlqbi((qword)(a), si_from_uint(count))));
2018 static __inline vec_ullong2 spu_slqw(vec_ullong2 a, unsigned int count)
2020 return ((vec_ullong2)(si_shlqbi((qword)(a), si_from_uint(count))));
2023 static __inline vec_llong2 spu_slqw(vec_llong2 a, unsigned int count)
2025 return ((vec_llong2)(si_shlqbi((qword)(a), si_from_uint(count))));
2028 static __inline vec_double2 spu_slqw(vec_double2 a, unsigned int count)
2030 return ((vec_double2)(si_shlqbi((qword)(a), si_from_uint(count))));
2033 /* spu_slqwbyte
2034 * ============
2036 static __inline vec_uchar16 spu_slqwbyte(vec_uchar16 a, unsigned int count)
2038 return ((vec_uchar16)(si_shlqby((qword)(a), si_from_uint(count))));
2041 static __inline vec_char16 spu_slqwbyte(vec_char16 a, unsigned int count)
2043 return ((vec_char16)(si_shlqby((qword)(a), si_from_uint(count))));
2046 static __inline vec_ushort8 spu_slqwbyte(vec_ushort8 a, unsigned int count)
2048 return ((vec_ushort8)(si_shlqby((qword)(a), si_from_uint(count))));
2051 static __inline vec_short8 spu_slqwbyte(vec_short8 a, unsigned int count)
2053 return ((vec_short8)(si_shlqby((qword)(a), si_from_uint(count))));
2056 static __inline vec_uint4 spu_slqwbyte(vec_uint4 a, unsigned int count)
2058 return ((vec_uint4)(si_shlqby((qword)(a), si_from_uint(count))));
2061 static __inline vec_int4 spu_slqwbyte(vec_int4 a, unsigned int count)
2063 return ((vec_int4)(si_shlqby((qword)(a), si_from_uint(count))));
2066 static __inline vec_float4 spu_slqwbyte(vec_float4 a, unsigned int count)
2068 return ((vec_float4)(si_shlqby((qword)(a), si_from_uint(count))));
2071 static __inline vec_ullong2 spu_slqwbyte(vec_ullong2 a, unsigned int count)
2073 return ((vec_ullong2)(si_shlqby((qword)(a), si_from_uint(count))));
2076 static __inline vec_llong2 spu_slqwbyte(vec_llong2 a, unsigned int count)
2078 return ((vec_llong2)(si_shlqby((qword)(a), si_from_uint(count))));
2081 static __inline vec_double2 spu_slqwbyte(vec_double2 a, unsigned int count)
2083 return ((vec_double2)(si_shlqby((qword)(a), si_from_uint(count))));
2086 /* spu_slqwbytebc
2087 * ==============
2089 static __inline vec_uchar16 spu_slqwbytebc(vec_uchar16 a, unsigned int count)
2091 return ((vec_uchar16)(si_shlqbybi((qword)(a), si_from_uint(count))));
2094 static __inline vec_char16 spu_slqwbytebc(vec_char16 a, unsigned int count)
2096 return ((vec_char16)(si_shlqbybi((qword)(a), si_from_uint(count))));
2099 static __inline vec_ushort8 spu_slqwbytebc(vec_ushort8 a, unsigned int count)
2101 return ((vec_ushort8)(si_shlqbybi((qword)(a), si_from_uint(count))));
2104 static __inline vec_short8 spu_slqwbytebc(vec_short8 a, unsigned int count)
2106 return ((vec_short8)(si_shlqbybi((qword)(a), si_from_uint(count))));
2109 static __inline vec_uint4 spu_slqwbytebc(vec_uint4 a, unsigned int count)
2111 return ((vec_uint4)(si_shlqbybi((qword)(a), si_from_uint(count))));
2114 static __inline vec_int4 spu_slqwbytebc(vec_int4 a, unsigned int count)
2116 return ((vec_int4)(si_shlqbybi((qword)(a), si_from_uint(count))));
2119 static __inline vec_float4 spu_slqwbytebc(vec_float4 a, unsigned int count)
2121 return ((vec_float4)(si_shlqbybi((qword)(a), si_from_uint(count))));
2124 static __inline vec_ullong2 spu_slqwbytebc(vec_ullong2 a, unsigned int count)
2126 return ((vec_ullong2)(si_shlqbybi((qword)(a), si_from_uint(count))));
2129 static __inline vec_llong2 spu_slqwbytebc(vec_llong2 a, unsigned int count)
2131 return ((vec_llong2)(si_shlqbybi((qword)(a), si_from_uint(count))));
2134 static __inline vec_double2 spu_slqwbytebc(vec_double2 a, unsigned int count)
2136 return ((vec_double2)(si_shlqbybi((qword)(a), si_from_uint(count))));
2139 /* spu_splats
2140 * ==========
2142 static __inline vec_uchar16 spu_splats(unsigned char a)
2144 union {
2145 vec_uchar16 v;
2146 unsigned char c[16];
2147 } in;
2149 in.c[0] = a;
2150 return (vec_splat(in.v, 0));
2153 static __inline vec_char16 spu_splats(signed char a)
2155 return ((vec_char16)spu_splats((unsigned char)(a)));
2158 static __inline vec_ushort8 spu_splats(unsigned short a)
2160 union {
2161 vec_ushort8 v;
2162 unsigned short s[8];
2163 } in;
2165 in.s[0] = a;
2166 return (vec_splat(in.v, 0));
2169 static __inline vec_short8 spu_splats(signed short a)
2171 return ((vec_short8)spu_splats((unsigned short)(a)));
2174 static __inline vec_uint4 spu_splats(unsigned int a)
2176 union {
2177 vec_uint4 v;
2178 unsigned int i[4];
2179 } in;
2181 in.i[0] = a;
2182 return (vec_splat(in.v, 0));
2185 static __inline vec_int4 spu_splats(signed int a)
2187 return ((vec_int4)spu_splats((unsigned int)(a)));
2190 static __inline vec_float4 spu_splats(float a)
2192 union {
2193 vec_float4 v;
2194 float f[4];
2195 } in;
2197 in.f[0] = a;
2198 return (vec_splat(in.v, 0));
2201 static __inline vec_ullong2 spu_splats(unsigned long long a)
2203 union {
2204 vec_ullong2 v;
2205 unsigned long long l[2];
2206 } in;
2208 in.l[0] = a;
2209 in.l[1] = a;
2210 return (in.v);
2213 static __inline vec_llong2 spu_splats(signed long long a)
2215 return ((vec_llong2)spu_splats((unsigned long long)(a)));
2218 static __inline vec_double2 spu_splats(double a)
2220 union {
2221 vec_double2 v;
2222 double d[2];
2223 } in;
2225 in.d[0] = a;
2226 in.d[1] = a;
2227 return (in.v);
2231 /* spu_stop
2232 * ========
2234 #define spu_stop(_type) si_stop(_type)
2237 /* spu_sub
2238 * =======
2240 static __inline vec_ushort8 spu_sub(vec_ushort8 a, vec_ushort8 b)
2242 return ((vec_ushort8)(si_sfh((qword)(b), (qword)(a))));
2245 static __inline vec_short8 spu_sub(vec_short8 a, vec_short8 b)
2247 return ((vec_short8)(si_sfh((qword)(b), (qword)(a))));
2250 static __inline vec_uint4 spu_sub(vec_uint4 a, vec_uint4 b)
2252 return ((vec_uint4)(si_sf((qword)(b), (qword)(a))));
2255 static __inline vec_int4 spu_sub(vec_int4 a, vec_int4 b)
2257 return ((vec_int4)(si_sf((qword)(b), (qword)(a))));
2260 static __inline vec_float4 spu_sub(vec_float4 a, vec_float4 b)
2262 return ((vec_float4)(si_fs((qword)(a), (qword)(b))));
2265 static __inline vec_double2 spu_sub(vec_double2 a, vec_double2 b)
2267 return ((vec_double2)(si_dfs((qword)(a), (qword)(b))));
2270 static __inline vec_uint4 spu_sub(unsigned int a, vec_uint4 b)
2272 return ((vec_uint4)(si_sfi((qword)b, (int)a)));
2275 static __inline vec_int4 spu_sub(signed int a, vec_int4 b)
2277 return ((vec_int4)(si_sfi((qword)b, (int)a)));
2280 static __inline vec_ushort8 spu_sub(unsigned short a, vec_ushort8 b)
2282 return ((vec_ushort8)(si_sfhi((qword)b, (short)a)));
2285 static __inline vec_short8 spu_sub(signed short a, vec_short8 b)
2287 return ((vec_short8)(si_sfhi((qword)b, (short)a)));
2290 /* spu_subx
2291 * ========
2293 static __inline vec_uint4 spu_subx(vec_uint4 a, vec_uint4 b, vec_uint4 c)
2295 return ((vec_uint4)(si_sfx((qword)(b), (qword)(a), (qword)(c))));
2298 static __inline vec_int4 spu_subx(vec_int4 a, vec_int4 b, vec_int4 c)
2300 return ((vec_int4)(si_sfx((qword)(b), (qword)(a), (qword)(c))));
2303 /* spu_sumb
2304 * ========
2306 static __inline vec_ushort8 spu_sumb(vec_uchar16 a, vec_uchar16 b)
2308 return ((vec_ushort8)(si_sumb((qword)(a), (qword)(b))));
2312 /* spu_sync
2313 * spu_sync_c
2314 * ========
2316 #define spu_sync() /* do nothing */
2318 #define spu_sync_c() /* do nothing */
2321 /* spu_writech
2322 * ===========
2324 #define spu_writech(_channel, _a) /* not mappable */
2326 /* spu_writechqw
2327 * =============
2329 #define spu_writechqw(_channel, _a) /* not mappable */
2332 /* spu_xor
2333 * =======
2335 static __inline vec_uchar16 spu_xor(vec_uchar16 a, vec_uchar16 b)
2337 return ((vec_uchar16)(si_xor((qword)(a), (qword)(b))));
2340 static __inline vec_char16 spu_xor(vec_char16 a, vec_char16 b)
2342 return ((vec_char16)(si_xor((qword)(a), (qword)(b))));
2345 static __inline vec_ushort8 spu_xor(vec_ushort8 a, vec_ushort8 b)
2347 return ((vec_ushort8)(si_xor((qword)(a), (qword)(b))));
2350 static __inline vec_short8 spu_xor(vec_short8 a, vec_short8 b)
2352 return ((vec_short8)(si_xor((qword)(a), (qword)(b))));
2355 static __inline vec_uint4 spu_xor(vec_uint4 a, vec_uint4 b)
2357 return ((vec_uint4)(si_xor((qword)(a), (qword)(b))));
2360 static __inline vec_int4 spu_xor(vec_int4 a, vec_int4 b)
2362 return ((vec_int4)(si_xor((qword)(a), (qword)(b))));
2365 static __inline vec_float4 spu_xor(vec_float4 a, vec_float4 b)
2367 return ((vec_float4)(si_xor((qword)(a), (qword)(b))));
2370 static __inline vec_ullong2 spu_xor(vec_ullong2 a, vec_ullong2 b)
2372 return ((vec_ullong2)(si_xor((qword)(a), (qword)(b))));
2375 static __inline vec_llong2 spu_xor(vec_llong2 a, vec_llong2 b)
2377 return ((vec_llong2)(si_xor((qword)(a), (qword)(b))));
2380 static __inline vec_double2 spu_xor(vec_double2 a, vec_double2 b)
2382 return ((vec_double2)(si_xor((qword)(a), (qword)(b))));
2385 static __inline vec_uchar16 spu_xor(vec_uchar16 a, unsigned char b)
2387 return ((vec_uchar16)(si_xorbi((qword)(a), b)));
2390 static __inline vec_char16 spu_xor(vec_char16 a, signed char b)
2392 return ((vec_char16)(si_xorbi((qword)(a), (unsigned char)(b))));
2395 static __inline vec_ushort8 spu_xor(vec_ushort8 a, unsigned short b)
2397 return ((vec_ushort8)(si_xorhi((qword)(a), b)));
2400 static __inline vec_short8 spu_xor(vec_short8 a, signed short b)
2402 return ((vec_short8)(si_xorhi((qword)(a), (unsigned short)(b))));
2405 static __inline vec_uint4 spu_xor(vec_uint4 a, unsigned int b)
2407 return ((vec_uint4)(si_xori((qword)(a), b)));
2410 static __inline vec_int4 spu_xor(vec_int4 a, signed int b)
2412 return ((vec_int4)(si_xori((qword)(a), (unsigned int)(b))));
2415 #endif /* !__SPU__ */
2416 #endif /* __cplusplus */
2417 #endif /* !_SPU2VMX_H_ */