OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [sh/] [ushmedia.h] - Blame information for rev 298

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Copyright (C) 2000, 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
2
 
3
This file is part of GCC.
4
 
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.
9
 
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.
14
 
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.
18
 
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/>.  */
23
 
24
 
25
/* ushmedia.h: Intrinsics corresponding to SHmedia instructions that
26
   may be executed in both user and privileged mode.  */
27
 
28
#ifndef _USHMEDIA_H
29
#define _USHMEDIA_H
30
 
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
36
 
37
static __inline unsigned long long
38
sh_media_MABS_L (unsigned long long mm)
39
{
40
  typedef float v2si __attribute__ ((mode(V2SI)));
41
 
42
  return (unsigned long long) __builtin_absv2si2 ((v2si) mm);
43
}
44
 
45
static __inline unsigned long long
46
sh_media_MABS_W (unsigned long long mm)
47
{
48
  typedef float v4hi __attribute__ ((mode(V4HI)));
49
 
50
  return (unsigned long long) __builtin_absv4hi2 ((v4hi) mm);
51
}
52
 
53
static __inline unsigned long long
54
sh_media_MADD_L (unsigned long long mm, unsigned long long mn)
55
{
56
  typedef float v2si __attribute__ ((mode(V2SI)));
57
 
58
  return (unsigned long long) __builtin_addv2si3 ((v2si) mm, (v2si) mn);
59
}
60
 
61
static __inline unsigned long long
62
sh_media_MADD_W (unsigned long long mm, unsigned long long mn)
63
{
64
  typedef float v4hi __attribute__ ((mode(V4HI)));
65
 
66
  return (unsigned long long) __builtin_addv4hi3 ((v4hi) mm, (v4hi) mn);
67
}
68
 
69
static __inline unsigned long long
70
sh_media_MADDS_L (unsigned long long mm, unsigned long long mn)
71
{
72
  typedef float v2si __attribute__ ((mode(V2SI)));
73
 
74
  return (unsigned long long) __builtin_ssaddv2si3 ((v2si) mm, (v2si) mn);
75
}
76
 
77
static __inline unsigned long long
78
sh_media_MADDS_UB (unsigned long long mm, unsigned long long mn)
79
{
80
  typedef float v8qi __attribute__ ((mode(V8QI)));
81
 
82
  return (unsigned long long) __builtin_usaddv8qi3 ((v8qi) mm, (v8qi) mn);
83
}
84
 
85
static __inline unsigned long long
86
sh_media_MADDS_W (unsigned long long mm, unsigned long long mn)
87
{
88
  typedef float v4hi __attribute__ ((mode(V4HI)));
89
 
90
  return (unsigned long long) __builtin_ssaddv4hi3 ((v4hi) mm, (v4hi) mn);
91
}
92
 
93
static __inline unsigned long long
94
sh_media_MCMPEQ_B (unsigned long long mm, unsigned long long mn)
95
{
96
  typedef float v8qi __attribute__ ((mode(V8QI)));
97
 
98
  return (unsigned long long) __builtin_sh_media_MCMPEQ_B ((v8qi) mm,
99
                                                           (v8qi) mn);
100
}
101
 
102
static __inline unsigned long long
103
sh_media_MCMPEQ_L (unsigned long long mm, unsigned long long mn)
104
{
105
  typedef float v2si __attribute__ ((mode(V2SI)));
106
 
107
  return (unsigned long long) __builtin_sh_media_MCMPEQ_L ((v2si) mm,
108
                                                           (v2si) mn);
109
}
110
 
111
static __inline unsigned long long
112
sh_media_MCMPEQ_W (unsigned long long mm, unsigned long long mn)
113
{
114
  typedef float v4hi __attribute__ ((mode(V4HI)));
115
 
116
  return (unsigned long long) __builtin_sh_media_MCMPEQ_W ((v4hi) mm,
117
                                                           (v4hi) mn);
118
}
119
 
120
static __inline unsigned long long
121
sh_media_MCMPGT_UB (unsigned long long mm, unsigned long long mn)
122
{
123
  typedef float v8qi __attribute__ ((mode(V8QI)));
124
 
125
  return (unsigned long long) __builtin_sh_media_MCMPGT_UB ((v8qi) mm,
126
                                                           (v8qi) mn);
127
}
128
 
