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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.target/] [mips/] [mips32-dsp.c] - Blame information for rev 691

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 691 jeremybenn
/* Test MIPS32 DSP instructions */
2
/* { dg-do compile } */
3
/* { dg-options "-mgp32 -mdsp" } */
4
/* { dg-final { scan-assembler "addq.ph" } } */
5
/* { dg-final { scan-assembler "addq_s.ph" } } */
6
/* { dg-final { scan-assembler "addq_s.w" } } */
7
/* { dg-final { scan-assembler "addu.qb" } } */
8
/* { dg-final { scan-assembler "addu_s.qb" } } */
9
/* { dg-final { scan-assembler "subq.ph" } } */
10
/* { dg-final { scan-assembler "subq_s.ph" } } */
11
/* { dg-final { scan-assembler "subq_s.w" } } */
12
/* { dg-final { scan-assembler "subu.qb" } } */
13
/* { dg-final { scan-assembler "subu_s.qb" } } */
14
/* { dg-final { scan-assembler "addsc" } } */
15
/* { dg-final { scan-assembler "addwc" } } */
16
/* { dg-final { scan-assembler "modsub" } } */
17
/* { dg-final { scan-assembler "raddu.w.qb" } } */
18
/* { dg-final { scan-assembler "absq_s.ph" } } */
19
/* { dg-final { scan-assembler "absq_s.w" } } */
20
/* { dg-final { scan-assembler "precrq.qb.ph" } } */
21
/* { dg-final { scan-assembler "precrq.ph.w" } } */
22
/* { dg-final { scan-assembler "precrq_rs.ph.w" } } */
23
/* { dg-final { scan-assembler "precrqu_s.qb.ph" } } */
24
/* { dg-final { scan-assembler "preceq.w.phl" } } */
25
/* { dg-final { scan-assembler "preceq.w.phr" } } */
26
/* { dg-final { scan-assembler "precequ.ph.qbl" } } */
27
/* { dg-final { scan-assembler "precequ.ph.qbr" } } */
28
/* { dg-final { scan-assembler "precequ.ph.qbla" } } */
29
/* { dg-final { scan-assembler "precequ.ph.qbra" } } */
30
/* { dg-final { scan-assembler "preceu.ph.qbl" } } */
31
/* { dg-final { scan-assembler "preceu.ph.qbr" } } */
32
/* { dg-final { scan-assembler "preceu.ph.qbla" } } */
33
/* { dg-final { scan-assembler "preceu.ph.qbra" } } */
34
/* { dg-final { scan-assembler "shllv?.qb" } } */
35
/* { dg-final { scan-assembler "shllv?.ph" } } */
36
/* { dg-final { scan-assembler "shllv?_s.ph" } } */
37
/* { dg-final { scan-assembler "shllv?_s.w" } } */
38
/* { dg-final { scan-assembler "shrlv?.qb" } } */
39
/* { dg-final { scan-assembler "shrav?.ph" } } */
40
/* { dg-final { scan-assembler "shrav?_r.ph" } } */
41
/* { dg-final { scan-assembler "shrav?_r.w" } } */
42
/* { dg-final { scan-assembler "muleu_s.ph.qbl" } } */
43
/* { dg-final { scan-assembler "muleu_s.ph.qbr" } } */
44
/* { dg-final { scan-assembler "mulq_rs.ph" } } */
45
/* { dg-final { scan-assembler "muleq_s.w.phl" } } */
46
/* { dg-final { scan-assembler "muleq_s.w.phr" } } */
47
/* { dg-final { scan-assembler "dpau.h.qbl" } } */
48
/* { dg-final { scan-assembler "dpau.h.qbr" } } */
49
/* { dg-final { scan-assembler "dpsu.h.qbl" } } */
50
/* { dg-final { scan-assembler "dpsu.h.qbr" } } */
51
/* { dg-final { scan-assembler "dpaq_s.w.ph" } } */
52
/* { dg-final { scan-assembler "dpsq_s.w.ph" } } */
53
/* { dg-final { scan-assembler "mulsaq_s.w.ph" } } */
54
/* { dg-final { scan-assembler "dpaq_sa.l.w" } } */
55
/* { dg-final { scan-assembler "dpsq_sa.l.w" } } */
56
/* { dg-final { scan-assembler "maq_s.w.phl" } } */
57
/* { dg-final { scan-assembler "maq_s.w.phr" } } */
58
/* { dg-final { scan-assembler "maq_sa.w.phl" } } */
59
/* { dg-final { scan-assembler "maq_sa.w.phr" } } */
60
/* { dg-final { scan-assembler "bitrev" } } */
61
/* { dg-final { scan-assembler "insv" } } */
62
/* { dg-final { scan-assembler "replv?.qb" } } */
63
/* { dg-final { scan-assembler "repl.ph" } } */
64
/* { dg-final { scan-assembler "replv.ph" } } */
65
/* { dg-final { scan-assembler "cmpu.eq.qb" } } */
66
/* { dg-final { scan-assembler "cmpu.lt.qb" } } */
67
/* { dg-final { scan-assembler "cmpu.le.qb" } } */
68
/* { dg-final { scan-assembler "cmpgu.eq.qb" } } */
69
/* { dg-final { scan-assembler "cmpgu.lt.qb" } } */
70
/* { dg-final { scan-assembler "cmpgu.le.qb" } } */
71
/* { dg-final { scan-assembler "cmp.eq.ph" } } */
72
/* { dg-final { scan-assembler "cmp.lt.ph" } } */
73
/* { dg-final { scan-assembler "cmp.le.ph" } } */
74
/* { dg-final { scan-assembler "pick.qb" } } */
75
/* { dg-final { scan-assembler "pick.ph" } } */
76
/* { dg-final { scan-assembler "packrl.ph" } } */
77
/* { dg-final { scan-assembler "extrv?.w" } } */
78
/* { dg-final { scan-assembler "extrv?_s.h" } } */
79
/* { dg-final { scan-assembler "extrv?_r.w" } } */
80
/* { dg-final { scan-assembler "extrv?_rs.w" } } */
81
/* { dg-final { scan-assembler "extpv?" } } */
82
/* { dg-final { scan-assembler "extpdpv?" } } */
83
/* { dg-final { scan-assembler "shilov?" } } */
84
/* { dg-final { scan-assembler "mthlip" } } */
85
/* { dg-final { scan-assembler "mfhi" } } */
86
/* { dg-final { scan-assembler "mflo" } } */
87
/* { dg-final { scan-assembler "mthi" } } */
88
/* { dg-final { scan-assembler "mtlo" } } */
89
/* { dg-final { scan-assembler "wrdsp" } } */
90
/* { dg-final { scan-assembler "rddsp" } } */
91
/* { dg-final { scan-assembler "lbux?" } } */
92
/* { dg-final { scan-assembler "lhx?" } } */
93
/* { dg-final { scan-assembler "lwx?" } } */
94
/* { dg-final { scan-assembler "bposge32" } } */
95
/* { dg-final { scan-assembler "madd" } } */
96
/* { dg-final { scan-assembler "maddu" } } */
97
/* { dg-final { scan-assembler "msub" } } */
98
/* { dg-final { scan-assembler "msubu" } } */
99
/* { dg-final { scan-assembler "mult" } } */
100
/* { dg-final { scan-assembler "multu" } } */
101
 
