1 /* Copyright (C) 2000, 2001, 2004, 2005 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 2, or (at your option)
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 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING. If not, write to
17 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. */
20 /* As a special exception, if you include this header file into source
21 files compiled by GCC, this header file does not by itself cause
22 the resulting executable to be covered by the GNU General Public
23 License. This exception does not however invalidate any other
24 reasons why the executable file might be covered by the GNU General
27 /* ushmedia.h: Intrinsics corresponding to SHmedia instructions that
28 may be executed in both user and privileged mode. */
35 typedef float __GCC_FV
__attribute__ ((vector_size (4 * sizeof (float))));
36 typedef float __GCC_MTRX
__attribute__ ((vector_size (16 * sizeof (float))));
39 static __inline
unsigned long long
40 sh_media_MABS_L (unsigned long long mm
)
42 typedef float v2si
__attribute__ ((mode(V2SI
)));
44 return (unsigned long long) __builtin_absv2si2 ((v2si
) mm
);
47 static __inline
unsigned long long
48 sh_media_MABS_W (unsigned long long mm
)
50 typedef float v4hi
__attribute__ ((mode(V4HI
)));
52 return (unsigned long long) __builtin_absv4hi2 ((v4hi
) mm
);
55 static __inline
unsigned long long
56 sh_media_MADD_L (unsigned long long mm
, unsigned long long mn
)
58 typedef float v2si
__attribute__ ((mode(V2SI
)));
60 return (unsigned long long) __builtin_addv2si3 ((v2si
) mm
, (v2si
) mn
);
63 static __inline
unsigned long long
64 sh_media_MADD_W (unsigned long long mm
, unsigned long long mn
)
66 typedef float v4hi
__attribute__ ((mode(V4HI
)));
68 return (unsigned long long) __builtin_addv4hi3 ((v4hi
) mm
, (v4hi
) mn
);
71 static __inline
unsigned long long
72 sh_media_MADDS_L (unsigned long long mm
, unsigned long long mn
)
74 typedef float v2si
__attribute__ ((mode(V2SI
)));
76 return (unsigned long long) __builtin_ssaddv2si3 ((v2si
) mm
, (v2si
) mn
);
79 static __inline
unsigned long long
80 sh_media_MADDS_UB (unsigned long long mm
, unsigned long long mn
)
82 typedef float v8qi
__attribute__ ((mode(V8QI
)));
84 return (unsigned long long) __builtin_usaddv8qi3 ((v8qi
) mm
, (v8qi
) mn
);
87 static __inline
unsigned long long
88 sh_media_MADDS_W (unsigned long long mm
, unsigned long long mn
)
90 typedef float v4hi
__attribute__ ((mode(V4HI
)));
92 return (unsigned long long) __builtin_ssaddv4hi3 ((v4hi
) mm
, (v4hi
) mn
);
95 static __inline
unsigned long long
96 sh_media_MCMPEQ_B (unsigned long long mm
, unsigned long long mn
)
98 typedef float v8qi
__attribute__ ((mode(V8QI
)));
100 return (unsigned long long) __builtin_sh_media_MCMPEQ_B ((v8qi
) mm
,
104 static __inline
unsigned long long
105 sh_media_MCMPEQ_L (unsigned long long mm
, unsigned long long mn
)
107 typedef float v2si
__attribute__ ((mode(V2SI
)));
109 return (unsigned long long) __builtin_sh_media_MCMPEQ_L ((v2si
) mm
,
113 static __inline
unsigned long long
114 sh_media_MCMPEQ_W (unsigned long long mm
, unsigned long long mn
)
116 typedef float v4hi
__attribute__ ((mode(V4HI
)));
118 return (unsigned long long) __builtin_sh_media_MCMPEQ_W ((v4hi
) mm
,
122 static __inline
unsigned long long
123 sh_media_MCMPGT_UB (unsigned long long mm
, unsigned long long mn
)
125 typedef float v8qi
__attribute__ ((mode(V8QI
)));
127 return (unsigned long long) __builtin_sh_media_MCMPGT_UB ((v8qi
) mm
,
131 static __inline
unsigned long long
132 sh_media_MCMPGT_L (unsigned long long mm
, unsigned long long mn
)
134 typedef float v2si
__attribute__ ((mode(V2SI
)));
136 return (unsigned long long) __builtin_sh_media_MCMPGT_L ((v2si
) mm
,
140 static __inline
unsigned long long
141 sh_media_MCMPGT_W (unsigned long long mm
, unsigned long long mn
)
143 typedef float v4hi
__attribute__ ((mode(V4HI
)));
145 return (unsigned long long) __builtin_sh_media_MCMPGT_W ((v4hi
) mm
,
149 #define sh_media_MCMV __builtin_sh_media_MCMV
151 static __inline
unsigned long long
152 sh_media_MCNVS_LW (unsigned long long mm
, unsigned long long mn
)
154 typedef float v2si
__attribute__ ((mode(V2SI
)));
155 typedef unsigned int uv2si
__attribute__ ((mode(V2SI
)));
157 return (unsigned long long) __builtin_sh_media_MCNVS_LW ((v2si
) mm
,
161 static __inline
unsigned long long
162 sh_media_MCNVS_WB (unsigned long long mm
, unsigned long long mn
)
164 typedef float v4hi
__attribute__ ((mode(V4HI
)));
166 return (unsigned long long) __builtin_sh_media_MCNVS_WB ((v4hi
) mm
,
170 static __inline
unsigned long long
171 sh_media_MCNVS_WUB (unsigned long long mm
, unsigned long long mn
)
173 typedef float v4hi
__attribute__ ((mode(V4HI
)));
175 return (unsigned long long) __builtin_sh_media_MCNVS_WUB ((v4hi
) mm
,
179 static __inline
unsigned long long
180 sh_media_MEXTR1 (unsigned long long mm
, unsigned long long mn
)
182 typedef float v8qi
__attribute__ ((mode(V8QI
)));
184 return (unsigned long long) __builtin_sh_media_MEXTR1 ((v8qi
) mm
,
188 static __inline
unsigned long long
189 sh_media_MEXTR2 (unsigned long long mm
, unsigned long long mn
)
191 typedef float v8qi
__attribute__ ((mode(V8QI
)));
193 return (unsigned long long) __builtin_sh_media_MEXTR2 ((v8qi
) mm
,
197 static __inline
unsigned long long
198 sh_media_MEXTR3 (unsigned long long mm
, unsigned long long mn
)
200 typedef float v8qi
__attribute__ ((mode(V8QI
)));
202 return (unsigned long long) __builtin_sh_media_MEXTR3 ((v8qi
) mm
,
206 static __inline
unsigned long long
207 sh_media_MEXTR4 (unsigned long long mm
, unsigned long long mn
)
209 typedef float v8qi
__attribute__ ((mode(V8QI
)));
211 return (unsigned long long) __builtin_sh_media_MEXTR4 ((v8qi
) mm
,
215 static __inline
unsigned long long
216 sh_media_MEXTR5 (unsigned long long mm
, unsigned long long mn
)
218 typedef float v8qi
__attribute__ ((mode(V8QI
)));
220 return (unsigned long long) __builtin_sh_media_MEXTR5 ((v8qi
) mm
,
224 static __inline
unsigned long long
225 sh_media_MEXTR6 (unsigned long long mm
, unsigned long long mn
)
227 typedef float v8qi
__attribute__ ((mode(V8QI
)));
229 return (unsigned long long) __builtin_sh_media_MEXTR6 ((v8qi
) mm
,
233 static __inline
unsigned long long
234 sh_media_MEXTR7 (unsigned long long mm
, unsigned long long mn
)
236 typedef float v8qi
__attribute__ ((mode(V8QI
)));
238 return (unsigned long long) __builtin_sh_media_MEXTR7 ((v8qi
) mm
,
242 static __inline
unsigned long long
243 sh_media_MMACFX_WL (unsigned long long mm
, unsigned long long mn
,
244 unsigned long long mw
)
246 typedef float v2hi
__attribute__ ((mode(V2HI
)));
247 typedef float v2si
__attribute__ ((mode(V2SI
)));
248 typedef unsigned int uv2si
__attribute__ ((mode(V2SI
)));
250 long mm_l
= (long) mm
;
251 long mn_l
= (long) mn
;
253 return ((unsigned long long)
254 __builtin_sh_media_MMACFX_WL ((v2hi
) mm_l
, (v2hi
) mn_l
,
258 static __inline
unsigned long long
259 sh_media_MMACNFX_WL (unsigned long long mm
, unsigned long long mn
,
260 unsigned long long mw
)
262 typedef float v2hi
__attribute__ ((mode(V2HI
)));
263 typedef float v2si
__attribute__ ((mode(V2SI
)));
264 typedef unsigned int uv2si
__attribute__ ((mode(V2SI
)));
266 long mm_l
= (long) mm
;
267 long mn_l
= (long) mn
;
269 return ((unsigned long long)
270 __builtin_sh_media_MMACNFX_WL ((v2hi
) mm_l
, (v2hi
) mn_l
,
274 static __inline
unsigned long long
275 sh_media_MMUL_L (unsigned long long mm
, unsigned long long mn
)
277 typedef float v2si
__attribute__ ((mode(V2SI
)));
279 return (unsigned long long) __builtin_mulv2si3 ((v2si
) mm
, (v2si
) mn
);
282 static __inline
unsigned long long
283 sh_media_MMUL_W (unsigned long long mm
, unsigned long long mn
)
285 typedef float v4hi
__attribute__ ((mode(V4HI
)));
287 return (unsigned long long) __builtin_mulv4hi3 ((v4hi
) mm
, (v4hi
) mn
);
290 static __inline
unsigned long long
291 sh_media_MMULFX_L (unsigned long long mm
, unsigned long long mn
)
293 typedef float v2si
__attribute__ ((mode(V2SI
)));
295 return (unsigned long long) __builtin_sh_media_MMULFX_L ((v2si
) mm
,
299 static __inline
unsigned long long
300 sh_media_MMULFX_W (unsigned long long mm
, unsigned long long mn
)
302 typedef float v4hi
__attribute__ ((mode(V4HI
)));
304 return (unsigned long long) __builtin_sh_media_MMULFX_W ((v4hi
) mm
,
308 static __inline
unsigned long long
309 sh_media_MMULFXRP_W (unsigned long long mm
, unsigned long long mn
)
311 typedef float v4hi
__attribute__ ((mode(V4HI
)));
313 return (unsigned long long) __builtin_sh_media_MMULFXRP_W ((v4hi
) mm
,
317 static __inline
unsigned long long
318 sh_media_MMULHI_WL (unsigned long long mm
, unsigned long long mn
)
320 typedef float v4hi
__attribute__ ((mode(V4HI
)));
322 return (unsigned long long) __builtin_sh_media_MMULHI_WL ((v4hi
) mm
,
326 static __inline
unsigned long long
327 sh_media_MMULLO_WL (unsigned long long mm
, unsigned long long mn
)
329 typedef float v4hi
__attribute__ ((mode(V4HI
)));
331 return (unsigned long long) __builtin_sh_media_MMULLO_WL ((v4hi
) mm
,
335 static __inline
unsigned long long
336 sh_media_MMULSUM_WQ (unsigned long long mm
, unsigned long long mn
,
337 unsigned long long mw
)
339 typedef unsigned int uv4hi
__attribute__ ((mode(V4HI
)));
341 return __builtin_sh_media_MMULSUM_WQ ((uv4hi
) mm
, (uv4hi
) mn
, mw
);
344 static __inline
unsigned long long
345 sh_media_MPERM_W (unsigned long long mm
, unsigned int mn
)
347 typedef float v4hi
__attribute__ ((mode(V4HI
)));
349 return (unsigned long long) __builtin_sh_media_MPERM_W ((v4hi
) mm
, mn
);
352 static __inline
unsigned long long
353 sh_media_MSAD_UBQ (unsigned long long mm
, unsigned long long mn
,
354 unsigned long long mw
)
356 typedef unsigned int uv8qi
__attribute__ ((mode(V8QI
)));
358 return __builtin_sh_media_MSAD_UBQ ((uv8qi
) mm
, (uv8qi
) mn
, mw
);
361 static __inline
unsigned long long
362 sh_media_MSHALDS_L (unsigned long long mm
, unsigned int mn
)
364 typedef float v2si
__attribute__ ((mode(V2SI
)));
366 return (unsigned long long) __builtin_sh_media_MSHALDS_L ((v2si
) mm
, mn
);
369 static __inline
unsigned long long
370 sh_media_MSHALDS_W (unsigned long long mm
, unsigned int mn
)
372 typedef float v4hi
__attribute__ ((mode(V4HI
)));
374 return (unsigned long long) __builtin_sh_media_MSHALDS_W ((v4hi
) mm
, mn
);
377 static __inline
unsigned long long
378 sh_media_MSHARD_L (unsigned long long mm
, unsigned int mn
)
380 typedef float v2si
__attribute__ ((mode(V2SI
)));
382 return (unsigned long long) __builtin_ashrv2si3 ((v2si
) mm
, mn
);
385 static __inline
unsigned long long
386 sh_media_MSHARD_W (unsigned long long mm
, unsigned int mn
)
388 typedef float v4hi
__attribute__ ((mode(V4HI
)));
390 return (unsigned long long) __builtin_ashrv4hi3 ((v4hi
) mm
, mn
);
393 #define sh_media_MSHARDS_Q __builtin_sh_media_MSHARDS_Q
395 static __inline
unsigned long long
396 sh_media_MSHFHI_B (unsigned long long mm
, unsigned long long mn
)
398 typedef float v8qi
__attribute__ ((mode(V8QI
)));
400 return (unsigned long long) __builtin_sh_media_MSHFHI_B ((v8qi
) mm
,
404 static __inline
unsigned long long
405 sh_media_MSHFHI_L (unsigned long long mm
, unsigned long long mn
)
407 typedef float v2si
__attribute__ ((mode(V2SI
)));
409 return (unsigned long long) __builtin_sh_media_MSHFHI_L ((v2si
) mm
,
413 static __inline
unsigned long long
414 sh_media_MSHFHI_W (unsigned long long mm
, unsigned long long mn
)
416 typedef float v4hi
__attribute__ ((mode(V4HI
)));
418 return (unsigned long long) __builtin_sh_media_MSHFHI_W ((v4hi
) mm
,
422 static __inline
unsigned long long
423 sh_media_MSHFLO_B (unsigned long long mm
, unsigned long long mn
)
425 typedef float v8qi
__attribute__ ((mode(V8QI
)));
427 return (unsigned long long) __builtin_sh_media_MSHFLO_B ((v8qi
) mm
,
431 static __inline
unsigned long long
432 sh_media_MSHFLO_L (unsigned long long mm
, unsigned long long mn
)
434 typedef float v2si
__attribute__ ((mode(V2SI
)));
436 return (unsigned long long) __builtin_sh_media_MSHFLO_L ((v2si
) mm
,
440 static __inline
unsigned long long
441 sh_media_MSHFLO_W (unsigned long long mm
, unsigned long long mn
)
443 typedef float v4hi
__attribute__ ((mode(V4HI
)));
445 return (unsigned long long) __builtin_sh_media_MSHFLO_W ((v4hi
) mm
,
449 static __inline
unsigned long long
450 sh_media_MSHLLD_L (unsigned long long mm
, unsigned int mn
)
452 typedef float v2si
__attribute__ ((mode(V2SI
)));
454 return (unsigned long long) __builtin_ashlv2si3 ((v2si
) mm
, mn
);
457 static __inline
unsigned long long
458 sh_media_MSHLLD_W (unsigned long long mm
, unsigned int mn
)
460 typedef float v4hi
__attribute__ ((mode(V4HI
)));
462 return (unsigned long long) __builtin_ashlv4hi3 ((v4hi
) mm
, mn
);
465 static __inline
unsigned long long
466 sh_media_MSHLRD_L (unsigned long long mm
, unsigned int mn
)
468 typedef float v2si
__attribute__ ((mode(V2SI
)));
470 return (unsigned long long) __builtin_lshrv2si3 ((v2si
) mm
, mn
);
473 static __inline
unsigned long long
474 sh_media_MSHLRD_W (unsigned long long mm
, unsigned int mn
)
476 typedef float v4hi
__attribute__ ((mode(V4HI
)));
478 return (unsigned long long) __builtin_lshrv4hi3 ((v4hi
) mm
, mn
);
481 static __inline
unsigned long long
482 sh_media_MSUB_L (unsigned long long mm
, unsigned long long mn
)
484 typedef float v2si
__attribute__ ((mode(V2SI
)));
486 return (unsigned long long) __builtin_subv2si3 ((v2si
) mm
, (v2si
) mn
);
489 static __inline
unsigned long long
490 sh_media_MSUB_W (unsigned long long mm
, unsigned long long mn
)
492 typedef float v4hi
__attribute__ ((mode(V4HI
)));
494 return (unsigned long long) __builtin_subv4hi3 ((v4hi
) mm
, (v4hi
) mn
);
497 static __inline
unsigned long long
498 sh_media_MSUBS_L (unsigned long long mm
, unsigned long long mn
)
500 typedef float v2si
__attribute__ ((mode(V2SI
)));
502 return (unsigned long long) __builtin_sssubv2si3 ((v2si
) mm
, (v2si
) mn
);
505 static __inline
unsigned long long
506 sh_media_MSUBS_UB (unsigned long long mm
, unsigned long long mn
)
508 typedef float v8qi
__attribute__ ((mode(V8QI
)));
510 return (unsigned long long) __builtin_ussubv8qi3 ((v8qi
) mm
, (v8qi
) mn
);
513 static __inline
unsigned long long
514 sh_media_MSUBS_W (unsigned long long mm
, unsigned long long mn
)
516 typedef float v4hi
__attribute__ ((mode(V4HI
)));
518 return (unsigned long long) __builtin_sssubv4hi3 ((v4hi
) mm
, (v4hi
) mn
);
522 /* Floating-point Intrinsics */
524 #define sh_media_FABS_D __builtin_fabs
525 #define sh_media_FABS_S __builtin_fabsf
526 #define sh_media_FCMPUN_D __builtin_isunordered
527 #define sh_media_FCMPUN_S __builtin_isunordered
529 static __inline
float sh_media_FCOSA_S (float fg
)
531 union { int i
; float f
; } u
;
534 return __builtin_sh_media_FCOSA_S (u
.i
);
537 static __inline
float
538 sh_media_FGETSCR (void)
542 __asm
volatile ("fgetscr %0" : "=f" (f
));
546 static __inline
float
547 sh_media_FIPR_S (const void *fvg
, const void *fvh
)
549 typedef float v4sf
__attribute__ ((mode(V4SF
)));
550 v4sf vg
= *(v4sf
*) fvg
;
551 v4sf vh
= *(v4sf
*) fvh
;
553 return __builtin_sh_media_FIPR_S (vg
, vh
);
557 /* This gives different results for -O0 */
558 static __inline
float
559 sh_media_FMAC_S (float fg
, float fh
, float fq
)
565 #define sh_media_FMAC_S __builtin_sh_media_FMAC_S
568 static __inline
long long
569 sh_media_FMOV_DQ (double dg
)
571 union { long long l
; double d
; } u
;
577 static __inline
float
578 sh_media_FMOV_LS (int mm
)
580 union { int i
; float f
; } u
;
586 static __inline
double
587 sh_media_FMOV_QD (long long mm
)
589 union { long long l
; double d
; } u
;
596 sh_media_FMOV_SL (float fg
)
598 union { int i
; float f
; } u
;
605 sh_media_FPUTSCR (float fg
)
607 __asm
volatile ("fputscr %0" : : "f" (fg
));
610 static __inline
float sh_media_FSINA_S (float fg
)
612 union { int i
; float f
; } u
;
615 return __builtin_sh_media_FSINA_S (u
.i
);
618 /* Can't use __builtin_sqrt / __builtin_sqrtf because they still implement
619 error handling unless -ffast-math is used. */
620 #define sh_media_FSQRT_D __builtin_sh_media_FSQRT_D
621 #define sh_media_FSQRT_S __builtin_sh_media_FSQRT_S
622 #define sh_media_FSRRA_S __builtin_sh_media_FSRRA_S
625 sh_media_FTRV_S (const void *mtrxg
, const void *fvh
, void *fvf
)
627 typedef float v16sf
__attribute__ ((mode(V16SF
)));
628 typedef float v4sf
__attribute__ ((mode(V4SF
)));
629 v16sf mtrx
= *(v16sf
*) mtrxg
;
630 v4sf vh
= *(v4sf
*) fvh
;
632 *(v4sf
*) fvf
= __builtin_sh_media_FTRV_S (mtrx
, vh
);
634 #endif /* ! __SH4_NOFPU__ */
636 /* Not implemented here: Control and Configuration intrinsics. */
637 /* Misaligned Access Support intrinsics */
639 static __inline
unsigned long long
640 sh_media_LDHI_L (void *p
, int s
)
642 return __builtin_sh_media_LDHI_L ((char *)p
+ s
);
645 static __inline
unsigned long long
646 sh_media_LDHI_Q (void *p
, int s
)
648 return __builtin_sh_media_LDHI_Q ((char *)p
+ s
);
651 static __inline
unsigned long long
652 sh_media_LDLO_L (void *p
, int s
)
654 return __builtin_sh_media_LDLO_L ((char *)p
+ s
);
657 static __inline
unsigned long long
658 sh_media_LDLO_Q (void *p
, int s
)
660 return __builtin_sh_media_LDLO_Q ((char *)p
+ s
);
664 sh_media_STHI_L (void *p
, int s
, unsigned int mw
)
666 __builtin_sh_media_STHI_L ((char*)p
+ s
, mw
);
670 sh_media_STHI_Q (void *p
, int s
, unsigned long long mw
)
672 __builtin_sh_media_STHI_Q ((char*)p
+ s
, mw
);
676 sh_media_STLO_L (void *p
, int s
, unsigned int mw
)
678 __builtin_sh_media_STLO_L ((char*)p
+ s
, mw
);
682 sh_media_STLO_Q (void *p
, int s
, unsigned long long mw
)
684 __builtin_sh_media_STLO_Q ((char*)p
+ s
, mw
);
687 /* Miscellaneous intrinsics */
689 #define sh_media_NSB __builtin_sh_media_NSB
691 static __inline
unsigned long long
692 sh_media_BYTEREV (unsigned long long mm
)
694 typedef float v8qi
__attribute__ ((mode(V8QI
)));
696 return (unsigned long long) __builtin_sh_media_BYTEREV ((v8qi
) mm
);
699 __inline__
static unsigned long long
700 sh_media_CMVEQ (unsigned long long mm
, unsigned long long mn
, unsigned long long mw
) __attribute__ ((always_inline
));
702 __inline__
static unsigned long long
703 sh_media_CMVEQ (unsigned long long mm
, unsigned long long mn
, unsigned long long mw
)
705 return mm
== 0 ? mn
: mw
;
708 __inline__
static unsigned long long
709 sh_media_CMVNE (unsigned long long mm
, unsigned long long mn
, unsigned long long mw
) __attribute__ ((always_inline
));
711 __inline__
static unsigned long long
712 sh_media_CMVNE (unsigned long long mm
, unsigned long long mn
, unsigned long long mw
)
714 return mm
!= 0 ? mn
: mw
;
717 static __inline
long long
718 sh_media_ADDZ_L (unsigned int mm
, unsigned int mn
)
723 /* NOP and Synchronization intrinsics not implemented here. */
725 static __inline__
void sh_media_PREFO(void *mm
, int s
)
727 __builtin_sh_media_PREFO (mm
+ s
, 0, 0);
730 /* Event Handling intrinsics not implemented here. */
743 sh_media_SWAP_Q (void *mm
, long long mn
, unsigned long long mw
)
745 unsigned long long res
;
746 unsigned long long *addr
= (unsigned long long *)((char *)mm
+ mn
);
747 __asm__ ("swap.q %m1, %0" : "=r" (res
), "+o" (*addr
) : "0" (mw
));
753 sh_media_SYNCI (void)
755 __asm__
__volatile__ ("synci");
760 sh_media_SYNCO (void)
762 __asm__
__volatile__ ("synco");
767 sh_media_ALLOCO (void *mm
, int s
)
769 __builtin_sh_media_ALLOCO (mm
+ s
);
774 sh_media_ICBI (void *mm
, int s
)
776 __asm__
__volatile__ ("icbi %m0" : : "o" (((char*)mm
)[s
]));
781 sh_media_OCBI (void *mm
, int s
)
783 __asm__
__volatile__ ("ocbi %m0" : : "o" (((char*)mm
)[s
]));
788 sh_media_OCBP (void *mm
, int s
)
790 __asm__
__volatile__ ("ocbp %m0" : : "o" (((char*)mm
)[s
]));
795 sh_media_OCBWB (void *mm
, int s
)
797 __asm__
__volatile__ ("ocbwb %m0" : : "o" (((char*)mm
)[s
]));
802 sh_media_PREFI (void *mm
, int s
)
804 __asm__
__volatile__ ("prefi %m0" : : "o" (((char*)mm
)[s
]));
811 __asm__
__volatile__ ("brk");
816 sh_media_TRAPA (unsigned long long mm
)
818 __asm__
__volatile__ ("trapa %%0" : : "r" (mm
));
823 sh_media_unaligned_LD_W (void *p
)
825 #if __LITTLE_ENDIAN__
826 return (((unsigned char *)p
)[0]
827 | (((short)((__signed__
char *)p
)[1]) << 8));
829 return ((((short)((__signed__
char *)p
)[0]) << 8)
830 | ((unsigned char *)p
)[1]);
836 sh_media_unaligned_LD_UW (void *p
)
838 unsigned char *addr
= p
;
839 #if __LITTLE_ENDIAN__
840 return sh_media_MSHFLO_B (addr
[0], addr
[1]);
842 return sh_media_MSHFLO_B (addr
[1], addr
[0]);
846 /* We don't use the sh_media_LD* functions here because that turned out
847 to impede constant propagation of the offsets into the ldhi / ldlo
851 sh_media_unaligned_LD_L (void *p
)
853 #if __LITTLE_ENDIAN__
854 return (__builtin_sh_media_LDHI_L ((char *)p
+ 3)
855 | __builtin_sh_media_LDLO_L (p
));
857 return (__builtin_sh_media_LDLO_L ((char *)p
+ 3)
858 | __builtin_sh_media_LDHI_L (p
));
864 sh_media_unaligned_LD_Q (void *p
)
866 #if __LITTLE_ENDIAN__
867 return (__builtin_sh_media_LDHI_Q ((char *)p
+ 7)
868 | __builtin_sh_media_LDLO_Q (p
));
870 return (__builtin_sh_media_LDLO_Q ((char *)p
+ 7)
871 | __builtin_sh_media_LDHI_Q (p
));
877 sh_media_unaligned_ST_W (void *p
, unsigned int k
)
880 #if __LITTLE_ENDIAN__
889 /* We don't use the sh_media_ST* functions here because that turned out
890 to impede constant propagation of the offsets into the ldhi / ldlo
894 sh_media_unaligned_ST_L (void *p
, unsigned int k
)
896 #if __LITTLE_ENDIAN__
897 __builtin_sh_media_STHI_L (p
+ 3, k
);
898 __builtin_sh_media_STLO_L (p
, k
);
900 __builtin_sh_media_STLO_L (p
+ 3, k
);
901 __builtin_sh_media_STHI_L (p
, k
);
907 sh_media_unaligned_ST_Q (void *p
, unsigned long long k
)
909 #if __LITTLE_ENDIAN__
910 __builtin_sh_media_STHI_Q (p
+ 7, k
);
911 __builtin_sh_media_STLO_Q (p
, k
);
913 __builtin_sh_media_STLO_Q (p
+ 7, k
);
914 __builtin_sh_media_STHI_Q (p
, k
);
921 sh_media_FVCOPY_S (const void *fvg
, void *fvf
)
923 const __GCC_FV
*g
= fvg
;
930 sh_media_FVADD_S (const void *fvg
, const void *fvh
, void *fvf
)
932 const float *g
= fvg
, *h
= fvh
;
937 for (i
= 0; i
< 4; i
++)
949 sh_media_FVSUB_S (const void *fvg
, const void *fvh
, void *fvf
)
951 const float *g
= fvg
, *h
= fvh
;
956 for (i
= 0; i
< 4; i
++)
968 sh_media_FMTRXCOPY_S (const void *mtrxg
, void *mtrxf
)
970 const __GCC_MTRX
*g
= mtrxg
;
971 __GCC_MTRX
*f
= mtrxf
;
977 sh_media_FMTRXADD_S (const void *mtrxg
, const void *mtrxh
, void *mtrxf
)
979 const __GCC_FV
*g
= mtrxg
, *h
= mtrxh
;
984 for (i
= 0; i
< 4; i
++)
985 sh_media_FVADD_S (&g
[i
], &h
[i
], &f
[i
]);
987 sh_media_FVADD_S (&g
[0], &h
[0], &f
[0]);
988 sh_media_FVADD_S (&g
[1], &h
[1], &f
[1]);
989 sh_media_FVADD_S (&g
[2], &h
[2], &f
[2]);
990 sh_media_FVADD_S (&g
[3], &h
[3], &f
[3]);
996 sh_media_FMTRXSUB_S (const void *mtrxg
, const void *mtrxh
, void *mtrxf
)
998 const __GCC_FV
*g
= mtrxg
, *h
= mtrxh
;
1003 for (i
= 0; i
< 4; i
++)
1004 sh_media_FVSUB_S (&g
[i
], &h
[i
], &f
[i
]);
1006 sh_media_FVSUB_S (&g
[0], &h
[0], &f
[0]);
1007 sh_media_FVSUB_S (&g
[1], &h
[1], &f
[1]);
1008 sh_media_FVSUB_S (&g
[2], &h
[2], &f
[2]);
1009 sh_media_FVSUB_S (&g
[3], &h
[3], &f
[3]);
1015 sh_media_FTRVADD_S (const void *mtrxg
, const void *fvh
, const void *fvi
, void *fvf
)
1017 sh_media_FTRV_S (mtrxg
, fvh
, fvf
);
1018 sh_media_FVADD_S (fvf
, fvi
, fvf
);
1023 sh_media_FTRVSUB_S (const void *mtrxg
, const void *fvh
, const void *fvi
, void *fvf
)
1025 sh_media_FTRV_S (mtrxg
, fvh
, fvf
);
1026 sh_media_FVSUB_S (fvf
, fvi
, fvf
);
1031 sh_media_FMTRXMUL_S (const void *mtrxg
, const void *mtrxh
, void *mtrxf
)
1033 const __GCC_FV
*g
= mtrxg
;
1034 __GCC_FV
*f
= mtrxf
;
1038 for (j
= 0; j
< 4; j
++)
1039 sh_media_FTRV_S (mtrxh
, &g
[j
], &f
[j
]);
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]);
1050 sh_media_FMTRXMULADD_S (const void *mtrxg
, const void *mtrxh
, const void *mtrxi
, void *mtrxf
)
1052 const __GCC_FV
*g
= mtrxg
, *i
= mtrxi
;
1053 __GCC_FV
*f
= mtrxf
;
1057 for (j
= 0; j
< 4; j
++)
1058 sh_media_FTRVADD_S (mtrxh
, &g
[j
], &i
[j
], &f
[j
]);
1060 sh_media_FTRVADD_S (mtrxh
, &g
[0], &i
[0], &f
[0]);
1061 sh_media_FTRVADD_S (mtrxh
, &g
[1], &i
[1], &f
[1]);
1062 sh_media_FTRVADD_S (mtrxh
, &g
[2], &i
[2], &f
[2]);
1063 sh_media_FTRVADD_S (mtrxh
, &g
[3], &i
[3], &f
[3]);
1069 sh_media_FMTRXMULSUB_S (const void *mtrxg
, const void *mtrxh
, const void *mtrxi
, void *mtrxf
)
1071 const __GCC_FV
*g
= mtrxg
, *i
= mtrxi
;
1072 __GCC_FV
*f
= mtrxf
;
1076 for (j
= 0; j
< 4; j
++)
1077 sh_media_FTRVSUB_S (mtrxh
, &g
[j
], &i
[j
], &f
[j
]);
1079 sh_media_FTRVSUB_S (mtrxh
, &g
[0], &i
[0], &f
[0]);
1080 sh_media_FTRVSUB_S (mtrxh
, &g
[1], &i
[1], &f
[1]);
1081 sh_media_FTRVSUB_S (mtrxh
, &g
[2], &i
[2], &f
[2]);
1082 sh_media_FTRVSUB_S (mtrxh
, &g
[3], &i
[3], &f
[3]);
1085 #endif /* ! __SH4_NOFPU__ */
1087 #endif /* __SHMEDIA__ */
1089 #endif /* _USHMEDIA_H */