129
static __inline unsigned long long
130
sh_media_MCMPGT_L (unsigned long long mm, unsigned long long mn)
131
{
132
  typedef float v2si __attribute__ ((mode(V2SI)));
133
 
134
  return (unsigned long long) __builtin_sh_media_MCMPGT_L ((v2si) mm,
135
                                                           (v2si) mn);
136
}
137
 
138
static __inline unsigned long long
139
sh_media_MCMPGT_W (unsigned long long mm, unsigned long long mn)
140
{
141
  typedef float v4hi __attribute__ ((mode(V4HI)));
142
 
143
  return (unsigned long long) __builtin_sh_media_MCMPGT_W ((v4hi) mm,
144
                                                           (v4hi) mn);
145
}
146
 
147
#define sh_media_MCMV __builtin_sh_media_MCMV
148
 
149
static __inline unsigned long long
150
sh_media_MCNVS_LW (unsigned long long mm, unsigned long long mn)
151
{
152
  typedef float v2si __attribute__ ((mode(V2SI)));
153
  typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
154
 
155
  return (unsigned long long) __builtin_sh_media_MCNVS_LW ((v2si) mm,
156
                                                           (uv2si) mn);
157
}
158
 
159
static __inline unsigned long long
160
sh_media_MCNVS_WB (unsigned long long mm, unsigned long long mn)
161
{
162
  typedef float v4hi __attribute__ ((mode(V4HI)));
163
 
164
  return (unsigned long long) __builtin_sh_media_MCNVS_WB ((v4hi) mm,
165
                                                           (v4hi) mn);
166
}
167
 
168
static __inline unsigned long long
169
sh_media_MCNVS_WUB (unsigned long long mm, unsigned long long mn)
170
{
171
  typedef float v4hi __attribute__ ((mode(V4HI)));
172
 
173
  return (unsigned long long) __builtin_sh_media_MCNVS_WUB ((v4hi) mm,
174
                                                            (v4hi) mn);
175
}
176
 
177
static __inline unsigned long long
178
sh_media_MEXTR1 (unsigned long long mm, unsigned long long mn)
179
{
180
  typedef float v8qi __attribute__ ((mode(V8QI)));
181
 
182
  return (unsigned long long) __builtin_sh_media_MEXTR1 ((v8qi) mm,
183
                                                         (v8qi) mn);
184
}
185
 
186
static __inline unsigned long long
187
sh_media_MEXTR2 (unsigned long long mm, unsigned long long mn)
188
{
189
  typedef float v8qi __attribute__ ((mode(V8QI)));
190
 
191
  return (unsigned long long) __builtin_sh_media_MEXTR2 ((v8qi) mm,
192
                                                         (v8qi) mn);
193
}
194
 
195
static __inline unsigned long long
196
sh_media_MEXTR3 (unsigned long long mm, unsigned long long mn)
197
{
198
  typedef float v8qi __attribute__ ((mode(V8QI)));
199
 
200
  return (unsigned long long) __builtin_sh_media_MEXTR3 ((v8qi) mm,
201
                                                         (v8qi) mn);
202
}
203
 
204
static __inline unsigned long long
205
sh_media_MEXTR4 (unsigned long long mm, unsigned long long mn)
206
{
207
  typedef float v8qi __attribute__ ((mode(V8QI)));
208
 
209
  return (unsigned long long) __builtin_sh_media_MEXTR4 ((v8qi) mm,
210
                                                         (v8qi) mn);
211
}
212
 
213
static __inline unsigned long long
214
sh_media_MEXTR5 (unsigned long long mm, unsigned long long mn)
215
{
216
  typedef float v8qi __attribute__ ((mode(V8QI)));
217
 
218
  return (unsigned long long) __builtin_sh_media_MEXTR5 ((v8qi) mm,
219
                                                         (v8qi) mn);
220
}
221
 
222
static __inline unsigned long long
223
sh_media_MEXTR6 (unsigned long long mm, unsigned long long mn)
224
{
225
  typedef float v8qi __attribute__ ((mode(V8QI)));
226
 
227
  return (unsigned long long) __builtin_sh_media_MEXTR6 ((v8qi) mm,
228
                                                         (v8qi) mn);
229
}
230
 
231
static __inline unsigned long long
232
sh_media_MEXTR7 (unsigned long long mm, unsigned long long mn)
233
{
234
  typedef float v8qi __attribute__ ((mode(V8QI)));
235
 
236
  return (unsigned long long) __builtin_sh_media_MEXTR7 ((v8qi) mm,
237
                                                         (v8qi) mn);
238
}
239
 