102
#include <stdlib.h>
103
#include <stdio.h>
104
 
105
typedef signed char v4i8 __attribute__ ((vector_size(4)));
106
typedef short v2q15 __attribute__ ((vector_size(4)));
107
 
108
typedef int q31;
109
typedef int i32;
110
typedef unsigned int ui32;
111
typedef long long a64;
112
 
113
NOMIPS16 void test_MIPS_DSP (void);
114
 
115
char array[100];
116
int little_endian;
117
 
118
int main ()
119
{
120
  int i;
121
 
122
  union { long long ll; int i[2]; } endianness_test;
123
  endianness_test.ll = 1;
124
  little_endian = endianness_test.i[0];
125
 
126
  for (i = 0; i < 100; i++)
127
    array[i] = i;
128
 
129
  test_MIPS_DSP ();
130
 
131
  exit (0);
132
}
133
 
134
NOMIPS16 v2q15 add_v2q15 (v2q15 a, v2q15 b)
135
{
136
  return __builtin_mips_addq_ph (a, b);
137
}
138
 
139
NOMIPS16 v4i8 add_v4i8 (v4i8 a, v4i8 b)
140
{
141
  return __builtin_mips_addu_qb (a, b);
142
}
143
 
144
NOMIPS16 v2q15 sub_v2q15 (v2q15 a, v2q15 b)
145
{
146
  return __builtin_mips_subq_ph (a, b);
147
}
148
 
149
NOMIPS16 v4i8 sub_v4i8 (v4i8 a, v4i8 b)
150
{
151
  return __builtin_mips_subu_qb (a, b);
152
}
153
 
