drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / none / tests / ppc32 / test_isa_2_06_part1.c
blob7300f8e8354e21587e8964708baf316bcc2f887e
1 /* Copyright (C) 2011 IBM
3 Author: Maynard Johnson <maynardj@us.ibm.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
18 The GNU General Public License is contained in the file COPYING.
21 #include <stdio.h>
22 #include <stdint.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <malloc.h>
27 #ifdef HAS_VSX
29 #include <altivec.h>
31 #ifndef __powerpc64__
32 typedef uint32_t HWord_t;
33 #else
34 typedef uint64_t HWord_t;
35 #endif /* __powerpc64__ */
37 #ifdef VGP_ppc64le_linux
38 #define isLE 1
39 #else
40 #define isLE 0
41 #endif
43 register HWord_t r14 __asm__ ("r14");
44 register HWord_t r15 __asm__ ("r15");
45 register HWord_t r16 __asm__ ("r16");
46 register HWord_t r17 __asm__ ("r17");
47 register double f14 __asm__ ("fr14");
48 register double f15 __asm__ ("fr15");
49 register double f16 __asm__ ("fr16");
50 register double f17 __asm__ ("fr17");
52 static volatile unsigned int cond_reg;
54 #define ALLCR "cr0","cr1","cr2","cr3","cr4","cr5","cr6","cr7"
56 #define SET_CR(_arg) \
57 __asm__ __volatile__ ("mtcr %0" : : "b"(_arg) : ALLCR );
59 #define SET_XER(_arg) \
60 __asm__ __volatile__ ("mtxer %0" : : "b"(_arg) : "xer" );
62 #define GET_CR(_lval) \
63 __asm__ __volatile__ ("mfcr %0" : "=b"(_lval) )
65 #define GET_XER(_lval) \
66 __asm__ __volatile__ ("mfxer %0" : "=b"(_lval) )
68 #define GET_CR_XER(_lval_cr,_lval_xer) \
69 do { GET_CR(_lval_cr); GET_XER(_lval_xer); } while (0)
71 #define SET_CR_ZERO \
72 SET_CR(0)
74 #define SET_XER_ZERO \
75 SET_XER(0)
77 #define SET_CR_XER_ZERO \
78 do { SET_CR_ZERO; SET_XER_ZERO; } while (0)
80 #define SET_FPSCR_ZERO \
81 do { double _d = 0.0; \
82 __asm__ __volatile__ ("mtfsf 0xFF, %0" : : "f"(_d) ); \
83 } while (0)
86 typedef void (*test_func_t)(void);
87 typedef struct ldst_test ldst_test_t;
88 typedef struct vsx_logic_test logic_test_t;
89 typedef struct xs_conv_test xs_conv_test_t;
90 typedef struct p7_fp_test fp_test_t;
91 typedef struct vx_fp_test vx_fp_test_t;
92 typedef struct vsx_move_test move_test_t;
93 typedef struct vsx_permute_test permute_test_t;
94 typedef struct test_table test_table_t;
96 static double *fargs = NULL;
97 static int nb_fargs;
99 /* These functions below that construct a table of floating point
100 * values were lifted from none/tests/ppc32/jm-insns.c.
103 #if defined (DEBUG_ARGS_BUILD)
104 #define AB_DPRINTF(fmt, args...) do { fprintf(stderr, fmt , ##args); } while (0)
105 #else
106 #define AB_DPRINTF(fmt, args...) do { } while (0)
107 #endif
109 static inline void register_farg (void *farg,
110 int s, uint16_t _exp, uint64_t mant)
112 uint64_t tmp;
114 tmp = ((uint64_t)s << 63) | ((uint64_t)_exp << 52) | mant;
115 *(uint64_t *)farg = tmp;
116 AB_DPRINTF("%d %03x %013llx => %016llx %0e\n",
117 s, _exp, mant, *(uint64_t *)farg, *(double *)farg);
120 static void build_fargs_table(void)
122 * Double precision:
123 * Sign goes from zero to one (1 bit)
124 * Exponent goes from 0 to ((1 << 12) - 1) (11 bits)
125 * Mantissa goes from 1 to ((1 << 52) - 1) (52 bits)
126 * + special values:
127 * +0.0 : 0 0x000 0x0000000000000 => 0x0000000000000000
128 * -0.0 : 1 0x000 0x0000000000000 => 0x8000000000000000
129 * +infinity : 0 0x7FF 0x0000000000000 => 0x7FF0000000000000
130 * -infinity : 1 0x7FF 0x0000000000000 => 0xFFF0000000000000
131 * +QNaN : 0 0x7FF 0x8000000000000 => 0x7FF8000000000000
132 * -QNaN : 1 0x7FF 0x8000000000000 => 0xFFF8000000000000
133 * +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF => 0x7FF7FFFFFFFFFFFF
134 * -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF => 0xFFF7FFFFFFFFFFFF
135 * (8 values)
137 * Single precision
138 * Sign: 1 bit
139 * Exponent: 8 bits
140 * Mantissa: 23 bits
141 * +0.0 : 0 0x00 0x000000 => 0x00000000
142 * -0.0 : 1 0x00 0x000000 => 0x80000000
143 * +infinity : 0 0xFF 0x000000 => 0x7F800000
144 * -infinity : 1 0xFF 0x000000 => 0xFF800000
145 * +QNaN : 0 0xFF 0x400000 => 0x7FC00000
146 * -QNaN : 1 0xFF 0x400000 => 0xFFC00000
147 * +SNaN : 0 0xFF 0x3FFFFF => 0x7FBFFFFF
148 * -SNaN : 1 0xFF 0x3FFFFF => 0xFFBFFFFF
151 uint64_t mant;
152 uint16_t _exp, e1;
153 int s;
154 int i=0;
156 if (nb_fargs)
157 return;
159 fargs = malloc( 16 * sizeof(double) );
160 for (s = 0; s < 2; s++) {
161 for (e1 = 0x001;; e1 = ((e1 + 1) << 13) + 7) {
162 if (e1 >= 0x400)
163 e1 = 0x3fe;
164 _exp = e1;
165 for (mant = 0x0000000000001ULL; mant < (1ULL << 52);
166 /* Add 'random' bits */
167 mant = ((mant + 0x4A6) << 29) + 0x359) {
168 register_farg( &fargs[i++], s, _exp, mant );
170 if (e1 == 0x3fe)
171 break;
174 // add a few smaller values to fargs . . .
175 s = 0;
176 _exp = 0x002;
177 mant = 0x0000000000b01ULL;
178 register_farg(&fargs[i++], s, _exp, mant);
180 _exp = 0x000;
181 mant = 0x00000203f0b3dULL;
182 register_farg(&fargs[i++], s, _exp, mant);
184 mant = 0x00000005a203dULL;
185 register_farg(&fargs[i++], s, _exp, mant);
187 s = 1;
188 _exp = 0x002;
189 mant = 0x0000000000b01ULL;
190 register_farg(&fargs[i++], s, _exp, mant);
192 _exp = 0x000;
193 mant = 0x00000203f0b3dULL;
194 register_farg(&fargs[i++], s, _exp, mant);
196 nb_fargs = i;
200 typedef struct fp_test_args {
201 int fra_idx;
202 int frb_idx;
203 int cr_flags;
204 } fp_test_args_t;
207 fp_test_args_t ftdiv_tests[] = {
208 {0, 1, 0x8},
209 {9, 1, 0xa},
210 {1, 12, 0xa},
211 {0, 2, 0xa},
212 {1, 3, 0xa},
213 {3, 0, 0xa},
214 {0, 3, 0xa},
215 {4, 0, 0xa},
216 {7, 1, 0xe},
217 {8, 1, 0xe},
218 {1, 7, 0xe},
219 {0, 13, 0xe},
220 {5, 5, 0xe},
221 {5, 6, 0xe},
224 fp_test_args_t xscmpX_tests[] = {
225 {8, 8, 0x2},
226 {8, 14, 0x8},
227 {8, 6, 0x8},
228 {8, 5, 0x8},
229 {8, 4, 0x8},
230 {8, 7, 0x8},
231 {8, 9, 0x1},
232 {8, 11, 0x1},
233 {14, 8, 0x4},
234 {14, 14, 0x2},
235 {14, 6, 0x8},
236 {14, 5, 0x8},
237 {14, 4, 0x8},
238 {14, 7, 0x8},
239 {14, 9, 0x1},
240 {14, 11, 0x1},
241 {6, 8, 0x4},
242 {6, 14, 0x4},
243 {6, 6, 0x2},
244 {6, 5, 0x2},
245 {6, 4, 0x8},
246 {6, 7, 0x8},
247 {6, 9, 0x1},
248 {6, 11, 0x1},
249 {5, 8, 0x4},
250 {5, 14, 0x4},
251 {5, 6, 0x2},
252 {5, 5, 0x2},
253 {5, 4, 0x8},
254 {5, 7, 0x8},
255 {5, 9, 0x1},
256 {5, 11, 0x1},
257 {4, 8, 0x4},
258 {4, 14, 0x4},
259 {4, 6, 0x4},
260 {4, 5, 0x4},
261 {4, 1, 0x8},
262 {4, 7, 0x8},
263 {4, 9, 0x1},
264 {4, 11, 0x1},
265 {7, 8, 0x4},
266 {7, 14, 0x4},
267 {7, 6, 0x4},
268 {7, 5, 0x4},
269 {7, 4, 0x4},
270 {7, 7, 0x2},
271 {7, 9, 0x1},
272 {7, 11, 0x1},
273 {10, 8, 0x1},
274 {10, 14, 0x1},
275 {10, 6, 0x1},
276 {10, 5, 0x1},
277 {10, 4, 0x1},
278 {10, 7, 0x1},
279 {10, 9, 0x1},
280 {10, 11, 0x1},
281 {12, 8, 0x1},
282 {12, 14, 0x1},
283 {12, 6, 0x1},
284 {12, 5, 0x1},
285 {12, 4, 0x1},
286 {12, 7, 0x1},
287 {12, 9, 0x1},
288 {12, 11, 0x1},
291 fp_test_args_t xsadddp_tests[] = {
292 {8, 8, 0x0},
293 {8, 14, 0x0},
294 {8, 6, 0x0},
295 {8, 5, 0x0},
296 {8, 4, 0x0},
297 {8, 7, 0x0},
298 {8, 9, 0x0},
299 {8, 11, 0x0},
300 {14, 8, 0x0},
301 {14, 14, 0x0},
302 {14, 6, 0x0},
303 {14, 5, 0x0},
304 {14, 4, 0x0},
305 {14, 7, 0x0},
306 {14, 9, 0x0},
307 {14, 11, 0x0},
308 {6, 8, 0x0},
309 {6, 14, 0x0},
310 {6, 6, 0x0},
311 {6, 5, 0x0},
312 {6, 4, 0x0},
313 {6, 7, 0x0},
314 {6, 9, 0x0},
315 {6, 11, 0x0},
316 {5, 8, 0x0},
317 {5, 14, 0x0},
318 {5, 6, 0x0},
319 {5, 5, 0x0},
320 {5, 4, 0x0},
321 {5, 7, 0x0},
322 {5, 9, 0x0},
323 {5, 11, 0x0},
324 {4, 8, 0x0},
325 {4, 14, 0x0},
326 {4, 6, 0x0},
327 {4, 5, 0x0},
328 {4, 1, 0x0},
329 {4, 7, 0x0},
330 {4, 9, 0x0},
331 {4, 11, 0x0},
332 {7, 8, 0x0},
333 {7, 14, 0x0},
334 {7, 6, 0x0},
335 {7, 5, 0x0},
336 {7, 4, 0x0},
337 {7, 7, 0x0},
338 {7, 9, 0x0},
339 {7, 11, 0x0},
340 {10, 8, 0x0},
341 {10, 14, 0x0},
342 {10, 6, 0x0},
343 {10, 5, 0x0},
344 {10, 4, 0x0},
345 {10, 7, 0x0},
346 {10, 9, 0x0},
347 {10, 11, 0x0},
348 {12, 8, 0x0},
349 {12, 14, 0x0},
350 {12, 6, 0x0},
351 {12, 5, 0x0},
352 {12, 4, 0x0},
353 {12, 7, 0x0},
354 {12, 9, 0x0},
355 {12, 11, 0x0},
358 fp_test_args_t xsdivdp_tests[] = {
359 {8, 8, 0x0},
360 {8, 14, 0x0},
361 {8, 6, 0x0},
362 {8, 5, 0x0},
363 {8, 4, 0x0},
364 {8, 7, 0x0},
365 {8, 9, 0x0},
366 {8, 11, 0x0},
367 {14, 8, 0x0},
368 {14, 14, 0x0},
369 {14, 6, 0x0},
370 {14, 5, 0x0},
371 {14, 4, 0x0},
372 {14, 7, 0x0},
373 {14, 9, 0x0},
374 {14, 11, 0x0},
375 {6, 8, 0x0},
376 {6, 14, 0x0},
377 {6, 6, 0x0},
378 {6, 5, 0x0},
379 {6, 4, 0x0},
380 {6, 7, 0x0},
381 {6, 9, 0x0},
382 {6, 11, 0x0},
383 {5, 8, 0x0},
384 {5, 14, 0x0},
385 {5, 6, 0x0},
386 {5, 5, 0x0},
387 {5, 4, 0x0},
388 {5, 7, 0x0},
389 {5, 9, 0x0},
390 {5, 11, 0x0},
391 {4, 8, 0x0},
392 {4, 14, 0x0},
393 {4, 6, 0x0},
394 {4, 5, 0x0},
395 {4, 1, 0x0},
396 {4, 7, 0x0},
397 {4, 9, 0x0},
398 {4, 11, 0x0},
399 {7, 8, 0x0},
400 {7, 14, 0x0},
401 {7, 6, 0x0},
402 {7, 5, 0x0},
403 {7, 4, 0x0},
404 {7, 7, 0x0},
405 {7, 9, 0x0},
406 {7, 11, 0x0},
407 {10, 8, 0x0},
408 {10, 14, 0x0},
409 {10, 6, 0x0},
410 {10, 5, 0x0},
411 {10, 4, 0x0},
412 {10, 7, 0x0},
413 {10, 9, 0x0},
414 {10, 11, 0x0},
415 {12, 8, 0x0},
416 {12, 14, 0x0},
417 {12, 6, 0x0},
418 {12, 5, 0x0},
419 {12, 4, 0x0},
420 {12, 7, 0x0},
421 {12, 9, 0x0},
422 {12, 11, 0x0},
425 fp_test_args_t xsmaddXdp_tests[] = {
426 {8, 8, 0x0},
427 {8, 14, 0x0},
428 {8, 6, 0x0},
429 {8, 5, 0x0},
430 {8, 4, 0x0},
431 {8, 7, 0x0},
432 {8, 9, 0x0},
433 {8, 11, 0x0},
434 {14, 8, 0x0},
435 {14, 14, 0x0},
436 {14, 6, 0x0},
437 {14, 5, 0x0},
438 {14, 4, 0x0},
439 {14, 7, 0x0},
440 {14, 9, 0x0},
441 {14, 11, 0x0},
442 {6, 8, 0x0},
443 {6, 14, 0x0},
444 {6, 6, 0x0},
445 {6, 5, 0x0},
446 {6, 4, 0x0},
447 {6, 7, 0x0},
448 {6, 9, 0x0},
449 {6, 11, 0x0},
450 {5, 8, 0x0},
451 {5, 14, 0x0},
452 {5, 6, 0x0},
453 {5, 5, 0x0},
454 {5, 4, 0x0},
455 {5, 7, 0x0},
456 {5, 9, 0x0},
457 {5, 11, 0x0},
458 {4, 8, 0x0},
459 {4, 14, 0x0},
460 {4, 6, 0x0},
461 {4, 5, 0x0},
462 {4, 1, 0x0},
463 {4, 7, 0x0},
464 {4, 9, 0x0},
465 {4, 11, 0x0},
466 {7, 8, 0x0},
467 {7, 14, 0x0},
468 {7, 6, 0x0},
469 {7, 5, 0x0},
470 {7, 4, 0x0},
471 {7, 7, 0x0},
472 {7, 9, 0x0},
473 {7, 11, 0x0},
474 {10, 8, 0x0},
475 {10, 14, 0x0},
476 {10, 6, 0x0},
477 {10, 5, 0x0},
478 {10, 4, 0x0},
479 {10, 7, 0x0},
480 {10, 9, 0x0},
481 {10, 11, 0x0},
482 {12, 8, 0x0},
483 {12, 14, 0x0},
484 {12, 6, 0x0},
485 {12, 5, 0x0},
486 {12, 4, 0x0},
487 {12, 7, 0x0},
488 {12, 9, 0x0},
489 {12, 11, 0x0},
492 fp_test_args_t xsmsubXdp_tests[] = {
493 {8, 8, 0x0},
494 {8, 14, 0x0},
495 {8, 6, 0x0},
496 {8, 5, 0x0},
497 {8, 4, 0x0},
498 {8, 7, 0x0},
499 {8, 9, 0x0},
500 {8, 11, 0x0},
501 {14, 8, 0x0},
502 {14, 14, 0x0},
503 {14, 6, 0x0},
504 {14, 5, 0x0},
505 {14, 4, 0x0},
506 {14, 7, 0x0},
507 {14, 9, 0x0},
508 {14, 11, 0x0},
509 {6, 8, 0x0},
510 {6, 14, 0x0},
511 {6, 6, 0x0},
512 {6, 5, 0x0},
513 {6, 4, 0x0},
514 {6, 7, 0x0},
515 {6, 9, 0x0},
516 {6, 11, 0x0},
517 {5, 8, 0x0},
518 {5, 14, 0x0},
519 {5, 6, 0x0},
520 {5, 5, 0x0},
521 {5, 4, 0x0},
522 {5, 7, 0x0},
523 {5, 9, 0x0},
524 {5, 11, 0x0},
525 {4, 8, 0x0},
526 {4, 14, 0x0},
527 {4, 6, 0x0},
528 {4, 5, 0x0},
529 {4, 1, 0x0},
530 {4, 7, 0x0},
531 {4, 9, 0x0},
532 {4, 11, 0x0},
533 {7, 8, 0x0},
534 {7, 14, 0x0},
535 {7, 6, 0x0},
536 {7, 5, 0x0},
537 {7, 4, 0x0},
538 {7, 7, 0x0},
539 {7, 9, 0x0},
540 {7, 11, 0x0},
541 {10, 8, 0x0},
542 {10, 14, 0x0},
543 {10, 6, 0x0},
544 {10, 5, 0x0},
545 {10, 4, 0x0},
546 {10, 7, 0x0},
547 {10, 9, 0x0},
548 {10, 11, 0x0},
549 {12, 8, 0x0},
550 {12, 14, 0x0},
551 {12, 6, 0x0},
552 {12, 5, 0x0},
553 {12, 4, 0x0},
554 {12, 7, 0x0},
555 {12, 9, 0x0},
556 {12, 11, 0x0},
559 fp_test_args_t xsnmaddXdp_tests[] = {
560 {8, 8, 0x0},
561 {8, 14, 0x0},
562 {8, 6, 0x0},
563 {8, 5, 0x0},
564 {8, 4, 0x0},
565 {8, 7, 0x0},
566 {8, 9, 0x0},
567 {8, 11, 0x0},
568 {14, 8, 0x0},
569 {14, 14, 0x0},
570 {14, 6, 0x0},
571 {14, 5, 0x0},
572 {14, 4, 0x0},
573 {14, 7, 0x0},
574 {14, 9, 0x0},
575 {14, 11, 0x0},
576 {6, 8, 0x0},
577 {6, 14, 0x0},
578 {6, 6, 0x0},
579 {6, 5, 0x0},
580 {6, 4, 0x0},
581 {6, 7, 0x0},
582 {6, 9, 0x0},
583 {6, 11, 0x0},
584 {5, 8, 0x0},
585 {5, 14, 0x0},
586 {5, 6, 0x0},
587 {5, 5, 0x0},
588 {5, 4, 0x0},
589 {5, 7, 0x0},
590 {5, 9, 0x0},
591 {5, 11, 0x0},
592 {4, 8, 0x0},
593 {4, 14, 0x0},
594 {4, 6, 0x0},
595 {4, 5, 0x0},
596 {4, 1, 0x0},
597 {4, 7, 0x0},
598 {4, 9, 0x0},
599 {4, 11, 0x0},
600 {7, 8, 0x0},
601 {7, 14, 0x0},
602 {7, 6, 0x0},
603 {7, 5, 0x0},
604 {7, 4, 0x0},
605 {7, 7, 0x0},
606 {7, 9, 0x0},
607 {7, 11, 0x0},
608 {10, 8, 0x0},
609 {10, 14, 0x0},
610 {10, 6, 0x0},
611 {10, 5, 0x0},
612 {10, 4, 0x0},
613 {10, 7, 0x0},
614 {10, 9, 0x0},
615 {10, 11, 0x0},
616 {12, 8, 0x0},
617 {12, 14, 0x0},
618 {12, 6, 0x0},
619 {12, 5, 0x0},
620 {12, 4, 0x0},
621 {12, 7, 0x0},
622 {12, 9, 0x0},
623 {12, 11, 0x0},
626 fp_test_args_t xsmuldp_tests[] = {
627 {8, 8, 0x0},
628 {8, 14, 0x0},
629 {8, 6, 0x0},
630 {8, 5, 0x0},
631 {8, 4, 0x0},
632 {8, 7, 0x0},
633 {8, 9, 0x0},
634 {8, 11, 0x0},
635 {14, 8, 0x0},
636 {14, 14, 0x0},
637 {14, 6, 0x0},
638 {14, 5, 0x0},
639 {14, 4, 0x0},
640 {14, 7, 0x0},
641 {14, 9, 0x0},
642 {14, 11, 0x0},
643 {6, 8, 0x0},
644 {6, 14, 0x0},
645 {6, 6, 0x0},
646 {6, 5, 0x0},
647 {6, 4, 0x0},
648 {6, 7, 0x0},
649 {6, 9, 0x0},
650 {6, 11, 0x0},
651 {5, 8, 0x0},
652 {5, 14, 0x0},
653 {5, 6, 0x0},
654 {5, 5, 0x0},
655 {5, 4, 0x0},
656 {5, 7, 0x0},
657 {5, 9, 0x0},
658 {5, 11, 0x0},
659 {4, 8, 0x0},
660 {4, 14, 0x0},
661 {4, 6, 0x0},
662 {4, 5, 0x0},
663 {4, 1, 0x0},
664 {4, 7, 0x0},
665 {4, 9, 0x0},
666 {4, 11, 0x0},
667 {7, 8, 0x0},
668 {7, 14, 0x0},
669 {7, 6, 0x0},
670 {7, 5, 0x0},
671 {7, 4, 0x0},
672 {7, 7, 0x0},
673 {7, 9, 0x0},
674 {7, 11, 0x0},
675 {10, 8, 0x0},
676 {10, 14, 0x0},
677 {10, 6, 0x0},
678 {10, 5, 0x0},
679 {10, 4, 0x0},
680 {10, 7, 0x0},
681 {10, 9, 0x0},
682 {10, 11, 0x0},
683 {12, 8, 0x0},
684 {12, 14, 0x0},
685 {12, 6, 0x0},
686 {12, 5, 0x0},
687 {12, 4, 0x0},
688 {12, 7, 0x0},
689 {12, 9, 0x0},
690 {12, 11, 0x0},
693 fp_test_args_t xssubdp_tests[] = {
694 {8, 8, 0x0},
695 {8, 14, 0x0},
696 {8, 6, 0x0},
697 {8, 5, 0x0},
698 {8, 4, 0x0},
699 {8, 7, 0x0},
700 {8, 9, 0x0},
701 {8, 11, 0x0},
702 {14, 8, 0x0},
703 {14, 14, 0x0},
704 {14, 6, 0x0},
705 {14, 5, 0x0},
706 {14, 4, 0x0},
707 {14, 7, 0x0},
708 {14, 9, 0x0},
709 {14, 11, 0x0},
710 {6, 8, 0x0},
711 {6, 14, 0x0},
712 {6, 6, 0x0},
713 {6, 5, 0x0},
714 {6, 4, 0x0},
715 {6, 7, 0x0},
716 {6, 9, 0x0},
717 {6, 11, 0x0},
718 {5, 8, 0x0},
719 {5, 14, 0x0},
720 {5, 6, 0x0},
721 {5, 5, 0x0},
722 {5, 4, 0x0},
723 {5, 7, 0x0},
724 {5, 9, 0x0},
725 {5, 11, 0x0},
726 {4, 8, 0x0},
727 {4, 14, 0x0},
728 {4, 6, 0x0},
729 {4, 5, 0x0},
730 {4, 1, 0x0},
731 {4, 7, 0x0},
732 {4, 9, 0x0},
733 {4, 11, 0x0},
734 {7, 8, 0x0},
735 {7, 14, 0x0},
736 {7, 6, 0x0},
737 {7, 5, 0x0},
738 {7, 4, 0x0},
739 {7, 7, 0x0},
740 {7, 9, 0x0},
741 {7, 11, 0x0},
742 {10, 8, 0x0},
743 {10, 14, 0x0},
744 {10, 6, 0x0},
745 {10, 5, 0x0},
746 {10, 4, 0x0},
747 {10, 7, 0x0},
748 {10, 9, 0x0},
749 {10, 11, 0x0},
750 {12, 8, 0x0},
751 {12, 14, 0x0},
752 {12, 6, 0x0},
753 {12, 5, 0x0},
754 {12, 4, 0x0},
755 {12, 7, 0x0},
756 {12, 9, 0x0},
757 {12, 11, 0x0},
762 static int nb_special_fargs;
763 static double * spec_fargs;
765 static void build_special_fargs_table(void)
767 /* The special floating point values created below are for
768 * use in the ftdiv tests for setting the fe_flag and fg_flag,
769 * but they can also be used for other tests (e.g., xscmpudp).
771 * Note that fl_flag is 'always '1' on ppc64 Linux.
773 Entry Sign Exp fraction Special value
774 0 0 3fd 0x8000000000000ULL Positive finite number
775 1 0 404 0xf000000000000ULL ...
776 2 0 001 0x8000000b77501ULL ...
777 3 0 7fe 0x800000000051bULL ...
778 4 0 012 0x3214569900000ULL ...
779 5 0 000 0x0000000000000ULL +0.0 (+zero)
780 6 1 000 0x0000000000000ULL -0.0 (-zero)
781 7 0 7ff 0x0000000000000ULL +infinity
782 8 1 7ff 0x0000000000000ULL -infinity
783 9 0 7ff 0x7FFFFFFFFFFFFULL +SNaN
784 10 1 7ff 0x7FFFFFFFFFFFFULL -SNaN
785 11 0 7ff 0x8000000000000ULL +QNaN
786 12 1 7ff 0x8000000000000ULL -QNaN
787 13 1 000 0x8340000078000ULL Denormalized val (zero exp and non-zero fraction)
788 14 1 40d 0x0650f5a07b353ULL Negative finite number
791 uint64_t mant;
792 uint16_t _exp;
793 int s;
794 int i = 0;
796 if (spec_fargs)
797 return;
799 spec_fargs = malloc( 16 * sizeof(double) );
801 // #0
802 s = 0;
803 _exp = 0x3fd;
804 mant = 0x8000000000000ULL;
805 register_farg(&spec_fargs[i++], s, _exp, mant);
807 // #1
808 s = 0;
809 _exp = 0x404;
810 mant = 0xf000000000000ULL;
811 register_farg(&spec_fargs[i++], s, _exp, mant);
813 /* None of the ftdiv tests succeed.
814 * FRA = value #0; FRB = value #1
815 * ea_ = -2; e_b = 5
816 * fl_flag || fg_flag || fe_flag = 100
819 /*************************************************
820 * fe_flag tests
822 *************************************************/
824 /* fe_flag <- 1 if FRA is a NaN
825 * FRA = value #9; FRB = value #1
826 * e_a = 1024; e_b = 5
827 * fl_flag || fg_flag || fe_flag = 101
830 /* fe_flag <- 1 if FRB is a NaN
831 * FRA = value #1; FRB = value #12
832 * e_a = 5; e_b = 1024
833 * fl_flag || fg_flag || fe_flag = 101
836 /* fe_flag <- 1 if e_b <= -1022
837 * FRA = value #0; FRB = value #2
838 * e_a = -2; e_b = -1022
839 * fl_flag || fg_flag || fe_flag = 101
842 // #2
843 s = 0;
844 _exp = 0x001;
845 mant = 0x8000000b77501ULL;
846 register_farg(&spec_fargs[i++], s, _exp, mant);
848 /* fe_flag <- 1 if e_b >= 1021
849 * FRA = value #1; FRB = value #3
850 * e_a = 5; e_b = 1023
851 * fl_flag || fg_flag || fe_flag = 101
853 // #3
854 s = 0;
855 _exp = 0x7fe;
856 mant = 0x800000000051bULL;
857 register_farg(&spec_fargs[i++], s, _exp, mant);
859 /* fe_flag <- 1 if FRA != 0 && e_a - e_b >= 1023
860 * Let FRA = value #3 and FRB be value #0.
861 * e_a = 1023; e_b = -2
862 * fl_flag || fg_flag || fe_flag = 101
865 /* fe_flag <- 1 if FRA != 0 && e_a - e_b <= -1023
866 * Let FRA = value #0 above and FRB be value #3 above
867 * e_a = -2; e_b = 1023
868 * fl_flag || fg_flag || fe_flag = 101
871 /* fe_flag <- 1 if FRA != 0 && e_a <= -970
872 * Let FRA = value #4 and FRB be value #0
873 * e_a = -1005; e_b = -2
874 * fl_flag || fg_flag || fe_flag = 101
876 // #4
877 s = 0;
878 _exp = 0x012;
879 mant = 0x3214569900000ULL;
880 register_farg(&spec_fargs[i++], s, _exp, mant);
882 /*************************************************
883 * fg_flag tests
885 *************************************************/
886 /* fg_flag <- 1 if FRA is an Infinity
887 * NOTE: FRA = Inf also sets fe_flag
888 * Do two tests, using values #7 and #8 (+/- Inf) for FRA.
889 * Test 1:
890 * Let FRA be value #7 and FRB be value #1
891 * e_a = 1024; e_b = 5
892 * fl_flag || fg_flag || fe_flag = 111
894 * Test 2:
895 * Let FRA be value #8 and FRB be value #1
896 * e_a = 1024; e_b = 5
897 * fl_flag || fg_flag || fe_flag = 111
901 /* fg_flag <- 1 if FRB is an Infinity
902 * NOTE: FRB = Inf also sets fe_flag
903 * Let FRA be value #1 and FRB be value #7
904 * e_a = 5; e_b = 1024
905 * fl_flag || fg_flag || fe_flag = 111
908 /* fg_flag <- 1 if FRB is denormalized
909 * NOTE: e_b < -1022 ==> fe_flag <- 1
910 * Let FRA be value #0 and FRB be value #13
911 * e_a = -2; e_b = -1023
912 * fl_flag || fg_flag || fe_flag = 111
915 /* fg_flag <- 1 if FRB is +zero
916 * NOTE: FRA = Inf also sets fe_flag
917 * Let FRA = val #5; FRB = val #5
918 * ea_ = -1023; e_b = -1023
919 * fl_flag || fg_flag || fe_flag = 111
922 /* fg_flag <- 1 if FRB is -zero
923 * NOTE: FRA = Inf also sets fe_flag
924 * Let FRA = val #5; FRB = val #6
925 * ea_ = -1023; e_b = -1023
926 * fl_flag || fg_flag || fe_flag = 111
929 /* Special values */
930 /* +0.0 : 0 0x000 0x0000000000000 */
931 // #5
932 s = 0;
933 _exp = 0x000;
934 mant = 0x0000000000000ULL;
935 register_farg(&spec_fargs[i++], s, _exp, mant);
937 /* -0.0 : 1 0x000 0x0000000000000 */
938 // #6
939 s = 1;
940 _exp = 0x000;
941 mant = 0x0000000000000ULL;
942 register_farg(&spec_fargs[i++], s, _exp, mant);
944 /* +infinity : 0 0x7FF 0x0000000000000 */
945 // #7
946 s = 0;
947 _exp = 0x7FF;
948 mant = 0x0000000000000ULL;
949 register_farg(&spec_fargs[i++], s, _exp, mant);
951 /* -infinity : 1 0x7FF 0x0000000000000 */
952 // #8
953 s = 1;
954 _exp = 0x7FF;
955 mant = 0x0000000000000ULL;
956 register_farg(&spec_fargs[i++], s, _exp, mant);
958 /* +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF */
959 // #9
960 s = 0;
961 _exp = 0x7FF;
962 mant = 0x7FFFFFFFFFFFFULL;
963 register_farg(&spec_fargs[i++], s, _exp, mant);
965 /* -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF */
966 // #10
967 s = 1;
968 _exp = 0x7FF;
969 mant = 0x7FFFFFFFFFFFFULL;
970 register_farg(&spec_fargs[i++], s, _exp, mant);
972 /* +QNaN : 0 0x7FF 0x8000000000000 */
973 // #11
974 s = 0;
975 _exp = 0x7FF;
976 mant = 0x8000000000000ULL;
977 register_farg(&spec_fargs[i++], s, _exp, mant);
979 /* -QNaN : 1 0x7FF 0x8000000000000 */
980 // #12
981 s = 1;
982 _exp = 0x7FF;
983 mant = 0x8000000000000ULL;
984 register_farg(&spec_fargs[i++], s, _exp, mant);
986 /* denormalized value */
987 // #13
988 s = 1;
989 _exp = 0x000;
990 mant = 0x8340000078000ULL;
991 register_farg(&spec_fargs[i++], s, _exp, mant);
993 /* Negative finite number */
994 // #14
995 s = 1;
996 _exp = 0x40d;
997 mant = 0x0650f5a07b353ULL;
998 register_farg(&spec_fargs[i++], s, _exp, mant);
1000 nb_special_fargs = i;
1004 struct test_table
1006 test_func_t test_category;
1007 char * name;
1010 struct p7_fp_test
1012 test_func_t test_func;
1013 const char *name;
1014 int single; // 1=single precision result; 0=double precision result
1017 typedef enum {
1018 VX_FP_CMP,
1019 VX_FP_SMA,
1020 VX_FP_SMS,
1021 VX_FP_SNMA,
1022 VX_FP_OTHER
1023 } vx_fp_test_type;
1025 struct vx_fp_test
1027 test_func_t test_func;
1028 const char *name;
1029 fp_test_args_t * targs;
1030 int num_tests;
1031 vx_fp_test_type test_type;
1034 struct xs_conv_test
1036 test_func_t test_func;
1037 const char *name;
1038 int num_tests;
1041 typedef enum {
1042 VSX_LOAD =1,
1043 VSX_LOAD_SPLAT,
1044 VSX_STORE
1045 } vsx_ldst_type;
1047 struct ldst_test
1049 test_func_t test_func;
1050 const char *name;
1051 void * base_addr;
1052 uint32_t offset;
1053 int num_words_to_process;
1054 vsx_ldst_type type;
1057 typedef enum {
1058 VSX_AND = 1,
1059 VSX_XOR,
1060 VSX_ANDC,
1061 VSX_OR,
1062 VSX_NOR
1063 } vsx_log_op;
1065 struct vsx_logic_test
1067 test_func_t test_func;
1068 const char *name;
1069 vsx_log_op op;
1072 struct vsx_move_test
1074 test_func_t test_func;
1075 const char *name;
1078 struct vsx_permute_test
1080 test_func_t test_func;
1081 const char *name;
1082 unsigned int xa[4];
1083 unsigned int xb[4];
1086 static vector unsigned int vec_out, vec_inA, vec_inB;
1088 static void test_lxsdx(void)
1090 __asm__ __volatile__ ("lxsdx %x0, %1, %2" : "=wa" (vec_out): "b" (r14),"r" (r15));
1093 static void
1094 test_lxvd2x(void)
1096 __asm__ __volatile__ ("lxvd2x %x0, %1, %2" : "=wa" (vec_out): "b" (r14),"r" (r15));
1099 static void test_lxvdsx(void)
1101 __asm__ __volatile__ ("lxvdsx %x0, %1, %2" : "=wa" (vec_out): "b" (r14),"r" (r15));
1104 static void test_lxvw4x(void)
1106 __asm__ __volatile__ ("lxvw4x %x0, %1, %2" : "=wa" (vec_out): "b" (r14),"r" (r15));
1109 static void test_stxsdx(void)
1111 __asm__ __volatile__ ("stxsdx %x0, %1, %2" : : "wa" (vec_inA), "b" (r14),"r" (r15));
1114 static void test_stxvd2x(void)
1116 __asm__ __volatile__ ("stxvd2x %x0, %1, %2" : : "wa" (vec_inA), "b" (r14),"r" (r15));
1119 static void test_stxvw4x(void)
1121 __asm__ __volatile__ ("stxvw4x %x0, %1, %2" : : "wa" (vec_inA), "b" (r14),"r" (r15));
1124 static void test_xxlxor(void)
1126 __asm__ __volatile__ ("xxlxor %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1129 static void test_xxlor(void)
1131 __asm__ __volatile__ ("xxlor %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1134 static void test_xxlnor(void)
1136 __asm__ __volatile__ ("xxlnor %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1139 static void test_xxland(void)
1141 __asm__ __volatile__ ("xxland %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1144 static void test_xxlandc(void)
1146 __asm__ __volatile__ ("xxlandc %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1149 static void test_xxmrghw(void)
1151 __asm__ __volatile__ ("xxmrghw %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1154 static void test_xxmrglw(void)
1156 __asm__ __volatile__ ("xxmrglw %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1159 static void test_xxpermdi_00(void)
1161 __asm__ __volatile__ ("xxpermdi %x0, %x1, %x2, 0x0" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1164 static void test_xxpermdi_01(void)
1166 __asm__ __volatile__ ("xxpermdi %x0, %x1, %x2, 0x1" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1169 static void test_xxpermdi_10(void)
1171 __asm__ __volatile__ ("xxpermdi %x0, %x1, %x2, 0x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1174 static void test_xxpermdi_11(void)
1176 __asm__ __volatile__ ("xxpermdi %x0, %x1, %x2, 0x3" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1179 static void test_xxsldwi_0(void)
1181 __asm__ __volatile__ ("xxsldwi %x0, %x1, %x2, 0" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1184 static void test_xxsldwi_1(void)
1186 __asm__ __volatile__ ("xxsldwi %x0, %x1, %x2, 1" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1189 static void test_xxsldwi_2(void)
1191 __asm__ __volatile__ ("xxsldwi %x0, %x1, %x2, 2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1194 static void test_xxsldwi_3(void)
1196 __asm__ __volatile__ ("xxsldwi %x0, %x1, %x2, 3" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1199 static void test_fcfids (void)
1201 __asm__ __volatile__ ("fcfids %0, %1" : "=f" (f17): "d" (f14));
1204 static void test_fcfidus (void)
1206 __asm__ __volatile__ ("fcfidus %0, %1" : "=f" (f17): "d" (f14));
1209 static void test_fcfidu (void)
1211 __asm__ __volatile__ ("fcfidu %0, %1" : "=f" (f17): "d" (f14));
1214 static void test_xsabsdp (void)
1216 __asm__ __volatile__ ("xsabsdp %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1219 static void test_xscpsgndp (void)
1221 __asm__ __volatile__ ("xscpsgndp %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1224 static void test_xsnabsdp (void)
1226 __asm__ __volatile__ ("xsnabsdp %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1229 static void test_xsnegdp (void)
1231 __asm__ __volatile__ ("xsnegdp %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1234 static int do_cmpudp;
1235 static void test_xscmp (void)
1237 if (do_cmpudp)
1238 __asm__ __volatile__ ("xscmpudp cr1, %x0, %x1" : : "wa" (vec_inA),"wa" (vec_inB));
1239 else
1240 __asm__ __volatile__ ("xscmpodp cr1, %x0, %x1" : : "wa" (vec_inA),"wa" (vec_inB));
1243 static void test_xsadddp(void)
1245 __asm__ __volatile__ ("xsadddp %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1248 static void test_xsdivdp(void)
1250 __asm__ __volatile__ ("xsdivdp %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1253 static int do_adp;
1254 static void test_xsmadd(void)
1256 if (do_adp)
1257 __asm__ __volatile__ ("xsmaddadp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1258 else
1259 __asm__ __volatile__ ("xsmaddmdp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1262 static void test_xsmsub(void)
1264 if (do_adp)
1265 __asm__ __volatile__ ("xsmsubadp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1266 else
1267 __asm__ __volatile__ ("xsmsubmdp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1270 static void test_xsnmadd(void)
1272 if (do_adp)
1273 __asm__ __volatile__ ("xsnmaddadp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1274 else
1275 __asm__ __volatile__ ("xsnmaddmdp %x0, %x1, %x2" : "+wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1278 static void test_xsmuldp(void)
1280 __asm__ __volatile__ ("xsmuldp %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1283 static void test_xssubdp(void)
1285 __asm__ __volatile__ ("xssubdp %x0, %x1, %x2" : "=wa" (vec_out): "wa" (vec_inA),"wa" (vec_inB));
1288 static void test_xscvdpsxds (void)
1290 __asm__ __volatile__ ("xscvdpsxds %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1293 static void test_xscvsxddp (void)
1295 __asm__ __volatile__ ("xscvsxddp %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1298 static void test_xscvuxddp (void)
1300 __asm__ __volatile__ ("xscvuxddp %x0, %x1" : "=wa" (vec_out): "wa" (vec_inB));
1303 static unsigned int vstg[] __attribute__ ((aligned (16))) = { 0, 0, 0,0,
1304 0, 0, 0, 0 };
1306 #define NUM_VSTG_INTS (sizeof vstg/sizeof vstg[0])
1307 #define NUM_VSTG_VECS (NUM_VSTG_INTS/4)
1309 static unsigned int viargs[] __attribute__ ((aligned (16))) = { 0x01234567,
1310 0x89abcdef,
1311 0x00112233,
1312 0x44556677,
1313 0x8899aabb,
1314 0x91929394,
1315 0xa1a2a3a4,
1316 0xb1b2b3b4,
1317 0xc1c2c3c4,
1318 0xd1d2d3d4,
1319 0x7a6b5d3e
1321 #define NUM_VIARGS_INTS (sizeof viargs/sizeof viargs[0])
1322 #define NUM_VIARGS_VECS (NUM_VIARGS_INTS/4)
1324 static ldst_test_t ldst_tests[] = { { &test_lxsdx, "lxsdx", viargs, 0, 2, VSX_LOAD },
1325 { &test_lxsdx, "lxsdx", viargs, 4, 2, VSX_LOAD },
1326 { &test_lxvd2x, "lxvd2x", viargs, 0, 4, VSX_LOAD },
1327 { &test_lxvd2x, "lxvd2x", viargs, 4, 4, VSX_LOAD },
1328 { &test_lxvdsx, "lxvdsx", viargs, 0, 4, VSX_LOAD_SPLAT },
1329 { &test_lxvdsx, "lxvdsx", viargs, 4, 4, VSX_LOAD_SPLAT },
1330 { &test_lxvw4x, "lxvw4x", viargs, 0, 4, VSX_LOAD },
1331 { &test_lxvw4x, "lxvw4x", viargs, 4, 4, VSX_LOAD },
1332 { &test_stxsdx, "stxsdx", vstg, 0, 2, VSX_STORE },
1333 { &test_stxsdx, "stxsdx", vstg, 4, 2, VSX_STORE },
1334 { &test_stxvd2x, "stxvd2x", vstg, 0, 4, VSX_STORE },
1335 { &test_stxvd2x, "stxvd2x", vstg, 4, 4, VSX_STORE },
1336 { &test_stxvw4x, "stxvw4x", vstg, 0, 4, VSX_STORE },
1337 { &test_stxvw4x, "stxvw4x", vstg, 4, 4, VSX_STORE },
1338 { NULL, NULL, NULL, 0, 0, 0 } };
1340 static logic_test_t logic_tests[] = { { &test_xxlxor, "xxlxor", VSX_XOR },
1341 { &test_xxlor, "xxlor", VSX_OR } ,
1342 { &test_xxlnor, "xxlnor", VSX_NOR },
1343 { &test_xxland, "xxland", VSX_AND },
1344 { &test_xxlandc, "xxlandc", VSX_ANDC },
1345 { NULL, NULL, 0}};
1347 static move_test_t move_tests[] = { { &test_xsabsdp, "xsabsdp" },
1348 { &test_xscpsgndp, "xscpsgndp" },
1349 { &test_xsnabsdp, "xsnabsdp" },
1350 { &test_xsnegdp, "xsnegdp" },
1351 { NULL, NULL }
1355 static permute_test_t permute_tests[] =
1357 { &test_xxmrghw, "xxmrghw",
1358 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1359 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1361 { &test_xxmrghw, "xxmrghw",
1362 { 0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff }, /* XA input */
1363 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XB input */
1365 { &test_xxmrglw, "xxmrglw",
1366 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1367 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1369 { &test_xxmrglw, "xxmrglw",
1370 { 0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff}, /* XA input */
1371 { 0x11111111, 0x22222222, 0x33333333, 0x44444444}, /* XB input */
1373 { &test_xxpermdi_00, "xxpermdi DM=00",
1374 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1375 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1377 { &test_xxpermdi_01, "xxpermdi DM=01",
1378 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1379 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1381 { &test_xxpermdi_10, "xxpermdi DM=10",
1382 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1383 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1385 { &test_xxpermdi_11, "xxpermdi DM=11",
1386 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1387 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1389 { &test_xxsldwi_0, "xxsldwi SHW=0",
1390 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1391 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1393 { &test_xxsldwi_1, "xxsldwi SHW=1",
1394 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1395 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1397 { &test_xxsldwi_2, "xxsldwi SHW=2",
1398 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1399 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1401 { &test_xxsldwi_3, "xxsldwi SHW=3",
1402 { 0x11111111, 0x22222222, 0x33333333, 0x44444444 }, /* XA input */
1403 { 0x55555555, 0x66666666, 0x77777777, 0x88888888 }, /* XB input */
1405 { NULL, NULL }
1408 static fp_test_t fp_tests[] = { { &test_fcfids, "fcfids", 1 },
1409 { &test_fcfidus, "fcfidus", 1 },
1410 { &test_fcfidu, "fcfidu", 1 },
1411 { NULL, NULL, 0 },
1415 static vx_fp_test_t vx_fp_tests[] = {
1416 { &test_xscmp, "xscmp", xscmpX_tests, 64, VX_FP_CMP},
1417 { &test_xsadddp, "xsadddp", xsadddp_tests, 64, VX_FP_OTHER},
1418 { &test_xsdivdp, "xsdivdp", xsdivdp_tests, 64, VX_FP_OTHER},
1419 { &test_xsmadd, "xsmadd", xsmaddXdp_tests, 64, VX_FP_SMA},
1420 { &test_xsmsub, "xsmsub", xsmsubXdp_tests, 64, VX_FP_SMS},
1421 { &test_xsnmadd, "xsnmadd", xsnmaddXdp_tests, 64, VX_FP_SNMA},
1422 { & test_xsmuldp, "xsmuldp", xsmuldp_tests, 64, VX_FP_OTHER},
1423 { & test_xssubdp, "xssubdp", xssubdp_tests, 64, VX_FP_OTHER},
1424 { NULL, NULL, NULL, 0, 0 }
1427 static xs_conv_test_t xs_conv_tests[] = {
1428 { &test_xscvdpsxds, "xscvdpsxds", 15},
1429 { &test_xscvsxddp, "xscvsxddp", 15},
1430 { &test_xscvuxddp, "xscvuxddp", 15},
1431 { NULL, NULL, 0}
1434 #ifdef __powerpc64__
1435 static void test_ldbrx(void)
1437 int i;
1438 HWord_t reg_out;
1439 unsigned char * byteIn, * byteOut;
1440 r14 = (HWord_t)viargs;
1441 // Just try the instruction an arbitrary number of times at different r15 offsets.
1442 for (i = 0; i < 3; i++) {
1443 int j, k;
1444 reg_out = 0;
1445 r15 = i * 4;
1446 __asm__ __volatile__ ("ldbrx %0, %1, %2" : "=r" (reg_out): "b" (r14),"r" (r15));
1447 byteIn = ((unsigned char *)(r14 + r15));
1448 byteOut = (unsigned char *)&reg_out;
1450 printf("ldbrx:");
1451 for (k = 0; k < 8; k++) {
1452 printf( " %02x", (byteIn[k]));
1454 printf(" (reverse) =>");
1455 for (j = 0; j < 8; j++) {
1456 printf( " %02x", (byteOut[j]));
1458 printf("\n");
1460 printf( "\n" );
1463 static void
1464 test_popcntd(void)
1466 uint64_t res;
1467 unsigned long long src = 0x9182736405504536ULL;
1468 r14 = src;
1469 __asm__ __volatile__ ("popcntd %0, %1" : "=r" (res): "r" (r14));
1470 printf("popcntd: 0x%llx => %d\n", src, (int)res);
1471 printf( "\n" );
1473 #endif
1475 static void
1476 test_lfiwzx(void)
1478 unsigned int i;
1479 unsigned int * src;
1480 uint64_t reg_out;
1481 r14 = (HWord_t)viargs;
1482 // Just try the instruction an arbitrary number of times at different r15 offsets.
1483 for (i = 0; i < 3; i++) {
1484 reg_out = 0;
1485 r15 = i * 4;
1486 __asm__ __volatile__ ("lfiwzx %0, %1, %2" : "=d" (reg_out): "b" (r14),"r" (r15));
1487 src = ((unsigned int *)(r14 + r15));
1488 printf("lfiwzx: %u => %llu.00\n", *src, (unsigned long long)reg_out);
1491 printf( "\n" );
1494 static void test_vx_fp_ops(void)
1497 test_func_t func;
1498 int k;
1499 char * test_name = (char *)malloc(20);
1500 k = 0;
1502 build_special_fargs_table();
1503 while ((func = vx_fp_tests[k].test_func)) {
1504 int i, condreg, repeat = 0;
1505 unsigned int flags;
1506 unsigned long long * frap, * frbp, * dst;
1507 vx_fp_test_t test_group = vx_fp_tests[k];
1508 vx_fp_test_type test_type = test_group.test_type;
1510 switch (test_type) {
1511 case VX_FP_CMP:
1512 strcpy(test_name, "xscmp");
1513 if (!repeat) {
1514 repeat = 1;
1515 strcat(test_name, "udp");
1516 do_cmpudp = 1;
1518 break;
1519 case VX_FP_SMA:
1520 case VX_FP_SMS:
1521 case VX_FP_SNMA:
1522 if (test_type == VX_FP_SMA)
1523 strcpy(test_name, "xsmadd");
1524 else if (test_type == VX_FP_SMS)
1525 strcpy(test_name, "xsmsub");
1526 else
1527 strcpy(test_name, "xsnmadd");
1528 if (!repeat) {
1529 repeat = 1;
1530 strcat(test_name, "adp");
1531 do_adp = 1;
1533 break;
1534 case VX_FP_OTHER:
1535 strcpy(test_name, test_group.name);
1536 break;
1537 default:
1538 printf("ERROR: Invalid VX FP test type %d\n", test_type);
1539 exit(1);
1542 again:
1543 for (i = 0; i < test_group.num_tests; i++) {
1544 unsigned int * inA, * inB, * pv;
1545 double * dpA = (double *)&vec_inA;
1546 double * dpB = (double *)&vec_inB;
1547 double * dpT = (double *)&vec_out;
1549 fp_test_args_t aTest = test_group.targs[i];
1550 inA = (unsigned int *)&spec_fargs[aTest.fra_idx];
1551 inB = (unsigned int *)&spec_fargs[aTest.frb_idx];
1552 frap = (unsigned long long *)&spec_fargs[aTest.fra_idx];
1553 frbp = (unsigned long long *)&spec_fargs[aTest.frb_idx];
1554 // Only need to copy one doubleword into each vector's element 0
1555 if (isLE) {
1556 // With LE, vector element 0 is the second doubleword from the left
1557 memset(dpA, 0, 8);
1558 memset(dpB, 0, 8);
1559 dpA++;
1560 dpB++;
1562 memcpy(dpA, inA, 8);
1563 memcpy(dpB, inB, 8);
1565 switch (test_type) {
1566 case VX_FP_CMP:
1567 SET_FPSCR_ZERO;
1568 SET_CR_XER_ZERO;
1569 (*func)();
1570 GET_CR(flags);
1571 condreg = (flags & 0x0f000000) >> 24;
1572 printf("#%d: %s %016llx <=> %016llx ? %x (CRx)\n", i, test_name, *frap, *frbp, condreg);
1573 // printf("\tFRA: %e; FRB: %e\n", spec_fargs[aTest.fra_idx], spec_fargs[aTest.frb_idx]);
1574 if ( condreg != aTest.cr_flags) {
1575 printf("Error: Expected CR flags 0x%x; actual flags: 0x%x\n", aTest.cr_flags, condreg);
1577 break;
1578 case VX_FP_SMA:
1579 case VX_FP_SMS:
1580 case VX_FP_SNMA:
1581 case VX_FP_OTHER:
1583 int idx;
1584 unsigned long long vsr_XT;
1585 pv = (unsigned int *)&vec_out;
1586 // clear vec_out
1587 for (idx = 0; idx < 4; idx++, pv++)
1588 *pv = 0;
1590 if (test_type != VX_FP_OTHER) {
1591 /* Then we need a third src argument, which is stored in element 0 of
1592 * VSX[XT] -- i.e., vec_out. For the xs<ZZZ>mdp cases, VSX[XT] holds
1593 * src3 and VSX[XB] holds src2; for the xs<ZZZ>adp cases, VSX[XT] holds
1594 * src2 and VSX[XB] holds src3. The fp_test_args_t that holds the test
1595 * data (input args) contain only two inputs, so I arbitrarily
1596 * use spec_fargs elements 4 and 14 (alternating) for the third source
1597 * argument. We can use the same input data for a given pair of
1598 * adp/mdp-type instructions by swapping the src2 and src3 arguments; thus
1599 * the expected result should be the same.
1601 int extra_arg_idx;
1602 if (i % 2)
1603 extra_arg_idx = 4;
1604 else
1605 extra_arg_idx = 14;
1607 if (repeat) {
1608 /* We're on the first time through of one of the VX_FP_SMx
1609 * test types, meaning we're testing a xs<ZZZ>adp case, thus we
1610 * have to swap inputs as described above:
1611 * src2 <= VSX[XT]
1612 * src3 <= VSX[XB]
1614 if (isLE)
1615 dpT++;
1616 memcpy(dpT, inB, 8); // src2
1617 memcpy(dpB, &spec_fargs[extra_arg_idx], 8); //src3
1618 frbp = (unsigned long long *)&spec_fargs[extra_arg_idx];
1619 } else {
1620 // Don't need to init src2, as it's done before the switch()
1621 if (isLE)
1622 dpT++;
1623 memcpy(dpT, &spec_fargs[extra_arg_idx], 8); //src3
1625 memcpy(&vsr_XT, dpT, 8);
1628 (*func)();
1629 dst = (unsigned long long *) &vec_out;
1630 if (isLE)
1631 dst++;
1632 if (test_type == VX_FP_OTHER)
1633 printf("#%d: %s %016llx %016llx = %016llx\n", i, test_name, *frap, *frbp, *dst);
1634 else
1635 printf( "#%d: %s %016llx %016llx %016llx = %016llx\n", i,
1636 test_name, vsr_XT, *frap, *frbp, *dst );
1640 // Debug code. Keep this block commented out except when debugging.
1641 double result, expected;
1642 memcpy(&result, dst, 8);
1643 memcpy(&expected, &aTest.dp_bin_result, 8);
1644 printf( "\tFRA + FRB: %e + %e: Expected = %e; Actual = %e\n",
1645 spec_fargs[aTest.fra_idx], spec_fargs[aTest.frb_idx],
1646 expected, result );
1649 break;
1655 printf( "\n" );
1657 if (repeat) {
1658 repeat = 0;
1659 switch (test_type) {
1660 case VX_FP_CMP:
1661 strcpy(test_name, "xscmp");
1662 strcat(test_name, "odp");
1663 do_cmpudp = 0;
1664 break;
1665 case VX_FP_SMA:
1666 case VX_FP_SMS:
1667 case VX_FP_SNMA:
1668 if (test_type == VX_FP_SMA)
1669 strcpy(test_name, "xsmadd");
1670 else if (test_type == VX_FP_SMS)
1671 strcpy(test_name, "xsmsub");
1672 else
1673 strcpy(test_name, "xsnmadd");
1674 strcat(test_name, "mdp");
1675 do_adp = 0;
1676 break;
1677 case VX_FP_OTHER:
1678 break;
1680 goto again;
1682 k++;
1684 printf( "\n" );
1685 free(test_name);
1688 static void test_xs_conv_ops(void)
1691 test_func_t func;
1692 int k = 0;
1693 double * dpB = (double *)&vec_inB;
1694 if (isLE) {
1695 memset(dpB, 0, 8);
1696 dpB++;
1699 build_special_fargs_table();
1700 while ((func = xs_conv_tests[k].test_func)) {
1701 int i;
1702 unsigned long long * frbp, * dst;
1703 xs_conv_test_t test_group = xs_conv_tests[k];
1704 for (i = 0; i < test_group.num_tests; i++) {
1705 unsigned int * inB, * pv;
1706 int idx;
1707 inB = (unsigned int *)&spec_fargs[i];
1708 frbp = (unsigned long long *)&spec_fargs[i];
1710 memcpy(dpB, inB, 8);
1711 pv = (unsigned int *)&vec_out;
1712 // clear vec_out
1713 for (idx = 0; idx < 4; idx++, pv++)
1714 *pv = 0;
1715 (*func)();
1716 dst = (unsigned long long *) &vec_out;
1717 if (isLE)
1718 dst++;
1719 printf("#%d: %s %016llx => %016llx\n", i, test_group.name, *frbp, *dst);
1722 k++;
1723 printf("\n");
1725 printf( "\n" );
1728 static void do_load_test(ldst_test_t loadTest)
1730 test_func_t func;
1731 unsigned int *src, *dst;
1732 int splat = loadTest.type == VSX_LOAD_SPLAT ? 1: 0;
1733 int i, j, m, k;
1734 i = j = 0;
1736 func = loadTest.test_func;
1737 for (i = 0, r14 = (HWord_t) loadTest.base_addr; i < NUM_VIARGS_VECS; i++) {
1738 int again;
1739 j = 0;
1740 r14 += i * 16;
1741 do {
1742 unsigned int * pv = (unsigned int *)&vec_out;
1743 int idx;
1744 // clear vec_out
1745 for (idx = 0; idx < 4; idx++, pv+=idx)
1746 *pv = 0;
1748 again = 0;
1749 r15 = j;
1751 // execute test insn
1752 (*func)();
1754 src = (unsigned int*) (((unsigned char *)r14) + j);
1755 dst = (unsigned int*) &vec_out;
1757 printf( "%s:", loadTest.name);
1758 for (m = 0; m < loadTest.num_words_to_process; m++) {
1759 printf( " %08x", src[splat ? m % 2 : m]);
1761 printf( " =>");
1762 m = 0;
1763 k = loadTest.num_words_to_process;
1764 if (isLE) {
1765 if (loadTest.num_words_to_process == 2) {
1766 m = 2;
1767 k += 2;
1771 for (; m < k; m++) {
1772 printf( " %08x", dst[m]);
1774 printf("\n");
1775 if (j == 0 && loadTest.offset) {
1776 again = 1;
1777 j += loadTest.offset;
1780 while (again);
1784 static void
1785 do_store_test ( ldst_test_t storeTest )
1787 test_func_t func;
1788 unsigned int *src, *dst;
1789 int m;
1791 func = storeTest.test_func;
1792 r14 = (HWord_t) storeTest.base_addr;
1793 r15 = (HWord_t) storeTest.offset;
1794 unsigned int * pv = (unsigned int *) storeTest.base_addr;
1795 int idx;
1796 // clear out storage destination
1797 for (idx = 0; idx < 4; idx++, pv += idx)
1798 *pv = 0;
1800 memcpy(&vec_inA, &viargs[0], sizeof(vector unsigned char));
1802 // execute test insn
1803 (*func)();
1804 src = &viargs[0];
1805 dst = (unsigned int*) (((unsigned char *) r14) + storeTest.offset);
1807 printf( "%s:", storeTest.name );
1808 for (m = 0; m < storeTest.num_words_to_process; m++) {
1809 printf( " %08x", src[m] );
1811 printf( " =>" );
1812 for (m = 0; m < storeTest.num_words_to_process; m++) {
1813 printf( " %08x", dst[m] );
1815 printf( "\n" );
1819 static void test_ldst(void)
1821 int k = 0;
1823 while (ldst_tests[k].test_func) {
1824 if (ldst_tests[k].type == VSX_STORE)
1825 do_store_test(ldst_tests[k]);
1826 else
1827 do_load_test(ldst_tests[k]);
1828 k++;
1829 printf("\n");
1833 static void test_ftdiv(void)
1835 int i, num_tests, crx;
1836 unsigned int flags;
1837 unsigned long long * frap, * frbp;
1838 build_special_fargs_table();
1840 num_tests = sizeof ftdiv_tests/sizeof ftdiv_tests[0];
1842 for (i = 0; i < num_tests; i++) {
1843 fp_test_args_t aTest = ftdiv_tests[i];
1844 f14 = spec_fargs[aTest.fra_idx];
1845 f15 = spec_fargs[aTest.frb_idx];
1846 frap = (unsigned long long *)&spec_fargs[aTest.fra_idx];
1847 frbp = (unsigned long long *)&spec_fargs[aTest.frb_idx];
1848 SET_FPSCR_ZERO;
1849 SET_CR_XER_ZERO;
1850 __asm__ __volatile__ ("ftdiv cr1, %0, %1" : : "d" (f14), "d" (f15));
1851 GET_CR(flags);
1852 crx = (flags & 0x0f000000) >> 24;
1853 printf( "ftdiv: %016llx <=> %016llx ? %x (CRx)\n", *frap, *frbp, crx);
1854 // printf("\tFRA: %e; FRB: %e\n", f14, f15);
1855 if ( crx != aTest.cr_flags) {
1856 printf("Error: Expected CR flags 0x%x; actual flags: 0x%x\n", aTest.cr_flags, crx);
1859 printf( "\n" );
1863 static void test_p7_fpops ( void )
1865 int k = 0;
1866 test_func_t func;
1868 build_fargs_table();
1869 while ((func = fp_tests[k].test_func)) {
1870 float res;
1871 double resd;
1872 unsigned long long u0;
1873 int i;
1874 // fcfids - 64-bit fp converted to inf precise fp integer, rounded to SP. (32)
1875 // fcfidus - 64-bit fp converted to inf precise fp integer, rounded to SP. (32)
1876 // fcfidu - 64-bit fp converted to inf precise fp integer, rounded to DP. (64)
1877 int res32 = (
1878 (strcmp(fp_tests[k].name, "fcfids")==0) ||
1879 (strcmp(fp_tests[k].name, "fcfidus")==0) );
1881 for (i = 0; i < nb_fargs; i++) {
1882 u0 = *(unsigned long long *) (&fargs[i]);
1883 f14 = fargs[i];
1884 (*func)();
1885 if (res32) {
1886 res = f17;
1887 printf( "%s %016llx => (raw sp) %08x)",
1888 fp_tests[k].name, u0, *((unsigned int *)&res));
1889 } else {
1890 resd = f17;
1891 printf( "%s %016llx => (raw sp) %016llx)",
1892 fp_tests[k].name, u0, *(unsigned long long *)(&resd));
1894 printf( "\n" );
1897 k++;
1898 printf( "\n" );
1902 static void test_vsx_logic(void)
1904 logic_test_t aTest;
1905 test_func_t func;
1906 int k;
1907 k = 0;
1909 while ((func = logic_tests[k].test_func)) {
1910 unsigned int * pv;
1911 int startA, startB;
1912 unsigned int * inA, * inB, * dst;
1913 int idx, i;
1914 startA = 0;
1915 aTest = logic_tests[k];
1916 for (i = 0; i <= (NUM_VIARGS_INTS - (NUM_VIARGS_VECS * sizeof(int))); i++, startA++) {
1917 startB = startA + 4;
1918 pv = (unsigned int *)&vec_out;
1919 inA = &viargs[startA];
1920 inB = &viargs[startB];
1921 memcpy(&vec_inA, inA, sizeof(vector unsigned char));
1922 memcpy(&vec_inB, inB, sizeof(vector unsigned char));
1923 // clear vec_out
1924 for (idx = 0; idx < 4; idx++, pv++)
1925 *pv = 0;
1927 // execute test insn
1928 (*func)();
1929 dst = (unsigned int*) &vec_out;
1931 printf( "%s:", aTest.name);
1932 printf( " %08x %08x %08x %08x %s", inA[0], inA[1], inA[2], inA[3], aTest.name);
1933 printf( " %08x %08x %08x %08x", inB[0], inB[1], inB[2], inB[3]);
1934 printf(" => %08x %08x %08x %08x\n", dst[0], dst[1], dst[2], dst[3]);
1937 k++;
1939 printf( "\n" );
1942 static vector unsigned long long vec_args[] __attribute__ ((aligned (16))) =
1944 { 0x0123456789abcdefULL, 0x0011223344556677ULL},
1945 { 0x8899aabb19293942ULL, 0xa1a2a3a4b1b2b3b4ULL},
1946 { 0xc1c2c3c4d1d2d3d4ULL, 0x7a6b5d3efc032778ULL}
1948 #define NUM_VEC_ARGS_LONGS (sizeof vec_args/sizeof vec_args[0])
1950 static void test_move_ops (void)
1952 move_test_t aTest;
1953 test_func_t func;
1954 int k;
1955 k = 0;
1957 while ((func = move_tests[k].test_func)) {
1958 unsigned int * pv;
1959 int startA, startB;
1960 unsigned long long * inA, * inB, * dst;
1961 int use_vecA = (strcmp(move_tests[k].name, "xscpsgndp") == 0);
1962 int idx;
1963 inA = NULL;
1964 aTest = move_tests[k];
1965 for (startB = 0; startB < NUM_VEC_ARGS_LONGS; startB++) {
1966 inB = (unsigned long long *)&vec_args[startB];
1967 memcpy(&vec_inB, inB, sizeof(vector unsigned char));
1968 if (isLE)
1969 inB++;
1970 startA = 0;
1971 repeat:
1972 if (use_vecA) {
1973 inA = (unsigned long long *)&vec_args[startA];
1974 memcpy(&vec_inA, inA, sizeof(vector unsigned char));
1975 startA++;
1977 pv = (unsigned int *)&vec_out;
1978 // clear vec_out
1979 for (idx = 0; idx < 4; idx++, pv++)
1980 *pv = 0;
1982 // execute test insn
1983 (*func)();
1984 dst = (unsigned long long *) &vec_out;
1985 if (isLE) {
1986 dst++;
1987 inA++;
1990 printf( "%s:", aTest.name);
1991 if (use_vecA)
1992 printf( " X[A]: %016llx ", *inA);
1993 printf( " X[B]: %016llx", *inB);
1994 printf(" => %016llx\n", *dst);
1996 if (use_vecA && startA < NUM_VEC_ARGS_LONGS)
1997 goto repeat;
1999 k++;
2000 printf( "\n" );
2004 static void test_permute_ops (void)
2006 permute_test_t *aTest;
2007 unsigned int *dst = (unsigned int *) &vec_out;
2009 for (aTest = &(permute_tests[0]); aTest->test_func != NULL; aTest++)
2011 /* Grab test input and clear output vector. */
2012 memcpy(&vec_inA, aTest->xa, sizeof(vec_inA));
2013 memcpy(&vec_inB, aTest->xb, sizeof(vec_inB));
2014 memset(dst, 0, sizeof(vec_out));
2016 /* execute test insn */
2017 aTest->test_func();
2019 printf( "%s:\n", aTest->name);
2020 printf( " XA[%08x,%08x,%08x,%08x]\n",
2021 aTest->xa[0], aTest->xa[1], aTest->xa[2], aTest->xa[3]);
2022 printf( " XB[%08x,%08x,%08x,%08x]\n",
2023 aTest->xb[0], aTest->xb[1], aTest->xb[2], aTest->xb[3]);
2024 printf( " => XT[%08x,%08x,%08x,%08x]\n",
2025 dst[0], dst[1], dst[2], dst[3]);
2028 printf( "\n" );
2031 static test_table_t all_tests[] = { { &test_ldst,
2032 "Test VSX load/store instructions" },
2033 { &test_vsx_logic,
2034 "Test VSX logic instructions" },
2035 #ifdef __powerpc64__
2036 { &test_ldbrx,
2037 "Test ldbrx instruction" },
2038 { &test_popcntd,
2039 "Test popcntd instruction" },
2040 #endif
2041 { &test_lfiwzx,
2042 "Test lfiwzx instruction" },
2043 { &test_p7_fpops,
2044 "Test P7 floating point convert instructions"},
2045 { &test_ftdiv,
2046 "Test ftdiv instruction" },
2047 { &test_move_ops,
2048 "Test VSX move instructions"},
2049 { &test_permute_ops,
2050 "Test VSX permute instructions"},
2051 { &test_vx_fp_ops,
2052 "Test VSX floating point instructions"},
2053 { &test_xs_conv_ops,
2054 "Test VSX scalar integer conversion instructions" },
2055 { NULL, NULL }
2057 #endif // HAS_VSX
2059 int main(int argc, char *argv[])
2061 #ifdef HAS_VSX
2063 test_table_t aTest;
2064 test_func_t func;
2065 int i = 0;
2067 while ((func = all_tests[i].test_category)) {
2068 aTest = all_tests[i];
2069 printf( "%s\n", aTest.name );
2070 (*func)();
2071 i++;
2074 #endif // HAS _VSX
2076 return 0;