240
static __inline unsigned long long
241
sh_media_MMACFX_WL (unsigned long long mm, unsigned long long mn,
242
                    unsigned long long mw)
243
{
244
  typedef float v2hi __attribute__ ((mode(V2HI)));
245
  typedef float v2si __attribute__ ((mode(V2SI)));
246
  typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
247
 
248
  long mm_l = (long) mm;
249
  long mn_l = (long) mn;
250
 
251
  return ((unsigned long long)
252
    __builtin_sh_media_MMACFX_WL ((v2hi) mm_l, (v2hi) mn_l,
253
                                  (uv2si) mw));
254
}
255
 
256
static __inline unsigned long long
257
sh_media_MMACNFX_WL (unsigned long long mm, unsigned long long mn,
258
                     unsigned long long mw)
259
{
260
  typedef float v2hi __attribute__ ((mode(V2HI)));
261
  typedef float v2si __attribute__ ((mode(V2SI)));
262
  typedef unsigned int uv2si __attribute__ ((mode(V2SI)));
263
 
264
  long mm_l = (long) mm;
265
  long mn_l = (long) mn;
266
 
267
  return ((unsigned long long)
268
    __builtin_sh_media_MMACNFX_WL ((v2hi) mm_l, (v2hi) mn_l,
269
                                   (uv2si) mw));
270
}
271
 
272
static __inline unsigned long long
273
sh_media_MMUL_L (unsigned long long mm, unsigned long long mn)
274
{
275
  typedef float v2si __attribute__ ((mode(V2SI)));
276
 
277
  return (unsigned long long) __builtin_mulv2si3 ((v2si) mm, (v2si) mn);
278
}
279
 
280
static __inline unsigned long long
281
sh_media_MMUL_W (unsigned long long mm, unsigned long long mn)
282
{
283
  typedef float v4hi __attribute__ ((mode(V4HI)));
284
 
285
  return (unsigned long long) __builtin_mulv4hi3 ((v4hi) mm, (v4hi) mn);
286
}
287
 
288
static __inline unsigned long long
289
sh_media_MMULFX_L (unsigned long long mm, unsigned long long mn)
290
{
291
  typedef float v2si __attribute__ ((mode(V2SI)));
292
 
293
  return (unsigned long long) __builtin_sh_media_MMULFX_L ((v2si) mm,
294
                                                           (v2si) mn);
295
}
296
 
297
static __inline unsigned long long
298
sh_media_MMULFX_W (unsigned long long mm, unsigned long long mn)
299
{
300
  typedef float v4hi __attribute__ ((mode(V4HI)));
301
 
302
  return (unsigned long long) __builtin_sh_media_MMULFX_W ((v4hi) mm,
303
                                                           (v4hi) mn);
304
}
305
 
306
static __inline unsigned long long
307
sh_media_MMULFXRP_W (unsigned long long mm, unsigned long long mn)
308
{
309
  typedef float v4hi __attribute__ ((mode(V4HI)));
310
 
311
  return (unsigned long long) __builtin_sh_media_MMULFXRP_W ((v4hi) mm,
312
                                                             (v4hi) mn);
313
}
314
 
315
static __inline unsigned long long
316
sh_media_MMULHI_WL (unsigned long long mm, unsigned long long mn)
317
{
318
  typedef float v4hi __attribute__ ((mode(V4HI)));
319
 
320
  return (unsigned long long) __builtin_sh_media_MMULHI_WL ((v4hi) mm,
321
                                                            (v4hi) mn);
322
}
323
 
324
static __inline unsigned long long
325
sh_media_MMULLO_WL (unsigned long long mm, unsigned long long mn)
326
{
327
  typedef float v4hi __attribute__ ((mode(V4HI)));
328
 
329
  return (unsigned long long) __builtin_sh_media_MMULLO_WL ((v4hi) mm,
330
                                                            (v4hi) mn);
331
}
332
 
333
static __inline unsigned long long
334
sh_media_MMULSUM_WQ (unsigned long long mm, unsigned long long mn,
335
                     unsigned long long mw)
336
{
337
  typedef unsigned int uv4hi __attribute__ ((mode(V4HI)));
338
 
339
  return __builtin_sh_media_MMULSUM_WQ ((uv4hi) mm, (uv4hi) mn, mw);
340
}
341
 