154
NOMIPS16 void test_MIPS_DSP ()
155
{
156
  v4i8 v4i8_a,v4i8_b,v4i8_c,v4i8_r,v4i8_s;
157
  v2q15 v2q15_a,v2q15_b,v2q15_c,v2q15_r,v2q15_s;
158
  q31 q31_a,q31_b,q31_c,q31_r,q31_s;
159
  i32 i32_a,i32_b,i32_c,i32_r,i32_s;
160
  ui32 ui32_a,ui32_b,ui32_c;
161
  a64 a64_a,a64_b,a64_c,a64_r,a64_s;
162
 
163
  void *ptr_a;
164
  int r,s;
165
  long long lr,ls;
166
 
167
  v2q15_a = (v2q15) {0x1234, 0x5678};
168
  v2q15_b = (v2q15) {0x6f89, 0x1111};
169
  v2q15_s = (v2q15) {0x81bd, 0x6789};
170
  v2q15_r = add_v2q15 (v2q15_a, v2q15_b);
171
  r = (int) v2q15_r;
172
  s = (int) v2q15_s;
173
  if (r != s)
174
    abort ();
175
 
176
  v2q15_a = (v2q15) {0x1234, 0x5678};
177
  v2q15_b = (v2q15) {0x6f89, 0x1111};
178
  v2q15_s = (v2q15) {0x7fff, 0x6789};
179
  v2q15_r = __builtin_mips_addq_s_ph (v2q15_a, v2q15_b);
180
  r = (int) v2q15_r;
181
  s = (int) v2q15_s;
182
  if (r != s)
183
    abort ();
184
 
185
  q31_a = 0x70000000;
186
  q31_b = 0x71234567;
187
  q31_s = 0x7fffffff;
188
  q31_r = __builtin_mips_addq_s_w (q31_a, q31_b);
189
  if (q31_r != q31_s)
190
    abort ();
191
 
192
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
193
  v4i8_b = (v4i8) {0xff, 0x89, 0x11, 0x11};
194
  v4i8_s = (v4i8) {0xf1, 0xbd, 0x67, 0x89};
195
  v4i8_r = add_v4i8 (v4i8_a, v4i8_b);
196
  r = (int) v4i8_r;
197
  s = (int) v4i8_s;
198
  if (r != s)
199
    abort ();
200
 
201
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
202
  v4i8_b = (v4i8) {0xff, 0x89, 0x11, 0x11};
203
  v4i8_s = (v4i8) {0xff, 0xbd, 0x67, 0x89};
204
  v4i8_r = __builtin_mips_addu_s_qb (v4i8_a, v4i8_b);
205
  r = (int) v4i8_r;
206
  s = (int) v4i8_s;
207
  if (r != s)
208
    abort ();
209
 
210
  v2q15_a = (v2q15) {0x1234, 0x5678};
211
  v2q15_b = (v2q15) {0x6f89, 0x1111};
212
  v2q15_s = (v2q15) {0xa2ab, 0x4567};
213
  v2q15_r = sub_v2q15 (v2q15_a, v2q15_b);
214
  r = (int) v2q15_r;
215
  s = (int) v2q15_s;
216
  if (r != s)
217
    abort ();
218
 
219
  v2q15_a = (v2q15) {0x8000, 0x5678};
220
  v2q15_b = (v2q15) {0x6f89, 0x1111};
221
  v2q15_s = (v2q15) {0x8000, 0x4567};
222
  v2q15_r = __builtin_mips_subq_s_ph (v2q15_a, v2q15_b);
223
  r = (int) v2q15_r;
224
  s = (int) v2q15_s;
225
  if (r != s)
226
    abort ();
227
 
228
  q31_a = 0x70000000;
229
  q31_b = 0x71234567;
230
  q31_s = 0xfedcba99;
231
  q31_r = __builtin_mips_subq_s_w (q31_a, q31_b);
232
  if (q31_r != q31_s)
233
    abort ();
234
 
235
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
236
  v4i8_b = (v4i8) {0xff, 0x89, 0x11, 0x11};
237
  v4i8_s = (v4i8) {0xf3, 0xab, 0x45, 0x67};
238
  v4i8_r = sub_v4i8 (v4i8_a, v4i8_b);
239
  r = (int) v4i8_r;
240
  s = (int) v4i8_s;
241
  if (r != s)
242
    abort ();
243
 
244
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
245
  v4i8_b = (v4i8) {0xff, 0x89, 0x11, 0x11};
246
  v4i8_s = (v4i8) {0x0, 0x0, 0x45, 0x67};
247
  v4i8_r = __builtin_mips_subu_s_qb (v4i8_a, v4i8_b);
248
  r = (int) v4i8_r;
249
  s = (int) v4i8_s;
250
  if (r != s)
251
    abort ();
252
 
253
  i32_a = 0xf5678900;
254
  i32_b = 0x7abcdef0;
255
  i32_s = 0x702467f0;
256
  i32_r = __builtin_mips_addsc (i32_a, i32_b);
257
  if (i32_r != i32_s)
258
    abort ();
259
 
260
  i32_a = 0x75678900;
261
  i32_b = 0x7abcdef0;
262
  i32_s = 0xf02467f1;
263
  i32_r = __builtin_mips_addwc (i32_a, i32_b);
264
  if (i32_r != i32_s)
265
    abort ();
266
 
267
  i32_a = 0;
268
  i32_b = 0x00000901;
269
  i32_s = 9;
270
  i32_r = __builtin_mips_modsub (i32_a, i32_b);
271
  if (i32_r != i32_s)
272
    abort ();
273
 
274
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
275
  i32_s = 0x1f4;
276
  i32_r = __builtin_mips_raddu_w_qb (v4i8_a);
277
  if (i32_r != i32_s)
278
    abort ();
279
 
280
  v2q15_a = (v2q15) {0x8000, 0x8134};
281
  v2q15_s = (v2q15) {0x7fff, 0x7ecc};
282
  v2q15_r = __builtin_mips_absq_s_ph (v2q15_a);
283
  r = (int) v2q15_r;
284
  s = (int) v2q15_s;
285
  if (r != s)
286
    abort ();
287
 
288
  q31_a = (q31) 0x80000000;
289
  q31_s = (q31) 0x7fffffff;
290
  q31_r = __builtin_mips_absq_s_w (q31_a);
291
  if (q31_r != q31_s)
292
    abort ();
293
 
294
  v2q15_a = (v2q15) {0x9999, 0x5612};
295
  v2q15_b = (v2q15) {0x5612, 0x3333};
296
  if (little_endian)
297
    v4i8_s = (v4i8) {0x56, 0x33, 0x99, 0x56};
298
  else
299
    v4i8_s = (v4i8) {0x99, 0x56, 0x56, 0x33};
300
  v4i8_r = __builtin_mips_precrq_qb_ph (v2q15_a, v2q15_b);
301
  r = (int) v4i8_r;
302
  s = (int) v4i8_s;
303
  if (r != s)
304
    abort ();
305
 
306
  q31_a = 0x12348678;
307
  q31_b = 0x44445555;
308
  if (little_endian)
309
    v2q15_s = (v2q15) {0x4444, 0x1234};
310
  else
311
    v2q15_s = (v2q15) {0x1234, 0x4444};
312
  v2q15_r = __builtin_mips_precrq_ph_w (q31_a, q31_b);
313
  r = (int) v2q15_r;
314
  s = (int) v2q15_s;
315
  if (r != s)
316
    abort ();
317
 
318
  q31_a = 0x12348678;
319
  q31_b = 0x44445555;
320
  if (little_endian)
321
    v2q15_s = (v2q15) {0x4444, 0x1235};
322
  else
323
    v2q15_s = (v2q15) {0x1235, 0x4444};
324
  v2q15_r = __builtin_mips_precrq_rs_ph_w (q31_a, q31_b);
325
  r = (int) v2q15_r;
326
  s = (int) v2q15_s;
327
  if (r != s)
328
    abort ();
329
 
330
  v2q15_a = (v2q15) {0x9999, 0x5612};
331
  v2q15_b = (v2q15) {0x5612, 0x3333};
332
  if (little_endian)
333
    v4i8_s = (v4i8) {0xac, 0x66, 0x00, 0xac};
334
  else
335
    v4i8_s = (v4i8) {0x00, 0xac, 0xac, 0x66};
336
  v4i8_r = __builtin_mips_precrqu_s_qb_ph (v2q15_a, v2q15_b);
337
  r = (int) v4i8_r;
338
  s = (int) v4i8_s;
339
  if (r != s)
340
    abort ();
341
 
342
  v2q15_a = (v2q15) {0x3589, 0x4444};
343
  if (little_endian)
344
    q31_s = 0x44440000;
345
  else
346
    q31_s = 0x35890000;
347
  q31_r = __builtin_mips_preceq_w_phl (v2q15_a);
348
  if (q31_r != q31_s)
349
    abort ();
350
 
351
  v2q15_a = (v2q15) {0x3589, 0x4444};
352
  if (little_endian)
353
    q31_s = 0x35890000;
354
  else
355
    q31_s = 0x44440000;
356
  q31_r = __builtin_mips_preceq_w_phr (v2q15_a);
357
  if (q31_r != q31_s)
358
    abort ();
359
 
360
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
361
  if (little_endian)
362
    v2q15_s = (v2q15) {0x2b00, 0x1980};
363
  else
364
    v2q15_s = (v2q15) {0x0900, 0x2b00};
365
  v2q15_r = __builtin_mips_precequ_ph_qbl (v4i8_a);
366
  r = (int) v2q15_r;
367
  s = (int) v2q15_s;
368
  if (r != s)
369
    abort ();
370
 
371
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
372
  if (little_endian)
373
    v2q15_s = (v2q15) {0x0900, 0x2b00};
374
  else
375
    v2q15_s = (v2q15) {0x2b00, 0x1980};
376
  v2q15_r = __builtin_mips_precequ_ph_qbr (v4i8_a);
377
  r = (int) v2q15_r;
378
  s = (int) v2q15_s;
379
  if (r != s)
380
    abort ();
381
 
382
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
383
  if (little_endian)
384
    v2q15_s = (v2q15) {0x2b00, 0x1980};
385
  else
386
    v2q15_s = (v2q15) {0x0900, 0x2b00};
387
  v2q15_r = __builtin_mips_precequ_ph_qbla (v4i8_a);
388
  r = (int) v2q15_r;
389
  s = (int) v2q15_s;
390
  if (r != s)
391
    abort ();
392
 
393
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
394
  if (little_endian)
395
    v2q15_s = (v2q15) {0x0900, 0x2b00};
396
  else
397
    v2q15_s = (v2q15) {0x2b00, 0x1980};
398
  v2q15_r = __builtin_mips_precequ_ph_qbra (v4i8_a);
399
  r = (int) v2q15_r;
400
  s = (int) v2q15_s;
401
  if (r != s)
402
    abort ();
403
 
404
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
405
  if (little_endian)
406
    v2q15_s = (v2q15) {0x56, 0x33};
407
  else
408
    v2q15_s = (v2q15) {0x12, 0x56};
409
  v2q15_r = __builtin_mips_preceu_ph_qbl (v4i8_a);
410
  r = (int) v2q15_r;
411
  s = (int) v2q15_s;
412
  if (r != s)
413
    abort ();
414
 
415
  v4i8_a = (v4i8) {0x12, 0x56, 0x56, 0x33};
416
  if (little_endian)
417
    v2q15_s = (v2q15) {0x12, 0x56};
418
  else
419
    v2q15_s = (v2q15) {0x56, 0x33};
420
  v2q15_r = __builtin_mips_preceu_ph_qbr (v4i8_a);
421
  r = (int) v2q15_r;
422
  s = (int) v2q15_s;
423
  if (r != s)
424
    abort ();
425
 
426
  v4i8_a = (v4i8) {0x12, 0x99, 0x56, 0x33};
427
  if (little_endian)
428
    v2q15_s = (v2q15) {0x99, 0x33};
429
  else
430
    v2q15_s = (v2q15) {0x12, 0x56};
431
  v2q15_r = __builtin_mips_preceu_ph_qbla (v4i8_a);
432
  r = (int) v2q15_r;
433
  s = (int) v2q15_s;
434
  if (r != s)
435
    abort ();
436
 
437
  v4i8_a = (v4i8) {0x12, 0x99, 0x56, 0x33};
438
  if (little_endian)
439
    v2q15_s = (v2q15) {0x12, 0x56};
440
  else
441
    v2q15_s = (v2q15) {0x99, 0x33};
442
  v2q15_r = __builtin_mips_preceu_ph_qbra (v4i8_a);
443
  r = (int) v2q15_r;
444
  s = (int) v2q15_s;
445
  if (r != s)
446
    abort ();
447
 
448
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
449
  v4i8_s = (v4i8) {0xc8, 0xd0, 0x58, 0xe0};
450
  v4i8_r = __builtin_mips_shll_qb (v4i8_a, 2);
451
  r = (int) v4i8_r;
452
  s = (int) v4i8_s;
453
  if (r != s)
454
    abort ();
455
 
456
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
457
  i32_b = 1;
458
  v4i8_s = (v4i8) {0xe4, 0x68, 0xac, 0xf0};
459
  v4i8_r = __builtin_mips_shll_qb (v4i8_a, i32_b);
460
  r = (int) v4i8_r;
461
  s = (int) v4i8_s;
462
  if (r != s)
463
    abort ();
464
 
465
  v2q15_a = (v2q15) {0x1234, 0x5678};
466
  v2q15_s = (v2q15) {0x48d0, 0x59e0};
467
  v2q15_r = __builtin_mips_shll_ph (v2q15_a, 2);
468
  r = (int) v2q15_r;
469
  s = (int) v2q15_s;
470
  if (r != s)
471
    abort ();
472
 
473
  v2q15_a = (v2q15) {0x1234, 0x5678};
474
  i32_b = 1;
475
  v2q15_s = (v2q15) {0x2468, 0xacf0};
476
  v2q15_r = __builtin_mips_shll_ph (v2q15_a, i32_b);
477
  r = (int) v2q15_r;
478
  s = (int) v2q15_s;
479
  if (r != s)
480
    abort ();
481
 
482
  v2q15_a = (v2q15) {0x1234, 0x5678};
483
  v2q15_s = (v2q15) {0x48d0, 0x7fff};
484
  v2q15_r = __builtin_mips_shll_s_ph (v2q15_a, 2);
485
  r = (int) v2q15_r;
486
  s = (int) v2q15_s;
487
  if (r != s)
488
    abort ();
489
 
490
  v2q15_a = (v2q15) {0x1234, 0x5678};
491
  i32_b = 1;
492
  v2q15_s = (v2q15) {0x2468, 0x7fff};
493
  v2q15_r = __builtin_mips_shll_s_ph (v2q15_a, i32_b);
494
  r = (int) v2q15_r;
495
  s = (int) v2q15_s;
496
  if (r != s)
497
    abort ();
498
 
499
  q31_a = 0x70000000;
500
  q31_s = 0x7fffffff;
501
  q31_r = __builtin_mips_shll_s_w (q31_a, 2);
502
  if (q31_r != q31_s)
503
    abort ();
504
 
505
  q31_a = 0x70000000;
506
  i32_b = 1;
507
  q31_s = 0x7fffffff;
508
  q31_r = __builtin_mips_shll_s_w (q31_a, i32_b);
509
  if (q31_r != q31_s)
510
    abort ();
511
 
512
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
513
  v4i8_s = (v4i8) {0x3c, 0xd, 0x15, 0x1e};
514
  v4i8_r = __builtin_mips_shrl_qb (v4i8_a, 2);
515
  r = (int) v4i8_r;
516
  s = (int) v4i8_s;
517
  if (r != s)
518
    abort ();
519
 
520
  v4i8_a = (v4i8) {0xf2, 0x34, 0x56, 0x78};
521
  i32_b = 1;
522
  v4i8_s = (v4i8) {0x79, 0x1a, 0x2b, 0x3c};
523
  v4i8_r = __builtin_mips_shrl_qb (v4i8_a, i32_b);
524
  r = (int) v4i8_r;
525
  s = (int) v4i8_s;
526
  if (r != s)
527
    abort ();
528
 
529
  v2q15_a = (v2q15) {0x1234, 0x5678};
530
  v2q15_s = (v2q15) {0x48d, 0x159e};
531
  v2q15_r = __builtin_mips_shra_ph (v2q15_a, 2);
532
  r = (int) v2q15_r;
533
  s = (int) v2q15_s;
534
  if (r != s)
535
    abort ();
536
 
537
  v2q15_a = (v2q15) {0x1234, 0x5678};
538
  i32_b = 1;
539
  v2q15_s = (v2q15) {0x91a, 0x2b3c};
540
  v2q15_r = __builtin_mips_shra_ph (v2q15_a, i32_b);
541
  r = (int) v2q15_r;
542
  s = (int) v2q15_s;
543
  if (r != s)
544
    abort ();
545
 
546
  v2q15_a = (v2q15) {0x1234, 0x5678};
547
  v2q15_s = (v2q15) {0x48d, 0x159e};
548
  v2q15_r = __builtin_mips_shra_r_ph (v2q15_a, 2);
549
  r = (int) v2q15_r;
550
  s = (int) v2q15_s;
551
  if (r != s)
552
    abort ();
553
 
554
  v2q15_a = (v2q15) {0x1234, 0x5678};
555
  i32_b = 3;
556
  v2q15_s = (v2q15) {0x247, 0xacf};
557
  v2q15_r = __builtin_mips_shra_r_ph (v2q15_a, i32_b);
558
  r = (int) v2q15_r;
559
  s = (int) v2q15_s;
560
  if (r != s)
561
    abort ();
562
 
563
  q31_a = 0x70000000;
564
  q31_s = 0x1c000000;
565
  q31_r = __builtin_mips_shra_r_w (q31_a, 2);
566
  if (q31_r != q31_s)
567
    abort ();
568
 
569
  q31_a = 0x70000004;
570
  i32_b = 3;
571
  q31_s = 0x0e000001;
572
  q31_r = __builtin_mips_shra_r_w (q31_a, i32_b);
573
  if (q31_r != q31_s)
574
    abort ();
575
 
576
  v4i8_a = (v4i8) {0x1, 0x2, 0x3, 0x4};
577
  v2q15_b = (v2q15) {0x6f89, 0x1111};
578
  if (little_endian)
579
    v2q15_s = (v2q15) {0xffff, 0x4444};
580
  else
581
    v2q15_s = (v2q15) {0x6f89, 0x2222};
582
  v2q15_r = __builtin_mips_muleu_s_ph_qbl (v4i8_a, v2q15_b);
583
  r = (int) v2q15_r;
584
  s = (int) v2q15_s;
585
  if (r != s)
586
    abort ();
587
 
588
  v4i8_a = (v4i8) {0x1, 0x2, 0x3, 0x4};
589
  v2q15_b = (v2q15) {0x6f89, 0x1111};
590
  if (little_endian)
591
    v2q15_s = (v2q15) {0x6f89, 0x2222};
592
  else
593
    v2q15_s = (v2q15) {0xffff, 0x4444};
594
  v2q15_r = __builtin_mips_muleu_s_ph_qbr (v4i8_a, v2q15_b);
595
  r = (int) v2q15_r;
596
  s = (int) v2q15_s;
597
  if (r != s)
598
    abort ();
599
 
600
  v2q15_a = (v2q15) {0x1234, 0x5678};
601
  v2q15_b = (v2q15) {0x6f89, 0x1111};
602
  v2q15_s = (v2q15) {0x0fdd, 0x0b87};
603
  v2q15_r = __builtin_mips_mulq_rs_ph (v2q15_a, v2q15_b);
604
  r = (int) v2q15_r;
605
  s = (int) v2q15_s;
606
  if (r != s)
607
    abort ();
608
 
609
  v2q15_a = (v2q15) {0x8000, 0x8000};
610
  v2q15_b = (v2q15) {0x8000, 0x8000};
611
  q31_s = 0x7fffffff;
612
  q31_r = __builtin_mips_muleq_s_w_phl (v2q15_a, v2q15_b);
613
  if (q31_r != q31_s)
614
    abort ();
615
 
616
  v2q15_a = (v2q15) {0x8000, 0x8000};
617
  v2q15_b = (v2q15) {0x8000, 0x8000};
618
  q31_s = 0x7fffffff;
619
  q31_r = __builtin_mips_muleq_s_w_phr (v2q15_a, v2q15_b);
620
  if (q31_r != q31_s)
621
    abort ();
622
 
623
#ifndef __mips64
624
  a64_a = 0x22221111;
625
  v4i8_b = (v4i8) {0x12, 0x34, 0x56, 0x78};
626
  v4i8_c = (v4i8) {0xaa, 0x89, 0x11, 0x34};
627
  if (little_endian)
628
    a64_s = 0x22222f27;
629
  else
630
    a64_s = 0x222238d9;
631
  a64_r = __builtin_mips_dpau_h_qbl (a64_a, v4i8_b, v4i8_c);
632
  if (a64_r != a64_s)
633
    abort ();
634
 
635
  a64_a = 0x22221111;
636
  v4i8_b = (v4i8) {0x12, 0x34, 0x56, 0x78};
637
  v4i8_c = (v4i8) {0xaa, 0x89, 0x11, 0x34};
638
  if (little_endian)
639
    a64_s = 0x222238d9;
640
  else
641
    a64_s = 0x22222f27;
642
  a64_r = __builtin_mips_dpau_h_qbr (a64_a, v4i8_b, v4i8_c);
643
  if (a64_r != a64_s)
644
    abort ();
645
 
646
  a64_a = 0x22221111;
647
  v4i8_b = (v4i8) {0x12, 0x34, 0x56, 0x78};
648
  v4i8_c = (v4i8) {0xaa, 0x89, 0x11, 0x34};
649
  if (little_endian)
650
    a64_s = 0x2221f2fb;
651
  else
652
    a64_s = 0x2221e949;
653
  a64_r = __builtin_mips_dpsu_h_qbl (a64_a, v4i8_b, v4i8_c);
654
  if (a64_r != a64_s)
655
    abort ();
656
 
657
  a64_a = 0x22221111;
658
  v4i8_b = (v4i8) {0x12, 0x34, 0x56, 0x78};
659
  v4i8_c = (v4i8) {0xaa, 0x89, 0x11, 0x34};
660
  if (little_endian)
661
    a64_s = 0x2221e949;
662
  else
663
    a64_s = 0x2221f2fb;
664
  a64_r = __builtin_mips_dpsu_h_qbr (a64_a, v4i8_b, v4i8_c);
665
  if (a64_r != a64_s)
666
    abort ();
667
 
668
  a64_a = 0x00001111;
669
  v2q15_b = (v2q15) {0x8000, 0x5678};
670
  v2q15_c = (v2q15) {0x8000, 0x1111};
671
  a64_s = 0x8b877d00;
672
  a64_r = __builtin_mips_dpaq_s_w_ph (a64_a, v2q15_b, v2q15_c);
673
  if (a64_r != a64_s)
674
    abort ();
675
 
676
  a64_a = 0x00001111;
677
  v2q15_b = (v2q15) {0x8000, 0x5678};
678
  v2q15_c = (v2q15) {0x8000, 0x1111};
679
  a64_s = 0xffffffff7478a522LL;
680
  a64_r = __builtin_mips_dpsq_s_w_ph (a64_a, v2q15_b, v2q15_c);
681
  if (a64_r != a64_s)
682
    abort ();
683
 
684
  a64_a = 0x00001111;
685
  v2q15_b = (v2q15) {0x8000, 0x5678};
686
  v2q15_c = (v2q15) {0x8000, 0x1111};
687
  if (little_endian)
688
    a64_s = 0xffffffff8b877d02LL;
689
  else
690
    a64_s = 0x7478a520;
691
  a64_r = __builtin_mips_mulsaq_s_w_ph (a64_a, v2q15_b, v2q15_c);
692
  if (a64_r != a64_s)
693
    abort ();
694
 
695
  a64_a = 0x00001111;
696
  q31_b = 0x80000000;
697
  q31_c = 0x80000000;
698
  a64_s = 0x7fffffffffffffffLL;
699
  a64_r = __builtin_mips_dpaq_sa_l_w (a64_a, q31_b, q31_c);
700
  if (a64_r != a64_s)
701
    abort ();
702
 
703
  a64_a = 0x00001111;
704
  q31_b = 0x80000000;
705
  q31_c = 0x80000000;
706
  a64_s = 0x8000000000001112LL;
707
  a64_r = __builtin_mips_dpsq_sa_l_w (a64_a, q31_b, q31_c);
708
  if (a64_r != a64_s)
709
    abort ();
710
 
711
  a64_a = 0x00001111;
712
  v2q15_b = (v2q15) {0x8000, 0x1};
713
  v2q15_c = (v2q15) {0x8000, 0x2};
714
  if (little_endian)
715
    a64_s = 0x1115;
716
  else
717
    a64_s = 0x80001110;
718
  a64_r = __builtin_mips_maq_s_w_phl (a64_a, v2q15_b, v2q15_c);
719
  if (a64_r != a64_s)
720
    abort ();
721
 
722
  a64_a = 0x00001111;
723
  v2q15_b = (v2q15) {0x8000, 0x1};
724
  v2q15_c = (v2q15) {0x8000, 0x2};
725
  if (little_endian)
726
    a64_s = 0x80001110;
727
  else
728
    a64_s = 0x1115;
729
  a64_r = __builtin_mips_maq_s_w_phr (a64_a, v2q15_b, v2q15_c);
730
  if (a64_r != a64_s)
731
    abort ();
732
 
733
  a64_a = 0x00001111;
734
  v2q15_b = (v2q15) {0x8000, 0x1};
735
  v2q15_c = (v2q15) {0x8000, 0x2};
736
  if (little_endian)
737
    a64_s = 0x1115;
738
  else
739
    a64_s = 0x7fffffff;
740
  a64_r = __builtin_mips_maq_sa_w_phl (a64_a, v2q15_b, v2q15_c);
741
  if (a64_r != a64_s)
742
    abort ();
743
 
744
  a64_a = 0x00001111;
745
  v2q15_b = (v2q15) {0x8000, 0x1};
746
  v2q15_c = (v2q15) {0x8000, 0x2};
747
  if (little_endian)
748
    a64_s = 0x7fffffff;
749
  else
750
    a64_s = 0x1115;
751
  a64_r = __builtin_mips_maq_sa_w_phr (a64_a, v2q15_b, v2q15_c);
752
  if (a64_r != a64_s)
753
    abort ();
754
#endif
755
 
756
  i32_a = 0x12345678;
757
  i32_s = 0x00001e6a;
758
  i32_r = __builtin_mips_bitrev (i32_a);
759
  if (i32_r != i32_s)
760
    abort ();
761
 
762
  i32_a = 0x00000208; // pos is 8, size is 4
763
  __builtin_mips_wrdsp (i32_a, 31);
764
  i32_a = 0x12345678;
765
  i32_b = 0x87654321;
766
  i32_s = 0x12345178;
767
  i32_r = __builtin_mips_insv (i32_a, i32_b);
768
  if (i32_r != i32_s)
769
    abort ();
770
 
771
  v4i8_s = (v4i8) {1, 1, 1, 1};
772
  v4i8_r = __builtin_mips_repl_qb (1);
773
  r = (int) v4i8_r;
774
  s = (int) v4i8_s;
775
  if (r != s)
776
    abort ();
777
 
778
  i32_a = 99;
779
  v4i8_s = (v4i8) {99, 99, 99, 99};
780
  v4i8_r = __builtin_mips_repl_qb (i32_a);
781
  r = (int) v4i8_r;
782
  s = (int) v4i8_s;
783
  if (r != s)
784
    abort ();
785
 
786
  v2q15_s = (v2q15) {30, 30};
787
  v2q15_r = __builtin_mips_repl_ph (30);
788
  r = (int) v2q15_r;
789
  s = (int) v2q15_s;
790
  if (r != s)
791
    abort ();
792
 
793
  i32_a = 0x5612;
794
  v2q15_s = (v2q15) {0x5612, 0x5612};
795
  v2q15_r = __builtin_mips_repl_ph (i32_a);
796
  r = (int) v2q15_r;
797
  s = (int) v2q15_s;
798
  if (r != s)
799
    abort ();
800
 
801
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
802
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
803
  if (little_endian)
804
    i32_s = 0x03000000;
805
  else
806
    i32_s = 0x0c000000;
807
  __builtin_mips_cmpu_eq_qb (v4i8_a, v4i8_b);
808
  i32_r = __builtin_mips_rddsp (16);
809
  if (i32_r != i32_s)
810
    abort ();
811
 
812
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
813
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
814
  if (little_endian)
815
    i32_s = 0x04000000;
816
  else
817
    i32_s = 0x02000000;
818
  __builtin_mips_cmpu_lt_qb (v4i8_a, v4i8_b);
819
  i32_r = __builtin_mips_rddsp (16);
820
  if (i32_r != i32_s)
821
    abort ();
822
 
823
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
824
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
825
  if (little_endian)
826
    i32_s = 0x07000000;
827
  else
828
    i32_s = 0x0e000000;
829
  __builtin_mips_cmpu_le_qb (v4i8_a, v4i8_b);
830
  i32_r = __builtin_mips_rddsp (16);
831
  if (i32_r != i32_s)
832
    abort ();
833
 
834
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
835
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
836
  if (little_endian)
837
    i32_s = 0x3;
838
  else
839
    i32_s = 0xc;
840
  i32_r=__builtin_mips_cmpgu_eq_qb (v4i8_a, v4i8_b);
841
  if (i32_r != i32_s)
842
    abort ();
843
 
844
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
845
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
846
  if (little_endian)
847
    i32_s = 0x4;
848
  else
849
    i32_s = 0x2;
850
  i32_r = __builtin_mips_cmpgu_lt_qb (v4i8_a, v4i8_b);
851
  if (i32_r != i32_s)
852
    abort ();
853
 
854
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
855
  v4i8_b = (v4i8) {0x12, 0x34, 0x78, 0x56};
856
  if (little_endian)
857
    i32_s = 0x7;
858
  else
859
    i32_s = 0xe;
860
  i32_r = __builtin_mips_cmpgu_le_qb (v4i8_a, v4i8_b);
861
  if (i32_r != i32_s)
862
    abort ();
863
 
864
  __builtin_mips_wrdsp (0,31); // Clear all condition code bits.
865
  v2q15_a = (v2q15) {0x1234, 0x5678};
866
  v2q15_b = (v2q15) {0x1234, 0x7856};
867
  if (little_endian)
868
    i32_s = 0x01000000;
869
  else
870
    i32_s = 0x02000000;
871
  __builtin_mips_cmp_eq_ph (v2q15_a, v2q15_b);
872
  i32_r = __builtin_mips_rddsp (16);
873
  if (i32_r != i32_s)
874
    abort ();
875
 
876
  v2q15_a = (v2q15) {0x1234, 0x5678};
877
  v2q15_b = (v2q15) {0x1234, 0x7856};
878
  if (little_endian)
879
    i32_s = 0x02000000;
880
  else
881
    i32_s = 0x01000000;
882
  __builtin_mips_cmp_lt_ph (v2q15_a, v2q15_b);
883
  i32_r = __builtin_mips_rddsp (16);
884
  if (i32_r != i32_s)
885
    abort ();
886
 
887
  v2q15_a = (v2q15) {0x1234, 0x5678};
888
  v2q15_b = (v2q15) {0x1234, 0x7856};
889
  i32_s = 0x03000000;
890
  __builtin_mips_cmp_le_ph (v2q15_a, v2q15_b);
891
  i32_r = __builtin_mips_rddsp (16);
892
  if (i32_r != i32_s)
893
    abort ();
894
 
895
  i32_a = 0x0a000000; // cc: 0000 1010
896
  __builtin_mips_wrdsp (i32_a, 31);
897
  v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78};
