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