342
static __inline unsigned long long
343
sh_media_MPERM_W (unsigned long long mm, unsigned int mn)
344
{
345
  typedef float v4hi __attribute__ ((mode(V4HI)));
346
 
347
  return (unsigned long long) __builtin_sh_media_MPERM_W ((v4hi) mm, mn);
348
}
349
 
350
static __inline unsigned long long
351
sh_media_MSAD_UBQ (unsigned long long mm, unsigned long long mn,
352
                   unsigned long long mw)
353
{
354
  typedef unsigned int uv8qi __attribute__ ((mode(V8QI)));
355
 
356
  return __builtin_sh_media_MSAD_UBQ ((uv8qi) mm, (uv8qi) mn, mw);
357
}
358
 
359
static __inline unsigned long long
360
sh_media_MSHALDS_L (unsigned long long mm, unsigned int mn)
361
{
362
  typedef float v2si __attribute__ ((mode(V2SI)));
363
 
364
  return (unsigned long long) __builtin_sh_media_MSHALDS_L ((v2si) mm, mn);
365
}
366
 
367
static __inline unsigned long long
368
sh_media_MSHALDS_W (unsigned long long mm, unsigned int mn)
369
{
370
  typedef float v4hi __attribute__ ((mode(V4HI)));
371
 
372
  return (unsigned long long) __builtin_sh_media_MSHALDS_W ((v4hi) mm, mn);
373
}
374
 
375
static __inline unsigned long long
376
sh_media_MSHARD_L (unsigned long long mm, unsigned int mn)
377
{
378
  typedef float v2si __attribute__ ((mode(V2SI)));
379
 
380
  return (unsigned long long) __builtin_ashrv2si3 ((v2si) mm, mn);
381
}
382
 
383
static __inline unsigned long long
384
sh_media_MSHARD_W (unsigned long long mm, unsigned int mn)
385
{
386
  typedef float v4hi __attribute__ ((mode(V4HI)));
387
 
388
  return (unsigned long long) __builtin_ashrv4hi3 ((v4hi) mm, mn);
389
}
390
 
391
#define sh_media_MSHARDS_Q __builtin_sh_media_MSHARDS_Q
392
 
393
static __inline unsigned long long
394
sh_media_MSHFHI_B (unsigned long long mm, unsigned long long mn)
395
{
396
  typedef float v8qi __attribute__ ((mode(V8QI)));
397
 
398
  return (unsigned long long) __builtin_sh_media_MSHFHI_B ((v8qi) mm,
399
                                                           (v8qi) mn);
400
}
401
 
402
static __inline unsigned long long
403
sh_media_MSHFHI_L (unsigned long long mm, unsigned long long mn)
404
{
405
  typedef float v2si __attribute__ ((mode(V2SI)));
406
 
407
  return (unsigned long long) __builtin_sh_media_MSHFHI_L ((v2si) mm,
408
                                                           (v2si) mn);
409
}
410
 
411
static __inline unsigned long long
412
sh_media_MSHFHI_W (unsigned long long mm, unsigned long long mn)
413
{
414
  typedef float v4hi __attribute__ ((mode(V4HI)));
415
 
416
  return (unsigned long long) __builtin_sh_media_MSHFHI_W ((v4hi) mm,
417
                                                           (v4hi) mn);
418
}
419
 
420
static __inline unsigned long long
421
sh_media_MSHFLO_B (unsigned long long mm, unsigned long long mn)
422
{
423
  typedef float v8qi __attribute__ ((mode(V8QI)));
424
 
425
  return (unsigned long long) __builtin_sh_media_MSHFLO_B ((v8qi) mm,
426
                                                           (v8qi) mn);
427
}
428
 
429
static __inline unsigned long long
430
sh_media_MSHFLO_L (unsigned long long mm, unsigned long long mn)
431
{
432
  typedef float v2si __attribute__ ((mode(V2SI)));
433
 
434
  return (unsigned long long) __builtin_sh_media_MSHFLO_L ((v2si) mm,
435
                                                           (v2si) mn);
436
}
437
 
438
static __inline unsigned long long
439
sh_media_MSHFLO_W (unsigned long long mm, unsigned long long mn)
440
{
441
  typedef float v4hi __attribute__ ((mode(V4HI)));
442
 
443
  return (unsigned long long) __builtin_sh_media_MSHFLO_W ((v4hi) mm,
444
                                                           (v4hi) mn);
445
}
446
 