898
  v4i8_b = (v4i8) {0x21, 0x43, 0x65, 0x87};
899
  if (little_endian)
900
    v4i8_s = (v4i8) {0x21, 0x34, 0x65, 0x78};
901
  else
902
    v4i8_s = (v4i8) {0x12, 0x43, 0x56, 0x87};
903
  v4i8_r = __builtin_mips_pick_qb (v4i8_a, v4i8_b);
904
  r = (int) v4i8_r;
905
  s = (int) v4i8_s;
906
  if (r != s)
907
    abort ();
908
 
909
  i32_a = 0x02000000; // cc: 0000 0010
910
  __builtin_mips_wrdsp (i32_a, 31);
911
  v2q15_a = (v2q15) {0x1234, 0x5678};
912
  v2q15_b = (v2q15) {0x2143, 0x6587};
913
  if (little_endian)
914
    v2q15_s = (v2q15) {0x2143, 0x5678};
915
  else
916
    v2q15_s = (v2q15) {0x1234, 0x6587};
917
  v2q15_r = __builtin_mips_pick_ph (v2q15_a, v2q15_b);
918
  r = (int) v2q15_r;
919
  s = (int) v2q15_s;
920
  if (r != s)
921
    abort ();
922
 
923
  v2q15_a = (v2q15) {0x1234, 0x5678};
