5 gcc -Winline -Wall -g -O -mregnames -maltivec
7 gcc -Winline -Wall -g -O -mregnames -maltivec -m64
9 This program is useful, but the register usage conventions in
10 it are a complete dog. In particular, _patch_op_imm has to
11 be inlined, else you wind up with it segfaulting in
12 completely different places due to corruption (of r20 in the
18 * PPC tests for qemu-PPC CPU emulation checks
20 * Copyright (c) 2005 Jocelyn Mayer
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License V2
24 * as published by the Free Software Foundation
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 * Theory of operations:
38 * a few registers are reserved for the test program:
41 * I do preload test values in r14 thru r17 (or less, depending on the number
42 * of register operands needed), patch the test opcode if any immediate
43 * operands are required, execute the tested opcode.
44 * XER, CCR and FPSCR are cleared before every test.
45 * I always get the result in r17 and also save XER and CCR for fixed-point
46 * operations. I also check FPSCR for floating points operations.
49 * a more clever FPSCR management is needed: for now, I always test
50 * the round-to-zero case. Other rounding modes also need to be tested.
56 * The 'test' functions (via all_tests[]) are wrappers of single asm instns
58 * The 'loops' (e.g. int_loops) do the actual work:
59 * - loops over as many arguments as the instn needs (regs | imms)
60 * - sets up the environment (reset cr,xer, assign src regs...)
61 * - maybe modifies the asm instn to test different imm args
62 * - calls the test function
63 * - retrieves relevant register data (rD,cr,xer,...)
64 * - prints argument and result data.
66 * More specifically...
68 * all_tests[i] holds insn tests
69 * - of which each holds: {instn_test_arr[], description, flags}
71 * flags hold 3 instn classifiers: {family, type, arg_type}
73 * // The main test loop:
74 * do_tests( user_ctl_flags ) {
75 * foreach(curr_test = all_test[i]) {
77 * // flags are used to control what tests are run:
78 * if (curr_test->flags && !user_ctl_flags)
81 * // a 'loop_family_arr' is chosen based on the 'family' flag...
82 * switch(curr_test->flags->family) {
83 * case x: loop_family_arr = int_loops;
87 * // ...and the actual test_loop to run is found by indexing into
88 * // the loop_family_arr with the 'arg_type' flag:
89 * test_loop = loop_family[curr_test->flags->arg_type]
91 * // finally, loop over all instn tests for this test:
92 * foreach (instn_test = curr_test->instn_test_arr[i]) {
94 * // and call the test_loop with the current instn_test function,name
95 * test_loop( instn_test->func, instn_test->name )
101 * Details of intruction patching for immediate operands
102 * -----------------------------------------------------
103 * All the immediate insn test functions are of the form {imm_insn, blr}
104 * In order to patch one of these functions, we simply copy both insns
105 * to a stack buffer, and rewrite the immediate part of imm_insn.
106 * We then execute our stack buffer.
107 * All ppc instructions are 32bits wide, which makes this fairly easy.
110 * extern void test_addi (void);
111 * asm(".section \".text\"\n"
113 * " .type test_addi,@function\n"
120 * We are interested only in:
121 * " addi 17, 14, 0\n"
124 * In a loop test, we may see:
125 * uint32_t func_buf[2]; // our new stack based 'function'
126 * for imm... // loop over imm
127 * init_function( &func, func_buf ); // copy insns, set func ptr
128 * patch_op_imm16(&func_buf[0], imm); // patch 'addi' insn
130 * (*func)(); // exec our rewritten code
132 * patch_op_imm16() itself simply takes the uint32_t insn and overwrites
133 * the immediate field with the new value (which, for 'addi', is the
136 * So in the loop test, if 'imm' is currently 9, and p[0] is:
137 * 0x3A2E0000 => addi 17, 14, 0
139 * after patch_op_imm16(), func_buf[0] becomes:
140 * 0x3A2E0009 => addi 17, 14, 9
142 * Note: init_function() needs to be called on every iteration
143 * - don't ask me why!
147 /**********************************************************************/
148 /* Uncomment to enable many arguments for altivec insns */
151 /* Uncomment to enable many arguments for altivec insns */
152 //#define ALTIVEC_ARGS_LARGE
154 /* Uncomment to enable output of CR flags for float tests */
155 //#define TEST_FLOAT_FLAGS
157 /* Uncomment to enable debug output */
158 //#define DEBUG_ARGS_BUILD
159 //#define DEBUG_FILTER
161 /* These should be set at build time */
163 //#define HAS_ALTIVEC // CFLAGS += -maltivec
165 /**********************************************************************/
169 #include "tests/sys_mman.h"
170 #include "tests/malloc.h" // memalign16
172 #define STATIC_ASSERT(e) sizeof(struct { int:-!(e); })
174 /* Something of the same size as void*, so can be safely be coerced
175 * to/from a pointer type. Also same size as the host's gp registers.
176 * According to the AltiVec section of the GCC manual, the syntax does
177 * not allow the use of a typedef name as a type specifier in conjunction
178 * with the vector keyword, so typedefs uint[32|64]_t are #undef'ed here
179 * and redefined using #define.
183 #define uint32_t unsigned int
184 #define uint64_t unsigned long long int
186 #ifndef __powerpc64__
187 typedef uint32_t HWord_t;
189 typedef uint64_t HWord_t;
190 #endif /* __powerpc64__ */
193 compile_time_test1 = STATIC_ASSERT(sizeof(uint32_t) == 4),
194 compile_time_test2 = STATIC_ASSERT(sizeof(uint64_t) == 8),
197 #define ALLCR "cr0","cr1","cr2","cr3","cr4","cr5","cr6","cr7"
199 #define SET_CR(_arg) \
200 __asm__ __volatile__ ("mtcr %0" : : "b"(_arg) : ALLCR );
202 #define SET_XER(_arg) \
203 __asm__ __volatile__ ("mtxer %0" : : "b"(_arg) : "xer" );
205 #define GET_CR(_lval) \
206 __asm__ __volatile__ ("mfcr %0" : "=b"(_lval) )
208 #define GET_XER(_lval) \
209 __asm__ __volatile__ ("mfxer %0" : "=b"(_lval) )
211 #define GET_CR_XER(_lval_cr,_lval_xer) \
212 do { GET_CR(_lval_cr); GET_XER(_lval_xer); } while (0)
214 #define SET_CR_ZERO \
217 #define SET_XER_ZERO \
220 #define SET_CR_XER_ZERO \
221 do { SET_CR_ZERO; SET_XER_ZERO; } while (0)
223 #define SET_FPSCR_ZERO \
224 do { double _d = 0.0; \
225 __asm__ __volatile__ ("mtfsf 0xFF, %0" : : "f"(_d) ); \
229 /* XXXX these must all be callee-save regs! */
230 register double f14 __asm__ ("fr14");
231 register double f15 __asm__ ("fr15");
232 register double f16 __asm__ ("fr16");
233 register double f17 __asm__ ("fr17");
234 register HWord_t r14 __asm__ ("r14");
235 register HWord_t r15 __asm__ ("r15");
236 register HWord_t r16 __asm__ ("r16");
237 register HWord_t r17 __asm__ ("r17");
239 #include "config.h" // HAS_ALTIVEC
240 #if defined (HAS_ALTIVEC)
241 # include <altivec.h>
244 #include <ctype.h> // isspace
248 #include <unistd.h> // getopt
251 #ifndef __powerpc64__
252 #define ASSEMBLY_FUNC(__fname, __insn) \
253 asm(".section \".text\"\n" \
255 "\t.type "__fname",@function\n" \
262 #define ASSEMBLY_FUNC(__fname, __insn) \
263 asm(".section \".text\"\n" \
265 "\t.global "__fname"\n" \
266 "\t.section \".opd\",\"aw\"\n" \
269 "\t.quad ."__fname",.TOC.@tocbase,0\n" \
271 "\t.type ."__fname",@function\n" \
272 "\t.global ."__fname"\n" \
277 #endif // #ifndef __powerpc64__
280 /* Return a pointer to a 1-page area where is is safe to both write
281 and execute instructions. Area is filled with 'trap' insns. */
283 uint32_t* get_rwx_area ( void )
286 static uint32_t* p = NULL;
288 p = mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
289 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
290 assert(p != MAP_FAILED);
293 for (i = 0; i < 4096/sizeof(uint32_t); i++)
294 p[i] = 0x7fe00008; /* trap */
300 /* -------------- BEGIN #include "test-ppc.h" -------------- */
303 * PPC tests for qemu-PPC CPU emulation checks - definitions
305 * Copyright (c) 2005 Jocelyn Mayer
307 * This program is free software; you can redistribute it and/or
308 * modify it under the terms of the GNU General Public License V2
309 * as published by the Free Software Foundation
311 * This program is distributed in the hope that it will be useful,
312 * but WITHOUT ANY WARRANTY; without even the implied warranty of
313 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314 * GNU General Public License for more details.
316 * You should have received a copy of the GNU General Public License
317 * along with this program; if not, write to the Free Software
318 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
321 #if !defined (__TEST_PPC_H__)
322 #define __TEST_PPC_H__
326 typedef void (*test_func_t) (void);
327 typedef struct test_t test_t;
328 typedef struct test_table_t test_table_t;
334 struct test_table_t {
340 typedef void (*test_loop_t) (const char *name, test_func_t func,
345 PPC_ONE_ARG = 0x00000001,
346 PPC_TWO_ARGS = 0x00000002,
347 PPC_THREE_ARGS = 0x00000003,
348 PPC_CMP_ARGS = 0x00000004, // family: compare
349 PPC_CMPI_ARGS = 0x00000005, // family: compare
350 PPC_TWO_I16 = 0x00000006, // family: arith/logical
351 PPC_SPECIAL = 0x00000007, // family: logical
352 PPC_LD_ARGS = 0x00000008, // family: ldst
353 PPC_LDX_ARGS = 0x00000009, // family: ldst
354 PPC_ST_ARGS = 0x0000000A, // family: ldst
355 PPC_STX_ARGS = 0x0000000B, // family: ldst
356 PPC_NB_ARGS = 0x0000000F,
358 PPC_ARITH = 0x00000100,
359 PPC_LOGICAL = 0x00000200,
360 PPC_COMPARE = 0x00000300,
361 PPC_CROP = 0x00000400,
362 PPC_LDST = 0x00000500,
363 PPC_TYPE = 0x00000F00,
365 PPC_INTEGER = 0x00010000,
366 PPC_FLOAT = 0x00020000,
367 PPC_405 = 0x00030000,
368 PPC_ALTIVEC = 0x00040000,
369 PPC_FALTIVEC = 0x00050000,
370 PPC_FAMILY = 0x000F0000,
371 /* Flags: these may be combined, so use separate bitfields. */
373 PPC_XER_CA = 0x02000000,
376 #endif /* !defined (__TEST_PPC_H__) */
378 /* -------------- END #include "test-ppc.h" -------------- */
383 #if defined (DEBUG_ARGS_BUILD)
384 #define AB_DPRINTF(fmt, args...) do { fprintf(stderr, fmt , ##args); } while (0)
386 #define AB_DPRINTF(fmt, args...) do { } while (0)
389 #if defined (DEBUG_FILTER)
390 #define FDPRINTF(fmt, args...) do { fprintf(stderr, fmt , ##args); } while (0)
392 #define FDPRINTF(fmt, args...) do { } while (0)
396 /* Produce the 64-bit pattern corresponding to the supplied double. */
397 static uint64_t double_to_bits ( double d )
399 union { uint64_t i; double d; } u;
400 assert(8 == sizeof(uint64_t));
401 assert(8 == sizeof(double));
402 assert(8 == sizeof(u));
408 static float bits_to_float ( uint32_t i )
410 union { uint32_t i; float f; } u;
411 assert(4 == sizeof(uint32_t));
412 assert(4 == sizeof(float));
413 assert(4 == sizeof(u));
420 #if defined (HAS_ALTIVEC)
421 static void AB_DPRINTF_VEC32x4 ( vector unsigned int v )
423 #if defined (DEBUG_ARGS_BUILD)
425 unsigned int* p_int = (unsigned int*)&v;
427 for (i=0; i<4; i++) {
428 AB_DPRINTF(" %08x", p_int[i]);
436 #define unused __attribute__ (( unused ))
439 /* -------------- BEGIN #include "ops-ppc.c" -------------- */
441 /* #include "test-ppc.h" */
443 static void test_add (void)
445 __asm__ __volatile__ ("add 17, 14, 15");
448 static void test_addo (void)
450 __asm__ __volatile__ ("addo 17, 14, 15");
453 static void test_addc (void)
455 __asm__ __volatile__ ("addc 17, 14, 15");
458 static void test_addco (void)
460 __asm__ __volatile__ ("addco 17, 14, 15");
463 static void test_divw (void)
465 __asm__ __volatile__ ("divw 17, 14, 15");
468 static void test_divwo (void)
470 __asm__ __volatile__ ("divwo 17, 14, 15");
473 static void test_divwu (void)
475 __asm__ __volatile__ ("divwu 17, 14, 15");
478 static void test_divwuo (void)
480 __asm__ __volatile__ ("divwuo 17, 14, 15");
483 static void test_mulhw (void)
485 __asm__ __volatile__ ("mulhw 17, 14, 15");
488 static void test_mulhwu (void)
490 __asm__ __volatile__ ("mulhwu 17, 14, 15");
493 static void test_mullw (void)
495 __asm__ __volatile__ ("mullw 17, 14, 15");
498 static void test_mullwo (void)
500 __asm__ __volatile__ ("mullwo 17, 14, 15");
503 static void test_subf (void)
505 __asm__ __volatile__ ("subf 17, 14, 15");
508 static void test_subfo (void)
510 __asm__ __volatile__ ("subfo 17, 14, 15");
513 static void test_subfc (void)
515 __asm__ __volatile__ ("subfc 17, 14, 15");
518 static void test_subfco (void)
520 __asm__ __volatile__ ("subfco 17, 14, 15");
524 static void test_mulld (void)
526 __asm__ __volatile__ ("mulld 17, 14, 15");
529 static void test_mulhd (void)
531 __asm__ __volatile__ ("mulhd 17, 14, 15");
534 static void test_mulhdu (void)
536 __asm__ __volatile__ ("mulhdu 17, 14, 15");
539 static void test_divd (void)
541 __asm__ __volatile__ ("divd 17, 14, 15");
544 static void test_divdu (void)
546 __asm__ __volatile__ ("divdu 17, 14, 15");
548 #endif // #ifdef __powerpc64__
550 static test_t tests_ia_ops_two[] = {
551 { &test_add , " add", },
552 { &test_addo , " addo", },
553 { &test_addc , " addc", },
554 { &test_addco , " addco", },
555 { &test_divw , " divw", },
556 { &test_divwo , " divwo", },
557 { &test_divwu , " divwu", },
558 { &test_divwuo , " divwuo", },
559 { &test_mulhw , " mulhw", },
560 { &test_mulhwu , " mulhwu", },
561 { &test_mullw , " mullw", },
562 { &test_mullwo , " mullwo", },
563 { &test_subf , " subf", },
564 { &test_subfo , " subfo", },
565 { &test_subfc , " subfc", },
566 { &test_subfco , " subfco", },
568 { &test_mulhd , " mulhd", },
569 { &test_mulhdu , " mulhdu", },
570 { &test_mulld , " mulld", },
571 { &test_divd , " divd", },
572 { &test_divdu , " divdu", },
573 #endif // #ifdef __powerpc64__
577 static void test_add_ (void)
579 __asm__ __volatile__ ("add. 17, 14, 15");
582 static void test_addo_ (void)
584 __asm__ __volatile__ ("addo. 17, 14, 15");
587 static void test_addc_ (void)
589 __asm__ __volatile__ ("addc. 17, 14, 15");
592 static void test_addco_ (void)
594 __asm__ __volatile__ ("addco. 17, 14, 15");
597 static void test_divw_ (void)
599 __asm__ __volatile__ ("divw. 17, 14, 15");
602 static void test_divwo_ (void)
604 __asm__ __volatile__ ("divwo. 17, 14, 15");
607 static void test_divwu_ (void)
609 __asm__ __volatile__ ("divwu. 17, 14, 15");
612 static void test_divwuo_ (void)
614 __asm__ __volatile__ ("divwuo. 17, 14, 15");
617 static void test_mulhw_ (void)
619 __asm__ __volatile__ ("mulhw. 17, 14, 15");
622 static void test_mulhwu_ (void)
624 __asm__ __volatile__ ("mulhwu. 17, 14, 15");
627 static void test_mullw_ (void)
629 __asm__ __volatile__ ("mullw. 17, 14, 15");
632 static void test_mullwo_ (void)
634 __asm__ __volatile__ ("mullwo. 17, 14, 15");
637 static void test_subf_ (void)
639 __asm__ __volatile__ ("subf. 17, 14, 15");
642 static void test_subfo_ (void)
644 __asm__ __volatile__ ("subfo. 17, 14, 15");
647 static void test_subfc_ (void)
649 __asm__ __volatile__ ("subfc. 17, 14, 15");
652 static void test_subfco_ (void)
654 __asm__ __volatile__ ("subfco. 17, 14, 15");
658 static void test_mulhd_ (void)
660 __asm__ __volatile__ ("mulhd. 17, 14, 15");
663 static void test_mulhdu_ (void)
665 __asm__ __volatile__ ("mulhdu. 17, 14, 15");
668 static void test_mulld_ (void)
670 __asm__ __volatile__ ("mulld. 17, 14, 15");
673 static void test_divd_ (void)
675 __asm__ __volatile__ ("divd. 17, 14, 15");
678 static void test_divdu_ (void)
680 __asm__ __volatile__ ("divdu. 17, 14, 15");
682 #endif // #ifdef __powerpc64__
684 static test_t tests_iar_ops_two[] = {
685 { &test_add_ , " add.", },
686 { &test_addo_ , " addo.", },
687 { &test_addc_ , " addc.", },
688 { &test_addco_ , " addco.", },
689 { &test_divw_ , " divw.", },
690 { &test_divwo_ , " divwo.", },
691 { &test_divwu_ , " divwu.", },
692 { &test_divwuo_ , " divwuo.", },
693 { &test_mulhw_ , " mulhw.", },
694 { &test_mulhwu_ , " mulhwu.", },
695 { &test_mullw_ , " mullw.", },
696 { &test_mullwo_ , " mullwo.", },
697 { &test_subf_ , " subf.", },
698 { &test_subfo_ , " subfo.", },
699 { &test_subfc_ , " subfc.", },
700 { &test_subfco_ , " subfco.", },
702 { &test_mulhd_ , " mulhd.", },
703 { &test_mulhdu_ , " mulhdu.", },
704 { &test_mulld_ , " mulld.", },
705 { &test_divd_ , " divd.", },
706 { &test_divdu_ , " divdu.", },
707 #endif // #ifdef __powerpc64__
711 static void test_adde (void)
713 __asm__ __volatile__ ("adde 17, 14, 15");
716 static void test_addeo (void)
718 __asm__ __volatile__ ("addeo 17, 14, 15");
721 static void test_subfe (void)
723 __asm__ __volatile__ ("subfe 17, 14, 15");
726 static void test_subfeo (void)
728 __asm__ __volatile__ ("subfeo 17, 14, 15");
731 static test_t tests_iac_ops_two[] = {
732 { &test_adde , " adde", },
733 { &test_addeo , " addeo", },
734 { &test_subfe , " subfe", },
735 { &test_subfeo , " subfeo", },
739 static void test_adde_ (void)
741 __asm__ __volatile__ ("adde. 17, 14, 15");
744 static void test_addeo_ (void)
746 __asm__ __volatile__ ("addeo. 17, 14, 15");
749 static void test_subfe_ (void)
751 __asm__ __volatile__ ("subfe. 17, 14, 15");
754 static void test_subfeo_ (void)
756 __asm__ __volatile__ ("subfeo. 17, 14, 15");
759 static test_t tests_iacr_ops_two[] = {
760 { &test_adde_ , " adde.", },
761 { &test_addeo_ , " addeo.", },
762 { &test_subfe_ , " subfe.", },
763 { &test_subfeo_ , " subfeo.", },
767 static void test_and (void)
769 __asm__ __volatile__ ("and 17, 14, 15");
772 static void test_andc (void)
774 __asm__ __volatile__ ("andc 17, 14, 15");
777 static void test_eqv (void)
779 __asm__ __volatile__ ("eqv 17, 14, 15");
782 static void test_nand (void)
784 __asm__ __volatile__ ("nand 17, 14, 15");
787 static void test_nor (void)
789 __asm__ __volatile__ ("nor 17, 14, 15");
792 static void test_or (void)
794 __asm__ __volatile__ ("or 17, 14, 15");
797 static void test_orc (void)
799 __asm__ __volatile__ ("orc 17, 14, 15");
802 static void test_xor (void)
804 __asm__ __volatile__ ("xor 17, 14, 15");
807 static void test_slw (void)
809 __asm__ __volatile__ ("slw 17, 14, 15");
812 static void test_sraw (void)
814 __asm__ __volatile__ ("sraw 17, 14, 15");
817 static void test_srw (void)
819 __asm__ __volatile__ ("srw 17, 14, 15");
823 static void test_sld (void)
825 __asm__ __volatile__ ("sld 17, 14, 15");
828 static void test_srad (void)
830 __asm__ __volatile__ ("srad 17, 14, 15");
833 static void test_srd (void)
835 __asm__ __volatile__ ("srd 17, 14, 15");
837 #endif // #ifdef __powerpc64__
839 static test_t tests_il_ops_two[] = {
840 { &test_and , " and", },
841 { &test_andc , " andc", },
842 { &test_eqv , " eqv", },
843 { &test_nand , " nand", },
844 { &test_nor , " nor", },
845 { &test_or , " or", },
846 { &test_orc , " orc", },
847 { &test_xor , " xor", },
848 { &test_slw , " slw", },
849 { &test_sraw , " sraw", },
850 { &test_srw , " srw", },
852 { &test_sld , " sld", },
853 { &test_srad , " srad", },
854 { &test_srd , " srd", },
855 #endif // #ifdef __powerpc64__
859 static void test_and_ (void)
861 __asm__ __volatile__ ("and. 17, 14, 15");
864 static void test_andc_ (void)
866 __asm__ __volatile__ ("andc. 17, 14, 15");
869 static void test_eqv_ (void)
871 __asm__ __volatile__ ("eqv. 17, 14, 15");
874 static void test_nand_ (void)
876 __asm__ __volatile__ ("nand. 17, 14, 15");
879 static void test_nor_ (void)
881 __asm__ __volatile__ ("nor. 17, 14, 15");
884 static void test_or_ (void)
886 __asm__ __volatile__ ("or. 17, 14, 15");
889 static void test_orc_ (void)
891 __asm__ __volatile__ ("orc. 17, 14, 15");
894 static void test_xor_ (void)
896 __asm__ __volatile__ ("xor. 17, 14, 15");
899 static void test_slw_ (void)
901 __asm__ __volatile__ ("slw. 17, 14, 15");
904 static void test_sraw_ (void)
906 __asm__ __volatile__ ("sraw. 17, 14, 15");
909 static void test_srw_ (void)
911 __asm__ __volatile__ ("srw. 17, 14, 15");
915 static void test_sld_ (void)
917 __asm__ __volatile__ ("sld. 17, 14, 15");
920 static void test_srad_ (void)
922 __asm__ __volatile__ ("srad. 17, 14, 15");
925 static void test_srd_ (void)
927 __asm__ __volatile__ ("srd. 17, 14, 15");
929 #endif // #ifdef __powerpc64__
931 static test_t tests_ilr_ops_two[] = {
932 { &test_and_ , " and.", },
933 { &test_andc_ , " andc.", },
934 { &test_eqv_ , " eqv.", },
935 { &test_nand_ , " nand.", },
936 { &test_nor_ , " nor.", },
937 { &test_or_ , " or.", },
938 { &test_orc_ , " orc.", },
939 { &test_xor_ , " xor.", },
940 { &test_slw_ , " slw.", },
941 { &test_sraw_ , " sraw.", },
942 { &test_srw_ , " srw.", },
944 { &test_sld_ , " sld.", },
945 { &test_srad_ , " srad.", },
946 { &test_srd_ , " srd.", },
947 #endif // #ifdef __powerpc64__
951 static void test_cmpw (void)
953 __asm__ __volatile__ ("cmpw 2, 14, 15");
956 static void test_cmplw (void)
958 __asm__ __volatile__ ("cmplw 2, 14, 15");
962 static void test_cmpd (void)
964 __asm__ __volatile__ ("cmpd 2, 14, 15");
967 static void test_cmpld (void)
969 __asm__ __volatile__ ("cmpld 2, 14, 15");
971 #endif // #ifdef __powerpc64__
973 static test_t tests_icr_ops_two[] = {
974 { &test_cmpw , " cmpw", },
975 { &test_cmplw , " cmplw", },
977 { &test_cmpd , " cmpd", },
978 { &test_cmpld , " cmpld", },
979 #endif // #ifdef __powerpc64__
983 extern void test_cmpwi (void);
984 ASSEMBLY_FUNC("test_cmpwi", "cmpwi 2, 14, 0");
986 extern void test_cmplwi (void);
987 ASSEMBLY_FUNC("test_cmplwi", "cmplwi 2, 14, 0");
990 extern void test_cmpdi (void);
991 ASSEMBLY_FUNC("test_cmpdi", "cmpdi 2, 14, 0");
993 extern void test_cmpldi (void);
994 ASSEMBLY_FUNC("test_cmpldi", "cmpldi 2, 14, 0");
995 #endif // #ifdef __powerpc64__
997 static test_t tests_icr_ops_two_i16[] = {
998 { &test_cmpwi , " cmpwi", },
999 { &test_cmplwi , " cmplwi", },
1000 #ifdef __powerpc64__
1001 { &test_cmpdi , " cmpdi", },
1002 { &test_cmpldi , " cmpldi", },
1003 #endif // #ifdef __powerpc64__
1007 extern void test_addi (void);
1008 ASSEMBLY_FUNC("test_addi", "addi 17, 14, 0");
1010 extern void test_addic (void);
1011 ASSEMBLY_FUNC("test_addic", "addic 17, 14, 0");
1013 extern void test_addis (void);
1014 ASSEMBLY_FUNC("test_addis", "addis 17, 14, 0");
1016 extern void test_mulli (void);
1017 ASSEMBLY_FUNC("test_mulli", "mulli 17, 14, 0");
1019 extern void test_subfic (void);
1020 ASSEMBLY_FUNC("test_subfic", "subfic 17, 14, 0");
1022 static test_t tests_ia_ops_two_i16[] = {
1023 { &test_addi , " addi", },
1024 { &test_addic , " addic", },
1025 { &test_addis , " addis", },
1026 { &test_mulli , " mulli", },
1027 { &test_subfic , " subfic", },
1031 extern void test_addic_ (void);
1032 ASSEMBLY_FUNC("test_addic_", "addic. 17, 14, 0");
1034 static test_t tests_iar_ops_two_i16[] = {
1035 { &test_addic_ , " addic.", },
1039 extern void test_ori (void);
1040 ASSEMBLY_FUNC("test_ori", "ori 17, 14, 0");
1042 extern void test_oris (void);
1043 ASSEMBLY_FUNC("test_oris", "oris 17, 14, 0");
1045 extern void test_xori (void);
1046 ASSEMBLY_FUNC("test_xori", "xori 17, 14, 0");
1048 extern void test_xoris (void);
1049 ASSEMBLY_FUNC("test_xoris", "xoris 17, 14, 0");
1051 static test_t tests_il_ops_two_i16[] = {
1052 { &test_ori , " ori", },
1053 { &test_oris , " oris", },
1054 { &test_xori , " xori", },
1055 { &test_xoris , " xoris", },
1059 extern void test_andi_ (void);
1060 ASSEMBLY_FUNC("test_andi_", "andi. 17, 14, 0");
1062 extern void test_andis_ (void);
1063 ASSEMBLY_FUNC("test_andis_", "andis. 17, 14, 0");
1065 static test_t tests_ilr_ops_two_i16[] = {
1066 { &test_andi_ , " andi.", },
1067 { &test_andis_ , " andis.", },
1071 static void test_crand (void)
1073 __asm__ __volatile__ ("crand 17, 14, 15");
1076 static void test_crandc (void)
1078 __asm__ __volatile__ ("crandc 17, 14, 15");
1081 static void test_creqv (void)
1083 __asm__ __volatile__ ("creqv 17, 14, 15");
1086 static void test_crnand (void)
1088 __asm__ __volatile__ ("crnand 17, 14, 15");
1091 static void test_crnor (void)
1093 __asm__ __volatile__ ("crnor 17, 14, 15");
1096 static void test_cror (void)
1098 __asm__ __volatile__ ("cror 17, 14, 15");
1101 static void test_crorc (void)
1103 __asm__ __volatile__ ("crorc 17, 14, 15");
1106 static void test_crxor (void)
1108 __asm__ __volatile__ ("crxor 17, 14, 15");
1111 static test_t tests_crl_ops_two[] = {
1112 { &test_crand , " crand", },
1113 { &test_crandc , " crandc", },
1114 { &test_creqv , " creqv", },
1115 { &test_crnand , " crnand", },
1116 { &test_crnor , " crnor", },
1117 { &test_cror , " cror", },
1118 { &test_crorc , " crorc", },
1119 { &test_crxor , " crxor", },
1123 static void test_addme (void)
1125 __asm__ __volatile__ ("addme 17, 14");
1128 static void test_addmeo (void)
1130 __asm__ __volatile__ ("addmeo 17, 14");
1133 static void test_addze (void)
1135 __asm__ __volatile__ ("addze 17, 14");
1138 static void test_addzeo (void)
1140 __asm__ __volatile__ ("addzeo 17, 14");
1143 static void test_subfme (void)
1145 __asm__ __volatile__ ("subfme 17, 14");
1148 static void test_subfmeo (void)
1150 __asm__ __volatile__ ("subfmeo 17, 14");
1153 static void test_subfze (void)
1155 __asm__ __volatile__ ("subfze 17, 14");
1158 static void test_subfzeo (void)
1160 __asm__ __volatile__ ("subfzeo 17, 14");
1163 static test_t tests_iac_ops_one[] = {
1164 { &test_addme , " addme", },
1165 { &test_addmeo , " addmeo", },
1166 { &test_addze , " addze", },
1167 { &test_addzeo , " addzeo", },
1168 { &test_subfme , " subfme", },
1169 { &test_subfmeo , " subfmeo", },
1170 { &test_subfze , " subfze", },
1171 { &test_subfzeo , " subfzeo", },
1175 static void test_addme_ (void)
1177 __asm__ __volatile__ ("addme. 17, 14");
1180 static void test_addmeo_ (void)
1182 __asm__ __volatile__ ("addmeo. 17, 14");
1185 static void test_addze_ (void)
1187 __asm__ __volatile__ ("addze. 17, 14");
1190 static void test_addzeo_ (void)
1192 __asm__ __volatile__ ("addzeo. 17, 14");
1195 static void test_subfme_ (void)
1197 __asm__ __volatile__ ("subfme. 17, 14");
1200 static void test_subfmeo_ (void)
1202 __asm__ __volatile__ ("subfmeo. 17, 14");
1205 static void test_subfze_ (void)
1207 __asm__ __volatile__ ("subfze. 17, 14");
1210 static void test_subfzeo_ (void)
1212 __asm__ __volatile__ ("subfzeo. 17, 14");
1215 static test_t tests_iacr_ops_one[] = {
1216 { &test_addme_ , " addme.", },
1217 { &test_addmeo_ , " addmeo.", },
1218 { &test_addze_ , " addze.", },
1219 { &test_addzeo_ , " addzeo.", },
1220 { &test_subfme_ , " subfme.", },
1221 { &test_subfmeo_ , " subfmeo.", },
1222 { &test_subfze_ , " subfze.", },
1223 { &test_subfzeo_ , " subfzeo.", },
1227 static void test_cntlzw (void)
1229 __asm__ __volatile__ ("cntlzw 17, 14");
1232 static void test_extsb (void)
1234 __asm__ __volatile__ ("extsb 17, 14");
1237 static void test_extsh (void)
1239 __asm__ __volatile__ ("extsh 17, 14");
1242 static void test_neg (void)
1244 __asm__ __volatile__ ("neg 17, 14");
1247 static void test_nego (void)
1249 __asm__ __volatile__ ("nego 17, 14");
1252 #ifdef __powerpc64__
1253 static void test_cntlzd (void)
1255 __asm__ __volatile__ ("cntlzd 17, 14");
1258 static void test_extsw (void)
1260 __asm__ __volatile__ ("extsw 17, 14");
1262 #endif // #ifdef __powerpc64__
1264 static test_t tests_il_ops_one[] = {
1265 { &test_cntlzw , " cntlzw", },
1266 { &test_extsb , " extsb", },
1267 { &test_extsh , " extsh", },
1268 { &test_neg , " neg", },
1269 { &test_nego , " nego", },
1270 #ifdef __powerpc64__
1271 { &test_cntlzd , " cntlzd", },
1272 { &test_extsw , " extsw", },
1273 #endif // #ifdef __powerpc64__
1277 static void test_cntlzw_ (void)
1279 __asm__ __volatile__ ("cntlzw. 17, 14");
1282 static void test_extsb_ (void)
1284 __asm__ __volatile__ ("extsb. 17, 14");
1287 static void test_extsh_ (void)
1289 __asm__ __volatile__ ("extsh. 17, 14");
1292 static void test_neg_ (void)
1294 __asm__ __volatile__ ("neg. 17, 14");
1297 static void test_nego_ (void)
1299 __asm__ __volatile__ ("nego. 17, 14");
1302 #ifdef __powerpc64__
1303 static void test_cntlzd_ (void)
1305 __asm__ __volatile__ ("cntlzd. 17, 14");
1308 static void test_extsw_ (void)
1310 __asm__ __volatile__ ("extsw. 17, 14");
1312 #endif // #ifdef __powerpc64__
1314 static test_t tests_ilr_ops_one[] = {
1315 { &test_cntlzw_ , " cntlzw.", },
1316 { &test_extsb_ , " extsb.", },
1317 { &test_extsh_ , " extsh.", },
1318 { &test_neg_ , " neg.", },
1319 { &test_nego_ , " nego.", },
1320 #ifdef __powerpc64__
1321 { &test_cntlzd_ , " cntlzd.", },
1322 { &test_extsw_ , " extsw.", },
1323 #endif // #ifdef __powerpc64__
1327 extern void test_rlwimi (void);
1328 ASSEMBLY_FUNC("test_rlwimi", "rlwimi 17, 14, 0, 0, 0");
1330 extern void test_rlwinm (void);
1331 ASSEMBLY_FUNC("test_rlwinm", "rlwinm 17, 14, 0, 0, 0");
1333 extern void test_rlwnm (void);
1334 ASSEMBLY_FUNC("test_rlwnm", "rlwnm 17, 14, 15, 0, 0");
1336 extern void test_srawi (void);
1337 ASSEMBLY_FUNC("test_srawi", "srawi 17, 14, 0");
1339 static void test_mfcr (void)
1341 __asm__ __volatile__ ("mfcr 17");
1344 static void test_mfspr (void)
1346 __asm__ __volatile__ ("mfspr 17, 1");
1349 static void test_mtspr (void)
1351 __asm__ __volatile__ ("mtspr 1, 14");
1354 #ifdef __powerpc64__
1355 extern void test_rldcl (void);
1356 ASSEMBLY_FUNC("test_rldcl", "rldcl 17, 14, 15, 0");
1358 extern void test_rldcr (void);
1359 ASSEMBLY_FUNC("test_rldcr", "rldcr 17, 14, 15, 0");
1361 extern void test_rldic (void);
1362 ASSEMBLY_FUNC("test_rldic", "rldic 17, 14, 0, 0");
1364 extern void test_rldicl (void);
1365 ASSEMBLY_FUNC("test_rldicl", "rldicl 17, 14, 0, 0");
1367 extern void test_rldicr (void);
1368 ASSEMBLY_FUNC("test_rldicr", "rldicr 17, 14, 0, 0");
1370 extern void test_rldimi (void);
1371 ASSEMBLY_FUNC("test_rldimi", "rldimi 17, 14, 0, 0");
1373 extern void test_sradi (void);
1374 ASSEMBLY_FUNC("test_sradi", "sradi 17, 14, 0");
1375 #endif // #ifdef __powerpc64__
1377 static test_t tests_il_ops_spe[] = {
1378 { &test_rlwimi , " rlwimi", },
1379 { &test_rlwinm , " rlwinm", },
1380 { &test_rlwnm , " rlwnm", },
1381 { &test_srawi , " srawi", },
1382 { &test_mfcr , " mfcr", },
1383 { &test_mfspr , " mfspr", },
1384 { &test_mtspr , " mtspr", },
1385 #ifdef __powerpc64__
1386 { &test_rldcl , " rldcl", },
1387 { &test_rldcr , " rldcr", },
1388 { &test_rldic , " rldic", },
1389 { &test_rldicl , " rldicl", },
1390 { &test_rldicr , " rldicr", },
1391 { &test_rldimi , " rldimi", },
1392 { &test_sradi , " sradi", },
1393 #endif // #ifdef __powerpc64__
1397 extern void test_rlwimi_ (void);
1398 ASSEMBLY_FUNC("test_rlwimi_", "rlwimi. 17, 14, 0, 0, 0");
1400 extern void test_rlwinm_ (void);
1401 ASSEMBLY_FUNC("test_rlwinm_", "rlwinm. 17, 14, 0, 0, 0");
1403 extern void test_rlwnm_ (void);
1404 ASSEMBLY_FUNC("test_rlwnm_", "rlwnm. 17, 14, 15, 0, 0");
1406 extern void test_srawi_ (void);
1407 ASSEMBLY_FUNC("test_srawi_", "srawi. 17, 14, 0");
1409 extern void test_mcrf (void);
1410 ASSEMBLY_FUNC("test_mcrf", "mcrf 0, 0");
1412 extern void test_mcrxr (void);
1413 ASSEMBLY_FUNC("test_mcrxr", "mcrxr 0");
1415 extern void test_mtcrf (void);
1416 ASSEMBLY_FUNC("test_mtcrf", "mtcrf 0, 14");
1418 #ifdef __powerpc64__
1419 extern void test_rldcl_ (void);
1420 ASSEMBLY_FUNC("test_rldcl_", "rldcl. 17, 14, 15, 0");
1422 extern void test_rldcr_ (void);
1423 ASSEMBLY_FUNC("test_rldcr_", "rldcr. 17, 14, 15, 0");
1425 extern void test_rldic_ (void);
1426 ASSEMBLY_FUNC("test_rldic_", "rldic. 17, 14, 0, 0");
1428 extern void test_rldicl_ (void);
1429 ASSEMBLY_FUNC("test_rldicl_", "rldicl. 17, 14, 0, 0");
1431 extern void test_rldicr_ (void);
1432 ASSEMBLY_FUNC("test_rldicr_", "rldicr. 17, 14, 0, 0");
1434 extern void test_rldimi_ (void);
1435 ASSEMBLY_FUNC("test_rldimi_", "rldimi. 17, 14, 0, 0");
1437 extern void test_sradi_ (void);
1438 ASSEMBLY_FUNC("test_sradi_", "sradi. 17, 14, 0");
1439 #endif // #ifdef __powerpc64__
1441 static test_t tests_ilr_ops_spe[] = {
1442 { &test_rlwimi_ , " rlwimi.", },
1443 { &test_rlwinm_ , " rlwinm.", },
1444 { &test_rlwnm_ , " rlwnm.", },
1445 { &test_srawi_ , " srawi.", },
1446 { &test_mcrf , " mcrf", },
1447 { &test_mcrxr , " mcrxr", },
1448 { &test_mtcrf , " mtcrf", },
1449 #ifdef __powerpc64__
1450 { &test_rldcl_ , " rldcl.", },
1451 { &test_rldcr_ , " rldcr.", },
1452 { &test_rldic_ , " rldic.", },
1453 { &test_rldicl_ , " rldicl.", },
1454 { &test_rldicr_ , " rldicr.", },
1455 { &test_rldimi_ , " rldimi.", },
1456 { &test_sradi_ , " sradi.", },
1457 #endif // #ifdef __powerpc64__
1461 extern void test_lbz (void);
1462 ASSEMBLY_FUNC("test_lbz", "lbz 17,0(14)");
1464 extern void test_lbzu (void);
1465 ASSEMBLY_FUNC("test_lbzu", "lbzu 17,0(14)");
1467 extern void test_lha (void);
1468 ASSEMBLY_FUNC("test_lha", "lha 17,0(14)");
1470 extern void test_lhau (void);
1471 ASSEMBLY_FUNC("test_lhau", "lhau 17,0(14)");
1473 extern void test_lhz (void);
1474 ASSEMBLY_FUNC("test_lhz", "lhz 17,0(14)");
1476 extern void test_lhzu (void);
1477 ASSEMBLY_FUNC("test_lhzu", "lhzu 17,0(14)");
1479 extern void test_lwz (void);
1480 ASSEMBLY_FUNC("test_lwz", "lwz 17,0(14)");
1482 extern void test_lwzu (void);
1483 ASSEMBLY_FUNC("test_lwzu", "lwzu 17,0(14)");
1485 #ifdef __powerpc64__
1486 extern void test_ld (void);
1487 ASSEMBLY_FUNC("test_ld", "ld 17,0(14)");
1489 extern void test_ldu (void);
1490 ASSEMBLY_FUNC("test_ldu", "ldu 17,0(14)");
1492 extern void test_lwa (void);
1493 ASSEMBLY_FUNC("test_lwa", "lwa 17,0(14)");
1494 #endif // #ifdef __powerpc64__
1496 static test_t tests_ild_ops_two_i16[] = {
1497 { &test_lbz , " lbz", },
1498 { &test_lbzu , " lbzu", },
1499 { &test_lha , " lha", },
1500 { &test_lhau , " lhau", },
1501 { &test_lhz , " lhz", },
1502 { &test_lhzu , " lhzu", },
1503 { &test_lwz , " lwz", },
1504 { &test_lwzu , " lwzu", },
1505 #ifdef __powerpc64__
1506 { &test_ld , " ld", },
1507 { &test_ldu , " ldu", },
1508 { &test_lwa , " lwa", },
1509 #endif // #ifdef __powerpc64__
1513 static void test_lbzx (void)
1515 __asm__ __volatile__ ("lbzx 17,14,15");
1518 static void test_lbzux (void)
1520 __asm__ __volatile__ ("lbzux 17,14,15");
1523 static void test_lhax (void)
1525 __asm__ __volatile__ ("lhax 17,14,15");
1528 static void test_lhaux (void)
1530 __asm__ __volatile__ ("lhaux 17,14,15");
1533 static void test_lhzx (void)
1535 __asm__ __volatile__ ("lhzx 17,14,15");
1538 static void test_lhzux (void)
1540 __asm__ __volatile__ ("lhzux 17,14,15");
1543 static void test_lwzx (void)
1545 __asm__ __volatile__ ("lwzx 17,14,15");
1548 static void test_lwzux (void)
1550 __asm__ __volatile__ ("lwzux 17,14,15");
1553 #ifdef __powerpc64__
1554 static void test_ldx (void)
1556 __asm__ __volatile__ ("ldx 17,14,15");
1559 static void test_ldux (void)
1561 __asm__ __volatile__ ("ldux 17,14,15");
1564 static void test_lwax (void)
1566 __asm__ __volatile__ ("lwax 17,14,15");
1569 static void test_lwaux (void)
1571 __asm__ __volatile__ ("lwaux 17,14,15");
1573 #endif // #ifdef __powerpc64__
1575 static test_t tests_ild_ops_two[] = {
1576 { &test_lbzx , " lbzx", },
1577 { &test_lbzux , " lbzux", },
1578 { &test_lhax , " lhax", },
1579 { &test_lhaux , " lhaux", },
1580 { &test_lhzx , " lhzx", },
1581 { &test_lhzux , " lhzux", },
1582 { &test_lwzx , " lwzx", },
1583 { &test_lwzux , " lwzux", },
1584 #ifdef __powerpc64__
1585 { &test_ldx , " ldx", },
1586 { &test_ldux , " ldux", },
1587 { &test_lwax , " lwax", },
1588 { &test_lwaux , " lwaux", },
1589 #endif // #ifdef __powerpc64__
1593 extern void test_stb (void);
1594 ASSEMBLY_FUNC("test_stb", "stb 14,0(15)");
1596 extern void test_stbu (void);
1597 ASSEMBLY_FUNC("test_stbu", "stbu 14,0(15)");
1599 extern void test_sth (void);
1600 ASSEMBLY_FUNC("test_sth", "sth 14,0(15)");
1602 extern void test_sthu (void);
1603 ASSEMBLY_FUNC("test_sthu", "sthu 14,0(15)");
1605 extern void test_stw (void);
1606 ASSEMBLY_FUNC("test_stw", "stw 14,0(15)");
1608 extern void test_stwu (void);
1609 ASSEMBLY_FUNC("test_stwu", "stwu 14,0(15)");
1611 #ifdef __powerpc64__
1612 extern void test_std (void);
1613 ASSEMBLY_FUNC("test_std", "std 14,0(15)");
1615 extern void test_stdu (void);
1616 ASSEMBLY_FUNC("test_stdu", "stdu 14,0(15)");
1617 #endif // #ifdef __powerpc64__
1619 static test_t tests_ist_ops_three_i16[] = {
1620 { &test_stb , " stb", },
1621 { &test_stbu , " stbu", },
1622 { &test_sth , " sth", },
1623 { &test_sthu , " sthu", },
1624 { &test_stw , " stw", },
1625 { &test_stwu , " stwu", },
1626 #ifdef __powerpc64__
1627 { &test_std , " std", },
1628 { &test_stdu , " stdu", },
1629 #endif // #ifdef __powerpc64__
1633 static void test_stbx (void)
1635 __asm__ __volatile__ ("stbx 14,15,16");
1638 static void test_stbux (void)
1640 __asm__ __volatile__ ("stbux 14,15,16");
1643 static void test_sthx (void)
1645 __asm__ __volatile__ ("sthx 14,15,16");
1648 static void test_sthux (void)
1650 __asm__ __volatile__ ("sthux 14,15,16");
1653 static void test_stwx (void)
1655 __asm__ __volatile__ ("stwx 14,15,16");
1658 static void test_stwux (void)
1660 __asm__ __volatile__ ("stwux 14,15,16");
1663 #ifdef __powerpc64__
1664 static void test_stdx (void)
1666 __asm__ __volatile__ ("stdx 14,15,16");
1669 static void test_stdux (void)
1671 __asm__ __volatile__ ("stdux 14,15,16");
1673 #endif // #ifdef __powerpc64__
1675 static test_t tests_ist_ops_three[] = {
1676 { &test_stbx , " stbx", },
1677 { &test_stbux , " stbux", },
1678 { &test_sthx , " sthx", },
1679 { &test_sthux , " sthux", },
1680 { &test_stwx , " stwx", },
1681 { &test_stwux , " stwux", },
1682 #ifdef __powerpc64__
1683 { &test_stdx , " stdx", },
1684 { &test_stdux , " stdux", },
1685 #endif // #ifdef __powerpc64__
1689 #if !defined (NO_FLOAT)
1690 static void test_fsel (void)
1692 __asm__ __volatile__ ("fsel 17, 14, 15, 16");
1695 static void test_fmadd (void)
1697 __asm__ __volatile__ ("fmadd 17, 14, 15, 16");
1700 static void test_fmadds (void)
1702 __asm__ __volatile__ ("fmadds 17, 14, 15, 16");
1705 static void test_fmsub (void)
1707 __asm__ __volatile__ ("fmsub 17, 14, 15, 16");
1710 static void test_fmsubs (void)
1712 __asm__ __volatile__ ("fmsubs 17, 14, 15, 16");
1715 static void test_fnmadd (void)
1717 __asm__ __volatile__ ("fnmadd 17, 14, 15, 16");
1720 static void test_fnmadds (void)
1722 __asm__ __volatile__ ("fnmadds 17, 14, 15, 16");
1725 static void test_fnmsub (void)
1727 __asm__ __volatile__ ("fnmsub 17, 14, 15, 16");
1730 static void test_fnmsubs (void)
1732 __asm__ __volatile__ ("fnmsubs 17, 14, 15, 16");
1735 static test_t tests_fa_ops_three[] = {
1736 { &test_fsel , " fsel", },
1737 { &test_fmadd , " fmadd", },
1738 { &test_fmadds , " fmadds", },
1739 { &test_fmsub , " fmsub", },
1740 { &test_fmsubs , " fmsubs", },
1741 { &test_fnmadd , " fnmadd", },
1742 { &test_fnmadds , " fnmadds", },
1743 { &test_fnmsub , " fnmsub", },
1744 { &test_fnmsubs , " fnmsubs", },
1747 #endif /* !defined (NO_FLOAT) */
1749 #if !defined (NO_FLOAT)
1750 static void test_fsel_ (void)
1752 __asm__ __volatile__ ("fsel. 17, 14, 15, 16");
1755 static void test_fmadd_ (void)
1757 __asm__ __volatile__ ("fmadd. 17, 14, 15, 16");
1760 static void test_fmadds_ (void)
1762 __asm__ __volatile__ ("fmadds. 17, 14, 15, 16");
1765 static void test_fmsub_ (void)
1767 __asm__ __volatile__ ("fmsub. 17, 14, 15, 16");
1770 static void test_fmsubs_ (void)
1772 __asm__ __volatile__ ("fmsubs. 17, 14, 15, 16");
1775 static void test_fnmadd_ (void)
1777 __asm__ __volatile__ ("fnmadd. 17, 14, 15, 16");
1780 static void test_fnmadds_ (void)
1782 __asm__ __volatile__ ("fnmadds. 17, 14, 15, 16");
1785 static void test_fnmsub_ (void)
1787 __asm__ __volatile__ ("fnmsub. 17, 14, 15, 16");
1790 static void test_fnmsubs_ (void)
1792 __asm__ __volatile__ ("fnmsubs. 17, 14, 15, 16");
1795 static test_t tests_far_ops_three[] = {
1796 { &test_fsel_ , " fsel.", },
1797 { &test_fmadd_ , " fmadd.", },
1798 { &test_fmadds_ , " fmadds.", },
1799 { &test_fmsub_ , " fmsub.", },
1800 { &test_fmsubs_ , " fmsubs.", },
1801 { &test_fnmadd_ , " fnmadd.", },
1802 { &test_fnmadds_ , " fnmadds.", },
1803 { &test_fnmsub_ , " fnmsub.", },
1804 { &test_fnmsubs_ , " fnmsubs.", },
1807 #endif /* !defined (NO_FLOAT) */
1809 #if !defined (NO_FLOAT)
1810 static void test_fadd (void)
1812 __asm__ __volatile__ ("fadd 17, 14, 15");
1815 static void test_fadds (void)
1817 __asm__ __volatile__ ("fadds 17, 14, 15");
1820 static void test_fsub (void)
1822 __asm__ __volatile__ ("fsub 17, 14, 15");
1825 static void test_fsubs (void)
1827 __asm__ __volatile__ ("fsubs 17, 14, 15");
1830 static void test_fmul (void)
1832 __asm__ __volatile__ ("fmul 17, 14, 15");
1835 static void test_fmuls (void)
1837 __asm__ __volatile__ ("fmuls 17, 14, 15");
1840 static void test_fdiv (void)
1842 __asm__ __volatile__ ("fdiv 17, 14, 15");
1845 static void test_fdivs (void)
1847 __asm__ __volatile__ ("fdivs 17, 14, 15");
1850 static test_t tests_fa_ops_two[] = {
1851 { &test_fadd , " fadd", },
1852 { &test_fadds , " fadds", },
1853 { &test_fsub , " fsub", },
1854 { &test_fsubs , " fsubs", },
1855 { &test_fmul , " fmul", },
1856 { &test_fmuls , " fmuls", },
1857 { &test_fdiv , " fdiv", },
1858 { &test_fdivs , " fdivs", },
1861 #endif /* !defined (NO_FLOAT) */
1863 #if !defined (NO_FLOAT)
1864 static void test_fadd_ (void)
1866 __asm__ __volatile__ ("fadd. 17, 14, 15");
1869 static void test_fadds_ (void)
1871 __asm__ __volatile__ ("fadds. 17, 14, 15");
1874 static void test_fsub_ (void)
1876 __asm__ __volatile__ ("fsub. 17, 14, 15");
1879 static void test_fsubs_ (void)
1881 __asm__ __volatile__ ("fsubs. 17, 14, 15");
1884 static void test_fmul_ (void)
1886 __asm__ __volatile__ ("fmul. 17, 14, 15");
1889 static void test_fmuls_ (void)
1891 __asm__ __volatile__ ("fmuls. 17, 14, 15");
1894 static void test_fdiv_ (void)
1896 __asm__ __volatile__ ("fdiv. 17, 14, 15");
1899 static void test_fdivs_ (void)
1901 __asm__ __volatile__ ("fdivs. 17, 14, 15");
1904 static test_t tests_far_ops_two[] = {
1905 { &test_fadd_ , " fadd.", },
1906 { &test_fadds_ , " fadds.", },
1907 { &test_fsub_ , " fsub.", },
1908 { &test_fsubs_ , " fsubs.", },
1909 { &test_fmul_ , " fmul.", },
1910 { &test_fmuls_ , " fmuls.", },
1911 { &test_fdiv_ , " fdiv.", },
1912 { &test_fdivs_ , " fdivs.", },
1915 #endif /* !defined (NO_FLOAT) */
1917 #if !defined (NO_FLOAT)
1918 static void test_fcmpo (void)
1920 __asm__ __volatile__ ("fcmpo 2, 14, 15");
1923 static void test_fcmpu (void)
1925 __asm__ __volatile__ ("fcmpu 2, 14, 15");
1928 static test_t tests_fcr_ops_two[] = {
1929 { &test_fcmpo , " fcmpo", },
1930 { &test_fcmpu , " fcmpu", },
1933 #endif /* !defined (NO_FLOAT) */
1935 #if !defined (NO_FLOAT)
1937 #if 0 // TODO: Not yet supported
1938 static void test_fres (void)
1940 __asm__ __volatile__ ("fres 17, 14");
1943 static void test_frsqrte (void)
1945 __asm__ __volatile__ ("frsqrte 17, 14");
1949 static void test_frsp (void)
1951 __asm__ __volatile__ ("frsp 17, 14");
1954 static void test_fctiw (void)
1956 __asm__ __volatile__ ("fctiw 17, 14");
1959 static void test_fctiwz (void)
1961 __asm__ __volatile__ ("fctiwz 17, 14");
1964 static void test_fmr (void)
1966 __asm__ __volatile__ ("fmr 17, 14");
1969 static void test_fneg (void)
1971 __asm__ __volatile__ ("fneg 17, 14");
1974 static void test_fabs (void)
1976 __asm__ __volatile__ ("fabs 17, 14");
1979 static void test_fnabs (void)
1981 __asm__ __volatile__ ("fnabs 17, 14");
1984 static void test_fsqrt (void)
1986 __asm__ __volatile__ ("fsqrt 17, 14");
1989 #ifdef __powerpc64__
1990 static void test_fcfid (void)
1992 __asm__ __volatile__ ("fcfid 17, 14");
1995 static void test_fctid (void)
1997 __asm__ __volatile__ ("fctid 17, 14");
2000 static void test_fctidz (void)
2002 __asm__ __volatile__ ("fctidz 17, 14");
2004 #endif // #ifdef __powerpc64__
2006 static test_t tests_fa_ops_one[] = {
2007 // { &test_fres , " fres", }, // TODO: Not yet supported
2008 // { &test_frsqrte , " frsqrte", }, // TODO: Not yet supported
2009 { &test_frsp , " frsp", },
2010 { &test_fctiw , " fctiw", },
2011 { &test_fctiwz , " fctiwz", },
2012 { &test_fmr , " fmr", },
2013 { &test_fneg , " fneg", },
2014 { &test_fabs , " fabs", },
2015 { &test_fnabs , " fnabs", },
2016 { &test_fsqrt , " fsqrt", },
2017 #ifdef __powerpc64__
2018 { &test_fcfid , " fcfid", },
2019 { &test_fctid , " fctid", },
2020 { &test_fctidz , " fctidz", },
2021 #endif // #ifdef __powerpc64__
2024 #endif /* !defined (NO_FLOAT) */
2026 #if !defined (NO_FLOAT)
2028 #if 0 // TODO: Not yet supported
2029 static void test_fres_ (void)
2031 __asm__ __volatile__ ("fres. 17, 14");
2034 static void test_frsqrte_ (void)
2036 __asm__ __volatile__ ("frsqrte. 17, 14");
2040 static void test_frsp_ (void)
2042 __asm__ __volatile__ ("frsp. 17, 14");
2045 static void test_fctiw_ (void)
2047 __asm__ __volatile__ ("fctiw. 17, 14");
2050 static void test_fctiwz_ (void)
2052 __asm__ __volatile__ ("fctiwz. 17, 14");
2055 static void test_fmr_ (void)
2057 __asm__ __volatile__ ("fmr. 17, 14");
2060 static void test_fneg_ (void)
2062 __asm__ __volatile__ ("fneg. 17, 14");
2065 static void test_fabs_ (void)
2067 __asm__ __volatile__ ("fabs. 17, 14");
2070 static void test_fnabs_ (void)
2072 __asm__ __volatile__ ("fnabs. 17, 14");
2075 #ifdef __powerpc64__
2076 static void test_fcfid_ (void)
2078 __asm__ __volatile__ ("fcfid. 17, 14");
2081 static void test_fctid_ (void)
2083 __asm__ __volatile__ ("fctid. 17, 14");
2086 static void test_fctidz_ (void)
2088 __asm__ __volatile__ ("fctidz. 17, 14");
2090 #endif // #ifdef __powerpc64__
2092 static test_t tests_far_ops_one[] = {
2093 // { &test_fres_ , " fres.", }, // TODO: Not yet supported
2094 // { &test_frsqrte_ , " frsqrte.", }, // TODO: Not yet supported
2095 { &test_frsp_ , " frsp.", },
2096 { &test_fctiw_ , " fctiw.", },
2097 { &test_fctiwz_ , " fctiwz.", },
2098 { &test_fmr_ , " fmr.", },
2099 { &test_fneg_ , " fneg.", },
2100 { &test_fabs_ , " fabs.", },
2101 { &test_fnabs_ , " fnabs.", },
2102 #ifdef __powerpc64__
2103 { &test_fcfid_ , " fcfid.", },
2104 { &test_fctid_ , " fctid.", },
2105 { &test_fctidz_ , " fctidz.", },
2106 #endif // #ifdef __powerpc64__
2109 #endif /* !defined (NO_FLOAT) */
2111 #if !defined (NO_FLOAT)
2112 static test_t tests_fl_ops_spe[] = {
2115 #endif /* !defined (NO_FLOAT) */
2117 #if !defined (NO_FLOAT)
2118 static test_t tests_flr_ops_spe[] = {
2121 #endif /* !defined (NO_FLOAT) */
2124 #if !defined (NO_FLOAT)
2125 extern void test_lfs (void);
2126 ASSEMBLY_FUNC("test_lfs", "lfs 17,0(14)");
2128 extern void test_lfsu (void);
2129 ASSEMBLY_FUNC("test_lfsu", "lfsu 17,0(14)");
2131 extern void test_lfd (void);
2132 ASSEMBLY_FUNC("test_lfd", "lfd 17,0(14)");
2134 extern void test_lfdu (void);
2135 ASSEMBLY_FUNC("test_lfdu", "lfdu 17,0(14)");
2137 static test_t tests_fld_ops_two_i16[] = {
2138 { &test_lfs , " lfs", },
2139 { &test_lfsu , " lfsu", },
2140 { &test_lfd , " lfd", },
2141 { &test_lfdu , " lfdu", },
2144 #endif /* !defined (NO_FLOAT) */
2146 #if !defined (NO_FLOAT)
2147 static void test_lfsx (void)
2149 __asm__ __volatile__ ("lfsx 17,14,15");
2152 static void test_lfsux (void)
2154 __asm__ __volatile__ ("lfsux 17,14,15");
2157 static void test_lfdx (void)
2159 __asm__ __volatile__ ("lfdx 17,14,15");
2162 static void test_lfdux (void)
2164 __asm__ __volatile__ ("lfdux 17,14,15");
2167 static test_t tests_fld_ops_two[] = {
2168 { &test_lfsx , " lfsx", },
2169 { &test_lfsux , " lfsux", },
2170 { &test_lfdx , " lfdx", },
2171 { &test_lfdux , " lfdux", },
2174 #endif /* !defined (NO_FLOAT) */
2176 #if !defined (NO_FLOAT)
2177 extern void test_stfs (void);
2178 ASSEMBLY_FUNC("test_stfs", "stfs 14,0(15)");
2180 extern void test_stfsu (void);
2181 ASSEMBLY_FUNC("test_stfsu", "stfsu 14,0(15)");
2183 extern void test_stfd (void);
2184 ASSEMBLY_FUNC("test_stfd", "stfd 14,0(15)");
2186 extern void test_stfdu (void);
2187 ASSEMBLY_FUNC("test_stfdu", "stfdu 14,0(15)");
2189 static test_t tests_fst_ops_three_i16[] = {
2190 { &test_stfs , " stfs", },
2191 { &test_stfsu , " stfsu", },
2192 { &test_stfd , " stfd", },
2193 { &test_stfdu , " stfdu", },
2196 #endif /* !defined (NO_FLOAT) */
2198 #if !defined (NO_FLOAT)
2199 static void test_stfsx (void)
2201 __asm__ __volatile__ ("stfsx 14,15,16");
2204 static void test_stfsux (void)
2206 __asm__ __volatile__ ("stfsux 14,15,16");
2209 static void test_stfdx (void)
2211 __asm__ __volatile__ ("stfdx 14,15,16");
2214 static void test_stfdux (void)
2216 __asm__ __volatile__ ("stfdux 14,15,16");
2219 static test_t tests_fst_ops_three[] = {
2220 { &test_stfsx , " stfsx", },
2221 { &test_stfsux , " stfsux", },
2222 { &test_stfdx , " stfdx", },
2223 { &test_stfdux , " stfdux", },
2226 #endif /* !defined (NO_FLOAT) */
2229 #if defined (HAS_ALTIVEC)
2230 static void test_vmhaddshs (void)
2232 __asm__ __volatile__ ("vmhaddshs 17, 14, 15, 16");
2235 static void test_vmhraddshs (void)
2237 __asm__ __volatile__ ("vmhraddshs 17, 14, 15, 16");
2240 static void test_vmladduhm (void)
2242 __asm__ __volatile__ ("vmladduhm 17, 14, 15, 16");
2245 static void test_vmsumubm (void)
2247 __asm__ __volatile__ ("vmsumubm 17, 14, 15, 16");
2250 static void test_vmsumuhm (void)
2252 __asm__ __volatile__ ("vmsumuhm 17, 14, 15, 16");
2255 static void test_vmsumshs (void)
2257 __asm__ __volatile__ ("vmsumshs 17, 14, 15, 16");
2260 static void test_vmsumuhs (void)
2262 __asm__ __volatile__ ("vmsumuhs 17, 14, 15, 16");
2265 static void test_vmsummbm (void)
2267 __asm__ __volatile__ ("vmsummbm 17, 14, 15, 16");
2270 static void test_vmsumshm (void)
2272 __asm__ __volatile__ ("vmsumshm 17, 14, 15, 16");
2275 static test_t tests_aa_ops_three[] = {
2276 { &test_vmhaddshs , " vmhaddshs", },
2277 { &test_vmhraddshs , " vmhraddshs", },
2278 { &test_vmladduhm , " vmladduhm", },
2279 { &test_vmsumubm , " vmsumubm", },
2280 { &test_vmsumuhm , " vmsumuhm", },
2281 { &test_vmsumshs , " vmsumshs", },
2282 { &test_vmsumuhs , " vmsumuhs", },
2283 { &test_vmsummbm , " vmsummbm", },
2284 { &test_vmsumshm , " vmsumshm", },
2287 #endif /* defined (HAS_ALTIVEC) */
2289 #if defined (HAS_ALTIVEC)
2290 static void test_vperm (void)
2292 __asm__ __volatile__ ("vperm 17, 14, 15, 16");
2295 static void test_vsel (void)
2297 __asm__ __volatile__ ("vsel 17, 14, 15, 16");
2300 static test_t tests_al_ops_three[] = {
2301 { &test_vperm , " vperm", },
2302 { &test_vsel , " vsel", },
2305 #endif /* defined (HAS_ALTIVEC) */
2307 #if defined (HAS_ALTIVEC)
2308 static void test_vaddubm (void)
2310 __asm__ __volatile__ ("vaddubm 17, 14, 15");
2313 static void test_vadduhm (void)
2315 __asm__ __volatile__ ("vadduhm 17, 14, 15");
2318 static void test_vadduwm (void)
2320 __asm__ __volatile__ ("vadduwm 17, 14, 15");
2323 static void test_vaddubs (void)
2325 __asm__ __volatile__ ("vaddubs 17, 14, 15");
2328 static void test_vadduhs (void)
2330 __asm__ __volatile__ ("vadduhs 17, 14, 15");
2333 static void test_vadduws (void)
2335 __asm__ __volatile__ ("vadduws 17, 14, 15");
2338 static void test_vaddsbs (void)
2340 __asm__ __volatile__ ("vaddsbs 17, 14, 15");
2343 static void test_vaddshs (void)
2345 __asm__ __volatile__ ("vaddshs 17, 14, 15");
2348 static void test_vaddsws (void)
2350 __asm__ __volatile__ ("vaddsws 17, 14, 15");
2353 static void test_vaddcuw (void)
2355 __asm__ __volatile__ ("vaddcuw 17, 14, 15");
2358 static void test_vsububm (void)
2360 __asm__ __volatile__ ("vsububm 17, 14, 15");
2363 static void test_vsubuhm (void)
2365 __asm__ __volatile__ ("vsubuhm 17, 14, 15");
2368 static void test_vsubuwm (void)
2370 __asm__ __volatile__ ("vsubuwm 17, 14, 15");
2373 static void test_vsububs (void)
2375 __asm__ __volatile__ ("vsububs 17, 14, 15");
2378 static void test_vsubuhs (void)
2380 __asm__ __volatile__ ("vsubuhs 17, 14, 15");
2383 static void test_vsubuws (void)
2385 __asm__ __volatile__ ("vsubuws 17, 14, 15");
2388 static void test_vsubsbs (void)
2390 __asm__ __volatile__ ("vsubsbs 17, 14, 15");
2393 static void test_vsubshs (void)
2395 __asm__ __volatile__ ("vsubshs 17, 14, 15");
2398 static void test_vsubsws (void)
2400 __asm__ __volatile__ ("vsubsws 17, 14, 15");
2403 static void test_vsubcuw (void)
2405 __asm__ __volatile__ ("vsubcuw 17, 14, 15");
2408 static void test_vmuloub (void)
2410 __asm__ __volatile__ ("vmuloub 17, 14, 15");
2413 static void test_vmulouh (void)
2415 __asm__ __volatile__ ("vmulouh 17, 14, 15");
2418 static void test_vmulosb (void)
2420 __asm__ __volatile__ ("vmulosb 17, 14, 15");
2423 static void test_vmulosh (void)
2425 __asm__ __volatile__ ("vmulosh 17, 14, 15");
2428 static void test_vmuleub (void)
2430 __asm__ __volatile__ ("vmuleub 17, 14, 15");
2433 static void test_vmuleuh (void)
2435 __asm__ __volatile__ ("vmuleuh 17, 14, 15");
2438 static void test_vmulesb (void)
2440 __asm__ __volatile__ ("vmulesb 17, 14, 15");
2443 static void test_vmulesh (void)
2445 __asm__ __volatile__ ("vmulesh 17, 14, 15");
2448 static void test_vsumsws (void)
2450 __asm__ __volatile__ ("vsumsws 17, 14, 15");
2453 static void test_vsum2sws (void)
2455 __asm__ __volatile__ ("vsum2sws 17, 14, 15");
2458 static void test_vsum4ubs (void)
2460 __asm__ __volatile__ ("vsum4ubs 17, 14, 15");
2463 static void test_vsum4sbs (void)
2465 __asm__ __volatile__ ("vsum4sbs 17, 14, 15");
2468 static void test_vsum4shs (void)
2470 __asm__ __volatile__ ("vsum4shs 17, 14, 15");
2473 static void test_vavgub (void)
2475 __asm__ __volatile__ ("vavgub 17, 14, 15");
2478 static void test_vavguh (void)
2480 __asm__ __volatile__ ("vavguh 17, 14, 15");
2483 static void test_vavguw (void)
2485 __asm__ __volatile__ ("vavguw 17, 14, 15");
2488 static void test_vavgsb (void)
2490 __asm__ __volatile__ ("vavgsb 17, 14, 15");
2493 static void test_vavgsh (void)
2495 __asm__ __volatile__ ("vavgsh 17, 14, 15");
2498 static void test_vavgsw (void)
2500 __asm__ __volatile__ ("vavgsw 17, 14, 15");
2503 static void test_vmaxub (void)
2505 __asm__ __volatile__ ("vmaxub 17, 14, 15");
2508 static void test_vmaxuh (void)
2510 __asm__ __volatile__ ("vmaxuh 17, 14, 15");
2513 static void test_vmaxuw (void)
2515 __asm__ __volatile__ ("vmaxuw 17, 14, 15");
2518 static void test_vmaxsb (void)
2520 __asm__ __volatile__ ("vmaxsb 17, 14, 15");
2523 static void test_vmaxsh (void)
2525 __asm__ __volatile__ ("vmaxsh 17, 14, 15");
2528 static void test_vmaxsw (void)
2530 __asm__ __volatile__ ("vmaxsw 17, 14, 15");
2533 static void test_vminub (void)
2535 __asm__ __volatile__ ("vminub 17, 14, 15");
2538 static void test_vminuh (void)
2540 __asm__ __volatile__ ("vminuh 17, 14, 15");
2543 static void test_vminuw (void)
2545 __asm__ __volatile__ ("vminuw 17, 14, 15");
2548 static void test_vminsb (void)
2550 __asm__ __volatile__ ("vminsb 17, 14, 15");
2553 static void test_vminsh (void)
2555 __asm__ __volatile__ ("vminsh 17, 14, 15");
2558 static void test_vminsw (void)
2560 __asm__ __volatile__ ("vminsw 17, 14, 15");
2563 static test_t tests_aa_ops_two[] = {
2564 { &test_vaddubm , " vaddubm", },
2565 { &test_vadduhm , " vadduhm", },
2566 { &test_vadduwm , " vadduwm", },
2567 { &test_vaddubs , " vaddubs", },
2568 { &test_vadduhs , " vadduhs", },
2569 { &test_vadduws , " vadduws", },
2570 { &test_vaddsbs , " vaddsbs", },
2571 { &test_vaddshs , " vaddshs", },
2572 { &test_vaddsws , " vaddsws", },
2573 { &test_vaddcuw , " vaddcuw", },
2574 { &test_vsububm , " vsububm", },
2575 { &test_vsubuhm , " vsubuhm", },
2576 { &test_vsubuwm , " vsubuwm", },
2577 { &test_vsububs , " vsububs", },
2578 { &test_vsubuhs , " vsubuhs", },
2579 { &test_vsubuws , " vsubuws", },
2580 { &test_vsubsbs , " vsubsbs", },
2581 { &test_vsubshs , " vsubshs", },
2582 { &test_vsubsws , " vsubsws", },
2583 { &test_vsubcuw , " vsubcuw", },
2584 { &test_vmuloub , " vmuloub", },
2585 { &test_vmulouh , " vmulouh", },
2586 { &test_vmulosb , " vmulosb", },
2587 { &test_vmulosh , " vmulosh", },
2588 { &test_vmuleub , " vmuleub", },
2589 { &test_vmuleuh , " vmuleuh", },
2590 { &test_vmulesb , " vmulesb", },
2591 { &test_vmulesh , " vmulesh", },
2592 { &test_vsumsws , " vsumsws", },
2593 { &test_vsum2sws , " vsum2sws", },
2594 { &test_vsum4ubs , " vsum4ubs", },
2595 { &test_vsum4sbs , " vsum4sbs", },
2596 { &test_vsum4shs , " vsum4shs", },
2597 { &test_vavgub , " vavgub", },
2598 { &test_vavguh , " vavguh", },
2599 { &test_vavguw , " vavguw", },
2600 { &test_vavgsb , " vavgsb", },
2601 { &test_vavgsh , " vavgsh", },
2602 { &test_vavgsw , " vavgsw", },
2603 { &test_vmaxub , " vmaxub", },
2604 { &test_vmaxuh , " vmaxuh", },
2605 { &test_vmaxuw , " vmaxuw", },
2606 { &test_vmaxsb , " vmaxsb", },
2607 { &test_vmaxsh , " vmaxsh", },
2608 { &test_vmaxsw , " vmaxsw", },
2609 { &test_vminub , " vminub", },
2610 { &test_vminuh , " vminuh", },
2611 { &test_vminuw , " vminuw", },
2612 { &test_vminsb , " vminsb", },
2613 { &test_vminsh , " vminsh", },
2614 { &test_vminsw , " vminsw", },
2617 #endif /* defined (HAS_ALTIVEC) */
2619 #if defined (HAS_ALTIVEC)
2620 static void test_vand (void)
2622 __asm__ __volatile__ ("vand 17, 14, 15");
2625 static void test_vor (void)
2627 __asm__ __volatile__ ("vor 17, 14, 15");
2630 static void test_vxor (void)
2632 __asm__ __volatile__ ("vxor 17, 14, 15");
2635 static void test_vandc (void)
2637 __asm__ __volatile__ ("vandc 17, 14, 15");
2640 static void test_vnor (void)
2642 __asm__ __volatile__ ("vnor 17, 14, 15");
2645 static void test_vrlb (void)
2647 __asm__ __volatile__ ("vrlb 17, 14, 15");
2650 static void test_vrlh (void)
2652 __asm__ __volatile__ ("vrlh 17, 14, 15");
2655 static void test_vrlw (void)
2657 __asm__ __volatile__ ("vrlw 17, 14, 15");
2660 static void test_vslb (void)
2662 __asm__ __volatile__ ("vslb 17, 14, 15");
2665 static void test_vslh (void)
2667 __asm__ __volatile__ ("vslh 17, 14, 15");
2670 static void test_vslw (void)
2672 __asm__ __volatile__ ("vslw 17, 14, 15");
2675 static void test_vsrb (void)
2677 __asm__ __volatile__ ("vsrb 17, 14, 15");
2680 static void test_vsrh (void)
2682 __asm__ __volatile__ ("vsrh 17, 14, 15");
2685 static void test_vsrw (void)
2687 __asm__ __volatile__ ("vsrw 17, 14, 15");
2690 static void test_vsrab (void)
2692 __asm__ __volatile__ ("vsrab 17, 14, 15");
2695 static void test_vsrah (void)
2697 __asm__ __volatile__ ("vsrah 17, 14, 15");
2700 static void test_vsraw (void)
2702 __asm__ __volatile__ ("vsraw 17, 14, 15");
2705 static void test_vpkuhum (void)
2707 __asm__ __volatile__ ("vpkuhum 17, 14, 15");
2710 static void test_vpkuwum (void)
2712 __asm__ __volatile__ ("vpkuwum 17, 14, 15");
2715 static void test_vpkuhus (void)
2717 __asm__ __volatile__ ("vpkuhus 17, 14, 15");
2720 static void test_vpkuwus (void)
2722 __asm__ __volatile__ ("vpkuwus 17, 14, 15");
2725 static void test_vpkshus (void)
2727 __asm__ __volatile__ ("vpkshus 17, 14, 15");
2730 static void test_vpkswus (void)
2732 __asm__ __volatile__ ("vpkswus 17, 14, 15");
2735 static void test_vpkshss (void)
2737 __asm__ __volatile__ ("vpkshss 17, 14, 15");
2740 static void test_vpkswss (void)
2742 __asm__ __volatile__ ("vpkswss 17, 14, 15");
2745 static void test_vpkpx (void)
2747 __asm__ __volatile__ ("vpkpx 17, 14, 15");
2750 static void test_vmrghb (void)
2752 __asm__ __volatile__ ("vmrghb 17, 14, 15");
2755 static void test_vmrghh (void)
2757 __asm__ __volatile__ ("vmrghh 17, 14, 15");
2760 static void test_vmrghw (void)
2762 __asm__ __volatile__ ("vmrghw 17, 14, 15");
2765 static void test_vmrglb (void)
2767 __asm__ __volatile__ ("vmrglb 17, 14, 15");
2770 static void test_vmrglh (void)
2772 __asm__ __volatile__ ("vmrglh 17, 14, 15");
2775 static void test_vmrglw (void)
2777 __asm__ __volatile__ ("vmrglw 17, 14, 15");
2780 static void test_vslo (void)
2782 __asm__ __volatile__ ("vslo 17, 14, 15");
2785 static void test_vsro (void)
2787 __asm__ __volatile__ ("vsro 17, 14, 15");
2790 static test_t tests_al_ops_two[] = {
2791 { &test_vand , " vand", },
2792 { &test_vor , " vor", },
2793 { &test_vxor , " vxor", },
2794 { &test_vandc , " vandc", },
2795 { &test_vnor , " vnor", },
2796 { &test_vrlb , " vrlb", },
2797 { &test_vrlh , " vrlh", },
2798 { &test_vrlw , " vrlw", },
2799 { &test_vslb , " vslb", },
2800 { &test_vslh , " vslh", },
2801 { &test_vslw , " vslw", },
2802 { &test_vsrb , " vsrb", },
2803 { &test_vsrh , " vsrh", },
2804 { &test_vsrw , " vsrw", },
2805 { &test_vsrab , " vsrab", },
2806 { &test_vsrah , " vsrah", },
2807 { &test_vsraw , " vsraw", },
2808 { &test_vpkuhum , " vpkuhum", },
2809 { &test_vpkuwum , " vpkuwum", },
2810 { &test_vpkuhus , " vpkuhus", },
2811 { &test_vpkuwus , " vpkuwus", },
2812 { &test_vpkshus , " vpkshus", },
2813 { &test_vpkswus , " vpkswus", },
2814 { &test_vpkshss , " vpkshss", },
2815 { &test_vpkswss , " vpkswss", },
2816 { &test_vpkpx , " vpkpx", },
2817 { &test_vmrghb , " vmrghb", },
2818 { &test_vmrghh , " vmrghh", },
2819 { &test_vmrghw , " vmrghw", },
2820 { &test_vmrglb , " vmrglb", },
2821 { &test_vmrglh , " vmrglh", },
2822 { &test_vmrglw , " vmrglw", },
2823 { &test_vslo , " vslo", },
2824 { &test_vsro , " vsro", },
2827 #endif /* defined (HAS_ALTIVEC) */
2829 #if defined (HAS_ALTIVEC)
2830 static void test_vupkhsb (void)
2832 __asm__ __volatile__ ("vupkhsb 17, 14");
2835 static void test_vupkhsh (void)
2837 __asm__ __volatile__ ("vupkhsh 17, 14");
2840 static void test_vupkhpx (void)
2842 __asm__ __volatile__ ("vupkhpx 17, 14");
2845 static void test_vupklsb (void)
2847 __asm__ __volatile__ ("vupklsb 17, 14");
2850 static void test_vupklsh (void)
2852 __asm__ __volatile__ ("vupklsh 17, 14");
2855 static void test_vupklpx (void)
2857 __asm__ __volatile__ ("vupklpx 17, 14");
2860 static test_t tests_al_ops_one[] = {
2861 { &test_vupkhsb , " vupkhsb", },
2862 { &test_vupkhsh , " vupkhsh", },
2863 { &test_vupkhpx , " vupkhpx", },
2864 { &test_vupklsb , " vupklsb", },
2865 { &test_vupklsh , " vupklsh", },
2866 { &test_vupklpx , " vupklpx", },
2869 #endif /* defined (HAS_ALTIVEC) */
2871 #if defined (HAS_ALTIVEC)
2872 static void test_vcmpgtub (void)
2874 __asm__ __volatile__ ("vcmpgtub 17, 14, 15");
2877 static void test_vcmpgtuh (void)
2879 __asm__ __volatile__ ("vcmpgtuh 17, 14, 15");
2882 static void test_vcmpgtuw (void)
2884 __asm__ __volatile__ ("vcmpgtuw 17, 14, 15");
2887 static void test_vcmpgtsb (void)
2889 __asm__ __volatile__ ("vcmpgtsb 17, 14, 15");
2892 static void test_vcmpgtsh (void)
2894 __asm__ __volatile__ ("vcmpgtsh 17, 14, 15");
2897 static void test_vcmpgtsw (void)
2899 __asm__ __volatile__ ("vcmpgtsw 17, 14, 15");
2902 static void test_vcmpequb (void)
2904 __asm__ __volatile__ ("vcmpequb 17, 14, 15");
2907 static void test_vcmpequh (void)
2909 __asm__ __volatile__ ("vcmpequh 17, 14, 15");
2912 static void test_vcmpequw (void)
2914 __asm__ __volatile__ ("vcmpequw 17, 14, 15");
2917 static test_t tests_ac_ops_two[] = {
2918 { &test_vcmpgtub , " vcmpgtub", },
2919 { &test_vcmpgtuh , " vcmpgtuh", },
2920 { &test_vcmpgtuw , " vcmpgtuw", },
2921 { &test_vcmpgtsb , " vcmpgtsb", },
2922 { &test_vcmpgtsh , " vcmpgtsh", },
2923 { &test_vcmpgtsw , " vcmpgtsw", },
2924 { &test_vcmpequb , " vcmpequb", },
2925 { &test_vcmpequh , " vcmpequh", },
2926 { &test_vcmpequw , " vcmpequw", },
2929 #endif /* defined (HAS_ALTIVEC) */
2931 #if defined (HAS_ALTIVEC)
2932 static void test_vcmpgtub_ (void)
2934 __asm__ __volatile__ ("vcmpgtub. 17, 14, 15");
2937 static void test_vcmpgtuh_ (void)
2939 __asm__ __volatile__ ("vcmpgtuh. 17, 14, 15");
2942 static void test_vcmpgtuw_ (void)
2944 __asm__ __volatile__ ("vcmpgtuw. 17, 14, 15");
2947 static void test_vcmpgtsb_ (void)
2949 __asm__ __volatile__ ("vcmpgtsb. 17, 14, 15");
2952 static void test_vcmpgtsh_ (void)
2954 __asm__ __volatile__ ("vcmpgtsh. 17, 14, 15");
2957 static void test_vcmpgtsw_ (void)
2959 __asm__ __volatile__ ("vcmpgtsw. 17, 14, 15");
2962 static void test_vcmpequb_ (void)
2964 __asm__ __volatile__ ("vcmpequb. 17, 14, 15");
2967 static void test_vcmpequh_ (void)
2969 __asm__ __volatile__ ("vcmpequh. 17, 14, 15");
2972 static void test_vcmpequw_ (void)
2974 __asm__ __volatile__ ("vcmpequw. 17, 14, 15");
2977 static test_t tests_acr_ops_two[] = {
2978 { &test_vcmpgtub_ , " vcmpgtub.", },
2979 { &test_vcmpgtuh_ , " vcmpgtuh.", },
2980 { &test_vcmpgtuw_ , " vcmpgtuw.", },
2981 { &test_vcmpgtsb_ , " vcmpgtsb.", },
2982 { &test_vcmpgtsh_ , " vcmpgtsh.", },
2983 { &test_vcmpgtsw_ , " vcmpgtsw.", },
2984 { &test_vcmpequb_ , " vcmpequb.", },
2985 { &test_vcmpequh_ , " vcmpequh.", },
2986 { &test_vcmpequw_ , " vcmpequw.", },
2989 #endif /* defined (HAS_ALTIVEC) */
2991 #if defined (HAS_ALTIVEC)
2992 static void test_vsl (void)
2994 __asm__ __volatile__ ("vsl 17, 14, 15");
2997 static void test_vsr (void)
2999 __asm__ __volatile__ ("vsr 17, 14, 15");
3002 extern void test_vspltb (void);
3003 ASSEMBLY_FUNC("test_vspltb", "vspltb 17, 14, 0");
3005 extern void test_vsplth (void);
3006 ASSEMBLY_FUNC("test_vsplth", "vsplth 17, 14, 0");
3008 extern void test_vspltw (void);
3009 ASSEMBLY_FUNC("test_vspltw", "vspltw 17, 14, 0");
3011 extern void test_vspltisb (void);
3012 ASSEMBLY_FUNC("test_vspltisb", "vspltisb 17, 0");
3014 extern void test_vspltish (void);
3015 ASSEMBLY_FUNC("test_vspltish", "vspltish 17, 0");
3017 extern void test_vspltisw (void);
3018 ASSEMBLY_FUNC("test_vspltisw", "vspltisw 17, 0");
3020 extern void test_vsldoi (void);
3021 ASSEMBLY_FUNC("test_vsldoi", "vsldoi 17, 14, 15, 0");
3023 static void test_lvsl (void)
3025 __asm__ __volatile__ ("lvsl 17, 14, 15");
3028 static void test_lvsr (void)
3030 __asm__ __volatile__ ("lvsr 17, 14, 15");
3033 static test_t tests_av_int_ops_spe[] = {
3034 { &test_vsl , " vsl", },
3035 { &test_vsr , " vsr", },
3036 { &test_vspltb , " vspltb", },
3037 { &test_vsplth , " vsplth", },
3038 { &test_vspltw , " vspltw", },
3039 { &test_vspltisb , " vspltisb", },
3040 { &test_vspltish , " vspltish", },
3041 { &test_vspltisw , " vspltisw", },
3042 { &test_vsldoi , " vsldoi", },
3043 { &test_lvsl , " lvsl", },
3044 { &test_lvsr , " lvsr", },
3047 #endif /* defined (HAS_ALTIVEC) */
3049 #if defined (HAS_ALTIVEC)
3050 static void test_lvebx (void)
3052 __asm__ __volatile__ ("lvebx 17,14,15");
3055 static void test_lvehx (void)
3057 __asm__ __volatile__ ("lvehx 17,14,15");
3060 static void test_lvewx (void)
3062 __asm__ __volatile__ ("lvewx 17,14,15");
3065 static void test_lvx (void)
3067 __asm__ __volatile__ ("lvx 17,14,15");
3070 static void test_lvxl (void)
3072 __asm__ __volatile__ ("lvxl 17,14,15");
3075 static test_t tests_ald_ops_two[] = {
3076 { &test_lvebx , " lvebx", },
3077 { &test_lvehx , " lvehx", },
3078 { &test_lvewx , " lvewx", },
3079 { &test_lvx , " lvx", },
3080 { &test_lvxl , " lvxl", },
3083 #endif /* defined (HAS_ALTIVEC) */
3085 #if defined (HAS_ALTIVEC)
3086 static void test_stvebx (void)
3088 __asm__ __volatile__ ("stvebx 14,15,16");
3091 static void test_stvehx (void)
3093 __asm__ __volatile__ ("stvehx 14,15,16");
3096 static void test_stvewx (void)
3098 __asm__ __volatile__ ("stvewx 14,15,16");
3101 static void test_stvx (void)
3103 __asm__ __volatile__ ("stvx 14,15,16");
3106 static void test_stvxl (void)
3108 __asm__ __volatile__ ("stvxl 14,15,16");
3111 static test_t tests_ast_ops_three[] = {
3112 { &test_stvebx , " stvebx", },
3113 { &test_stvehx , " stvehx", },
3114 { &test_stvewx , " stvewx", },
3115 { &test_stvx , " stvx", },
3116 { &test_stvxl , " stvxl", },
3119 #endif /* defined (HAS_ALTIVEC) */
3121 #if defined (HAS_ALTIVEC)
3123 static void test_vmaddfp (void)
3125 __asm__ __volatile__ ("vmaddfp 17, 14, 15, 16");
3128 static void test_vnmsubfp (void)
3130 __asm__ __volatile__ ("vnmsubfp 17, 14, 15, 16");
3134 static test_t tests_afa_ops_three[] = {
3135 // { &test_vmaddfp , " vmaddfp", }, // TODO: Not yet supported
3136 // { &test_vnmsubfp , " vnmsubfp", }, // TODO: Not yet supported
3139 #endif /* defined (HAS_ALTIVEC) */
3141 #if defined (HAS_ALTIVEC)
3142 static void test_vaddfp (void)
3144 __asm__ __volatile__ ("vaddfp 17, 14, 15");
3147 static void test_vsubfp (void)
3149 __asm__ __volatile__ ("vsubfp 17, 14, 15");
3152 static void test_vmaxfp (void)
3154 __asm__ __volatile__ ("vmaxfp 17, 14, 15");
3157 static void test_vminfp (void)
3159 __asm__ __volatile__ ("vminfp 17, 14, 15");
3162 static test_t tests_afa_ops_two[] = {
3163 { &test_vaddfp , " vaddfp", },
3164 { &test_vsubfp , " vsubfp", },
3165 { &test_vmaxfp , " vmaxfp", },
3166 { &test_vminfp , " vminfp", },
3169 #endif /* defined (HAS_ALTIVEC) */
3171 #if defined (HAS_ALTIVEC)
3172 static void test_vrfin (void)
3174 __asm__ __volatile__ ("vrfin 17, 14");
3177 static void test_vrfiz (void)
3179 __asm__ __volatile__ ("vrfiz 17, 14");
3182 static void test_vrfip (void)
3184 __asm__ __volatile__ ("vrfip 17, 14");
3187 static void test_vrfim (void)
3189 __asm__ __volatile__ ("vrfim 17, 14");
3192 static void test_vrefp (void)
3194 __asm__ __volatile__ ("vrefp 17, 14");
3197 static void test_vrsqrtefp (void)
3199 __asm__ __volatile__ ("vrsqrtefp 17, 14");
3202 #if 0 // TODO: Not yet supported
3203 static void test_vlogefp (void)
3205 __asm__ __volatile__ ("vlogefp 17, 14");
3208 static void test_vexptefp (void)
3210 __asm__ __volatile__ ("vexptefp 17, 14");
3214 static test_t tests_afa_ops_one[] = {
3215 { &test_vrfin , " vrfin", },
3216 { &test_vrfiz , " vrfiz", },
3217 { &test_vrfip , " vrfip", },
3218 { &test_vrfim , " vrfim", },
3219 { &test_vrefp , " vrefp", },
3220 { &test_vrsqrtefp , " vrsqrtefp", },
3221 // { &test_vlogefp , " vlogefp", }, // TODO: Not yet supported
3222 // { &test_vexptefp , " vexptefp", }, // TODO: Not yet supported
3225 #endif /* defined (HAS_ALTIVEC) */
3227 #if defined (HAS_ALTIVEC)
3228 static void test_vcmpgtfp (void)
3230 __asm__ __volatile__ ("vcmpgtfp 17, 14, 15");
3233 static void test_vcmpeqfp (void)
3235 __asm__ __volatile__ ("vcmpeqfp 17, 14, 15");
3238 static void test_vcmpgefp (void)
3240 __asm__ __volatile__ ("vcmpgefp 17, 14, 15");
3243 static void test_vcmpbfp (void)
3245 __asm__ __volatile__ ("vcmpbfp 17, 14, 15");
3248 static test_t tests_afc_ops_two[] = {
3249 { &test_vcmpgtfp , " vcmpgtfp", },
3250 { &test_vcmpeqfp , " vcmpeqfp", },
3251 { &test_vcmpgefp , " vcmpgefp", },
3252 { &test_vcmpbfp , " vcmpbfp", },
3255 #endif /* defined (HAS_ALTIVEC) */
3257 #if defined (HAS_ALTIVEC)
3258 static void test_vcmpgtfp_ (void)
3260 __asm__ __volatile__ ("vcmpgtfp. 17, 14, 15");
3263 static void test_vcmpeqfp_ (void)
3265 __asm__ __volatile__ ("vcmpeqfp. 17, 14, 15");
3268 static void test_vcmpgefp_ (void)
3270 __asm__ __volatile__ ("vcmpgefp. 17, 14, 15");
3273 static void test_vcmpbfp_ (void)
3275 __asm__ __volatile__ ("vcmpbfp. 17, 14, 15");
3278 static test_t tests_afcr_ops_two[] = {
3279 { &test_vcmpgtfp_ , " vcmpgtfp.", },
3280 { &test_vcmpeqfp_ , " vcmpeqfp.", },
3281 { &test_vcmpgefp_ , " vcmpgefp.", },
3282 { &test_vcmpbfp_ , " vcmpbfp.", },
3285 #endif /* defined (HAS_ALTIVEC) */
3287 #if defined (HAS_ALTIVEC)
3288 extern void test_vcfux (void);
3289 ASSEMBLY_FUNC("test_vcfux", "vcfux 17, 14, 0");
3291 extern void test_vcfsx (void);
3292 ASSEMBLY_FUNC("test_vcfsx", "vcfsx 17, 14, 0");
3294 extern void test_vctuxs (void);
3295 ASSEMBLY_FUNC("test_vctuxs", "vctuxs 17, 14, 0");
3297 extern void test_vctsxs (void);
3298 ASSEMBLY_FUNC("test_vctsxs", "vctsxs 17, 14, 0");
3300 static test_t tests_av_float_ops_spe[] = {
3301 { &test_vcfux , " vcfux", },
3302 { &test_vcfsx , " vcfsx", },
3303 { &test_vctuxs , " vctuxs", },
3304 { &test_vctsxs , " vctsxs", },
3307 #endif /* defined (HAS_ALTIVEC) */
3309 #if defined (IS_PPC405)
3310 static void test_macchw (void)
3312 __asm__ __volatile__ ("macchw 17, 14, 15");
3315 static void test_macchwo (void)
3317 __asm__ __volatile__ ("macchwo 17, 14, 15");
3320 static void test_macchws (void)
3322 __asm__ __volatile__ ("macchws 17, 14, 15");
3325 static void test_macchwso (void)
3327 __asm__ __volatile__ ("macchwso 17, 14, 15");
3330 static void test_macchwsu (void)
3332 __asm__ __volatile__ ("macchwsu 17, 14, 15");
3335 static void test_macchwsuo (void)
3337 __asm__ __volatile__ ("macchwsuo 17, 14, 15");
3340 static void test_macchwu (void)
3342 __asm__ __volatile__ ("macchwu 17, 14, 15");
3345 static void test_macchwuo (void)
3347 __asm__ __volatile__ ("macchwuo 17, 14, 15");
3350 static void test_machhw (void)
3352 __asm__ __volatile__ ("machhw 17, 14, 15");
3355 static void test_machhwo (void)
3357 __asm__ __volatile__ ("machhwo 17, 14, 15");
3360 static void test_machhws (void)
3362 __asm__ __volatile__ ("machhws 17, 14, 15");
3365 static void test_machhwso (void)
3367 __asm__ __volatile__ ("machhwso 17, 14, 15");
3370 static void test_machhwsu (void)
3372 __asm__ __volatile__ ("machhwsu 17, 14, 15");
3375 static void test_machhwsuo (void)
3377 __asm__ __volatile__ ("machhwsuo 17, 14, 15");
3380 static void test_machhwu (void)
3382 __asm__ __volatile__ ("machhwu 17, 14, 15");
3385 static void test_machhwuo (void)
3387 __asm__ __volatile__ ("machhwuo 17, 14, 15");
3390 static void test_maclhw (void)
3392 __asm__ __volatile__ ("maclhw 17, 14, 15");
3395 static void test_maclhwo (void)
3397 __asm__ __volatile__ ("maclhwo 17, 14, 15");
3400 static void test_maclhws (void)
3402 __asm__ __volatile__ ("maclhws 17, 14, 15");
3405 static void test_maclhwso (void)
3407 __asm__ __volatile__ ("maclhwso 17, 14, 15");
3410 static void test_maclhwsu (void)
3412 __asm__ __volatile__ ("maclhwsu 17, 14, 15");
3415 static void test_maclhwsuo (void)
3417 __asm__ __volatile__ ("maclhwsuo 17, 14, 15");
3420 static void test_maclhwu (void)
3422 __asm__ __volatile__ ("maclhwu 17, 14, 15");
3425 static void test_maclhwuo (void)
3427 __asm__ __volatile__ ("maclhwuo 17, 14, 15");
3430 static void test_mulchw (void)
3432 __asm__ __volatile__ ("mulchw 17, 14, 15");
3435 static void test_mulchwu (void)
3437 __asm__ __volatile__ ("mulchwu 17, 14, 15");
3440 static void test_mulhhw (void)
3442 __asm__ __volatile__ ("mulhhw 17, 14, 15");
3445 static void test_mulhhwu (void)
3447 __asm__ __volatile__ ("mulhhwu 17, 14, 15");
3450 static void test_mullhw (void)
3452 __asm__ __volatile__ ("mullhw 17, 14, 15");
3455 static void test_mullhwu (void)
3457 __asm__ __volatile__ ("mullhwu 17, 14, 15");
3460 static void test_nmacchw (void)
3462 __asm__ __volatile__ ("nmacchw 17, 14, 15");
3465 static void test_nmacchwo (void)
3467 __asm__ __volatile__ ("nmacchwo 17, 14, 15");
3470 static void test_nmacchws (void)
3472 __asm__ __volatile__ ("nmacchws 17, 14, 15");
3475 static void test_nmacchwso (void)
3477 __asm__ __volatile__ ("nmacchwso 17, 14, 15");
3480 static void test_nmachhw (void)
3482 __asm__ __volatile__ ("nmachhw 17, 14, 15");
3485 static void test_nmachhwo (void)
3487 __asm__ __volatile__ ("nmachhwo 17, 14, 15");
3490 static void test_nmachhws (void)
3492 __asm__ __volatile__ ("nmachhws 17, 14, 15");
3495 static void test_nmachhwso (void)
3497 __asm__ __volatile__ ("nmachhwso 17, 14, 15");
3500 static void test_nmaclhw (void)
3502 __asm__ __volatile__ ("nmaclhw 17, 14, 15");
3505 static void test_nmaclhwo (void)
3507 __asm__ __volatile__ ("nmaclhwo 17, 14, 15");
3510 static void test_nmaclhws (void)
3512 __asm__ __volatile__ ("nmaclhws 17, 14, 15");
3515 static void test_nmaclhwso (void)
3517 __asm__ __volatile__ ("nmaclhwso 17, 14, 15");
3520 static test_t tests_p4m_ops_two[] = {
3521 { &test_macchw , " macchw", },
3522 { &test_macchwo , " macchwo", },
3523 { &test_macchws , " macchws", },
3524 { &test_macchwso , " macchwso", },
3525 { &test_macchwsu , " macchwsu", },
3526 { &test_macchwsuo , " macchwsuo", },
3527 { &test_macchwu , " macchwu", },
3528 { &test_macchwuo , " macchwuo", },
3529 { &test_machhw , " machhw", },
3530 { &test_machhwo , " machhwo", },
3531 { &test_machhws , " machhws", },
3532 { &test_machhwso , " machhwso", },
3533 { &test_machhwsu , " machhwsu", },
3534 { &test_machhwsuo , " machhwsuo", },
3535 { &test_machhwu , " machhwu", },
3536 { &test_machhwuo , " machhwuo", },
3537 { &test_maclhw , " maclhw", },
3538 { &test_maclhwo , " maclhwo", },
3539 { &test_maclhws , " maclhws", },
3540 { &test_maclhwso , " maclhwso", },
3541 { &test_maclhwsu , " maclhwsu", },
3542 { &test_maclhwsuo , " maclhwsuo", },
3543 { &test_maclhwu , " maclhwu", },
3544 { &test_maclhwuo , " maclhwuo", },
3545 { &test_mulchw , " mulchw", },
3546 { &test_mulchwu , " mulchwu", },
3547 { &test_mulhhw , " mulhhw", },
3548 { &test_mulhhwu , " mulhhwu", },
3549 { &test_mullhw , " mullhw", },
3550 { &test_mullhwu , " mullhwu", },
3551 { &test_nmacchw , " nmacchw", },
3552 { &test_nmacchwo , " nmacchwo", },
3553 { &test_nmacchws , " nmacchws", },
3554 { &test_nmacchwso , " nmacchwso", },
3555 { &test_nmachhw , " nmachhw", },
3556 { &test_nmachhwo , " nmachhwo", },
3557 { &test_nmachhws , " nmachhws", },
3558 { &test_nmachhwso , " nmachhwso", },
3559 { &test_nmaclhw , " nmaclhw", },
3560 { &test_nmaclhwo , " nmaclhwo", },
3561 { &test_nmaclhws , " nmaclhws", },
3562 { &test_nmaclhwso , " nmaclhwso", },
3565 #endif /* defined (IS_PPC405) */
3567 #if defined (IS_PPC405)
3568 static void test_macchw_ (void)
3570 __asm__ __volatile__ ("macchw. 17, 14, 15");
3573 static void test_macchwo_ (void)
3575 __asm__ __volatile__ ("macchwo. 17, 14, 15");
3578 static void test_macchws_ (void)
3580 __asm__ __volatile__ ("macchws. 17, 14, 15");
3583 static void test_macchwso_ (void)
3585 __asm__ __volatile__ ("macchwso. 17, 14, 15");
3588 static void test_macchwsu_ (void)
3590 __asm__ __volatile__ ("macchwsu. 17, 14, 15");
3593 static void test_macchwsuo_ (void)
3595 __asm__ __volatile__ ("macchwsuo. 17, 14, 15");
3598 static void test_macchwu_ (void)
3600 __asm__ __volatile__ ("macchwu. 17, 14, 15");
3603 static void test_macchwuo_ (void)
3605 __asm__ __volatile__ ("macchwuo. 17, 14, 15");
3608 static void test_machhw_ (void)
3610 __asm__ __volatile__ ("machhw. 17, 14, 15");
3613 static void test_machhwo_ (void)
3615 __asm__ __volatile__ ("machhwo. 17, 14, 15");
3618 static void test_machhws_ (void)
3620 __asm__ __volatile__ ("machhws. 17, 14, 15");
3623 static void test_machhwso_ (void)
3625 __asm__ __volatile__ ("machhwso. 17, 14, 15");
3628 static void test_machhwsu_ (void)
3630 __asm__ __volatile__ ("machhwsu. 17, 14, 15");
3633 static void test_machhwsuo_ (void)
3635 __asm__ __volatile__ ("machhwsuo. 17, 14, 15");
3638 static void test_machhwu_ (void)
3640 __asm__ __volatile__ ("machhwu. 17, 14, 15");
3643 static void test_machhwuo_ (void)
3645 __asm__ __volatile__ ("machhwuo. 17, 14, 15");
3648 static void test_maclhw_ (void)
3650 __asm__ __volatile__ ("maclhw. 17, 14, 15");
3653 static void test_maclhwo_ (void)
3655 __asm__ __volatile__ ("maclhwo. 17, 14, 15");
3658 static void test_maclhws_ (void)
3660 __asm__ __volatile__ ("maclhws. 17, 14, 15");
3663 static void test_maclhwso_ (void)
3665 __asm__ __volatile__ ("maclhwso. 17, 14, 15");
3668 static void test_maclhwsu_ (void)
3670 __asm__ __volatile__ ("maclhwsu. 17, 14, 15");
3673 static void test_maclhwsuo_ (void)
3675 __asm__ __volatile__ ("maclhwsuo. 17, 14, 15");
3678 static void test_maclhwu_ (void)
3680 __asm__ __volatile__ ("maclhwu. 17, 14, 15");
3683 static void test_maclhwuo_ (void)
3685 __asm__ __volatile__ ("maclhwuo. 17, 14, 15");
3688 static void test_mulchw_ (void)
3690 __asm__ __volatile__ ("mulchw. 17, 14, 15");
3693 static void test_mulchwu_ (void)
3695 __asm__ __volatile__ ("mulchwu. 17, 14, 15");
3698 static void test_mulhhw_ (void)
3700 __asm__ __volatile__ ("mulhhw. 17, 14, 15");
3703 static void test_mulhhwu_ (void)
3705 __asm__ __volatile__ ("mulhhwu. 17, 14, 15");
3708 static void test_mullhw_ (void)
3710 __asm__ __volatile__ ("mullhw. 17, 14, 15");
3713 static void test_mullhwu_ (void)
3715 __asm__ __volatile__ ("mullhwu. 17, 14, 15");
3718 static void test_nmacchw_ (void)
3720 __asm__ __volatile__ ("nmacchw. 17, 14, 15");
3723 static void test_nmacchwo_ (void)
3725 __asm__ __volatile__ ("nmacchwo. 17, 14, 15");
3728 static void test_nmacchws_ (void)
3730 __asm__ __volatile__ ("nmacchws. 17, 14, 15");
3733 static void test_nmacchwso_ (void)
3735 __asm__ __volatile__ ("nmacchwso. 17, 14, 15");
3738 static void test_nmachhw_ (void)
3740 __asm__ __volatile__ ("nmachhw. 17, 14, 15");
3743 static void test_nmachhwo_ (void)
3745 __asm__ __volatile__ ("nmachhwo. 17, 14, 15");
3748 static void test_nmachhws_ (void)
3750 __asm__ __volatile__ ("nmachhws. 17, 14, 15");
3753 static void test_nmachhwso_ (void)
3755 __asm__ __volatile__ ("nmachhwso. 17, 14, 15");
3758 static void test_nmaclhw_ (void)
3760 __asm__ __volatile__ ("nmaclhw. 17, 14, 15");
3763 static void test_nmaclhwo_ (void)
3765 __asm__ __volatile__ ("nmaclhwo. 17, 14, 15");
3768 static void test_nmaclhws_ (void)
3770 __asm__ __volatile__ ("nmaclhws. 17, 14, 15");
3773 static void test_nmaclhwso_ (void)
3775 __asm__ __volatile__ ("nmaclhwso. 17, 14, 15");
3778 static test_t tests_p4mc_ops_two[] = {
3779 { &test_macchw_ , " macchw.", },
3780 { &test_macchwo_ , " macchwo.", },
3781 { &test_macchws_ , " macchws.", },
3782 { &test_macchwso_ , " macchwso.", },
3783 { &test_macchwsu_ , " macchwsu.", },
3784 { &test_macchwsuo_ , " macchwsuo.", },
3785 { &test_macchwu_ , " macchwu.", },
3786 { &test_macchwuo_ , " macchwuo.", },
3787 { &test_machhw_ , " machhw.", },
3788 { &test_machhwo_ , " machhwo.", },
3789 { &test_machhws_ , " machhws.", },
3790 { &test_machhwso_ , " machhwso.", },
3791 { &test_machhwsu_ , " machhwsu.", },
3792 { &test_machhwsuo_ , " machhwsuo.", },
3793 { &test_machhwu_ , " machhwu.", },
3794 { &test_machhwuo_ , " machhwuo.", },
3795 { &test_maclhw_ , " maclhw.", },
3796 { &test_maclhwo_ , " maclhwo.", },
3797 { &test_maclhws_ , " maclhws.", },
3798 { &test_maclhwso_ , " maclhwso.", },
3799 { &test_maclhwsu_ , " maclhwsu.", },
3800 { &test_maclhwsuo_ , " maclhwsuo.", },
3801 { &test_maclhwu_ , " maclhwu.", },
3802 { &test_maclhwuo_ , " maclhwuo.", },
3803 { &test_mulchw_ , " mulchw.", },
3804 { &test_mulchwu_ , " mulchwu.", },
3805 { &test_mulhhw_ , " mulhhw.", },
3806 { &test_mulhhwu_ , " mulhhwu.", },
3807 { &test_mullhw_ , " mullhw.", },
3808 { &test_mullhwu_ , " mullhwu.", },
3809 { &test_nmacchw_ , " nmacchw.", },
3810 { &test_nmacchwo_ , " nmacchwo.", },
3811 { &test_nmacchws_ , " nmacchws.", },
3812 { &test_nmacchwso_ , " nmacchwso.", },
3813 { &test_nmachhw_ , " nmachhw.", },
3814 { &test_nmachhwo_ , " nmachhwo.", },
3815 { &test_nmachhws_ , " nmachhws.", },
3816 { &test_nmachhwso_ , " nmachhwso.", },
3817 { &test_nmaclhw_ , " nmaclhw.", },
3818 { &test_nmaclhwo_ , " nmaclhwo.", },
3819 { &test_nmaclhws_ , " nmaclhws.", },
3820 { &test_nmaclhwso_ , " nmaclhwso.", },
3823 #endif /* defined (IS_PPC405) */
3825 static test_table_t all_tests[] = {
3828 "PPC integer arith insns with two args",
3833 "PPC integer arith insns with two args with flags update",
3838 "PPC integer arith insns with two args and carry",
3842 tests_iacr_ops_two ,
3843 "PPC integer arith insns with two args and carry with flags update",
3848 "PPC integer logical insns with two args",
3853 "PPC integer logical insns with two args with flags update",
3858 "PPC integer compare insns (two args)",
3862 tests_icr_ops_two_i16 ,
3863 "PPC integer compare with immediate insns (two args)",
3867 tests_ia_ops_two_i16 ,
3868 "PPC integer arith insns\n with one register + one 16 bits immediate args",
3872 tests_iar_ops_two_i16 ,
3873 "PPC integer arith insns\n with one register + one 16 bits immediate args with flags update",
3877 tests_il_ops_two_i16 ,
3878 "PPC integer logical insns\n with one register + one 16 bits immediate args",
3882 tests_ilr_ops_two_i16 ,
3883 "PPC integer logical insns\n with one register + one 16 bits immediate args with flags update",
3888 "PPC condition register logical insns - two operands",
3893 "PPC integer arith insns with one arg and carry",
3897 tests_iacr_ops_one ,
3898 "PPC integer arith insns with one arg and carry with flags update",
3903 "PPC integer logical insns with one arg",
3908 "PPC integer logical insns with one arg with flags update",
3913 "PPC logical insns with special forms",
3918 "PPC logical insns with special forms with flags update",
3922 tests_ild_ops_two_i16 ,
3923 "PPC integer load insns\n with one register + one 16 bits immediate args with flags update",
3928 "PPC integer load insns with two register args",
3932 tests_ist_ops_three_i16,
3933 "PPC integer store insns\n with one register + one 16 bits immediate args with flags update",
3937 tests_ist_ops_three ,
3938 "PPC integer store insns with three register args",
3941 #if !defined (NO_FLOAT)
3943 tests_fa_ops_three ,
3944 "PPC floating point arith insns with three args",
3947 #endif /* !defined (NO_FLOAT) */
3948 #if !defined (NO_FLOAT)
3950 tests_far_ops_three ,
3951 "PPC floating point arith insns\n with three args with flags update",
3954 #endif /* !defined (NO_FLOAT) */
3955 #if !defined (NO_FLOAT)
3958 "PPC floating point arith insns with two args",
3961 #endif /* !defined (NO_FLOAT) */
3962 #if !defined (NO_FLOAT)
3965 "PPC floating point arith insns\n with two args with flags update",
3968 #endif /* !defined (NO_FLOAT) */
3969 #if !defined (NO_FLOAT)
3972 "PPC floating point compare insns (two args)",
3975 #endif /* !defined (NO_FLOAT) */
3976 #if !defined (NO_FLOAT)
3979 "PPC floating point arith insns with one arg",
3982 #endif /* !defined (NO_FLOAT) */
3983 #if !defined (NO_FLOAT)
3986 "PPC floating point arith insns\n with one arg with flags update",
3989 #endif /* !defined (NO_FLOAT) */
3990 #if !defined (NO_FLOAT)
3993 "PPC floating point status register manipulation insns",
3996 #endif /* !defined (NO_FLOAT) */
3997 #if !defined (NO_FLOAT)
4000 "PPC floating point status register manipulation insns\n with flags update",
4003 #endif /* !defined (NO_FLOAT) */
4004 #if !defined (NO_FLOAT)
4006 tests_fld_ops_two_i16 ,
4007 "PPC float load insns\n with one register + one 16 bits immediate args with flags update",
4010 #endif /* !defined (NO_FLOAT) */
4011 #if !defined (NO_FLOAT)
4014 "PPC float load insns with two register args",
4017 #endif /* !defined (NO_FLOAT) */
4018 #if !defined (NO_FLOAT)
4020 tests_fst_ops_three_i16,
4021 "PPC float store insns\n with one register + one 16 bits immediate args with flags update",
4024 #endif /* !defined (NO_FLOAT) */
4025 #if !defined (NO_FLOAT)
4027 tests_fst_ops_three ,
4028 "PPC float store insns with three register args",
4031 #endif /* !defined (NO_FLOAT) */
4032 #if defined (HAS_ALTIVEC)
4034 tests_aa_ops_three ,
4035 "PPC altivec integer arith insns with three args",
4038 #endif /* defined (HAS_ALTIVEC) */
4039 #if defined (HAS_ALTIVEC)
4041 tests_al_ops_three ,
4042 "PPC altivec integer logical insns with three args",
4045 #endif /* defined (HAS_ALTIVEC) */
4046 #if defined (HAS_ALTIVEC)
4049 "PPC altivec integer arith insns with two args",
4052 #endif /* defined (HAS_ALTIVEC) */
4053 #if defined (HAS_ALTIVEC)
4056 "PPC altivec integer logical insns with two args",
4059 #endif /* defined (HAS_ALTIVEC) */
4060 #if defined (HAS_ALTIVEC)
4063 "PPC altivec integer logical insns with one arg",
4066 #endif /* defined (HAS_ALTIVEC) */
4067 #if defined (HAS_ALTIVEC)
4070 "Altivec integer compare insns",
4073 #endif /* defined (HAS_ALTIVEC) */
4074 #if defined (HAS_ALTIVEC)
4077 "Altivec integer compare insns with flags update",
4080 #endif /* defined (HAS_ALTIVEC) */
4081 #if defined (HAS_ALTIVEC)
4083 tests_av_int_ops_spe ,
4084 "Altivec integer special insns",
4087 #endif /* defined (HAS_ALTIVEC) */
4088 #if defined (HAS_ALTIVEC)
4091 "Altivec load insns with two register args",
4094 #endif /* defined (HAS_ALTIVEC) */
4095 #if defined (HAS_ALTIVEC)
4097 tests_ast_ops_three ,
4098 "Altivec store insns with three register args",
4101 #endif /* defined (HAS_ALTIVEC) */
4102 #if defined (HAS_ALTIVEC)
4104 tests_afa_ops_three ,
4105 "Altivec floating point arith insns with three args",
4108 #endif /* defined (HAS_ALTIVEC) */
4109 #if defined (HAS_ALTIVEC)
4112 "Altivec floating point arith insns with two args",
4115 #endif /* defined (HAS_ALTIVEC) */
4116 #if defined (HAS_ALTIVEC)
4119 "Altivec floating point arith insns with one arg",
4122 #endif /* defined (HAS_ALTIVEC) */
4123 #if defined (HAS_ALTIVEC)
4126 "Altivec floating point compare insns",
4129 #endif /* defined (HAS_ALTIVEC) */
4130 #if defined (HAS_ALTIVEC)
4132 tests_afcr_ops_two ,
4133 "Altivec floating point compare insns with flags update",
4136 #endif /* defined (HAS_ALTIVEC) */
4137 #if defined (HAS_ALTIVEC)
4139 tests_av_float_ops_spe,
4140 "Altivec float special insns",
4143 #endif /* defined (HAS_ALTIVEC) */
4144 #if defined (IS_PPC405)
4147 "PPC 405 mac insns with three args",
4150 #endif /* defined (IS_PPC405) */
4151 #if defined (IS_PPC405)
4153 tests_p4mc_ops_two ,
4154 "PPC 405 mac insns with three args with flags update",
4157 #endif /* defined (IS_PPC405) */
4158 { NULL, NULL, 0x00000000, },
4161 /* -------------- END #include "ops-ppc.c" -------------- */
4163 static int verbose = 0;
4164 static int arg_list_size = 0;
4166 static double *fargs = NULL;
4167 static int nb_fargs = 0;
4168 static int nb_normal_fargs = 0;
4169 static HWord_t *iargs = NULL;
4170 static int nb_iargs = 0;
4171 static uint16_t *ii16 = NULL;
4172 static int nb_ii16 = 0;
4174 #if defined (HAS_ALTIVEC)
4175 static vector unsigned int* viargs = NULL;
4176 static int nb_viargs = 0;
4177 static vector float* vfargs = NULL;
4178 static int nb_vfargs = 0;
4180 //#define TEST_VSCR_SAT
4183 static inline void register_farg (void *farg,
4184 int s, uint16_t _exp, uint64_t mant)
4188 tmp = ((uint64_t)s << 63) | ((uint64_t)_exp << 52) | mant;
4189 *(uint64_t *)farg = tmp;
4190 #ifndef __powerpc64__
4191 AB_DPRINTF("%d %03x %013llx => %016llx %0e\n",
4193 AB_DPRINTF("%d %03x %013lx => %016lx %0e\n",
4195 s, _exp, mant, *(uint64_t *)farg, *(double *)farg);
4198 static void build_fargs_table (void)
4200 /* Double precision:
4201 * Sign goes from zero to one (1 bit)
4202 * Exponent goes from 0 to ((1 << 12) - 1) (11 bits)
4203 * Mantissa goes from 1 to ((1 << 52) - 1) (52 bits)
4205 * +0.0 : 0 0x000 0x0000000000000 => 0x0000000000000000
4206 * -0.0 : 1 0x000 0x0000000000000 => 0x8000000000000000
4207 * +infinity : 0 0x7FF 0x0000000000000 => 0x7FF0000000000000
4208 * -infinity : 1 0x7FF 0x0000000000000 => 0xFFF0000000000000
4209 * +QNaN : 0 0x7FF 0x7FFFFFFFFFFFF => 0x7FF7FFFFFFFFFFFF
4210 * -QNaN : 1 0x7FF 0x7FFFFFFFFFFFF => 0xFFF7FFFFFFFFFFFF
4211 * +SNaN : 0 0x7FF 0x8000000000000 => 0x7FF8000000000000
4212 * -SNaN : 1 0x7FF 0x8000000000000 => 0xFFF8000000000000
4220 * +0.0 : 0 0x00 0x000000 => 0x00000000
4221 * -0.0 : 1 0x00 0x000000 => 0x80000000
4222 * +infinity : 0 0xFF 0x000000 => 0x7F800000
4223 * -infinity : 1 0xFF 0x000000 => 0xFF800000
4224 * +QNaN : 0 0xFF 0x3FFFFF => 0x7FBFFFFF
4225 * -QNaN : 1 0xFF 0x3FFFFF => 0xFFBFFFFF
4226 * +SNaN : 0 0xFF 0x400000 => 0x7FC00000
4227 * -SNaN : 1 0xFF 0x400000 => 0xFFC00000
4230 uint16_t _exp, e0, e1;
4234 /* Note: VEX isn't so hot with denormals, so don't bother
4235 testing them: set _exp > 0
4238 if ( arg_list_size == 1 ) { // Large
4239 fargs = malloc(200 * sizeof(double));
4240 for (s=0; s<2; s++) {
4241 for (e0=0; e0<2; e0++) {
4242 for (e1=0x001; ; e1 = ((e1 + 1) << 2) + 6) {
4245 _exp = (e0 << 10) | e1;
4246 for (mant = 0x0000000000001ULL; mant < (1ULL << 52);
4247 /* Add 'random' bits */
4248 mant = ((mant + 0x4A6) << 13) + 0x359) {
4249 register_farg(&fargs[i++], s, _exp, mant);
4257 fargs = malloc(16 * sizeof(double));
4258 for (s=0; s<2; s++) { // x2
4259 // for (e0=0; e0<2; e0++) {
4260 for (e1=0x001; ; e1 = ((e1 + 1) << 13) + 7) { // x2
4261 // for (e1=0x001; ; e1 = ((e1 + 1) << 5) + 7) { // x3
4264 // _exp = (e0 << 10) | e1;
4266 for (mant = 0x0000000000001ULL; mant < (1ULL << 52);
4267 /* Add 'random' bits */
4268 mant = ((mant + 0x4A6) << 29) + 0x359) { // x2
4269 register_farg(&fargs[i++], s, _exp, mant);
4278 /* To iterate over non-special values only */
4279 nb_normal_fargs = i;
4282 /* Special values */
4283 /* +0.0 : 0 0x000 0x0000000000000 */
4286 mant = 0x0000000000000ULL;
4287 register_farg(&fargs[i++], s, _exp, mant);
4288 /* -0.0 : 1 0x000 0x0000000000000 */
4291 mant = 0x0000000000000ULL;
4292 register_farg(&fargs[i++], s, _exp, mant);
4293 /* +infinity : 0 0x7FF 0x0000000000000 */
4296 mant = 0x0000000000000ULL;
4297 register_farg(&fargs[i++], s, _exp, mant);
4298 /* -infinity : 1 0x7FF 0x0000000000000 */
4301 mant = 0x0000000000000ULL;
4302 register_farg(&fargs[i++], s, _exp, mant);
4303 /* +QNaN : 0 0x7FF 0x7FFFFFFFFFFFF */
4306 mant = 0x7FFFFFFFFFFFFULL;
4307 register_farg(&fargs[i++], s, _exp, mant);
4308 /* -QNaN : 1 0x7FF 0x7FFFFFFFFFFFF */
4311 mant = 0x7FFFFFFFFFFFFULL;
4312 register_farg(&fargs[i++], s, _exp, mant);
4313 /* +SNaN : 0 0x7FF 0x8000000000000 */
4316 mant = 0x8000000000000ULL;
4317 register_farg(&fargs[i++], s, _exp, mant);
4318 /* -SNaN : 1 0x7FF 0x8000000000000 */
4321 mant = 0x8000000000000ULL;
4322 register_farg(&fargs[i++], s, _exp, mant);
4323 AB_DPRINTF("Registered %d fargs values\n", i);
4328 static void build_iargs_table (void)
4333 #ifndef __powerpc64__
4334 if (arg_list_size == 1) { // Large
4335 iargs = malloc(400 * sizeof(HWord_t));
4336 for (tmp=0; ; tmp = tmp + 1 + (tmp >> 1)) {
4337 if (tmp >= 0x100000000ULL)
4339 iargs[i++] = (HWord_t)tmp;
4340 AB_DPRINTF("val %08x\n", (HWord_t)tmp);
4341 if (tmp == 0xFFFFFFFF)
4345 iargs = malloc(10 * sizeof(HWord_t));
4346 // for (tmp = 0; ; tmp = 71*tmp + 1 + (tmp>>1)) { // gives 8
4347 // for (tmp = 0; ; tmp = 100000*tmp + 1 + (tmp>>1)) { // gives 4
4348 for (tmp=0; ; tmp = 999999*tmp + 999999) { // gives 3
4349 if (tmp >= 0x100000000ULL)
4351 iargs[i++] = (HWord_t)tmp;
4352 AB_DPRINTF("val %08x\n", (HWord_t)tmp);
4353 if (tmp == 0xFFFFFFFF)
4358 if (arg_list_size == 1) { // Large
4359 iargs = malloc(800 * sizeof(HWord_t));
4360 for (tmp=0; ; tmp = 2*tmp + 1 + (tmp >> 2)) {
4362 tmp = 0xFFFFFFFFFFFFFFFFULL;
4364 AB_DPRINTF("val %016lx\n", tmp);
4365 if (tmp == 0xFFFFFFFFFFFFFFFFULL)
4369 iargs = malloc(20 * sizeof(HWord_t));
4370 // for (tmp=0; ; tmp = 9999*tmp + 999999) { // gives 6
4371 for (tmp = 0; ; tmp = 123456789*tmp + 123456789999) { // gives 3
4373 tmp = 0xFFFFFFFFFFFFFFFFULL;
4375 AB_DPRINTF("val %016lx\n", tmp);
4376 if (tmp == 0xFFFFFFFFFFFFFFFFULL)
4380 #endif // #ifndef __powerpc64__
4382 AB_DPRINTF("Registered %d iargs values\n", i);
4386 static void build_ii16_table (void)
4391 if (arg_list_size == 1) { // Large
4392 ii16 = malloc(200 * sizeof(uint32_t));
4393 for (tmp=0; ; tmp = tmp + 1 + (tmp >> 2)) {
4397 AB_DPRINTF("val %04x\n", tmp);
4402 ii16 = malloc(10 * sizeof(uint32_t));
4403 for (tmp=0; ; tmp = 999*tmp + 999) { // gives 3
4407 AB_DPRINTF("val %04x\n", tmp);
4412 AB_DPRINTF("Registered %d ii16 values\n", i);
4416 #if defined (HAS_ALTIVEC)
4417 static void build_viargs_table (void)
4419 #if !defined (ALTIVEC_ARGS_LARGE)
4421 viargs = memalign16(i * sizeof(vector unsigned int));
4422 viargs[0] = (vector unsigned int) { 0x01020304,0x05060708,0x090A0B0C,0x0E0D0E0F };
4423 AB_DPRINTF_VEC32x4( viargs[0] );
4424 viargs[1] = (vector unsigned int) { 0xF1F2F3F4,0xF5F6F7F8,0xF9FAFBFC,0xFEFDFEFF };
4425 AB_DPRINTF_VEC32x4( viargs[1] );
4428 // build from iargs table (large/default already set)
4429 viargs = malloc(nb_iargs * sizeof(vector unsigned int));
4430 for (i=0; i<nb_iargs; i++) {
4432 viargs[i] = (vector unsigned int){ j, j*2, j*3, j*4 };
4433 AB_DPRINTF_VEC32x4( viargs[i] );
4437 AB_DPRINTF("Registered %d viargs values\n", i);
4441 static inline void register_vfarg (vector float* vfarg,
4442 int s, uint8_t _exp, uint32_t mant)
4445 vector uint32_t* vfargI = (vector uint32_t*)vfarg;
4447 tmp = ((uint64_t)s << 31) | ((uint64_t)_exp << 23) | mant;
4448 *vfargI = (vector uint32_t){ tmp,tmp,tmp,tmp };
4449 AB_DPRINTF("%d %02x %06x => %08x %0e\n",
4450 s, _exp, mant, *((uint32_t*)&tmp), *(float*)&tmp);
4453 static void build_vfargs_table (void)
4455 /* Sign goes from zero to one
4456 * Exponent goes from 0 to ((1 << 9) - 1)
4457 * Mantissa goes from 1 to ((1 << 24) - 1)
4459 * +0.0 : 0 0x00 0x000000 => 0x00000000
4460 * -0.0 : 1 0x00 0x000000 => 0x80000000
4461 * +infinity : 0 0xFF 0x000000 => 0x7F800000
4462 * -infinity : 1 0xFF 0x000000 => 0xFF800000
4463 * +SNaN : 0 0xFF 0x7FFFFF (non-zero) => 0x7FFFFFFF
4464 * -SNaN : 1 0xFF 0x7FFFFF (non-zero) => 0xFFFFFFFF
4465 * +QNaN : 0 0xFF 0x3FFFFF (non-zero) => 0x7FBFFFFF
4466 * -QNaN : 1 0xFF 0x3FFFFF (non-zero) => 0xFFBFFFFF
4475 #if !defined (ALTIVEC_ARGS_LARGE)
4477 vfargs = memalign16(nb_vfargs * sizeof(vector float));
4480 for (s=0; s<2; s++) {
4481 for (_exp=0x5; ; _exp += 0x9D ) {
4484 for (mant = 0x3FFFFF; mant < 0x7FFFFF;
4485 mant = /* random */ ((mant + 0x1A6) << 31) + 0x159) {
4486 register_vfarg(&vfargs[i++], s, (uint8_t)_exp, mant);
4492 vfargs = memalign16(nb_vfargs * sizeof(vector float));
4494 for (s=0; s<2; s++) {
4495 for (_exp=0x0; ; _exp += 0x3F ) {
4496 // for (_exp=0; ; _exp = ((_exp + 1) << 1) + 3) {
4499 for (mant = 0x0; mant < 0x7FFFFF;
4500 mant = /* random */ ((mant + 0x4A6) << 5) + 0x359) {
4501 register_vfarg(&vfargs[i++], s, (uint8_t)_exp, mant);
4509 /* Special values */
4510 /* +0.0 : 0 0x00 0x000000 */
4514 register_vfarg(&vfargs[i++], s, _exp, mant);
4515 /* -0.0 : 1 0x00 0x000000 */
4519 register_vfarg(&vfargs[i++], s, _exp, mant);
4521 /* +infinity : 0 0xFF 0x000000 */
4525 register_vfarg(&vfargs[i++], s, _exp, mant);
4526 /* -infinity : 1 0xFF 0x000000 */
4530 register_vfarg(&vfargs[i++], s, _exp, mant);
4532 /* NaN: _exponent all 1s, non-zero fraction */
4533 /* SNaN is a NaN with the most significant fraction bit clear.*/
4534 /* +SNaN : 0 0xFF 0x7FFFFF */
4538 register_vfarg(&vfargs[i++], s, _exp, mant);
4539 /* -SNaN : 1 0xFF 0x7FFFFF */
4543 register_vfarg(&vfargs[i++], s, _exp, mant);
4545 /* QNaN is a NaN with the most significant fraction bit set */
4546 /* +QNaN : 0 0xFF 0x3F0000 */
4550 register_vfarg(&vfargs[i++], s, _exp, mant);
4551 /* -QNaN : 1 0xFF 0x3F0000 */
4555 register_vfarg(&vfargs[i++], s, _exp, mant);
4556 AB_DPRINTF("Registered %d vfargs values\n", i);
4558 assert(i <= nb_vfargs);
4564 static void dump_iargs (void)
4567 for (i = 0; i < nb_iargs; i++) {
4568 printf("iarg %d: %08x %08x %08x\n", i, iargs[i],
4569 (unsigned int)&iargs[i], (unsigned int)iargs);
4573 static void dump_iargs16 (void)
4576 for (i = 0; i < nb_ii16; i++) {
4577 printf("iarg16 %d: %08x %08x %08x\n", i, ii16[i],
4578 (unsigned int)&ii16[i], (unsigned int)ii16);
4582 static void dump_vfargs (void)
4587 for (i=0; i<nb_vfargs; i++) {
4588 vf = (vector float)vfargs[i];
4589 f = ((float*)&vf)[0];
4590 printf("vfarg %3d: %24f : %08x\n", i, f, ((unsigned int*)&f)[0]);
4595 static void test_int_three_args (const char* name, test_func_t func,
4596 unused uint32_t test_flags)
4598 volatile HWord_t res;
4599 volatile uint32_t flags, xer;
4602 for (i=0; i<nb_iargs; i++) {
4603 for (j=0; j<nb_iargs; j++) {
4604 for (k=0; k<nb_iargs; k++) {
4611 GET_CR_XER(flags,xer);
4614 #ifndef __powerpc64__
4615 printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
4617 printf("%s %016llx, %016llx, %016llx => %016llx (%08x %08x)\n",
4619 name, iargs[i], iargs[j], iargs[k], res, flags, xer);
4621 if (verbose) printf("\n");
4626 static void test_int_two_args (const char* name, test_func_t func,
4627 uint32_t test_flags)
4629 volatile HWord_t res;
4630 volatile uint32_t flags, xer, xer_orig;
4631 int i, j, is_div, zap_hi32;
4633 // catches div, divwu, divo, divwu, divwuo, and . variants
4634 is_div = strstr(name, "divw") != NULL;
4636 zap_hi32 = strstr(name, "mulhw") != NULL;
4638 xer_orig = 0x00000000;
4640 for (i=0; i<nb_iargs; i++) {
4641 for (j=0; j<nb_iargs; j++) {
4643 /* result of division by zero is implementation dependent.
4645 if (is_div && iargs[j] == 0)
4654 GET_CR_XER(flags,xer);
4657 #ifndef __powerpc64__
4658 printf("%s %08x, %08x => %08x (%08x %08x)\n",
4660 if (zap_hi32) res &= 0xFFFFFFFFULL;
4661 printf("%s %016llx, %016llx => %016llx (%08x %08x)\n",
4663 name, iargs[i], iargs[j], res, flags, xer);
4665 if (verbose) printf("\n");
4667 if ((test_flags & PPC_XER_CA) && xer_orig == 0x00000000) {
4668 xer_orig = 0x20000000;
4673 static void test_int_one_arg (const char* name, test_func_t func,
4674 uint32_t test_flags)
4676 volatile HWord_t res;
4677 volatile uint32_t flags, xer, xer_orig;
4680 xer_orig = 0x00000000;
4682 for (i=0; i<nb_iargs; i++) {
4688 GET_CR_XER(flags,xer);
4690 #ifndef __powerpc64__
4691 printf("%s %08x => %08x (%08x %08x)\n",
4693 printf("%s %016llx => %016llx (%08x %08x)\n",
4695 name, iargs[i], res, flags, xer);
4697 if ((test_flags & PPC_XER_CA) && xer_orig == 0x00000000) {
4698 xer_orig = 0x20000000;
4703 static inline void invalidate_icache ( void *ptr, int nbytes )
4705 HWord_t startaddr = (HWord_t) ptr;
4706 HWord_t endaddr = startaddr + nbytes;
4707 HWord_t cls = 32; /*VG_(cache_line_size_ppc32);*/
4710 startaddr &= ~(cls - 1);
4711 for (addr = startaddr; addr < endaddr; addr += cls)
4712 asm volatile("dcbst 0,%0" : : "r" (addr));
4713 asm volatile("sync");
4714 for (addr = startaddr; addr < endaddr; addr += cls)
4715 asm volatile("icbi 0,%0" : : "r" (addr));
4716 asm volatile("sync; isync");
4719 /* for god knows what reason, if this isn't inlined, the
4720 program segfaults. */
4722 void _patch_op_imm (uint32_t *p_insn, uint16_t imm, int sh, int len)
4724 uint32_t mask = ((1 << len) - 1) << sh;
4725 *p_insn = (*p_insn & ~mask) | ((imm<<sh) & mask);
4729 void patch_op_imm (uint32_t* p_insn, uint16_t imm, int sh, int len)
4731 _patch_op_imm(p_insn, imm, sh, len);
4732 invalidate_icache(p_insn, 4);
4736 void patch_op_imm16 (uint32_t *p_insn, uint16_t imm)
4738 patch_op_imm(p_insn, imm, 0, 16);
4742 /* Copy the 2 insn function starting at p_func_F to func_buf[], and
4743 return a possibly different pointer, which, when called, runs the
4744 copy in func_buf[]. */
4746 test_func_t init_function( test_func_t p_func_F, uint32_t func_buf[] )
4748 uint32_t* p_func = (uint32_t*)p_func_F;
4749 #ifndef __powerpc64__
4750 func_buf[0] = p_func[0];
4751 func_buf[1] = p_func[1];
4752 return (test_func_t)&func_buf[0];
4754 /* p_func points to a function descriptor, the first word of which
4755 points to the real code. Copy the code itself but not the
4756 descriptor, and just swizzle the descriptor's entry pointer. */
4757 uint64_t* descr = (uint64_t*)p_func;
4758 uint32_t* entry = (uint32_t*)(descr[0]);
4759 func_buf[0] = entry[0];
4760 func_buf[1] = entry[1];
4761 descr[0] = (uint64_t)&func_buf[0];
4762 return (test_func_t)descr;
4763 #endif // #ifndef __powerpc64__
4767 static void test_int_one_reg_imm16 (const char* name,
4768 test_func_t func_IN,
4769 unused uint32_t test_flags)
4771 volatile test_func_t func;
4772 uint32_t* func_buf = get_rwx_area();
4773 volatile HWord_t res;
4774 volatile uint32_t flags, xer;
4777 for (i=0; i<nb_iargs; i++) {
4778 for (j=0; j<nb_ii16; j++) {
4779 /* Patch up the instruction */
4780 func = init_function( func_IN, func_buf );
4781 patch_op_imm16(&func_buf[0], ii16[j]);
4787 GET_CR_XER(flags,xer);
4790 #ifndef __powerpc64__
4791 printf("%s %08x, %08x => %08x (%08x %08x)\n",
4793 printf("%s %016llx, %08x => %016llx (%08x %08x)\n",
4795 name, iargs[i], ii16[j], res, flags, xer);
4797 if (verbose) printf("\n");
4801 /* Special test cases for:
4819 * rldicl rA,rS,SH,MB
4820 * rldicr rA,rS,SH,ME
4821 * rldimi rA,rS,SH,MB
4825 static void rlwi_cb (const char* name, test_func_t func_IN,
4826 unused uint32_t test_flags)
4828 volatile test_func_t func;
4829 uint32_t* func_buf = get_rwx_area();
4830 volatile HWord_t res;
4831 volatile uint32_t flags, xer;
4832 int i, j, k, l, arg_step;
4834 arg_step = (arg_list_size == 0) ? 31 : 3;
4836 r17 = 0; // rlwimi takes r17 as input: start with a clean slate.
4838 for (i=0; i<nb_iargs; i++) {
4839 for (j=0; j<32; j+=arg_step) {
4840 for (k=0; k<32; k+=arg_step) {
4841 for (l=0; l<32; l+=arg_step) {
4842 /* Patch up the instruction */
4843 func = init_function( func_IN, func_buf );
4844 _patch_op_imm(&func_buf[0], j, 11, 5);
4845 _patch_op_imm(&func_buf[0], k, 6, 5);
4846 patch_op_imm(&func_buf[0], l, 1, 5);
4852 GET_CR_XER(flags,xer);
4855 #ifndef __powerpc64__
4856 printf("%s %08x, %2d, %2d, %2d => %08x (%08x %08x)\n",
4858 printf("%s %016llx, %2d, %2d, %2d => %016llx (%08x %08x)\n",
4860 name, iargs[i], j, k, l, res, flags, xer);
4862 if (verbose) printf("\n");
4868 static void rlwnm_cb (const char* name, test_func_t func_IN,
4869 unused uint32_t test_flags)
4871 volatile test_func_t func;
4872 uint32_t* func_buf = get_rwx_area();
4873 volatile HWord_t res;
4874 volatile uint32_t flags, xer;
4875 int i, j, k, l, arg_step;
4877 arg_step = (arg_list_size == 0) ? 31 : 3;
4879 for (i=0; i<nb_iargs; i++) {
4880 for (j=0; j<nb_iargs; j++) {
4881 for (k=0; k<32; k+=arg_step) {
4882 for (l=0; l<32; l+=arg_step) {
4883 /* Patch up the instruction */
4884 func = init_function( func_IN, func_buf );
4885 _patch_op_imm(&func_buf[0], k, 6, 5);
4886 patch_op_imm(&func_buf[0], l, 1, 5);
4893 GET_CR_XER(flags,xer);
4896 #ifndef __powerpc64__
4897 printf("%s %08x, %08x, %2d, %2d => %08x (%08x %08x)\n",
4899 printf("%s %016llx, %016llx, %2d, %2d => %016llx (%08x %08x)\n",
4901 name, iargs[i], iargs[j], k, l, res, flags, xer);
4903 if (verbose) printf("\n");
4909 static void srawi_cb (const char* name, test_func_t func_IN,
4910 unused uint32_t test_flags)
4912 volatile test_func_t func;
4913 uint32_t* func_buf = get_rwx_area();
4914 volatile HWord_t res;
4915 volatile uint32_t flags, xer;
4918 arg_step = (arg_list_size == 0) ? 31 : 1;
4920 for (i=0; i<nb_iargs; i++) {
4921 for (j=0; j<32; j+=arg_step) {
4922 /* Patch up the instruction */
4923 func = init_function( func_IN, func_buf );
4924 patch_op_imm(&func_buf[0], j, 11, 5);
4930 GET_CR_XER(flags,xer);
4933 #ifndef __powerpc64__
4934 printf("%s %08x, %2d => %08x (%08x %08x)\n",
4936 printf("%s %016llx, %2d => %016llx (%08x %08x)\n",
4938 name, iargs[i], j, res, flags, xer);
4940 if (verbose) printf("\n");
4944 static void mcrf_cb (const char* name, test_func_t func_IN,
4945 unused uint32_t test_flags)
4947 volatile test_func_t func;
4948 uint32_t* func_buf = get_rwx_area();
4949 volatile uint32_t flags, xer;
4950 int i, j, k, arg_step;
4952 arg_step = (arg_list_size == 0) ? 7 : 1;
4954 for (i=0; i<nb_iargs; i++) {
4955 for (j=0; j<8; j+=arg_step) {
4956 for (k=0; k<8; k+=arg_step) {
4957 /* Patch up the instruction */
4958 func = init_function( func_IN, func_buf );
4959 _patch_op_imm(&func_buf[0], j, 23, 3);
4960 patch_op_imm(&func_buf[0], k, 18, 3);
4967 GET_CR_XER(flags,xer);
4969 #ifndef __powerpc64__
4970 printf("%s %d, %d (%08x) => (%08x %08x)\n",
4972 printf("%s %d, %d (%016llx) => (%08x %08x)\n",
4974 name, j, k, iargs[i], flags, xer);
4976 if (verbose) printf("\n");
4981 static void mcrxr_cb (const char* name, test_func_t func_IN,
4982 unused uint32_t test_flags)
4984 volatile test_func_t func;
4985 uint32_t* func_buf = get_rwx_area();
4986 volatile uint32_t flags, xer;
4987 int i, j, k, arg_step;
4989 arg_step = 1; //(arg_list_size == 0) ? 7 : 1;
4991 for (i=0; i<16; i+=arg_step) {
4993 for (k=0; k<8; k+=arg_step) {
4994 /* Patch up the instruction */
4995 func = init_function( func_IN, func_buf );
4996 patch_op_imm(&func_buf[0], k, 23, 3);
5003 GET_CR_XER(flags,xer);
5005 printf("%s %d (%08x) => (%08x %08x)\n",
5006 name, k, j, flags, xer);
5008 if (verbose) printf("\n");
5012 static void mfcr_cb (const char* name, test_func_t func,
5013 unused uint32_t test_flags)
5015 volatile HWord_t res;
5016 volatile uint32_t flags, xer;
5019 for (i=0; i<nb_iargs; i++) {
5022 /* Set up flags for test */
5026 GET_CR_XER(flags,xer);
5029 #ifndef __powerpc64__
5030 printf("%s (%08x) => %08x (%08x %08x)\n",
5032 printf("%s (%016llx) => %016llx (%08x %08x)\n",
5034 name, iargs[i], res, flags, xer);
5038 // NOTE: Not using func: calling function kills lr
5039 static void mfspr_cb (const char* name, test_func_t func,
5040 unused uint32_t test_flags)
5042 //volatile uint32_t res, flags, xer, ctr, lr, tmpcr, tmpxer;
5043 volatile HWord_t res;
5045 func = func; // just to stop compiler complaining
5047 // mtxer followed by mfxer
5048 for (k=0; k<nb_iargs; k++) {
5050 __asm__ __volatile__(
5053 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"xer"
5055 res &= 0xE000007F; /* rest of the bits are undefined */
5057 #ifndef __powerpc64__
5058 printf("%s 1 (%08x) -> mtxer -> mfxer => %08x\n",
5060 printf("%s 1 (%08x) -> mtxer -> mfxer => %016llx\n",
5065 // mtlr followed by mflr
5066 for (k=0; k<nb_iargs; k++) {
5068 __asm__ __volatile__(
5071 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"lr"
5074 #ifndef __powerpc64__
5075 printf("%s 8 (%08x) -> mtlr -> mflr => %08x\n",
5077 printf("%s 8 (%08x) -> mtlr -> mflr => %016llx\n",
5082 // mtctr followed by mfctr
5083 for (k=0; k<nb_iargs; k++) {
5085 __asm__ __volatile__(
5088 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"ctr"
5091 #ifndef __powerpc64__
5092 printf("%s 9 (%08x) -> mtctr -> mfctr => %08x\n",
5094 printf("%s 9 (%08x) -> mtctr -> mfctr => %016llx\n",
5100 static void mtcrf_cb (const char* name, test_func_t func_IN,
5101 unused uint32_t test_flags)
5103 volatile test_func_t func;
5104 uint32_t* func_buf = get_rwx_area();
5105 volatile uint32_t flags, xer;
5108 arg_step = (arg_list_size == 0) ? 99 : 1;
5110 for (i=0; i<nb_iargs; i++) {
5111 for (j=0; j<256; j+=arg_step) {
5112 /* Patch up the instruction */
5113 func = init_function( func_IN, func_buf );
5114 patch_op_imm(&func_buf[0], j, 12, 8);
5120 GET_CR_XER(flags,xer);
5122 #ifndef __powerpc64__
5123 printf("%s %3d, %08x => (%08x %08x)\n",
5125 printf("%s %3d, %016llx => (%08x %08x)\n",
5127 name, j, iargs[i], flags, xer);
5129 if (verbose) printf("\n");
5133 // NOTE: Not using func: calling function kills lr
5134 static void mtspr_cb (const char* name, test_func_t func,
5135 unused uint32_t test_flags)
5139 #ifdef __powerpc64__
5140 static void rldc_cb (const char* name, test_func_t func_IN,
5141 unused uint32_t test_flags)
5143 volatile test_func_t func;
5144 uint32_t* func_buf = get_rwx_area();
5145 volatile HWord_t res;
5146 volatile uint32_t flags, xer;
5147 int i, j, k, arg_step;
5149 arg_step = (arg_list_size == 0) ? 7 : 3;
5151 for (i=0; i<nb_iargs; i++) {
5152 for (j=0; j<nb_iargs; j++) {
5153 for (k=0; k<64; k+=arg_step) {
5154 /* Patch up the instruction */
5155 func = init_function( func_IN, func_buf );
5156 patch_op_imm(&func_buf[0], (((k & 0x1F)<<1) | ((k>>5)&1)), 5, 6);
5163 GET_CR_XER(flags,xer);
5166 printf("%s %016llx, %016llx, %2d => %016llx (%08x %08x)\n",
5167 name, iargs[i], iargs[j], k, res, flags, xer);
5169 if (verbose) printf("\n");
5174 static void rldi_cb (const char* name, test_func_t func_IN,
5175 unused uint32_t test_flags)
5177 volatile test_func_t func;
5178 uint32_t* func_buf = get_rwx_area();
5179 volatile HWord_t res;
5180 volatile uint32_t flags, xer;
5181 int i, j, k, arg_step;
5183 arg_step = (arg_list_size == 0) ? 7 : 3;
5185 for (i=0; i<nb_iargs; i++) {
5186 for (j=0; j<64; j+=arg_step) { // SH
5187 for (k=0; k<64; k+=arg_step) { // MB|ME
5188 /* Patch up the instruction */
5189 func = init_function( func_IN, func_buf );
5190 _patch_op_imm(&func_buf[0], (j & 0x1F), 11, 5);
5191 _patch_op_imm(&func_buf[0], ((j>>5)&1), 1, 1);
5192 patch_op_imm(&func_buf[0], (((k & 0x1F)<<1) | ((k>>5)&1)), 5, 6);
5198 GET_CR_XER(flags,xer);
5201 printf("%s %016llx, %2d, %2d => %016llx (%08x %08x)\n",
5202 name, iargs[i], j, k, res, flags, xer);
5204 if (verbose) printf("\n");
5209 static void sradi_cb (const char* name, test_func_t func_IN,
5210 unused uint32_t test_flags)
5212 volatile test_func_t func;
5213 uint32_t* func_buf = get_rwx_area();
5214 volatile HWord_t res;
5215 volatile uint32_t flags, xer;
5218 arg_step = (arg_list_size == 0) ? 7 : 3;
5220 for (i=0; i<nb_iargs; i++) {
5221 for (j=0; j<64; j+=arg_step) { // SH
5222 /* Patch up the instruction */
5223 func = init_function( func_IN, func_buf );
5224 _patch_op_imm(&func_buf[0], (j & 0x1F), 11, 5);
5225 patch_op_imm(&func_buf[0], ((j>>5)&1), 1, 1);
5231 GET_CR_XER(flags,xer);
5234 printf("%s %016llx, %2d => %016llx (%08x %08x)\n",
5235 name, iargs[i], j, res, flags, xer);
5237 if (verbose) printf("\n");
5240 #endif // #ifdef __powerpc64__
5243 typedef struct special_t special_t;
5247 void (*test_cb)(const char* name, test_func_t func,
5248 unused uint32_t test_flags);
5251 static void test_special (special_t *table,
5252 const char* name, test_func_t func,
5253 unused uint32_t test_flags)
5258 for (tmp = name; isspace(*tmp); tmp++)
5260 for (i=0; table[i].name != NULL; i++) {
5262 fprintf(stderr, "look for handler for '%s' (%s)\n", name,
5265 if (strcmp(table[i].name, tmp) == 0) {
5266 (*table[i].test_cb)(name, func, test_flags);
5270 fprintf(stderr, "ERROR: no test found for op '%s'\n", name);
5273 static special_t special_int_ops[] = {
5275 "rlwimi", /* One register + 3 5 bits immediate arguments */
5279 "rlwimi.", /* One register + 3 5 bits immediate arguments */
5283 "rlwinm", /* One register + 3 5 bits immediate arguments */
5287 "rlwinm.", /* One register + 3 5 bits immediate arguments */
5291 "rlwnm", /* Two registers + 2 5 bits immediate arguments */
5295 "rlwnm.", /* Two registers + 2 5 bits immediate arguments */
5299 "srawi", /* One register + 1 5 bits immediate arguments */
5303 "srawi.", /* One register + 1 5 bits immediate arguments */
5307 "mcrf", /* 2 3 bits immediate arguments */
5312 "mcrfs", /* 2 3 bits immediate arguments */
5317 "mcrxr", /* 1 3 bits immediate argument */
5321 "mfcr", /* No arguments */
5325 "mfspr", /* 1 10 bits immediate argument */
5329 { // Move from time base
5330 "mftb", /* 1 10 bits immediate arguments */
5335 "mtcrf", /* One register + 1 8 bits immediate arguments */
5339 "mtspr", /* One register + 1 10 bits immediate arguments */
5342 #ifdef __powerpc64__
5344 "rldcl", /* Two registers + 1 6 bit immediate argument */
5348 "rldcl.", /* Two registers + 1 6 bit immediate argument */
5352 "rldcr", /* Two registers + 1 6 bit immediate argument */
5356 "rldcr.", /* Two registers + 1 6 bit immediate argument */
5360 "rldic", /* One register + 2 6 bit immediate arguments */
5364 "rldic.", /* One register + 2 6 bit immediate arguments */
5368 "rldicl", /* One register + 2 6 bit immediate arguments */
5372 "rldicl.", /* One register + 2 6 bit immediate arguments */
5376 "rldicr", /* One register + 2 6 bit immediate arguments */
5380 "rldicr.", /* One register + 2 6 bit immediate arguments */
5384 "rldimi", /* One register + 2 6 bit immediate arguments */
5388 "rldimi.", /* One register + 2 6 bit immediate arguments */
5392 "sradi", /* One register + 1 6 bit immediate argument */
5396 "sradi.", /* One register + 1 6 bit immediate argument */
5399 #endif // #ifdef __powerpc64__
5406 static void test_int_special (const char* name, test_func_t func,
5407 uint32_t test_flags)
5409 test_special(special_int_ops, name, func, test_flags);
5413 static void test_int_ld_one_reg_imm16 (const char* name,
5414 test_func_t func_IN,
5415 unused uint32_t test_flags)
5417 volatile test_func_t func;
5418 uint32_t* func_buf = get_rwx_area();
5419 volatile HWord_t res, base;
5420 volatile uint32_t flags, xer;
5421 int i, offs, is_lwa=0;
5423 #ifdef __powerpc64__
5424 is_lwa = strstr(name, "lwa") != NULL;
5428 base = (HWord_t)&iargs[0];
5429 for (i=0; i<nb_iargs; i++) {
5430 offs = i * sizeof(HWord_t);
5432 /* Patch up the instruction */
5433 func = init_function( func_IN, func_buf );
5435 patch_op_imm(&func_buf[0], offs>>2, 2, 14);
5437 patch_op_imm16(&func_buf[0], offs);
5443 GET_CR_XER(flags,xer);
5446 #ifndef __powerpc64__
5447 printf("%s %2d, (%08x) => %08x, %2d (%08x %08x)\n",
5449 printf("%s %3d, (%016llx) => %016llx, %3lld (%08x %08x)\n",
5451 name, offs, iargs[i], res, r14-base, flags, xer);
5453 if (verbose) printf("\n");
5456 base = (HWord_t)&iargs[nb_iargs-1];
5457 for (i = -nb_iargs+1; i<=0; i++) {
5458 offs = i * sizeof(HWord_t);
5460 /* Patch up the instruction */
5461 func = init_function( func, func_buf );
5462 patch_op_imm16(&func_buf[0], offs);
5468 GET_CR_XER(flags,xer);
5471 #ifndef __powerpc64__
5472 printf("%s %2d, (%08x) => %08x, %2d (%08x %08x)\n",
5474 printf("%s %3d, (%016llx) => %016llx, %3lld (%08x %08x)\n",
5476 name, offs, iargs[nb_iargs-1+i], res, r14-base, flags, xer);
5480 static void test_int_ld_two_regs (const char* name,
5482 unused uint32_t test_flags)
5484 volatile HWord_t res, base;
5485 volatile uint32_t flags, xer;
5489 base = (HWord_t)&iargs[0];
5490 for (i=0; i<nb_iargs; i++) {
5491 offs = i * sizeof(HWord_t);
5497 GET_CR_XER(flags,xer);
5500 #ifndef __powerpc64__
5501 printf("%s %d (%08x) => %08x, %d (%08x %08x)\n",
5503 printf("%s %3d, (%016llx) => %016llx, %2lld (%08x %08x)\n",
5505 name, offs, iargs[i], res, r14-base, flags, xer);
5509 static void test_int_st_two_regs_imm16 (const char* name,
5510 test_func_t func_IN,
5511 unused uint32_t test_flags)
5513 volatile test_func_t func;
5514 uint32_t* func_buf = get_rwx_area();
5515 volatile uint32_t flags, xer;
5517 HWord_t *iargs_priv, base;
5519 // private iargs table to store to
5520 iargs_priv = malloc(nb_iargs * sizeof(HWord_t));
5523 base = (HWord_t)&iargs_priv[0];
5524 for (i=0; i<nb_iargs; i++) {
5525 for (k=0; k<nb_iargs; k++) // clear array
5528 offs = i * sizeof(HWord_t);
5530 /* Patch up the instruction */
5531 func = init_function( func_IN, func_buf );
5532 patch_op_imm16(&func_buf[0], offs);
5534 r14 = iargs[i]; // read from iargs
5535 r15 = base; // store to r15 + offs
5539 GET_CR_XER(flags,xer);
5541 #ifndef __powerpc64__
5542 printf("%s %08x, %2d => %08x, %2d (%08x %08x)\n",
5544 printf("%s %016llx, %3d => %016llx, %3lld (%08x %08x)\n",
5546 name, iargs[i], offs, iargs_priv[i], r15-base, flags, xer);
5548 if (verbose) printf("\n");
5551 base = (HWord_t)&iargs_priv[nb_iargs-1];
5552 for (i = -nb_iargs+1; i<=0; i++) {
5553 for (k=0; k<nb_iargs; k++) // clear array
5556 offs = i * sizeof(HWord_t);
5558 /* Patch up the instruction */
5559 func = init_function( func, func_buf );
5560 patch_op_imm16(&func_buf[0], offs);
5562 r14 = iargs[nb_iargs-1+i]; // read from iargs
5563 r15 = base; // store to r15 + offs
5567 GET_CR_XER(flags,xer);
5569 #ifndef __powerpc64__
5570 printf("%s %08x, %2d => %08x, %2d (%08x %08x)\n",
5572 printf("%s %016llx, %3d => %016llx, %3lld (%08x %08x)\n",
5574 name, iargs[nb_iargs-1+i], offs, iargs_priv[nb_iargs-1+i],
5575 r15-base, flags, xer);
5580 static void test_int_st_three_regs (const char* name,
5582 unused uint32_t test_flags)
5584 volatile uint32_t flags, xer;
5586 HWord_t *iargs_priv, base;
5588 // private iargs table to store to
5589 iargs_priv = malloc(nb_iargs * sizeof(HWord_t));
5591 base = (HWord_t)&iargs_priv[0];
5592 for (i=0; i<nb_iargs; i++) {
5593 for (k=0; k<nb_iargs; k++) // clear array
5596 offs = i * sizeof(HWord_t);
5597 r14 = iargs[i]; // read from iargs
5598 r15 = base; // store to r15 + offs
5603 GET_CR_XER(flags,xer);
5605 #ifndef __powerpc64__
5606 printf("%s %08x, %d => %08x, %d (%08x %08x)\n",
5608 printf("%s %016llx, %3d => %016llx, %2lld (%08x %08x)\n",
5610 name, iargs[i], offs, iargs_priv[i], r15-base, flags, xer);
5616 /* Used in do_tests, indexed by flags->nb_args
5617 Elements correspond to enum test_flags::num args
5619 static test_loop_t int_loops[] = {
5622 &test_int_three_args,
5624 &test_int_one_reg_imm16,
5625 &test_int_one_reg_imm16,
5627 &test_int_ld_one_reg_imm16,
5628 &test_int_ld_two_regs,
5629 &test_int_st_two_regs_imm16,
5630 &test_int_st_three_regs,
5633 #if !defined (NO_FLOAT)
5634 static void test_float_three_args (const char* name, test_func_t func,
5635 unused uint32_t test_flags)
5638 uint64_t u0, u1, u2, ur;
5639 volatile uint32_t flags;
5642 /* Note: using nb_normal_fargs:
5643 - not testing special values for these insns
5646 for (i=0; i<nb_normal_fargs; i+=3) {
5647 for (j=0; j<nb_normal_fargs; j+=5) {
5648 for (k=0; k<nb_normal_fargs; k+=7) {
5649 u0 = *(uint64_t *)(&fargs[i]);
5650 u1 = *(uint64_t *)(&fargs[j]);
5651 u2 = *(uint64_t *)(&fargs[k]);
5661 ur = *(uint64_t *)(&res);
5663 /* Note: zapping the bottom byte of the result,
5664 as vex's accuracy isn't perfect */
5665 ur &= 0xFFFFFFFFFFFFFF00ULL;
5667 #ifndef __powerpc64__
5668 printf("%s %016llx, %016llx, %016llx => %016llx",
5670 printf("%s %016llx, %016llx, %016llx => %016llx",
5672 name, u0, u1, u2, ur);
5673 #if defined TEST_FLOAT_FLAGS
5674 printf(" (%08x)", flags);
5678 if (verbose) printf("\n");
5683 static void test_float_two_args (const char* name, test_func_t func,
5684 unused uint32_t test_flags)
5687 uint64_t u0, u1, ur;
5688 volatile uint32_t flags;
5691 for (i=0; i<nb_fargs; i+=3) {
5692 for (j=0; j<nb_fargs; j+=5) {
5693 u0 = *(uint64_t *)(&fargs[i]);
5694 u1 = *(uint64_t *)(&fargs[j]);
5703 ur = *(uint64_t *)(&res);
5705 #ifndef __powerpc64__
5706 printf("%s %016llx, %016llx => %016llx",
5708 printf("%s %016llx, %016llx => %016llx",
5711 #if defined TEST_FLOAT_FLAGS
5712 printf(" (%08x)", flags);
5716 if (verbose) printf("\n");
5720 static void test_float_one_arg (const char* name, test_func_t func,
5721 unused uint32_t test_flags)
5725 volatile uint32_t flags;
5726 int i, zap_hi_32bits;
5728 /* if we're testing fctiw or fctiwz, zap the hi 32bits,
5729 as they're undefined */
5730 zap_hi_32bits = strstr(name, "fctiw") != NULL;
5732 for (i=0; i<nb_fargs; i++) {
5733 u0 = *(uint64_t *)(&fargs[i]);
5741 ur = *(uint64_t *)(&res);
5744 ur &= 0xFFFFFFFFULL;
5746 #ifndef __powerpc64__
5747 printf("%s %016llx => %016llx",
5749 printf("%s %016llx => %016llx",
5752 #if defined TEST_FLOAT_FLAGS
5753 printf(" (%08x)", flags);
5759 /* Special test cases for:
5764 static special_t special_float_ops[] = {
5767 "mffs", /* One 5 bits immediate argument */
5771 "mffs.", /* One 5 bits immediate argument */
5775 "mtfsb0", /* One 5 bits immediate argument */
5779 "mtfsb0.", /* One 5 bits immediate argument */
5783 "mtfsb1", /* One 5 bits immediate argument */
5787 "mtfsb1.", /* One 5 bits immediate argument */
5791 "mtfsf", /* One register + 1 8 bits immediate argument */
5795 "mtfsf.", /* One register + 1 8 bits immediate argument */
5799 "mtfsfi", /* One 5 bits argument + 1 5 bits argument */
5803 "mtfsfi.", /* One 5 bits argument + 1 5 bits argument */
5813 static void test_float_special (const char* name, test_func_t func,
5814 uint32_t test_flags)
5816 test_special(special_float_ops, name, func, test_flags);
5820 static void test_float_ld_one_reg_imm16 (const char* name,
5821 test_func_t func_IN,
5822 unused uint32_t test_flags)
5824 volatile test_func_t func;
5825 uint32_t* func_buf = get_rwx_area();
5827 volatile uint32_t flags, xer;
5828 volatile double src, res;
5831 /* offset within [1-nb_fargs:nb_fargs] */
5832 for (i=1-nb_fargs; i<nb_fargs; i++) {
5833 offs = i * 8; // offset = i * sizeof(double)
5835 src = fargs[nb_fargs-1 + i];
5836 base = (HWord_t)&fargs[nb_fargs-1];
5839 base = (HWord_t)&fargs[0];
5842 /* Patch up the instruction */
5843 func = init_function( func_IN, func_buf );
5844 patch_op_imm16(&func_buf[0], offs);
5846 // load from fargs[idx] => r14 + offs
5851 GET_CR_XER(flags,xer);
5854 #ifndef __powerpc64__
5855 printf("%s %016llx, %4d => %016llx, %4d",
5857 printf("%s %016llx, %4d => %016llx, %4lld",
5859 name, double_to_bits(src), offs,
5860 double_to_bits(res), r14-base);
5861 #if defined TEST_FLOAT_FLAGS
5862 printf(" (%08x %08x)", flags, xer);
5866 if (verbose) printf("\n");
5869 static void test_float_ld_two_regs (const char* name,
5871 unused uint32_t test_flags)
5873 volatile HWord_t base;
5874 volatile uint32_t flags, xer;
5875 volatile double src, res;
5878 /* offset within [1-nb_fargs:nb_fargs] */
5879 for (i=1-nb_fargs; i<nb_fargs; i++) {
5880 offs = i * 8; // offset = i * sizeof(double)
5881 if (i < 0) { // base reg = start of array
5882 src = fargs[nb_fargs-1 + i];
5883 base = (HWord_t)&fargs[nb_fargs-1];
5886 base = (HWord_t)&fargs[0];
5894 GET_CR_XER(flags,xer);
5897 #ifndef __powerpc64__
5898 printf("%s %016llx, %4d => %016llx, %4d",
5900 printf("%s %016llx, %4lld => %016llx, %4lld",
5902 name, double_to_bits(src), r15/*offs*/,
5903 double_to_bits(res), r14-base);
5904 #if defined TEST_FLOAT_FLAGS
5905 printf(" (%08x %08x)", flags, xer);
5911 static void test_float_st_two_regs_imm16 (const char* name,
5912 test_func_t func_IN,
5913 unused uint32_t test_flags)
5915 volatile test_func_t func;
5916 uint32_t* func_buf = get_rwx_area();
5918 volatile uint32_t flags, xer;
5922 int nb_tmp_fargs = nb_fargs;
5925 /* if we're storing an fp single-precision, don't want nans
5926 - the vex implementation doesn't like them (yet)
5927 Note: This is actually a bigger problem: the vex implementation
5928 rounds these insns twice. This leads to many rounding errors.
5929 For the small fargs set, however, this doesn't show up.
5931 if (strstr(name, "stfs") != NULL)
5932 nb_tmp_fargs = nb_normal_fargs;
5935 // private fargs table to store to
5936 fargs_priv = malloc(nb_tmp_fargs * sizeof(double));
5938 /* offset within [1-nb_tmp_fargs:nb_tmp_fargs] */
5939 for (i=1-nb_tmp_fargs; i<nb_tmp_fargs; i++) {
5940 offs = i * 8; // offset = i * sizeof(double)
5942 src = fargs [nb_tmp_fargs-1 + i];
5943 p_dst = &fargs_priv[nb_tmp_fargs-1 + i];
5944 base = (HWord_t)&fargs_priv[nb_tmp_fargs-1];
5947 p_dst = &fargs_priv[i];
5948 base = (HWord_t)&fargs_priv[0];
5950 *p_dst = 0; // clear dst
5952 /* Patch up the instruction */
5953 func = init_function( func_IN, func_buf );
5954 patch_op_imm16(&func_buf[0], offs);
5956 // read from fargs[idx] => f14
5957 // store to fargs_priv[idx] => r15 + offs
5963 GET_CR_XER(flags,xer);
5965 #ifndef __powerpc64__
5966 printf("%s %016llx, %4d => %016llx, %4d",
5968 printf("%s %016llx, %4d => %016llx, %4lld",
5970 name, double_to_bits(src), offs,
5971 double_to_bits(*p_dst), r15-base);
5972 #if defined TEST_FLOAT_FLAGS
5973 printf(" (%08x %08x)", flags, xer);
5980 static void test_float_st_three_regs (const char* name,
5982 unused uint32_t test_flags)
5984 volatile HWord_t base;
5985 volatile uint32_t flags, xer;
5989 int nb_tmp_fargs = nb_fargs;
5992 /* if we're storing an fp single-precision, don't want nans
5993 - the vex implementation doesn't like them (yet)
5994 Note: This is actually a bigger problem: the vex implementation
5995 rounds these insns twice. This leads to many rounding errors.
5996 For the small fargs set, however, this doesn't show up.
5998 if (strstr(name, "stfs") != NULL) // stfs(u)(x)
5999 nb_tmp_fargs = nb_normal_fargs;
6002 // private fargs table to store to
6003 fargs_priv = malloc(nb_tmp_fargs * sizeof(double));
6005 // /* offset within [1-nb_tmp_fargs:nb_tmp_fargs] */
6006 // for (i=1-nb_tmp_fargs; i<nb_tmp_fargs; i++) {
6007 for (i=0; i<nb_tmp_fargs; i++) {
6008 offs = i * 8; // offset = i * sizeof(double)
6010 src = fargs [nb_tmp_fargs-1 + i];
6011 p_dst = &fargs_priv[nb_tmp_fargs-1 + i];
6012 base = (HWord_t)&fargs_priv[nb_tmp_fargs-1];
6015 p_dst = &fargs_priv[i];
6016 base = (HWord_t)&fargs_priv[0];
6018 *p_dst = 0; // clear dst
6020 f14 = src; // read from fargs
6021 r15 = base; // store to r15 + offs
6026 GET_CR_XER(flags,xer);
6028 #ifndef __powerpc64__
6029 printf("%s %016llx, %4d => %016llx, %4d",
6031 printf("%s %016llx, %4lld => %016llx, %4lld",
6033 name, double_to_bits(src), r16/*offs*/,
6034 double_to_bits(*p_dst), r15-base);
6035 #if defined TEST_FLOAT_FLAGS
6036 printf(" (%08x %08x)", flags, xer);
6042 // print double precision result
6043 #ifndef __powerpc64__
6044 printf("%s %016llx (%014e), %4d => %016llx (%014e), %08x (%08x %08x)\n",
6046 printf("%s %016llx (%014e), %4d => %016llx (%014e), %08x (%08x %08x)\n",
6048 name, double_to_bits(src), src, offs,
6049 double_to_bits(*p_dst), *p_dst, r15, flags, xer);
6051 // print single precision result
6052 #ifndef __powerpc64__
6053 printf("%s %016llx (%014e), %4d => %08x (%f), %08x (%08x %08x)\n",
6055 printf("%s %016llx (%014e), %4d => %08x (%f), %08x (%08x %08x)\n",
6057 name, double_to_bits(src), src, offs,
6058 (uint32_t)(double_to_bits(*p_dst) >> 32),
6059 bits_to_float( (uint32_t)(double_to_bits(*p_dst) >> 32) ),
6067 /* Used in do_tests, indexed by flags->nb_args
6068 Elements correspond to enum test_flags::num args
6070 static test_loop_t float_loops[] = {
6071 &test_float_one_arg,
6072 &test_float_two_args,
6073 &test_float_three_args,
6074 &test_float_two_args,
6077 &test_float_special,
6078 &test_float_ld_one_reg_imm16,
6079 &test_float_ld_two_regs,
6080 &test_float_st_two_regs_imm16,
6081 &test_float_st_three_regs,
6083 #endif /* !defined (NO_FLOAT) */
6086 #if defined (HAS_ALTIVEC)
6088 /* Ref: vector insns to test setting CR, VSCR:
6089 volatile vector unsigned int v1 =
6090 // (vector unsigned int){ 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
6091 (vector unsigned int){ 0x80808080,0x80808080,0x80808080,0x80808080 };
6092 volatile vector unsigned int v2 =
6093 // (vector unsigned int){ 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
6094 (vector unsigned int){ 0x01010101,0x01010101,0x01010101,0x01010101 };
6095 //__asm__ __volatile__ ("vcmpequw. 31,%0,%1" : : "v" (v1), "v" (v2)); // sets CR[6]
6096 //__asm__ __volatile__ ("vpkswss 31,%0,%1" : : "v" (v1), "v" (v2)); // sets VSCR[SAT]
6097 __asm__ __volatile__ ("vsubsbs 31,%0,%1" : : "v" (v1), "v" (v2)); // sets VSCR[SAT]
6100 //#define DEFAULT_VSCR 0x00010000
6101 #define DEFAULT_VSCR 0x0
6103 static void test_av_int_one_arg (const char* name, test_func_t func,
6104 unused uint32_t test_flags)
6106 volatile uint32_t flags, tmpcr;
6107 volatile vector unsigned int tmpvscr;
6108 volatile vector unsigned int vec_in, vec_out, vscr;
6109 unsigned int *src, *dst;
6111 #if defined TEST_VSCR_SAT
6112 unsigned int* p_vscr;
6115 for (i=0; i<nb_viargs; i++) {
6117 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6118 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6120 vec_in = (vector unsigned int)viargs[i];
6121 vec_out = (vector unsigned int){ 0,0,0,0 };
6123 // reset VSCR and CR
6124 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6126 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6127 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6129 // load input -> r14
6130 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in));
6135 // retrieve output <- r17
6136 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6138 // get CR,VSCR flags
6139 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6140 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6143 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6144 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6146 src = (unsigned int*)&vec_in;
6147 dst = (unsigned int*)&vec_out;
6149 printf("%s: %08x %08x %08x %08x\n", name,
6150 src[0], src[1], src[2], src[3]);
6151 printf("%s: => %08x %08x %08x %08x ", name,
6152 dst[0], dst[1], dst[2], dst[3]);
6153 #if defined TEST_VSCR_SAT
6154 p_vscr = (unsigned int*)𝓋
6155 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6157 printf("(%08x)\n", flags);
6162 static void test_av_int_two_args (const char* name, test_func_t func,
6163 unused uint32_t test_flags)
6165 volatile uint32_t flags, tmpcr;
6166 volatile vector unsigned int tmpvscr;
6167 volatile vector unsigned int vec_in1, vec_in2, vec_out, vscr;
6168 unsigned int *src1, *src2, *dst;
6170 #if defined TEST_VSCR_SAT
6171 unsigned int* p_vscr;
6174 for (i=0; i<nb_viargs; i++) {
6175 vec_in1 = (vector unsigned int)viargs[i];
6176 for (j=0; j<nb_viargs; j++) {
6177 vec_in2 = (vector unsigned int)viargs[j];
6178 vec_out = (vector unsigned int){ 0,0,0,0 };
6181 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6182 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6184 // reset VSCR and CR
6185 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6187 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6188 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6190 // load inputs -> r14,r15
6191 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6192 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_in2));
6197 // retrieve output <- r17
6198 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6200 // get CR,VSCR flags
6201 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6202 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6205 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6206 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6208 src1 = (unsigned int*)&vec_in1;
6209 src2 = (unsigned int*)&vec_in2;
6210 dst = (unsigned int*)&vec_out;
6212 printf("%s: ", name);
6213 printf("%08x%08x%08x%08x, ", src1[0], src1[1], src1[2], src1[3]);
6214 printf("%08x%08x%08x%08x\n", src2[0], src2[1], src2[2], src2[3]);
6215 printf("%s: => %08x %08x %08x %08x ", name,
6216 dst[0], dst[1], dst[2], dst[3]);
6217 #if defined TEST_VSCR_SAT
6218 p_vscr = (unsigned int*)𝓋
6219 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6221 printf("(%08x)\n", flags);
6224 if (verbose) printf("\n");
6228 static void test_av_int_three_args (const char* name, test_func_t func,
6229 unused uint32_t test_flags)
6231 volatile uint32_t flags, tmpcr;
6232 volatile vector unsigned int tmpvscr;
6233 volatile vector unsigned int vec_in1, vec_in2, vec_in3, vec_out, vscr;
6234 unsigned int *src1, *src2, *src3, *dst;
6236 #if defined TEST_VSCR_SAT
6237 unsigned int* p_vscr;
6240 for (i=0; i<nb_viargs; i++) {
6241 vec_in1 = (vector unsigned int)viargs[i];
6242 for (j=0; j<nb_viargs; j++) {
6243 vec_in2 = (vector unsigned int)viargs[j];
6244 for (k=0; k<nb_viargs; k++) {
6245 vec_in3 = (vector unsigned int)viargs[k];
6246 vec_out = (vector unsigned int){ 0,0,0,0 };
6249 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6250 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6252 // reset VSCR and CR
6253 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6255 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6256 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6258 // load inputs -> r14,r15,r16
6259 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6260 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_in2));
6261 __asm__ __volatile__ ("vor 16,%0,%0" : : "v" (vec_in3));
6266 // retrieve output <- r17
6267 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6269 // get CR,VSCR flags
6270 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6271 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6274 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6275 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6277 src1 = (unsigned int*)&vec_in1;
6278 src2 = (unsigned int*)&vec_in2;
6279 src3 = (unsigned int*)&vec_in3;
6280 dst = (unsigned int*)&vec_out;
6282 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
6283 src1[0], src1[1], src1[2], src1[3],
6284 src2[0], src2[1], src2[2], src2[3],
6285 src3[0], src3[1], src3[2], src3[3]);
6287 printf("%s: => %08x%08x%08x%08x ", name,
6288 dst[0], dst[1], dst[2], dst[3]);
6289 #if defined TEST_VSCR_SAT
6290 p_vscr = (unsigned int*)𝓋
6291 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6293 printf("(%08x)\n", flags);
6296 if (verbose) printf("\n");
6302 static void vs128_cb (const char* name, test_func_t func,
6303 unused uint32_t test_flags)
6305 volatile uint32_t flags, tmpcr;
6306 volatile vector unsigned int tmpvscr;
6307 volatile vector unsigned char vec_shft;
6308 volatile vector unsigned int vec_in1, vec_out, vscr;
6309 unsigned int *src1, *src2, *dst;
6311 #if defined TEST_VSCR_SAT
6312 unsigned int* p_vscr;
6315 for (i=0; i<nb_viargs; i++) {
6316 vec_in1 = (vector unsigned int)viargs[i];
6317 for (j=0; j<8; j++) {
6318 /* low-order 3bits of every byte must be the same for the shift vector */
6319 vec_shft = (vector unsigned char) { j,j,j,j, j,j,j,j, j,j,j,j, j,j,j,j };
6320 vec_out = (vector unsigned int){ 0,0,0,0 };
6323 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6324 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6326 // reset VSCR and CR
6327 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6329 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6330 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6332 // load inputs -> r14,r15
6333 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6334 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_shft));
6339 // retrieve output <- r17
6340 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6342 // get CR,VSCR flags
6343 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6344 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6347 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6348 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6350 src1 = (unsigned int*)&vec_in1;
6351 src2 = (unsigned int*)&vec_shft;
6352 dst = (unsigned int*)&vec_out;
6354 printf("%s: ", name);
6355 printf("%08x%08x%08x%08x, ", src1[0], src1[1], src1[2], src1[3]);
6356 printf("%08x%08x%08x%08x\n", src2[0], src2[1], src2[2], src2[3]);
6358 printf("%s: => %08x %08x %08x %08x ", name,
6359 dst[0], dst[1], dst[2], dst[3]);
6360 #if defined TEST_VSCR_SAT
6361 p_vscr = (unsigned int*)𝓋
6362 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6364 printf("(%08x)\n", flags);
6367 if (verbose) printf("\n");
6371 static void vsplt_cb (const char* name, test_func_t func_IN,
6372 unused uint32_t test_flags)
6374 volatile test_func_t func;
6375 uint32_t* func_buf = get_rwx_area();
6376 volatile uint32_t flags, tmpcr;
6377 volatile vector unsigned int tmpvscr;
6378 volatile vector unsigned int vec_in1, vec_out, vscr;
6379 unsigned int *src1, *dst;
6381 #if defined TEST_VSCR_SAT
6382 unsigned int* p_vscr;
6385 for (i=0; i<nb_viargs; i++) {
6386 vec_in1 = (vector unsigned int)viargs[i];
6388 for (j=0; j<16; j+=3) {
6389 vec_out = (vector unsigned int){ 0,0,0,0 };
6391 /* Patch up the instruction */
6392 func = init_function( func_IN, func_buf );
6393 patch_op_imm(&func_buf[0], j, 16, 5);
6396 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6397 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6399 // reset VSCR and CR
6400 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6402 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6403 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6405 // load input -> r14
6406 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6411 // retrieve output <- r17
6412 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6414 // get CR,VSCR flags
6415 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6416 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6419 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6420 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6422 src1 = (unsigned int*)&vec_in1;
6423 dst = (unsigned int*)&vec_out;
6425 printf("%s: ", name);
6426 printf("%08x %08x %08x %08x, %u\n", src1[0], src1[1], src1[2], src1[3], j);
6428 printf("%s: => %08x %08x %08x %08x ", name,
6429 dst[0], dst[1], dst[2], dst[3]);
6430 #if defined TEST_VSCR_SAT
6431 p_vscr = (unsigned int*)𝓋
6432 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6434 printf("(%08x)\n", flags);
6437 if (verbose) printf("\n");
6441 static void vspltis_cb (const char* name, test_func_t func_IN,
6442 unused uint32_t test_flags)
6444 volatile test_func_t func;
6445 uint32_t* func_buf = get_rwx_area();
6446 volatile uint32_t flags, tmpcr;
6447 volatile vector unsigned int tmpvscr;
6448 volatile vector unsigned int vec_out, vscr;
6451 #if defined TEST_VSCR_SAT
6452 unsigned int* p_vscr;
6455 for (i=0; i<32; i++) {
6456 vec_out = (vector unsigned int){ 0,0,0,0 };
6458 /* Patch up the instruction */
6459 func = init_function( func_IN, func_buf );
6460 patch_op_imm(&func_buf[0], i, 16, 5);
6463 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6464 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6466 // reset VSCR and CR
6467 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6469 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6470 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6475 // retrieve output <- r17
6476 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6478 // get CR,VSCR flags
6479 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6480 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6483 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6484 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6486 dst = (unsigned int*)&vec_out;
6488 printf("%s: %2d => ", name, i);
6489 printf("%08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6490 #if defined TEST_VSCR_SAT
6491 p_vscr = (unsigned int*)𝓋
6492 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6494 printf("(%08x)\n", flags);
6499 static void vsldoi_cb (const char* name, test_func_t func_IN,
6500 unused uint32_t test_flags)
6502 volatile test_func_t func;
6503 uint32_t* func_buf = get_rwx_area();
6504 volatile uint32_t flags, tmpcr;
6505 volatile vector unsigned int tmpvscr;
6506 volatile vector unsigned int vec_in1, vec_in2, vec_out, vscr;
6507 unsigned int *src1, *src2, *dst;
6509 #if defined TEST_VSCR_SAT
6510 unsigned int* p_vscr;
6513 for (i=0; i<nb_viargs; i++) {
6514 vec_in1 = (vector unsigned int)viargs[i];
6515 for (j=0; j<nb_viargs; j++) {
6516 vec_in2 = (vector unsigned int)viargs[j];
6517 for (k=0; k<16; k+=14) {
6518 vec_out = (vector unsigned int){ 0,0,0,0 };
6520 /* Patch up the instruction */
6521 func = init_function( func_IN, func_buf );
6522 patch_op_imm(&func_buf[0], k, 6, 4);
6525 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6526 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6528 // reset VSCR and CR
6529 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6531 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6532 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6534 // load inputs -> r14,r15
6535 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6536 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_in2));
6541 // retrieve output <- r17
6542 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6544 // get CR,VSCR flags
6545 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6546 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6549 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6550 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6552 src1 = (unsigned int*)&vec_in1;
6553 src2 = (unsigned int*)&vec_in2;
6554 dst = (unsigned int*)&vec_out;
6556 printf("%s: ", name);
6557 printf("%08x%08x%08x%08x, %08x%08x%08x%08x, %u\n",
6558 src1[0], src1[1], src1[2], src1[3],
6559 src2[0], src2[1], src2[2], src2[3], k);
6561 printf("%s: => %08x %08x %08x %08x] ", name,
6562 dst[0], dst[1], dst[2], dst[3]);
6563 #if defined TEST_VSCR_SAT
6564 p_vscr = (unsigned int*)𝓋
6565 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6567 printf("(%08x)\n", flags);
6570 if (verbose) printf("\n");
6576 static void lvs_cb (const char *name, test_func_t func,
6577 unused uint32_t test_flags)
6579 volatile uint32_t flags, tmpcr;
6580 volatile vector unsigned int tmpvscr;
6581 volatile vector unsigned int vec_out, vscr;
6584 #if defined TEST_VSCR_SAT
6585 unsigned int* p_vscr;
6588 for (i=-1; i<17; i++) {
6589 vec_out = (vector unsigned int){ 0,0,0,0 };
6591 // make sure start address is 16 aligned - use viargs[0]
6592 r15 = (HWord_t)&viargs[0];
6596 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6597 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6599 // reset VSCR and CR
6600 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6602 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6603 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6608 // retrieve output <- r17
6609 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6611 // get CR,VSCR flags
6612 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6613 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6616 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6617 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6619 dst = (unsigned int*)&vec_out;
6621 printf("%s %3d, %3d", name, i, 0);
6622 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6623 printf("(%08x)\n", flags);
6625 if (verbose) printf("\n");
6628 static special_t special_av_int_ops[] = {
6630 "vsr", /* Two registers arguments */
6634 "vsl", /* Two registers arguments */
6638 "vspltb", /* One reg, one 5-bit uimm arguments */
6642 "vsplth", /* One reg, one 5-bit uimm arguments */
6646 "vspltw", /* One reg, one 5-bit uimm arguments */
6650 "vspltisb", /* One reg, one 5-bit uimm arguments */
6654 "vspltish", /* One reg, one 5-bit uimm arguments */
6658 "vspltisw", /* One reg, one 5-bit uimm arguments */
6662 "vsldoi", /* Two regs, one 4-bit uimm arguments */
6666 "lvsl", /* Two regs */
6670 "lvsr", /* Two regs */
6679 static void test_av_int_special (const char* name, test_func_t func,
6680 uint32_t test_flags)
6682 test_special(special_av_int_ops, name, func, test_flags);
6685 static void test_av_int_ld_two_regs (const char *name,
6687 unused uint32_t test_flags)
6689 volatile uint32_t flags, tmpcr;
6690 volatile vector unsigned int tmpvscr;
6691 volatile vector unsigned int vec_in, vec_out, vscr;
6692 unsigned int *src, *dst;
6693 int i,j, k, do_mask;
6696 if (strstr(name, "lvebx") != NULL) do_mask = 1;
6697 if (strstr(name, "lvehx") != NULL) do_mask = 2;
6698 if (strstr(name, "lvewx") != NULL) do_mask = 4;
6700 for (i=0; i<nb_viargs; i++) {
6701 for (j=0; j<16; j+=7) {
6702 vec_out = (vector unsigned int){ 0,0,0,0 };
6704 // load from viargs array + some dis-alignment
6705 r15 = (HWord_t)&viargs[0];
6709 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6710 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6712 // reset VSCR and CR
6713 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6715 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6716 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6721 // retrieve output <- r17
6722 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6724 // get CR,VSCR flags
6725 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6726 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6729 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6730 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6732 vec_in = (vector unsigned int)viargs[i];
6733 src = (unsigned int*)&vec_in;
6734 dst = (unsigned int*)&vec_out;
6736 /* For lvebx/lvehx/lvewx, as per the documentation, all of
6737 the dest reg except the loaded bits are undefined
6738 afterwards. And different CPUs really do produce
6739 different results. So mask out bits of the result that
6740 are undefined so as to make the test work reliably. */
6742 char* p = (char*)dst;
6743 for (k = 0; k < 16; k++)
6748 short* p = (short*)dst;
6749 for (k = 0; k < 8; k++)
6755 for (k = 0; k < 4; k++)
6760 printf("%s %3d, %08x %08x %08x %08x", name, j, src[0], src[1], src[2], src[3]);
6761 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6762 printf("(%08x)\n", flags);
6764 if (verbose) printf("\n");
6769 static void test_av_int_st_three_regs (const char *name,
6771 unused uint32_t test_flags)
6773 volatile uint32_t flags, tmpcr;
6774 volatile vector unsigned int tmpvscr;
6775 volatile vector unsigned int vec_in, vec_out, vscr;
6776 unsigned int *src, *dst;
6778 vector unsigned int* viargs_priv;
6780 // private viargs table to store to
6781 viargs_priv = memalign16(nb_viargs * sizeof(vector unsigned int));
6782 for (i=0; i<nb_viargs; i++)
6783 viargs_priv[i] = (vector unsigned int) { 0,0,0,0 };
6785 for (i=0; i<nb_viargs; i++) {
6786 for (j=0; j<16; j+=7) {
6788 vec_in = (vector unsigned int)viargs[i];
6790 // store to viargs_priv[0] + some dis-alignment
6791 r16 = (HWord_t)&viargs_priv[0];
6795 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6796 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6798 // reset VSCR and CR
6799 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6801 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6802 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6804 // load inputs -> r14
6805 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in));
6810 // Output stored in viargs_priv
6812 // get CR,VSCR flags
6813 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6814 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6817 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6818 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6820 vec_out = (vector unsigned int)viargs_priv[i];
6821 src = (unsigned int*)&vec_in;
6822 dst = (unsigned int*)&vec_out;
6824 printf("%s %3d, %08x %08x %08x %08x", name, j, src[0], src[1], src[2], src[3]);
6825 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6826 printf("(%08x)\n", flags);
6828 if (verbose) printf("\n");
6832 /* Used in do_tests, indexed by flags->nb_args
6833 Elements correspond to enum test_flags::num args
6835 static test_loop_t altivec_int_loops[] = {
6836 &test_av_int_one_arg,
6837 &test_av_int_two_args,
6838 &test_av_int_three_args,
6839 &test_av_int_two_args,
6842 &test_av_int_special,
6844 &test_av_int_ld_two_regs,
6846 test_av_int_st_three_regs,
6850 static void test_av_float_one_arg (const char* name, test_func_t func,
6851 unused uint32_t test_flags)
6853 volatile uint32_t flags, tmpcr;
6854 volatile vector unsigned int tmpvscr;
6855 volatile vector float vec_in, vec_out;
6856 volatile vector unsigned int vscr;
6857 unsigned int *src, *dst;
6859 #if defined TEST_VSCR_SAT
6860 unsigned int* p_vscr;
6863 /* if we're doing an estimation operation, arrange to zap the
6864 bottom byte of the result as it's basically garbage, and differs
6867 = (strstr(name,"vrsqrtefp") != NULL ||
6868 strstr(name, "vrefp") != NULL)
6869 ? 0xFFFFFF00 : 0xFFFFFFFF;
6871 for (i=0; i<nb_vfargs; i++) {
6872 vec_in = (vector float)vfargs[i];
6873 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
6876 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6877 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6879 // reset VSCR and CR
6880 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6882 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6883 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6885 // load input -> r14
6886 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in));
6891 // retrieve output <- r17
6892 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6894 // get CR,VSCR flags
6895 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6896 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6899 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6900 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6902 src = (unsigned int*)&vec_in;
6903 dst = (unsigned int*)&vec_out;
6905 printf("%s: %08x %08x %08x %08x\n", name,
6906 src[0], src[1], src[2], src[3]);
6907 printf("%s: => %08x %08x %08x %08x ", name,
6908 dst[0] & mask, dst[1] & mask, dst[2] & mask, dst[3] & mask);
6909 #if defined TEST_VSCR_SAT
6910 p_vscr = (unsigned int*)𝓋
6911 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6913 printf("(%08x)\n", flags);
6918 static void test_av_float_two_args (const char* name, test_func_t func,
6919 unused uint32_t test_flags)
6921 volatile uint32_t flags, tmpcr;
6922 volatile vector unsigned int tmpvscr;
6923 volatile vector float vec_in1, vec_in2, vec_out;
6924 volatile vector unsigned int vscr;
6925 unsigned int *src1, *src2, *dst;
6927 #if defined TEST_VSCR_SAT
6928 unsigned int* p_vscr;
6931 for (i=0; i<nb_vfargs; i++) {
6932 for (j=0; j<nb_vfargs; j+=3) {
6933 vec_in1 = (vector float)vfargs[i];
6934 vec_in2 = (vector float)vfargs[j];
6935 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
6938 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6939 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6941 // reset VSCR and CR
6942 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6944 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
6945 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6947 // load inputs -> r14,r15
6948 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
6949 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_in2));
6954 // retrieve output <- r17
6955 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6957 // get CR,VSCR flags
6958 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6959 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6962 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6963 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
6965 src1 = (unsigned int*)&vec_in1;
6966 src2 = (unsigned int*)&vec_in2;
6967 dst = (unsigned int*)&vec_out;
6969 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
6970 src1[0], src1[1], src1[2], src1[3],
6971 src2[0], src2[1], src2[2], src2[3]);
6972 printf("%s: => %08x %08x %08x %08x ", name,
6973 dst[0], dst[1], dst[2], dst[3]);
6974 #if defined TEST_VSCR_SAT
6975 p_vscr = (unsigned int*)𝓋
6976 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6978 printf("(%08x)\n", flags);
6981 if (verbose) printf("\n");
6985 static void test_av_float_three_args (const char* name, test_func_t func,
6986 unused uint32_t test_flags)
6988 volatile uint32_t flags, tmpcr;
6989 volatile vector unsigned int tmpvscr;
6990 volatile vector float vec_in1, vec_in2, vec_in3, vec_out;
6991 volatile vector unsigned int vscr;
6992 unsigned int *src1, *src2, *src3, *dst;
6994 #if defined TEST_VSCR_SAT
6995 unsigned int* p_vscr;
6998 for (i=0; i<nb_vfargs; i++) {
6999 for (j=0; j<nb_vfargs; j+=3) {
7000 for (k=0; k<nb_vfargs; k+=5) {
7001 vec_in1 = (vector float)vfargs[i];
7002 vec_in2 = (vector float)vfargs[j];
7003 vec_in3 = (vector float)vfargs[k];
7004 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
7007 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
7008 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
7010 // reset VSCR and CR
7011 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
7013 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
7014 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
7016 // load inputs -> r14,r15,r16
7017 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in1));
7018 __asm__ __volatile__ ("vor 15,%0,%0" : : "v" (vec_in2));
7019 __asm__ __volatile__ ("vor 16,%0,%0" : : "v" (vec_in3));
7024 // retrieve output <- r17
7025 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
7027 // get CR,VSCR flags
7028 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
7029 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
7032 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
7033 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
7035 src1 = (unsigned int*)&vec_in1;
7036 src2 = (unsigned int*)&vec_in2;
7037 src3 = (unsigned int*)&vec_in3;
7038 dst = (unsigned int*)&vec_out;
7040 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
7041 src1[0], src1[1], src1[2], src1[3],
7042 src2[0], src2[1], src2[2], src2[3],
7043 src3[0], src3[1], src3[2], src3[3]);
7044 printf("%s: => %08x %08x %08x %08x ", name,
7045 dst[0], dst[1], dst[2], dst[3]);
7046 #if defined TEST_VSCR_SAT
7047 p_vscr = (unsigned int*)𝓋
7048 printf("(%08x, %08x)\n", flags, p_vscr[3]);
7050 printf("(%08x)\n", flags);
7053 if (verbose) printf("\n");
7058 static void vcvt_cb (const char* name, test_func_t func_IN,
7059 unused uint32_t test_flags)
7061 volatile test_func_t func;
7062 uint32_t* func_buf = get_rwx_area();
7063 volatile uint32_t flags, tmpcr;
7064 volatile vector unsigned int tmpvscr;
7065 volatile vector unsigned int vec_in, vec_out, vscr;
7066 unsigned int *src, *dst;
7068 #if defined TEST_VSCR_SAT
7069 unsigned int* p_vscr;
7072 for (i=0; i<nb_vfargs; i++) {
7073 vec_in = (vector unsigned int)vfargs[i];
7075 for (j=0; j<32; j+=9) {
7076 vec_out = (vector unsigned int){ 0,0,0,0 };
7078 /* Patch up the instruction */
7079 func = init_function( func_IN, func_buf );
7080 patch_op_imm(&func_buf[0], j, 16, 5);
7083 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
7084 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
7086 // reset VSCR and CR
7087 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
7089 __asm__ __volatile__ ("mtvscr %0" : : "v" (vscr) );
7090 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
7092 // load input -> r14
7093 __asm__ __volatile__ ("vor 14,%0,%0" : : "v" (vec_in));
7098 // retrieve output <- r17
7099 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
7101 // get CR,VSCR flags
7102 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
7103 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
7106 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
7107 __asm__ __volatile__ ("mtvscr %0" : : "v" (tmpvscr));
7109 src = (unsigned int*)&vec_in;
7110 dst = (unsigned int*)&vec_out;
7112 printf("%s: %08x (%13e), %2u", name, src[0], *(float*)(&src[0]), j);
7113 printf(" => %08x (%13e) ", dst[0], *(float*)(&dst[0]));
7114 // printf(" => %08x ", dst[0]);
7115 #if defined TEST_VSCR_SAT
7116 p_vscr = (unsigned int*)𝓋
7117 printf("(%08x, %08x)\n", flags, p_vscr[3]);
7119 printf("(%08x)\n", flags);
7122 if (verbose) printf("\n");
7126 static special_t special_av_float_ops[] = {
7128 "vcfux", /* One reg, one 5-bit uimm argument */
7132 "vcfsx", /* One reg, one 5-bit uimm argument */
7136 "vctuxs", /* One reg, one 5-bit uimm argument */
7140 "vcfux", /* One reg, one 5-bit uimm argument */
7144 "vctsxs", /* One reg, one 5-bit uimm argument */
7153 static void test_av_float_special (const char* name, test_func_t func,
7154 uint32_t test_flags)
7156 test_special(special_av_float_ops, name, func, test_flags);
7159 /* Used in do_tests, indexed by flags->nb_args
7160 Elements correspond to enum test_flags::num args
7162 static test_loop_t altivec_float_loops[] = {
7163 &test_av_float_one_arg,
7164 &test_av_float_two_args,
7165 &test_av_float_three_args,
7166 &test_av_float_two_args,
7169 &test_av_float_special,
7176 #endif /* defined (HAS_ALTIVEC) */
7179 #if defined (IS_PPC405)
7180 static void test_ppc405 (const char* name, test_func_t func,
7181 unused uint32_t test_flags)
7183 volatile uint32_t res, flags, xer, tmpcr, tmpxer;
7186 for (i=0; i<nb_iargs; i++) {
7187 for (j=0; j<nb_iargs; j++) {
7188 for (k=0; k<nb_iargs; k++) {
7191 /* Beware: the third argument and the result
7192 * are in the same register
7197 __asm__ __volatile__ ("mfcr 18");
7199 __asm__ __volatile__ ("mfxer 18");
7202 /* Set up flags for test */
7204 __asm__ __volatile__ ("mtcr 18");
7205 __asm__ __volatile__ ("mtxer 18");
7207 __asm__ __volatile__ ("mfcr 18");
7209 __asm__ __volatile__ ("mfxer 18");
7215 __asm__ __volatile__ ("mtcr 18");
7217 __asm__ __volatile__ ("mtxer 18");
7219 printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
7220 name, iargs[i], iargs[j], iargs[k], res, flags, xer);
7222 if (verbose) printf("\n");
7226 #endif /* defined (IS_PPC405) */
7228 static int check_filter (char *filter)
7233 if (filter != NULL) {
7234 c = strchr(filter, '*');
7244 static int check_name (const char* name, const char *filter,
7250 if (filter != NULL) {
7251 for (; isspace(*name); name++)
7253 FDPRINTF("Check '%s' againt '%s' (%s match)\n",
7254 name, filter, exact ? "exact" : "starting");
7255 nlen = strlen(name);
7256 flen = strlen(filter);
7258 if (nlen == flen && memcmp(name, filter, flen) == 0)
7261 if (flen <= nlen && memcmp(name, filter, flen) == 0)
7272 typedef struct insn_sel_flags_t_struct {
7273 int one_arg, two_args, three_args;
7274 int arith, logical, compare, ldst;
7275 int integer, floats, p405, altivec, faltivec;
7279 static void do_tests ( insn_sel_flags_t seln_flags,
7282 #if defined (IS_PPC405)
7287 int nb_args, type, family;
7291 exact = check_filter(filter);
7293 for (i=0; all_tests[i].name != NULL; i++) {
7294 nb_args = all_tests[i].flags & PPC_NB_ARGS;
7295 /* Check number of arguments */
7296 if ((nb_args == 1 && !seln_flags.one_arg) ||
7297 (nb_args == 2 && !seln_flags.two_args) ||
7298 (nb_args == 3 && !seln_flags.three_args))
7300 /* Check instruction type */
7301 type = all_tests[i].flags & PPC_TYPE;
7302 if ((type == PPC_ARITH && !seln_flags.arith) ||
7303 (type == PPC_LOGICAL && !seln_flags.logical) ||
7304 (type == PPC_COMPARE && !seln_flags.compare) ||
7305 (type == PPC_LDST && !seln_flags.ldst))
7307 /* Check instruction family */
7308 family = all_tests[i].flags & PPC_FAMILY;
7309 if ((family == PPC_INTEGER && !seln_flags.integer) ||
7310 (family == PPC_FLOAT && !seln_flags.floats) ||
7311 (family == PPC_405 && !seln_flags.p405) ||
7312 (family == PPC_ALTIVEC && !seln_flags.altivec) ||
7313 (family == PPC_FALTIVEC && !seln_flags.faltivec))
7315 /* Check flags update */
7316 if (((all_tests[i].flags & PPC_CR) && seln_flags.cr == 0) ||
7317 (!(all_tests[i].flags & PPC_CR) && seln_flags.cr == 1))
7319 /* All passed, do the tests */
7320 tests = all_tests[i].tests;
7321 /* Select the test loop */
7324 loop = &int_loops[nb_args - 1];
7327 #if !defined (NO_FLOAT)
7328 loop = &float_loops[nb_args - 1];
7331 fprintf(stderr, "Sorry. "
7332 "PPC floating point instructions tests "
7333 "are disabled on your host\n");
7334 #endif /* !defined (NO_FLOAT) */
7337 #if defined (IS_PPC405)
7338 tmpl = &test_ppc405;
7342 fprintf(stderr, "Sorry. "
7343 "PPC405 instructions tests are disabled on your host\n");
7345 #endif /* defined (IS_PPC405) */
7347 #if defined (HAS_ALTIVEC)
7348 loop = &altivec_int_loops[nb_args - 1];
7351 fprintf(stderr, "Sorry. "
7352 "Altivec instructions tests are disabled on your host\n");
7356 #if defined (HAS_ALTIVEC)
7357 loop = &altivec_float_loops[nb_args - 1];
7360 fprintf(stderr, "Sorry. "
7361 "Altivec float instructions tests "
7362 "are disabled on your host\n");
7366 printf("ERROR: unknown insn family %08x\n", family);
7369 if (1 || verbose > 0)
7370 printf("%s:\n", all_tests[i].name);
7371 for (j=0; tests[j].name != NULL; j++) {
7372 if (check_name(tests[j].name, filter, exact)) {
7374 printf("Test instruction %s\n", tests[j].name);
7375 (*loop)(tests[j].name, tests[j].func, all_tests[i].flags);
7380 if (verbose) printf("\n");
7382 printf("All done. Tested %d different instructions\n", n);
7386 static void usage (void)
7388 #if !defined (USAGE_SIMPLE)
7390 "jm-insns [-1] [-2] [-3] [-*] [-t <type>] [-f <family>] [-u] "
7391 "[-n <filter>] [-r <test_rigour>] [-h]\n"
7392 "\t-1: test opcodes with one argument\n"
7393 "\t-2: test opcodes with two arguments\n"
7394 "\t-3: test opcodes with three arguments\n"
7395 "\t-*: launch test without checking the number of arguments\n"
7396 "\t-t: launch test for instructions of type <type>\n"
7397 "\t recognized types:\n"
7398 "\t\tarith (or a)\n"
7399 "\t\tlogical (or l)\n"
7400 "\t\tcompare (or c)\n"
7401 "\t\tstoreload (or s)\n"
7402 "\t-f: launch test for instructions of family <family>\n"
7403 "\t recognized families:\n"
7404 "\t\tinteger (or i)\n"
7405 "\t\tfloat (or f)\n"
7406 "\t\tppc405 (or mac)\n"
7407 "\t\taltivec (or a)\n"
7408 "\t-u: test instructions that update flags\n"
7409 "\t-n: filter instructions with <filter>\n"
7410 "\t <filter> can be in two forms:\n"
7411 "\t\tname : filter functions that exactly match <name>\n"
7412 "\t\tname* : filter functions that start with <name>\n"
7413 "\t-r: set size of arg tables to use to define <test_rigour>\n"
7414 "\t recognized types:\n"
7415 "\t\tlarge (or l)\n"
7416 "\t\tsmall (or s) - default\n"
7417 "\t-v: verbose (-v -v for more)\n"
7418 "\t-h: print this help\n"
7420 #else // #if !defined (USAGE_SIMPLE)
7422 "Usage: jm-insns [OPTION]\n"
7423 "\t-i: test integer instructions (default)\n"
7424 "\t-f: test floating point instructions\n"
7425 "\t-a: test altivec instructions\n"
7426 "\t-A: test all (int, fp, altivec) instructions\n"
7427 "\t-v: be verbose\n"
7428 "\t-h: display this help and exit\n"
7430 #endif // #if !defined (USAGE_SIMPLE)
7435 int main (int argc, char **argv)
7437 #if !defined (USAGE_SIMPLE)
7438 ////////////////////////////////////////////////////////////////////////
7439 unsigned char *tmp, *filter = NULL;
7440 insn_sel_flags_t flags;
7443 // check HWord_t really is a host word
7444 assert(sizeof(void*) == sizeof(HWord_t));
7448 flags.three_args = 0;
7460 while ((c = getopt(argc, argv, "123t:f:n:r:uvh")) != -1) {
7469 flags.three_args = 1;
7473 if (strcmp(tmp, "arith") == 0 || strcmp(tmp, "a") == 0) {
7475 } else if (strcmp(tmp, "logical") == 0 || strcmp(tmp, "l") == 0) {
7477 } else if (strcmp(tmp, "compare") == 0 || strcmp(tmp, "c") == 0) {
7479 } else if (strcmp(tmp, "storeload") == 0 || strcmp(tmp, "s") == 0) {
7487 if (strcmp(tmp, "integer") == 0 || strcmp(tmp, "i") == 0) {
7489 } else if (strcmp(tmp, "float") == 0 || strcmp(tmp, "f") == 0) {
7491 } else if (strcmp(tmp, "ppc405") == 0 || strcmp(tmp, "mac") == 0) {
7493 } else if (strcmp(tmp, "altivec") == 0 || strcmp(tmp, "a") == 0) {
7505 if (strcmp(tmp, "large") == 0 || strcmp(tmp, "l") == 0) {
7507 } else if (strcmp(tmp, "small") == 0 || strcmp(tmp, "s") == 0) {
7525 fprintf(stderr, "Unknown argument: '%c'\n", c);
7529 fprintf(stderr, "Bad argument for '%c': '%s'\n", c, tmp);
7533 if (argc != optind) {
7535 fprintf(stderr, "Bad number of arguments\n");
7540 if (flags.one_arg == 0 && flags.two_args == 0 && flags.three_args == 0) {
7543 flags.three_args = 1;
7546 if (flags.arith == 0 && flags.logical == 0 &&
7547 flags.compare == 0 && flags.ldst == 0) {
7554 if (flags.integer == 0 && flags.floats == 0 &&
7555 flags.p405 == 0 && flags.altivec == 0 && flags.faltivec == 0) {
7562 // Default cr update
7564 flags.cr = 2; // both
7566 #else // #if !defined (USAGE_SIMPLE)
7567 ////////////////////////////////////////////////////////////////////////
7569 ./jm-insns -i => int insns
7570 ./jm-insns -f => fp insns
7571 ./jm-insns -a => av insns
7572 ./jm-insns -A => int, fp and avinsns
7574 char *filter = NULL;
7575 insn_sel_flags_t flags;
7581 flags.three_args = 1;
7596 while ((c = getopt(argc, argv, "ifahvA")) != -1) {
7622 fprintf(stderr, "Unknown argument: '%c'\n", c);
7628 #endif // #if !defined (USAGE_SIMPLE)
7631 build_iargs_table();
7632 build_fargs_table();
7634 #if defined (HAS_ALTIVEC)
7635 if (flags.altivec || flags.faltivec) {
7636 build_viargs_table();
7637 build_vfargs_table();
7645 printf("\nInstruction Selection:\n");
7646 printf(" n_args: \n");
7647 printf(" one_arg = %d\n", flags.one_arg);
7648 printf(" two_args = %d\n", flags.two_args);
7649 printf(" three_args = %d\n", flags.three_args);
7650 printf(" type: \n");
7651 printf(" arith = %d\n", flags.arith);
7652 printf(" logical = %d\n", flags.logical);
7653 printf(" compare = %d\n", flags.compare);
7654 printf(" ldst = %d\n", flags.ldst);
7655 printf(" family: \n");
7656 printf(" integer = %d\n", flags.integer);
7657 printf(" floats = %d\n", flags.floats);
7658 printf(" p405 = %d\n", flags.p405);
7659 printf(" altivec = %d\n", flags.altivec);
7660 printf(" faltivec = %d\n", flags.faltivec);
7661 printf(" cr update: \n");
7662 printf(" cr = %d\n", flags.cr);
7664 printf(" num args: \n");
7665 printf(" iargs - %d\n", nb_iargs);
7666 printf(" fargs - %d\n", nb_fargs);
7667 #if defined (HAS_ALTIVEC)
7668 printf(" viargs - %d\n", nb_viargs);
7669 printf(" vfargs - %d\n", nb_vfargs);
7674 do_tests( flags, filter );