447
static __inline unsigned long long
448
sh_media_MSHLLD_L (unsigned long long mm, unsigned int mn)
449
{
450
  typedef float v2si __attribute__ ((mode(V2SI)));
451
 
452
  return (unsigned long long) __builtin_ashlv2si3 ((v2si) mm, mn);
453
}
454
 
455
static __inline unsigned long long
456
sh_media_MSHLLD_W (unsigned long long mm, unsigned int mn)
457
{
458
  typedef float v4hi __attribute__ ((mode(V4HI)));
459
 
460
  return (unsigned long long) __builtin_ashlv4hi3 ((v4hi) mm, mn);
461
}
462
 
463
static __inline unsigned long long
464
sh_media_MSHLRD_L (unsigned long long mm, unsigned int mn)
465
{
466
  typedef float v2si __attribute__ ((mode(V2SI)));
467
 
468
  return (unsigned long long) __builtin_lshrv2si3 ((v2si) mm, mn);
469
}
470
 
471
static __inline unsigned long long
472
sh_media_MSHLRD_W (unsigned long long mm, unsigned int mn)
473
{
474
  typedef float v4hi __attribute__ ((mode(V4HI)));
475
 
476
  return (unsigned long long) __builtin_lshrv4hi3 ((v4hi) mm, mn);
477
}
478
 
479
static __inline unsigned long long
480
sh_media_MSUB_L (unsigned long long mm, unsigned long long mn)
481
{
482
  typedef float v2si __attribute__ ((mode(V2SI)));
483
 
484
  return (unsigned long long) __builtin_subv2si3 ((v2si) mm, (v2si) mn);
485
}
486
 
487
static __inline unsigned long long
488
sh_media_MSUB_W (unsigned long long mm, unsigned long long mn)
489
{
490
  typedef float v4hi __attribute__ ((mode(V4HI)));
491
 
492
  return (unsigned long long) __builtin_subv4hi3 ((v4hi) mm, (v4hi) mn);
493
}
494
 
495
static __inline unsigned long long
496
sh_media_MSUBS_L (unsigned long long mm, unsigned long long mn)
497
{
498
  typedef float v2si __attribute__ ((mode(V2SI)));
499
 
500
  return (unsigned long long) __builtin_sssubv2si3 ((v2si) mm, (v2si) mn);
501
}
502
 
503
static __inline unsigned long long
504
sh_media_MSUBS_UB (unsigned long long mm, unsigned long long mn)
505
{
506
  typedef float v8qi __attribute__ ((mode(V8QI)));
507
 
508
  return (unsigned long long) __builtin_ussubv8qi3 ((v8qi) mm, (v8qi) mn);
509
}
510
 
511
static __inline unsigned long long
512
sh_media_MSUBS_W (unsigned long long mm, unsigned long long mn)
513
{
514
  typedef float v4hi __attribute__ ((mode(V4HI)));
515
 
516
  return (unsigned long long) __builtin_sssubv4hi3 ((v4hi) mm, (v4hi) mn);
517
}
518
 
519
#if ! __SH4_NOFPU__
520
/* Floating-point Intrinsics */
521
 
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
526
 
527
static __inline float sh_media_FCOSA_S (float fg)
528
{
529
  union { int i; float f; } u;
530
 
531
  u.f = fg;
532
  return __builtin_sh_media_FCOSA_S (u.i);
533
}
534
 
535
static __inline float
536
sh_media_FGETSCR (void)
537
{
538
  float f;
539
 
540
  __asm volatile ("fgetscr %0" : "=f" (f));
541
  return f;
542
}
543
 
544
static __inline float
545
sh_media_FIPR_S (const void *fvg, const void *fvh)
546
{
547
  typedef float v4sf __attribute__ ((mode(V4SF)));
548
  v4sf vg = *(v4sf*) fvg;
549
  v4sf vh = *(v4sf*) fvh;
550
 
551
  return __builtin_sh_media_FIPR_S (vg, vh);
552
}
553
 
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)
558
{
559
  return fg * fh + fq;
560
}
561
#else
562
 
563
#define sh_media_FMAC_S __builtin_sh_media_FMAC_S
564
#endif
565
 
566
static __inline long long
567
sh_media_FMOV_DQ (double dg)
568
{
569
  union { long long l; double d; } u;
570
 
571
  u.d = dg;
572
  return u.l;
573
}
574
 