924
  v2q15_b = (v2q15) {0x1234, 0x7856};
925
  if (little_endian)
926
    v2q15_s = (v2q15) {0x7856, 0x1234};
927
  else
928
    v2q15_s = (v2q15) {0x5678, 0x1234};
929
  v2q15_r = __builtin_mips_packrl_ph (v2q15_a, v2q15_b);
930
  r = (int) v2q15_r;
931
  s = (int) v2q15_s;
932
  if (r != s)
933
    abort ();
934
 
935
#ifndef __mips64
936
  a64_a = 0x1234567887654321LL;
937
  i32_s = 0x88765432;
938
  i32_r = __builtin_mips_extr_w (a64_a, 4);
939
  if (i32_r != i32_s)
940
    abort ();
941
 
942
  a64_a = 0x1234567887658321LL;
943
  i32_s = 0x56788766;
944
  i32_r = __builtin_mips_extr_r_w (a64_a, 16);
945
  if (i32_r != i32_s)
946
    abort ();
947
 
948
  a64_a = 0x12345677fffffff8LL;
949
  i32_s = 0x7fffffff;
950
  i32_r = __builtin_mips_extr_rs_w (a64_a, 4);
951
  if (i32_r != i32_s)
952
    abort ();
953
 
954
  a64_a = 0x1234567887658321LL;
