PR 61187 Fix use of uninitialized memory.
[official-gcc.git] / gcc / config / sh / ushmedia.h
blob03064e964d501013cab070929df1a1a14df9aef9
1 /* Copyright (C) 2000-2014 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
25 /* ushmedia.h: Intrinsics corresponding to SHmedia instructions that
26 may be executed in both user and privileged mode. */
28 #ifndef _USHMEDIA_H
29 #define _USHMEDIA_H
31 #if __SHMEDIA__
32 #if ! __SH4_NO_FPU
33 typedef float __GCC_FV __attribute__ ((vector_size (4 * sizeof (float))));
34 typedef float __GCC_MTRX __attribute__ ((vector_size (16 * sizeof (float))));
35 #endif
37 static __inline unsigned long long
38 sh_media_MABS_L (unsigned long long mm)
40 typedef float v2si __attribute__ ((mode(V2SI)));
42 return (unsigned long long) __builtin_absv2si2 ((v2si) mm);
45 static __inline unsigned long long
46 sh_media_MABS_W (unsigned long long mm)
48 typedef float v4hi __attribute__ ((mode(V4HI)));
50 return (unsigned long long) __builtin_absv4hi2 ((v4hi) mm);
53 static __inline unsigned long long
54 sh_media_MADD_L (unsigned long long mm, unsigned long long mn)
56 typedef float v2si __attribute__ ((mode(V2SI)));
58 return (unsigned long long) __builtin_addv2si3 ((v2si) mm, (v2si) mn);
61 static __inline unsigned long long
62 sh_media_MADD_W (unsigned long long mm, unsigned long long mn)
64 typedef float v4hi __attribute__ ((mode(V4HI)));
66 return (unsigned long long) __builtin_addv4hi3 ((v4hi) mm, (v4hi) mn);
69 static __inline unsigned long long
70 sh_media_MADDS_L (unsigned long long mm, unsigned long long mn)
72 typedef float v2si __attribute__ ((mode(V2SI)));
74 return (unsigned long long) __builtin_ssaddv2si3 ((v2si) mm, (v2si) mn);
77 static __inline unsigned long long
78 sh_media_MADDS_UB (unsigned long long mm, unsigned long long mn)
80 typedef float v8qi __attribute__ ((mode(V8QI)));
82 return (unsigned long long) __builtin_usaddv8qi3 ((v8qi) mm, (v8qi) mn);
85 static __inline unsigned long long
86 sh_media_MADDS_W (unsigned long long mm, unsigned long long mn)
88 typedef float v4hi __attribute__ ((mode(V4HI)));
90 return (unsigned long long) __builtin_ssaddv4hi3 ((v4hi) mm, (v4hi) mn);
93 static __inline unsigned long long
94 sh_media_MCMPEQ_B (unsigned long long mm, unsigned long long mn)
96 typedef float v8qi __attribute__ ((mode(V8QI)));
98 return (unsigned long long) __builtin_sh_media_MCMPEQ_B ((v8qi) mm,
99 (v8qi) mn);
102 static __inline unsigned long long
103 sh_media_MCMPEQ_L (unsigned long long mm, unsigned long long mn)
105 typedef float v2si __attribute__ ((mode(V2SI)));
107 return (unsigned long long) __builtin_sh_media_MCMPEQ_L ((v2si) mm,
108 (v2si) mn);
111 static __inline unsigned long long
112 sh_media_MCMPEQ_W (unsigned long long mm, unsigned long long mn)
114 typedef float v4hi __attribute__ ((mode(V4HI)));
116 return (unsigned long long) __builtin_sh_media_MCMPEQ_W ((v4hi) mm,
117 (v4hi) mn);
120 static __inline unsigned long long
121 sh_media_MCMPGT_UB (unsigned long long mm, unsigned long long mn)
123 typedef float v8qi __attribute__ ((mode(V8QI)));
125 return (unsigned long long) __builtin_sh_media_MCMPGT_UB ((v8qi) mm,
126 (v8qi) mn);
129 static __inline unsigned long long
130 sh_media_MCMPGT_L (unsigned long long mm, unsigned long long mn)
132 typedef float v2si __attribute__ ((mode(V2SI)));
134 return (unsigned long long) __builtin_sh_media_MCMPGT_L ((v2si) mm,
135 (v2si) mn);
138 static __inline unsigned long long
139 sh_media_MCMPGT_W (unsigned long long mm, unsigned long long mn)
141 typedef float v4hi __attribute__ ((mode(V4HI)));
143 return (unsigned long long) __builtin_sh_media_MCMPGT_W ((v4hi) mm,
144 (v4hi) mn);
147 #define sh_media_MCMV __builtin_sh_media_MCMV
149 static __inline unsigned long long
150 sh_media_MCNVS_LW (unsigned long long mm, unsigned long long mn)
152 typedef float v2si __attribute__ ((mode(V2SI)));
153 typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
155 return (unsigned long long) __builtin_sh_media_MCNVS_LW ((v2si) mm,
156 (uv2si) mn);
159 static __inline unsigned long long
160 sh_media_MCNVS_WB (unsigned long long mm, unsigned long long mn)
162 typedef float v4hi __attribute__ ((mode(V4HI)));
164 return (unsigned long long) __builtin_sh_media_MCNVS_WB ((v4hi) mm,
165 (v4hi) mn);
168 static __inline unsigned long long
169 sh_media_MCNVS_WUB (unsigned long long mm, unsigned long long mn)
171 typedef float v4hi __attribute__ ((mode(V4HI)));
173 return (unsigned long long) __builtin_sh_media_MCNVS_WUB ((v4hi) mm,
174 (v4hi) mn);
177 static __inline unsigned long long
178 sh_media_MEXTR1 (unsigned long long mm, unsigned long long mn)
180 typedef float v8qi __attribute__ ((mode(V8QI)));
182 return (unsigned long long) __builtin_sh_media_MEXTR1 ((v8qi) mm,
183 (v8qi) mn);
186 static __inline unsigned long long
187 sh_media_MEXTR2 (unsigned long long mm, unsigned long long mn)
189 typedef float v8qi __attribute__ ((mode(V8QI)));
191 return (unsigned long long) __builtin_sh_media_MEXTR2 ((v8qi) mm,
192 (v8qi) mn);
195 static __inline unsigned long long
196 sh_media_MEXTR3 (unsigned long long mm, unsigned long long mn)
198 typedef float v8qi __attribute__ ((mode(V8QI)));
200 return (unsigned long long) __builtin_sh_media_MEXTR3 ((v8qi) mm,
201 (v8qi) mn);
204 static __inline unsigned long long
205 sh_media_MEXTR4 (unsigned long long mm, unsigned long long mn)
207 typedef float v8qi __attribute__ ((mode(V8QI)));
209 return (unsigned long long) __builtin_sh_media_MEXTR4 ((v8qi) mm,
210 (v8qi) mn);
213 static __inline unsigned long long
214 sh_media_MEXTR5 (unsigned long long mm, unsigned long long mn)
216 typedef float v8qi __attribute__ ((mode(V8QI)));
218 return (unsigned long long) __builtin_sh_media_MEXTR5 ((v8qi) mm,
219 (v8qi) mn);
222 static __inline unsigned long long
223 sh_media_MEXTR6 (unsigned long long mm, unsigned long long mn)
225 typedef float v8qi __attribute__ ((mode(V8QI)));
227 return (unsigned long long) __builtin_sh_media_MEXTR6 ((v8qi) mm,
228 (v8qi) mn);
231 static __inline unsigned long long
232 sh_media_MEXTR7 (unsigned long long mm, unsigned long long mn)
234 typedef float v8qi __attribute__ ((mode(V8QI)));
236 return (unsigned long long) __builtin_sh_media_MEXTR7 ((v8qi) mm,
237 (v8qi) mn);
240 static __inline unsigned long long
241 sh_media_MMACFX_WL (unsigned long long mm, unsigned long long mn,
242 unsigned long long mw)
244 typedef float v2hi __attribute__ ((mode(V2HI)));
245 typedef float v2si __attribute__ ((mode(V2SI)));
246 typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
248 long mm_l = (long) mm;
249 long mn_l = (long) mn;
251 return ((unsigned long long)
252 __builtin_sh_media_MMACFX_WL ((v2hi) mm_l, (v2hi) mn_l,
253 (uv2si) mw));
256 static __inline unsigned long long
257 sh_media_MMACNFX_WL (unsigned long long mm, unsigned long long mn,
258 unsigned long long mw)
260 typedef float v2hi __attribute__ ((mode(V2HI)));
261 typedef float v2si __attribute__ ((mode(V2SI)));
262 typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
264 long mm_l = (long) mm;
265 long mn_l = (long) mn;
267 return ((unsigned long long)
268 __builtin_sh_media_MMACNFX_WL ((v2hi) mm_l, (v2hi) mn_l,
269 (uv2si) mw));
272 static __inline unsigned long long
273 sh_media_MMUL_L (unsigned long long mm, unsigned long long mn)
275 typedef float v2si __attribute__ ((mode(V2SI)));
277 return (unsigned long long) __builtin_mulv2si3 ((v2si) mm, (v2si) mn);
280 static __inline unsigned long long
281 sh_media_MMUL_W (unsigned long long mm, unsigned long long mn)
283 typedef float v4hi __attribute__ ((mode(V4HI)));
285 return (unsigned long long) __builtin_mulv4hi3 ((v4hi) mm, (v4hi) mn);
288 static __inline unsigned long long
289 sh_media_MMULFX_L (unsigned long long mm, unsigned long long mn)
291 typedef float v2si __attribute__ ((mode(V2SI)));
293 return (unsigned long long) __builtin_sh_media_MMULFX_L ((v2si) mm,
294 (v2si) mn);
297 static __inline unsigned long long
298 sh_media_MMULFX_W (unsigned long long mm, unsigned long long mn)
300 typedef float v4hi __attribute__ ((mode(V4HI)));
302 return (unsigned long long) __builtin_sh_media_MMULFX_W ((v4hi) mm,
303 (v4hi) mn);
306 static __inline unsigned long long
307 sh_media_MMULFXRP_W (unsigned long long mm, unsigned long long mn)
309 typedef float v4hi __attribute__ ((mode(V4HI)));
311 return (unsigned long long) __builtin_sh_media_MMULFXRP_W ((v4hi) mm,
312 (v4hi) mn);
315 static __inline unsigned long long
316 sh_media_MMULHI_WL (unsigned long long mm, unsigned long long mn)
318 typedef float v4hi __attribute__ ((mode(V4HI)));
320 return (unsigned long long) __builtin_sh_media_MMULHI_WL ((v4hi) mm,
321 (v4hi) mn);
324 static __inline unsigned long long
325 sh_media_MMULLO_WL (unsigned long long mm, unsigned long long mn)
327 typedef float v4hi __attribute__ ((mode(V4HI)));
329 return (unsigned long long) __builtin_sh_media_MMULLO_WL ((v4hi) mm,
330 (v4hi) mn);
333 static __inline unsigned long long
334 sh_media_MMULSUM_WQ (unsigned long long mm, unsigned long long mn,
335 unsigned long long mw)
337 typedef unsigned int uv4hi __attribute__ ((mode(V4HI)));
339 return __builtin_sh_media_MMULSUM_WQ ((uv4hi) mm, (uv4hi) mn, mw);
342 static __inline unsigned long long
343 sh_media_MPERM_W (unsigned long long mm, unsigned int mn)
345 typedef float v4hi __attribute__ ((mode(V4HI)));
347 return (unsigned long long) __builtin_sh_media_MPERM_W ((v4hi) mm, mn);
350 static __inline unsigned long long
351 sh_media_MSAD_UBQ (unsigned long long mm, unsigned long long mn,
352 unsigned long long mw)
354 typedef unsigned int uv8qi __attribute__ ((mode(V8QI)));
356 return __builtin_sh_media_MSAD_UBQ ((uv8qi) mm, (uv8qi) mn, mw);
359 static __inline unsigned long long
360 sh_media_MSHALDS_L (unsigned long long mm, unsigned int mn)
362 typedef float v2si __attribute__ ((mode(V2SI)));
364 return (unsigned long long) __builtin_sh_media_MSHALDS_L ((v2si) mm, mn);
367 static __inline unsigned long long
368 sh_media_MSHALDS_W (unsigned long long mm, unsigned int mn)
370 typedef float v4hi __attribute__ ((mode(V4HI)));
372 return (unsigned long long) __builtin_sh_media_MSHALDS_W ((v4hi) mm, mn);
375 static __inline unsigned long long
376 sh_media_MSHARD_L (unsigned long long mm, unsigned int mn)
378 typedef float v2si __attribute__ ((mode(V2SI)));
380 return (unsigned long long) __builtin_ashrv2si3 ((v2si) mm, mn);
383 static __inline unsigned long long
384 sh_media_MSHARD_W (unsigned long long mm, unsigned int mn)
386 typedef float v4hi __attribute__ ((mode(V4HI)));
388 return (unsigned long long) __builtin_ashrv4hi3 ((v4hi) mm, mn);
391 #define sh_media_MSHARDS_Q __builtin_sh_media_MSHARDS_Q
393 static __inline unsigned long long
394 sh_media_MSHFHI_B (unsigned long long mm, unsigned long long mn)
396 typedef float v8qi __attribute__ ((mode(V8QI)));
398 return (unsigned long long) __builtin_sh_media_MSHFHI_B ((v8qi) mm,
399 (v8qi) mn);
402 static __inline unsigned long long
403 sh_media_MSHFHI_L (unsigned long long mm, unsigned long long mn)
405 typedef float v2si __attribute__ ((mode(V2SI)));
407 return (unsigned long long) __builtin_sh_media_MSHFHI_L ((v2si) mm,
408 (v2si) mn);
411 static __inline unsigned long long
412 sh_media_MSHFHI_W (unsigned long long mm, unsigned long long mn)
414 typedef float v4hi __attribute__ ((mode(V4HI)));
416 return (unsigned long long) __builtin_sh_media_MSHFHI_W ((v4hi) mm,
417 (v4hi) mn);
420 static __inline unsigned long long
421 sh_media_MSHFLO_B (unsigned long long mm, unsigned long long mn)
423 typedef float v8qi __attribute__ ((mode(V8QI)));
425 return (unsigned long long) __builtin_sh_media_MSHFLO_B ((v8qi) mm,
426 (v8qi) mn);
429 static __inline unsigned long long
430 sh_media_MSHFLO_L (unsigned long long mm, unsigned long long mn)
432 typedef float v2si __attribute__ ((mode(V2SI)));
434 return (unsigned long long) __builtin_sh_media_MSHFLO_L ((v2si) mm,
435 (v2si) mn);
438 static __inline unsigned long long
439 sh_media_MSHFLO_W (unsigned long long mm, unsigned long long mn)
441 typedef float v4hi __attribute__ ((mode(V4HI)));
443 return (unsigned long long) __builtin_sh_media_MSHFLO_W ((v4hi) mm,
444 (v4hi) mn);
447 static __inline unsigned long long
448 sh_media_MSHLLD_L (unsigned long long mm, unsigned int mn)
450 typedef float v2si __attribute__ ((mode(V2SI)));
452 return (unsigned long long) __builtin_ashlv2si3 ((v2si) mm, mn);
455 static __inline unsigned long long
456 sh_media_MSHLLD_W (unsigned long long mm, unsigned int mn)
458 typedef float v4hi __attribute__ ((mode(V4HI)));
460 return (unsigned long long) __builtin_ashlv4hi3 ((v4hi) mm, mn);
463 static __inline unsigned long long
464 sh_media_MSHLRD_L (unsigned long long mm, unsigned int mn)
466 typedef float v2si __attribute__ ((mode(V2SI)));
468 return (unsigned long long) __builtin_lshrv2si3 ((v2si) mm, mn);
471 static __inline unsigned long long
472 sh_media_MSHLRD_W (unsigned long long mm, unsigned int mn)
474 typedef float v4hi __attribute__ ((mode(V4HI)));
476 return (unsigned long long) __builtin_lshrv4hi3 ((v4hi) mm, mn);
479 static __inline unsigned long long
480 sh_media_MSUB_L (unsigned long long mm, unsigned long long mn)
482 typedef float v2si __attribute__ ((mode(V2SI)));
484 return (unsigned long long) __builtin_subv2si3 ((v2si) mm, (v2si) mn);
487 static __inline unsigned long long
488 sh_media_MSUB_W (unsigned long long mm, unsigned long long mn)
490 typedef float v4hi __attribute__ ((mode(V4HI)));
492 return (unsigned long long) __builtin_subv4hi3 ((v4hi) mm, (v4hi) mn);
495 static __inline unsigned long long
496 sh_media_MSUBS_L (unsigned long long mm, unsigned long long mn)
498 typedef float v2si __attribute__ ((mode(V2SI)));
500 return (unsigned long long) __builtin_sssubv2si3 ((v2si) mm, (v2si) mn);
503 static __inline unsigned long long
504 sh_media_MSUBS_UB (unsigned long long mm, unsigned long long mn)
506 typedef float v8qi __attribute__ ((mode(V8QI)));
508 return (unsigned long long) __builtin_ussubv8qi3 ((v8qi) mm, (v8qi) mn);
511 static __inline unsigned long long
512 sh_media_MSUBS_W (unsigned long long mm, unsigned long long mn)
514 typedef float v4hi __attribute__ ((mode(V4HI)));
516 return (unsigned long long) __builtin_sssubv4hi3 ((v4hi) mm, (v4hi) mn);
519 #if ! __SH4_NOFPU__
520 /* Floating-point Intrinsics */
522 #define sh_media_FABS_D __builtin_fabs
523 #define sh_media_FABS_S __builtin_fabsf
524 #define sh_media_FCMPUN_D __builtin_isunordered
525 #define sh_media_FCMPUN_S __builtin_isunordered
527 static __inline float sh_media_FCOSA_S (float fg)
529 union { int i; float f; } u;
531 u.f = fg;
532 return __builtin_sh_media_FCOSA_S (u.i);
535 static __inline float
536 sh_media_FGETSCR (void)
538 float f;
540 __asm volatile ("fgetscr %0" : "=f" (f));
541 return f;
544 static __inline float
545 sh_media_FIPR_S (const void *fvg, const void *fvh)
547 typedef float v4sf __attribute__ ((mode(V4SF)));
548 v4sf vg = *(v4sf*) fvg;
549 v4sf vh = *(v4sf*) fvh;
551 return __builtin_sh_media_FIPR_S (vg, vh);
554 #if 0
555 /* This gives different results for -O0 */
556 static __inline float
557 sh_media_FMAC_S (float fg, float fh, float fq)
559 return fg * fh + fq;
561 #else
563 #define sh_media_FMAC_S __builtin_sh_media_FMAC_S
564 #endif
566 static __inline long long
567 sh_media_FMOV_DQ (double dg)
569 union { long long l; double d; } u;
571 u.d = dg;
572 return u.l;
575 static __inline float
576 sh_media_FMOV_LS (int mm)
578 union { int i; float f; } u;
580 u.i = mm;
581 return u.f;
584 static __inline double
585 sh_media_FMOV_QD (long long mm)
587 union { long long l; double d; } u;
589 u.l = mm;
590 return u.d;
593 static __inline int
594 sh_media_FMOV_SL (float fg)
596 union { int i; float f; } u;
598 u.f = fg;
599 return u.i;
602 static __inline void
603 sh_media_FPUTSCR (float fg)
605 __asm volatile ("fputscr %0" : : "f" (fg));
608 static __inline float sh_media_FSINA_S (float fg)
610 union { int i; float f; } u;
612 u.f = fg;
613 return __builtin_sh_media_FSINA_S (u.i);
616 /* Can't use __builtin_sqrt / __builtin_sqrtf because they still implement
617 error handling unless -ffast-math is used. */
618 #define sh_media_FSQRT_D __builtin_sh_media_FSQRT_D
619 #define sh_media_FSQRT_S __builtin_sh_media_FSQRT_S
620 #define sh_media_FSRRA_S __builtin_sh_media_FSRRA_S
622 static __inline void
623 sh_media_FTRV_S (const void *mtrxg, const void *fvh, void *fvf)
625 typedef float v16sf __attribute__ ((mode(V16SF)));
626 typedef float v4sf __attribute__ ((mode(V4SF)));
627 v16sf mtrx = *(v16sf*) mtrxg;
628 v4sf vh = *(v4sf*) fvh;
630 *(v4sf*) fvf = __builtin_sh_media_FTRV_S (mtrx, vh);
632 #endif /* ! __SH4_NOFPU__ */
634 /* Not implemented here: Control and Configuration intrinsics. */
635 /* Misaligned Access Support intrinsics */
637 static __inline unsigned long long
638 sh_media_LDHI_L (void *p, int s)
640 return __builtin_sh_media_LDHI_L ((char *)p + s);
643 static __inline unsigned long long
644 sh_media_LDHI_Q (void *p, int s)
646 return __builtin_sh_media_LDHI_Q ((char *)p + s);
649 static __inline unsigned long long
650 sh_media_LDLO_L (void *p, int s)
652 return __builtin_sh_media_LDLO_L ((char *)p + s);
655 static __inline unsigned long long
656 sh_media_LDLO_Q (void *p, int s)
658 return __builtin_sh_media_LDLO_Q ((char *)p + s);
661 static __inline void
662 sh_media_STHI_L (void *p, int s, unsigned int mw)
664 __builtin_sh_media_STHI_L ((char*)p + s, mw);
667 static __inline void
668 sh_media_STHI_Q (void *p, int s, unsigned long long mw)
670 __builtin_sh_media_STHI_Q ((char*)p + s, mw);
673 static __inline void
674 sh_media_STLO_L (void *p, int s, unsigned int mw)
676 __builtin_sh_media_STLO_L ((char*)p + s, mw);
679 static __inline void
680 sh_media_STLO_Q (void *p, int s, unsigned long long mw)
682 __builtin_sh_media_STLO_Q ((char*)p + s, mw);
685 /* Miscellaneous intrinsics */
687 #define sh_media_NSB __builtin_sh_media_NSB
689 static __inline unsigned long long
690 sh_media_BYTEREV (unsigned long long mm)
692 typedef float v8qi __attribute__ ((mode(V8QI)));
694 return (unsigned long long) __builtin_sh_media_BYTEREV ((v8qi) mm);
697 __inline__ static unsigned long long
698 sh_media_CMVEQ (unsigned long long mm, unsigned long long mn, unsigned long long mw) __attribute__ ((always_inline));
700 __inline__ static unsigned long long
701 sh_media_CMVEQ (unsigned long long mm, unsigned long long mn, unsigned long long mw)
703 return mm == 0 ? mn : mw;
706 __inline__ static unsigned long long
707 sh_media_CMVNE (unsigned long long mm, unsigned long long mn, unsigned long long mw) __attribute__ ((always_inline));
709 __inline__ static unsigned long long
710 sh_media_CMVNE (unsigned long long mm, unsigned long long mn, unsigned long long mw)
712 return mm != 0 ? mn : mw;
715 static __inline long long
716 sh_media_ADDZ_L (unsigned int mm, unsigned int mn)
718 return mm + mn;
721 /* NOP and Synchronization intrinsics not implemented here. */
723 static __inline__ void sh_media_PREFO(void *mm, int s)
725 __builtin_sh_media_PREFO (mm + s, 0, 0);
728 /* Event Handling intrinsics not implemented here. */
730 /* Old asm stuff */
732 static __inline__
733 void
734 sh_media_NOP (void)
736 __asm__ ("nop" : :);
739 __inline__ static
740 unsigned long long
741 sh_media_SWAP_Q (void *mm, long long mn, unsigned long long mw)
743 unsigned long long res;
744 unsigned long long *addr = (unsigned long long *)((char *)mm + mn);
745 __asm__ ("swap.q %m1, %0" : "=r" (res), "+o" (*addr) : "0" (mw));
746 return res;
749 __inline__ static
750 void
751 sh_media_SYNCI (void)
753 __asm__ __volatile__ ("synci");
756 __inline__ static
757 void
758 sh_media_SYNCO (void)
760 __asm__ __volatile__ ("synco");
763 __inline__ static
764 void
765 sh_media_ALLOCO (void *mm, int s)
767 __builtin_sh_media_ALLOCO (mm + s);
770 __inline__ static
771 void
772 sh_media_ICBI (void *mm, int s)
774 __asm__ __volatile__ ("icbi %m0" : : "o" (((char*)mm)[s]));
777 __inline__ static
778 void
779 sh_media_OCBI (void *mm, int s)
781 __asm__ __volatile__ ("ocbi %m0" : : "o" (((char*)mm)[s]));
784 __inline__ static
785 void
786 sh_media_OCBP (void *mm, int s)
788 __asm__ __volatile__ ("ocbp %m0" : : "o" (((char*)mm)[s]));
791 __inline__ static
792 void
793 sh_media_OCBWB (void *mm, int s)
795 __asm__ __volatile__ ("ocbwb %m0" : : "o" (((char*)mm)[s]));
798 __inline__ static
799 void
800 sh_media_PREFI (void *mm, int s)
802 __asm__ __volatile__ ("prefi %m0" : : "o" (((char*)mm)[s]));
805 __inline__ static
806 void
807 sh_media_BRK (void)
809 __asm__ __volatile__ ("brk");
812 __inline__ static
813 void
814 sh_media_TRAPA (unsigned long long mm)
816 __asm__ __volatile__ ("trapa %%0" : : "r" (mm));
819 __inline__ static
820 short
821 sh_media_unaligned_LD_W (void *p)
823 #if __LITTLE_ENDIAN__
824 return (((unsigned char *)p)[0]
825 | (((short)((__signed__ char *)p)[1]) << 8));
826 #else
827 return ((((short)((__signed__ char *)p)[0]) << 8)
828 | ((unsigned char *)p)[1]);
829 #endif
832 __inline__ static
833 unsigned short
834 sh_media_unaligned_LD_UW (void *p)
836 unsigned char *addr = p;
837 #if __LITTLE_ENDIAN__
838 return sh_media_MSHFLO_B (addr[0], addr[1]);
839 #else
840 return sh_media_MSHFLO_B (addr[1], addr[0]);
841 #endif
844 /* We don't use the sh_media_LD* functions here because that turned out
845 to impede constant propagation of the offsets into the ldhi / ldlo
846 instructions. */
847 __inline__ static
848 int
849 sh_media_unaligned_LD_L (void *p)
851 #if __LITTLE_ENDIAN__
852 return (__builtin_sh_media_LDHI_L ((char *)p + 3)
853 | __builtin_sh_media_LDLO_L (p));
854 #else
855 return (__builtin_sh_media_LDLO_L ((char *)p + 3)
856 | __builtin_sh_media_LDHI_L (p));
857 #endif
860 __inline__ static
861 long long
862 sh_media_unaligned_LD_Q (void *p)
864 #if __LITTLE_ENDIAN__
865 return (__builtin_sh_media_LDHI_Q ((char *)p + 7)
866 | __builtin_sh_media_LDLO_Q (p));
867 #else
868 return (__builtin_sh_media_LDLO_Q ((char *)p + 7)
869 | __builtin_sh_media_LDHI_Q (p));
870 #endif
873 __inline__ static
874 void
875 sh_media_unaligned_ST_W (void *p, unsigned int k)
877 char *addr = p;
878 #if __LITTLE_ENDIAN__
879 addr[0] = k;
880 addr[1] = k >> 8;
881 #else
882 addr[1] = k;
883 addr[0] = k >> 8;
884 #endif
887 /* We don't use the sh_media_ST* functions here because that turned out
888 to impede constant propagation of the offsets into the ldhi / ldlo
889 instructions. */
890 __inline__ static
891 void
892 sh_media_unaligned_ST_L (void *p, unsigned int k)
894 #if __LITTLE_ENDIAN__
895 __builtin_sh_media_STHI_L (p + 3, k);
896 __builtin_sh_media_STLO_L (p, k);
897 #else
898 __builtin_sh_media_STLO_L (p + 3, k);
899 __builtin_sh_media_STHI_L (p, k);
900 #endif
903 __inline__ static
904 void
905 sh_media_unaligned_ST_Q (void *p, unsigned long long k)
907 #if __LITTLE_ENDIAN__
908 __builtin_sh_media_STHI_Q (p + 7, k);
909 __builtin_sh_media_STLO_Q (p, k);
910 #else
911 __builtin_sh_media_STLO_Q (p + 7, k);
912 __builtin_sh_media_STHI_Q (p, k);
913 #endif
916 #if ! __SH4_NOFPU__
917 __inline__ static
918 void
919 sh_media_FVCOPY_S (const void *fvg, void *fvf)
921 const __GCC_FV *g = fvg;
922 __GCC_FV *f = fvf;
923 *f = *g;
926 __inline__ static
927 void
928 sh_media_FVADD_S (const void *fvg, const void *fvh, void *fvf)
930 const float *g = fvg, *h = fvh;
931 float *f = fvf;
932 #if 1
933 int i;
935 for (i = 0; i < 4; i++)
936 f[i] = g[i] + h[i];
937 #else
938 f[0] = g[0] + h[0];
939 f[1] = g[1] + h[1];
940 f[2] = g[2] + h[2];
941 f[3] = g[3] + h[3];
942 #endif
945 __inline__ static
946 void
947 sh_media_FVSUB_S (const void *fvg, const void *fvh, void *fvf)
949 const float *g = fvg, *h = fvh;
950 float *f = fvf;
951 #if 1
952 int i;
954 for (i = 0; i < 4; i++)
955 f[i] = g[i] - h[i];
956 #else
957 f[0] = g[0] - h[0];
958 f[1] = g[1] - h[1];
959 f[2] = g[2] - h[2];
960 f[3] = g[3] - h[3];
961 #endif
964 __inline__ static
965 void
966 sh_media_FMTRXCOPY_S (const void *mtrxg, void *mtrxf)
968 const __GCC_MTRX *g = mtrxg;
969 __GCC_MTRX *f = mtrxf;
970 *f = *g;
973 __inline__ static
974 void
975 sh_media_FMTRXADD_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
977 const __GCC_FV *g = mtrxg, *h = mtrxh;
978 __GCC_FV *f = mtrxf;
979 #if 1
980 int i;
982 for (i = 0; i < 4; i++)
983 sh_media_FVADD_S (&g[i], &h[i], &f[i]);
984 #else
985 sh_media_FVADD_S (&g[0], &h[0], &f[0]);
986 sh_media_FVADD_S (&g[1], &h[1], &f[1]);
987 sh_media_FVADD_S (&g[2], &h[2], &f[2]);
988 sh_media_FVADD_S (&g[3], &h[3], &f[3]);
989 #endif
992 __inline__ static
993 void
994 sh_media_FMTRXSUB_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
996 const __GCC_FV *g = mtrxg, *h = mtrxh;
997 __GCC_FV *f = mtrxf;
998 #if 1
999 int i;
1001 for (i = 0; i < 4; i++)
1002 sh_media_FVSUB_S (&g[i], &h[i], &f[i]);
1003 #else
1004 sh_media_FVSUB_S (&g[0], &h[0], &f[0]);
1005 sh_media_FVSUB_S (&g[1], &h[1], &f[1]);
1006 sh_media_FVSUB_S (&g[2], &h[2], &f[2]);
1007 sh_media_FVSUB_S (&g[3], &h[3], &f[3]);
1008 #endif
1011 __inline__ static
1012 void
1013 sh_media_FTRVADD_S (const void *mtrxg, const void *fvh, const void *fvi,
1014 void *fvf)
1016 sh_media_FTRV_S (mtrxg, fvh, fvf);
1017 sh_media_FVADD_S (fvf, fvi, fvf);
1020 __inline__ static
1021 void
1022 sh_media_FTRVSUB_S (const void *mtrxg, const void *fvh, const void *fvi,
1023 void *fvf)
1025 sh_media_FTRV_S (mtrxg, fvh, fvf);
1026 sh_media_FVSUB_S (fvf, fvi, fvf);
1029 __inline__ static
1030 void
1031 sh_media_FMTRXMUL_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
1033 const __GCC_FV *g = mtrxg;
1034 __GCC_FV *f = mtrxf;
1035 #if 1
1036 int j;
1038 for (j = 0; j < 4; j++)
1039 sh_media_FTRV_S (mtrxh, &g[j], &f[j]);
1040 #else
1041 sh_media_FTRV_S (mtrxh, &g[0], &f[0]);
1042 sh_media_FTRV_S (mtrxh, &g[1], &f[1]);
1043 sh_media_FTRV_S (mtrxh, &g[2], &f[2]);
1044 sh_media_FTRV_S (mtrxh, &g[3], &f[3]);
1045 #endif
1048 __inline__ static
1049 void
1050 sh_media_FMTRXMULADD_S (const void *mtrxg, const void *mtrxh,
1051 const void *mtrxi, void *mtrxf)
1053 const __GCC_FV *g = mtrxg, *i = mtrxi;
1054 __GCC_FV *f = mtrxf;
1055 #if 1
1056 int j;
1058 for (j = 0; j < 4; j++)
1059 sh_media_FTRVADD_S (mtrxh, &g[j], &i[j], &f[j]);
1060 #else
1061 sh_media_FTRVADD_S (mtrxh, &g[0], &i[0], &f[0]);
1062 sh_media_FTRVADD_S (mtrxh, &g[1], &i[1], &f[1]);
1063 sh_media_FTRVADD_S (mtrxh, &g[2], &i[2], &f[2]);
1064 sh_media_FTRVADD_S (mtrxh, &g[3], &i[3], &f[3]);
1065 #endif
1068 __inline__ static
1069 void
1070 sh_media_FMTRXMULSUB_S (const void *mtrxg, const void *mtrxh,
1071 const void *mtrxi, void *mtrxf)
1073 const __GCC_FV *g = mtrxg, *i = mtrxi;
1074 __GCC_FV *f = mtrxf;
1075 #if 1
1076 int j;
1078 for (j = 0; j < 4; j++)
1079 sh_media_FTRVSUB_S (mtrxh, &g[j], &i[j], &f[j]);
1080 #else
1081 sh_media_FTRVSUB_S (mtrxh, &g[0], &i[0], &f[0]);
1082 sh_media_FTRVSUB_S (mtrxh, &g[1], &i[1], &f[1]);
1083 sh_media_FTRVSUB_S (mtrxh, &g[2], &i[2], &f[2]);
1084 sh_media_FTRVSUB_S (mtrxh, &g[3], &i[3], &f[3]);
1085 #endif
1087 #endif /* ! __SH4_NOFPU__ */
1089 #endif /* __SHMEDIA__ */
1091 #endif /* _USHMEDIA_H */