575
static __inline float
576
sh_media_FMOV_LS (int mm)
577
{
578
  union { int i; float f; } u;
579
 
580
  u.i = mm;
581
  return u.f;
582
}
583
 
584
static __inline double
585
sh_media_FMOV_QD (long long mm)
586
{
587
  union { long long l; double d; } u;
588
 
589
  u.l = mm;
590
  return u.d;
591
}
592
 
593
static __inline int
594
sh_media_FMOV_SL (float fg)
595
{
596
  union { int i; float f; } u;
597
 
598
  u.f = fg;
599
  return u.i;
600
}
601
 
602
static __inline void
603
sh_media_FPUTSCR (float fg)
604
{
605
  __asm volatile ("fputscr %0" : : "f" (fg));
606
}
607
 
608
static __inline float sh_media_FSINA_S (float fg)
609
{
610
  union { int i; float f; } u;
611
 
612
  u.f = fg;
613
  return __builtin_sh_media_FSINA_S (u.i);
614
}
615
 
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
621
 
622
static __inline void
623
sh_media_FTRV_S (const void *mtrxg, const void *fvh, void *fvf)
624
{
625
  typedef float v16sf __attribute__ ((mode(V16SF)));
626
  typedef float v4sf __attribute__ ((mode(V4SF)));
627
  v16sf mtrx = *(v16sf*) mtrxg;
628
  v4sf vh = *(v4sf*) fvh;
629
 
630
  *(v4sf*) fvf = __builtin_sh_media_FTRV_S (mtrx, vh);
631
}
632
#endif /* ! __SH4_NOFPU__ */
633
 
634
/* Not implemented here: Control and Configuration intrinsics.  */
635
/* Misaligned Access Support intrinsics */
636
 
637
static __inline unsigned long long
638
sh_media_LDHI_L (void *p, int s)
639
{
640
  return __builtin_sh_media_LDHI_L ((char *)p + s);
641
}
642
 
643
static __inline unsigned long long
644
sh_media_LDHI_Q (void *p, int s)
645
{
646
  return __builtin_sh_media_LDHI_Q ((char *)p + s);
647
}
648
 
649
static __inline unsigned long long
650
sh_media_LDLO_L (void *p, int s)
651
{
652
  return __builtin_sh_media_LDLO_L ((char *)p + s);
653
}
654
 
655
static __inline unsigned long long
656
sh_media_LDLO_Q (void *p, int s)
657
{
658
  return __builtin_sh_media_LDLO_Q ((char *)p + s);
659
}
660
 
661
static __inline void
662
sh_media_STHI_L (void *p, int s, unsigned int mw)
663
{
664
  __builtin_sh_media_STHI_L ((char*)p + s, mw);
665
}
666
 
667
static __inline void
668
sh_media_STHI_Q (void *p, int s, unsigned long long mw)
669
{
670
  __builtin_sh_media_STHI_Q ((char*)p + s, mw);
671
}
672
 
673
static __inline void
674
sh_media_STLO_L (void *p, int s, unsigned int mw)
675
{
676
  __builtin_sh_media_STLO_L ((char*)p + s, mw);
677
}
678
 
679
static __inline void
680
sh_media_STLO_Q (void *p, int s, unsigned long long mw)
681
{
682
  __builtin_sh_media_STLO_Q ((char*)p + s, mw);
683
}
684
 
685
/* Miscellaneous intrinsics */
686
 
687
#define sh_media_NSB __builtin_sh_media_NSB
688
 
689
static __inline unsigned long long
690
sh_media_BYTEREV (unsigned long long mm)
691
{
692
  typedef float v8qi __attribute__ ((mode(V8QI)));
693
 
694
  return (unsigned long long) __builtin_sh_media_BYTEREV ((v8qi) mm);
695
}
696
 
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));
699
 
700
__inline__ static unsigned long long
701
sh_media_CMVEQ (unsigned long long mm, unsigned long long mn, unsigned long long mw)
702
{
703
  return mm == 0 ? mn : mw;
704
}
705
 
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));
708
 
709
__inline__ static unsigned long long
710
sh_media_CMVNE (unsigned long long mm, unsigned long long mn, unsigned long long mw)
711
{
712
  return mm != 0 ? mn : mw;
713
}
714
 
715
static __inline long long
716
sh_media_ADDZ_L (unsigned int mm, unsigned int mn)
717
{
718
  return mm + mn;
719
}
720
 
721
/* NOP and Synchronization intrinsics not implemented here.  */
722
 