955
  i32_s = 0x7fff;
956
  i32_r = __builtin_mips_extr_s_h (a64_a, 16);
957
  if (i32_r != i32_s)
958
    abort ();
959
 
960
  a64_a = 0x0000007887658321LL;
961
  i32_b = 24;
962
  i32_s = 0x7887;
963
  i32_r = __builtin_mips_extr_s_h (a64_a, i32_b);
964
  if (i32_r != i32_s)
965
    abort ();
966
 
967
  a64_a = 0x1234567887654321LL;
968
  i32_b = 4;
969
  i32_s = 0x88765432;
970
  i32_r = __builtin_mips_extr_w (a64_a, i32_b);
971
  if (i32_r != i32_s)
972
    abort ();
973
 
974
  a64_a = 0x1234567887658321LL;
975
  i32_b = 16;
976
  i32_s = 0x56788766;
977
  i32_r = __builtin_mips_extr_r_w (a64_a, i32_b);
978
  if (i32_r != i32_s)
979
    abort ();
980
 
981
  a64_a = 0x12345677fffffff8LL;
982
  i32_b = 4;
983
  i32_s = 0x7fffffff;
984
  i32_r = __builtin_mips_extr_rs_w (a64_a, i32_b);
985
  if (i32_r != i32_s)
986
    abort ();
