1 2 /* HOW TO COMPILE FOR SWITCHBACK: 3 4 gcc -O -c test_ppc_jm1.c -mregnames -Wall 5 6 */ 7 8 #undef HAS_ALTIVEC 9 #define NO_FLOAT 10 #undef IS_PPC405 11 12 13 /* 14 * test-ppc.c: 15 * PPC tests for qemu-PPC CPU emulation checks 16 * 17 * Copyright (c) 2005 Jocelyn Mayer 18 * 19 * This program is free software; you can redistribute it and/or 20 * modify it under the terms of the GNU General Public License V2 21 * as published by the Free Software Foundation. 22 */ 23 24 /* 25 * Theory of operations: 26 * a few registers are reserved for the test program: 27 * r14 => r18 28 * f14 => f18 29 * I do preload test values in r14 thru r17 (or less, depending on the number 30 * of register operands needed), patch the test opcode if any immediate 31 * operands are required, execute the tested opcode. 32 * XER, CCR and FPSCR are cleared before every test. 33 * I always get the result in r17 and also save XER and CCR for fixed-point 34 * operations. I also check FPSCR for floating points operations. 35 * 36 * Improvments: 37 * a more cleaver FPSCR management is needed: for now, I always test 38 * the round-to-zero case. Other rounding modes also need to be tested. 39 */ 40 41 #include <stdint.h> 42 //#include <stdlib.h> 43 //#include <stdio.h> 44 //#include <string.h> 45 //#include <unistd.h> 46 //#include <fcntl.h> 47 //#include <ctype.h> 48 //#include <math.h> 49 //#include <fenv.h> 50 51 #define NULL ((void*)0) 52 53 //#include "test-ppc.h" 54 55 // BEGIN #include "test-ppc.h" 56 /* 57 * test-ppc.h: 58 * PPC tests for qemu-PPC CPU emulation checks - definitions 59 * 60 * Copyright (c) 2005 Jocelyn Mayer 61 * 62 * This program is free software; you can redistribute it and/or 63 * modify it under the terms of the GNU General Public License V2 64 * as published by the Free Software Foundation. 65 */ 66 67 #if !defined (__TEST_PPC_H__) 68 #define __TEST_PPC_H__ 69 70 typedef void (*test_func_t) (void); 71 typedef struct test_t test_t; 72 typedef struct test_table_t test_table_t; 73 struct test_t { 74 test_func_t func; 75 const unsigned char *name; 76 }; 77 78 struct test_table_t { 79 test_t *tests; 80 const unsigned char *name; 81 int flags; 82 }; 83 84 typedef void (*test_loop_t) (const unsigned char *name, test_func_t func); 85 86 enum test_flags { 87 /* Nb arguments */ 88 PPC_ONE_ARG = 0x00000001, 89 PPC_TWO_ARGS = 0x00000002, 90 PPC_THREE_ARGS = 0x00000003, 91 PPC_CMP_ARGS = 0x00000004, 92 PPC_CMPI_ARGS = 0x00000005, 93 PPC_TWO_I16 = 0x00000006, 94 PPC_SPECIAL = 0x00000007, 95 PPC_NB_ARGS = 0x0000000F, 96 /* Type */ 97 PPC_ARITH = 0x00000100, 98 PPC_LOGICAL = 0x00000200, 99 PPC_COMPARE = 0x00000300, 100 PPC_CROP = 0x00000400, 101 PPC_TYPE = 0x00000F00, 102 /* Family */ 103 PPC_INTEGER = 0x00010000, 104 PPC_FLOAT = 0x00020000, 105 PPC_405 = 0x00030000, 106 PPC_ALTIVEC = 0x00040000, 107 PPC_FALTIVEC = 0x00050000, 108 PPC_FAMILY = 0x000F0000, 109 /* Flags */ 110 PPC_CR = 0x01000000, 111 }; 112 113 #endif /* !defined (__TEST_PPC_H__) */ 114 115 // END #include "test-ppc.h" 116 117 118 119 120 //#define DEBUG_ARGS_BUILD 121 #if defined (DEBUG_ARGS_BUILD) 122 #define AB_DPRINTF(fmt, args...) do { vexxx_printf(fmt , ##args); } while (0) 123 #else 124 #define AB_DPRINTF(fmt, args...) do { } while (0) 125 #endif 126 127 //#define DEBUG_FILTER 128 #if defined (DEBUG_FILTER) 129 #define FDPRINTF(fmt, args...) do { vexxx_printf(fmt , ##args); } while (0) 130 #else 131 #define FDPRINTF(fmt, args...) do { } while (0) 132 #endif 133 134 #if !defined (NO_FLOAT) 135 register double f14 __asm__ ("f14"); 136 register double f15 __asm__ ("f15"); 137 register double f16 __asm__ ("f16"); 138 register double f17 __asm__ ("f17"); 139 register double f18 __asm__ ("f18"); 140 #endif 141 register uint32_t r14 __asm__ ("r14"); 142 register uint32_t r15 __asm__ ("r15"); 143 register uint32_t r16 __asm__ ("r16"); 144 register uint32_t r17 __asm__ ("r17"); 145 register uint32_t r18 __asm__ ("r18"); 146 147 148 ///////////////////////////////////////////////////////////////////// 149 ///////////////////////////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////// 151 ///////////////////////////////////////////////////////////////////// 152 153 /* Something which has the same size as void* on the host. That is, 154 it is 32 bits on a 32-bit host and 64 bits on a 64-bit host, and so 155 it can safely be coerced to and from a pointer type on the host 156 machine. */ 157 typedef unsigned long HWord; 158 typedef char HChar; 159 typedef signed int Int; 160 typedef unsigned int UInt; 161 typedef unsigned char UChar; 162 163 typedef signed long long int Long; 164 typedef unsigned long long int ULong; 165 166 typedef unsigned char Bool; 167 #define True ((Bool)1) 168 #define False ((Bool)0) 169 170 171 //#include "/home/sewardj/VEX/trunk/pub/libvex_basictypes.h" 172 173 static HWord (*serviceFn)(HWord,HWord) = 0; 174 175 static Bool my_isspace ( UChar c ) 176 { 177 return c == ' ' 178 || c == '\f' 179 || c == '\n' 180 || c == '\r' 181 || c == '\t' 182 || c == '\v'; 183 } 184 185 #if 0 // unused 186 static char* my_strcpy ( char* dest, const char* src ) 187 { 188 char* dest_orig = dest; 189 while (*src) *dest++ = *src++; 190 *dest = 0; 191 return dest_orig; 192 } 193 194 static void* my_memcpy ( void *dest, const void *src, int sz ) 195 { 196 const char *s = (const char *)src; 197 char *d = (char *)dest; 198 199 while (sz--) 200 *d++ = *s++; 201 202 return dest; 203 } 204 205 static void* my_memmove( void *dst, const void *src, unsigned int len ) 206 { 207 register char *d; 208 register char *s; 209 if ( dst > src ) { 210 d = (char *)dst + len - 1; 211 s = (char *)src + len - 1; 212 while ( len >= 4 ) { 213 *d-- = *s--; 214 *d-- = *s--; 215 *d-- = *s--; 216 *d-- = *s--; 217 len -= 4; 218 } 219 while ( len-- ) { 220 *d-- = *s--; 221 } 222 } else if ( dst < src ) { 223 d = (char *)dst; 224 s = (char *)src; 225 while ( len >= 4 ) { 226 *d++ = *s++; 227 *d++ = *s++; 228 *d++ = *s++; 229 *d++ = *s++; 230 len -= 4; 231 } 232 while ( len-- ) { 233 *d++ = *s++; 234 } 235 } 236 return dst; 237 } 238 #endif 239 240 char* my_strcat ( char* dest, const char* src ) 241 { 242 char* dest_orig = dest; 243 while (*dest) dest++; 244 while (*src) *dest++ = *src++; 245 *dest = 0; 246 return dest_orig; 247 } 248 249 int my_strcmp ( const char* s1, const char* s2 ) 250 { 251 register unsigned char c1; 252 register unsigned char c2; 253 while (True) { 254 c1 = *(unsigned char *)s1; 255 c2 = *(unsigned char *)s2; 256 if (c1 != c2) break; 257 if (c1 == 0) break; 258 s1++; s2++; 259 } 260 if ((unsigned char)c1 < (unsigned char)c2) return -1; 261 if ((unsigned char)c1 > (unsigned char)c2) return 1; 262 return 0; 263 } 264 265 266 int my_memcmp ( const void *s1V, const void *s2V, int n ) 267 { 268 int res; 269 unsigned char a0; 270 unsigned char b0; 271 unsigned char* s1 = (unsigned char*)s1V; 272 unsigned char* s2 = (unsigned char*)s2V; 273 274 while (n != 0) { 275 a0 = s1[0]; 276 b0 = s2[0]; 277 s1 += 1; 278 s2 += 1; 279 res = ((int)a0) - ((int)b0); 280 if (res != 0) 281 return res; 282 n -= 1; 283 } 284 return 0; 285 } 286 287 char* my_strchr ( const char* s, int c ) 288 { 289 UChar ch = (UChar)((UInt)c); 290 UChar* p = (UChar*)s; 291 while (True) { 292 if (*p == ch) return p; 293 if (*p == 0) return NULL; 294 p++; 295 } 296 } 297 298 void* my_malloc ( int n ) 299 { 300 void* r = (void*) (*serviceFn)(2,n); 301 return r; 302 } 303 304 305 ///////////////////////////////////////////////////////////////////// 306 307 static void vexxx_log_bytes ( char* p, int n ) 308 { 309 int i; 310 for (i = 0; i < n; i++) 311 (*serviceFn)( 1, (int)p[i] ); 312 } 313 314 /*---------------------------------------------------------*/ 315 /*--- vexxx_printf ---*/ 316 /*---------------------------------------------------------*/ 317 318 /* This should be the only <...> include in the entire VEX library. 319 New code for vex_util.c should go above this point. */ 320 #include <stdarg.h> 321 322 static HChar vexxx_toupper ( HChar c ) 323 { 324 if (c >= 'a' && c <= 'z') 325 return c + ('A' - 'a'); 326 else 327 return c; 328 } 329 330 static Int vexxx_strlen ( const HChar* str ) 331 { 332 Int i = 0; 333 while (str[i] != 0) i++; 334 return i; 335 } 336 337 Bool vexxx_streq ( const HChar* s1, const HChar* s2 ) 338 { 339 while (True) { 340 if (*s1 == 0 && *s2 == 0) 341 return True; 342 if (*s1 != *s2) 343 return False; 344 s1++; 345 s2++; 346 } 347 } 348 349 /* Some flags. */ 350 #define VG_MSG_SIGNED 1 /* The value is signed. */ 351 #define VG_MSG_ZJUSTIFY 2 /* Must justify with '0'. */ 352 #define VG_MSG_LJUSTIFY 4 /* Must justify on the left. */ 353 #define VG_MSG_PAREN 8 /* Parenthesize if present (for %y) */ 354 #define VG_MSG_COMMA 16 /* Add commas to numbers (for %d, %u) */ 355 356 /* Copy a string into the buffer. */ 357 static UInt 358 myvprintf_str ( void(*send)(HChar), Int flags, Int width, HChar* str, 359 Bool capitalise ) 360 { 361 # define MAYBE_TOUPPER(ch) (capitalise ? vexxx_toupper(ch) : (ch)) 362 UInt ret = 0; 363 Int i, extra; 364 Int len = vexxx_strlen(str); 365 366 if (width == 0) { 367 ret += len; 368 for (i = 0; i < len; i++) 369 send(MAYBE_TOUPPER(str[i])); 370 return ret; 371 } 372 373 if (len > width) { 374 ret += width; 375 for (i = 0; i < width; i++) 376 send(MAYBE_TOUPPER(str[i])); 377 return ret; 378 } 379 380 extra = width - len; 381 if (flags & VG_MSG_LJUSTIFY) { 382 ret += extra; 383 for (i = 0; i < extra; i++) 384 send(' '); 385 } 386 ret += len; 387 for (i = 0; i < len; i++) 388 send(MAYBE_TOUPPER(str[i])); 389 if (!(flags & VG_MSG_LJUSTIFY)) { 390 ret += extra; 391 for (i = 0; i < extra; i++) 392 send(' '); 393 } 394 395 # undef MAYBE_TOUPPER 396 397 return ret; 398 } 399 400 /* Write P into the buffer according to these args: 401 * If SIGN is true, p is a signed. 402 * BASE is the base. 403 * If WITH_ZERO is true, '0' must be added. 404 * WIDTH is the width of the field. 405 */ 406 static UInt 407 myvprintf_int64 ( void(*send)(HChar), Int flags, Int base, Int width, ULong pL) 408 { 409 HChar buf[40]; 410 Int ind = 0; 411 Int i, nc = 0; 412 Bool neg = False; 413 HChar *digits = "0123456789ABCDEF"; 414 UInt ret = 0; 415 UInt p = (UInt)pL; 416 417 if (base < 2 || base > 16) 418 return ret; 419 420 if ((flags & VG_MSG_SIGNED) && (Int)p < 0) { 421 p = - (Int)p; 422 neg = True; 423 } 424 425 if (p == 0) 426 buf[ind++] = '0'; 427 else { 428 while (p > 0) { 429 if ((flags & VG_MSG_COMMA) && 10 == base && 430 0 == (ind-nc) % 3 && 0 != ind) 431 { 432 buf[ind++] = ','; 433 nc++; 434 } 435 buf[ind++] = digits[p % base]; 436 p /= base; 437 } 438 } 439 440 if (neg) 441 buf[ind++] = '-'; 442 443 if (width > 0 && !(flags & VG_MSG_LJUSTIFY)) { 444 for(; ind < width; ind++) { 445 //vassert(ind < 39); 446 buf[ind] = ((flags & VG_MSG_ZJUSTIFY) ? '0': ' '); 447 } 448 } 449 450 /* Reverse copy to buffer. */ 451 ret += ind; 452 for (i = ind -1; i >= 0; i--) { 453 send(buf[i]); 454 } 455 if (width > 0 && (flags & VG_MSG_LJUSTIFY)) { 456 for(; ind < width; ind++) { 457 ret++; 458 send(' '); // Never pad with zeroes on RHS -- changes the value! 459 } 460 } 461 return ret; 462 } 463 464 465 /* A simple vprintf(). */ 466 static 467 UInt vprintf_wrk ( void(*send)(HChar), const HChar *format, va_list vargs ) 468 { 469 UInt ret = 0; 470 int i; 471 int flags; 472 int width; 473 Bool is_long; 474 475 /* We assume that vargs has already been initialised by the 476 caller, using va_start, and that the caller will similarly 477 clean up with va_end. 478 */ 479 480 for (i = 0; format[i] != 0; i++) { 481 if (format[i] != '%') { 482 send(format[i]); 483 ret++; 484 continue; 485 } 486 i++; 487 /* A '%' has been found. Ignore a trailing %. */ 488 if (format[i] == 0) 489 break; 490 if (format[i] == '%') { 491 /* `%%' is replaced by `%'. */ 492 send('%'); 493 ret++; 494 continue; 495 } 496 flags = 0; 497 is_long = False; 498 width = 0; /* length of the field. */ 499 if (format[i] == '(') { 500 flags |= VG_MSG_PAREN; 501 i++; 502 } 503 /* If ',' follows '%', commas will be inserted. */ 504 if (format[i] == ',') { 505 flags |= VG_MSG_COMMA; 506 i++; 507 } 508 /* If '-' follows '%', justify on the left. */ 509 if (format[i] == '-') { 510 flags |= VG_MSG_LJUSTIFY; 511 i++; 512 } 513 /* If '0' follows '%', pads will be inserted. */ 514 if (format[i] == '0') { 515 flags |= VG_MSG_ZJUSTIFY; 516 i++; 517 } 518 /* Compute the field length. */ 519 while (format[i] >= '0' && format[i] <= '9') { 520 width *= 10; 521 width += format[i++] - '0'; 522 } 523 while (format[i] == 'l') { 524 i++; 525 is_long = True; 526 } 527 528 switch (format[i]) { 529 case 'd': /* %d */ 530 flags |= VG_MSG_SIGNED; 531 if (is_long) 532 ret += myvprintf_int64(send, flags, 10, width, 533 (ULong)(va_arg (vargs, Long))); 534 else 535 ret += myvprintf_int64(send, flags, 10, width, 536 (ULong)(va_arg (vargs, Int))); 537 break; 538 case 'u': /* %u */ 539 if (is_long) 540 ret += myvprintf_int64(send, flags, 10, width, 541 (ULong)(va_arg (vargs, ULong))); 542 else 543 ret += myvprintf_int64(send, flags, 10, width, 544 (ULong)(va_arg (vargs, UInt))); 545 break; 546 case 'p': /* %p */ 547 ret += 2; 548 send('0'); 549 send('x'); 550 ret += myvprintf_int64(send, flags, 16, width, 551 (ULong)((HWord)va_arg (vargs, void *))); 552 break; 553 case 'x': /* %x */ 554 if (is_long) 555 ret += myvprintf_int64(send, flags, 16, width, 556 (ULong)(va_arg (vargs, ULong))); 557 else 558 ret += myvprintf_int64(send, flags, 16, width, 559 (ULong)(va_arg (vargs, UInt))); 560 break; 561 case 'c': /* %c */ 562 ret++; 563 send((va_arg (vargs, int))); 564 break; 565 case 's': case 'S': { /* %s */ 566 char *str = va_arg (vargs, char *); 567 if (str == (char*) 0) str = "(null)"; 568 ret += myvprintf_str(send, flags, width, str, 569 (format[i]=='S')); 570 break; 571 } 572 # if 0 573 case 'y': { /* %y - print symbol */ 574 Addr a = va_arg(vargs, Addr); 575 576 HChar *name; 577 if (VG_(get_fnname_w_offset)(a, &name)) { 578 HChar buf[1 + VG_strlen(name) + 1 + 1]; 579 if (flags & VG_MSG_PAREN) { 580 VG_(sprintf)(str, "(%s)", name): 581 } else { 582 VG_(sprintf)(str, "%s", name): 583 } 584 ret += myvprintf_str(send, flags, width, buf, 0); 585 } 586 break; 587 } 588 # endif 589 default: 590 break; 591 } 592 } 593 return ret; 594 } 595 596 597 /* A general replacement for printf(). Note that only low-level 598 debugging info should be sent via here. The official route is to 599 to use vg_message(). This interface is deprecated. 600 */ 601 static HChar myprintf_buf[1000]; 602 static Int n_myprintf_buf; 603 604 static void add_to_myprintf_buf ( HChar c ) 605 { 606 if (c == '\n' || n_myprintf_buf >= 1000-10 /*paranoia*/ ) { 607 (*vexxx_log_bytes)( myprintf_buf, vexxx_strlen(myprintf_buf) ); 608 n_myprintf_buf = 0; 609 myprintf_buf[n_myprintf_buf] = 0; 610 } 611 myprintf_buf[n_myprintf_buf++] = c; 612 myprintf_buf[n_myprintf_buf] = 0; 613 } 614 615 static UInt vexxx_printf ( const char *format, ... ) 616 { 617 UInt ret; 618 va_list vargs; 619 va_start(vargs,format); 620 621 n_myprintf_buf = 0; 622 myprintf_buf[n_myprintf_buf] = 0; 623 ret = vprintf_wrk ( add_to_myprintf_buf, format, vargs ); 624 625 if (n_myprintf_buf > 0) { 626 (*vexxx_log_bytes)( myprintf_buf, n_myprintf_buf ); 627 } 628 629 va_end(vargs); 630 631 return ret; 632 } 633 634 /*---------------------------------------------------------------*/ 635 /*--- end vex_util.c ---*/ 636 /*---------------------------------------------------------------*/ 637 638 639 ///////////////////////////////////////////////////////////////////// 640 ///////////////////////////////////////////////////////////////////// 641 ///////////////////////////////////////////////////////////////////// 642 ///////////////////////////////////////////////////////////////////// 643 644 // BEGIN #include "ops-ppc.c" 645 /* 646 * WARNING: 647 * This file has been auto-generated by './gen-ppc' program 648 * Please don't edit by hand 649 */ 650 651 652 //BEGIN #include "test-ppc.h" 653 /* 654 * test-ppc.h: 655 * PPC tests for qemu-PPC CPU emulation checks - definitions 656 * 657 * Copyright (c) 2005 Jocelyn Mayer 658 * 659 * This program is free software; you can redistribute it and/or 660 * modify it under the terms of the GNU General Public License V2 661 * as published by the Free Software Foundation. 662 */ 663 664 #if !defined (__TEST_PPC_H__) 665 #define __TEST_PPC_H__ 666 667 typedef void (*test_func_t) (void); 668 typedef struct test_t test_t; 669 typedef struct test_table_t test_table_t; 670 struct test_t { 671 test_func_t func; 672 const unsigned char *name; 673 }; 674 675 struct test_table_t { 676 test_t *tests; 677 const unsigned char *name; 678 int flags; 679 }; 680 681 typedef void (*test_loop_t) (const unsigned char *name, test_func_t func); 682 683 enum test_flags { 684 /* Nb arguments */ 685 PPC_ONE_ARG = 0x00000001, 686 PPC_TWO_ARGS = 0x00000002, 687 PPC_THREE_ARGS = 0x00000003, 688 PPC_CMP_ARGS = 0x00000004, 689 PPC_CMPI_ARGS = 0x00000005, 690 PPC_TWO_I16 = 0x00000006, 691 PPC_SPECIAL = 0x00000007, 692 PPC_NB_ARGS = 0x0000000F, 693 /* Type */ 694 PPC_ARITH = 0x00000100, 695 PPC_LOGICAL = 0x00000200, 696 PPC_COMPARE = 0x00000300, 697 PPC_CROP = 0x00000400, 698 PPC_TYPE = 0x00000F00, 699 /* Family */ 700 PPC_INTEGER = 0x00010000, 701 PPC_FLOAT = 0x00020000, 702 PPC_405 = 0x00030000, 703 PPC_ALTIVEC = 0x00040000, 704 PPC_FALTIVEC = 0x00050000, 705 PPC_FAMILY = 0x000F0000, 706 /* Flags */ 707 PPC_CR = 0x01000000, 708 }; 709 710 #endif /* !defined (__TEST_PPC_H__) */ 711 712 //END #include "test-ppc.h" 713 714 static void test_add (void) 715 { 716 __asm__ __volatile__ ("add 17, 14, 15"); 717 } 718 719 static void test_addo (void) 720 { 721 __asm__ __volatile__ ("addo 17, 14, 15"); 722 } 723 724 static void test_addc (void) 725 { 726 __asm__ __volatile__ ("addc 17, 14, 15"); 727 } 728 729 static void test_addco (void) 730 { 731 __asm__ __volatile__ ("addco 17, 14, 15"); 732 } 733 734 static void test_adde (void) 735 { 736 __asm__ __volatile__ ("adde 17, 14, 15"); 737 } 738 739 static void test_addeo (void) 740 { 741 __asm__ __volatile__ ("addeo 17, 14, 15"); 742 } 743 744 static void test_divw (void) 745 { 746 __asm__ __volatile__ ("divw 17, 14, 15"); 747 } 748 749 static void test_divwo (void) 750 { 751 __asm__ __volatile__ ("divwo 17, 14, 15"); 752 } 753 754 static void test_divwu (void) 755 { 756 __asm__ __volatile__ ("divwu 17, 14, 15"); 757 } 758 759 static void test_divwuo (void) 760 { 761 __asm__ __volatile__ ("divwuo 17, 14, 15"); 762 } 763 764 static void test_mulhw (void) 765 { 766 __asm__ __volatile__ ("mulhw 17, 14, 15"); 767 } 768 769 static void test_mulhwu (void) 770 { 771 __asm__ __volatile__ ("mulhwu 17, 14, 15"); 772 } 773 774 static void test_mullw (void) 775 { 776 __asm__ __volatile__ ("mullw 17, 14, 15"); 777 } 778 779 static void test_mullwo (void) 780 { 781 __asm__ __volatile__ ("mullwo 17, 14, 15"); 782 } 783 784 static void test_subf (void) 785 { 786 __asm__ __volatile__ ("subf 17, 14, 15"); 787 } 788 789 static void test_subfo (void) 790 { 791 __asm__ __volatile__ ("subfo 17, 14, 15"); 792 } 793 794 static void test_subfc (void) 795 { 796 __asm__ __volatile__ ("subfc 17, 14, 15"); 797 } 798 799 static void test_subfco (void) 800 { 801 __asm__ __volatile__ ("subfco 17, 14, 15"); 802 } 803 804 static void test_subfe (void) 805 { 806 __asm__ __volatile__ ("subfe 17, 14, 15"); 807 } 808 809 static void test_subfeo (void) 810 { 811 __asm__ __volatile__ ("subfeo 17, 14, 15"); 812 } 813 814 static test_t tests_ia_ops_two[] = { 815 { &test_add , " add", }, 816 { &test_addo , " addo", }, 817 { &test_addc , " addc", }, 818 { &test_addco , " addco", }, 819 { &test_adde , " adde", }, 820 { &test_addeo , " addeo", }, 821 { &test_divw , " divw", }, 822 { &test_divwo , " divwo", }, 823 { &test_divwu , " divwu", }, 824 { &test_divwuo , " divwuo", }, 825 { &test_mulhw , " mulhw", }, 826 { &test_mulhwu , " mulhwu", }, 827 { &test_mullw , " mullw", }, 828 { &test_mullwo , " mullwo", }, 829 { &test_subf , " subf", }, 830 { &test_subfo , " subfo", }, 831 { &test_subfc , " subfc", }, 832 { &test_subfco , " subfco", }, 833 { &test_subfe , " subfe", }, 834 { &test_subfeo , " subfeo", }, 835 { NULL, NULL, }, 836 }; 837 838 static void test_add_ (void) 839 { 840 __asm__ __volatile__ ("add. 17, 14, 15"); 841 } 842 843 static void test_addo_ (void) 844 { 845 __asm__ __volatile__ ("addo. 17, 14, 15"); 846 } 847 848 static void test_addc_ (void) 849 { 850 __asm__ __volatile__ ("addc. 17, 14, 15"); 851 } 852 853 static void test_addco_ (void) 854 { 855 __asm__ __volatile__ ("addco. 17, 14, 15"); 856 } 857 858 static void test_adde_ (void) 859 { 860 __asm__ __volatile__ ("adde. 17, 14, 15"); 861 } 862 863 static void test_addeo_ (void) 864 { 865 __asm__ __volatile__ ("addeo. 17, 14, 15"); 866 } 867 868 static void test_divw_ (void) 869 { 870 __asm__ __volatile__ ("divw. 17, 14, 15"); 871 } 872 873 static void test_divwo_ (void) 874 { 875 __asm__ __volatile__ ("divwo. 17, 14, 15"); 876 } 877 878 static void test_divwu_ (void) 879 { 880 __asm__ __volatile__ ("divwu. 17, 14, 15"); 881 } 882 883 static void test_divwuo_ (void) 884 { 885 __asm__ __volatile__ ("divwuo. 17, 14, 15"); 886 } 887 888 static void test_subf_ (void) 889 { 890 __asm__ __volatile__ ("subf. 17, 14, 15"); 891 } 892 893 static void test_subfo_ (void) 894 { 895 __asm__ __volatile__ ("subfo. 17, 14, 15"); 896 } 897 898 static void test_subfc_ (void) 899 { 900 __asm__ __volatile__ ("subfc. 17, 14, 15"); 901 } 902 903 static void test_subfco_ (void) 904 { 905 __asm__ __volatile__ ("subfco. 17, 14, 15"); 906 } 907 908 static void test_subfe_ (void) 909 { 910 __asm__ __volatile__ ("subfe. 17, 14, 15"); 911 } 912 913 static void test_subfeo_ (void) 914 { 915 __asm__ __volatile__ ("subfeo. 17, 14, 15"); 916 } 917 918 static test_t tests_iar_ops_two[] = { 919 { &test_add_ , " add.", }, 920 { &test_addo_ , " addo.", }, 921 { &test_addc_ , " addc.", }, 922 { &test_addco_ , " addco.", }, 923 { &test_adde_ , " adde.", }, 924 { &test_addeo_ , " addeo.", }, 925 { &test_divw_ , " divw.", }, 926 { &test_divwo_ , " divwo.", }, 927 { &test_divwu_ , " divwu.", }, 928 { &test_divwuo_ , " divwuo.", }, 929 { &test_subf_ , " subf.", }, 930 { &test_subfo_ , " subfo.", }, 931 { &test_subfc_ , " subfc.", }, 932 { &test_subfco_ , " subfco.", }, 933 { &test_subfe_ , " subfe.", }, 934 { &test_subfeo_ , " subfeo.", }, 935 { NULL, NULL, }, 936 }; 937 938 static void test_and (void) 939 { 940 __asm__ __volatile__ ("and 17, 14, 15"); 941 } 942 943 static void test_andc (void) 944 { 945 __asm__ __volatile__ ("andc 17, 14, 15"); 946 } 947 948 static void test_eqv (void) 949 { 950 __asm__ __volatile__ ("eqv 17, 14, 15"); 951 } 952 953 static void test_nand (void) 954 { 955 __asm__ __volatile__ ("nand 17, 14, 15"); 956 } 957 958 static void test_nor (void) 959 { 960 __asm__ __volatile__ ("nor 17, 14, 15"); 961 } 962 963 static void test_or (void) 964 { 965 __asm__ __volatile__ ("or 17, 14, 15"); 966 } 967 968 static void test_orc (void) 969 { 970 __asm__ __volatile__ ("orc 17, 14, 15"); 971 } 972 973 static void test_xor (void) 974 { 975 __asm__ __volatile__ ("xor 17, 14, 15"); 976 } 977 978 static void test_slw (void) 979 { 980 __asm__ __volatile__ ("slw 17, 14, 15"); 981 } 982 983 static void test_sraw (void) 984 { 985 __asm__ __volatile__ ("sraw 17, 14, 15"); 986 } 987 988 static void test_srw (void) 989 { 990 __asm__ __volatile__ ("srw 17, 14, 15"); 991 } 992 993 static test_t tests_il_ops_two[] = { 994 { &test_and , " and", }, 995 { &test_andc , " andc", }, 996 { &test_eqv , " eqv", }, 997 { &test_nand , " nand", }, 998 { &test_nor , " nor", }, 999 { &test_or , " or", }, 1000 { &test_orc , " orc", }, 1001 { &test_xor , " xor", }, 1002 { &test_slw , " slw", }, 1003 { &test_sraw , " sraw", }, 1004 { &test_srw , " srw", }, 1005 { NULL, NULL, }, 1006 }; 1007 1008 static void test_and_ (void) 1009 { 1010 __asm__ __volatile__ ("and. 17, 14, 15"); 1011 } 1012 1013 static void test_andc_ (void) 1014 { 1015 __asm__ __volatile__ ("andc. 17, 14, 15"); 1016 } 1017 1018 static void test_eqv_ (void) 1019 { 1020 __asm__ __volatile__ ("eqv. 17, 14, 15"); 1021 } 1022 1023 static void test_mulhw_ (void) 1024 { 1025 __asm__ __volatile__ ("mulhw. 17, 14, 15"); 1026 } 1027 1028 static void test_mulhwu_ (void) 1029 { 1030 __asm__ __volatile__ ("mulhwu. 17, 14, 15"); 1031 } 1032 1033 static void test_mullw_ (void) 1034 { 1035 __asm__ __volatile__ ("mullw. 17, 14, 15"); 1036 } 1037 1038 static void test_mullwo_ (void) 1039 { 1040 __asm__ __volatile__ ("mullwo. 17, 14, 15"); 1041 } 1042 1043 static void test_nand_ (void) 1044 { 1045 __asm__ __volatile__ ("nand. 17, 14, 15"); 1046 } 1047 1048 static void test_nor_ (void) 1049 { 1050 __asm__ __volatile__ ("nor. 17, 14, 15"); 1051 } 1052 1053 static void test_or_ (void) 1054 { 1055 __asm__ __volatile__ ("or. 17, 14, 15"); 1056 } 1057 1058 static void test_orc_ (void) 1059 { 1060 __asm__ __volatile__ ("orc. 17, 14, 15"); 1061 } 1062 1063 static void test_xor_ (void) 1064 { 1065 __asm__ __volatile__ ("xor. 17, 14, 15"); 1066 } 1067 1068 static void test_slw_ (void) 1069 { 1070 __asm__ __volatile__ ("slw. 17, 14, 15"); 1071 } 1072 1073 static void test_sraw_ (void) 1074 { 1075 __asm__ __volatile__ ("sraw. 17, 14, 15"); 1076 } 1077 1078 static void test_srw_ (void) 1079 { 1080 __asm__ __volatile__ ("srw. 17, 14, 15"); 1081 } 1082 1083 static test_t tests_ilr_ops_two[] = { 1084 { &test_and_ , " and.", }, 1085 { &test_andc_ , " andc.", }, 1086 { &test_eqv_ , " eqv.", }, 1087 { &test_mulhw_ , " mulhw.", }, 1088 { &test_mulhwu_ , " mulhwu.", }, 1089 { &test_mullw_ , " mullw.", }, 1090 { &test_mullwo_ , " mullwo.", }, 1091 { &test_nand_ , " nand.", }, 1092 { &test_nor_ , " nor.", }, 1093 { &test_or_ , " or.", }, 1094 { &test_orc_ , " orc.", }, 1095 { &test_xor_ , " xor.", }, 1096 { &test_slw_ , " slw.", }, 1097 { &test_sraw_ , " sraw.", }, 1098 { &test_srw_ , " srw.", }, 1099 { NULL, NULL, }, 1100 }; 1101 1102 static void test_cmp (void) 1103 { 1104 __asm__ __volatile__ ("cmp 2, 14, 15"); 1105 } 1106 1107 static void test_cmpl (void) 1108 { 1109 __asm__ __volatile__ ("cmpl 2, 14, 15"); 1110 } 1111 1112 static test_t tests_icr_ops_two[] = { 1113 { &test_cmp , " cmp", }, 1114 { &test_cmpl , " cmpl", }, 1115 { NULL, NULL, }, 1116 }; 1117 1118 static void test_cmpi (void) 1119 { 1120 __asm__ __volatile__ ("cmpi 2, 14, 15"); 1121 } 1122 1123 static void test_cmpli (void) 1124 { 1125 __asm__ __volatile__ ("cmpli 2, 14, 15"); 1126 } 1127 1128 static test_t tests_icr_ops_two_i16[] = { 1129 { &test_cmpi , " cmpi", }, 1130 { &test_cmpli , " cmpli", }, 1131 { NULL, NULL, }, 1132 }; 1133 1134 static void test_addi (void) 1135 { 1136 __asm__ __volatile__ ("addi 17, 14, 0"); 1137 } 1138 1139 static void test_addic (void) 1140 { 1141 __asm__ __volatile__ ("addic 17, 14, 0"); 1142 } 1143 1144 static void test_addis (void) 1145 { 1146 __asm__ __volatile__ ("addis 17, 14, 0"); 1147 } 1148 1149 static void test_mulli (void) 1150 { 1151 __asm__ __volatile__ ("mulli 17, 14, 0"); 1152 } 1153 1154 static void test_subfic (void) 1155 { 1156 __asm__ __volatile__ ("subfic 17, 14, 0"); 1157 } 1158 1159 static test_t tests_ia_ops_two_i16[] = { 1160 { &test_addi , " addi", }, 1161 { &test_addic , " addic", }, 1162 { &test_addis , " addis", }, 1163 { &test_mulli , " mulli", }, 1164 { &test_subfic , " subfic", }, 1165 { NULL, NULL, }, 1166 }; 1167 1168 static void test_addic_ (void) 1169 { 1170 __asm__ __volatile__ ("addic. 17, 14, 0"); 1171 } 1172 1173 static test_t tests_iar_ops_two_i16[] = { 1174 { &test_addic_ , " addic.", }, 1175 { NULL, NULL, }, 1176 }; 1177 1178 static void test_ori (void) 1179 { 1180 __asm__ __volatile__ ("ori 17, 14, 0"); 1181 } 1182 1183 static void test_oris (void) 1184 { 1185 __asm__ __volatile__ ("oris 17, 14, 0"); 1186 } 1187 1188 static void test_xori (void) 1189 { 1190 __asm__ __volatile__ ("xori 17, 14, 0"); 1191 } 1192 1193 static void test_xoris (void) 1194 { 1195 __asm__ __volatile__ ("xoris 17, 14, 0"); 1196 } 1197 1198 static test_t tests_il_ops_two_i16[] = { 1199 { &test_ori , " ori", }, 1200 { &test_oris , " oris", }, 1201 { &test_xori , " xori", }, 1202 { &test_xoris , " xoris", }, 1203 { NULL, NULL, }, 1204 }; 1205 1206 static void test_andi_ (void) 1207 { 1208 __asm__ __volatile__ ("andi. 17, 14, 0"); 1209 } 1210 1211 static void test_andis_ (void) 1212 { 1213 __asm__ __volatile__ ("andis. 17, 14, 0"); 1214 } 1215 1216 static test_t tests_ilr_ops_two_i16[] = { 1217 { &test_andi_ , " andi.", }, 1218 { &test_andis_ , " andis.", }, 1219 { NULL, NULL, }, 1220 }; 1221 1222 static void test_crand (void) 1223 { 1224 __asm__ __volatile__ ("crand 17, 14, 15"); 1225 } 1226 1227 static void test_crandc (void) 1228 { 1229 __asm__ __volatile__ ("crandc 17, 14, 15"); 1230 } 1231 1232 static void test_creqv (void) 1233 { 1234 __asm__ __volatile__ ("creqv 17, 14, 15"); 1235 } 1236 1237 static void test_crnand (void) 1238 { 1239 __asm__ __volatile__ ("crnand 17, 14, 15"); 1240 } 1241 1242 static void test_crnor (void) 1243 { 1244 __asm__ __volatile__ ("crnor 17, 14, 15"); 1245 } 1246 1247 static void test_cror (void) 1248 { 1249 __asm__ __volatile__ ("cror 17, 14, 15"); 1250 } 1251 1252 static void test_crorc (void) 1253 { 1254 __asm__ __volatile__ ("crorc 17, 14, 15"); 1255 } 1256 1257 static void test_crxor (void) 1258 { 1259 __asm__ __volatile__ ("crxor 17, 14, 15"); 1260 } 1261 1262 static test_t tests_crl_ops_two[] = { 1263 { &test_crand , " crand", }, 1264 { &test_crandc , " crandc", }, 1265 { &test_creqv , " creqv", }, 1266 { &test_crnand , " crnand", }, 1267 { &test_crnor , " crnor", }, 1268 { &test_cror , " cror", }, 1269 { &test_crorc , " crorc", }, 1270 { &test_crxor , " crxor", }, 1271 { NULL, NULL, }, 1272 }; 1273 1274 static void test_addme (void) 1275 { 1276 __asm__ __volatile__ ("addme 17, 14"); 1277 } 1278 1279 static void test_addmeo (void) 1280 { 1281 __asm__ __volatile__ ("addmeo 17, 14"); 1282 } 1283 1284 static void test_addze (void) 1285 { 1286 __asm__ __volatile__ ("addze 17, 14"); 1287 } 1288 1289 static void test_addzeo (void) 1290 { 1291 __asm__ __volatile__ ("addzeo 17, 14"); 1292 } 1293 1294 static void test_subfme (void) 1295 { 1296 __asm__ __volatile__ ("subfme 17, 14"); 1297 } 1298 1299 static void test_subfmeo (void) 1300 { 1301 __asm__ __volatile__ ("subfmeo 17, 14"); 1302 } 1303 1304 static void test_subfze (void) 1305 { 1306 __asm__ __volatile__ ("subfze 17, 14"); 1307 } 1308 1309 static void test_subfzeo (void) 1310 { 1311 __asm__ __volatile__ ("subfzeo 17, 14"); 1312 } 1313 1314 static test_t tests_ia_ops_one[] = { 1315 { &test_addme , " addme", }, 1316 { &test_addmeo , " addmeo", }, 1317 { &test_addze , " addze", }, 1318 { &test_addzeo , " addzeo", }, 1319 { &test_subfme , " subfme", }, 1320 { &test_subfmeo , " subfmeo", }, 1321 { &test_subfze , " subfze", }, 1322 { &test_subfzeo , " subfzeo", }, 1323 { NULL, NULL, }, 1324 }; 1325 1326 static void test_addme_ (void) 1327 { 1328 __asm__ __volatile__ ("addme. 17, 14"); 1329 } 1330 1331 static void test_addmeo_ (void) 1332 { 1333 __asm__ __volatile__ ("addmeo. 17, 14"); 1334 } 1335 1336 static void test_addze_ (void) 1337 { 1338 __asm__ __volatile__ ("addze. 17, 14"); 1339 } 1340 1341 static void test_addzeo_ (void) 1342 { 1343 __asm__ __volatile__ ("addzeo. 17, 14"); 1344 } 1345 1346 static void test_subfme_ (void) 1347 { 1348 __asm__ __volatile__ ("subfme. 17, 14"); 1349 } 1350 1351 static void test_subfmeo_ (void) 1352 { 1353 __asm__ __volatile__ ("subfmeo. 17, 14"); 1354 } 1355 1356 static void test_subfze_ (void) 1357 { 1358 __asm__ __volatile__ ("subfze. 17, 14"); 1359 } 1360 1361 static void test_subfzeo_ (void) 1362 { 1363 __asm__ __volatile__ ("subfzeo. 17, 14"); 1364 } 1365 1366 static test_t tests_iar_ops_one[] = { 1367 { &test_addme_ , " addme.", }, 1368 { &test_addmeo_ , " addmeo.", }, 1369 { &test_addze_ , " addze.", }, 1370 { &test_addzeo_ , " addzeo.", }, 1371 { &test_subfme_ , " subfme.", }, 1372 { &test_subfmeo_ , " subfmeo.", }, 1373 { &test_subfze_ , " subfze.", }, 1374 { &test_subfzeo_ , " subfzeo.", }, 1375 { NULL, NULL, }, 1376 }; 1377 1378 static void test_cntlzw (void) 1379 { 1380 __asm__ __volatile__ ("cntlzw 17, 14"); 1381 } 1382 1383 static void test_extsb (void) 1384 { 1385 __asm__ __volatile__ ("extsb 17, 14"); 1386 } 1387 1388 static void test_extsh (void) 1389 { 1390 __asm__ __volatile__ ("extsh 17, 14"); 1391 } 1392 1393 static void test_neg (void) 1394 { 1395 __asm__ __volatile__ ("neg 17, 14"); 1396 } 1397 1398 static void test_nego (void) 1399 { 1400 __asm__ __volatile__ ("nego 17, 14"); 1401 } 1402 1403 static test_t tests_il_ops_one[] = { 1404 { &test_cntlzw , " cntlzw", }, 1405 { &test_extsb , " extsb", }, 1406 { &test_extsh , " extsh", }, 1407 { &test_neg , " neg", }, 1408 { &test_nego , " nego", }, 1409 { NULL, NULL, }, 1410 }; 1411 1412 static void test_cntlzw_ (void) 1413 { 1414 __asm__ __volatile__ ("cntlzw. 17, 14"); 1415 } 1416 1417 static void test_extsb_ (void) 1418 { 1419 __asm__ __volatile__ ("extsb. 17, 14"); 1420 } 1421 1422 static void test_extsh_ (void) 1423 { 1424 __asm__ __volatile__ ("extsh. 17, 14"); 1425 } 1426 1427 static void test_neg_ (void) 1428 { 1429 __asm__ __volatile__ ("neg. 17, 14"); 1430 } 1431 1432 static void test_nego_ (void) 1433 { 1434 __asm__ __volatile__ ("nego. 17, 14"); 1435 } 1436 1437 static test_t tests_ilr_ops_one[] = { 1438 { &test_cntlzw_ , " cntlzw.", }, 1439 { &test_extsb_ , " extsb.", }, 1440 { &test_extsh_ , " extsh.", }, 1441 { &test_neg_ , " neg.", }, 1442 { &test_nego_ , " nego.", }, 1443 { NULL, NULL, }, 1444 }; 1445 1446 static void test_rlwimi (void) 1447 { 1448 __asm__ __volatile__ ("rlwimi 17, 14, 0, 0, 0"); 1449 } 1450 1451 static void test_rlwinm (void) 1452 { 1453 __asm__ __volatile__ ("rlwinm 17, 14, 0, 0, 0"); 1454 } 1455 1456 static void test_rlwnm (void) 1457 { 1458 __asm__ __volatile__ ("rlwnm 17, 14, 15, 0, 0"); 1459 } 1460 1461 static void test_srawi (void) 1462 { 1463 __asm__ __volatile__ ("srawi 17, 14, 0"); 1464 } 1465 1466 static test_t tests_il_ops_spe[] = { 1467 { &test_rlwimi , " rlwimi", }, 1468 { &test_rlwinm , " rlwinm", }, 1469 { &test_rlwnm , " rlwnm", }, 1470 { &test_srawi , " srawi", }, 1471 { NULL, NULL, }, 1472 }; 1473 1474 static void test_rlwimi_ (void) 1475 { 1476 __asm__ __volatile__ ("rlwimi. 17, 14, 0, 0, 0"); 1477 } 1478 1479 static void test_rlwinm_ (void) 1480 { 1481 __asm__ __volatile__ ("rlwinm. 17, 14, 0, 0, 0"); 1482 } 1483 1484 static void test_rlwnm_ (void) 1485 { 1486 __asm__ __volatile__ ("rlwnm. 17, 14, 15, 0, 0"); 1487 } 1488 1489 static void test_srawi_ (void) 1490 { 1491 __asm__ __volatile__ ("srawi. 17, 14, 0"); 1492 } 1493 1494 static test_t tests_ilr_ops_spe[] = { 1495 { &test_rlwimi_ , " rlwimi.", }, 1496 { &test_rlwinm_ , " rlwinm.", }, 1497 { &test_rlwnm_ , " rlwnm.", }, 1498 { &test_srawi_ , " srawi.", }, 1499 { NULL, NULL, }, 1500 }; 1501 1502 #if !defined (NO_FLOAT) 1503 static void test_fsel (void) 1504 { 1505 __asm__ __volatile__ ("fsel 17, 14, 15, 16"); 1506 } 1507 1508 static void test_fmadd (void) 1509 { 1510 __asm__ __volatile__ ("fmadd 17, 14, 15, 16"); 1511 } 1512 1513 static void test_fmadds (void) 1514 { 1515 __asm__ __volatile__ ("fmadds 17, 14, 15, 16"); 1516 } 1517 1518 static void test_fmsub (void) 1519 { 1520 __asm__ __volatile__ ("fmsub 17, 14, 15, 16"); 1521 } 1522 1523 static void test_fmsubs (void) 1524 { 1525 __asm__ __volatile__ ("fmsubs 17, 14, 15, 16"); 1526 } 1527 1528 static void test_fnmadd (void) 1529 { 1530 __asm__ __volatile__ ("fnmadd 17, 14, 15, 16"); 1531 } 1532 1533 static void test_fnmadds (void) 1534 { 1535 __asm__ __volatile__ ("fnmadds 17, 14, 15, 16"); 1536 } 1537 1538 static void test_fnmsub (void) 1539 { 1540 __asm__ __volatile__ ("fnmsub 17, 14, 15, 16"); 1541 } 1542 1543 static void test_fnmsubs (void) 1544 { 1545 __asm__ __volatile__ ("fnmsubs 17, 14, 15, 16"); 1546 } 1547 1548 static test_t tests_fa_ops_three[] = { 1549 { &test_fsel , " fsel", }, 1550 { &test_fmadd , " fmadd", }, 1551 { &test_fmadds , " fmadds", }, 1552 { &test_fmsub , " fmsub", }, 1553 { &test_fmsubs , " fmsubs", }, 1554 { &test_fnmadd , " fnmadd", }, 1555 { &test_fnmadds , " fnmadds", }, 1556 { &test_fnmsub , " fnmsub", }, 1557 { &test_fnmsubs , " fnmsubs", }, 1558 { NULL, NULL, }, 1559 }; 1560 #endif /* !defined (NO_FLOAT) */ 1561 1562 #if !defined (NO_FLOAT) 1563 static void test_fsel_ (void) 1564 { 1565 __asm__ __volatile__ ("fsel. 17, 14, 15, 16"); 1566 } 1567 1568 static void test_fmadd_ (void) 1569 { 1570 __asm__ __volatile__ ("fmadd. 17, 14, 15, 16"); 1571 } 1572 1573 static void test_fmadds_ (void) 1574 { 1575 __asm__ __volatile__ ("fmadds. 17, 14, 15, 16"); 1576 } 1577 1578 static void test_fmsub_ (void) 1579 { 1580 __asm__ __volatile__ ("fmsub. 17, 14, 15, 16"); 1581 } 1582 1583 static void test_fmsubs_ (void) 1584 { 1585 __asm__ __volatile__ ("fmsubs. 17, 14, 15, 16"); 1586 } 1587 1588 static void test_fnmadd_ (void) 1589 { 1590 __asm__ __volatile__ ("fnmadd. 17, 14, 15, 16"); 1591 } 1592 1593 static void test_fnmadds_ (void) 1594 { 1595 __asm__ __volatile__ ("fnmadds. 17, 14, 15, 16"); 1596 } 1597 1598 static void test_fnmsub_ (void) 1599 { 1600 __asm__ __volatile__ ("fnmsub. 17, 14, 15, 16"); 1601 } 1602 1603 static void test_fnmsubs_ (void) 1604 { 1605 __asm__ __volatile__ ("fnmsubs. 17, 14, 15, 16"); 1606 } 1607 1608 static test_t tests_far_ops_three[] = { 1609 { &test_fsel_ , " fsel.", }, 1610 { &test_fmadd_ , " fmadd.", }, 1611 { &test_fmadds_ , " fmadds.", }, 1612 { &test_fmsub_ , " fmsub.", }, 1613 { &test_fmsubs_ , " fmsubs.", }, 1614 { &test_fnmadd_ , " fnmadd.", }, 1615 { &test_fnmadds_ , " fnmadds.", }, 1616 { &test_fnmsub_ , " fnmsub.", }, 1617 { &test_fnmsubs_ , " fnmsubs.", }, 1618 { NULL, NULL, }, 1619 }; 1620 #endif /* !defined (NO_FLOAT) */ 1621 1622 #if !defined (NO_FLOAT) 1623 static void test_fadd (void) 1624 { 1625 __asm__ __volatile__ ("fadd 17, 14, 15"); 1626 } 1627 1628 static void test_fadds (void) 1629 { 1630 __asm__ __volatile__ ("fadds 17, 14, 15"); 1631 } 1632 1633 static void test_fsub (void) 1634 { 1635 __asm__ __volatile__ ("fsub 17, 14, 15"); 1636 } 1637 1638 static void test_fsubs (void) 1639 { 1640 __asm__ __volatile__ ("fsubs 17, 14, 15"); 1641 } 1642 1643 static void test_fmul (void) 1644 { 1645 __asm__ __volatile__ ("fmul 17, 14, 15"); 1646 } 1647 1648 static void test_fmuls (void) 1649 { 1650 __asm__ __volatile__ ("fmuls 17, 14, 15"); 1651 } 1652 1653 static void test_fdiv (void) 1654 { 1655 __asm__ __volatile__ ("fdiv 17, 14, 15"); 1656 } 1657 1658 static void test_fdivs (void) 1659 { 1660 __asm__ __volatile__ ("fdivs 17, 14, 15"); 1661 } 1662 1663 static test_t tests_fa_ops_two[] = { 1664 { &test_fadd , " fadd", }, 1665 { &test_fadds , " fadds", }, 1666 { &test_fsub , " fsub", }, 1667 { &test_fsubs , " fsubs", }, 1668 { &test_fmul , " fmul", }, 1669 { &test_fmuls , " fmuls", }, 1670 { &test_fdiv , " fdiv", }, 1671 { &test_fdivs , " fdivs", }, 1672 { NULL, NULL, }, 1673 }; 1674 #endif /* !defined (NO_FLOAT) */ 1675 1676 #if !defined (NO_FLOAT) 1677 static void test_fadd_ (void) 1678 { 1679 __asm__ __volatile__ ("fadd. 17, 14, 15"); 1680 } 1681 1682 static void test_fadds_ (void) 1683 { 1684 __asm__ __volatile__ ("fadds. 17, 14, 15"); 1685 } 1686 1687 static void test_fsub_ (void) 1688 { 1689 __asm__ __volatile__ ("fsub. 17, 14, 15"); 1690 } 1691 1692 static void test_fsubs_ (void) 1693 { 1694 __asm__ __volatile__ ("fsubs. 17, 14, 15"); 1695 } 1696 1697 static void test_fmul_ (void) 1698 { 1699 __asm__ __volatile__ ("fmul. 17, 14, 15"); 1700 } 1701 1702 static void test_fmuls_ (void) 1703 { 1704 __asm__ __volatile__ ("fmuls. 17, 14, 15"); 1705 } 1706 1707 static void test_fdiv_ (void) 1708 { 1709 __asm__ __volatile__ ("fdiv. 17, 14, 15"); 1710 } 1711 1712 static void test_fdivs_ (void) 1713 { 1714 __asm__ __volatile__ ("fdivs. 17, 14, 15"); 1715 } 1716 1717 static test_t tests_far_ops_two[] = { 1718 { &test_fadd_ , " fadd.", }, 1719 { &test_fadds_ , " fadds.", }, 1720 { &test_fsub_ , " fsub.", }, 1721 { &test_fsubs_ , " fsubs.", }, 1722 { &test_fmul_ , " fmul.", }, 1723 { &test_fmuls_ , " fmuls.", }, 1724 { &test_fdiv_ , " fdiv.", }, 1725 { &test_fdivs_ , " fdivs.", }, 1726 { NULL, NULL, }, 1727 }; 1728 #endif /* !defined (NO_FLOAT) */ 1729 1730 #if !defined (NO_FLOAT) 1731 static void test_fcmpo (void) 1732 { 1733 __asm__ __volatile__ ("fcmpo 2, 14, 15"); 1734 } 1735 1736 static void test_fcmpu (void) 1737 { 1738 __asm__ __volatile__ ("fcmpu 2, 14, 15"); 1739 } 1740 1741 static test_t tests_fcr_ops_two[] = { 1742 { &test_fcmpo , " fcmpo", }, 1743 { &test_fcmpu , " fcmpu", }, 1744 { NULL, NULL, }, 1745 }; 1746 #endif /* !defined (NO_FLOAT) */ 1747 1748 #if !defined (NO_FLOAT) 1749 static void test_fres (void) 1750 { 1751 __asm__ __volatile__ ("fres 17, 14"); 1752 } 1753 1754 static void test_frsqrte (void) 1755 { 1756 __asm__ __volatile__ ("frsqrte 17, 14"); 1757 } 1758 1759 static void test_frsp (void) 1760 { 1761 __asm__ __volatile__ ("frsp 17, 14"); 1762 } 1763 1764 static void test_fctiw (void) 1765 { 1766 __asm__ __volatile__ ("fctiw 17, 14"); 1767 } 1768 1769 static void test_fctiwz (void) 1770 { 1771 __asm__ __volatile__ ("fctiwz 17, 14"); 1772 } 1773 1774 static void test_fmr (void) 1775 { 1776 __asm__ __volatile__ ("fmr 17, 14"); 1777 } 1778 1779 static void test_fneg (void) 1780 { 1781 __asm__ __volatile__ ("fneg 17, 14"); 1782 } 1783 1784 static void test_fabs (void) 1785 { 1786 __asm__ __volatile__ ("fabs 17, 14"); 1787 } 1788 1789 static void test_fnabs (void) 1790 { 1791 __asm__ __volatile__ ("fnabs 17, 14"); 1792 } 1793 1794 static test_t tests_fa_ops_one[] = { 1795 { &test_fres , " fres", }, 1796 { &test_frsqrte , " frsqrte", }, 1797 { &test_frsp , " frsp", }, 1798 { &test_fctiw , " fctiw", }, 1799 { &test_fctiwz , " fctiwz", }, 1800 { &test_fmr , " fmr", }, 1801 { &test_fneg , " fneg", }, 1802 { &test_fabs , " fabs", }, 1803 { &test_fnabs , " fnabs", }, 1804 { NULL, NULL, }, 1805 }; 1806 #endif /* !defined (NO_FLOAT) */ 1807 1808 #if !defined (NO_FLOAT) 1809 static void test_fres_ (void) 1810 { 1811 __asm__ __volatile__ ("fres. 17, 14"); 1812 } 1813 1814 static void test_frsqrte_ (void) 1815 { 1816 __asm__ __volatile__ ("frsqrte. 17, 14"); 1817 } 1818 1819 static void test_frsp_ (void) 1820 { 1821 __asm__ __volatile__ ("frsp. 17, 14"); 1822 } 1823 1824 static void test_fctiw_ (void) 1825 { 1826 __asm__ __volatile__ ("fctiw. 17, 14"); 1827 } 1828 1829 static void test_fctiwz_ (void) 1830 { 1831 __asm__ __volatile__ ("fctiwz. 17, 14"); 1832 } 1833 1834 static void test_fmr_ (void) 1835 { 1836 __asm__ __volatile__ ("fmr. 17, 14"); 1837 } 1838 1839 static void test_fneg_ (void) 1840 { 1841 __asm__ __volatile__ ("fneg. 17, 14"); 1842 } 1843 1844 static void test_fabs_ (void) 1845 { 1846 __asm__ __volatile__ ("fabs. 17, 14"); 1847 } 1848 1849 static void test_fnabs_ (void) 1850 { 1851 __asm__ __volatile__ ("fnabs. 17, 14"); 1852 } 1853 1854 static test_t tests_far_ops_one[] = { 1855 { &test_fres_ , " fres.", }, 1856 { &test_frsqrte_ , " frsqrte.", }, 1857 { &test_frsp_ , " frsp.", }, 1858 { &test_fctiw_ , " fctiw.", }, 1859 { &test_fctiwz_ , " fctiwz.", }, 1860 { &test_fmr_ , " fmr.", }, 1861 { &test_fneg_ , " fneg.", }, 1862 { &test_fabs_ , " fabs.", }, 1863 { &test_fnabs_ , " fnabs.", }, 1864 { NULL, NULL, }, 1865 }; 1866 #endif /* !defined (NO_FLOAT) */ 1867 1868 #if !defined (NO_FLOAT) 1869 static test_t tests_fl_ops_spe[] = { 1870 { NULL, NULL, }, 1871 }; 1872 #endif /* !defined (NO_FLOAT) */ 1873 1874 #if !defined (NO_FLOAT) 1875 static test_t tests_flr_ops_spe[] = { 1876 { NULL, NULL, }, 1877 }; 1878 #endif /* !defined (NO_FLOAT) */ 1879 1880 #if defined (HAS_ALTIVEC) 1881 static void test_vmhaddshs (void) 1882 { 1883 __asm__ __volatile__ ("vmhaddshs 17, 14, 15, 16"); 1884 } 1885 1886 static void test_vmhraddshs (void) 1887 { 1888 __asm__ __volatile__ ("vmhraddshs 17, 14, 15, 16"); 1889 } 1890 1891 static void test_vmladduhm (void) 1892 { 1893 __asm__ __volatile__ ("vmladduhm 17, 14, 15, 16"); 1894 } 1895 1896 static void test_vmsumubm (void) 1897 { 1898 __asm__ __volatile__ ("vmsumubm 17, 14, 15, 16"); 1899 } 1900 1901 static void test_vmsumuhm (void) 1902 { 1903 __asm__ __volatile__ ("vmsumuhm 17, 14, 15, 16"); 1904 } 1905 1906 static void test_vmsumshs (void) 1907 { 1908 __asm__ __volatile__ ("vmsumshs 17, 14, 15, 16"); 1909 } 1910 1911 static void test_vmsumuhs (void) 1912 { 1913 __asm__ __volatile__ ("vmsumuhs 17, 14, 15, 16"); 1914 } 1915 1916 static void test_vmsummbm (void) 1917 { 1918 __asm__ __volatile__ ("vmsummbm 17, 14, 15, 16"); 1919 } 1920 1921 static void test_vmsumshm (void) 1922 { 1923 __asm__ __volatile__ ("vmsumshm 17, 14, 15, 16"); 1924 } 1925 1926 static test_t tests_aa_ops_three[] = { 1927 { &test_vmhaddshs , " vmhaddshs", }, 1928 { &test_vmhraddshs , " vmhraddshs", }, 1929 { &test_vmladduhm , " vmladduhm", }, 1930 { &test_vmsumubm , " vmsumubm", }, 1931 { &test_vmsumuhm , " vmsumuhm", }, 1932 { &test_vmsumshs , " vmsumshs", }, 1933 { &test_vmsumuhs , " vmsumuhs", }, 1934 { &test_vmsummbm , " vmsummbm", }, 1935 { &test_vmsumshm , " vmsumshm", }, 1936 { NULL, NULL, }, 1937 }; 1938 #endif /* defined (HAS_ALTIVEC) */ 1939 1940 #if defined (HAS_ALTIVEC) 1941 static void test_vperm (void) 1942 { 1943 __asm__ __volatile__ ("vperm 17, 14, 15, 16"); 1944 } 1945 1946 static void test_vsel (void) 1947 { 1948 __asm__ __volatile__ ("vsel 17, 14, 15, 16"); 1949 } 1950 1951 static test_t tests_al_ops_three[] = { 1952 { &test_vperm , " vperm", }, 1953 { &test_vsel , " vsel", }, 1954 { NULL, NULL, }, 1955 }; 1956 #endif /* defined (HAS_ALTIVEC) */ 1957 1958 #if defined (HAS_ALTIVEC) 1959 static void test_vaddubm (void) 1960 { 1961 __asm__ __volatile__ ("vaddubm 17, 14, 15"); 1962 } 1963 1964 static void test_vadduhm (void) 1965 { 1966 __asm__ __volatile__ ("vadduhm 17, 14, 15"); 1967 } 1968 1969 static void test_vadduwm (void) 1970 { 1971 __asm__ __volatile__ ("vadduwm 17, 14, 15"); 1972 } 1973 1974 static void test_vaddubs (void) 1975 { 1976 __asm__ __volatile__ ("vaddubs 17, 14, 15"); 1977 } 1978 1979 static void test_vadduhs (void) 1980 { 1981 __asm__ __volatile__ ("vadduhs 17, 14, 15"); 1982 } 1983 1984 static void test_vadduws (void) 1985 { 1986 __asm__ __volatile__ ("vadduws 17, 14, 15"); 1987 } 1988 1989 static void test_vaddsbs (void) 1990 { 1991 __asm__ __volatile__ ("vaddsbs 17, 14, 15"); 1992 } 1993 1994 static void test_vaddshs (void) 1995 { 1996 __asm__ __volatile__ ("vaddshs 17, 14, 15"); 1997 } 1998 1999 static void test_vaddsws (void) 2000 { 2001 __asm__ __volatile__ ("vaddsws 17, 14, 15"); 2002 } 2003 2004 static void test_vaddcuw (void) 2005 { 2006 __asm__ __volatile__ ("vaddcuw 17, 14, 15"); 2007 } 2008 2009 static void test_vsububm (void) 2010 { 2011 __asm__ __volatile__ ("vsububm 17, 14, 15"); 2012 } 2013 2014 static void test_vsubuhm (void) 2015 { 2016 __asm__ __volatile__ ("vsubuhm 17, 14, 15"); 2017 } 2018 2019 static void test_vsubuwm (void) 2020 { 2021 __asm__ __volatile__ ("vsubuwm 17, 14, 15"); 2022 } 2023 2024 static void test_vsububs (void) 2025 { 2026 __asm__ __volatile__ ("vsububs 17, 14, 15"); 2027 } 2028 2029 static void test_vsubuhs (void) 2030 { 2031 __asm__ __volatile__ ("vsubuhs 17, 14, 15"); 2032 } 2033 2034 static void test_vsubuws (void) 2035 { 2036 __asm__ __volatile__ ("vsubuws 17, 14, 15"); 2037 } 2038 2039 static void test_vsubcuw (void) 2040 { 2041 __asm__ __volatile__ ("vsubcuw 17, 14, 15"); 2042 } 2043 2044 static void test_vmuloub (void) 2045 { 2046 __asm__ __volatile__ ("vmuloub 17, 14, 15"); 2047 } 2048 2049 static void test_vmulouh (void) 2050 { 2051 __asm__ __volatile__ ("vmulouh 17, 14, 15"); 2052 } 2053 2054 static void test_vmulosb (void) 2055 { 2056 __asm__ __volatile__ ("vmulosb 17, 14, 15"); 2057 } 2058 2059 static void test_vmulosh (void) 2060 { 2061 __asm__ __volatile__ ("vmulosh 17, 14, 15"); 2062 } 2063 2064 static void test_vmuleub (void) 2065 { 2066 __asm__ __volatile__ ("vmuleub 17, 14, 15"); 2067 } 2068 2069 static void test_vmuleuh (void) 2070 { 2071 __asm__ __volatile__ ("vmuleuh 17, 14, 15"); 2072 } 2073 2074 static void test_vmulesb (void) 2075 { 2076 __asm__ __volatile__ ("vmulesb 17, 14, 15"); 2077 } 2078 2079 static void test_vmulesh (void) 2080 { 2081 __asm__ __volatile__ ("vmulesh 17, 14, 15"); 2082 } 2083 2084 static void test_vsumsws (void) 2085 { 2086 __asm__ __volatile__ ("vsumsws 17, 14, 15"); 2087 } 2088 2089 static void test_vsum2sws (void) 2090 { 2091 __asm__ __volatile__ ("vsum2sws 17, 14, 15"); 2092 } 2093 2094 static void test_vsum4ubs (void) 2095 { 2096 __asm__ __volatile__ ("vsum4ubs 17, 14, 15"); 2097 } 2098 2099 static void test_vsum4sbs (void) 2100 { 2101 __asm__ __volatile__ ("vsum4sbs 17, 14, 15"); 2102 } 2103 2104 static void test_vsum4shs (void) 2105 { 2106 __asm__ __volatile__ ("vsum4shs 17, 14, 15"); 2107 } 2108 2109 static void test_vavgub (void) 2110 { 2111 __asm__ __volatile__ ("vavgub 17, 14, 15"); 2112 } 2113 2114 static void test_vavguh (void) 2115 { 2116 __asm__ __volatile__ ("vavguh 17, 14, 15"); 2117 } 2118 2119 static void test_vavguw (void) 2120 { 2121 __asm__ __volatile__ ("vavguw 17, 14, 15"); 2122 } 2123 2124 static void test_vavgsb (void) 2125 { 2126 __asm__ __volatile__ ("vavgsb 17, 14, 15"); 2127 } 2128 2129 static void test_vavgsh (void) 2130 { 2131 __asm__ __volatile__ ("vavgsh 17, 14, 15"); 2132 } 2133 2134 static void test_vavgsw (void) 2135 { 2136 __asm__ __volatile__ ("vavgsw 17, 14, 15"); 2137 } 2138 2139 static void test_vmaxub (void) 2140 { 2141 __asm__ __volatile__ ("vmaxub 17, 14, 15"); 2142 } 2143 2144 static void test_vmaxuh (void) 2145 { 2146 __asm__ __volatile__ ("vmaxuh 17, 14, 15"); 2147 } 2148 2149 static void test_vmaxuw (void) 2150 { 2151 __asm__ __volatile__ ("vmaxuw 17, 14, 15"); 2152 } 2153 2154 static void test_vmaxsb (void) 2155 { 2156 __asm__ __volatile__ ("vmaxsb 17, 14, 15"); 2157 } 2158 2159 static void test_vmaxsh (void) 2160 { 2161 __asm__ __volatile__ ("vmaxsh 17, 14, 15"); 2162 } 2163 2164 static void test_vmaxsw (void) 2165 { 2166 __asm__ __volatile__ ("vmaxsw 17, 14, 15"); 2167 } 2168 2169 static void test_vminub (void) 2170 { 2171 __asm__ __volatile__ ("vminub 17, 14, 15"); 2172 } 2173 2174 static void test_vminuh (void) 2175 { 2176 __asm__ __volatile__ ("vminuh 17, 14, 15"); 2177 } 2178 2179 static void test_vminuw (void) 2180 { 2181 __asm__ __volatile__ ("vminuw 17, 14, 15"); 2182 } 2183 2184 static void test_vminsb (void) 2185 { 2186 __asm__ __volatile__ ("vminsb 17, 14, 15"); 2187 } 2188 2189 static void test_vminsh (void) 2190 { 2191 __asm__ __volatile__ ("vminsh 17, 14, 15"); 2192 } 2193 2194 static void test_vminsw (void) 2195 { 2196 __asm__ __volatile__ ("vminsw 17, 14, 15"); 2197 } 2198 2199 static test_t tests_aa_ops_two[] = { 2200 { &test_vaddubm , " vaddubm", }, 2201 { &test_vadduhm , " vadduhm", }, 2202 { &test_vadduwm , " vadduwm", }, 2203 { &test_vaddubs , " vaddubs", }, 2204 { &test_vadduhs , " vadduhs", }, 2205 { &test_vadduws , " vadduws", }, 2206 { &test_vaddsbs , " vaddsbs", }, 2207 { &test_vaddshs , " vaddshs", }, 2208 { &test_vaddsws , " vaddsws", }, 2209 { &test_vaddcuw , " vaddcuw", }, 2210 { &test_vsububm , " vsububm", }, 2211 { &test_vsubuhm , " vsubuhm", }, 2212 { &test_vsubuwm , " vsubuwm", }, 2213 { &test_vsububs , " vsububs", }, 2214 { &test_vsubuhs , " vsubuhs", }, 2215 { &test_vsubuws , " vsubuws", }, 2216 { &test_vsubcuw , " vsubcuw", }, 2217 { &test_vmuloub , " vmuloub", }, 2218 { &test_vmulouh , " vmulouh", }, 2219 { &test_vmulosb , " vmulosb", }, 2220 { &test_vmulosh , " vmulosh", }, 2221 { &test_vmuleub , " vmuleub", }, 2222 { &test_vmuleuh , " vmuleuh", }, 2223 { &test_vmulesb , " vmulesb", }, 2224 { &test_vmulesh , " vmulesh", }, 2225 { &test_vsumsws , " vsumsws", }, 2226 { &test_vsum2sws , " vsum2sws", }, 2227 { &test_vsum4ubs , " vsum4ubs", }, 2228 { &test_vsum4sbs , " vsum4sbs", }, 2229 { &test_vsum4shs , " vsum4shs", }, 2230 { &test_vavgub , " vavgub", }, 2231 { &test_vavguh , " vavguh", }, 2232 { &test_vavguw , " vavguw", }, 2233 { &test_vavgsb , " vavgsb", }, 2234 { &test_vavgsh , " vavgsh", }, 2235 { &test_vavgsw , " vavgsw", }, 2236 { &test_vmaxub , " vmaxub", }, 2237 { &test_vmaxuh , " vmaxuh", }, 2238 { &test_vmaxuw , " vmaxuw", }, 2239 { &test_vmaxsb , " vmaxsb", }, 2240 { &test_vmaxsh , " vmaxsh", }, 2241 { &test_vmaxsw , " vmaxsw", }, 2242 { &test_vminub , " vminub", }, 2243 { &test_vminuh , " vminuh", }, 2244 { &test_vminuw , " vminuw", }, 2245 { &test_vminsb , " vminsb", }, 2246 { &test_vminsh , " vminsh", }, 2247 { &test_vminsw , " vminsw", }, 2248 { NULL, NULL, }, 2249 }; 2250 #endif /* defined (HAS_ALTIVEC) */ 2251 2252 #if defined (HAS_ALTIVEC) 2253 static void test_vand (void) 2254 { 2255 __asm__ __volatile__ ("vand 17, 14, 15"); 2256 } 2257 2258 static void test_vor (void) 2259 { 2260 __asm__ __volatile__ ("vor 17, 14, 15"); 2261 } 2262 2263 static void test_vxor (void) 2264 { 2265 __asm__ __volatile__ ("vxor 17, 14, 15"); 2266 } 2267 2268 static void test_vandc (void) 2269 { 2270 __asm__ __volatile__ ("vandc 17, 14, 15"); 2271 } 2272 2273 static void test_vnor (void) 2274 { 2275 __asm__ __volatile__ ("vnor 17, 14, 15"); 2276 } 2277 2278 static void test_vrlb (void) 2279 { 2280 __asm__ __volatile__ ("vrlb 17, 14, 15"); 2281 } 2282 2283 static void test_vrlh (void) 2284 { 2285 __asm__ __volatile__ ("vrlh 17, 14, 15"); 2286 } 2287 2288 static void test_vrlw (void) 2289 { 2290 __asm__ __volatile__ ("vrlw 17, 14, 15"); 2291 } 2292 2293 static void test_vslb (void) 2294 { 2295 __asm__ __volatile__ ("vslb 17, 14, 15"); 2296 } 2297 2298 static void test_vslh (void) 2299 { 2300 __asm__ __volatile__ ("vslh 17, 14, 15"); 2301 } 2302 2303 static void test_vslw (void) 2304 { 2305 __asm__ __volatile__ ("vslw 17, 14, 15"); 2306 } 2307 2308 static void test_vsrb (void) 2309 { 2310 __asm__ __volatile__ ("vsrb 17, 14, 15"); 2311 } 2312 2313 static void test_vsrh (void) 2314 { 2315 __asm__ __volatile__ ("vsrh 17, 14, 15"); 2316 } 2317 2318 static void test_vsrw (void) 2319 { 2320 __asm__ __volatile__ ("vsrw 17, 14, 15"); 2321 } 2322 2323 static void test_vsrab (void) 2324 { 2325 __asm__ __volatile__ ("vsrab 17, 14, 15"); 2326 } 2327 2328 static void test_vsrah (void) 2329 { 2330 __asm__ __volatile__ ("vsrah 17, 14, 15"); 2331 } 2332 2333 static void test_vsraw (void) 2334 { 2335 __asm__ __volatile__ ("vsraw 17, 14, 15"); 2336 } 2337 2338 static void test_vpkuhum (void) 2339 { 2340 __asm__ __volatile__ ("vpkuhum 17, 14, 15"); 2341 } 2342 2343 static void test_vpkuwum (void) 2344 { 2345 __asm__ __volatile__ ("vpkuwum 17, 14, 15"); 2346 } 2347 2348 static void test_vpkuhus (void) 2349 { 2350 __asm__ __volatile__ ("vpkuhus 17, 14, 15"); 2351 } 2352 2353 static void test_vpkuwus (void) 2354 { 2355 __asm__ __volatile__ ("vpkuwus 17, 14, 15"); 2356 } 2357 2358 static void test_vpkshus (void) 2359 { 2360 __asm__ __volatile__ ("vpkshus 17, 14, 15"); 2361 } 2362 2363 static void test_vpkswus (void) 2364 { 2365 __asm__ __volatile__ ("vpkswus 17, 14, 15"); 2366 } 2367 2368 static void test_vpkshss (void) 2369 { 2370 __asm__ __volatile__ ("vpkshss 17, 14, 15"); 2371 } 2372 2373 static void test_vpkswss (void) 2374 { 2375 __asm__ __volatile__ ("vpkswss 17, 14, 15"); 2376 } 2377 2378 static void test_vpkpx (void) 2379 { 2380 __asm__ __volatile__ ("vpkpx 17, 14, 15"); 2381 } 2382 2383 static void test_vmrghb (void) 2384 { 2385 __asm__ __volatile__ ("vmrghb 17, 14, 15"); 2386 } 2387 2388 static void test_vmrghh (void) 2389 { 2390 __asm__ __volatile__ ("vmrghh 17, 14, 15"); 2391 } 2392 2393 static void test_vmrghw (void) 2394 { 2395 __asm__ __volatile__ ("vmrghw 17, 14, 15"); 2396 } 2397 2398 static void test_vmrglb (void) 2399 { 2400 __asm__ __volatile__ ("vmrglb 17, 14, 15"); 2401 } 2402 2403 static void test_vmrglh (void) 2404 { 2405 __asm__ __volatile__ ("vmrglh 17, 14, 15"); 2406 } 2407 2408 static void test_vmrglw (void) 2409 { 2410 __asm__ __volatile__ ("vmrglw 17, 14, 15"); 2411 } 2412 2413 static void test_vsl (void) 2414 { 2415 __asm__ __volatile__ ("vsl 17, 14, 15"); 2416 } 2417 2418 static void test_vsr (void) 2419 { 2420 __asm__ __volatile__ ("vsr 17, 14, 15"); 2421 } 2422 2423 static void test_vslo (void) 2424 { 2425 __asm__ __volatile__ ("vslo 17, 14, 15"); 2426 } 2427 2428 static void test_vsro (void) 2429 { 2430 __asm__ __volatile__ ("vsro 17, 14, 15"); 2431 } 2432 2433 static test_t tests_al_ops_two[] = { 2434 { &test_vand , " vand", }, 2435 { &test_vor , " vor", }, 2436 { &test_vxor , " vxor", }, 2437 { &test_vandc , " vandc", }, 2438 { &test_vnor , " vnor", }, 2439 { &test_vrlb , " vrlb", }, 2440 { &test_vrlh , " vrlh", }, 2441 { &test_vrlw , " vrlw", }, 2442 { &test_vslb , " vslb", }, 2443 { &test_vslh , " vslh", }, 2444 { &test_vslw , " vslw", }, 2445 { &test_vsrb , " vsrb", }, 2446 { &test_vsrh , " vsrh", }, 2447 { &test_vsrw , " vsrw", }, 2448 { &test_vsrab , " vsrab", }, 2449 { &test_vsrah , " vsrah", }, 2450 { &test_vsraw , " vsraw", }, 2451 { &test_vpkuhum , " vpkuhum", }, 2452 { &test_vpkuwum , " vpkuwum", }, 2453 { &test_vpkuhus , " vpkuhus", }, 2454 { &test_vpkuwus , " vpkuwus", }, 2455 { &test_vpkshus , " vpkshus", }, 2456 { &test_vpkswus , " vpkswus", }, 2457 { &test_vpkshss , " vpkshss", }, 2458 { &test_vpkswss , " vpkswss", }, 2459 { &test_vpkpx , " vpkpx", }, 2460 { &test_vmrghb , " vmrghb", }, 2461 { &test_vmrghh , " vmrghh", }, 2462 { &test_vmrghw , " vmrghw", }, 2463 { &test_vmrglb , " vmrglb", }, 2464 { &test_vmrglh , " vmrglh", }, 2465 { &test_vmrglw , " vmrglw", }, 2466 { &test_vsl , " vsl", }, 2467 { &test_vsr , " vsr", }, 2468 { &test_vslo , " vslo", }, 2469 { &test_vsro , " vsro", }, 2470 { NULL, NULL, }, 2471 }; 2472 #endif /* defined (HAS_ALTIVEC) */ 2473 2474 #if defined (HAS_ALTIVEC) 2475 static void test_vupkhsb (void) 2476 { 2477 __asm__ __volatile__ ("vupkhsb 17, 14"); 2478 } 2479 2480 static void test_vupkhsh (void) 2481 { 2482 __asm__ __volatile__ ("vupkhsh 17, 14"); 2483 } 2484 2485 static void test_vupkhpx (void) 2486 { 2487 __asm__ __volatile__ ("vupkhpx 17, 14"); 2488 } 2489 2490 static void test_vupklsb (void) 2491 { 2492 __asm__ __volatile__ ("vupklsb 17, 14"); 2493 } 2494 2495 static void test_vupklsh (void) 2496 { 2497 __asm__ __volatile__ ("vupklsh 17, 14"); 2498 } 2499 2500 static void test_vupklpx (void) 2501 { 2502 __asm__ __volatile__ ("vupklpx 17, 14"); 2503 } 2504 2505 static test_t tests_al_ops_one[] = { 2506 { &test_vupkhsb , " vupkhsb", }, 2507 { &test_vupkhsh , " vupkhsh", }, 2508 { &test_vupkhpx , " vupkhpx", }, 2509 { &test_vupklsb , " vupklsb", }, 2510 { &test_vupklsh , " vupklsh", }, 2511 { &test_vupklpx , " vupklpx", }, 2512 { NULL, NULL, }, 2513 }; 2514 #endif /* defined (HAS_ALTIVEC) */ 2515 2516 #if defined (HAS_ALTIVEC) 2517 static void test_vcmpgtub (void) 2518 { 2519 __asm__ __volatile__ ("vcmpgtub 17, 14, 15"); 2520 } 2521 2522 static void test_vcmpgtuh (void) 2523 { 2524 __asm__ __volatile__ ("vcmpgtuh 17, 14, 15"); 2525 } 2526 2527 static void test_vcmpgtuw (void) 2528 { 2529 __asm__ __volatile__ ("vcmpgtuw 17, 14, 15"); 2530 } 2531 2532 static void test_vcmpgtsb (void) 2533 { 2534 __asm__ __volatile__ ("vcmpgtsb 17, 14, 15"); 2535 } 2536 2537 static void test_vcmpgtsh (void) 2538 { 2539 __asm__ __volatile__ ("vcmpgtsh 17, 14, 15"); 2540 } 2541 2542 static void test_vcmpgtsw (void) 2543 { 2544 __asm__ __volatile__ ("vcmpgtsw 17, 14, 15"); 2545 } 2546 2547 static void test_vcmpequb (void) 2548 { 2549 __asm__ __volatile__ ("vcmpequb 17, 14, 15"); 2550 } 2551 2552 static void test_vcmpequh (void) 2553 { 2554 __asm__ __volatile__ ("vcmpequh 17, 14, 15"); 2555 } 2556 2557 static void test_vcmpequw (void) 2558 { 2559 __asm__ __volatile__ ("vcmpequw 17, 14, 15"); 2560 } 2561 2562 static test_t tests_ac_ops_two[] = { 2563 { &test_vcmpgtub , " vcmpgtub", }, 2564 { &test_vcmpgtuh , " vcmpgtuh", }, 2565 { &test_vcmpgtuw , " vcmpgtuw", }, 2566 { &test_vcmpgtsb , " vcmpgtsb", }, 2567 { &test_vcmpgtsh , " vcmpgtsh", }, 2568 { &test_vcmpgtsw , " vcmpgtsw", }, 2569 { &test_vcmpequb , " vcmpequb", }, 2570 { &test_vcmpequh , " vcmpequh", }, 2571 { &test_vcmpequw , " vcmpequw", }, 2572 { NULL, NULL, }, 2573 }; 2574 #endif /* defined (HAS_ALTIVEC) */ 2575 2576 #if defined (HAS_ALTIVEC) 2577 static void test_vcmpgtub_ (void) 2578 { 2579 __asm__ __volatile__ ("vcmpgtub. 17, 14, 15"); 2580 } 2581 2582 static void test_vcmpgtuh_ (void) 2583 { 2584 __asm__ __volatile__ ("vcmpgtuh. 17, 14, 15"); 2585 } 2586 2587 static void test_vcmpgtuw_ (void) 2588 { 2589 __asm__ __volatile__ ("vcmpgtuw. 17, 14, 15"); 2590 } 2591 2592 static void test_vcmpgtsb_ (void) 2593 { 2594 __asm__ __volatile__ ("vcmpgtsb. 17, 14, 15"); 2595 } 2596 2597 static void test_vcmpgtsh_ (void) 2598 { 2599 __asm__ __volatile__ ("vcmpgtsh. 17, 14, 15"); 2600 } 2601 2602 static void test_vcmpgtsw_ (void) 2603 { 2604 __asm__ __volatile__ ("vcmpgtsw. 17, 14, 15"); 2605 } 2606 2607 static void test_vcmpequb_ (void) 2608 { 2609 __asm__ __volatile__ ("vcmpequb. 17, 14, 15"); 2610 } 2611 2612 static void test_vcmpequh_ (void) 2613 { 2614 __asm__ __volatile__ ("vcmpequh. 17, 14, 15"); 2615 } 2616 2617 static void test_vcmpequw_ (void) 2618 { 2619 __asm__ __volatile__ ("vcmpequw. 17, 14, 15"); 2620 } 2621 2622 static test_t tests_acr_ops_two[] = { 2623 { &test_vcmpgtub_ , " vcmpgtub.", }, 2624 { &test_vcmpgtuh_ , " vcmpgtuh.", }, 2625 { &test_vcmpgtuw_ , " vcmpgtuw.", }, 2626 { &test_vcmpgtsb_ , " vcmpgtsb.", }, 2627 { &test_vcmpgtsh_ , " vcmpgtsh.", }, 2628 { &test_vcmpgtsw_ , " vcmpgtsw.", }, 2629 { &test_vcmpequb_ , " vcmpequb.", }, 2630 { &test_vcmpequh_ , " vcmpequh.", }, 2631 { &test_vcmpequw_ , " vcmpequw.", }, 2632 { NULL, NULL, }, 2633 }; 2634 #endif /* defined (HAS_ALTIVEC) */ 2635 2636 #if defined (HAS_ALTIVEC) 2637 static void test_vmaddfp (void) 2638 { 2639 __asm__ __volatile__ ("vmaddfp 17, 14, 15, 16"); 2640 } 2641 2642 static void test_vnmsubfp (void) 2643 { 2644 __asm__ __volatile__ ("vnmsubfp 17, 14, 15, 16"); 2645 } 2646 2647 static test_t tests_afa_ops_three[] = { 2648 { &test_vmaddfp , " vmaddfp", }, 2649 { &test_vnmsubfp , " vnmsubfp", }, 2650 { NULL, NULL, }, 2651 }; 2652 #endif /* defined (HAS_ALTIVEC) */ 2653 2654 #if defined (HAS_ALTIVEC) 2655 static void test_vaddfp (void) 2656 { 2657 __asm__ __volatile__ ("vaddfp 17, 14, 15"); 2658 } 2659 2660 static void test_vsubfp (void) 2661 { 2662 __asm__ __volatile__ ("vsubfp 17, 14, 15"); 2663 } 2664 2665 static void test_vmaxfp (void) 2666 { 2667 __asm__ __volatile__ ("vmaxfp 17, 14, 15"); 2668 } 2669 2670 static void test_vminfp (void) 2671 { 2672 __asm__ __volatile__ ("vminfp 17, 14, 15"); 2673 } 2674 2675 static test_t tests_afa_ops_two[] = { 2676 { &test_vaddfp , " vaddfp", }, 2677 { &test_vsubfp , " vsubfp", }, 2678 { &test_vmaxfp , " vmaxfp", }, 2679 { &test_vminfp , " vminfp", }, 2680 { NULL, NULL, }, 2681 }; 2682 #endif /* defined (HAS_ALTIVEC) */ 2683 2684 #if defined (HAS_ALTIVEC) 2685 static void test_vrfin (void) 2686 { 2687 __asm__ __volatile__ ("vrfin 17, 14"); 2688 } 2689 2690 static void test_vrfiz (void) 2691 { 2692 __asm__ __volatile__ ("vrfiz 17, 14"); 2693 } 2694 2695 static void test_vrfip (void) 2696 { 2697 __asm__ __volatile__ ("vrfip 17, 14"); 2698 } 2699 2700 static void test_vrfim (void) 2701 { 2702 __asm__ __volatile__ ("vrfim 17, 14"); 2703 } 2704 2705 static void test_vrefp (void) 2706 { 2707 __asm__ __volatile__ ("vrefp 17, 14"); 2708 } 2709 2710 static void test_vrsqrtefp (void) 2711 { 2712 __asm__ __volatile__ ("vrsqrtefp 17, 14"); 2713 } 2714 2715 static void test_vlogefp (void) 2716 { 2717 __asm__ __volatile__ ("vlogefp 17, 14"); 2718 } 2719 2720 static void test_vexptefp (void) 2721 { 2722 __asm__ __volatile__ ("vexptefp 17, 14"); 2723 } 2724 2725 static test_t tests_afa_ops_one[] = { 2726 { &test_vrfin , " vrfin", }, 2727 { &test_vrfiz , " vrfiz", }, 2728 { &test_vrfip , " vrfip", }, 2729 { &test_vrfim , " vrfim", }, 2730 { &test_vrefp , " vrefp", }, 2731 { &test_vrsqrtefp , " vrsqrtefp", }, 2732 { &test_vlogefp , " vlogefp", }, 2733 { &test_vexptefp , " vexptefp", }, 2734 { NULL, NULL, }, 2735 }; 2736 #endif /* defined (HAS_ALTIVEC) */ 2737 2738 #if defined (HAS_ALTIVEC) 2739 static void test_vcmpgtfp (void) 2740 { 2741 __asm__ __volatile__ ("vcmpgtfp 17, 14, 15"); 2742 } 2743 2744 static void test_vcmpeqfp (void) 2745 { 2746 __asm__ __volatile__ ("vcmpeqfp 17, 14, 15"); 2747 } 2748 2749 static void test_vcmpgefp (void) 2750 { 2751 __asm__ __volatile__ ("vcmpgefp 17, 14, 15"); 2752 } 2753 2754 static void test_vcmpbfp (void) 2755 { 2756 __asm__ __volatile__ ("vcmpbfp 17, 14, 15"); 2757 } 2758 2759 static test_t tests_afc_ops_two[] = { 2760 { &test_vcmpgtfp , " vcmpgtfp", }, 2761 { &test_vcmpeqfp , " vcmpeqfp", }, 2762 { &test_vcmpgefp , " vcmpgefp", }, 2763 { &test_vcmpbfp , " vcmpbfp", }, 2764 { NULL, NULL, }, 2765 }; 2766 #endif /* defined (HAS_ALTIVEC) */ 2767 2768 #if defined (HAS_ALTIVEC) 2769 static void test_vcmpgtfp_ (void) 2770 { 2771 __asm__ __volatile__ ("vcmpgtfp. 17, 14, 15"); 2772 } 2773 2774 static void test_vcmpeqfp_ (void) 2775 { 2776 __asm__ __volatile__ ("vcmpeqfp. 17, 14, 15"); 2777 } 2778 2779 static void test_vcmpgefp_ (void) 2780 { 2781 __asm__ __volatile__ ("vcmpgefp. 17, 14, 15"); 2782 } 2783 2784 static void test_vcmpbfp_ (void) 2785 { 2786 __asm__ __volatile__ ("vcmpbfp. 17, 14, 15"); 2787 } 2788 2789 static test_t tests_afcr_ops_two[] = { 2790 { &test_vcmpgtfp_ , " vcmpgtfp.", }, 2791 { &test_vcmpeqfp_ , " vcmpeqfp.", }, 2792 { &test_vcmpgefp_ , " vcmpgefp.", }, 2793 { &test_vcmpbfp_ , " vcmpbfp.", }, 2794 { NULL, NULL, }, 2795 }; 2796 #endif /* defined (HAS_ALTIVEC) */ 2797 2798 #if defined (IS_PPC405) 2799 static void test_macchw (void) 2800 { 2801 __asm__ __volatile__ ("macchw 17, 14, 15"); 2802 } 2803 2804 static void test_macchwo (void) 2805 { 2806 __asm__ __volatile__ ("macchwo 17, 14, 15"); 2807 } 2808 2809 static void test_macchws (void) 2810 { 2811 __asm__ __volatile__ ("macchws 17, 14, 15"); 2812 } 2813 2814 static void test_macchwso (void) 2815 { 2816 __asm__ __volatile__ ("macchwso 17, 14, 15"); 2817 } 2818 2819 static void test_macchwsu (void) 2820 { 2821 __asm__ __volatile__ ("macchwsu 17, 14, 15"); 2822 } 2823 2824 static void test_macchwsuo (void) 2825 { 2826 __asm__ __volatile__ ("macchwsuo 17, 14, 15"); 2827 } 2828 2829 static void test_macchwu (void) 2830 { 2831 __asm__ __volatile__ ("macchwu 17, 14, 15"); 2832 } 2833 2834 static void test_macchwuo (void) 2835 { 2836 __asm__ __volatile__ ("macchwuo 17, 14, 15"); 2837 } 2838 2839 static void test_machhw (void) 2840 { 2841 __asm__ __volatile__ ("machhw 17, 14, 15"); 2842 } 2843 2844 static void test_machhwo (void) 2845 { 2846 __asm__ __volatile__ ("machhwo 17, 14, 15"); 2847 } 2848 2849 static void test_machhws (void) 2850 { 2851 __asm__ __volatile__ ("machhws 17, 14, 15"); 2852 } 2853 2854 static void test_machhwso (void) 2855 { 2856 __asm__ __volatile__ ("machhwso 17, 14, 15"); 2857 } 2858 2859 static void test_machhwsu (void) 2860 { 2861 __asm__ __volatile__ ("machhwsu 17, 14, 15"); 2862 } 2863 2864 static void test_machhwsuo (void) 2865 { 2866 __asm__ __volatile__ ("machhwsuo 17, 14, 15"); 2867 } 2868 2869 static void test_machhwu (void) 2870 { 2871 __asm__ __volatile__ ("machhwu 17, 14, 15"); 2872 } 2873 2874 static void test_machhwuo (void) 2875 { 2876 __asm__ __volatile__ ("machhwuo 17, 14, 15"); 2877 } 2878 2879 static void test_maclhw (void) 2880 { 2881 __asm__ __volatile__ ("maclhw 17, 14, 15"); 2882 } 2883 2884 static void test_maclhwo (void) 2885 { 2886 __asm__ __volatile__ ("maclhwo 17, 14, 15"); 2887 } 2888 2889 static void test_maclhws (void) 2890 { 2891 __asm__ __volatile__ ("maclhws 17, 14, 15"); 2892 } 2893 2894 static void test_maclhwso (void) 2895 { 2896 __asm__ __volatile__ ("maclhwso 17, 14, 15"); 2897 } 2898 2899 static void test_maclhwsu (void) 2900 { 2901 __asm__ __volatile__ ("maclhwsu 17, 14, 15"); 2902 } 2903 2904 static void test_maclhwsuo (void) 2905 { 2906 __asm__ __volatile__ ("maclhwsuo 17, 14, 15"); 2907 } 2908 2909 static void test_maclhwu (void) 2910 { 2911 __asm__ __volatile__ ("maclhwu 17, 14, 15"); 2912 } 2913 2914 static void test_maclhwuo (void) 2915 { 2916 __asm__ __volatile__ ("maclhwuo 17, 14, 15"); 2917 } 2918 2919 static void test_mulchw (void) 2920 { 2921 __asm__ __volatile__ ("mulchw 17, 14, 15"); 2922 } 2923 2924 static void test_mulchwu (void) 2925 { 2926 __asm__ __volatile__ ("mulchwu 17, 14, 15"); 2927 } 2928 2929 static void test_mulhhw (void) 2930 { 2931 __asm__ __volatile__ ("mulhhw 17, 14, 15"); 2932 } 2933 2934 static void test_mulhhwu (void) 2935 { 2936 __asm__ __volatile__ ("mulhhwu 17, 14, 15"); 2937 } 2938 2939 static void test_mullhw (void) 2940 { 2941 __asm__ __volatile__ ("mullhw 17, 14, 15"); 2942 } 2943 2944 static void test_mullhwu (void) 2945 { 2946 __asm__ __volatile__ ("mullhwu 17, 14, 15"); 2947 } 2948 2949 static void test_nmacchw (void) 2950 { 2951 __asm__ __volatile__ ("nmacchw 17, 14, 15"); 2952 } 2953 2954 static void test_nmacchwo (void) 2955 { 2956 __asm__ __volatile__ ("nmacchwo 17, 14, 15"); 2957 } 2958 2959 static void test_nmacchws (void) 2960 { 2961 __asm__ __volatile__ ("nmacchws 17, 14, 15"); 2962 } 2963 2964 static void test_nmacchwso (void) 2965 { 2966 __asm__ __volatile__ ("nmacchwso 17, 14, 15"); 2967 } 2968 2969 static void test_nmachhw (void) 2970 { 2971 __asm__ __volatile__ ("nmachhw 17, 14, 15"); 2972 } 2973 2974 static void test_nmachhwo (void) 2975 { 2976 __asm__ __volatile__ ("nmachhwo 17, 14, 15"); 2977 } 2978 2979 static void test_nmachhws (void) 2980 { 2981 __asm__ __volatile__ ("nmachhws 17, 14, 15"); 2982 } 2983 2984 static void test_nmachhwso (void) 2985 { 2986 __asm__ __volatile__ ("nmachhwso 17, 14, 15"); 2987 } 2988 2989 static void test_nmaclhw (void) 2990 { 2991 __asm__ __volatile__ ("nmaclhw 17, 14, 15"); 2992 } 2993 2994 static void test_nmaclhwo (void) 2995 { 2996 __asm__ __volatile__ ("nmaclhwo 17, 14, 15"); 2997 } 2998 2999 static void test_nmaclhws (void) 3000 { 3001 __asm__ __volatile__ ("nmaclhws 17, 14, 15"); 3002 } 3003 3004 static void test_nmaclhwso (void) 3005 { 3006 __asm__ __volatile__ ("nmaclhwso 17, 14, 15"); 3007 } 3008 3009 static test_t tests_p4m_ops_two[] = { 3010 { &test_macchw , " macchw", }, 3011 { &test_macchwo , " macchwo", }, 3012 { &test_macchws , " macchws", }, 3013 { &test_macchwso , " macchwso", }, 3014 { &test_macchwsu , " macchwsu", }, 3015 { &test_macchwsuo , " macchwsuo", }, 3016 { &test_macchwu , " macchwu", }, 3017 { &test_macchwuo , " macchwuo", }, 3018 { &test_machhw , " machhw", }, 3019 { &test_machhwo , " machhwo", }, 3020 { &test_machhws , " machhws", }, 3021 { &test_machhwso , " machhwso", }, 3022 { &test_machhwsu , " machhwsu", }, 3023 { &test_machhwsuo , " machhwsuo", }, 3024 { &test_machhwu , " machhwu", }, 3025 { &test_machhwuo , " machhwuo", }, 3026 { &test_maclhw , " maclhw", }, 3027 { &test_maclhwo , " maclhwo", }, 3028 { &test_maclhws , " maclhws", }, 3029 { &test_maclhwso , " maclhwso", }, 3030 { &test_maclhwsu , " maclhwsu", }, 3031 { &test_maclhwsuo , " maclhwsuo", }, 3032 { &test_maclhwu , " maclhwu", }, 3033 { &test_maclhwuo , " maclhwuo", }, 3034 { &test_mulchw , " mulchw", }, 3035 { &test_mulchwu , " mulchwu", }, 3036 { &test_mulhhw , " mulhhw", }, 3037 { &test_mulhhwu , " mulhhwu", }, 3038 { &test_mullhw , " mullhw", }, 3039 { &test_mullhwu , " mullhwu", }, 3040 { &test_nmacchw , " nmacchw", }, 3041 { &test_nmacchwo , " nmacchwo", }, 3042 { &test_nmacchws , " nmacchws", }, 3043 { &test_nmacchwso , " nmacchwso", }, 3044 { &test_nmachhw , " nmachhw", }, 3045 { &test_nmachhwo , " nmachhwo", }, 3046 { &test_nmachhws , " nmachhws", }, 3047 { &test_nmachhwso , " nmachhwso", }, 3048 { &test_nmaclhw , " nmaclhw", }, 3049 { &test_nmaclhwo , " nmaclhwo", }, 3050 { &test_nmaclhws , " nmaclhws", }, 3051 { &test_nmaclhwso , " nmaclhwso", }, 3052 { NULL, NULL, }, 3053 }; 3054 #endif /* defined (IS_PPC405) */ 3055 3056 #if defined (IS_PPC405) 3057 static void test_macchw_ (void) 3058 { 3059 __asm__ __volatile__ ("macchw. 17, 14, 15"); 3060 } 3061 3062 static void test_macchwo_ (void) 3063 { 3064 __asm__ __volatile__ ("macchwo. 17, 14, 15"); 3065 } 3066 3067 static void test_macchws_ (void) 3068 { 3069 __asm__ __volatile__ ("macchws. 17, 14, 15"); 3070 } 3071 3072 static void test_macchwso_ (void) 3073 { 3074 __asm__ __volatile__ ("macchwso. 17, 14, 15"); 3075 } 3076 3077 static void test_macchwsu_ (void) 3078 { 3079 __asm__ __volatile__ ("macchwsu. 17, 14, 15"); 3080 } 3081 3082 static void test_macchwsuo_ (void) 3083 { 3084 __asm__ __volatile__ ("macchwsuo. 17, 14, 15"); 3085 } 3086 3087 static void test_macchwu_ (void) 3088 { 3089 __asm__ __volatile__ ("macchwu. 17, 14, 15"); 3090 } 3091 3092 static void test_macchwuo_ (void) 3093 { 3094 __asm__ __volatile__ ("macchwuo. 17, 14, 15"); 3095 } 3096 3097 static void test_machhw_ (void) 3098 { 3099 __asm__ __volatile__ ("machhw. 17, 14, 15"); 3100 } 3101 3102 static void test_machhwo_ (void) 3103 { 3104 __asm__ __volatile__ ("machhwo. 17, 14, 15"); 3105 } 3106 3107 static void test_machhws_ (void) 3108 { 3109 __asm__ __volatile__ ("machhws. 17, 14, 15"); 3110 } 3111 3112 static void test_machhwso_ (void) 3113 { 3114 __asm__ __volatile__ ("machhwso. 17, 14, 15"); 3115 } 3116 3117 static void test_machhwsu_ (void) 3118 { 3119 __asm__ __volatile__ ("machhwsu. 17, 14, 15"); 3120 } 3121 3122 static void test_machhwsuo_ (void) 3123 { 3124 __asm__ __volatile__ ("machhwsuo. 17, 14, 15"); 3125 } 3126 3127 static void test_machhwu_ (void) 3128 { 3129 __asm__ __volatile__ ("machhwu. 17, 14, 15"); 3130 } 3131 3132 static void test_machhwuo_ (void) 3133 { 3134 __asm__ __volatile__ ("machhwuo. 17, 14, 15"); 3135 } 3136 3137 static void test_maclhw_ (void) 3138 { 3139 __asm__ __volatile__ ("maclhw. 17, 14, 15"); 3140 } 3141 3142 static void test_maclhwo_ (void) 3143 { 3144 __asm__ __volatile__ ("maclhwo. 17, 14, 15"); 3145 } 3146 3147 static void test_maclhws_ (void) 3148 { 3149 __asm__ __volatile__ ("maclhws. 17, 14, 15"); 3150 } 3151 3152 static void test_maclhwso_ (void) 3153 { 3154 __asm__ __volatile__ ("maclhwso. 17, 14, 15"); 3155 } 3156 3157 static void test_maclhwsu_ (void) 3158 { 3159 __asm__ __volatile__ ("maclhwsu. 17, 14, 15"); 3160 } 3161 3162 static void test_maclhwsuo_ (void) 3163 { 3164 __asm__ __volatile__ ("maclhwsuo. 17, 14, 15"); 3165 } 3166 3167 static void test_maclhwu_ (void) 3168 { 3169 __asm__ __volatile__ ("maclhwu. 17, 14, 15"); 3170 } 3171 3172 static void test_maclhwuo_ (void) 3173 { 3174 __asm__ __volatile__ ("maclhwuo. 17, 14, 15"); 3175 } 3176 3177 static void test_mulchw_ (void) 3178 { 3179 __asm__ __volatile__ ("mulchw. 17, 14, 15"); 3180 } 3181 3182 static void test_mulchwu_ (void) 3183 { 3184 __asm__ __volatile__ ("mulchwu. 17, 14, 15"); 3185 } 3186 3187 static void test_mulhhw_ (void) 3188 { 3189 __asm__ __volatile__ ("mulhhw. 17, 14, 15"); 3190 } 3191 3192 static void test_mulhhwu_ (void) 3193 { 3194 __asm__ __volatile__ ("mulhhwu. 17, 14, 15"); 3195 } 3196 3197 static void test_mullhw_ (void) 3198 { 3199 __asm__ __volatile__ ("mullhw. 17, 14, 15"); 3200 } 3201 3202 static void test_mullhwu_ (void) 3203 { 3204 __asm__ __volatile__ ("mullhwu. 17, 14, 15"); 3205 } 3206 3207 static void test_nmacchw_ (void) 3208 { 3209 __asm__ __volatile__ ("nmacchw. 17, 14, 15"); 3210 } 3211 3212 static void test_nmacchwo_ (void) 3213 { 3214 __asm__ __volatile__ ("nmacchwo. 17, 14, 15"); 3215 } 3216 3217 static void test_nmacchws_ (void) 3218 { 3219 __asm__ __volatile__ ("nmacchws. 17, 14, 15"); 3220 } 3221 3222 static void test_nmacchwso_ (void) 3223 { 3224 __asm__ __volatile__ ("nmacchwso. 17, 14, 15"); 3225 } 3226 3227 static void test_nmachhw_ (void) 3228 { 3229 __asm__ __volatile__ ("nmachhw. 17, 14, 15"); 3230 } 3231 3232 static void test_nmachhwo_ (void) 3233 { 3234 __asm__ __volatile__ ("nmachhwo. 17, 14, 15"); 3235 } 3236 3237 static void test_nmachhws_ (void) 3238 { 3239 __asm__ __volatile__ ("nmachhws. 17, 14, 15"); 3240 } 3241 3242 static void test_nmachhwso_ (void) 3243 { 3244 __asm__ __volatile__ ("nmachhwso. 17, 14, 15"); 3245 } 3246 3247 static void test_nmaclhw_ (void) 3248 { 3249 __asm__ __volatile__ ("nmaclhw. 17, 14, 15"); 3250 } 3251 3252 static void test_nmaclhwo_ (void) 3253 { 3254 __asm__ __volatile__ ("nmaclhwo. 17, 14, 15"); 3255 } 3256 3257 static void test_nmaclhws_ (void) 3258 { 3259 __asm__ __volatile__ ("nmaclhws. 17, 14, 15"); 3260 } 3261 3262 static void test_nmaclhwso_ (void) 3263 { 3264 __asm__ __volatile__ ("nmaclhwso. 17, 14, 15"); 3265 } 3266 3267 static test_t tests_p4mc_ops_two[] = { 3268 { &test_macchw_ , " macchw.", }, 3269 { &test_macchwo_ , " macchwo.", }, 3270 { &test_macchws_ , " macchws.", }, 3271 { &test_macchwso_ , " macchwso.", }, 3272 { &test_macchwsu_ , " macchwsu.", }, 3273 { &test_macchwsuo_ , " macchwsuo.", }, 3274 { &test_macchwu_ , " macchwu.", }, 3275 { &test_macchwuo_ , " macchwuo.", }, 3276 { &test_machhw_ , " machhw.", }, 3277 { &test_machhwo_ , " machhwo.", }, 3278 { &test_machhws_ , " machhws.", }, 3279 { &test_machhwso_ , " machhwso.", }, 3280 { &test_machhwsu_ , " machhwsu.", }, 3281 { &test_machhwsuo_ , " machhwsuo.", }, 3282 { &test_machhwu_ , " machhwu.", }, 3283 { &test_machhwuo_ , " machhwuo.", }, 3284 { &test_maclhw_ , " maclhw.", }, 3285 { &test_maclhwo_ , " maclhwo.", }, 3286 { &test_maclhws_ , " maclhws.", }, 3287 { &test_maclhwso_ , " maclhwso.", }, 3288 { &test_maclhwsu_ , " maclhwsu.", }, 3289 { &test_maclhwsuo_ , " maclhwsuo.", }, 3290 { &test_maclhwu_ , " maclhwu.", }, 3291 { &test_maclhwuo_ , " maclhwuo.", }, 3292 { &test_mulchw_ , " mulchw.", }, 3293 { &test_mulchwu_ , " mulchwu.", }, 3294 { &test_mulhhw_ , " mulhhw.", }, 3295 { &test_mulhhwu_ , " mulhhwu.", }, 3296 { &test_mullhw_ , " mullhw.", }, 3297 { &test_mullhwu_ , " mullhwu.", }, 3298 { &test_nmacchw_ , " nmacchw.", }, 3299 { &test_nmacchwo_ , " nmacchwo.", }, 3300 { &test_nmacchws_ , " nmacchws.", }, 3301 { &test_nmacchwso_ , " nmacchwso.", }, 3302 { &test_nmachhw_ , " nmachhw.", }, 3303 { &test_nmachhwo_ , " nmachhwo.", }, 3304 { &test_nmachhws_ , " nmachhws.", }, 3305 { &test_nmachhwso_ , " nmachhwso.", }, 3306 { &test_nmaclhw_ , " nmaclhw.", }, 3307 { &test_nmaclhwo_ , " nmaclhwo.", }, 3308 { &test_nmaclhws_ , " nmaclhws.", }, 3309 { &test_nmaclhwso_ , " nmaclhwso.", }, 3310 { NULL, NULL, }, 3311 }; 3312 #endif /* defined (IS_PPC405) */ 3313 3314 static test_table_t all_tests[] = { 3315 { 3316 tests_ia_ops_two , 3317 "PPC integer arithmetic instructions with two arguments", 3318 0x00010102, 3319 }, 3320 { 3321 tests_iar_ops_two , 3322 "PPC integer instructions with two arguments with flags update", 3323 0x01010102, 3324 }, 3325 { 3326 tests_il_ops_two , 3327 "PPC integer logical instructions with two arguments", 3328 0x00010202, 3329 }, 3330 { 3331 tests_ilr_ops_two , 3332 "PPC integer logical instructions with two arguments with flags update", 3333 0x01010202, 3334 }, 3335 { 3336 tests_icr_ops_two , 3337 "PPC integer compare instructions (two arguents)", 3338 0x01010304, 3339 }, 3340 { 3341 tests_icr_ops_two_i16 , 3342 "PPC integer compare with immediate instructions (two arguents)", 3343 0x01010304, 3344 }, 3345 { 3346 tests_ia_ops_two_i16 , 3347 "PPC integer arithmetic instructions\n with one register + one 16 bits immediate arguments", 3348 0x00010106, 3349 }, 3350 { 3351 tests_iar_ops_two_i16 , 3352 "PPC integer arithmetic instructions\n with one register + one 16 bits immediate arguments with flags update", 3353 0x01010106, 3354 }, 3355 { 3356 tests_il_ops_two_i16 , 3357 "PPC integer logical instructions\n with one register + one 16 bits immediate arguments", 3358 0x00010206, 3359 }, 3360 { 3361 tests_ilr_ops_two_i16 , 3362 "PPC integer logical instructions\n with one register + one 16 bits immediate arguments with flags update", 3363 0x01010206, 3364 }, 3365 { 3366 tests_crl_ops_two , 3367 "PPC condition register logical instructions - two operands", 3368 0x01000602, 3369 }, 3370 { 3371 tests_ia_ops_one , 3372 "PPC integer arithmetic instructions with one argument", 3373 0x00010101, 3374 }, 3375 { 3376 tests_iar_ops_one , 3377 "PPC integer arithmetic instructions with one argument with flags update", 3378 0x01010101, 3379 }, 3380 { 3381 tests_il_ops_one , 3382 "PPC integer logical instructions with one argument", 3383 0x00010201, 3384 }, 3385 { 3386 tests_ilr_ops_one , 3387 "PPC integer logical instructions with one argument with flags update", 3388 0x01010201, 3389 }, 3390 { 3391 tests_il_ops_spe , 3392 "PPC logical instructions with special forms", 3393 0x00010207, 3394 }, 3395 { 3396 tests_ilr_ops_spe , 3397 "PPC logical instructions with special forms with flags update", 3398 0x01010207, 3399 }, 3400 #if !defined (NO_FLOAT) 3401 { 3402 tests_fa_ops_three , 3403 "PPC floating point arithmetic instructions with three arguments", 3404 0x00020103, 3405 }, 3406 #endif /* !defined (NO_FLOAT) */ 3407 #if !defined (NO_FLOAT) 3408 { 3409 tests_far_ops_three , 3410 "PPC floating point arithmetic instructions\n with three arguments with flags update", 3411 0x01020103, 3412 }, 3413 #endif /* !defined (NO_FLOAT) */ 3414 #if !defined (NO_FLOAT) 3415 { 3416 tests_fa_ops_two , 3417 "PPC floating point arithmetic instructions with two arguments", 3418 0x00020102, 3419 }, 3420 #endif /* !defined (NO_FLOAT) */ 3421 #if !defined (NO_FLOAT) 3422 { 3423 tests_far_ops_two , 3424 "PPC floating point arithmetic instructions\n with two arguments with flags update", 3425 0x01020102, 3426 }, 3427 #endif /* !defined (NO_FLOAT) */ 3428 #if !defined (NO_FLOAT) 3429 { 3430 tests_fcr_ops_two , 3431 "PPC floating point compare instructions (two arguments)", 3432 0x01020304, 3433 }, 3434 #endif /* !defined (NO_FLOAT) */ 3435 #if !defined (NO_FLOAT) 3436 { 3437 tests_fa_ops_one , 3438 "PPC floating point arithmetic instructions with one argument", 3439 0x00020101, 3440 }, 3441 #endif /* !defined (NO_FLOAT) */ 3442 #if !defined (NO_FLOAT) 3443 { 3444 tests_far_ops_one , 3445 "PPC floating point arithmetic instructions\n with one argument with flags update", 3446 0x01020101, 3447 }, 3448 #endif /* !defined (NO_FLOAT) */ 3449 #if !defined (NO_FLOAT) 3450 { 3451 tests_fl_ops_spe , 3452 "PPC floating point status register manipulation instructions", 3453 0x00020207, 3454 }, 3455 #endif /* !defined (NO_FLOAT) */ 3456 #if !defined (NO_FLOAT) 3457 { 3458 tests_flr_ops_spe , 3459 "PPC floating point status register manipulation instructions\n with flags update", 3460 0x01020207, 3461 }, 3462 #endif /* !defined (NO_FLOAT) */ 3463 #if defined (HAS_ALTIVEC) 3464 { 3465 tests_aa_ops_three , 3466 "PPC altivec integer arithmetic instructions with three arguments", 3467 0x00040103, 3468 }, 3469 #endif /* defined (HAS_ALTIVEC) */ 3470 #if defined (HAS_ALTIVEC) 3471 { 3472 tests_al_ops_three , 3473 "PPC altivec integer logical instructions with three arguments", 3474 0x00040203, 3475 }, 3476 #endif /* defined (HAS_ALTIVEC) */ 3477 #if defined (HAS_ALTIVEC) 3478 { 3479 tests_aa_ops_two , 3480 "PPC altivec integer arithmetic instructions with two arguments", 3481 0x00040102, 3482 }, 3483 #endif /* defined (HAS_ALTIVEC) */ 3484 #if defined (HAS_ALTIVEC) 3485 { 3486 tests_al_ops_two , 3487 "PPC altivec integer logical instructions with two arguments", 3488 0x00040202, 3489 }, 3490 #endif /* defined (HAS_ALTIVEC) */ 3491 #if defined (HAS_ALTIVEC) 3492 { 3493 tests_al_ops_one , 3494 "PPC altivec integer logical instructions with one argument", 3495 0x00040201, 3496 }, 3497 #endif /* defined (HAS_ALTIVEC) */ 3498 #if defined (HAS_ALTIVEC) 3499 { 3500 tests_ac_ops_two , 3501 "Altivec integer compare instructions", 3502 0x00040302, 3503 }, 3504 #endif /* defined (HAS_ALTIVEC) */ 3505 #if defined (HAS_ALTIVEC) 3506 { 3507 tests_acr_ops_two , 3508 "Altivec integer compare instructions with flags update", 3509 0x01040302, 3510 }, 3511 #endif /* defined (HAS_ALTIVEC) */ 3512 #if defined (HAS_ALTIVEC) 3513 { 3514 tests_afa_ops_three , 3515 "Altivec floating point arithmetic instructions with three arguments", 3516 0x00050103, 3517 }, 3518 #endif /* defined (HAS_ALTIVEC) */ 3519 #if defined (HAS_ALTIVEC) 3520 { 3521 tests_afa_ops_two , 3522 "Altivec floating point arithmetic instructions with two arguments", 3523 0x00050102, 3524 }, 3525 #endif /* defined (HAS_ALTIVEC) */ 3526 #if defined (HAS_ALTIVEC) 3527 { 3528 tests_afa_ops_one , 3529 "Altivec floating point arithmetic instructions with one argument", 3530 0x00050101, 3531 }, 3532 #endif /* defined (HAS_ALTIVEC) */ 3533 #if defined (HAS_ALTIVEC) 3534 { 3535 tests_afc_ops_two , 3536 "Altivec floating point compare instructions", 3537 0x00050302, 3538 }, 3539 #endif /* defined (HAS_ALTIVEC) */ 3540 #if defined (HAS_ALTIVEC) 3541 { 3542 tests_afcr_ops_two , 3543 "Altivec floating point compare instructions with flags update", 3544 0x01050302, 3545 }, 3546 #endif /* defined (HAS_ALTIVEC) */ 3547 #if defined (IS_PPC405) 3548 { 3549 tests_p4m_ops_two , 3550 "PPC 405 mac instructions with three arguments", 3551 0x00030102, 3552 }, 3553 #endif /* defined (IS_PPC405) */ 3554 #if defined (IS_PPC405) 3555 { 3556 tests_p4mc_ops_two , 3557 "PPC 405 mac instructions with three arguments with flags update", 3558 0x01030102, 3559 }, 3560 #endif /* defined (IS_PPC405) */ 3561 { NULL, NULL, 0x00000000, }, 3562 }; 3563 3564 // END #include "ops-ppc.c" 3565 3566 3567 static int verbose = 0; 3568 3569 static double *fargs; 3570 static int nb_fargs; 3571 static uint32_t *iargs; 3572 static int nb_iargs; 3573 static uint16_t *ii16; 3574 static int nb_ii16; 3575 3576 static inline void register_farg (void *farg, 3577 int s, uint16_t _exp, uint64_t mant) 3578 { 3579 uint64_t tmp; 3580 3581 tmp = ((uint64_t)s << 63) | ((uint64_t)_exp << 52) | mant; 3582 *(uint64_t *)farg = tmp; 3583 AB_DPRINTF("%d %03x %013llx => %016llx %0e\n", 3584 s, _exp, mant, *(uint64_t *)farg, *(double *)farg); 3585 } 3586 3587 static void build_fargs_table (void) 3588 { 3589 /* Sign goes from zero to one 3590 * Exponent goes from 0 to ((1 << 12) - 1) 3591 * Mantissa goes from 1 to ((1 << 52) - 1) 3592 * + special values: 3593 * +0.0 : 0 0x000 0x0000000000000 3594 * -0.0 : 1 0x000 0x0000000000000 3595 * +infinity : 0 0x7FF 0x0000000000000 3596 * -infinity : 1 0x7FF 0x0000000000000 3597 * +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF 3598 * -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF 3599 * +QNaN : 0 0x7FF 0x8000000000000 3600 * -QNaN : 1 0x7FF 0x8000000000000 3601 * (8 values) 3602 */ 3603 uint64_t mant; 3604 uint16_t _exp, e0, e1; 3605 int s; 3606 int i; 3607 3608 fargs = my_malloc(200 * sizeof(double)); 3609 i = 0; 3610 for (s = 0; s < 2; s++) { 3611 for (e0 = 0; e0 < 2; e0++) { 3612 for (e1 = 0x000; ; e1 = ((e1 + 1) << 2) + 6) { 3613 if (e1 >= 0x400) 3614 e1 = 0x3fe; 3615 _exp = (e0 << 10) | e1; 3616 for (mant = 0x0000000000001ULL; mant < (1ULL << 52); 3617 /* Add 'random' bits */ 3618 mant = ((mant + 0x4A6) << 13) + 0x359) { 3619 register_farg(&fargs[i++], s, _exp, mant); 3620 } 3621 if (e1 == 0x3fe) 3622 break; 3623 } 3624 } 3625 } 3626 /* Special values */ 3627 /* +0.0 : 0 0x000 0x0000000000000 */ 3628 s = 0; 3629 _exp = 0x000; 3630 mant = 0x0000000000000ULL; 3631 register_farg(&fargs[i++], s, _exp, mant); 3632 /* -0.0 : 1 0x000 0x0000000000000 */ 3633 s = 1; 3634 _exp = 0x000; 3635 mant = 0x0000000000000ULL; 3636 register_farg(&fargs[i++], s, _exp, mant); 3637 /* +infinity : 0 0x7FF 0x0000000000000 */ 3638 s = 0; 3639 _exp = 0x7FF; 3640 mant = 0x0000000000000ULL; 3641 register_farg(&fargs[i++], s, _exp, mant); 3642 /* -infinity : 1 0x7FF 0x0000000000000 */ 3643 s = 1; 3644 _exp = 0x7FF; 3645 mant = 0x0000000000000ULL; 3646 register_farg(&fargs[i++], s, _exp, mant); 3647 /* +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF */ 3648 s = 0; 3649 _exp = 0x7FF; 3650 mant = 0x7FFFFFFFFFFFFULL; 3651 register_farg(&fargs[i++], s, _exp, mant); 3652 /* -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF */ 3653 s = 1; 3654 _exp = 0x7FF; 3655 mant = 0x7FFFFFFFFFFFFULL; 3656 register_farg(&fargs[i++], s, _exp, mant); 3657 /* +QNaN : 0 0x7FF 0x8000000000000 */ 3658 s = 0; 3659 _exp = 0x7FF; 3660 mant = 0x8000000000000ULL; 3661 register_farg(&fargs[i++], s, _exp, mant); 3662 /* -QNaN : 1 0x7FF 0x8000000000000 */ 3663 s = 1; 3664 _exp = 0x7FF; 3665 mant = 0x8000000000000ULL; 3666 register_farg(&fargs[i++], s, _exp, mant); 3667 AB_DPRINTF("Registered %d floats values\n", i); 3668 nb_fargs = i; 3669 } 3670 3671 static void build_iargs_table (void) 3672 { 3673 uint64_t tmp; 3674 int i; 3675 3676 iargs = my_malloc(400 * sizeof(uint32_t)); 3677 i = 0; 3678 for (tmp = 0; ; tmp = tmp + 1 + (tmp>>1)+(tmp>>2)+(tmp>>3)) { 3679 if (tmp >= 0x100000000ULL) 3680 tmp = 0xFFFFFFFF; 3681 iargs[i++] = tmp; 3682 AB_DPRINTF("val %08llx\n", tmp); 3683 if (tmp == 0xFFFFFFFF) 3684 break; 3685 } 3686 AB_DPRINTF("Registered %d ints values\n", i); 3687 nb_iargs = i; 3688 } 3689 3690 static void build_ii16_table (void) 3691 { 3692 uint32_t tmp; 3693 int i; 3694 3695 ii16 = my_malloc(200 * sizeof(uint32_t)); 3696 i = 0; 3697 for (tmp = 0; ; tmp = tmp + 1 + (tmp>>1)+(tmp>>2)+(tmp>>3)) { 3698 if (tmp >= 0x10000) 3699 tmp = 0xFFFF; 3700 ii16[i++] = tmp; 3701 AB_DPRINTF("val %08llx\n", tmp); 3702 if (tmp == 0xFFFF) 3703 break; 3704 } 3705 AB_DPRINTF("Registered %d ints values\n", i); 3706 nb_ii16 = i; 3707 } 3708 3709 static void test_int_three_args (const unsigned char *name, test_func_t func) 3710 { 3711 uint32_t res, flags, xer; 3712 int i, j, k; 3713 3714 if (verbose > 1) 3715 vexxx_printf( "Test instruction %s\n", name); 3716 for (i = 0; i < nb_iargs; i++) { 3717 for (j = 0; j < nb_iargs; j++) { 3718 for (k = 0;k < nb_iargs; k++) { 3719 r14 = iargs[i]; 3720 r15 = iargs[j]; 3721 r16 = iargs[k]; 3722 r18 = 0; 3723 __asm__ __volatile__ ("mtcr 18"); 3724 __asm__ __volatile__ ("mtxer 18"); 3725 (*func)(); 3726 __asm__ __volatile__ ("mfcr 18"); 3727 flags = r18; 3728 __asm__ __volatile__ ("mfxer 18"); 3729 xer = r18; 3730 res = r17; 3731 vexxx_printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n", 3732 name, iargs[i], iargs[j], iargs[k], res, flags, xer); 3733 } 3734 vexxx_printf("\n"); 3735 } 3736 vexxx_printf("\n"); 3737 } 3738 vexxx_printf("\n"); 3739 } 3740 3741 static void test_int_two_args (const unsigned char *name, test_func_t func) 3742 { 3743 uint32_t res, flags, xer; 3744 int i, j; 3745 3746 if (verbose > 1) 3747 vexxx_printf( "Test instruction %s\n", name); 3748 for (i = 0; i < nb_iargs; i++) { 3749 for (j = 0; j < nb_iargs; j++) { 3750 r14 = iargs[i]; 3751 r15 = iargs[j]; 3752 r18 = 0; 3753 __asm__ __volatile__ ("mtcr 18"); 3754 __asm__ __volatile__ ("mtxer 18"); 3755 (*func)(); 3756 __asm__ __volatile__ ("mfcr 18"); 3757 flags = r18; 3758 __asm__ __volatile__ ("mfxer 18"); 3759 xer = r18; 3760 res = r17; 3761 vexxx_printf("%s %08x, %08x => %08x (%08x %08x)\n", 3762 name, iargs[i], iargs[j], res, flags, xer); 3763 } 3764 vexxx_printf("\n"); 3765 } 3766 vexxx_printf("\n"); 3767 } 3768 3769 static void test_int_one_arg (const unsigned char *name, test_func_t func) 3770 { 3771 uint32_t res, flags, xer; 3772 int i; 3773 3774 if (verbose > 1) 3775 vexxx_printf( "Test instruction %s\n", name); 3776 for (i = 0; i < nb_iargs; i++) { 3777 r14 = iargs[i]; 3778 r18 = 0; 3779 __asm__ __volatile__ ("mtcr 18"); 3780 // r18 = 0x20000000; // set xer_ca 3781 __asm__ __volatile__ ("mtxer 18"); 3782 (*func)(); 3783 res = r17; 3784 __asm__ __volatile__ ("mfcr 18"); 3785 flags = r18; 3786 __asm__ __volatile__ ("mfxer 18"); 3787 xer = r18; 3788 vexxx_printf("%s %08x => %08x (%08x %08x)\n", 3789 name, iargs[i], res, flags, xer); 3790 } 3791 vexxx_printf("\n"); 3792 } 3793 3794 static inline void _patch_op_imm (void *out, void *in, 3795 uint16_t imm, int sh, int len) 3796 { 3797 volatile uint32_t *p, *q; 3798 3799 p = out; 3800 q = in; 3801 *p = (*q & ~(((1 << len) - 1) << sh)) | ((imm & ((1 << len) - 1)) << sh); 3802 } 3803 3804 static inline void patch_op_imm (void *out, void *in, 3805 uint16_t imm, int sh, int len) 3806 { 3807 volatile uint32_t *p; 3808 3809 p = out; 3810 _patch_op_imm(out, in, imm, sh, len); 3811 __asm__ __volatile__ ("dcbf 0, %0 ; icbi 0, %0 ; isync" ::"r"(p)); 3812 } 3813 3814 static inline void patch_op_imm16 (void *out, void *in, uint16_t imm) 3815 { 3816 patch_op_imm(out, in, imm, 0, 16); 3817 } 3818 3819 static void test_int_one_reg_imm16 (const unsigned char *name, 3820 test_func_t func) 3821 { 3822 uint32_t func_buf[2], *p; 3823 uint32_t res, flags, xer; 3824 int i, j; 3825 3826 if (verbose > 1) 3827 vexxx_printf( "Test instruction %s\n", name); 3828 for (i = 0; i < nb_iargs; i++) { 3829 for (j = 0; j < nb_ii16; j++) { 3830 p = (void *)func; 3831 #if 0 3832 vexxx_printf("copy func %s from %p to %p (%08x %08x)\n", 3833 name, func, func_buf, p[0], p[1]); 3834 #endif 3835 func_buf[1] = p[1]; 3836 patch_op_imm16(func_buf, p, ii16[j]); 3837 func = (void *)func_buf; 3838 #if 0 3839 vexxx_printf(" => func %s from %p to %p (%08x %08x)\n", 3840 name, func, func_buf, func_buf[0], func_buf[1]); 3841 #endif 3842 r14 = iargs[i]; 3843 r18 = 0; 3844 __asm__ __volatile__ ("mtcr 18"); 3845 __asm__ __volatile__ ("mtxer 18"); 3846 (*func)(); 3847 __asm__ __volatile__ ("mfcr 18"); 3848 flags = r18; 3849 __asm__ __volatile__ ("mfxer 18"); 3850 xer = r18; 3851 res = r17; 3852 vexxx_printf("%s %08x, %08x => %08x (%08x %08x)\n", 3853 name, iargs[i], ii16[j], res, flags, xer); 3854 } 3855 vexxx_printf("\n"); 3856 } 3857 vexxx_printf("\n"); 3858 } 3859 3860 /* Special test cases for: 3861 * rlwimi 3862 * rlwinm 3863 * rlwnm 3864 * srawi 3865 * mcrf 3866 * mcrfs 3867 * mffs 3868 * mtfsb0 3869 * mtfsb1 3870 */ 3871 3872 static void rlwi_cb (const unsigned char *name, test_func_t func) 3873 { 3874 uint32_t func_buf[2], *p; 3875 uint32_t res, flags, xer; 3876 int i, j, k, l; 3877 3878 if (verbose > 1) 3879 vexxx_printf( "Test instruction %s\n", name); 3880 for (i = 0;;) { 3881 if (i >= nb_iargs) 3882 i = nb_iargs - 1; 3883 for (j = 0; j < 32; j++) { 3884 for (k = 0; k < 32; k++) { 3885 for (l = 0; l < 32; l++) { 3886 p = (void *)func; 3887 func_buf[1] = p[1]; 3888 _patch_op_imm(func_buf, p, j, 11, 5); 3889 _patch_op_imm(func_buf, p, k, 6, 5); 3890 patch_op_imm(func_buf, p, l, 1, 5); 3891 func = (void *)func_buf; 3892 r14 = iargs[i]; 3893 r18 = 0; 3894 __asm__ __volatile__ ("mtcr 18"); 3895 __asm__ __volatile__ ("mtxer 18"); 3896 (*func)(); 3897 __asm__ __volatile__ ("mfcr 18"); 3898 flags = r18; 3899 __asm__ __volatile__ ("mfxer 18"); 3900 xer = r18; 3901 res = r17; 3902 vexxx_printf("%s %08x, %d, %d, %d => %08x (%08x %08x)\n", 3903 name, iargs[i], j, k, l, res, flags, xer); 3904 } 3905 vexxx_printf("\n"); 3906 } 3907 vexxx_printf("\n"); 3908 } 3909 vexxx_printf("\n"); 3910 if (i == 0) 3911 i = 1; 3912 else if (i == nb_iargs - 1) 3913 break; 3914 else 3915 i += 3; 3916 } 3917 vexxx_printf("\n"); 3918 } 3919 3920 static void rlwnm_cb (const unsigned char *name, test_func_t func) 3921 { 3922 uint32_t func_buf[2], *p; 3923 uint32_t res, flags, xer; 3924 int i, j, k, l; 3925 3926 if (verbose > 1) 3927 vexxx_printf( "Test instruction %s\n", name); 3928 for (i = 0; i < nb_iargs; i++) { 3929 for (j = 0; j < 64; j++) { 3930 for (k = 0; k < 32; k++) { 3931 for (l = 0; l < 32; l++) { 3932 p = (void *)func; 3933 func_buf[1] = p[1]; 3934 _patch_op_imm(func_buf, p, k, 6, 5); 3935 patch_op_imm(func_buf, p, l, 1, 5); 3936 func = (void *)func_buf; 3937 r14 = iargs[i]; 3938 r15 = j; 3939 r18 = 0; 3940 __asm__ __volatile__ ("mtcr 18"); 3941 __asm__ __volatile__ ("mtxer 18"); 3942 (*func)(); 3943 __asm__ __volatile__ ("mfcr 18"); 3944 flags = r18; 3945 __asm__ __volatile__ ("mfxer 18"); 3946 xer = r18; 3947 res = r17; 3948 vexxx_printf("%s %08x, %08x, %d, %d => %08x (%08x %08x)\n", 3949 name, iargs[i], j, k, l, res, flags, xer); 3950 } 3951 vexxx_printf("\n"); 3952 } 3953 vexxx_printf("\n"); 3954 } 3955 vexxx_printf("\n"); 3956 } 3957 vexxx_printf("\n"); 3958 } 3959 3960 static void srawi_cb (const unsigned char *name, test_func_t func) 3961 { 3962 uint32_t func_buf[2], *p; 3963 uint32_t res, flags, xer; 3964 int i, j; 3965 3966 if (verbose > 1) 3967 vexxx_printf( "Test instruction %s\n", name); 3968 for (i = 0; i < nb_iargs; i++) { 3969 for (j = 0; j < 32; j++) { 3970 p = (void *)func; 3971 func_buf[1] = p[1]; 3972 patch_op_imm(func_buf, p, j, 11, 5); 3973 func = (void *)func_buf; 3974 r14 = iargs[i]; 3975 r18 = 0; 3976 __asm__ __volatile__ ("mtcr 18"); 3977 __asm__ __volatile__ ("mtxer 18"); 3978 (*func)(); 3979 __asm__ __volatile__ ("mfcr 18"); 3980 flags = r18; 3981 __asm__ __volatile__ ("mfxer 18"); 3982 xer = r18; 3983 res = r17; 3984 vexxx_printf("%s %08x, %d => %08x (%08x %08x)\n", 3985 name, iargs[i], j, res, flags, xer); 3986 } 3987 vexxx_printf("\n"); 3988 } 3989 vexxx_printf("\n"); 3990 } 3991 3992 typedef struct special_t special_t; 3993 struct special_t { 3994 const unsigned char *name; 3995 void (*test_cb)(const unsigned char *name, test_func_t func); 3996 }; 3997 3998 static void test_special (special_t *table, 3999 const unsigned char *name, test_func_t func) 4000 { 4001 const unsigned char *tmp; 4002 int i; 4003 4004 for (tmp = name; my_isspace(*tmp); tmp++) 4005 continue; 4006 for (i = 0; table[i].name != NULL; i++) { 4007 #if 0 4008 vexxx_printf( "look for handler for '%s' (%s)\n", name, 4009 table[i].name); 4010 #endif 4011 if (my_strcmp(table[i].name, tmp) == 0) { 4012 (*table[i].test_cb)(name, func); 4013 return; 4014 } 4015 } 4016 vexxx_printf( "ERROR: no test found for op '%s'\n", name); 4017 } 4018 4019 static special_t special_int_ops[] = { 4020 #if 0 4021 { 4022 "rlwimi", /* One register + 3 5 bits immediate arguments */ 4023 &rlwi_cb, 4024 }, 4025 { 4026 "rlwimi.", /* One register + 3 5 bits immediate arguments */ 4027 &rlwi_cb, 4028 }, 4029 { 4030 "rlwinm", /* One register + 3 5 bits immediate arguments */ 4031 &rlwi_cb, 4032 }, 4033 { 4034 "rlwinm.", /* One register + 3 5 bits immediate arguments */ 4035 &rlwi_cb, 4036 }, 4037 { 4038 "rlwnm", /* Two registers + 3 5 bits immediate arguments */ 4039 &rlwnm_cb, 4040 }, 4041 { 4042 "rlwnm.", /* Two registers + 3 5 bits immediate arguments */ 4043 &rlwnm_cb, 4044 }, 4045 { 4046 "srawi", /* One register + 1 5 bits immediate arguments */ 4047 &srawi_cb, 4048 }, 4049 { 4050 "srawi.", /* One register + 1 5 bits immediate arguments */ 4051 &srawi_cb, 4052 }, 4053 #endif 4054 #if 0 4055 { 4056 "mcrf", /* 2 3 bits immediate arguments */ 4057 &mcrf_cb, 4058 }, 4059 { 4060 "mcrf", /* 2 3 bits immediate arguments */ 4061 &mcrf_cb, 4062 }, 4063 #endif 4064 { 4065 NULL, 4066 NULL, 4067 }, 4068 }; 4069 4070 static void test_int_special (const unsigned char *name, test_func_t func) 4071 { 4072 test_special(special_int_ops, name, func); 4073 } 4074 4075 static test_loop_t int_loops[] = { 4076 &test_int_one_arg, 4077 &test_int_two_args, 4078 &test_int_three_args, 4079 &test_int_two_args, 4080 &test_int_one_reg_imm16, 4081 &test_int_one_reg_imm16, 4082 &test_int_special, 4083 }; 4084 4085 #if !defined (NO_FLOAT) 4086 static void test_float_three_args (const unsigned char *name, test_func_t func) 4087 { 4088 double res; 4089 uint64_t u0, u1, u2, ur; 4090 uint32_t flags; 4091 int i, j, k; 4092 4093 if (verbose > 1) 4094 vexxx_printf( "Test instruction %s\n", name); 4095 for (i = 0; i < nb_fargs; i++) { 4096 for (j = 0; j < nb_fargs; j++) { 4097 for (k = 0;k < nb_fargs; k++) { 4098 u0 = *(uint64_t *)(&fargs[i]); 4099 u1 = *(uint64_t *)(&fargs[j]); 4100 u2 = *(uint64_t *)(&fargs[k]); 4101 f14 = fargs[i]; 4102 f15 = fargs[j]; 4103 f16 = fargs[k]; 4104 r18 = 0; 4105 __asm__ __volatile__ ("mtcr 18"); 4106 __asm__ __volatile__ ("mtxer 18"); 4107 f18 = +0.0; 4108 __asm__ __volatile__ ("mtfsf 0xFF, 18"); 4109 (*func)(); 4110 __asm__ __volatile__ ("mfcr 18"); 4111 flags = r18; 4112 res = f17; 4113 ur = *(uint64_t *)(&res); 4114 vexxx_printf("%s %016llx, %016llx, %016llx => %016llx (%08x)\n", 4115 name, u0, u1, u2, ur, flags); 4116 } 4117 vexxx_printf("\n"); 4118 } 4119 vexxx_printf("\n"); 4120 } 4121 vexxx_printf("\n"); 4122 } 4123 4124 static void test_float_two_args (const unsigned char *name, test_func_t func) 4125 { 4126 double res; 4127 uint64_t u0, u1, ur; 4128 uint32_t flags; 4129 int i, j; 4130 4131 if (verbose > 1) 4132 vexxx_printf( "Test instruction %s\n", name); 4133 for (i = 0; i < nb_fargs; i++) { 4134 for (j = 0; j < nb_fargs; j++) { 4135 u0 = *(uint64_t *)(&fargs[i]); 4136 u1 = *(uint64_t *)(&fargs[j]); 4137 f14 = fargs[i]; 4138 f15 = fargs[j]; 4139 r18 = 0; 4140 __asm__ __volatile__ ("mtcr 18"); 4141 __asm__ __volatile__ ("mtxer 18"); 4142 f18 = +0.0; 4143 __asm__ __volatile__ ("mtfsf 0xFF, 18"); 4144 (*func)(); 4145 __asm__ __volatile__ ("mfcr 18"); 4146 flags = r18; 4147 res = f17; 4148 ur = *(uint64_t *)(&res); 4149 vexxx_printf("%s %016llx, %016llx => %016llx (%08x)\n", 4150 name, u0, u1, ur, flags); 4151 } 4152 vexxx_printf("\n"); 4153 } 4154 vexxx_printf("\n"); 4155 } 4156 4157 static void test_float_one_arg (const unsigned char *name, test_func_t func) 4158 { 4159 double res; 4160 uint64_t u0, ur; 4161 uint32_t flags; 4162 int i; 4163 4164 if (verbose > 1) 4165 vexxx_printf( "Test instruction %s\n", name); 4166 for (i = 0; i < nb_fargs; i++) { 4167 u0 = *(uint64_t *)(&fargs[i]); 4168 f14 = fargs[i]; 4169 r18 = 0; 4170 __asm__ __volatile__ ("mtcr 18"); 4171 __asm__ __volatile__ ("mtxer 18"); 4172 f18 = +0.0; 4173 __asm__ __volatile__ ("mtfsf 0xFF, 18"); 4174 (*func)(); 4175 __asm__ __volatile__ ("mfcr 18"); 4176 flags = r18; 4177 res = f17; 4178 ur = *(uint64_t *)(&res); 4179 vexxx_printf("%s %016llx => %016llx (%08x)\n", name, u0, ur, flags); 4180 } 4181 vexxx_printf("\n"); 4182 } 4183 4184 static special_t special_float_ops[] = { 4185 #if 0 4186 { 4187 "mffs", /* One 5 bits immediate argument */ 4188 &mffs_cb, 4189 }, 4190 { 4191 "mffs.", /* One 5 bits immediate argument */ 4192 &mffs_cb, 4193 }, 4194 { 4195 "mtfsb0", /* One 5 bits immediate argument */ 4196 &mffs_cb, 4197 }, 4198 { 4199 "mtfsb0.", /* One 5 bits immediate argument */ 4200 &mffs_cb, 4201 }, 4202 { 4203 "mtfsb1", /* One 5 bits immediate argument */ 4204 &mffs_cb, 4205 }, 4206 { 4207 "mtfsb1.", /* One 5 bits immediate argument */ 4208 &mffs_cb, 4209 }, 4210 { 4211 "mtfsf", /* One register + 1 8 bits immediate argument */ 4212 &mtfsf_cb, 4213 }, 4214 { 4215 "mtfsf.", /* One register + 1 8 bits immediate argument */ 4216 &mtfsf_cb, 4217 }, 4218 { 4219 "mtfsfi", /* One 5 bits argument + 1 5 bits argument */ 4220 &mtfsfi_cb, 4221 }, 4222 { 4223 "mtfsfi.", /* One 5 bits argument + 1 5 bits argument */ 4224 &mtfsfi_cb, 4225 }, 4226 #endif 4227 { 4228 NULL, 4229 NULL, 4230 }, 4231 }; 4232 4233 static void test_float_special (const unsigned char *name, test_func_t func) 4234 { 4235 test_special(special_float_ops, name, func); 4236 } 4237 4238 static test_loop_t float_loops[] = { 4239 &test_float_one_arg, 4240 &test_float_two_args, 4241 &test_float_three_args, 4242 &test_float_two_args, 4243 NULL, 4244 NULL, 4245 &test_float_special, 4246 }; 4247 #endif /* !defined (NO_FLOAT) */ 4248 4249 4250 #if defined (HAS_ALTIVEC) /* XXX: TODO */ 4251 #endif /* defined (HAS_ALTIVEC) */ 4252 4253 #if defined (IS_PPC405) 4254 static void test_ppc405 (const unsigned char *name, test_func_t func) 4255 { 4256 uint32_t res, flags, xer; 4257 int i, j, k; 4258 4259 if (verbose > 1) 4260 vexxx_printf( "Test instruction %s\n", name); 4261 for (i = 0; i < nb_iargs; i++) { 4262 for (j = 0; j < nb_iargs; j++) { 4263 for (k = 0;k < nb_iargs; k++) { 4264 r14 = iargs[i]; 4265 r15 = iargs[j]; 4266 /* Beware: the third argument and the result 4267 * are in the same register 4268 */ 4269 r17 = iargs[k]; 4270 r18 = 0; 4271 __asm__ __volatile__ ("mtcr 18"); 4272 __asm__ __volatile__ ("mtxer 18"); 4273 (*func)(); 4274 __asm__ __volatile__ ("mfcr 18"); 4275 flags = r18; 4276 __asm__ __volatile__ ("mfxer 18"); 4277 xer = r18; 4278 res = r17; 4279 vexxx_printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n", 4280 name, iargs[i], iargs[j], iargs[k], res, flags, xer); 4281 } 4282 vexxx_printf("\n"); 4283 } 4284 vexxx_printf("\n"); 4285 } 4286 vexxx_printf("\n"); 4287 } 4288 #endif /* defined (IS_PPC405) */ 4289 4290 static int check_filter (unsigned char *filter) 4291 { 4292 unsigned char *c; 4293 int ret = 1; 4294 4295 if (filter != NULL) { 4296 c = my_strchr(filter, '*'); 4297 if (c != NULL) { 4298 *c = '\0'; 4299 ret = 0; 4300 } 4301 } 4302 4303 return ret; 4304 } 4305 4306 static int check_name (const unsigned char *name, const unsigned char *filter, 4307 int exact) 4308 { 4309 int nlen, flen; 4310 int ret = 0; 4311 4312 if (filter != NULL) { 4313 for (; my_isspace(*name); name++) 4314 continue; 4315 FDPRINTF("Check '%s' againt '%s' (%s match)\n", 4316 name, filter, exact ? "exact" : "starting"); 4317 nlen = vexxx_strlen(name); 4318 flen = vexxx_strlen(filter); 4319 if (exact) { 4320 if (nlen == flen && my_memcmp(name, filter, flen) == 0) 4321 ret = 1; 4322 } else { 4323 if (flen <= nlen && my_memcmp(name, filter, flen) == 0) 4324 ret = 1; 4325 } 4326 } else { 4327 ret = 1; 4328 } 4329 4330 return ret; 4331 } 4332 4333 static void do_tests (int one_arg, int two_args, int three_args, 4334 int arith, int logical, int compare, 4335 int integer, int floats, int p405, 4336 int altivec, int faltivec, 4337 int cr, unsigned char *filter) 4338 { 4339 #if defined (IS_PPC405) 4340 test_loop_t tmpl; 4341 #endif 4342 test_loop_t *loop; 4343 test_t *tests; 4344 int nb_args, type, family; 4345 int i, j, n; 4346 int exact; 4347 4348 exact = check_filter(filter); 4349 n = 0; 4350 for (i = 0; all_tests[i].name != NULL; i++) { 4351 nb_args = all_tests[i].flags & PPC_NB_ARGS; 4352 /* Check number of arguments */ 4353 if ((nb_args == 1 && !one_arg) || 4354 (nb_args == 2 && !two_args) || 4355 (nb_args == 3 && !three_args)) 4356 continue; 4357 /* Check instruction type */ 4358 type = all_tests[i].flags & PPC_TYPE; 4359 if ((type == PPC_ARITH && !arith) || 4360 (type == PPC_LOGICAL && !logical) || 4361 (type == PPC_COMPARE && !compare)) 4362 continue; 4363 /* Check instruction family */ 4364 family = all_tests[i].flags & PPC_FAMILY; 4365 if ((family == PPC_INTEGER && !integer) || 4366 (family == PPC_FLOAT && !floats) || 4367 (family == PPC_405 && !p405) || 4368 (family == PPC_ALTIVEC && !altivec) || 4369 (family == PPC_FALTIVEC && !faltivec)) 4370 continue; 4371 /* Check flags update */ 4372 if (((all_tests[i].flags & PPC_CR) && cr == 0) || 4373 (!(all_tests[i].flags & PPC_CR) && cr == 1)) 4374 continue; 4375 /* All passed, do the tests */ 4376 tests = all_tests[i].tests; 4377 /* Select the test loop */ 4378 switch (family) { 4379 case PPC_INTEGER: 4380 loop = &int_loops[nb_args - 1]; 4381 break; 4382 case PPC_FLOAT: 4383 #if !defined (NO_FLOAT) 4384 loop = &float_loops[nb_args - 1]; 4385 break; 4386 #else 4387 vexxx_printf( "Sorry. " 4388 "PPC floating point instructions tests " 4389 "are disabled on your host\n"); 4390 #endif /* !defined (NO_FLOAT) */ 4391 4392 case PPC_405: 4393 #if defined (IS_PPC405) 4394 tmpl = &test_ppc405; 4395 loop = &tmpl; 4396 break; 4397 #else 4398 vexxx_printf( "Sorry. " 4399 "PPC405 instructions tests are disabled on your host\n"); 4400 continue; 4401 #endif /* defined (IS_PPC405) */ 4402 case PPC_ALTIVEC: 4403 #if defined (HAS_ALTIVEC) 4404 #if 0 4405 loop = &altivec_int_loops[nb_args - 1]; 4406 break; 4407 #else 4408 vexxx_printf( "Sorry. " 4409 "Altivec instructions tests are not yet implemented\n"); 4410 continue; 4411 #endif 4412 #else 4413 vexxx_printf( "Sorry. " 4414 "Altivec instructions tests are disabled on your host\n"); 4415 continue; 4416 #endif 4417 case PPC_FALTIVEC: 4418 #if defined (HAS_ALTIVEC) 4419 #if 0 4420 loop = &altivec_float_loops[nb_args - 1]; 4421 break; 4422 #else 4423 vexxx_printf( "Sorry. " 4424 "Altivec instructions tests are not yet implemented\n"); 4425 continue; 4426 #endif 4427 #else 4428 vexxx_printf( "Sorry. " 4429 "Altivec float instructions tests " 4430 "are disabled on your host\n"); 4431 #endif 4432 continue; 4433 default: 4434 vexxx_printf("ERROR: unknown insn family %08x\n", family); 4435 continue; 4436 } 4437 if (verbose > 0) 4438 vexxx_printf( "%s:\n", all_tests[i].name); 4439 for (j = 0; tests[j].name != NULL; j++) { 4440 if (check_name(tests[j].name, filter, exact)) 4441 (*loop)(tests[j].name, tests[j].func); 4442 n++; 4443 } 4444 vexxx_printf("\n"); 4445 } 4446 vexxx_printf( "All done. Tested %d different instructions\n", n); 4447 } 4448 4449 #if 0 // unused 4450 static void usage (void) 4451 { 4452 vexxx_printf( 4453 "test-ppc [-1] [-2] [-3] [-*] [-t <type>] [-f <family>] [-u] " 4454 "[-n <filter>] [-x] [-h]\n" 4455 "\t-1: test opcodes with one argument\n" 4456 "\t-2: test opcodes with two arguments\n" 4457 "\t-3: test opcodes with three arguments\n" 4458 "\t-*: launch test without checking the number of arguments\n" 4459 "\t-t: launch test for instructions of type <type>\n" 4460 "\t recognized types:\n" 4461 "\t\tarith (or a)\n" 4462 "\t\tlogical (or l)\n" 4463 "\t\tcompare (or c)\n" 4464 "\t-f: launch test for instructions of family <family>\n" 4465 "\t recognized families:\n" 4466 "\t\tinteger (or i)\n" 4467 "\t\tfloat (or f)\n" 4468 "\t\tppc405 (or mac)\n" 4469 "\t\taltivec (or a)\n" 4470 "\t-u: test instructions that update flags\n" 4471 "\t-n: filter instructions with <filter>\n" 4472 "\t <filter> can be in two forms:\n" 4473 "\t\tname : filter functions that exactly match <name>\n" 4474 "\t\tname* : filter functions that start with <name>\n" 4475 "\t-h: print this help\n" 4476 ); 4477 } 4478 #endif 4479 4480 int _main (int argc, char **argv) 4481 { 4482 unsigned char /* *tmp, */ *filter = NULL; 4483 int one_arg = 0, two_args = 0, three_args = 0; 4484 int arith = 0, logical = 0, compare = 0; 4485 int integer = 0, floats = 0, p405 = 0, altivec = 0, faltivec = 0; 4486 int cr = -1; 4487 //int c; 4488 4489 // while ((c = getopt(argc, argv, "123t:f:n:uvh")) != -1) { 4490 // switch (c) { 4491 // case '1': 4492 // one_arg = 1; 4493 // break; 4494 // case '2': 4495 // two_args = 1; 4496 // break; 4497 // case '3': 4498 // three_args = 1; 4499 // break; 4500 // case 't': 4501 // tmp = optarg; 4502 // if (my_strcmp(tmp, "arith") == 0 || my_strcmp(tmp, "a") == 0) { 4503 // arith = 1; 4504 // } else if (my_strcmp(tmp, "logical") == 0 || my_strcmp(tmp, "l") == 0) { 4505 // logical = 1; 4506 // } else if (my_strcmp(tmp, "compare") == 0 || my_strcmp(tmp, "c") == 0) { 4507 // compare = 1; 4508 // } else { 4509 // goto bad_arg; 4510 // } 4511 // break; 4512 // case 'f': 4513 // tmp = optarg; 4514 // if (my_strcmp(tmp, "integer") == 0 || my_strcmp(tmp, "i") == 0) { 4515 // integer = 1; 4516 // } else if (my_strcmp(tmp, "float") == 0 || my_strcmp(tmp, "f") == 0) { 4517 // floats = 1; 4518 // } else if (my_strcmp(tmp, "ppc405") == 0 || my_strcmp(tmp, "mac") == 0) { 4519 // p405 = 1; 4520 // } else if (my_strcmp(tmp, "altivec") == 0 || my_strcmp(tmp, "a") == 0) { 4521 // altivec = 1; 4522 // faltivec = 1; 4523 // } else { 4524 // goto bad_arg; 4525 // } 4526 // break; 4527 // case 'n': 4528 // filter = optarg; 4529 // break; 4530 // case 'u': 4531 // cr = 1; 4532 // break; 4533 // case 'h': 4534 // usage(); 4535 // return 0; 4536 // case 'v': 4537 // verbose++; 4538 // break; 4539 // default: 4540 // usage(); 4541 // vexxx_printf( "Unknown argument: '%c'\n", c); 4542 // return 1; 4543 // bad_arg: 4544 // usage(); 4545 // vexxx_printf( "Bad argument for '%c': '%s'\n", c, tmp); 4546 // return 1; 4547 // } 4548 // } 4549 // if (argc != optind) { 4550 // usage(); 4551 // vexxx_printf( "Bad number of arguments\n"); 4552 // return 1; 4553 // } 4554 4555 if (one_arg == 0 && two_args == 0 && three_args == 0) { 4556 one_arg = 1; 4557 two_args = 1; 4558 three_args = 1; 4559 } 4560 if (arith == 0 && logical == 0 && compare == 0) { 4561 arith = 1; 4562 logical = 1; 4563 compare = 1; 4564 } 4565 if (integer == 0 && floats == 0 && altivec == 0 && faltivec == 0 && 4566 p405 == 0) { 4567 integer = 1; 4568 floats = 1; 4569 altivec = 1; 4570 faltivec = 1; 4571 p405 = 1; 4572 } 4573 if (cr == -1) 4574 cr = 2; 4575 build_iargs_table(); 4576 build_fargs_table(); 4577 build_ii16_table(); 4578 4579 #if 1 4580 one_arg=1; 4581 two_args=1; 4582 three_args=1; 4583 4584 arith=1; 4585 logical=1; 4586 compare=1; 4587 4588 integer=1; 4589 floats=0; 4590 4591 p405=0; 4592 altivec=0; 4593 faltivec=0; 4594 #endif 4595 4596 do_tests(one_arg, two_args, three_args, 4597 arith, logical, compare, 4598 integer, floats, p405, altivec, faltivec, 4599 cr, filter); 4600 4601 return 0; 4602 } 4603 4604 4605 void entry ( HWord(*service)(HWord,HWord) ) 4606 { 4607 char* argv[2] = { NULL, NULL }; 4608 serviceFn = service; 4609 _main(0, argv); 4610 (*service)(0,0); 4611 } 4612