723
static __inline__ void sh_media_PREFO(void *mm, int s)
724
{
725
  __builtin_sh_media_PREFO (mm + s, 0, 0);
726
}
727
 
728
/* Event Handling intrinsics not implemented here.  */
729
 
730
/* Old asm stuff */
731
 
732
static __inline__
733
void
734
sh_media_NOP (void)
735
{
736
  __asm__ ("nop" : :);
737
}
738
 
739
__inline__ static
740
unsigned long long
741
sh_media_SWAP_Q (void *mm, long long mn, unsigned long long mw)
742
{
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;
747
}
748
 
749
__inline__ static
750
void
751
sh_media_SYNCI (void)
752
{
753
  __asm__ __volatile__ ("synci");
754
}
755
 
756
__inline__ static
757
void
758
sh_media_SYNCO (void)
759
{
760
  __asm__ __volatile__ ("synco");
761
}
762
 
763
__inline__ static
764
void
765
sh_media_ALLOCO (void *mm, int s)
766
{
767
  __builtin_sh_media_ALLOCO (mm + s);
768
}
769
 
770
__inline__ static
771
void
772
sh_media_ICBI (void *mm, int s)
773
{
774
  __asm__ __volatile__ ("icbi   %m0" : : "o" (((char*)mm)[s]));
775
}
776
 
777
__inline__ static
778
void
779
sh_media_OCBI (void *mm, int s)
780
{
781
  __asm__ __volatile__ ("ocbi   %m0" : : "o" (((char*)mm)[s]));
782
}
783
 
784
__inline__ static
785
void
786
sh_media_OCBP (void *mm, int s)
787
{
788
  __asm__ __volatile__ ("ocbp   %m0" : : "o" (((char*)mm)[s]));
789
}
790
 
791
__inline__ static
792
void
793
sh_media_OCBWB (void *mm, int s)
794
{
795
  __asm__ __volatile__ ("ocbwb  %m0" : : "o" (((char*)mm)[s]));
796
}
797
 
798
__inline__ static
799
void
800
sh_media_PREFI (void *mm, int s)
801
{
802
  __asm__ __volatile__ ("prefi  %m0" : : "o" (((char*)mm)[s]));
803
}
804
 
805
__inline__ static
806
void
807
sh_media_BRK (void)
808
{
809
  __asm__ __volatile__ ("brk");
810
}
811
 
812
__inline__ static
813
void
814
sh_media_TRAPA (unsigned long long mm)
815
{
816
  __asm__ __volatile__ ("trapa  %%0" : : "r" (mm));
817
}
818
 
819
__inline__ static
820
short
821
sh_media_unaligned_LD_W (void *p)
822
{
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
830
}
831
 
832
__inline__ static
833
unsigned short
834
sh_media_unaligned_LD_UW (void *p)
835
{
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
842
}
843
 
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)
850
{
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
858
}
859
 
860
__inline__ static
861
long long
862
sh_media_unaligned_LD_Q (void *p)
863
{
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
871
}
872
 
873
__inline__ static
874
void
875
sh_media_unaligned_ST_W (void *p, unsigned int k)
876
{
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
885
}
886
 
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)
893
{
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
901
}
902
 
903
__inline__ static
904
void
905
sh_media_unaligned_ST_Q (void *p, unsigned long long k)
906
{
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
914
}
915
 
916
#if ! __SH4_NOFPU__
917
__inline__ static
918
void
919
sh_media_FVCOPY_S (const void *fvg, void *fvf)
920
{
921
  const __GCC_FV *g = fvg;
922
  __GCC_FV *f = fvf;
923
  *f = *g;
924
}
925
 
926
__inline__ static
927
void
928
sh_media_FVADD_S (const void *fvg, const void *fvh, void *fvf)
929
{
930
  const float *g = fvg, *h = fvh;
931
  float *f = fvf;
932
#if 1
933
  int i;
934
 
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
943
}
944
 
945
__inline__ static
946
void
947
sh_media_FVSUB_S (const void *fvg, const void *fvh, void *fvf)
948
{
949
  const float *g = fvg, *h = fvh;
950
  float *f = fvf;
951
#if 1
952
  int i;
953
 
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
962
}
963
 
964
__inline__ static
965
void
966
sh_media_FMTRXCOPY_S (const void *mtrxg, void *mtrxf)
967
{
968
  const __GCC_MTRX *g = mtrxg;
969
  __GCC_MTRX *f = mtrxf;
970
  *f = *g;
971
}
972
 