987
 
988
  i32_a = 0x0000021f; // pos is 31
989
  __builtin_mips_wrdsp (i32_a, 31);
990
  a64_a = 0x1234567887654321LL;
991
  i32_s = 8;
992
  i32_r = __builtin_mips_extp (a64_a, 3); // extract 4 bits
993
  if (i32_r != i32_s)
994
    abort ();
995
 
996
  i32_a = 0x0000021f; // pos is 31
997
  __builtin_mips_wrdsp (i32_a, 31);
998
  a64_a = 0x1234567887654321LL;
999
  i32_b = 7; // size is 8. NOTE!! we should use 7
1000
  i32_s = 0x87;
1001
  i32_r = __builtin_mips_extp (a64_a, i32_b);
1002
  if (i32_r != i32_s)
1003
    abort ();
1004
 
1005
  i32_a = 0x0000021f; // pos is 31
1006
  __builtin_mips_wrdsp (i32_a, 31);
1007
  a64_a = 0x1234567887654321LL;
1008
  i32_s = 8;
1009
  i32_r = __builtin_mips_extpdp (a64_a, 3); // extract 4 bits
1010
  if (i32_r != i32_s)
1011
    abort ();
1012
 
1013
  i32_s = 0x0000021b; // pos is 27
1014
  i32_r = __builtin_mips_rddsp (31);
