2 /* HOW TO COMPILE FOR SWITCHBACK:
4 gcc -O -c test_ppc_jm1.c -mregnames -Wall
15 * PPC tests for qemu-PPC CPU emulation checks
17 * Copyright (c) 2005 Jocelyn Mayer
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.
25 * Theory of operations:
26 * a few registers are reserved for the test program:
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.
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.
51 #define NULL ((void*)0)
53 //#include "test-ppc.h"
55 // BEGIN #include "test-ppc.h"
58 * PPC tests for qemu-PPC CPU emulation checks - definitions
60 * Copyright (c) 2005 Jocelyn Mayer
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.
67 #if !defined (__TEST_PPC_H__)
68 #define __TEST_PPC_H__
70 typedef void (*test_func_t
) (void);
71 typedef struct test_t test_t
;
72 typedef struct test_table_t test_table_t
;
75 const unsigned char *name
;
80 const unsigned char *name
;
84 typedef void (*test_loop_t
) (const unsigned char *name
, test_func_t func
);
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,
97 PPC_ARITH
= 0x00000100,
98 PPC_LOGICAL
= 0x00000200,
99 PPC_COMPARE
= 0x00000300,
100 PPC_CROP
= 0x00000400,
101 PPC_TYPE
= 0x00000F00,
103 PPC_INTEGER
= 0x00010000,
104 PPC_FLOAT
= 0x00020000,
105 PPC_405
= 0x00030000,
106 PPC_ALTIVEC
= 0x00040000,
107 PPC_FALTIVEC
= 0x00050000,
108 PPC_FAMILY
= 0x000F0000,
113 #endif /* !defined (__TEST_PPC_H__) */
115 // END #include "test-ppc.h"
120 //#define DEBUG_ARGS_BUILD
121 #if defined (DEBUG_ARGS_BUILD)
122 #define AB_DPRINTF(fmt, args...) do { vexxx_printf(fmt , ##args); } while (0)
124 #define AB_DPRINTF(fmt, args...) do { } while (0)
127 //#define DEBUG_FILTER
128 #if defined (DEBUG_FILTER)
129 #define FDPRINTF(fmt, args...) do { vexxx_printf(fmt , ##args); } while (0)
131 #define FDPRINTF(fmt, args...) do { } while (0)
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");
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");
148 /////////////////////////////////////////////////////////////////////
149 /////////////////////////////////////////////////////////////////////
150 /////////////////////////////////////////////////////////////////////
151 /////////////////////////////////////////////////////////////////////
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
157 typedef unsigned long HWord
;
159 typedef signed int Int
;
160 typedef unsigned int UInt
;
161 typedef unsigned char UChar
;
163 typedef signed long long int Long
;
164 typedef unsigned long long int ULong
;
166 typedef unsigned char Bool
;
167 #define True ((Bool)1)
168 #define False ((Bool)0)
171 //#include "/home/sewardj/VEX/trunk/pub/libvex_basictypes.h"
173 static HWord (*serviceFn
)(HWord
,HWord
) = 0;
175 static Bool
my_isspace ( UChar c
)
186 static char* my_strcpy ( char* dest
, const char* src
)
188 char* dest_orig
= dest
;
189 while (*src
) *dest
++ = *src
++;
194 static void* my_memcpy ( void *dest
, const void *src
, int sz
)
196 const char *s
= (const char *)src
;
197 char *d
= (char *)dest
;
205 static void* my_memmove( void *dst
, const void *src
, unsigned int len
)
210 d
= (char *)dst
+ len
- 1;
211 s
= (char *)src
+ len
- 1;
222 } else if ( dst
< src
) {
240 char* my_strcat ( char* dest
, const char* src
)
242 char* dest_orig
= dest
;
243 while (*dest
) dest
++;
244 while (*src
) *dest
++ = *src
++;
249 int my_strcmp ( const char* s1
, const char* s2
)
251 register unsigned char c1
;
252 register unsigned char c2
;
254 c1
= *(unsigned char *)s1
;
255 c2
= *(unsigned char *)s2
;
260 if ((unsigned char)c1
< (unsigned char)c2
) return -1;
261 if ((unsigned char)c1
> (unsigned char)c2
) return 1;
266 int my_memcmp ( const void *s1V
, const void *s2V
, int n
)
271 unsigned char* s1
= (unsigned char*)s1V
;
272 unsigned char* s2
= (unsigned char*)s2V
;
279 res
= ((int)a0
) - ((int)b0
);
287 char* my_strchr ( const char* s
, int c
)
289 UChar ch
= (UChar
)((UInt
)c
);
290 UChar
* p
= (UChar
*)s
;
292 if (*p
== ch
) return p
;
293 if (*p
== 0) return NULL
;
298 void* my_malloc ( int n
)
300 void* r
= (void*) (*serviceFn
)(2,n
);
305 /////////////////////////////////////////////////////////////////////
307 static void vexxx_log_bytes ( char* p
, int n
)
310 for (i
= 0; i
< n
; i
++)
311 (*serviceFn
)( 1, (int)p
[i
] );
314 /*---------------------------------------------------------*/
315 /*--- vexxx_printf ---*/
316 /*---------------------------------------------------------*/
318 /* This should be the only <...> include in the entire VEX library.
319 New code for vex_util.c should go above this point. */
322 static HChar
vexxx_toupper ( HChar c
)
324 if (c
>= 'a' && c
<= 'z')
325 return c
+ ('A' - 'a');
330 static Int
vexxx_strlen ( const HChar
* str
)
333 while (str
[i
] != 0) i
++;
337 Bool
vexxx_streq ( const HChar
* s1
, const HChar
* s2
)
340 if (*s1
== 0 && *s2
== 0)
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) */
356 /* Copy a string into the buffer. */
358 myvprintf_str ( void(*send
)(HChar
), Int flags
, Int width
, HChar
* str
,
361 # define MAYBE_TOUPPER(ch) (capitalise ? vexxx_toupper(ch) : (ch))
364 Int len
= vexxx_strlen(str
);
368 for (i
= 0; i
< len
; i
++)
369 send(MAYBE_TOUPPER(str
[i
]));
375 for (i
= 0; i
< width
; i
++)
376 send(MAYBE_TOUPPER(str
[i
]));
381 if (flags
& VG_MSG_LJUSTIFY
) {
383 for (i
= 0; i
< extra
; i
++)
387 for (i
= 0; i
< len
; i
++)
388 send(MAYBE_TOUPPER(str
[i
]));
389 if (!(flags
& VG_MSG_LJUSTIFY
)) {
391 for (i
= 0; i
< extra
; i
++)
395 # undef MAYBE_TOUPPER
400 /* Write P into the buffer according to these args:
401 * If SIGN is true, p is a signed.
403 * If WITH_ZERO is true, '0' must be added.
404 * WIDTH is the width of the field.
407 myvprintf_int64 ( void(*send
)(HChar
), Int flags
, Int base
, Int width
, ULong pL
)
413 HChar
*digits
= "0123456789ABCDEF";
417 if (base
< 2 || base
> 16)
420 if ((flags
& VG_MSG_SIGNED
) && (Int
)p
< 0) {
429 if ((flags
& VG_MSG_COMMA
) && 10 == base
&&
430 0 == (ind
-nc
) % 3 && 0 != ind
)
435 buf
[ind
++] = digits
[p
% base
];
443 if (width
> 0 && !(flags
& VG_MSG_LJUSTIFY
)) {
444 for(; ind
< width
; ind
++) {
446 buf
[ind
] = ((flags
& VG_MSG_ZJUSTIFY
) ? '0': ' ');
450 /* Reverse copy to buffer. */
452 for (i
= ind
-1; i
>= 0; i
--) {
455 if (width
> 0 && (flags
& VG_MSG_LJUSTIFY
)) {
456 for(; ind
< width
; ind
++) {
458 send(' '); // Never pad with zeroes on RHS -- changes the value!
465 /* A simple vprintf(). */
467 UInt
vprintf_wrk ( void(*send
)(HChar
), const HChar
*format
, va_list vargs
)
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.
480 for (i
= 0; format
[i
] != 0; i
++) {
481 if (format
[i
] != '%') {
487 /* A '%' has been found. Ignore a trailing %. */
490 if (format
[i
] == '%') {
491 /* `%%' is replaced by `%'. */
498 width
= 0; /* length of the field. */
499 if (format
[i
] == '(') {
500 flags
|= VG_MSG_PAREN
;
503 /* If ',' follows '%', commas will be inserted. */
504 if (format
[i
] == ',') {
505 flags
|= VG_MSG_COMMA
;
508 /* If '-' follows '%', justify on the left. */
509 if (format
[i
] == '-') {
510 flags
|= VG_MSG_LJUSTIFY
;
513 /* If '0' follows '%', pads will be inserted. */
514 if (format
[i
] == '0') {
515 flags
|= VG_MSG_ZJUSTIFY
;
518 /* Compute the field length. */
519 while (format
[i
] >= '0' && format
[i
] <= '9') {
521 width
+= format
[i
++] - '0';
523 while (format
[i
] == 'l') {
530 flags
|= VG_MSG_SIGNED
;
532 ret
+= myvprintf_int64(send
, flags
, 10, width
,
533 (ULong
)(va_arg (vargs
, Long
)));
535 ret
+= myvprintf_int64(send
, flags
, 10, width
,
536 (ULong
)(va_arg (vargs
, Int
)));
540 ret
+= myvprintf_int64(send
, flags
, 10, width
,
541 (ULong
)(va_arg (vargs
, ULong
)));
543 ret
+= myvprintf_int64(send
, flags
, 10, width
,
544 (ULong
)(va_arg (vargs
, UInt
)));
550 ret
+= myvprintf_int64(send
, flags
, 16, width
,
551 (ULong
)((HWord
)va_arg (vargs
, void *)));
555 ret
+= myvprintf_int64(send
, flags
, 16, width
,
556 (ULong
)(va_arg (vargs
, ULong
)));
558 ret
+= myvprintf_int64(send
, flags
, 16, width
,
559 (ULong
)(va_arg (vargs
, UInt
)));
563 send((va_arg (vargs
, int)));
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
,
573 case 'y': { /* %y - print symbol */
574 Addr a
= va_arg(vargs
, Addr
);
577 if (VG_(get_fnname_w_offset
)(a
, &name
)) {
578 HChar buf
[1 + VG_strlen(name
) + 1 + 1];
579 if (flags
& VG_MSG_PAREN
) {
580 VG_(sprintf
)(str
, "(%s)", name
):
582 VG_(sprintf
)(str
, "%s", name
):
584 ret
+= myvprintf_str(send
, flags
, width
, buf
, 0);
597 /* A general replacement for printf(). Note that only low-level
598 debugging info should be sent via here. The official route is to
599 to use vg_message(). This interface is deprecated.
601 static HChar myprintf_buf
[1000];
602 static Int n_myprintf_buf
;
604 static void add_to_myprintf_buf ( HChar c
)
606 if (c
== '\n' || n_myprintf_buf
>= 1000-10 /*paranoia*/ ) {
607 (*vexxx_log_bytes
)( myprintf_buf
, vexxx_strlen(myprintf_buf
) );
609 myprintf_buf
[n_myprintf_buf
] = 0;
611 myprintf_buf
[n_myprintf_buf
++] = c
;
612 myprintf_buf
[n_myprintf_buf
] = 0;
615 static UInt
vexxx_printf ( const char *format
, ... )
619 va_start(vargs
,format
);
622 myprintf_buf
[n_myprintf_buf
] = 0;
623 ret
= vprintf_wrk ( add_to_myprintf_buf
, format
, vargs
);
625 if (n_myprintf_buf
> 0) {
626 (*vexxx_log_bytes
)( myprintf_buf
, n_myprintf_buf
);
634 /*---------------------------------------------------------------*/
635 /*--- end vex_util.c ---*/
636 /*---------------------------------------------------------------*/
639 /////////////////////////////////////////////////////////////////////
640 /////////////////////////////////////////////////////////////////////
641 /////////////////////////////////////////////////////////////////////
642 /////////////////////////////////////////////////////////////////////
644 // BEGIN #include "ops-ppc.c"
647 * This file has been auto-generated by './gen-ppc' program
648 * Please don't edit by hand
652 //BEGIN #include "test-ppc.h"
655 * PPC tests for qemu-PPC CPU emulation checks - definitions
657 * Copyright (c) 2005 Jocelyn Mayer
659 * This program is free software; you can redistribute it and/or
660 * modify it under the terms of the GNU General Public License V2
661 * as published by the Free Software Foundation.
664 #if !defined (__TEST_PPC_H__)
665 #define __TEST_PPC_H__
667 typedef void (*test_func_t
) (void);
668 typedef struct test_t test_t
;
669 typedef struct test_table_t test_table_t
;
672 const unsigned char *name
;
675 struct test_table_t
{
677 const unsigned char *name
;
681 typedef void (*test_loop_t
) (const unsigned char *name
, test_func_t func
);
685 PPC_ONE_ARG
= 0x00000001,
686 PPC_TWO_ARGS
= 0x00000002,
687 PPC_THREE_ARGS
= 0x00000003,
688 PPC_CMP_ARGS
= 0x00000004,
689 PPC_CMPI_ARGS
= 0x00000005,
690 PPC_TWO_I16
= 0x00000006,
691 PPC_SPECIAL
= 0x00000007,
692 PPC_NB_ARGS
= 0x0000000F,
694 PPC_ARITH
= 0x00000100,
695 PPC_LOGICAL
= 0x00000200,
696 PPC_COMPARE
= 0x00000300,
697 PPC_CROP
= 0x00000400,
698 PPC_TYPE
= 0x00000F00,
700 PPC_INTEGER
= 0x00010000,
701 PPC_FLOAT
= 0x00020000,
702 PPC_405
= 0x00030000,
703 PPC_ALTIVEC
= 0x00040000,
704 PPC_FALTIVEC
= 0x00050000,
705 PPC_FAMILY
= 0x000F0000,
710 #endif /* !defined (__TEST_PPC_H__) */
712 //END #include "test-ppc.h"
714 static void test_add (void)
716 __asm__
__volatile__ ("add 17, 14, 15");
719 static void test_addo (void)
721 __asm__
__volatile__ ("addo 17, 14, 15");
724 static void test_addc (void)
726 __asm__
__volatile__ ("addc 17, 14, 15");
729 static void test_addco (void)
731 __asm__
__volatile__ ("addco 17, 14, 15");
734 static void test_adde (void)
736 __asm__
__volatile__ ("adde 17, 14, 15");
739 static void test_addeo (void)
741 __asm__
__volatile__ ("addeo 17, 14, 15");
744 static void test_divw (void)
746 __asm__
__volatile__ ("divw 17, 14, 15");
749 static void test_divwo (void)
751 __asm__
__volatile__ ("divwo 17, 14, 15");
754 static void test_divwu (void)
756 __asm__
__volatile__ ("divwu 17, 14, 15");
759 static void test_divwuo (void)
761 __asm__
__volatile__ ("divwuo 17, 14, 15");
764 static void test_mulhw (void)
766 __asm__
__volatile__ ("mulhw 17, 14, 15");
769 static void test_mulhwu (void)
771 __asm__
__volatile__ ("mulhwu 17, 14, 15");
774 static void test_mullw (void)
776 __asm__
__volatile__ ("mullw 17, 14, 15");
779 static void test_mullwo (void)
781 __asm__
__volatile__ ("mullwo 17, 14, 15");
784 static void test_subf (void)
786 __asm__
__volatile__ ("subf 17, 14, 15");
789 static void test_subfo (void)
791 __asm__
__volatile__ ("subfo 17, 14, 15");
794 static void test_subfc (void)
796 __asm__
__volatile__ ("subfc 17, 14, 15");
799 static void test_subfco (void)
801 __asm__
__volatile__ ("subfco 17, 14, 15");
804 static void test_subfe (void)
806 __asm__
__volatile__ ("subfe 17, 14, 15");
809 static void test_subfeo (void)
811 __asm__
__volatile__ ("subfeo 17, 14, 15");
814 static test_t tests_ia_ops_two
[] = {
815 { &test_add
, " add", },
816 { &test_addo
, " addo", },
817 { &test_addc
, " addc", },
818 { &test_addco
, " addco", },
819 { &test_adde
, " adde", },
820 { &test_addeo
, " addeo", },
821 { &test_divw
, " divw", },
822 { &test_divwo
, " divwo", },
823 { &test_divwu
, " divwu", },
824 { &test_divwuo
, " divwuo", },
825 { &test_mulhw
, " mulhw", },
826 { &test_mulhwu
, " mulhwu", },
827 { &test_mullw
, " mullw", },
828 { &test_mullwo
, " mullwo", },
829 { &test_subf
, " subf", },
830 { &test_subfo
, " subfo", },
831 { &test_subfc
, " subfc", },
832 { &test_subfco
, " subfco", },
833 { &test_subfe
, " subfe", },
834 { &test_subfeo
, " subfeo", },
838 static void test_add_ (void)
840 __asm__
__volatile__ ("add. 17, 14, 15");
843 static void test_addo_ (void)
845 __asm__
__volatile__ ("addo. 17, 14, 15");
848 static void test_addc_ (void)
850 __asm__
__volatile__ ("addc. 17, 14, 15");
853 static void test_addco_ (void)
855 __asm__
__volatile__ ("addco. 17, 14, 15");
858 static void test_adde_ (void)
860 __asm__
__volatile__ ("adde. 17, 14, 15");
863 static void test_addeo_ (void)
865 __asm__
__volatile__ ("addeo. 17, 14, 15");
868 static void test_divw_ (void)
870 __asm__
__volatile__ ("divw. 17, 14, 15");
873 static void test_divwo_ (void)
875 __asm__
__volatile__ ("divwo. 17, 14, 15");
878 static void test_divwu_ (void)
880 __asm__
__volatile__ ("divwu. 17, 14, 15");
883 static void test_divwuo_ (void)
885 __asm__
__volatile__ ("divwuo. 17, 14, 15");
888 static void test_subf_ (void)
890 __asm__
__volatile__ ("subf. 17, 14, 15");
893 static void test_subfo_ (void)
895 __asm__
__volatile__ ("subfo. 17, 14, 15");
898 static void test_subfc_ (void)
900 __asm__
__volatile__ ("subfc. 17, 14, 15");
903 static void test_subfco_ (void)
905 __asm__
__volatile__ ("subfco. 17, 14, 15");
908 static void test_subfe_ (void)
910 __asm__
__volatile__ ("subfe. 17, 14, 15");
913 static void test_subfeo_ (void)
915 __asm__
__volatile__ ("subfeo. 17, 14, 15");
918 static test_t tests_iar_ops_two
[] = {
919 { &test_add_
, " add.", },
920 { &test_addo_
, " addo.", },
921 { &test_addc_
, " addc.", },
922 { &test_addco_
, " addco.", },
923 { &test_adde_
, " adde.", },
924 { &test_addeo_
, " addeo.", },
925 { &test_divw_
, " divw.", },
926 { &test_divwo_
, " divwo.", },
927 { &test_divwu_
, " divwu.", },
928 { &test_divwuo_
, " divwuo.", },
929 { &test_subf_
, " subf.", },
930 { &test_subfo_
, " subfo.", },
931 { &test_subfc_
, " subfc.", },
932 { &test_subfco_
, " subfco.", },
933 { &test_subfe_
, " subfe.", },
934 { &test_subfeo_
, " subfeo.", },
938 static void test_and (void)
940 __asm__
__volatile__ ("and 17, 14, 15");
943 static void test_andc (void)
945 __asm__
__volatile__ ("andc 17, 14, 15");
948 static void test_eqv (void)
950 __asm__
__volatile__ ("eqv 17, 14, 15");
953 static void test_nand (void)
955 __asm__
__volatile__ ("nand 17, 14, 15");
958 static void test_nor (void)
960 __asm__
__volatile__ ("nor 17, 14, 15");
963 static void test_or (void)
965 __asm__
__volatile__ ("or 17, 14, 15");
968 static void test_orc (void)
970 __asm__
__volatile__ ("orc 17, 14, 15");
973 static void test_xor (void)
975 __asm__
__volatile__ ("xor 17, 14, 15");
978 static void test_slw (void)
980 __asm__
__volatile__ ("slw 17, 14, 15");
983 static void test_sraw (void)
985 __asm__
__volatile__ ("sraw 17, 14, 15");
988 static void test_srw (void)
990 __asm__
__volatile__ ("srw 17, 14, 15");
993 static test_t tests_il_ops_two
[] = {
994 { &test_and
, " and", },
995 { &test_andc
, " andc", },
996 { &test_eqv
, " eqv", },
997 { &test_nand
, " nand", },
998 { &test_nor
, " nor", },
999 { &test_or
, " or", },
1000 { &test_orc
, " orc", },
1001 { &test_xor
, " xor", },
1002 { &test_slw
, " slw", },
1003 { &test_sraw
, " sraw", },
1004 { &test_srw
, " srw", },
1008 static void test_and_ (void)
1010 __asm__
__volatile__ ("and. 17, 14, 15");
1013 static void test_andc_ (void)
1015 __asm__
__volatile__ ("andc. 17, 14, 15");
1018 static void test_eqv_ (void)
1020 __asm__
__volatile__ ("eqv. 17, 14, 15");
1023 static void test_mulhw_ (void)
1025 __asm__
__volatile__ ("mulhw. 17, 14, 15");
1028 static void test_mulhwu_ (void)
1030 __asm__
__volatile__ ("mulhwu. 17, 14, 15");
1033 static void test_mullw_ (void)
1035 __asm__
__volatile__ ("mullw. 17, 14, 15");
1038 static void test_mullwo_ (void)
1040 __asm__
__volatile__ ("mullwo. 17, 14, 15");
1043 static void test_nand_ (void)
1045 __asm__
__volatile__ ("nand. 17, 14, 15");
1048 static void test_nor_ (void)
1050 __asm__
__volatile__ ("nor. 17, 14, 15");
1053 static void test_or_ (void)
1055 __asm__
__volatile__ ("or. 17, 14, 15");
1058 static void test_orc_ (void)
1060 __asm__
__volatile__ ("orc. 17, 14, 15");
1063 static void test_xor_ (void)
1065 __asm__
__volatile__ ("xor. 17, 14, 15");
1068 static void test_slw_ (void)
1070 __asm__
__volatile__ ("slw. 17, 14, 15");
1073 static void test_sraw_ (void)
1075 __asm__
__volatile__ ("sraw. 17, 14, 15");
1078 static void test_srw_ (void)
1080 __asm__
__volatile__ ("srw. 17, 14, 15");
1083 static test_t tests_ilr_ops_two
[] = {
1084 { &test_and_
, " and.", },
1085 { &test_andc_
, " andc.", },
1086 { &test_eqv_
, " eqv.", },
1087 { &test_mulhw_
, " mulhw.", },
1088 { &test_mulhwu_
, " mulhwu.", },
1089 { &test_mullw_
, " mullw.", },
1090 { &test_mullwo_
, " mullwo.", },
1091 { &test_nand_
, " nand.", },
1092 { &test_nor_
, " nor.", },
1093 { &test_or_
, " or.", },
1094 { &test_orc_
, " orc.", },
1095 { &test_xor_
, " xor.", },
1096 { &test_slw_
, " slw.", },
1097 { &test_sraw_
, " sraw.", },
1098 { &test_srw_
, " srw.", },
1102 static void test_cmp (void)
1104 __asm__
__volatile__ ("cmp 2, 14, 15");
1107 static void test_cmpl (void)
1109 __asm__
__volatile__ ("cmpl 2, 14, 15");
1112 static test_t tests_icr_ops_two
[] = {
1113 { &test_cmp
, " cmp", },
1114 { &test_cmpl
, " cmpl", },
1118 static void test_cmpi (void)
1120 __asm__
__volatile__ ("cmpi 2, 14, 15");
1123 static void test_cmpli (void)
1125 __asm__
__volatile__ ("cmpli 2, 14, 15");
1128 static test_t tests_icr_ops_two_i16
[] = {
1129 { &test_cmpi
, " cmpi", },
1130 { &test_cmpli
, " cmpli", },
1134 static void test_addi (void)
1136 __asm__
__volatile__ ("addi 17, 14, 0");
1139 static void test_addic (void)
1141 __asm__
__volatile__ ("addic 17, 14, 0");
1144 static void test_addis (void)
1146 __asm__
__volatile__ ("addis 17, 14, 0");
1149 static void test_mulli (void)
1151 __asm__
__volatile__ ("mulli 17, 14, 0");
1154 static void test_subfic (void)
1156 __asm__
__volatile__ ("subfic 17, 14, 0");
1159 static test_t tests_ia_ops_two_i16
[] = {
1160 { &test_addi
, " addi", },
1161 { &test_addic
, " addic", },
1162 { &test_addis
, " addis", },
1163 { &test_mulli
, " mulli", },
1164 { &test_subfic
, " subfic", },
1168 static void test_addic_ (void)
1170 __asm__
__volatile__ ("addic. 17, 14, 0");
1173 static test_t tests_iar_ops_two_i16
[] = {
1174 { &test_addic_
, " addic.", },
1178 static void test_ori (void)
1180 __asm__
__volatile__ ("ori 17, 14, 0");
1183 static void test_oris (void)
1185 __asm__
__volatile__ ("oris 17, 14, 0");
1188 static void test_xori (void)
1190 __asm__
__volatile__ ("xori 17, 14, 0");
1193 static void test_xoris (void)
1195 __asm__
__volatile__ ("xoris 17, 14, 0");
1198 static test_t tests_il_ops_two_i16
[] = {
1199 { &test_ori
, " ori", },
1200 { &test_oris
, " oris", },
1201 { &test_xori
, " xori", },
1202 { &test_xoris
, " xoris", },
1206 static void test_andi_ (void)
1208 __asm__
__volatile__ ("andi. 17, 14, 0");
1211 static void test_andis_ (void)
1213 __asm__
__volatile__ ("andis. 17, 14, 0");
1216 static test_t tests_ilr_ops_two_i16
[] = {
1217 { &test_andi_
, " andi.", },
1218 { &test_andis_
, " andis.", },
1222 static void test_crand (void)
1224 __asm__
__volatile__ ("crand 17, 14, 15");
1227 static void test_crandc (void)
1229 __asm__
__volatile__ ("crandc 17, 14, 15");
1232 static void test_creqv (void)
1234 __asm__
__volatile__ ("creqv 17, 14, 15");
1237 static void test_crnand (void)
1239 __asm__
__volatile__ ("crnand 17, 14, 15");
1242 static void test_crnor (void)
1244 __asm__
__volatile__ ("crnor 17, 14, 15");
1247 static void test_cror (void)
1249 __asm__
__volatile__ ("cror 17, 14, 15");
1252 static void test_crorc (void)
1254 __asm__
__volatile__ ("crorc 17, 14, 15");
1257 static void test_crxor (void)
1259 __asm__
__volatile__ ("crxor 17, 14, 15");
1262 static test_t tests_crl_ops_two
[] = {
1263 { &test_crand
, " crand", },
1264 { &test_crandc
, " crandc", },
1265 { &test_creqv
, " creqv", },
1266 { &test_crnand
, " crnand", },
1267 { &test_crnor
, " crnor", },
1268 { &test_cror
, " cror", },
1269 { &test_crorc
, " crorc", },
1270 { &test_crxor
, " crxor", },
1274 static void test_addme (void)
1276 __asm__
__volatile__ ("addme 17, 14");
1279 static void test_addmeo (void)
1281 __asm__
__volatile__ ("addmeo 17, 14");
1284 static void test_addze (void)
1286 __asm__
__volatile__ ("addze 17, 14");
1289 static void test_addzeo (void)
1291 __asm__
__volatile__ ("addzeo 17, 14");
1294 static void test_subfme (void)
1296 __asm__
__volatile__ ("subfme 17, 14");
1299 static void test_subfmeo (void)
1301 __asm__
__volatile__ ("subfmeo 17, 14");
1304 static void test_subfze (void)
1306 __asm__
__volatile__ ("subfze 17, 14");
1309 static void test_subfzeo (void)
1311 __asm__
__volatile__ ("subfzeo 17, 14");
1314 static test_t tests_ia_ops_one
[] = {
1315 { &test_addme
, " addme", },
1316 { &test_addmeo
, " addmeo", },
1317 { &test_addze
, " addze", },
1318 { &test_addzeo
, " addzeo", },
1319 { &test_subfme
, " subfme", },
1320 { &test_subfmeo
, " subfmeo", },
1321 { &test_subfze
, " subfze", },
1322 { &test_subfzeo
, " subfzeo", },
1326 static void test_addme_ (void)
1328 __asm__
__volatile__ ("addme. 17, 14");
1331 static void test_addmeo_ (void)
1333 __asm__
__volatile__ ("addmeo. 17, 14");
1336 static void test_addze_ (void)
1338 __asm__
__volatile__ ("addze. 17, 14");
1341 static void test_addzeo_ (void)
1343 __asm__
__volatile__ ("addzeo. 17, 14");
1346 static void test_subfme_ (void)
1348 __asm__
__volatile__ ("subfme. 17, 14");
1351 static void test_subfmeo_ (void)
1353 __asm__
__volatile__ ("subfmeo. 17, 14");
1356 static void test_subfze_ (void)
1358 __asm__
__volatile__ ("subfze. 17, 14");
1361 static void test_subfzeo_ (void)
1363 __asm__
__volatile__ ("subfzeo. 17, 14");
1366 static test_t tests_iar_ops_one
[] = {
1367 { &test_addme_
, " addme.", },
1368 { &test_addmeo_
, " addmeo.", },
1369 { &test_addze_
, " addze.", },
1370 { &test_addzeo_
, " addzeo.", },
1371 { &test_subfme_
, " subfme.", },
1372 { &test_subfmeo_
, " subfmeo.", },
1373 { &test_subfze_
, " subfze.", },
1374 { &test_subfzeo_
, " subfzeo.", },
1378 static void test_cntlzw (void)
1380 __asm__
__volatile__ ("cntlzw 17, 14");
1383 static void test_extsb (void)
1385 __asm__
__volatile__ ("extsb 17, 14");
1388 static void test_extsh (void)
1390 __asm__
__volatile__ ("extsh 17, 14");
1393 static void test_neg (void)
1395 __asm__
__volatile__ ("neg 17, 14");
1398 static void test_nego (void)
1400 __asm__
__volatile__ ("nego 17, 14");
1403 static test_t tests_il_ops_one
[] = {
1404 { &test_cntlzw
, " cntlzw", },
1405 { &test_extsb
, " extsb", },
1406 { &test_extsh
, " extsh", },
1407 { &test_neg
, " neg", },
1408 { &test_nego
, " nego", },
1412 static void test_cntlzw_ (void)
1414 __asm__
__volatile__ ("cntlzw. 17, 14");
1417 static void test_extsb_ (void)
1419 __asm__
__volatile__ ("extsb. 17, 14");
1422 static void test_extsh_ (void)
1424 __asm__
__volatile__ ("extsh. 17, 14");
1427 static void test_neg_ (void)
1429 __asm__
__volatile__ ("neg. 17, 14");
1432 static void test_nego_ (void)
1434 __asm__
__volatile__ ("nego. 17, 14");
1437 static test_t tests_ilr_ops_one
[] = {
1438 { &test_cntlzw_
, " cntlzw.", },
1439 { &test_extsb_
, " extsb.", },
1440 { &test_extsh_
, " extsh.", },
1441 { &test_neg_
, " neg.", },
1442 { &test_nego_
, " nego.", },
1446 static void test_rlwimi (void)
1448 __asm__
__volatile__ ("rlwimi 17, 14, 0, 0, 0");
1451 static void test_rlwinm (void)
1453 __asm__
__volatile__ ("rlwinm 17, 14, 0, 0, 0");
1456 static void test_rlwnm (void)
1458 __asm__
__volatile__ ("rlwnm 17, 14, 15, 0, 0");
1461 static void test_srawi (void)
1463 __asm__
__volatile__ ("srawi 17, 14, 0");
1466 static test_t tests_il_ops_spe
[] = {
1467 { &test_rlwimi
, " rlwimi", },
1468 { &test_rlwinm
, " rlwinm", },
1469 { &test_rlwnm
, " rlwnm", },
1470 { &test_srawi
, " srawi", },
1474 static void test_rlwimi_ (void)
1476 __asm__
__volatile__ ("rlwimi. 17, 14, 0, 0, 0");
1479 static void test_rlwinm_ (void)
1481 __asm__
__volatile__ ("rlwinm. 17, 14, 0, 0, 0");
1484 static void test_rlwnm_ (void)
1486 __asm__
__volatile__ ("rlwnm. 17, 14, 15, 0, 0");
1489 static void test_srawi_ (void)
1491 __asm__
__volatile__ ("srawi. 17, 14, 0");
1494 static test_t tests_ilr_ops_spe
[] = {
1495 { &test_rlwimi_
, " rlwimi.", },
1496 { &test_rlwinm_
, " rlwinm.", },
1497 { &test_rlwnm_
, " rlwnm.", },
1498 { &test_srawi_
, " srawi.", },
1502 #if !defined (NO_FLOAT)
1503 static void test_fsel (void)
1505 __asm__
__volatile__ ("fsel 17, 14, 15, 16");
1508 static void test_fmadd (void)
1510 __asm__
__volatile__ ("fmadd 17, 14, 15, 16");
1513 static void test_fmadds (void)
1515 __asm__
__volatile__ ("fmadds 17, 14, 15, 16");
1518 static void test_fmsub (void)
1520 __asm__
__volatile__ ("fmsub 17, 14, 15, 16");
1523 static void test_fmsubs (void)
1525 __asm__
__volatile__ ("fmsubs 17, 14, 15, 16");
1528 static void test_fnmadd (void)
1530 __asm__
__volatile__ ("fnmadd 17, 14, 15, 16");
1533 static void test_fnmadds (void)
1535 __asm__
__volatile__ ("fnmadds 17, 14, 15, 16");
1538 static void test_fnmsub (void)
1540 __asm__
__volatile__ ("fnmsub 17, 14, 15, 16");
1543 static void test_fnmsubs (void)
1545 __asm__
__volatile__ ("fnmsubs 17, 14, 15, 16");
1548 static test_t tests_fa_ops_three
[] = {
1549 { &test_fsel
, " fsel", },
1550 { &test_fmadd
, " fmadd", },
1551 { &test_fmadds
, " fmadds", },
1552 { &test_fmsub
, " fmsub", },
1553 { &test_fmsubs
, " fmsubs", },
1554 { &test_fnmadd
, " fnmadd", },
1555 { &test_fnmadds
, " fnmadds", },
1556 { &test_fnmsub
, " fnmsub", },
1557 { &test_fnmsubs
, " fnmsubs", },
1560 #endif /* !defined (NO_FLOAT) */
1562 #if !defined (NO_FLOAT)
1563 static void test_fsel_ (void)
1565 __asm__
__volatile__ ("fsel. 17, 14, 15, 16");
1568 static void test_fmadd_ (void)
1570 __asm__
__volatile__ ("fmadd. 17, 14, 15, 16");
1573 static void test_fmadds_ (void)
1575 __asm__
__volatile__ ("fmadds. 17, 14, 15, 16");
1578 static void test_fmsub_ (void)
1580 __asm__
__volatile__ ("fmsub. 17, 14, 15, 16");
1583 static void test_fmsubs_ (void)
1585 __asm__
__volatile__ ("fmsubs. 17, 14, 15, 16");
1588 static void test_fnmadd_ (void)
1590 __asm__
__volatile__ ("fnmadd. 17, 14, 15, 16");
1593 static void test_fnmadds_ (void)
1595 __asm__
__volatile__ ("fnmadds. 17, 14, 15, 16");
1598 static void test_fnmsub_ (void)
1600 __asm__
__volatile__ ("fnmsub. 17, 14, 15, 16");
1603 static void test_fnmsubs_ (void)
1605 __asm__
__volatile__ ("fnmsubs. 17, 14, 15, 16");
1608 static test_t tests_far_ops_three
[] = {
1609 { &test_fsel_
, " fsel.", },
1610 { &test_fmadd_
, " fmadd.", },
1611 { &test_fmadds_
, " fmadds.", },
1612 { &test_fmsub_
, " fmsub.", },
1613 { &test_fmsubs_
, " fmsubs.", },
1614 { &test_fnmadd_
, " fnmadd.", },
1615 { &test_fnmadds_
, " fnmadds.", },
1616 { &test_fnmsub_
, " fnmsub.", },
1617 { &test_fnmsubs_
, " fnmsubs.", },
1620 #endif /* !defined (NO_FLOAT) */
1622 #if !defined (NO_FLOAT)
1623 static void test_fadd (void)
1625 __asm__
__volatile__ ("fadd 17, 14, 15");
1628 static void test_fadds (void)
1630 __asm__
__volatile__ ("fadds 17, 14, 15");
1633 static void test_fsub (void)
1635 __asm__
__volatile__ ("fsub 17, 14, 15");
1638 static void test_fsubs (void)
1640 __asm__
__volatile__ ("fsubs 17, 14, 15");
1643 static void test_fmul (void)
1645 __asm__
__volatile__ ("fmul 17, 14, 15");
1648 static void test_fmuls (void)
1650 __asm__
__volatile__ ("fmuls 17, 14, 15");
1653 static void test_fdiv (void)
1655 __asm__
__volatile__ ("fdiv 17, 14, 15");
1658 static void test_fdivs (void)
1660 __asm__
__volatile__ ("fdivs 17, 14, 15");
1663 static test_t tests_fa_ops_two
[] = {
1664 { &test_fadd
, " fadd", },
1665 { &test_fadds
, " fadds", },
1666 { &test_fsub
, " fsub", },
1667 { &test_fsubs
, " fsubs", },
1668 { &test_fmul
, " fmul", },
1669 { &test_fmuls
, " fmuls", },
1670 { &test_fdiv
, " fdiv", },
1671 { &test_fdivs
, " fdivs", },
1674 #endif /* !defined (NO_FLOAT) */
1676 #if !defined (NO_FLOAT)
1677 static void test_fadd_ (void)
1679 __asm__
__volatile__ ("fadd. 17, 14, 15");
1682 static void test_fadds_ (void)
1684 __asm__
__volatile__ ("fadds. 17, 14, 15");
1687 static void test_fsub_ (void)
1689 __asm__
__volatile__ ("fsub. 17, 14, 15");
1692 static void test_fsubs_ (void)
1694 __asm__
__volatile__ ("fsubs. 17, 14, 15");
1697 static void test_fmul_ (void)
1699 __asm__
__volatile__ ("fmul. 17, 14, 15");
1702 static void test_fmuls_ (void)
1704 __asm__
__volatile__ ("fmuls. 17, 14, 15");
1707 static void test_fdiv_ (void)
1709 __asm__
__volatile__ ("fdiv. 17, 14, 15");
1712 static void test_fdivs_ (void)
1714 __asm__
__volatile__ ("fdivs. 17, 14, 15");
1717 static test_t tests_far_ops_two
[] = {
1718 { &test_fadd_
, " fadd.", },
1719 { &test_fadds_
, " fadds.", },
1720 { &test_fsub_
, " fsub.", },
1721 { &test_fsubs_
, " fsubs.", },
1722 { &test_fmul_
, " fmul.", },
1723 { &test_fmuls_
, " fmuls.", },
1724 { &test_fdiv_
, " fdiv.", },
1725 { &test_fdivs_
, " fdivs.", },
1728 #endif /* !defined (NO_FLOAT) */
1730 #if !defined (NO_FLOAT)
1731 static void test_fcmpo (void)
1733 __asm__
__volatile__ ("fcmpo 2, 14, 15");
1736 static void test_fcmpu (void)
1738 __asm__
__volatile__ ("fcmpu 2, 14, 15");
1741 static test_t tests_fcr_ops_two
[] = {
1742 { &test_fcmpo
, " fcmpo", },
1743 { &test_fcmpu
, " fcmpu", },
1746 #endif /* !defined (NO_FLOAT) */
1748 #if !defined (NO_FLOAT)
1749 static void test_fres (void)
1751 __asm__
__volatile__ ("fres 17, 14");
1754 static void test_frsqrte (void)
1756 __asm__
__volatile__ ("frsqrte 17, 14");
1759 static void test_frsp (void)
1761 __asm__
__volatile__ ("frsp 17, 14");
1764 static void test_fctiw (void)
1766 __asm__
__volatile__ ("fctiw 17, 14");
1769 static void test_fctiwz (void)
1771 __asm__
__volatile__ ("fctiwz 17, 14");
1774 static void test_fmr (void)
1776 __asm__
__volatile__ ("fmr 17, 14");
1779 static void test_fneg (void)
1781 __asm__
__volatile__ ("fneg 17, 14");
1784 static void test_fabs (void)
1786 __asm__
__volatile__ ("fabs 17, 14");
1789 static void test_fnabs (void)
1791 __asm__
__volatile__ ("fnabs 17, 14");
1794 static test_t tests_fa_ops_one
[] = {
1795 { &test_fres
, " fres", },
1796 { &test_frsqrte
, " frsqrte", },
1797 { &test_frsp
, " frsp", },
1798 { &test_fctiw
, " fctiw", },
1799 { &test_fctiwz
, " fctiwz", },
1800 { &test_fmr
, " fmr", },
1801 { &test_fneg
, " fneg", },
1802 { &test_fabs
, " fabs", },
1803 { &test_fnabs
, " fnabs", },
1806 #endif /* !defined (NO_FLOAT) */
1808 #if !defined (NO_FLOAT)
1809 static void test_fres_ (void)
1811 __asm__
__volatile__ ("fres. 17, 14");
1814 static void test_frsqrte_ (void)
1816 __asm__
__volatile__ ("frsqrte. 17, 14");
1819 static void test_frsp_ (void)
1821 __asm__
__volatile__ ("frsp. 17, 14");
1824 static void test_fctiw_ (void)
1826 __asm__
__volatile__ ("fctiw. 17, 14");
1829 static void test_fctiwz_ (void)
1831 __asm__
__volatile__ ("fctiwz. 17, 14");
1834 static void test_fmr_ (void)
1836 __asm__
__volatile__ ("fmr. 17, 14");
1839 static void test_fneg_ (void)
1841 __asm__
__volatile__ ("fneg. 17, 14");
1844 static void test_fabs_ (void)
1846 __asm__
__volatile__ ("fabs. 17, 14");
1849 static void test_fnabs_ (void)
1851 __asm__
__volatile__ ("fnabs. 17, 14");
1854 static test_t tests_far_ops_one
[] = {
1855 { &test_fres_
, " fres.", },
1856 { &test_frsqrte_
, " frsqrte.", },
1857 { &test_frsp_
, " frsp.", },
1858 { &test_fctiw_
, " fctiw.", },
1859 { &test_fctiwz_
, " fctiwz.", },
1860 { &test_fmr_
, " fmr.", },
1861 { &test_fneg_
, " fneg.", },
1862 { &test_fabs_
, " fabs.", },
1863 { &test_fnabs_
, " fnabs.", },
1866 #endif /* !defined (NO_FLOAT) */
1868 #if !defined (NO_FLOAT)
1869 static test_t tests_fl_ops_spe
[] = {
1872 #endif /* !defined (NO_FLOAT) */
1874 #if !defined (NO_FLOAT)
1875 static test_t tests_flr_ops_spe
[] = {
1878 #endif /* !defined (NO_FLOAT) */
1880 #if defined (HAS_ALTIVEC)
1881 static void test_vmhaddshs (void)
1883 __asm__
__volatile__ ("vmhaddshs 17, 14, 15, 16");
1886 static void test_vmhraddshs (void)
1888 __asm__
__volatile__ ("vmhraddshs 17, 14, 15, 16");
1891 static void test_vmladduhm (void)
1893 __asm__
__volatile__ ("vmladduhm 17, 14, 15, 16");
1896 static void test_vmsumubm (void)
1898 __asm__
__volatile__ ("vmsumubm 17, 14, 15, 16");
1901 static void test_vmsumuhm (void)
1903 __asm__
__volatile__ ("vmsumuhm 17, 14, 15, 16");
1906 static void test_vmsumshs (void)
1908 __asm__
__volatile__ ("vmsumshs 17, 14, 15, 16");
1911 static void test_vmsumuhs (void)
1913 __asm__
__volatile__ ("vmsumuhs 17, 14, 15, 16");
1916 static void test_vmsummbm (void)
1918 __asm__
__volatile__ ("vmsummbm 17, 14, 15, 16");
1921 static void test_vmsumshm (void)
1923 __asm__
__volatile__ ("vmsumshm 17, 14, 15, 16");
1926 static test_t tests_aa_ops_three
[] = {
1927 { &test_vmhaddshs
, " vmhaddshs", },
1928 { &test_vmhraddshs
, " vmhraddshs", },
1929 { &test_vmladduhm
, " vmladduhm", },
1930 { &test_vmsumubm
, " vmsumubm", },
1931 { &test_vmsumuhm
, " vmsumuhm", },
1932 { &test_vmsumshs
, " vmsumshs", },
1933 { &test_vmsumuhs
, " vmsumuhs", },
1934 { &test_vmsummbm
, " vmsummbm", },
1935 { &test_vmsumshm
, " vmsumshm", },
1938 #endif /* defined (HAS_ALTIVEC) */
1940 #if defined (HAS_ALTIVEC)
1941 static void test_vperm (void)
1943 __asm__
__volatile__ ("vperm 17, 14, 15, 16");
1946 static void test_vsel (void)
1948 __asm__
__volatile__ ("vsel 17, 14, 15, 16");
1951 static test_t tests_al_ops_three
[] = {
1952 { &test_vperm
, " vperm", },
1953 { &test_vsel
, " vsel", },
1956 #endif /* defined (HAS_ALTIVEC) */
1958 #if defined (HAS_ALTIVEC)
1959 static void test_vaddubm (void)
1961 __asm__
__volatile__ ("vaddubm 17, 14, 15");
1964 static void test_vadduhm (void)
1966 __asm__
__volatile__ ("vadduhm 17, 14, 15");
1969 static void test_vadduwm (void)
1971 __asm__
__volatile__ ("vadduwm 17, 14, 15");
1974 static void test_vaddubs (void)
1976 __asm__
__volatile__ ("vaddubs 17, 14, 15");
1979 static void test_vadduhs (void)
1981 __asm__
__volatile__ ("vadduhs 17, 14, 15");
1984 static void test_vadduws (void)
1986 __asm__
__volatile__ ("vadduws 17, 14, 15");
1989 static void test_vaddsbs (void)
1991 __asm__
__volatile__ ("vaddsbs 17, 14, 15");
1994 static void test_vaddshs (void)
1996 __asm__
__volatile__ ("vaddshs 17, 14, 15");
1999 static void test_vaddsws (void)
2001 __asm__
__volatile__ ("vaddsws 17, 14, 15");
2004 static void test_vaddcuw (void)
2006 __asm__
__volatile__ ("vaddcuw 17, 14, 15");
2009 static void test_vsububm (void)
2011 __asm__
__volatile__ ("vsububm 17, 14, 15");
2014 static void test_vsubuhm (void)
2016 __asm__
__volatile__ ("vsubuhm 17, 14, 15");
2019 static void test_vsubuwm (void)
2021 __asm__
__volatile__ ("vsubuwm 17, 14, 15");
2024 static void test_vsububs (void)
2026 __asm__
__volatile__ ("vsububs 17, 14, 15");
2029 static void test_vsubuhs (void)
2031 __asm__
__volatile__ ("vsubuhs 17, 14, 15");
2034 static void test_vsubuws (void)
2036 __asm__
__volatile__ ("vsubuws 17, 14, 15");
2039 static void test_vsubcuw (void)
2041 __asm__
__volatile__ ("vsubcuw 17, 14, 15");
2044 static void test_vmuloub (void)
2046 __asm__
__volatile__ ("vmuloub 17, 14, 15");
2049 static void test_vmulouh (void)
2051 __asm__
__volatile__ ("vmulouh 17, 14, 15");
2054 static void test_vmulosb (void)
2056 __asm__
__volatile__ ("vmulosb 17, 14, 15");
2059 static void test_vmulosh (void)
2061 __asm__
__volatile__ ("vmulosh 17, 14, 15");
2064 static void test_vmuleub (void)
2066 __asm__
__volatile__ ("vmuleub 17, 14, 15");
2069 static void test_vmuleuh (void)
2071 __asm__
__volatile__ ("vmuleuh 17, 14, 15");
2074 static void test_vmulesb (void)
2076 __asm__
__volatile__ ("vmulesb 17, 14, 15");
2079 static void test_vmulesh (void)
2081 __asm__
__volatile__ ("vmulesh 17, 14, 15");
2084 static void test_vsumsws (void)
2086 __asm__
__volatile__ ("vsumsws 17, 14, 15");
2089 static void test_vsum2sws (void)
2091 __asm__
__volatile__ ("vsum2sws 17, 14, 15");
2094 static void test_vsum4ubs (void)
2096 __asm__
__volatile__ ("vsum4ubs 17, 14, 15");
2099 static void test_vsum4sbs (void)
2101 __asm__
__volatile__ ("vsum4sbs 17, 14, 15");
2104 static void test_vsum4shs (void)
2106 __asm__
__volatile__ ("vsum4shs 17, 14, 15");
2109 static void test_vavgub (void)
2111 __asm__
__volatile__ ("vavgub 17, 14, 15");
2114 static void test_vavguh (void)
2116 __asm__
__volatile__ ("vavguh 17, 14, 15");
2119 static void test_vavguw (void)
2121 __asm__
__volatile__ ("vavguw 17, 14, 15");
2124 static void test_vavgsb (void)
2126 __asm__
__volatile__ ("vavgsb 17, 14, 15");
2129 static void test_vavgsh (void)
2131 __asm__
__volatile__ ("vavgsh 17, 14, 15");
2134 static void test_vavgsw (void)
2136 __asm__
__volatile__ ("vavgsw 17, 14, 15");
2139 static void test_vmaxub (void)
2141 __asm__
__volatile__ ("vmaxub 17, 14, 15");
2144 static void test_vmaxuh (void)
2146 __asm__
__volatile__ ("vmaxuh 17, 14, 15");
2149 static void test_vmaxuw (void)
2151 __asm__
__volatile__ ("vmaxuw 17, 14, 15");
2154 static void test_vmaxsb (void)
2156 __asm__
__volatile__ ("vmaxsb 17, 14, 15");
2159 static void test_vmaxsh (void)
2161 __asm__
__volatile__ ("vmaxsh 17, 14, 15");
2164 static void test_vmaxsw (void)
2166 __asm__
__volatile__ ("vmaxsw 17, 14, 15");
2169 static void test_vminub (void)
2171 __asm__
__volatile__ ("vminub 17, 14, 15");
2174 static void test_vminuh (void)
2176 __asm__
__volatile__ ("vminuh 17, 14, 15");
2179 static void test_vminuw (void)
2181 __asm__
__volatile__ ("vminuw 17, 14, 15");
2184 static void test_vminsb (void)
2186 __asm__
__volatile__ ("vminsb 17, 14, 15");
2189 static void test_vminsh (void)
2191 __asm__
__volatile__ ("vminsh 17, 14, 15");
2194 static void test_vminsw (void)
2196 __asm__
__volatile__ ("vminsw 17, 14, 15");
2199 static test_t tests_aa_ops_two
[] = {
2200 { &test_vaddubm
, " vaddubm", },
2201 { &test_vadduhm
, " vadduhm", },
2202 { &test_vadduwm
, " vadduwm", },
2203 { &test_vaddubs
, " vaddubs", },
2204 { &test_vadduhs
, " vadduhs", },
2205 { &test_vadduws
, " vadduws", },
2206 { &test_vaddsbs
, " vaddsbs", },
2207 { &test_vaddshs
, " vaddshs", },
2208 { &test_vaddsws
, " vaddsws", },
2209 { &test_vaddcuw
, " vaddcuw", },
2210 { &test_vsububm
, " vsububm", },
2211 { &test_vsubuhm
, " vsubuhm", },
2212 { &test_vsubuwm
, " vsubuwm", },
2213 { &test_vsububs
, " vsububs", },
2214 { &test_vsubuhs
, " vsubuhs", },
2215 { &test_vsubuws
, " vsubuws", },
2216 { &test_vsubcuw
, " vsubcuw", },
2217 { &test_vmuloub
, " vmuloub", },
2218 { &test_vmulouh
, " vmulouh", },
2219 { &test_vmulosb
, " vmulosb", },
2220 { &test_vmulosh
, " vmulosh", },
2221 { &test_vmuleub
, " vmuleub", },
2222 { &test_vmuleuh
, " vmuleuh", },
2223 { &test_vmulesb
, " vmulesb", },
2224 { &test_vmulesh
, " vmulesh", },
2225 { &test_vsumsws
, " vsumsws", },
2226 { &test_vsum2sws
, " vsum2sws", },
2227 { &test_vsum4ubs
, " vsum4ubs", },
2228 { &test_vsum4sbs
, " vsum4sbs", },
2229 { &test_vsum4shs
, " vsum4shs", },
2230 { &test_vavgub
, " vavgub", },
2231 { &test_vavguh
, " vavguh", },
2232 { &test_vavguw
, " vavguw", },
2233 { &test_vavgsb
, " vavgsb", },
2234 { &test_vavgsh
, " vavgsh", },
2235 { &test_vavgsw
, " vavgsw", },
2236 { &test_vmaxub
, " vmaxub", },
2237 { &test_vmaxuh
, " vmaxuh", },
2238 { &test_vmaxuw
, " vmaxuw", },
2239 { &test_vmaxsb
, " vmaxsb", },
2240 { &test_vmaxsh
, " vmaxsh", },
2241 { &test_vmaxsw
, " vmaxsw", },
2242 { &test_vminub
, " vminub", },
2243 { &test_vminuh
, " vminuh", },
2244 { &test_vminuw
, " vminuw", },
2245 { &test_vminsb
, " vminsb", },
2246 { &test_vminsh
, " vminsh", },
2247 { &test_vminsw
, " vminsw", },
2250 #endif /* defined (HAS_ALTIVEC) */
2252 #if defined (HAS_ALTIVEC)
2253 static void test_vand (void)
2255 __asm__
__volatile__ ("vand 17, 14, 15");
2258 static void test_vor (void)
2260 __asm__
__volatile__ ("vor 17, 14, 15");
2263 static void test_vxor (void)
2265 __asm__
__volatile__ ("vxor 17, 14, 15");
2268 static void test_vandc (void)
2270 __asm__
__volatile__ ("vandc 17, 14, 15");
2273 static void test_vnor (void)
2275 __asm__
__volatile__ ("vnor 17, 14, 15");
2278 static void test_vrlb (void)
2280 __asm__
__volatile__ ("vrlb 17, 14, 15");
2283 static void test_vrlh (void)
2285 __asm__
__volatile__ ("vrlh 17, 14, 15");
2288 static void test_vrlw (void)
2290 __asm__
__volatile__ ("vrlw 17, 14, 15");
2293 static void test_vslb (void)
2295 __asm__
__volatile__ ("vslb 17, 14, 15");
2298 static void test_vslh (void)
2300 __asm__
__volatile__ ("vslh 17, 14, 15");
2303 static void test_vslw (void)
2305 __asm__
__volatile__ ("vslw 17, 14, 15");
2308 static void test_vsrb (void)
2310 __asm__
__volatile__ ("vsrb 17, 14, 15");
2313 static void test_vsrh (void)
2315 __asm__
__volatile__ ("vsrh 17, 14, 15");
2318 static void test_vsrw (void)
2320 __asm__
__volatile__ ("vsrw 17, 14, 15");
2323 static void test_vsrab (void)
2325 __asm__
__volatile__ ("vsrab 17, 14, 15");
2328 static void test_vsrah (void)
2330 __asm__
__volatile__ ("vsrah 17, 14, 15");
2333 static void test_vsraw (void)
2335 __asm__
__volatile__ ("vsraw 17, 14, 15");
2338 static void test_vpkuhum (void)
2340 __asm__
__volatile__ ("vpkuhum 17, 14, 15");
2343 static void test_vpkuwum (void)
2345 __asm__
__volatile__ ("vpkuwum 17, 14, 15");
2348 static void test_vpkuhus (void)
2350 __asm__
__volatile__ ("vpkuhus 17, 14, 15");
2353 static void test_vpkuwus (void)
2355 __asm__
__volatile__ ("vpkuwus 17, 14, 15");
2358 static void test_vpkshus (void)
2360 __asm__
__volatile__ ("vpkshus 17, 14, 15");
2363 static void test_vpkswus (void)
2365 __asm__
__volatile__ ("vpkswus 17, 14, 15");
2368 static void test_vpkshss (void)
2370 __asm__
__volatile__ ("vpkshss 17, 14, 15");
2373 static void test_vpkswss (void)
2375 __asm__
__volatile__ ("vpkswss 17, 14, 15");
2378 static void test_vpkpx (void)
2380 __asm__
__volatile__ ("vpkpx 17, 14, 15");
2383 static void test_vmrghb (void)
2385 __asm__
__volatile__ ("vmrghb 17, 14, 15");
2388 static void test_vmrghh (void)
2390 __asm__
__volatile__ ("vmrghh 17, 14, 15");
2393 static void test_vmrghw (void)
2395 __asm__
__volatile__ ("vmrghw 17, 14, 15");
2398 static void test_vmrglb (void)
2400 __asm__
__volatile__ ("vmrglb 17, 14, 15");
2403 static void test_vmrglh (void)
2405 __asm__
__volatile__ ("vmrglh 17, 14, 15");
2408 static void test_vmrglw (void)
2410 __asm__
__volatile__ ("vmrglw 17, 14, 15");
2413 static void test_vsl (void)
2415 __asm__
__volatile__ ("vsl 17, 14, 15");
2418 static void test_vsr (void)
2420 __asm__
__volatile__ ("vsr 17, 14, 15");
2423 static void test_vslo (void)
2425 __asm__
__volatile__ ("vslo 17, 14, 15");
2428 static void test_vsro (void)
2430 __asm__
__volatile__ ("vsro 17, 14, 15");
2433 static test_t tests_al_ops_two
[] = {
2434 { &test_vand
, " vand", },
2435 { &test_vor
, " vor", },
2436 { &test_vxor
, " vxor", },
2437 { &test_vandc
, " vandc", },
2438 { &test_vnor
, " vnor", },
2439 { &test_vrlb
, " vrlb", },
2440 { &test_vrlh
, " vrlh", },
2441 { &test_vrlw
, " vrlw", },
2442 { &test_vslb
, " vslb", },
2443 { &test_vslh
, " vslh", },
2444 { &test_vslw
, " vslw", },
2445 { &test_vsrb
, " vsrb", },
2446 { &test_vsrh
, " vsrh", },
2447 { &test_vsrw
, " vsrw", },
2448 { &test_vsrab
, " vsrab", },
2449 { &test_vsrah
, " vsrah", },
2450 { &test_vsraw
, " vsraw", },
2451 { &test_vpkuhum
, " vpkuhum", },
2452 { &test_vpkuwum
, " vpkuwum", },
2453 { &test_vpkuhus
, " vpkuhus", },
2454 { &test_vpkuwus
, " vpkuwus", },
2455 { &test_vpkshus
, " vpkshus", },
2456 { &test_vpkswus
, " vpkswus", },
2457 { &test_vpkshss
, " vpkshss", },
2458 { &test_vpkswss
, " vpkswss", },
2459 { &test_vpkpx
, " vpkpx", },
2460 { &test_vmrghb
, " vmrghb", },
2461 { &test_vmrghh
, " vmrghh", },
2462 { &test_vmrghw
, " vmrghw", },
2463 { &test_vmrglb
, " vmrglb", },
2464 { &test_vmrglh
, " vmrglh", },
2465 { &test_vmrglw
, " vmrglw", },
2466 { &test_vsl
, " vsl", },
2467 { &test_vsr
, " vsr", },
2468 { &test_vslo
, " vslo", },
2469 { &test_vsro
, " vsro", },
2472 #endif /* defined (HAS_ALTIVEC) */
2474 #if defined (HAS_ALTIVEC)
2475 static void test_vupkhsb (void)
2477 __asm__
__volatile__ ("vupkhsb 17, 14");
2480 static void test_vupkhsh (void)
2482 __asm__
__volatile__ ("vupkhsh 17, 14");
2485 static void test_vupkhpx (void)
2487 __asm__
__volatile__ ("vupkhpx 17, 14");
2490 static void test_vupklsb (void)
2492 __asm__
__volatile__ ("vupklsb 17, 14");
2495 static void test_vupklsh (void)
2497 __asm__
__volatile__ ("vupklsh 17, 14");
2500 static void test_vupklpx (void)
2502 __asm__
__volatile__ ("vupklpx 17, 14");
2505 static test_t tests_al_ops_one
[] = {
2506 { &test_vupkhsb
, " vupkhsb", },
2507 { &test_vupkhsh
, " vupkhsh", },
2508 { &test_vupkhpx
, " vupkhpx", },
2509 { &test_vupklsb
, " vupklsb", },
2510 { &test_vupklsh
, " vupklsh", },
2511 { &test_vupklpx
, " vupklpx", },
2514 #endif /* defined (HAS_ALTIVEC) */
2516 #if defined (HAS_ALTIVEC)
2517 static void test_vcmpgtub (void)
2519 __asm__
__volatile__ ("vcmpgtub 17, 14, 15");
2522 static void test_vcmpgtuh (void)
2524 __asm__
__volatile__ ("vcmpgtuh 17, 14, 15");
2527 static void test_vcmpgtuw (void)
2529 __asm__
__volatile__ ("vcmpgtuw 17, 14, 15");
2532 static void test_vcmpgtsb (void)
2534 __asm__
__volatile__ ("vcmpgtsb 17, 14, 15");
2537 static void test_vcmpgtsh (void)
2539 __asm__
__volatile__ ("vcmpgtsh 17, 14, 15");
2542 static void test_vcmpgtsw (void)
2544 __asm__
__volatile__ ("vcmpgtsw 17, 14, 15");
2547 static void test_vcmpequb (void)
2549 __asm__
__volatile__ ("vcmpequb 17, 14, 15");
2552 static void test_vcmpequh (void)
2554 __asm__
__volatile__ ("vcmpequh 17, 14, 15");
2557 static void test_vcmpequw (void)
2559 __asm__
__volatile__ ("vcmpequw 17, 14, 15");
2562 static test_t tests_ac_ops_two
[] = {
2563 { &test_vcmpgtub
, " vcmpgtub", },
2564 { &test_vcmpgtuh
, " vcmpgtuh", },
2565 { &test_vcmpgtuw
, " vcmpgtuw", },
2566 { &test_vcmpgtsb
, " vcmpgtsb", },
2567 { &test_vcmpgtsh
, " vcmpgtsh", },
2568 { &test_vcmpgtsw
, " vcmpgtsw", },
2569 { &test_vcmpequb
, " vcmpequb", },
2570 { &test_vcmpequh
, " vcmpequh", },
2571 { &test_vcmpequw
, " vcmpequw", },
2574 #endif /* defined (HAS_ALTIVEC) */
2576 #if defined (HAS_ALTIVEC)
2577 static void test_vcmpgtub_ (void)
2579 __asm__
__volatile__ ("vcmpgtub. 17, 14, 15");
2582 static void test_vcmpgtuh_ (void)
2584 __asm__
__volatile__ ("vcmpgtuh. 17, 14, 15");
2587 static void test_vcmpgtuw_ (void)
2589 __asm__
__volatile__ ("vcmpgtuw. 17, 14, 15");
2592 static void test_vcmpgtsb_ (void)
2594 __asm__
__volatile__ ("vcmpgtsb. 17, 14, 15");
2597 static void test_vcmpgtsh_ (void)
2599 __asm__
__volatile__ ("vcmpgtsh. 17, 14, 15");
2602 static void test_vcmpgtsw_ (void)
2604 __asm__
__volatile__ ("vcmpgtsw. 17, 14, 15");
2607 static void test_vcmpequb_ (void)
2609 __asm__
__volatile__ ("vcmpequb. 17, 14, 15");
2612 static void test_vcmpequh_ (void)
2614 __asm__
__volatile__ ("vcmpequh. 17, 14, 15");
2617 static void test_vcmpequw_ (void)
2619 __asm__
__volatile__ ("vcmpequw. 17, 14, 15");
2622 static test_t tests_acr_ops_two
[] = {
2623 { &test_vcmpgtub_
, " vcmpgtub.", },
2624 { &test_vcmpgtuh_
, " vcmpgtuh.", },
2625 { &test_vcmpgtuw_
, " vcmpgtuw.", },
2626 { &test_vcmpgtsb_
, " vcmpgtsb.", },
2627 { &test_vcmpgtsh_
, " vcmpgtsh.", },
2628 { &test_vcmpgtsw_
, " vcmpgtsw.", },
2629 { &test_vcmpequb_
, " vcmpequb.", },
2630 { &test_vcmpequh_
, " vcmpequh.", },
2631 { &test_vcmpequw_
, " vcmpequw.", },
2634 #endif /* defined (HAS_ALTIVEC) */
2636 #if defined (HAS_ALTIVEC)
2637 static void test_vmaddfp (void)
2639 __asm__
__volatile__ ("vmaddfp 17, 14, 15, 16");
2642 static void test_vnmsubfp (void)
2644 __asm__
__volatile__ ("vnmsubfp 17, 14, 15, 16");
2647 static test_t tests_afa_ops_three
[] = {
2648 { &test_vmaddfp
, " vmaddfp", },
2649 { &test_vnmsubfp
, " vnmsubfp", },
2652 #endif /* defined (HAS_ALTIVEC) */
2654 #if defined (HAS_ALTIVEC)
2655 static void test_vaddfp (void)
2657 __asm__
__volatile__ ("vaddfp 17, 14, 15");
2660 static void test_vsubfp (void)
2662 __asm__
__volatile__ ("vsubfp 17, 14, 15");
2665 static void test_vmaxfp (void)
2667 __asm__
__volatile__ ("vmaxfp 17, 14, 15");
2670 static void test_vminfp (void)
2672 __asm__
__volatile__ ("vminfp 17, 14, 15");
2675 static test_t tests_afa_ops_two
[] = {
2676 { &test_vaddfp
, " vaddfp", },
2677 { &test_vsubfp
, " vsubfp", },
2678 { &test_vmaxfp
, " vmaxfp", },
2679 { &test_vminfp
, " vminfp", },
2682 #endif /* defined (HAS_ALTIVEC) */
2684 #if defined (HAS_ALTIVEC)
2685 static void test_vrfin (void)
2687 __asm__
__volatile__ ("vrfin 17, 14");
2690 static void test_vrfiz (void)
2692 __asm__
__volatile__ ("vrfiz 17, 14");
2695 static void test_vrfip (void)
2697 __asm__
__volatile__ ("vrfip 17, 14");
2700 static void test_vrfim (void)
2702 __asm__
__volatile__ ("vrfim 17, 14");
2705 static void test_vrefp (void)
2707 __asm__
__volatile__ ("vrefp 17, 14");
2710 static void test_vrsqrtefp (void)
2712 __asm__
__volatile__ ("vrsqrtefp 17, 14");
2715 static void test_vlogefp (void)
2717 __asm__
__volatile__ ("vlogefp 17, 14");
2720 static void test_vexptefp (void)
2722 __asm__
__volatile__ ("vexptefp 17, 14");
2725 static test_t tests_afa_ops_one
[] = {
2726 { &test_vrfin
, " vrfin", },
2727 { &test_vrfiz
, " vrfiz", },
2728 { &test_vrfip
, " vrfip", },
2729 { &test_vrfim
, " vrfim", },
2730 { &test_vrefp
, " vrefp", },
2731 { &test_vrsqrtefp
, " vrsqrtefp", },
2732 { &test_vlogefp
, " vlogefp", },
2733 { &test_vexptefp
, " vexptefp", },
2736 #endif /* defined (HAS_ALTIVEC) */
2738 #if defined (HAS_ALTIVEC)
2739 static void test_vcmpgtfp (void)
2741 __asm__
__volatile__ ("vcmpgtfp 17, 14, 15");
2744 static void test_vcmpeqfp (void)
2746 __asm__
__volatile__ ("vcmpeqfp 17, 14, 15");
2749 static void test_vcmpgefp (void)
2751 __asm__
__volatile__ ("vcmpgefp 17, 14, 15");
2754 static void test_vcmpbfp (void)
2756 __asm__
__volatile__ ("vcmpbfp 17, 14, 15");
2759 static test_t tests_afc_ops_two
[] = {
2760 { &test_vcmpgtfp
, " vcmpgtfp", },
2761 { &test_vcmpeqfp
, " vcmpeqfp", },
2762 { &test_vcmpgefp
, " vcmpgefp", },
2763 { &test_vcmpbfp
, " vcmpbfp", },
2766 #endif /* defined (HAS_ALTIVEC) */
2768 #if defined (HAS_ALTIVEC)
2769 static void test_vcmpgtfp_ (void)
2771 __asm__
__volatile__ ("vcmpgtfp. 17, 14, 15");
2774 static void test_vcmpeqfp_ (void)
2776 __asm__
__volatile__ ("vcmpeqfp. 17, 14, 15");
2779 static void test_vcmpgefp_ (void)
2781 __asm__
__volatile__ ("vcmpgefp. 17, 14, 15");
2784 static void test_vcmpbfp_ (void)
2786 __asm__
__volatile__ ("vcmpbfp. 17, 14, 15");
2789 static test_t tests_afcr_ops_two
[] = {
2790 { &test_vcmpgtfp_
, " vcmpgtfp.", },
2791 { &test_vcmpeqfp_
, " vcmpeqfp.", },
2792 { &test_vcmpgefp_
, " vcmpgefp.", },
2793 { &test_vcmpbfp_
, " vcmpbfp.", },
2796 #endif /* defined (HAS_ALTIVEC) */
2798 #if defined (IS_PPC405)
2799 static void test_macchw (void)
2801 __asm__
__volatile__ ("macchw 17, 14, 15");
2804 static void test_macchwo (void)
2806 __asm__
__volatile__ ("macchwo 17, 14, 15");
2809 static void test_macchws (void)
2811 __asm__
__volatile__ ("macchws 17, 14, 15");
2814 static void test_macchwso (void)
2816 __asm__
__volatile__ ("macchwso 17, 14, 15");
2819 static void test_macchwsu (void)
2821 __asm__
__volatile__ ("macchwsu 17, 14, 15");
2824 static void test_macchwsuo (void)
2826 __asm__
__volatile__ ("macchwsuo 17, 14, 15");
2829 static void test_macchwu (void)
2831 __asm__
__volatile__ ("macchwu 17, 14, 15");
2834 static void test_macchwuo (void)
2836 __asm__
__volatile__ ("macchwuo 17, 14, 15");
2839 static void test_machhw (void)
2841 __asm__
__volatile__ ("machhw 17, 14, 15");
2844 static void test_machhwo (void)
2846 __asm__
__volatile__ ("machhwo 17, 14, 15");
2849 static void test_machhws (void)
2851 __asm__
__volatile__ ("machhws 17, 14, 15");
2854 static void test_machhwso (void)
2856 __asm__
__volatile__ ("machhwso 17, 14, 15");
2859 static void test_machhwsu (void)
2861 __asm__
__volatile__ ("machhwsu 17, 14, 15");
2864 static void test_machhwsuo (void)
2866 __asm__
__volatile__ ("machhwsuo 17, 14, 15");
2869 static void test_machhwu (void)
2871 __asm__
__volatile__ ("machhwu 17, 14, 15");
2874 static void test_machhwuo (void)
2876 __asm__
__volatile__ ("machhwuo 17, 14, 15");
2879 static void test_maclhw (void)
2881 __asm__
__volatile__ ("maclhw 17, 14, 15");
2884 static void test_maclhwo (void)
2886 __asm__
__volatile__ ("maclhwo 17, 14, 15");
2889 static void test_maclhws (void)
2891 __asm__
__volatile__ ("maclhws 17, 14, 15");
2894 static void test_maclhwso (void)
2896 __asm__
__volatile__ ("maclhwso 17, 14, 15");
2899 static void test_maclhwsu (void)
2901 __asm__
__volatile__ ("maclhwsu 17, 14, 15");
2904 static void test_maclhwsuo (void)
2906 __asm__
__volatile__ ("maclhwsuo 17, 14, 15");
2909 static void test_maclhwu (void)
2911 __asm__
__volatile__ ("maclhwu 17, 14, 15");
2914 static void test_maclhwuo (void)
2916 __asm__
__volatile__ ("maclhwuo 17, 14, 15");
2919 static void test_mulchw (void)
2921 __asm__
__volatile__ ("mulchw 17, 14, 15");
2924 static void test_mulchwu (void)
2926 __asm__
__volatile__ ("mulchwu 17, 14, 15");
2929 static void test_mulhhw (void)
2931 __asm__
__volatile__ ("mulhhw 17, 14, 15");
2934 static void test_mulhhwu (void)
2936 __asm__
__volatile__ ("mulhhwu 17, 14, 15");
2939 static void test_mullhw (void)
2941 __asm__
__volatile__ ("mullhw 17, 14, 15");
2944 static void test_mullhwu (void)
2946 __asm__
__volatile__ ("mullhwu 17, 14, 15");
2949 static void test_nmacchw (void)
2951 __asm__
__volatile__ ("nmacchw 17, 14, 15");
2954 static void test_nmacchwo (void)
2956 __asm__
__volatile__ ("nmacchwo 17, 14, 15");
2959 static void test_nmacchws (void)
2961 __asm__
__volatile__ ("nmacchws 17, 14, 15");
2964 static void test_nmacchwso (void)
2966 __asm__
__volatile__ ("nmacchwso 17, 14, 15");
2969 static void test_nmachhw (void)
2971 __asm__
__volatile__ ("nmachhw 17, 14, 15");
2974 static void test_nmachhwo (void)
2976 __asm__
__volatile__ ("nmachhwo 17, 14, 15");
2979 static void test_nmachhws (void)
2981 __asm__
__volatile__ ("nmachhws 17, 14, 15");
2984 static void test_nmachhwso (void)
2986 __asm__
__volatile__ ("nmachhwso 17, 14, 15");
2989 static void test_nmaclhw (void)
2991 __asm__
__volatile__ ("nmaclhw 17, 14, 15");
2994 static void test_nmaclhwo (void)
2996 __asm__
__volatile__ ("nmaclhwo 17, 14, 15");
2999 static void test_nmaclhws (void)
3001 __asm__
__volatile__ ("nmaclhws 17, 14, 15");
3004 static void test_nmaclhwso (void)
3006 __asm__
__volatile__ ("nmaclhwso 17, 14, 15");
3009 static test_t tests_p4m_ops_two
[] = {
3010 { &test_macchw
, " macchw", },
3011 { &test_macchwo
, " macchwo", },
3012 { &test_macchws
, " macchws", },
3013 { &test_macchwso
, " macchwso", },
3014 { &test_macchwsu
, " macchwsu", },
3015 { &test_macchwsuo
, " macchwsuo", },
3016 { &test_macchwu
, " macchwu", },
3017 { &test_macchwuo
, " macchwuo", },
3018 { &test_machhw
, " machhw", },
3019 { &test_machhwo
, " machhwo", },
3020 { &test_machhws
, " machhws", },
3021 { &test_machhwso
, " machhwso", },
3022 { &test_machhwsu
, " machhwsu", },
3023 { &test_machhwsuo
, " machhwsuo", },
3024 { &test_machhwu
, " machhwu", },
3025 { &test_machhwuo
, " machhwuo", },
3026 { &test_maclhw
, " maclhw", },
3027 { &test_maclhwo
, " maclhwo", },
3028 { &test_maclhws
, " maclhws", },
3029 { &test_maclhwso
, " maclhwso", },
3030 { &test_maclhwsu
, " maclhwsu", },
3031 { &test_maclhwsuo
, " maclhwsuo", },
3032 { &test_maclhwu
, " maclhwu", },
3033 { &test_maclhwuo
, " maclhwuo", },
3034 { &test_mulchw
, " mulchw", },
3035 { &test_mulchwu
, " mulchwu", },
3036 { &test_mulhhw
, " mulhhw", },
3037 { &test_mulhhwu
, " mulhhwu", },
3038 { &test_mullhw
, " mullhw", },
3039 { &test_mullhwu
, " mullhwu", },
3040 { &test_nmacchw
, " nmacchw", },
3041 { &test_nmacchwo
, " nmacchwo", },
3042 { &test_nmacchws
, " nmacchws", },
3043 { &test_nmacchwso
, " nmacchwso", },
3044 { &test_nmachhw
, " nmachhw", },
3045 { &test_nmachhwo
, " nmachhwo", },
3046 { &test_nmachhws
, " nmachhws", },
3047 { &test_nmachhwso
, " nmachhwso", },
3048 { &test_nmaclhw
, " nmaclhw", },
3049 { &test_nmaclhwo
, " nmaclhwo", },
3050 { &test_nmaclhws
, " nmaclhws", },
3051 { &test_nmaclhwso
, " nmaclhwso", },
3054 #endif /* defined (IS_PPC405) */
3056 #if defined (IS_PPC405)
3057 static void test_macchw_ (void)
3059 __asm__
__volatile__ ("macchw. 17, 14, 15");
3062 static void test_macchwo_ (void)
3064 __asm__
__volatile__ ("macchwo. 17, 14, 15");
3067 static void test_macchws_ (void)
3069 __asm__
__volatile__ ("macchws. 17, 14, 15");
3072 static void test_macchwso_ (void)
3074 __asm__
__volatile__ ("macchwso. 17, 14, 15");
3077 static void test_macchwsu_ (void)
3079 __asm__
__volatile__ ("macchwsu. 17, 14, 15");
3082 static void test_macchwsuo_ (void)
3084 __asm__
__volatile__ ("macchwsuo. 17, 14, 15");
3087 static void test_macchwu_ (void)
3089 __asm__
__volatile__ ("macchwu. 17, 14, 15");
3092 static void test_macchwuo_ (void)
3094 __asm__
__volatile__ ("macchwuo. 17, 14, 15");
3097 static void test_machhw_ (void)
3099 __asm__
__volatile__ ("machhw. 17, 14, 15");
3102 static void test_machhwo_ (void)
3104 __asm__
__volatile__ ("machhwo. 17, 14, 15");
3107 static void test_machhws_ (void)
3109 __asm__
__volatile__ ("machhws. 17, 14, 15");
3112 static void test_machhwso_ (void)
3114 __asm__
__volatile__ ("machhwso. 17, 14, 15");
3117 static void test_machhwsu_ (void)
3119 __asm__
__volatile__ ("machhwsu. 17, 14, 15");
3122 static void test_machhwsuo_ (void)
3124 __asm__
__volatile__ ("machhwsuo. 17, 14, 15");
3127 static void test_machhwu_ (void)
3129 __asm__
__volatile__ ("machhwu. 17, 14, 15");
3132 static void test_machhwuo_ (void)
3134 __asm__
__volatile__ ("machhwuo. 17, 14, 15");
3137 static void test_maclhw_ (void)
3139 __asm__
__volatile__ ("maclhw. 17, 14, 15");
3142 static void test_maclhwo_ (void)
3144 __asm__
__volatile__ ("maclhwo. 17, 14, 15");
3147 static void test_maclhws_ (void)
3149 __asm__
__volatile__ ("maclhws. 17, 14, 15");
3152 static void test_maclhwso_ (void)
3154 __asm__
__volatile__ ("maclhwso. 17, 14, 15");
3157 static void test_maclhwsu_ (void)
3159 __asm__
__volatile__ ("maclhwsu. 17, 14, 15");
3162 static void test_maclhwsuo_ (void)
3164 __asm__
__volatile__ ("maclhwsuo. 17, 14, 15");
3167 static void test_maclhwu_ (void)
3169 __asm__
__volatile__ ("maclhwu. 17, 14, 15");
3172 static void test_maclhwuo_ (void)
3174 __asm__
__volatile__ ("maclhwuo. 17, 14, 15");
3177 static void test_mulchw_ (void)
3179 __asm__
__volatile__ ("mulchw. 17, 14, 15");
3182 static void test_mulchwu_ (void)
3184 __asm__
__volatile__ ("mulchwu. 17, 14, 15");
3187 static void test_mulhhw_ (void)
3189 __asm__
__volatile__ ("mulhhw. 17, 14, 15");
3192 static void test_mulhhwu_ (void)
3194 __asm__
__volatile__ ("mulhhwu. 17, 14, 15");
3197 static void test_mullhw_ (void)
3199 __asm__
__volatile__ ("mullhw. 17, 14, 15");
3202 static void test_mullhwu_ (void)
3204 __asm__
__volatile__ ("mullhwu. 17, 14, 15");
3207 static void test_nmacchw_ (void)
3209 __asm__
__volatile__ ("nmacchw. 17, 14, 15");
3212 static void test_nmacchwo_ (void)
3214 __asm__
__volatile__ ("nmacchwo. 17, 14, 15");
3217 static void test_nmacchws_ (void)
3219 __asm__
__volatile__ ("nmacchws. 17, 14, 15");
3222 static void test_nmacchwso_ (void)
3224 __asm__
__volatile__ ("nmacchwso. 17, 14, 15");
3227 static void test_nmachhw_ (void)
3229 __asm__
__volatile__ ("nmachhw. 17, 14, 15");
3232 static void test_nmachhwo_ (void)
3234 __asm__
__volatile__ ("nmachhwo. 17, 14, 15");
3237 static void test_nmachhws_ (void)
3239 __asm__
__volatile__ ("nmachhws. 17, 14, 15");
3242 static void test_nmachhwso_ (void)
3244 __asm__
__volatile__ ("nmachhwso. 17, 14, 15");
3247 static void test_nmaclhw_ (void)
3249 __asm__
__volatile__ ("nmaclhw. 17, 14, 15");
3252 static void test_nmaclhwo_ (void)
3254 __asm__
__volatile__ ("nmaclhwo. 17, 14, 15");
3257 static void test_nmaclhws_ (void)
3259 __asm__
__volatile__ ("nmaclhws. 17, 14, 15");
3262 static void test_nmaclhwso_ (void)
3264 __asm__
__volatile__ ("nmaclhwso. 17, 14, 15");
3267 static test_t tests_p4mc_ops_two
[] = {
3268 { &test_macchw_
, " macchw.", },
3269 { &test_macchwo_
, " macchwo.", },
3270 { &test_macchws_
, " macchws.", },
3271 { &test_macchwso_
, " macchwso.", },
3272 { &test_macchwsu_
, " macchwsu.", },
3273 { &test_macchwsuo_
, " macchwsuo.", },
3274 { &test_macchwu_
, " macchwu.", },
3275 { &test_macchwuo_
, " macchwuo.", },
3276 { &test_machhw_
, " machhw.", },
3277 { &test_machhwo_
, " machhwo.", },
3278 { &test_machhws_
, " machhws.", },
3279 { &test_machhwso_
, " machhwso.", },
3280 { &test_machhwsu_
, " machhwsu.", },
3281 { &test_machhwsuo_
, " machhwsuo.", },
3282 { &test_machhwu_
, " machhwu.", },
3283 { &test_machhwuo_
, " machhwuo.", },
3284 { &test_maclhw_
, " maclhw.", },
3285 { &test_maclhwo_
, " maclhwo.", },
3286 { &test_maclhws_
, " maclhws.", },
3287 { &test_maclhwso_
, " maclhwso.", },
3288 { &test_maclhwsu_
, " maclhwsu.", },
3289 { &test_maclhwsuo_
, " maclhwsuo.", },
3290 { &test_maclhwu_
, " maclhwu.", },
3291 { &test_maclhwuo_
, " maclhwuo.", },
3292 { &test_mulchw_
, " mulchw.", },
3293 { &test_mulchwu_
, " mulchwu.", },
3294 { &test_mulhhw_
, " mulhhw.", },
3295 { &test_mulhhwu_
, " mulhhwu.", },
3296 { &test_mullhw_
, " mullhw.", },
3297 { &test_mullhwu_
, " mullhwu.", },
3298 { &test_nmacchw_
, " nmacchw.", },
3299 { &test_nmacchwo_
, " nmacchwo.", },
3300 { &test_nmacchws_
, " nmacchws.", },
3301 { &test_nmacchwso_
, " nmacchwso.", },
3302 { &test_nmachhw_
, " nmachhw.", },
3303 { &test_nmachhwo_
, " nmachhwo.", },
3304 { &test_nmachhws_
, " nmachhws.", },
3305 { &test_nmachhwso_
, " nmachhwso.", },
3306 { &test_nmaclhw_
, " nmaclhw.", },
3307 { &test_nmaclhwo_
, " nmaclhwo.", },
3308 { &test_nmaclhws_
, " nmaclhws.", },
3309 { &test_nmaclhwso_
, " nmaclhwso.", },
3312 #endif /* defined (IS_PPC405) */
3314 static test_table_t all_tests
[] = {
3317 "PPC integer arithmetic instructions with two arguments",
3322 "PPC integer instructions with two arguments with flags update",
3327 "PPC integer logical instructions with two arguments",
3332 "PPC integer logical instructions with two arguments with flags update",
3337 "PPC integer compare instructions (two arguents)",
3341 tests_icr_ops_two_i16
,
3342 "PPC integer compare with immediate instructions (two arguents)",
3346 tests_ia_ops_two_i16
,
3347 "PPC integer arithmetic instructions\n with one register + one 16 bits immediate arguments",
3351 tests_iar_ops_two_i16
,
3352 "PPC integer arithmetic instructions\n with one register + one 16 bits immediate arguments with flags update",
3356 tests_il_ops_two_i16
,
3357 "PPC integer logical instructions\n with one register + one 16 bits immediate arguments",
3361 tests_ilr_ops_two_i16
,
3362 "PPC integer logical instructions\n with one register + one 16 bits immediate arguments with flags update",
3367 "PPC condition register logical instructions - two operands",
3372 "PPC integer arithmetic instructions with one argument",
3377 "PPC integer arithmetic instructions with one argument with flags update",
3382 "PPC integer logical instructions with one argument",
3387 "PPC integer logical instructions with one argument with flags update",
3392 "PPC logical instructions with special forms",
3397 "PPC logical instructions with special forms with flags update",
3400 #if !defined (NO_FLOAT)
3402 tests_fa_ops_three
,
3403 "PPC floating point arithmetic instructions with three arguments",
3406 #endif /* !defined (NO_FLOAT) */
3407 #if !defined (NO_FLOAT)
3409 tests_far_ops_three
,
3410 "PPC floating point arithmetic instructions\n with three arguments with flags update",
3413 #endif /* !defined (NO_FLOAT) */
3414 #if !defined (NO_FLOAT)
3417 "PPC floating point arithmetic instructions with two arguments",
3420 #endif /* !defined (NO_FLOAT) */
3421 #if !defined (NO_FLOAT)
3424 "PPC floating point arithmetic instructions\n with two arguments with flags update",
3427 #endif /* !defined (NO_FLOAT) */
3428 #if !defined (NO_FLOAT)
3431 "PPC floating point compare instructions (two arguments)",
3434 #endif /* !defined (NO_FLOAT) */
3435 #if !defined (NO_FLOAT)
3438 "PPC floating point arithmetic instructions with one argument",
3441 #endif /* !defined (NO_FLOAT) */
3442 #if !defined (NO_FLOAT)
3445 "PPC floating point arithmetic instructions\n with one argument with flags update",
3448 #endif /* !defined (NO_FLOAT) */
3449 #if !defined (NO_FLOAT)
3452 "PPC floating point status register manipulation instructions",
3455 #endif /* !defined (NO_FLOAT) */
3456 #if !defined (NO_FLOAT)
3459 "PPC floating point status register manipulation instructions\n with flags update",
3462 #endif /* !defined (NO_FLOAT) */
3463 #if defined (HAS_ALTIVEC)
3465 tests_aa_ops_three
,
3466 "PPC altivec integer arithmetic instructions with three arguments",
3469 #endif /* defined (HAS_ALTIVEC) */
3470 #if defined (HAS_ALTIVEC)
3472 tests_al_ops_three
,
3473 "PPC altivec integer logical instructions with three arguments",
3476 #endif /* defined (HAS_ALTIVEC) */
3477 #if defined (HAS_ALTIVEC)
3480 "PPC altivec integer arithmetic instructions with two arguments",
3483 #endif /* defined (HAS_ALTIVEC) */
3484 #if defined (HAS_ALTIVEC)
3487 "PPC altivec integer logical instructions with two arguments",
3490 #endif /* defined (HAS_ALTIVEC) */
3491 #if defined (HAS_ALTIVEC)
3494 "PPC altivec integer logical instructions with one argument",
3497 #endif /* defined (HAS_ALTIVEC) */
3498 #if defined (HAS_ALTIVEC)
3501 "Altivec integer compare instructions",
3504 #endif /* defined (HAS_ALTIVEC) */
3505 #if defined (HAS_ALTIVEC)
3508 "Altivec integer compare instructions with flags update",
3511 #endif /* defined (HAS_ALTIVEC) */
3512 #if defined (HAS_ALTIVEC)
3514 tests_afa_ops_three
,
3515 "Altivec floating point arithmetic instructions with three arguments",
3518 #endif /* defined (HAS_ALTIVEC) */
3519 #if defined (HAS_ALTIVEC)
3522 "Altivec floating point arithmetic instructions with two arguments",
3525 #endif /* defined (HAS_ALTIVEC) */
3526 #if defined (HAS_ALTIVEC)
3529 "Altivec floating point arithmetic instructions with one argument",
3532 #endif /* defined (HAS_ALTIVEC) */
3533 #if defined (HAS_ALTIVEC)
3536 "Altivec floating point compare instructions",
3539 #endif /* defined (HAS_ALTIVEC) */
3540 #if defined (HAS_ALTIVEC)
3542 tests_afcr_ops_two
,
3543 "Altivec floating point compare instructions with flags update",
3546 #endif /* defined (HAS_ALTIVEC) */
3547 #if defined (IS_PPC405)
3550 "PPC 405 mac instructions with three arguments",
3553 #endif /* defined (IS_PPC405) */
3554 #if defined (IS_PPC405)
3556 tests_p4mc_ops_two
,
3557 "PPC 405 mac instructions with three arguments with flags update",
3560 #endif /* defined (IS_PPC405) */
3561 { NULL
, NULL
, 0x00000000, },
3564 // END #include "ops-ppc.c"
3567 static int verbose
= 0;
3569 static double *fargs
;
3570 static int nb_fargs
;
3571 static uint32_t *iargs
;
3572 static int nb_iargs
;
3573 static uint16_t *ii16
;
3576 static inline void register_farg (void *farg
,
3577 int s
, uint16_t _exp
, uint64_t mant
)
3581 tmp
= ((uint64_t)s
<< 63) | ((uint64_t)_exp
<< 52) | mant
;
3582 *(uint64_t *)farg
= tmp
;
3583 AB_DPRINTF("%d %03x %013llx => %016llx %0e\n",
3584 s
, _exp
, mant
, *(uint64_t *)farg
, *(double *)farg
);
3587 static void build_fargs_table (void)
3589 /* Sign goes from zero to one
3590 * Exponent goes from 0 to ((1 << 12) - 1)
3591 * Mantissa goes from 1 to ((1 << 52) - 1)
3593 * +0.0 : 0 0x000 0x0000000000000
3594 * -0.0 : 1 0x000 0x0000000000000
3595 * +infinity : 0 0x7FF 0x0000000000000
3596 * -infinity : 1 0x7FF 0x0000000000000
3597 * +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF
3598 * -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF
3599 * +QNaN : 0 0x7FF 0x8000000000000
3600 * -QNaN : 1 0x7FF 0x8000000000000
3604 uint16_t _exp
, e0
, e1
;
3608 fargs
= my_malloc(200 * sizeof(double));
3610 for (s
= 0; s
< 2; s
++) {
3611 for (e0
= 0; e0
< 2; e0
++) {
3612 for (e1
= 0x000; ; e1
= ((e1
+ 1) << 2) + 6) {
3615 _exp
= (e0
<< 10) | e1
;
3616 for (mant
= 0x0000000000001ULL
; mant
< (1ULL << 52);
3617 /* Add 'random' bits */
3618 mant
= ((mant
+ 0x4A6) << 13) + 0x359) {
3619 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3626 /* Special values */
3627 /* +0.0 : 0 0x000 0x0000000000000 */
3630 mant
= 0x0000000000000ULL
;
3631 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3632 /* -0.0 : 1 0x000 0x0000000000000 */
3635 mant
= 0x0000000000000ULL
;
3636 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3637 /* +infinity : 0 0x7FF 0x0000000000000 */
3640 mant
= 0x0000000000000ULL
;
3641 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3642 /* -infinity : 1 0x7FF 0x0000000000000 */
3645 mant
= 0x0000000000000ULL
;
3646 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3647 /* +SNaN : 0 0x7FF 0x7FFFFFFFFFFFF */
3650 mant
= 0x7FFFFFFFFFFFFULL
;
3651 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3652 /* -SNaN : 1 0x7FF 0x7FFFFFFFFFFFF */
3655 mant
= 0x7FFFFFFFFFFFFULL
;
3656 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3657 /* +QNaN : 0 0x7FF 0x8000000000000 */
3660 mant
= 0x8000000000000ULL
;
3661 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3662 /* -QNaN : 1 0x7FF 0x8000000000000 */
3665 mant
= 0x8000000000000ULL
;
3666 register_farg(&fargs
[i
++], s
, _exp
, mant
);
3667 AB_DPRINTF("Registered %d floats values\n", i
);
3671 static void build_iargs_table (void)
3676 iargs
= my_malloc(400 * sizeof(uint32_t));
3678 for (tmp
= 0; ; tmp
= tmp
+ 1 + (tmp
>>1)+(tmp
>>2)+(tmp
>>3)) {
3679 if (tmp
>= 0x100000000ULL
)
3682 AB_DPRINTF("val %08llx\n", tmp
);
3683 if (tmp
== 0xFFFFFFFF)
3686 AB_DPRINTF("Registered %d ints values\n", i
);
3690 static void build_ii16_table (void)
3695 ii16
= my_malloc(200 * sizeof(uint32_t));
3697 for (tmp
= 0; ; tmp
= tmp
+ 1 + (tmp
>>1)+(tmp
>>2)+(tmp
>>3)) {
3701 AB_DPRINTF("val %08llx\n", tmp
);
3705 AB_DPRINTF("Registered %d ints values\n", i
);
3709 static void test_int_three_args (const unsigned char *name
, test_func_t func
)
3711 uint32_t res
, flags
, xer
;
3715 vexxx_printf( "Test instruction %s\n", name
);
3716 for (i
= 0; i
< nb_iargs
; i
++) {
3717 for (j
= 0; j
< nb_iargs
; j
++) {
3718 for (k
= 0;k
< nb_iargs
; k
++) {
3723 __asm__
__volatile__ ("mtcr 18");
3724 __asm__
__volatile__ ("mtxer 18");
3726 __asm__
__volatile__ ("mfcr 18");
3728 __asm__
__volatile__ ("mfxer 18");
3731 vexxx_printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
3732 name
, iargs
[i
], iargs
[j
], iargs
[k
], res
, flags
, xer
);
3741 static void test_int_two_args (const unsigned char *name
, test_func_t func
)
3743 uint32_t res
, flags
, xer
;
3747 vexxx_printf( "Test instruction %s\n", name
);
3748 for (i
= 0; i
< nb_iargs
; i
++) {
3749 for (j
= 0; j
< nb_iargs
; j
++) {
3753 __asm__
__volatile__ ("mtcr 18");
3754 __asm__
__volatile__ ("mtxer 18");
3756 __asm__
__volatile__ ("mfcr 18");
3758 __asm__
__volatile__ ("mfxer 18");
3761 vexxx_printf("%s %08x, %08x => %08x (%08x %08x)\n",
3762 name
, iargs
[i
], iargs
[j
], res
, flags
, xer
);
3769 static void test_int_one_arg (const unsigned char *name
, test_func_t func
)
3771 uint32_t res
, flags
, xer
;
3775 vexxx_printf( "Test instruction %s\n", name
);
3776 for (i
= 0; i
< nb_iargs
; i
++) {
3779 __asm__
__volatile__ ("mtcr 18");
3780 // r18 = 0x20000000; // set xer_ca
3781 __asm__
__volatile__ ("mtxer 18");
3784 __asm__
__volatile__ ("mfcr 18");
3786 __asm__
__volatile__ ("mfxer 18");
3788 vexxx_printf("%s %08x => %08x (%08x %08x)\n",
3789 name
, iargs
[i
], res
, flags
, xer
);
3794 static inline void _patch_op_imm (void *out
, void *in
,
3795 uint16_t imm
, int sh
, int len
)
3797 volatile uint32_t *p
, *q
;
3801 *p
= (*q
& ~(((1 << len
) - 1) << sh
)) | ((imm
& ((1 << len
) - 1)) << sh
);
3804 static inline void patch_op_imm (void *out
, void *in
,
3805 uint16_t imm
, int sh
, int len
)
3807 volatile uint32_t *p
;
3810 _patch_op_imm(out
, in
, imm
, sh
, len
);
3811 __asm__
__volatile__ ("dcbf 0, %0 ; icbi 0, %0 ; isync" ::"r"(p
));
3814 static inline void patch_op_imm16 (void *out
, void *in
, uint16_t imm
)
3816 patch_op_imm(out
, in
, imm
, 0, 16);
3819 static void test_int_one_reg_imm16 (const unsigned char *name
,
3822 uint32_t func_buf
[2], *p
;
3823 uint32_t res
, flags
, xer
;
3827 vexxx_printf( "Test instruction %s\n", name
);
3828 for (i
= 0; i
< nb_iargs
; i
++) {
3829 for (j
= 0; j
< nb_ii16
; j
++) {
3832 vexxx_printf("copy func %s from %p to %p (%08x %08x)\n",
3833 name
, func
, func_buf
, p
[0], p
[1]);
3836 patch_op_imm16(func_buf
, p
, ii16
[j
]);
3837 func
= (void *)func_buf
;
3839 vexxx_printf(" => func %s from %p to %p (%08x %08x)\n",
3840 name
, func
, func_buf
, func_buf
[0], func_buf
[1]);
3844 __asm__
__volatile__ ("mtcr 18");
3845 __asm__
__volatile__ ("mtxer 18");
3847 __asm__
__volatile__ ("mfcr 18");
3849 __asm__
__volatile__ ("mfxer 18");
3852 vexxx_printf("%s %08x, %08x => %08x (%08x %08x)\n",
3853 name
, iargs
[i
], ii16
[j
], res
, flags
, xer
);
3860 /* Special test cases for:
3872 static void rlwi_cb (const unsigned char *name
, test_func_t func
)
3874 uint32_t func_buf
[2], *p
;
3875 uint32_t res
, flags
, xer
;
3879 vexxx_printf( "Test instruction %s\n", name
);
3883 for (j
= 0; j
< 32; j
++) {
3884 for (k
= 0; k
< 32; k
++) {
3885 for (l
= 0; l
< 32; l
++) {
3888 _patch_op_imm(func_buf
, p
, j
, 11, 5);
3889 _patch_op_imm(func_buf
, p
, k
, 6, 5);
3890 patch_op_imm(func_buf
, p
, l
, 1, 5);
3891 func
= (void *)func_buf
;
3894 __asm__
__volatile__ ("mtcr 18");
3895 __asm__
__volatile__ ("mtxer 18");
3897 __asm__
__volatile__ ("mfcr 18");
3899 __asm__
__volatile__ ("mfxer 18");
3902 vexxx_printf("%s %08x, %d, %d, %d => %08x (%08x %08x)\n",
3903 name
, iargs
[i
], j
, k
, l
, res
, flags
, xer
);
3912 else if (i
== nb_iargs
- 1)
3920 static void rlwnm_cb (const unsigned char *name
, test_func_t func
)
3922 uint32_t func_buf
[2], *p
;
3923 uint32_t res
, flags
, xer
;
3927 vexxx_printf( "Test instruction %s\n", name
);
3928 for (i
= 0; i
< nb_iargs
; i
++) {
3929 for (j
= 0; j
< 64; j
++) {
3930 for (k
= 0; k
< 32; k
++) {
3931 for (l
= 0; l
< 32; l
++) {
3934 _patch_op_imm(func_buf
, p
, k
, 6, 5);
3935 patch_op_imm(func_buf
, p
, l
, 1, 5);
3936 func
= (void *)func_buf
;
3940 __asm__
__volatile__ ("mtcr 18");
3941 __asm__
__volatile__ ("mtxer 18");
3943 __asm__
__volatile__ ("mfcr 18");
3945 __asm__
__volatile__ ("mfxer 18");
3948 vexxx_printf("%s %08x, %08x, %d, %d => %08x (%08x %08x)\n",
3949 name
, iargs
[i
], j
, k
, l
, res
, flags
, xer
);
3960 static void srawi_cb (const unsigned char *name
, test_func_t func
)
3962 uint32_t func_buf
[2], *p
;
3963 uint32_t res
, flags
, xer
;
3967 vexxx_printf( "Test instruction %s\n", name
);
3968 for (i
= 0; i
< nb_iargs
; i
++) {
3969 for (j
= 0; j
< 32; j
++) {
3972 patch_op_imm(func_buf
, p
, j
, 11, 5);
3973 func
= (void *)func_buf
;
3976 __asm__
__volatile__ ("mtcr 18");
3977 __asm__
__volatile__ ("mtxer 18");
3979 __asm__
__volatile__ ("mfcr 18");
3981 __asm__
__volatile__ ("mfxer 18");
3984 vexxx_printf("%s %08x, %d => %08x (%08x %08x)\n",
3985 name
, iargs
[i
], j
, res
, flags
, xer
);
3992 typedef struct special_t special_t
;
3994 const unsigned char *name
;
3995 void (*test_cb
)(const unsigned char *name
, test_func_t func
);
3998 static void test_special (special_t
*table
,
3999 const unsigned char *name
, test_func_t func
)
4001 const unsigned char *tmp
;
4004 for (tmp
= name
; my_isspace(*tmp
); tmp
++)
4006 for (i
= 0; table
[i
].name
!= NULL
; i
++) {
4008 vexxx_printf( "look for handler for '%s' (%s)\n", name
,
4011 if (my_strcmp(table
[i
].name
, tmp
) == 0) {
4012 (*table
[i
].test_cb
)(name
, func
);
4016 vexxx_printf( "ERROR: no test found for op '%s'\n", name
);
4019 static special_t special_int_ops
[] = {
4022 "rlwimi", /* One register + 3 5 bits immediate arguments */
4026 "rlwimi.", /* One register + 3 5 bits immediate arguments */
4030 "rlwinm", /* One register + 3 5 bits immediate arguments */
4034 "rlwinm.", /* One register + 3 5 bits immediate arguments */
4038 "rlwnm", /* Two registers + 3 5 bits immediate arguments */
4042 "rlwnm.", /* Two registers + 3 5 bits immediate arguments */
4046 "srawi", /* One register + 1 5 bits immediate arguments */
4050 "srawi.", /* One register + 1 5 bits immediate arguments */
4056 "mcrf", /* 2 3 bits immediate arguments */
4060 "mcrf", /* 2 3 bits immediate arguments */
4070 static void test_int_special (const unsigned char *name
, test_func_t func
)
4072 test_special(special_int_ops
, name
, func
);
4075 static test_loop_t int_loops
[] = {
4078 &test_int_three_args
,
4080 &test_int_one_reg_imm16
,
4081 &test_int_one_reg_imm16
,
4085 #if !defined (NO_FLOAT)
4086 static void test_float_three_args (const unsigned char *name
, test_func_t func
)
4089 uint64_t u0
, u1
, u2
, ur
;
4094 vexxx_printf( "Test instruction %s\n", name
);
4095 for (i
= 0; i
< nb_fargs
; i
++) {
4096 for (j
= 0; j
< nb_fargs
; j
++) {
4097 for (k
= 0;k
< nb_fargs
; k
++) {
4098 u0
= *(uint64_t *)(&fargs
[i
]);
4099 u1
= *(uint64_t *)(&fargs
[j
]);
4100 u2
= *(uint64_t *)(&fargs
[k
]);
4105 __asm__
__volatile__ ("mtcr 18");
4106 __asm__
__volatile__ ("mtxer 18");
4108 __asm__
__volatile__ ("mtfsf 0xFF, 18");
4110 __asm__
__volatile__ ("mfcr 18");
4113 ur
= *(uint64_t *)(&res
);
4114 vexxx_printf("%s %016llx, %016llx, %016llx => %016llx (%08x)\n",
4115 name
, u0
, u1
, u2
, ur
, flags
);
4124 static void test_float_two_args (const unsigned char *name
, test_func_t func
)
4127 uint64_t u0
, u1
, ur
;
4132 vexxx_printf( "Test instruction %s\n", name
);
4133 for (i
= 0; i
< nb_fargs
; i
++) {
4134 for (j
= 0; j
< nb_fargs
; j
++) {
4135 u0
= *(uint64_t *)(&fargs
[i
]);
4136 u1
= *(uint64_t *)(&fargs
[j
]);
4140 __asm__
__volatile__ ("mtcr 18");
4141 __asm__
__volatile__ ("mtxer 18");
4143 __asm__
__volatile__ ("mtfsf 0xFF, 18");
4145 __asm__
__volatile__ ("mfcr 18");
4148 ur
= *(uint64_t *)(&res
);
4149 vexxx_printf("%s %016llx, %016llx => %016llx (%08x)\n",
4150 name
, u0
, u1
, ur
, flags
);
4157 static void test_float_one_arg (const unsigned char *name
, test_func_t func
)
4165 vexxx_printf( "Test instruction %s\n", name
);
4166 for (i
= 0; i
< nb_fargs
; i
++) {
4167 u0
= *(uint64_t *)(&fargs
[i
]);
4170 __asm__
__volatile__ ("mtcr 18");
4171 __asm__
__volatile__ ("mtxer 18");
4173 __asm__
__volatile__ ("mtfsf 0xFF, 18");
4175 __asm__
__volatile__ ("mfcr 18");
4178 ur
= *(uint64_t *)(&res
);
4179 vexxx_printf("%s %016llx => %016llx (%08x)\n", name
, u0
, ur
, flags
);
4184 static special_t special_float_ops
[] = {
4187 "mffs", /* One 5 bits immediate argument */
4191 "mffs.", /* One 5 bits immediate argument */
4195 "mtfsb0", /* One 5 bits immediate argument */
4199 "mtfsb0.", /* One 5 bits immediate argument */
4203 "mtfsb1", /* One 5 bits immediate argument */
4207 "mtfsb1.", /* One 5 bits immediate argument */
4211 "mtfsf", /* One register + 1 8 bits immediate argument */
4215 "mtfsf.", /* One register + 1 8 bits immediate argument */
4219 "mtfsfi", /* One 5 bits argument + 1 5 bits argument */
4223 "mtfsfi.", /* One 5 bits argument + 1 5 bits argument */
4233 static void test_float_special (const unsigned char *name
, test_func_t func
)
4235 test_special(special_float_ops
, name
, func
);
4238 static test_loop_t float_loops
[] = {
4239 &test_float_one_arg
,
4240 &test_float_two_args
,
4241 &test_float_three_args
,
4242 &test_float_two_args
,
4245 &test_float_special
,
4247 #endif /* !defined (NO_FLOAT) */
4250 #if defined (HAS_ALTIVEC) /* XXX: TODO */
4251 #endif /* defined (HAS_ALTIVEC) */
4253 #if defined (IS_PPC405)
4254 static void test_ppc405 (const unsigned char *name
, test_func_t func
)
4256 uint32_t res
, flags
, xer
;
4260 vexxx_printf( "Test instruction %s\n", name
);
4261 for (i
= 0; i
< nb_iargs
; i
++) {
4262 for (j
= 0; j
< nb_iargs
; j
++) {
4263 for (k
= 0;k
< nb_iargs
; k
++) {
4266 /* Beware: the third argument and the result
4267 * are in the same register
4271 __asm__
__volatile__ ("mtcr 18");
4272 __asm__
__volatile__ ("mtxer 18");
4274 __asm__
__volatile__ ("mfcr 18");
4276 __asm__
__volatile__ ("mfxer 18");
4279 vexxx_printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
4280 name
, iargs
[i
], iargs
[j
], iargs
[k
], res
, flags
, xer
);
4288 #endif /* defined (IS_PPC405) */
4290 static int check_filter (unsigned char *filter
)
4295 if (filter
!= NULL
) {
4296 c
= my_strchr(filter
, '*');
4306 static int check_name (const unsigned char *name
, const unsigned char *filter
,
4312 if (filter
!= NULL
) {
4313 for (; my_isspace(*name
); name
++)
4315 FDPRINTF("Check '%s' againt '%s' (%s match)\n",
4316 name
, filter
, exact
? "exact" : "starting");
4317 nlen
= vexxx_strlen(name
);
4318 flen
= vexxx_strlen(filter
);
4320 if (nlen
== flen
&& my_memcmp(name
, filter
, flen
) == 0)
4323 if (flen
<= nlen
&& my_memcmp(name
, filter
, flen
) == 0)
4333 static void do_tests (int one_arg
, int two_args
, int three_args
,
4334 int arith
, int logical
, int compare
,
4335 int integer
, int floats
, int p405
,
4336 int altivec
, int faltivec
,
4337 int cr
, unsigned char *filter
)
4339 #if defined (IS_PPC405)
4344 int nb_args
, type
, family
;
4348 exact
= check_filter(filter
);
4350 for (i
= 0; all_tests
[i
].name
!= NULL
; i
++) {
4351 nb_args
= all_tests
[i
].flags
& PPC_NB_ARGS
;
4352 /* Check number of arguments */
4353 if ((nb_args
== 1 && !one_arg
) ||
4354 (nb_args
== 2 && !two_args
) ||
4355 (nb_args
== 3 && !three_args
))
4357 /* Check instruction type */
4358 type
= all_tests
[i
].flags
& PPC_TYPE
;
4359 if ((type
== PPC_ARITH
&& !arith
) ||
4360 (type
== PPC_LOGICAL
&& !logical
) ||
4361 (type
== PPC_COMPARE
&& !compare
))
4363 /* Check instruction family */
4364 family
= all_tests
[i
].flags
& PPC_FAMILY
;
4365 if ((family
== PPC_INTEGER
&& !integer
) ||
4366 (family
== PPC_FLOAT
&& !floats
) ||
4367 (family
== PPC_405
&& !p405
) ||
4368 (family
== PPC_ALTIVEC
&& !altivec
) ||
4369 (family
== PPC_FALTIVEC
&& !faltivec
))
4371 /* Check flags update */
4372 if (((all_tests
[i
].flags
& PPC_CR
) && cr
== 0) ||
4373 (!(all_tests
[i
].flags
& PPC_CR
) && cr
== 1))
4375 /* All passed, do the tests */
4376 tests
= all_tests
[i
].tests
;
4377 /* Select the test loop */
4380 loop
= &int_loops
[nb_args
- 1];
4383 #if !defined (NO_FLOAT)
4384 loop
= &float_loops
[nb_args
- 1];
4387 vexxx_printf( "Sorry. "
4388 "PPC floating point instructions tests "
4389 "are disabled on your host\n");
4390 #endif /* !defined (NO_FLOAT) */
4393 #if defined (IS_PPC405)
4394 tmpl
= &test_ppc405
;
4398 vexxx_printf( "Sorry. "
4399 "PPC405 instructions tests are disabled on your host\n");
4401 #endif /* defined (IS_PPC405) */
4403 #if defined (HAS_ALTIVEC)
4405 loop
= &altivec_int_loops
[nb_args
- 1];
4408 vexxx_printf( "Sorry. "
4409 "Altivec instructions tests are not yet implemented\n");
4413 vexxx_printf( "Sorry. "
4414 "Altivec instructions tests are disabled on your host\n");
4418 #if defined (HAS_ALTIVEC)
4420 loop
= &altivec_float_loops
[nb_args
- 1];
4423 vexxx_printf( "Sorry. "
4424 "Altivec instructions tests are not yet implemented\n");
4428 vexxx_printf( "Sorry. "
4429 "Altivec float instructions tests "
4430 "are disabled on your host\n");
4434 vexxx_printf("ERROR: unknown insn family %08x\n", family
);
4438 vexxx_printf( "%s:\n", all_tests
[i
].name
);
4439 for (j
= 0; tests
[j
].name
!= NULL
; j
++) {
4440 if (check_name(tests
[j
].name
, filter
, exact
))
4441 (*loop
)(tests
[j
].name
, tests
[j
].func
);
4446 vexxx_printf( "All done. Tested %d different instructions\n", n
);
4450 static void usage (void)
4453 "test-ppc [-1] [-2] [-3] [-*] [-t <type>] [-f <family>] [-u] "
4454 "[-n <filter>] [-x] [-h]\n"
4455 "\t-1: test opcodes with one argument\n"
4456 "\t-2: test opcodes with two arguments\n"
4457 "\t-3: test opcodes with three arguments\n"
4458 "\t-*: launch test without checking the number of arguments\n"
4459 "\t-t: launch test for instructions of type <type>\n"
4460 "\t recognized types:\n"
4461 "\t\tarith (or a)\n"
4462 "\t\tlogical (or l)\n"
4463 "\t\tcompare (or c)\n"
4464 "\t-f: launch test for instructions of family <family>\n"
4465 "\t recognized families:\n"
4466 "\t\tinteger (or i)\n"
4467 "\t\tfloat (or f)\n"
4468 "\t\tppc405 (or mac)\n"
4469 "\t\taltivec (or a)\n"
4470 "\t-u: test instructions that update flags\n"
4471 "\t-n: filter instructions with <filter>\n"
4472 "\t <filter> can be in two forms:\n"
4473 "\t\tname : filter functions that exactly match <name>\n"
4474 "\t\tname* : filter functions that start with <name>\n"
4475 "\t-h: print this help\n"
4480 int _main (int argc
, char **argv
)
4482 unsigned char /* *tmp, */ *filter
= NULL
;
4483 int one_arg
= 0, two_args
= 0, three_args
= 0;
4484 int arith
= 0, logical
= 0, compare
= 0;
4485 int integer
= 0, floats
= 0, p405
= 0, altivec
= 0, faltivec
= 0;
4489 // while ((c = getopt(argc, argv, "123t:f:n:uvh")) != -1) {
4502 // if (my_strcmp(tmp, "arith") == 0 || my_strcmp(tmp, "a") == 0) {
4504 // } else if (my_strcmp(tmp, "logical") == 0 || my_strcmp(tmp, "l") == 0) {
4506 // } else if (my_strcmp(tmp, "compare") == 0 || my_strcmp(tmp, "c") == 0) {
4514 // if (my_strcmp(tmp, "integer") == 0 || my_strcmp(tmp, "i") == 0) {
4516 // } else if (my_strcmp(tmp, "float") == 0 || my_strcmp(tmp, "f") == 0) {
4518 // } else if (my_strcmp(tmp, "ppc405") == 0 || my_strcmp(tmp, "mac") == 0) {
4520 // } else if (my_strcmp(tmp, "altivec") == 0 || my_strcmp(tmp, "a") == 0) {
4541 // vexxx_printf( "Unknown argument: '%c'\n", c);
4545 // vexxx_printf( "Bad argument for '%c': '%s'\n", c, tmp);
4549 // if (argc != optind) {
4551 // vexxx_printf( "Bad number of arguments\n");
4555 if (one_arg
== 0 && two_args
== 0 && three_args
== 0) {
4560 if (arith
== 0 && logical
== 0 && compare
== 0) {
4565 if (integer
== 0 && floats
== 0 && altivec
== 0 && faltivec
== 0 &&
4575 build_iargs_table();
4576 build_fargs_table();
4596 do_tests(one_arg
, two_args
, three_args
,
4597 arith
, logical
, compare
,
4598 integer
, floats
, p405
, altivec
, faltivec
,
4605 void entry ( HWord(*service
)(HWord
,HWord
) )
4607 char* argv
[2] = { NULL
, NULL
};
4608 serviceFn
= service
;