973
__inline__ static
974
void
975
sh_media_FMTRXADD_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
976
{
977
  const __GCC_FV *g = mtrxg, *h = mtrxh;
978
  __GCC_FV *f = mtrxf;
979
#if 1
980
  int i;
981
 
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
990
}
991
 
992
__inline__ static
993
void
994
sh_media_FMTRXSUB_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
995
{
996
  const __GCC_FV *g = mtrxg, *h = mtrxh;
997
  __GCC_FV *f = mtrxf;
998
#if 1
999
  int i;
1000
 
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
1009
}
1010
 
1011
__inline__ static
1012
void
1013
sh_media_FTRVADD_S (const void *mtrxg, const void *fvh, const void *fvi, void *fvf)
1014
{
1015
  sh_media_FTRV_S (mtrxg, fvh, fvf);
1016
  sh_media_FVADD_S (fvf, fvi, fvf);
1017
}
1018
 
1019
__inline__ static
1020
void
1021
sh_media_FTRVSUB_S (const void *mtrxg, const void *fvh, const void *fvi, void *fvf)
1022
{
1023
  sh_media_FTRV_S (mtrxg, fvh, fvf);
1024
  sh_media_FVSUB_S (fvf, fvi, fvf);
1025
}
1026
 
1027
__inline__ static
1028
void
1029
sh_media_FMTRXMUL_S (const void *mtrxg, const void *mtrxh, void *mtrxf)
1030
{
1031
  const __GCC_FV *g = mtrxg;
1032
  __GCC_FV *f = mtrxf;
1033
#if 1
1034
  int j;
1035
 
1036
  for (j = 0; j < 4; j++)
1037
    sh_media_FTRV_S (mtrxh, &g[j], &f[j]);
1038
#else
1039
  sh_media_FTRV_S (mtrxh, &g[0], &f[0]);
1040
  sh_media_FTRV_S (mtrxh, &g[1], &f[1]);
1041
  sh_media_FTRV_S (mtrxh, &g[2], &f[2]);
1042
  sh_media_FTRV_S (mtrxh, &g[3], &f[3]);
1043
#endif
1044
}
1045
 
1046
__inline__ static
1047
void
1048
sh_media_FMTRXMULADD_S (const void *mtrxg, const void *mtrxh, const void *mtrxi, void *mtrxf)
1049
{
1050
  const __GCC_FV *g = mtrxg, *i = mtrxi;
1051
  __GCC_FV *f = mtrxf;
1052
#if 1
1053
  int j;
1054
 
1055
  for (j = 0; j < 4; j++)
1056
    sh_media_FTRVADD_S (mtrxh, &g[j], &i[j], &f[j]);
1057
#else
1058
  sh_media_FTRVADD_S (mtrxh, &g[0], &i[0], &f[0]);
1059
  sh_media_FTRVADD_S (mtrxh, &g[1], &i[1], &f[1]);
1060
  sh_media_FTRVADD_S (mtrxh, &g[2], &i[2], &f[2]);
1061
  sh_media_FTRVADD_S (mtrxh, &g[3], &i[3], &f[3]);
1062
#endif
1063
}
1064
 
1065
__inline__ static
1066
void
1067
sh_media_FMTRXMULSUB_S (const void *mtrxg, const void *mtrxh, const void *mtrxi, void *mtrxf)
1068
{
1069
  const __GCC_FV *g = mtrxg, *i = mtrxi;
1070
  __GCC_FV *f = mtrxf;
1071
#if 1
1072
  int j;
1073
 
1074
  for (j = 0; j < 4; j++)
1075
    sh_media_FTRVSUB_S (mtrxh, &g[j], &i[j], &f[j]);
1076
#else
1077
  sh_media_FTRVSUB_S (mtrxh, &g[0], &i[0], &f[0]);
1078
  sh_media_FTRVSUB_S (mtrxh, &g[1], &i[1], &f[1]);
1079
  sh_media_FTRVSUB_S (mtrxh, &g[2], &i[2], &f[2]);
1080
  sh_media_FTRVSUB_S (mtrxh, &g[3], &i[3], &f[3]);
1081
#endif
1082
}
1083
#endif /* ! __SH4_NOFPU__ */
1084
 
1085
#endif /* __SHMEDIA__ */
1086
 
1087
#endif /* _USHMEDIA_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.