1015
  if (i32_r != i32_s)
1016
    abort ();
1017
 
1018
  i32_a = 0x0000021f; // pos is 31
1019
  __builtin_mips_wrdsp (i32_a, 31);
1020
  a64_a = 0x1234567887654321LL;
1021
  i32_b = 11; // size is 12. NOTE!!! We should use 11
1022
  i32_s = 0x876;
1023
  i32_r = __builtin_mips_extpdp (a64_a, i32_b);
1024
  if (i32_r != i32_s)
1025
    abort ();
1026
 
1027
  i32_s = 0x00000213; // pos is 19
1028
  i32_r = __builtin_mips_rddsp (31);
1029
  if (i32_r != i32_s)
1030
    abort ();
1031
 
1032
  a64_a = 0x1234567887654321LL;
1033
  a64_s = 0x0012345678876543LL;
1034
  a64_r = __builtin_mips_shilo (a64_a, 8);
1035
  if (a64_r != a64_s)
1036
    abort ();
1037
 
1038
  a64_a = 0x1234567887654321LL;
1039
  i32_b = -16;
1040
  a64_s = 0x5678876543210000LL;
1041
  a64_r = __builtin_mips_shilo (a64_a, i32_b);
1042
  if (a64_r != a64_s)
1043
    abort ();
1044
 
1045
  i32_a = 0x0;
1046
  __builtin_mips_wrdsp (i32_a, 31);
1047
  a64_a = 0x1234567887654321LL;
1048
  i32_b = 0x11112222;
1049
  a64_s = 0x8765432111112222LL;
1050
  a64_r = __builtin_mips_mthlip (a64_a, i32_b);
1051
  if (a64_r != a64_s)
1052
    abort ();
1053
  i32_s = 32;
1054
  i32_r = __builtin_mips_rddsp (31);
1055
  if (i32_r != i32_s)
1056
    abort ();
1057
#endif
1058
 
1059
  i32_a = 0x1357a468;
1060
  __builtin_mips_wrdsp (i32_a, 63);
1061
  i32_s = 0x03572428;
1062
  i32_r = __builtin_mips_rddsp (63);
1063
  if (i32_r != i32_s)
1064
    abort ();
1065
 
1066
  ptr_a = &array;
1067
  i32_b = 37;
1068
  i32_s = 37;
1069
  i32_r = __builtin_mips_lbux (ptr_a, i32_b);
1070
  if (i32_r != i32_s)
1071
    abort ();
1072
 
1073
  ptr_a = &array;
1074
  i32_b = 38;
1075
  if (little_endian)
1076
    i32_s = 0x2726;
1077
  else
1078
    i32_s = 0x2627;
1079
  i32_r = __builtin_mips_lhx (ptr_a, i32_b);
1080
  if (i32_r != i32_s)
1081
    abort ();
1082
 
1083
  ptr_a = &array;
1084
  i32_b = 40;
1085
  if (little_endian)
1086
    i32_s = 0x2b2a2928;
1087
  else
1088
    i32_s = 0x28292a2b;
1089
  i32_r = __builtin_mips_lwx (ptr_a, i32_b);
1090
  if (i32_r != i32_s)
1091
    abort ();
1092
 
1093
  i32_a = 0x00000220; // pos is 32, size is 4
1094
  __builtin_mips_wrdsp (i32_a, 63);
1095
  i32_s = 1;
1096
  i32_r = __builtin_mips_bposge32 ();
1097
  if (i32_r != i32_s)
1098
    abort ();
1099
 
1100
#ifndef __mips64
1101
  a64_a = 0x12345678;
1102
  i32_b = 0x80000000;
1103
  i32_c = 0x11112222;
1104
  a64_s = 0xF7776EEF12345678LL;
1105
  a64_r = __builtin_mips_madd (a64_a, i32_b, i32_c);
1106
  if (a64_r != a64_s)
1107
    abort ();
1108
#endif
1109
 
1110
#ifndef __mips64
1111
  a64_a = 0x12345678;
1112
  ui32_b = 0x80000000;
1113
  ui32_c = 0x11112222;
1114
  a64_s = 0x0888911112345678LL;
1115
  a64_r = __builtin_mips_maddu (a64_a, ui32_b, ui32_c);
1116
  if (a64_r != a64_s)
1117
    abort ();
1118
#endif
1119
 
1120
#ifndef __mips64
1121
  a64_a = 0x12345678;
1122
  i32_b = 0x80000000;
1123
  i32_c = 0x11112222;
1124
  a64_s = 0x0888911112345678LL;
1125
  a64_r = __builtin_mips_msub (a64_a, i32_b, i32_c);
1126
  if (a64_r != a64_s)
1127
    abort ();
1128
#endif
1129
 
1130
#ifndef __mips64
1131
  a64_a = 0x12345678;
1132
  ui32_b = 0x80000000;
1133
  ui32_c = 0x11112222;
1134
  a64_s = 0xF7776EEF12345678LL;
1135
  a64_r = __builtin_mips_msubu (a64_a, ui32_b, ui32_c);
1136
  if (a64_r != a64_s)
1137
    abort ();
1138
#endif
1139
 
1140
#ifndef __mips64
1141
  i32_a = 0x80000000;
1142
  i32_b = 0x11112222;
1143
  a64_s = 0xF7776EEF00000000LL;
1144
  a64_r = __builtin_mips_mult (i32_a, i32_b);
1145
  if (a64_r != a64_s)
1146
    abort ();
1147
#endif
1148
 
1149
#ifndef __mips64
1150
  ui32_a = 0x80000000;
1151
  ui32_b = 0x11112222;
1152
  a64_s = 0x888911100000000LL;
1153
  a64_r = __builtin_mips_multu (ui32_a, ui32_b);
1154
  if (a64_r != a64_s)
1155
    abort ();
1156
#endif
1157
}
1158
 

powered by: WebSVN 2.1.0

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