1 /* Copyright (C) 2000-2013 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)
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. */
33 typedef float __GCC_FV
__attribute__ ((vector_size (4 * sizeof (float))));
34 typedef float __GCC_MTRX
__attribute__ ((vector_size (16 * sizeof (float))));
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
);
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
;
532 return __builtin_sh_media_FCOSA_S (u
.i
);
535 static __inline
float
536 sh_media_FGETSCR (void)
540 __asm
volatile ("fgetscr %0" : "=f" (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
);
555 /* This gives different results for -O0 */
556 static __inline
float
557 sh_media_FMAC_S (float fg
, float fh
, float fq
)
563 #define sh_media_FMAC_S __builtin_sh_media_FMAC_S
566 static __inline
long long
567 sh_media_FMOV_DQ (double dg
)
569 union { long long l
; double d
; } u
;
575 static __inline
float
576 sh_media_FMOV_LS (int mm
)
578 union { int i
; float f
; } u
;
584 static __inline
double
585 sh_media_FMOV_QD (long long mm
)
587 union { long long l
; double d
; } u
;
594 sh_media_FMOV_SL (float fg
)
596 union { int i
; float f
; } u
;
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
;
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
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
);
662 sh_media_STHI_L (void *p
, int s
, unsigned int mw
)
664 __builtin_sh_media_STHI_L ((char*)p
+ s
, mw
);
668 sh_media_STHI_Q (void *p
, int s
, unsigned long long mw
)
670 __builtin_sh_media_STHI_Q ((char*)p
+ s
, mw
);
674 sh_media_STLO_L (void *p
, int s
, unsigned int mw
)
676 __builtin_sh_media_STLO_L ((char*)p
+ s
, mw
);
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
)
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. */
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
));
751 sh_media_SYNCI (void)
753 __asm__
__volatile__ ("synci");
758 sh_media_SYNCO (void)
760 __asm__
__volatile__ ("synco");
765 sh_media_ALLOCO (void *mm
, int s
)
767 __builtin_sh_media_ALLOCO (mm
+ s
);
772 sh_media_ICBI (void *mm
, int s
)
774 __asm__
__volatile__ ("icbi %m0" : : "o" (((char*)mm
)[s
]));
779 sh_media_OCBI (void *mm
, int s
)
781 __asm__
__volatile__ ("ocbi %m0" : : "o" (((char*)mm
)[s
]));
786 sh_media_OCBP (void *mm
, int s
)
788 __asm__
__volatile__ ("ocbp %m0" : : "o" (((char*)mm
)[s
]));
793 sh_media_OCBWB (void *mm
, int s
)
795 __asm__
__volatile__ ("ocbwb %m0" : : "o" (((char*)mm
)[s
]));
800 sh_media_PREFI (void *mm
, int s
)
802 __asm__
__volatile__ ("prefi %m0" : : "o" (((char*)mm
)[s
]));
809 __asm__
__volatile__ ("brk");
814 sh_media_TRAPA (unsigned long long mm
)
816 __asm__
__volatile__ ("trapa %%0" : : "r" (mm
));
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));
827 return ((((short)((__signed__
char *)p
)[0]) << 8)
828 | ((unsigned char *)p
)[1]);
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]);
840 return sh_media_MSHFLO_B (addr
[1], addr
[0]);
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
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
));
855 return (__builtin_sh_media_LDLO_L ((char *)p
+ 3)
856 | __builtin_sh_media_LDHI_L (p
));
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
));
868 return (__builtin_sh_media_LDLO_Q ((char *)p
+ 7)
869 | __builtin_sh_media_LDHI_Q (p
));
875 sh_media_unaligned_ST_W (void *p
, unsigned int k
)
878 #if __LITTLE_ENDIAN__
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
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
);
898 __builtin_sh_media_STLO_L (p
+ 3, k
);
899 __builtin_sh_media_STHI_L (p
, k
);
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
);
911 __builtin_sh_media_STLO_Q (p
+ 7, k
);
912 __builtin_sh_media_STHI_Q (p
, k
);
919 sh_media_FVCOPY_S (const void *fvg
, void *fvf
)
921 const __GCC_FV
*g
= fvg
;
928 sh_media_FVADD_S (const void *fvg
, const void *fvh
, void *fvf
)
930 const float *g
= fvg
, *h
= fvh
;
935 for (i
= 0; i
< 4; i
++)
947 sh_media_FVSUB_S (const void *fvg
, const void *fvh
, void *fvf
)
949 const float *g
= fvg
, *h
= fvh
;
954 for (i
= 0; i
< 4; i
++)
966 sh_media_FMTRXCOPY_S (const void *mtrxg
, void *mtrxf
)
968 const __GCC_MTRX
*g
= mtrxg
;
969 __GCC_MTRX
*f
= mtrxf
;
975 sh_media_FMTRXADD_S (const void *mtrxg
, const void *mtrxh
, void *mtrxf
)
977 const __GCC_FV
*g
= mtrxg
, *h
= mtrxh
;
982 for (i
= 0; i
< 4; i
++)
983 sh_media_FVADD_S (&g
[i
], &h
[i
], &f
[i
]);
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]);
994 sh_media_FMTRXSUB_S (const void *mtrxg
, const void *mtrxh
, void *mtrxf
)
996 const __GCC_FV
*g
= mtrxg
, *h
= mtrxh
;
1001 for (i
= 0; i
< 4; i
++)
1002 sh_media_FVSUB_S (&g
[i
], &h
[i
], &f
[i
]);
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]);
1013 sh_media_FTRVADD_S (const void *mtrxg
, const void *fvh
, const void *fvi
,
1016 sh_media_FTRV_S (mtrxg
, fvh
, fvf
);
1017 sh_media_FVADD_S (fvf
, fvi
, fvf
);
1022 sh_media_FTRVSUB_S (const void *mtrxg
, const void *fvh
, const void *fvi
,
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
,
1051 const void *mtrxi
, void *mtrxf
)
1053 const __GCC_FV
*g
= mtrxg
, *i
= mtrxi
;
1054 __GCC_FV
*f
= mtrxf
;
1058 for (j
= 0; j
< 4; j
++)
1059 sh_media_FTRVADD_S (mtrxh
, &g
[j
], &i
[j
], &f
[j
]);
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]);
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
;
1078 for (j
= 0; j
< 4; j
++)
1079 sh_media_FTRVSUB_S (mtrxh
, &g
[j
], &i
[j
], &f
[j
]);
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]);
1087 #endif /* ! __SH4_NOFPU__ */
1089 #endif /* __SHMEDIA__ */
1091 #endif /* _USHMEDIA_H */