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"
171 /* Something of the same size as void*, so can be safely be coerced
172 to/from a pointer type. Also same size as the host's gp registers. */
173 #ifndef __powerpc64__
174 typedef uint32_t HWord_t;
176 typedef uint64_t HWord_t;
177 #endif // #ifndef __powerpc64__
180 #define ALLCR "cr0","cr1","cr2","cr3","cr4","cr5","cr6","cr7"
182 #define SET_CR(_arg) \
183 __asm__ __volatile__ ("mtcr %0" : : "b"(_arg) : ALLCR );
185 #define SET_XER(_arg) \
186 __asm__ __volatile__ ("mtxer %0" : : "b"(_arg) : "xer" );
188 #define GET_CR(_lval) \
189 __asm__ __volatile__ ("mfcr %0" : "=b"(_lval) )
191 #define GET_XER(_lval) \
192 __asm__ __volatile__ ("mfxer %0" : "=b"(_lval) )
194 #define GET_CR_XER(_lval_cr,_lval_xer) \
195 do { GET_CR(_lval_cr); GET_XER(_lval_xer); } while (0)
197 #define SET_CR_ZERO \
200 #define SET_XER_ZERO \
203 #define SET_CR_XER_ZERO \
204 do { SET_CR_ZERO; SET_XER_ZERO; } while (0)
206 #define SET_FPSCR_ZERO \
207 do { double _d = 0.0; \
208 __asm__ __volatile__ ("mtfsf 0xFF, %0" : : "f"(_d) ); \
212 /* XXXX these must all be callee-save regs! */
213 register double f14 __asm__ ("f14");
214 register double f15 __asm__ ("f15");
215 register double f16 __asm__ ("f16");
216 register double f17 __asm__ ("f17");
217 register HWord_t r14 __asm__ ("r14");
218 register HWord_t r15 __asm__ ("r15");
219 register HWord_t r16 __asm__ ("r16");
220 register HWord_t r17 __asm__ ("r17");
223 #if defined (HAVE_ALTIVEC_H)
224 # include <altivec.h>
227 #include <ctype.h> // isspace
231 #include <unistd.h> // getopt
234 #ifndef __powerpc64__
235 #define ASSEMBLY_FUNC(__fname, __insn) \
236 asm(".section \".text\"\n" \
238 "\t.type "__fname",@function\n" \
245 #define ASSEMBLY_FUNC(__fname, __insn) \
246 asm(".section \".text\"\n" \
248 "\t.global "__fname"\n" \
249 "\t.section \".opd\",\"aw\"\n" \
252 "\t.quad ."__fname",.TOC.@tocbase,0\n" \
254 "\t.type ."__fname",@function\n" \
255 "\t.global ."__fname"\n" \
260 #endif // #ifndef __powerpc64__
263 /* Return a pointer to a 1-page area where is is safe to both write
264 and execute instructions. Area is filled with 'trap' insns. */
266 uint32_t* get_rwx_area ( void )
269 static uint32_t* p = NULL;
271 p = mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC,
272 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
273 assert(p != MAP_FAILED);
276 for (i = 0; i < 4096/sizeof(uint32_t); i++)
277 p[i] = 0x7fe00008; /* trap */
283 /* -------------- BEGIN #include "test-ppc.h" -------------- */
286 * PPC tests for qemu-PPC CPU emulation checks - definitions
288 * Copyright (c) 2005 Jocelyn Mayer
290 * This program is free software; you can redistribute it and/or
291 * modify it under the terms of the GNU General Public License V2
292 * as published by the Free Software Foundation
294 * This program is distributed in the hope that it will be useful,
295 * but WITHOUT ANY WARRANTY; without even the implied warranty of
296 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
297 * GNU General Public License for more details.
299 * You should have received a copy of the GNU General Public License
300 * along with this program; if not, write to the Free Software
301 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
304 #if !defined (__TEST_PPC_H__)
305 #define __TEST_PPC_H__
309 typedef void (*test_func_t) (void);
310 typedef struct test_t test_t;
311 typedef struct test_table_t test_table_t;
317 struct test_table_t {
323 typedef void (*test_loop_t) (const char *name, test_func_t func,
328 PPC_ONE_ARG = 0x00000001,
329 PPC_TWO_ARGS = 0x00000002,
330 PPC_THREE_ARGS = 0x00000003,
331 PPC_CMP_ARGS = 0x00000004, // family: compare
332 PPC_CMPI_ARGS = 0x00000005, // family: compare
333 PPC_TWO_I16 = 0x00000006, // family: arith/logical
334 PPC_SPECIAL = 0x00000007, // family: logical
335 PPC_LD_ARGS = 0x00000008, // family: ldst
336 PPC_LDX_ARGS = 0x00000009, // family: ldst
337 PPC_ST_ARGS = 0x0000000A, // family: ldst
338 PPC_STX_ARGS = 0x0000000B, // family: ldst
339 PPC_NB_ARGS = 0x0000000F,
341 PPC_ARITH = 0x00000100,
342 PPC_LOGICAL = 0x00000200,
343 PPC_COMPARE = 0x00000300,
344 PPC_CROP = 0x00000400,
345 PPC_LDST = 0x00000500,
346 PPC_TYPE = 0x00000F00,
348 PPC_INTEGER = 0x00010000,
349 PPC_FLOAT = 0x00020000,
350 PPC_405 = 0x00030000,
351 PPC_ALTIVEC = 0x00040000,
352 PPC_FALTIVEC = 0x00050000,
353 PPC_FAMILY = 0x000F0000,
354 /* Flags: these may be combined, so use separate bitfields. */
356 PPC_XER_CA = 0x02000000,
359 #endif /* !defined (__TEST_PPC_H__) */
361 /* -------------- END #include "test-ppc.h" -------------- */
366 #if defined (DEBUG_ARGS_BUILD)
367 #define AB_DPRINTF(fmt, args...) do { fprintf(stderr, fmt , ##args); } while (0)
369 #define AB_DPRINTF(fmt, args...) do { } while (0)
372 #if defined (DEBUG_FILTER)
373 #define FDPRINTF(fmt, args...) do { fprintf(stderr, fmt , ##args); } while (0)
375 #define FDPRINTF(fmt, args...) do { } while (0)
379 /* Produce the 64-bit pattern corresponding to the supplied double. */
380 static uint64_t double_to_bits ( double d )
382 union { uint64_t i; double d; } u;
383 assert(8 == sizeof(uint64_t));
384 assert(8 == sizeof(double));
385 assert(8 == sizeof(u));
391 static float bits_to_float ( uint32_t i )
393 union { uint32_t i; float f; } u;
394 assert(4 == sizeof(uint32_t));
395 assert(4 == sizeof(float));
396 assert(4 == sizeof(u));
403 #if defined (HAS_ALTIVEC)
404 static void AB_DPRINTF_VEC32x4 ( vector unsigned int v )
406 #if defined (DEBUG_ARGS_BUILD)
408 unsigned int* p_int = (unsigned int*)&v;
410 for (i=0; i<4; i++) {
411 AB_DPRINTF(" %08x", p_int[i]);
419 #define unused __attribute__ (( unused ))
422 /* -------------- BEGIN #include "ops-ppc.c" -------------- */
424 /* #include "test-ppc.h" */
426 static void test_add (void)
428 __asm__ __volatile__ ("add 17, 14, 15");
431 static void test_addo (void)
433 __asm__ __volatile__ ("addo 17, 14, 15");
436 static void test_addc (void)
438 __asm__ __volatile__ ("addc 17, 14, 15");
441 static void test_addco (void)
443 __asm__ __volatile__ ("addco 17, 14, 15");
446 static void test_divw (void)
448 __asm__ __volatile__ ("divw 17, 14, 15");
451 static void test_divwo (void)
453 __asm__ __volatile__ ("divwo 17, 14, 15");
456 static void test_divwu (void)
458 __asm__ __volatile__ ("divwu 17, 14, 15");
461 static void test_divwuo (void)
463 __asm__ __volatile__ ("divwuo 17, 14, 15");
466 static void test_mulhw (void)
468 __asm__ __volatile__ ("mulhw 17, 14, 15");
471 static void test_mulhwu (void)
473 __asm__ __volatile__ ("mulhwu 17, 14, 15");
476 static void test_mullw (void)
478 __asm__ __volatile__ ("mullw 17, 14, 15");
481 static void test_mullwo (void)
483 __asm__ __volatile__ ("mullwo 17, 14, 15");
486 static void test_subf (void)
488 __asm__ __volatile__ ("subf 17, 14, 15");
491 static void test_subfo (void)
493 __asm__ __volatile__ ("subfo 17, 14, 15");
496 static void test_subfc (void)
498 __asm__ __volatile__ ("subfc 17, 14, 15");
501 static void test_subfco (void)
503 __asm__ __volatile__ ("subfco 17, 14, 15");
507 static void test_mulld (void)
509 __asm__ __volatile__ ("mulld 17, 14, 15");
512 static void test_mulhd (void)
514 __asm__ __volatile__ ("mulhd 17, 14, 15");
517 static void test_mulhdu (void)
519 __asm__ __volatile__ ("mulhdu 17, 14, 15");
522 static void test_divd (void)
524 __asm__ __volatile__ ("divd 17, 14, 15");
527 static void test_divdu (void)
529 __asm__ __volatile__ ("divdu 17, 14, 15");
531 #endif // #ifdef __powerpc64__
533 static test_t tests_ia_ops_two[] = {
534 { &test_add , " add", },
535 { &test_addo , " addo", },
536 { &test_addc , " addc", },
537 { &test_addco , " addco", },
538 { &test_divw , " divw", },
539 { &test_divwo , " divwo", },
540 { &test_divwu , " divwu", },
541 { &test_divwuo , " divwuo", },
542 { &test_mulhw , " mulhw", },
543 { &test_mulhwu , " mulhwu", },
544 { &test_mullw , " mullw", },
545 { &test_mullwo , " mullwo", },
546 { &test_subf , " subf", },
547 { &test_subfo , " subfo", },
548 { &test_subfc , " subfc", },
549 { &test_subfco , " subfco", },
551 { &test_mulhd , " mulhd", },
552 { &test_mulhdu , " mulhdu", },
553 { &test_mulld , " mulld", },
554 { &test_divd , " divd", },
555 { &test_divdu , " divdu", },
556 #endif // #ifdef __powerpc64__
560 static void test_add_ (void)
562 __asm__ __volatile__ ("add. 17, 14, 15");
565 static void test_addo_ (void)
567 __asm__ __volatile__ ("addo. 17, 14, 15");
570 static void test_addc_ (void)
572 __asm__ __volatile__ ("addc. 17, 14, 15");
575 static void test_addco_ (void)
577 __asm__ __volatile__ ("addco. 17, 14, 15");
580 static void test_divw_ (void)
582 __asm__ __volatile__ ("divw. 17, 14, 15");
585 static void test_divwo_ (void)
587 __asm__ __volatile__ ("divwo. 17, 14, 15");
590 static void test_divwu_ (void)
592 __asm__ __volatile__ ("divwu. 17, 14, 15");
595 static void test_divwuo_ (void)
597 __asm__ __volatile__ ("divwuo. 17, 14, 15");
600 static void test_mulhw_ (void)
602 __asm__ __volatile__ ("mulhw. 17, 14, 15");
605 static void test_mulhwu_ (void)
607 __asm__ __volatile__ ("mulhwu. 17, 14, 15");
610 static void test_mullw_ (void)
612 __asm__ __volatile__ ("mullw. 17, 14, 15");
615 static void test_mullwo_ (void)
617 __asm__ __volatile__ ("mullwo. 17, 14, 15");
620 static void test_subf_ (void)
622 __asm__ __volatile__ ("subf. 17, 14, 15");
625 static void test_subfo_ (void)
627 __asm__ __volatile__ ("subfo. 17, 14, 15");
630 static void test_subfc_ (void)
632 __asm__ __volatile__ ("subfc. 17, 14, 15");
635 static void test_subfco_ (void)
637 __asm__ __volatile__ ("subfco. 17, 14, 15");
641 static void test_mulhd_ (void)
643 __asm__ __volatile__ ("mulhd. 17, 14, 15");
646 static void test_mulhdu_ (void)
648 __asm__ __volatile__ ("mulhdu. 17, 14, 15");
651 static void test_mulld_ (void)
653 __asm__ __volatile__ ("mulld. 17, 14, 15");
656 static void test_divd_ (void)
658 __asm__ __volatile__ ("divd. 17, 14, 15");
661 static void test_divdu_ (void)
663 __asm__ __volatile__ ("divdu. 17, 14, 15");
665 #endif // #ifdef __powerpc64__
667 static test_t tests_iar_ops_two[] = {
668 { &test_add_ , " add.", },
669 { &test_addo_ , " addo.", },
670 { &test_addc_ , " addc.", },
671 { &test_addco_ , " addco.", },
672 { &test_divw_ , " divw.", },
673 { &test_divwo_ , " divwo.", },
674 { &test_divwu_ , " divwu.", },
675 { &test_divwuo_ , " divwuo.", },
676 { &test_mulhw_ , " mulhw.", },
677 { &test_mulhwu_ , " mulhwu.", },
678 { &test_mullw_ , " mullw.", },
679 { &test_mullwo_ , " mullwo.", },
680 { &test_subf_ , " subf.", },
681 { &test_subfo_ , " subfo.", },
682 { &test_subfc_ , " subfc.", },
683 { &test_subfco_ , " subfco.", },
685 { &test_mulhd_ , " mulhd.", },
686 { &test_mulhdu_ , " mulhdu.", },
687 { &test_mulld_ , " mulld.", },
688 { &test_divd_ , " divd.", },
689 { &test_divdu_ , " divdu.", },
690 #endif // #ifdef __powerpc64__
694 static void test_adde (void)
696 __asm__ __volatile__ ("adde 17, 14, 15");
699 static void test_addeo (void)
701 __asm__ __volatile__ ("addeo 17, 14, 15");
704 static void test_subfe (void)
706 __asm__ __volatile__ ("subfe 17, 14, 15");
709 static void test_subfeo (void)
711 __asm__ __volatile__ ("subfeo 17, 14, 15");
714 static test_t tests_iac_ops_two[] = {
715 { &test_adde , " adde", },
716 { &test_addeo , " addeo", },
717 { &test_subfe , " subfe", },
718 { &test_subfeo , " subfeo", },
722 static void test_adde_ (void)
724 __asm__ __volatile__ ("adde. 17, 14, 15");
727 static void test_addeo_ (void)
729 __asm__ __volatile__ ("addeo. 17, 14, 15");
732 static void test_subfe_ (void)
734 __asm__ __volatile__ ("subfe. 17, 14, 15");
737 static void test_subfeo_ (void)
739 __asm__ __volatile__ ("subfeo. 17, 14, 15");
742 static test_t tests_iacr_ops_two[] = {
743 { &test_adde_ , " adde.", },
744 { &test_addeo_ , " addeo.", },
745 { &test_subfe_ , " subfe.", },
746 { &test_subfeo_ , " subfeo.", },
750 static void test_and (void)
752 __asm__ __volatile__ ("and 17, 14, 15");
755 static void test_andc (void)
757 __asm__ __volatile__ ("andc 17, 14, 15");
760 static void test_eqv (void)
762 __asm__ __volatile__ ("eqv 17, 14, 15");
765 static void test_nand (void)
767 __asm__ __volatile__ ("nand 17, 14, 15");
770 static void test_nor (void)
772 __asm__ __volatile__ ("nor 17, 14, 15");
775 static void test_or (void)
777 __asm__ __volatile__ ("or 17, 14, 15");
780 static void test_orc (void)
782 __asm__ __volatile__ ("orc 17, 14, 15");
785 static void test_xor (void)
787 __asm__ __volatile__ ("xor 17, 14, 15");
790 static void test_slw (void)
792 __asm__ __volatile__ ("slw 17, 14, 15");
795 static void test_sraw (void)
797 __asm__ __volatile__ ("sraw 17, 14, 15");
800 static void test_srw (void)
802 __asm__ __volatile__ ("srw 17, 14, 15");
806 static void test_sld (void)
808 __asm__ __volatile__ ("sld 17, 14, 15");
811 static void test_srad (void)
813 __asm__ __volatile__ ("srad 17, 14, 15");
816 static void test_srd (void)
818 __asm__ __volatile__ ("srd 17, 14, 15");
820 #endif // #ifdef __powerpc64__
822 static test_t tests_il_ops_two[] = {
823 { &test_and , " and", },
824 { &test_andc , " andc", },
825 { &test_eqv , " eqv", },
826 { &test_nand , " nand", },
827 { &test_nor , " nor", },
828 { &test_or , " or", },
829 { &test_orc , " orc", },
830 { &test_xor , " xor", },
831 { &test_slw , " slw", },
832 { &test_sraw , " sraw", },
833 { &test_srw , " srw", },
835 { &test_sld , " sld", },
836 { &test_srad , " srad", },
837 { &test_srd , " srd", },
838 #endif // #ifdef __powerpc64__
842 static void test_and_ (void)
844 __asm__ __volatile__ ("and. 17, 14, 15");
847 static void test_andc_ (void)
849 __asm__ __volatile__ ("andc. 17, 14, 15");
852 static void test_eqv_ (void)
854 __asm__ __volatile__ ("eqv. 17, 14, 15");
857 static void test_nand_ (void)
859 __asm__ __volatile__ ("nand. 17, 14, 15");
862 static void test_nor_ (void)
864 __asm__ __volatile__ ("nor. 17, 14, 15");
867 static void test_or_ (void)
869 __asm__ __volatile__ ("or. 17, 14, 15");
872 static void test_orc_ (void)
874 __asm__ __volatile__ ("orc. 17, 14, 15");
877 static void test_xor_ (void)
879 __asm__ __volatile__ ("xor. 17, 14, 15");
882 static void test_slw_ (void)
884 __asm__ __volatile__ ("slw. 17, 14, 15");
887 static void test_sraw_ (void)
889 __asm__ __volatile__ ("sraw. 17, 14, 15");
892 static void test_srw_ (void)
894 __asm__ __volatile__ ("srw. 17, 14, 15");
898 static void test_sld_ (void)
900 __asm__ __volatile__ ("sld. 17, 14, 15");
903 static void test_srad_ (void)
905 __asm__ __volatile__ ("srad. 17, 14, 15");
908 static void test_srd_ (void)
910 __asm__ __volatile__ ("srd. 17, 14, 15");
912 #endif // #ifdef __powerpc64__
914 static test_t tests_ilr_ops_two[] = {
915 { &test_and_ , " and.", },
916 { &test_andc_ , " andc.", },
917 { &test_eqv_ , " eqv.", },
918 { &test_nand_ , " nand.", },
919 { &test_nor_ , " nor.", },
920 { &test_or_ , " or.", },
921 { &test_orc_ , " orc.", },
922 { &test_xor_ , " xor.", },
923 { &test_slw_ , " slw.", },
924 { &test_sraw_ , " sraw.", },
925 { &test_srw_ , " srw.", },
927 { &test_sld_ , " sld.", },
928 { &test_srad_ , " srad.", },
929 { &test_srd_ , " srd.", },
930 #endif // #ifdef __powerpc64__
934 static void test_cmpw (void)
936 __asm__ __volatile__ ("cmpw 2, 14, 15");
939 static void test_cmplw (void)
941 __asm__ __volatile__ ("cmplw 2, 14, 15");
945 static void test_cmpd (void)
947 __asm__ __volatile__ ("cmpd 2, 14, 15");
950 static void test_cmpld (void)
952 __asm__ __volatile__ ("cmpld 2, 14, 15");
954 #endif // #ifdef __powerpc64__
956 static test_t tests_icr_ops_two[] = {
957 { &test_cmpw , " cmpw", },
958 { &test_cmplw , " cmplw", },
960 { &test_cmpd , " cmpd", },
961 { &test_cmpld , " cmpld", },
962 #endif // #ifdef __powerpc64__
966 extern void test_cmpwi (void);
967 ASSEMBLY_FUNC("test_cmpwi", "cmpwi 2, 14, 0");
969 extern void test_cmplwi (void);
970 ASSEMBLY_FUNC("test_cmplwi", "cmplwi 2, 14, 0");
973 extern void test_cmpdi (void);
974 ASSEMBLY_FUNC("test_cmpdi", "cmpdi 2, 14, 0");
976 extern void test_cmpldi (void);
977 ASSEMBLY_FUNC("test_cmpldi", "cmpldi 2, 14, 0");
978 #endif // #ifdef __powerpc64__
980 static test_t tests_icr_ops_two_i16[] = {
981 { &test_cmpwi , " cmpwi", },
982 { &test_cmplwi , " cmplwi", },
984 { &test_cmpdi , " cmpdi", },
985 { &test_cmpldi , " cmpldi", },
986 #endif // #ifdef __powerpc64__
990 extern void test_addi (void);
991 ASSEMBLY_FUNC("test_addi", "addi 17, 14, 0");
993 extern void test_addic (void);
994 ASSEMBLY_FUNC("test_addic", "addic 17, 14, 0");
996 extern void test_addis (void);
997 ASSEMBLY_FUNC("test_addis", "addis 17, 14, 0");
999 extern void test_mulli (void);
1000 ASSEMBLY_FUNC("test_mulli", "mulli 17, 14, 0");
1002 extern void test_subfic (void);
1003 ASSEMBLY_FUNC("test_subfic", "subfic 17, 14, 0");
1005 static test_t tests_ia_ops_two_i16[] = {
1006 { &test_addi , " addi", },
1007 { &test_addic , " addic", },
1008 { &test_addis , " addis", },
1009 { &test_mulli , " mulli", },
1010 { &test_subfic , " subfic", },
1014 extern void test_addic_ (void);
1015 ASSEMBLY_FUNC("test_addic_", "addic. 17, 14, 0");
1017 static test_t tests_iar_ops_two_i16[] = {
1018 { &test_addic_ , " addic.", },
1022 extern void test_ori (void);
1023 ASSEMBLY_FUNC("test_ori", "ori 17, 14, 0");
1025 extern void test_oris (void);
1026 ASSEMBLY_FUNC("test_oris", "oris 17, 14, 0");
1028 extern void test_xori (void);
1029 ASSEMBLY_FUNC("test_xori", "xori 17, 14, 0");
1031 extern void test_xoris (void);
1032 ASSEMBLY_FUNC("test_xoris", "xoris 17, 14, 0");
1034 static test_t tests_il_ops_two_i16[] = {
1035 { &test_ori , " ori", },
1036 { &test_oris , " oris", },
1037 { &test_xori , " xori", },
1038 { &test_xoris , " xoris", },
1042 extern void test_andi_ (void);
1043 ASSEMBLY_FUNC("test_andi_", "andi. 17, 14, 0");
1045 extern void test_andis_ (void);
1046 ASSEMBLY_FUNC("test_andis_", "andis. 17, 14, 0");
1048 static test_t tests_ilr_ops_two_i16[] = {
1049 { &test_andi_ , " andi.", },
1050 { &test_andis_ , " andis.", },
1054 static void test_crand (void)
1056 __asm__ __volatile__ ("crand 17, 14, 15");
1059 static void test_crandc (void)
1061 __asm__ __volatile__ ("crandc 17, 14, 15");
1064 static void test_creqv (void)
1066 __asm__ __volatile__ ("creqv 17, 14, 15");
1069 static void test_crnand (void)
1071 __asm__ __volatile__ ("crnand 17, 14, 15");
1074 static void test_crnor (void)
1076 __asm__ __volatile__ ("crnor 17, 14, 15");
1079 static void test_cror (void)
1081 __asm__ __volatile__ ("cror 17, 14, 15");
1084 static void test_crorc (void)
1086 __asm__ __volatile__ ("crorc 17, 14, 15");
1089 static void test_crxor (void)
1091 __asm__ __volatile__ ("crxor 17, 14, 15");
1094 static test_t tests_crl_ops_two[] = {
1095 { &test_crand , " crand", },
1096 { &test_crandc , " crandc", },
1097 { &test_creqv , " creqv", },
1098 { &test_crnand , " crnand", },
1099 { &test_crnor , " crnor", },
1100 { &test_cror , " cror", },
1101 { &test_crorc , " crorc", },
1102 { &test_crxor , " crxor", },
1106 static void test_addme (void)
1108 __asm__ __volatile__ ("addme 17, 14");
1111 static void test_addmeo (void)
1113 __asm__ __volatile__ ("addmeo 17, 14");
1116 static void test_addze (void)
1118 __asm__ __volatile__ ("addze 17, 14");
1121 static void test_addzeo (void)
1123 __asm__ __volatile__ ("addzeo 17, 14");
1126 static void test_subfme (void)
1128 __asm__ __volatile__ ("subfme 17, 14");
1131 static void test_subfmeo (void)
1133 __asm__ __volatile__ ("subfmeo 17, 14");
1136 static void test_subfze (void)
1138 __asm__ __volatile__ ("subfze 17, 14");
1141 static void test_subfzeo (void)
1143 __asm__ __volatile__ ("subfzeo 17, 14");
1146 static test_t tests_iac_ops_one[] = {
1147 { &test_addme , " addme", },
1148 { &test_addmeo , " addmeo", },
1149 { &test_addze , " addze", },
1150 { &test_addzeo , " addzeo", },
1151 { &test_subfme , " subfme", },
1152 { &test_subfmeo , " subfmeo", },
1153 { &test_subfze , " subfze", },
1154 { &test_subfzeo , " subfzeo", },
1158 static void test_addme_ (void)
1160 __asm__ __volatile__ ("addme. 17, 14");
1163 static void test_addmeo_ (void)
1165 __asm__ __volatile__ ("addmeo. 17, 14");
1168 static void test_addze_ (void)
1170 __asm__ __volatile__ ("addze. 17, 14");
1173 static void test_addzeo_ (void)
1175 __asm__ __volatile__ ("addzeo. 17, 14");
1178 static void test_subfme_ (void)
1180 __asm__ __volatile__ ("subfme. 17, 14");
1183 static void test_subfmeo_ (void)
1185 __asm__ __volatile__ ("subfmeo. 17, 14");
1188 static void test_subfze_ (void)
1190 __asm__ __volatile__ ("subfze. 17, 14");
1193 static void test_subfzeo_ (void)
1195 __asm__ __volatile__ ("subfzeo. 17, 14");
1198 static test_t tests_iacr_ops_one[] = {
1199 { &test_addme_ , " addme.", },
1200 { &test_addmeo_ , " addmeo.", },
1201 { &test_addze_ , " addze.", },
1202 { &test_addzeo_ , " addzeo.", },
1203 { &test_subfme_ , " subfme.", },
1204 { &test_subfmeo_ , " subfmeo.", },
1205 { &test_subfze_ , " subfze.", },
1206 { &test_subfzeo_ , " subfzeo.", },
1210 static void test_cntlzw (void)
1212 __asm__ __volatile__ ("cntlzw 17, 14");
1215 static void test_extsb (void)
1217 __asm__ __volatile__ ("extsb 17, 14");
1220 static void test_extsh (void)
1222 __asm__ __volatile__ ("extsh 17, 14");
1225 static void test_neg (void)
1227 __asm__ __volatile__ ("neg 17, 14");
1230 static void test_nego (void)
1232 __asm__ __volatile__ ("nego 17, 14");
1235 #ifdef __powerpc64__
1236 static void test_cntlzd (void)
1238 __asm__ __volatile__ ("cntlzd 17, 14");
1241 static void test_extsw (void)
1243 __asm__ __volatile__ ("extsw 17, 14");
1245 #endif // #ifdef __powerpc64__
1247 static test_t tests_il_ops_one[] = {
1248 { &test_cntlzw , " cntlzw", },
1249 { &test_extsb , " extsb", },
1250 { &test_extsh , " extsh", },
1251 { &test_neg , " neg", },
1252 { &test_nego , " nego", },
1253 #ifdef __powerpc64__
1254 { &test_cntlzd , " cntlzd", },
1255 { &test_extsw , " extsw", },
1256 #endif // #ifdef __powerpc64__
1260 static void test_cntlzw_ (void)
1262 __asm__ __volatile__ ("cntlzw. 17, 14");
1265 static void test_extsb_ (void)
1267 __asm__ __volatile__ ("extsb. 17, 14");
1270 static void test_extsh_ (void)
1272 __asm__ __volatile__ ("extsh. 17, 14");
1275 static void test_neg_ (void)
1277 __asm__ __volatile__ ("neg. 17, 14");
1280 static void test_nego_ (void)
1282 __asm__ __volatile__ ("nego. 17, 14");
1285 #ifdef __powerpc64__
1286 static void test_cntlzd_ (void)
1288 __asm__ __volatile__ ("cntlzd. 17, 14");
1291 static void test_extsw_ (void)
1293 __asm__ __volatile__ ("extsw. 17, 14");
1295 #endif // #ifdef __powerpc64__
1297 static test_t tests_ilr_ops_one[] = {
1298 { &test_cntlzw_ , " cntlzw.", },
1299 { &test_extsb_ , " extsb.", },
1300 { &test_extsh_ , " extsh.", },
1301 { &test_neg_ , " neg.", },
1302 { &test_nego_ , " nego.", },
1303 #ifdef __powerpc64__
1304 { &test_cntlzd_ , " cntlzd.", },
1305 { &test_extsw_ , " extsw.", },
1306 #endif // #ifdef __powerpc64__
1310 extern void test_rlwimi (void);
1311 ASSEMBLY_FUNC("test_rlwimi", "rlwimi 17, 14, 0, 0, 0");
1313 extern void test_rlwinm (void);
1314 ASSEMBLY_FUNC("test_rlwinm", "rlwinm 17, 14, 0, 0, 0");
1316 extern void test_rlwnm (void);
1317 ASSEMBLY_FUNC("test_rlwnm", "rlwnm 17, 14, 15, 0, 0");
1319 extern void test_srawi (void);
1320 ASSEMBLY_FUNC("test_srawi", "srawi 17, 14, 0");
1322 static void test_mfcr (void)
1324 __asm__ __volatile__ ("mfcr 17");
1327 static void test_mfspr (void)
1329 __asm__ __volatile__ ("mfspr 17, 1");
1332 static void test_mtspr (void)
1334 __asm__ __volatile__ ("mtspr 1, 14");
1337 #ifdef __powerpc64__
1338 extern void test_rldcl (void);
1339 ASSEMBLY_FUNC("test_rldcl", "rldcl 17, 14, 15, 0");
1341 extern void test_rldcr (void);
1342 ASSEMBLY_FUNC("test_rldcr", "rldcr 17, 14, 15, 0");
1344 extern void test_rldic (void);
1345 ASSEMBLY_FUNC("test_rldic", "rldic 17, 14, 0, 0");
1347 extern void test_rldicl (void);
1348 ASSEMBLY_FUNC("test_rldicl", "rldicl 17, 14, 0, 0");
1350 extern void test_rldicr (void);
1351 ASSEMBLY_FUNC("test_rldicr", "rldicr 17, 14, 0, 0");
1353 extern void test_rldimi (void);
1354 ASSEMBLY_FUNC("test_rldimi", "rldimi 17, 14, 0, 0");
1356 extern void test_sradi (void);
1357 ASSEMBLY_FUNC("test_sradi", "sradi 17, 14, 0");
1358 #endif // #ifdef __powerpc64__
1360 static test_t tests_il_ops_spe[] = {
1361 { &test_rlwimi , " rlwimi", },
1362 { &test_rlwinm , " rlwinm", },
1363 { &test_rlwnm , " rlwnm", },
1364 { &test_srawi , " srawi", },
1365 { &test_mfcr , " mfcr", },
1366 { &test_mfspr , " mfspr", },
1367 { &test_mtspr , " mtspr", },
1368 #ifdef __powerpc64__
1369 { &test_rldcl , " rldcl", },
1370 { &test_rldcr , " rldcr", },
1371 { &test_rldic , " rldic", },
1372 { &test_rldicl , " rldicl", },
1373 { &test_rldicr , " rldicr", },
1374 { &test_rldimi , " rldimi", },
1375 { &test_sradi , " sradi", },
1376 #endif // #ifdef __powerpc64__
1380 extern void test_rlwimi_ (void);
1381 ASSEMBLY_FUNC("test_rlwimi_", "rlwimi. 17, 14, 0, 0, 0");
1383 extern void test_rlwinm_ (void);
1384 ASSEMBLY_FUNC("test_rlwinm_", "rlwinm. 17, 14, 0, 0, 0");
1386 extern void test_rlwnm_ (void);
1387 ASSEMBLY_FUNC("test_rlwnm_", "rlwnm. 17, 14, 15, 0, 0");
1389 extern void test_srawi_ (void);
1390 ASSEMBLY_FUNC("test_srawi_", "srawi. 17, 14, 0");
1392 extern void test_mcrf (void);
1393 ASSEMBLY_FUNC("test_mcrf", "mcrf 0, 0");
1395 extern void test_mcrxr (void);
1396 ASSEMBLY_FUNC("test_mcrxr", "mcrxr 0");
1398 extern void test_mtcrf (void);
1399 ASSEMBLY_FUNC("test_mtcrf", "mtcrf 0, 14");
1401 #ifdef __powerpc64__
1402 extern void test_rldcl_ (void);
1403 ASSEMBLY_FUNC("test_rldcl_", "rldcl. 17, 14, 15, 0");
1405 extern void test_rldcr_ (void);
1406 ASSEMBLY_FUNC("test_rldcr_", "rldcr. 17, 14, 15, 0");
1408 extern void test_rldic_ (void);
1409 ASSEMBLY_FUNC("test_rldic_", "rldic. 17, 14, 0, 0");
1411 extern void test_rldicl_ (void);
1412 ASSEMBLY_FUNC("test_rldicl_", "rldicl. 17, 14, 0, 0");
1414 extern void test_rldicr_ (void);
1415 ASSEMBLY_FUNC("test_rldicr_", "rldicr. 17, 14, 0, 0");
1417 extern void test_rldimi_ (void);
1418 ASSEMBLY_FUNC("test_rldimi_", "rldimi. 17, 14, 0, 0");
1420 extern void test_sradi_ (void);
1421 ASSEMBLY_FUNC("test_sradi_", "sradi. 17, 14, 0");
1422 #endif // #ifdef __powerpc64__
1424 static test_t tests_ilr_ops_spe[] = {
1425 { &test_rlwimi_ , " rlwimi.", },
1426 { &test_rlwinm_ , " rlwinm.", },
1427 { &test_rlwnm_ , " rlwnm.", },
1428 { &test_srawi_ , " srawi.", },
1429 { &test_mcrf , " mcrf", },
1430 { &test_mcrxr , " mcrxr", },
1431 { &test_mtcrf , " mtcrf", },
1432 #ifdef __powerpc64__
1433 { &test_rldcl_ , " rldcl.", },
1434 { &test_rldcr_ , " rldcr.", },
1435 { &test_rldic_ , " rldic.", },
1436 { &test_rldicl_ , " rldicl.", },
1437 { &test_rldicr_ , " rldicr.", },
1438 { &test_rldimi_ , " rldimi.", },
1439 { &test_sradi_ , " sradi.", },
1440 #endif // #ifdef __powerpc64__
1444 extern void test_lbz (void);
1445 ASSEMBLY_FUNC("test_lbz", "lbz 17,0(14)");
1447 extern void test_lbzu (void);
1448 ASSEMBLY_FUNC("test_lbzu", "lbzu 17,0(14)");
1450 extern void test_lha (void);
1451 ASSEMBLY_FUNC("test_lha", "lha 17,0(14)");
1453 extern void test_lhau (void);
1454 ASSEMBLY_FUNC("test_lhau", "lhau 17,0(14)");
1456 extern void test_lhz (void);
1457 ASSEMBLY_FUNC("test_lhz", "lhz 17,0(14)");
1459 extern void test_lhzu (void);
1460 ASSEMBLY_FUNC("test_lhzu", "lhzu 17,0(14)");
1462 extern void test_lwz (void);
1463 ASSEMBLY_FUNC("test_lwz", "lwz 17,0(14)");
1465 extern void test_lwzu (void);
1466 ASSEMBLY_FUNC("test_lwzu", "lwzu 17,0(14)");
1468 #ifdef __powerpc64__
1469 extern void test_ld (void);
1470 ASSEMBLY_FUNC("test_ld", "ld 17,0(14)");
1472 extern void test_ldu (void);
1473 ASSEMBLY_FUNC("test_ldu", "ldu 17,0(14)");
1475 extern void test_lwa (void);
1476 ASSEMBLY_FUNC("test_lwa", "lwa 17,0(14)");
1477 #endif // #ifdef __powerpc64__
1479 static test_t tests_ild_ops_two_i16[] = {
1480 { &test_lbz , " lbz", },
1481 { &test_lbzu , " lbzu", },
1482 { &test_lha , " lha", },
1483 { &test_lhau , " lhau", },
1484 { &test_lhz , " lhz", },
1485 { &test_lhzu , " lhzu", },
1486 { &test_lwz , " lwz", },
1487 { &test_lwzu , " lwzu", },
1488 #ifdef __powerpc64__
1489 { &test_ld , " ld", },
1490 { &test_ldu , " ldu", },
1491 { &test_lwa , " lwa", },
1492 #endif // #ifdef __powerpc64__
1496 static void test_lbzx (void)
1498 __asm__ __volatile__ ("lbzx 17,14,15");
1501 static void test_lbzux (void)
1503 __asm__ __volatile__ ("lbzux 17,14,15");
1506 static void test_lhax (void)
1508 __asm__ __volatile__ ("lhax 17,14,15");
1511 static void test_lhaux (void)
1513 __asm__ __volatile__ ("lhaux 17,14,15");
1516 static void test_lhzx (void)
1518 __asm__ __volatile__ ("lhzx 17,14,15");
1521 static void test_lhzux (void)
1523 __asm__ __volatile__ ("lhzux 17,14,15");
1526 static void test_lwzx (void)
1528 __asm__ __volatile__ ("lwzx 17,14,15");
1531 static void test_lwzux (void)
1533 __asm__ __volatile__ ("lwzux 17,14,15");
1536 #ifdef __powerpc64__
1537 static void test_ldx (void)
1539 __asm__ __volatile__ ("ldx 17,14,15");
1542 static void test_ldux (void)
1544 __asm__ __volatile__ ("ldux 17,14,15");
1547 static void test_lwax (void)
1549 __asm__ __volatile__ ("lwax 17,14,15");
1552 static void test_lwaux (void)
1554 __asm__ __volatile__ ("lwaux 17,14,15");
1556 #endif // #ifdef __powerpc64__
1558 static test_t tests_ild_ops_two[] = {
1559 { &test_lbzx , " lbzx", },
1560 { &test_lbzux , " lbzux", },
1561 { &test_lhax , " lhax", },
1562 { &test_lhaux , " lhaux", },
1563 { &test_lhzx , " lhzx", },
1564 { &test_lhzux , " lhzux", },
1565 { &test_lwzx , " lwzx", },
1566 { &test_lwzux , " lwzux", },
1567 #ifdef __powerpc64__
1568 { &test_ldx , " ldx", },
1569 { &test_ldux , " ldux", },
1570 { &test_lwax , " lwax", },
1571 { &test_lwaux , " lwaux", },
1572 #endif // #ifdef __powerpc64__
1576 extern void test_stb (void);
1577 ASSEMBLY_FUNC("test_stb", "stb 14,0(15)");
1579 extern void test_stbu (void);
1580 ASSEMBLY_FUNC("test_stbu", "stbu 14,0(15)");
1582 extern void test_sth (void);
1583 ASSEMBLY_FUNC("test_sth", "sth 14,0(15)");
1585 extern void test_sthu (void);
1586 ASSEMBLY_FUNC("test_sthu", "sthu 14,0(15)");
1588 extern void test_stw (void);
1589 ASSEMBLY_FUNC("test_stw", "stw 14,0(15)");
1591 extern void test_stwu (void);
1592 ASSEMBLY_FUNC("test_stwu", "stwu 14,0(15)");
1594 #ifdef __powerpc64__
1595 extern void test_std (void);
1596 ASSEMBLY_FUNC("test_std", "std 14,0(15)");
1598 extern void test_stdu (void);
1599 ASSEMBLY_FUNC("test_stdu", "stdu 14,0(15)");
1600 #endif // #ifdef __powerpc64__
1602 static test_t tests_ist_ops_three_i16[] = {
1603 { &test_stb , " stb", },
1604 { &test_stbu , " stbu", },
1605 { &test_sth , " sth", },
1606 { &test_sthu , " sthu", },
1607 { &test_stw , " stw", },
1608 { &test_stwu , " stwu", },
1609 #ifdef __powerpc64__
1610 { &test_std , " std", },
1611 { &test_stdu , " stdu", },
1612 #endif // #ifdef __powerpc64__
1616 static void test_stbx (void)
1618 __asm__ __volatile__ ("stbx 14,15,16");
1621 static void test_stbux (void)
1623 __asm__ __volatile__ ("stbux 14,15,16");
1626 static void test_sthx (void)
1628 __asm__ __volatile__ ("sthx 14,15,16");
1631 static void test_sthux (void)
1633 __asm__ __volatile__ ("sthux 14,15,16");
1636 static void test_stwx (void)
1638 __asm__ __volatile__ ("stwx 14,15,16");
1641 static void test_stwux (void)
1643 __asm__ __volatile__ ("stwux 14,15,16");
1646 #ifdef __powerpc64__
1647 static void test_stdx (void)
1649 __asm__ __volatile__ ("stdx 14,15,16");
1652 static void test_stdux (void)
1654 __asm__ __volatile__ ("stdux 14,15,16");
1656 #endif // #ifdef __powerpc64__
1658 static test_t tests_ist_ops_three[] = {
1659 { &test_stbx , " stbx", },
1660 { &test_stbux , " stbux", },
1661 { &test_sthx , " sthx", },
1662 { &test_sthux , " sthux", },
1663 { &test_stwx , " stwx", },
1664 { &test_stwux , " stwux", },
1665 #ifdef __powerpc64__
1666 { &test_stdx , " stdx", },
1667 { &test_stdux , " stdux", },
1668 #endif // #ifdef __powerpc64__
1672 #if !defined (NO_FLOAT)
1673 static void test_fsel (void)
1675 __asm__ __volatile__ ("fsel 17, 14, 15, 16");
1678 static void test_fmadd (void)
1680 __asm__ __volatile__ ("fmadd 17, 14, 15, 16");
1683 static void test_fmadds (void)
1685 __asm__ __volatile__ ("fmadds 17, 14, 15, 16");
1688 static void test_fmsub (void)
1690 __asm__ __volatile__ ("fmsub 17, 14, 15, 16");
1693 static void test_fmsubs (void)
1695 __asm__ __volatile__ ("fmsubs 17, 14, 15, 16");
1698 static void test_fnmadd (void)
1700 __asm__ __volatile__ ("fnmadd 17, 14, 15, 16");
1703 static void test_fnmadds (void)
1705 __asm__ __volatile__ ("fnmadds 17, 14, 15, 16");
1708 static void test_fnmsub (void)
1710 __asm__ __volatile__ ("fnmsub 17, 14, 15, 16");
1713 static void test_fnmsubs (void)
1715 __asm__ __volatile__ ("fnmsubs 17, 14, 15, 16");
1718 static test_t tests_fa_ops_three[] = {
1719 { &test_fsel , " fsel", },
1720 { &test_fmadd , " fmadd", },
1721 { &test_fmadds , " fmadds", },
1722 { &test_fmsub , " fmsub", },
1723 { &test_fmsubs , " fmsubs", },
1724 { &test_fnmadd , " fnmadd", },
1725 { &test_fnmadds , " fnmadds", },
1726 { &test_fnmsub , " fnmsub", },
1727 { &test_fnmsubs , " fnmsubs", },
1730 #endif /* !defined (NO_FLOAT) */
1732 #if !defined (NO_FLOAT)
1733 static void test_fsel_ (void)
1735 __asm__ __volatile__ ("fsel. 17, 14, 15, 16");
1738 static void test_fmadd_ (void)
1740 __asm__ __volatile__ ("fmadd. 17, 14, 15, 16");
1743 static void test_fmadds_ (void)
1745 __asm__ __volatile__ ("fmadds. 17, 14, 15, 16");
1748 static void test_fmsub_ (void)
1750 __asm__ __volatile__ ("fmsub. 17, 14, 15, 16");
1753 static void test_fmsubs_ (void)
1755 __asm__ __volatile__ ("fmsubs. 17, 14, 15, 16");
1758 static void test_fnmadd_ (void)
1760 __asm__ __volatile__ ("fnmadd. 17, 14, 15, 16");
1763 static void test_fnmadds_ (void)
1765 __asm__ __volatile__ ("fnmadds. 17, 14, 15, 16");
1768 static void test_fnmsub_ (void)
1770 __asm__ __volatile__ ("fnmsub. 17, 14, 15, 16");
1773 static void test_fnmsubs_ (void)
1775 __asm__ __volatile__ ("fnmsubs. 17, 14, 15, 16");
1778 static test_t tests_far_ops_three[] = {
1779 { &test_fsel_ , " fsel.", },
1780 { &test_fmadd_ , " fmadd.", },
1781 { &test_fmadds_ , " fmadds.", },
1782 { &test_fmsub_ , " fmsub.", },
1783 { &test_fmsubs_ , " fmsubs.", },
1784 { &test_fnmadd_ , " fnmadd.", },
1785 { &test_fnmadds_ , " fnmadds.", },
1786 { &test_fnmsub_ , " fnmsub.", },
1787 { &test_fnmsubs_ , " fnmsubs.", },
1790 #endif /* !defined (NO_FLOAT) */
1792 #if !defined (NO_FLOAT)
1793 static void test_fadd (void)
1795 __asm__ __volatile__ ("fadd 17, 14, 15");
1798 static void test_fadds (void)
1800 __asm__ __volatile__ ("fadds 17, 14, 15");
1803 static void test_fsub (void)
1805 __asm__ __volatile__ ("fsub 17, 14, 15");
1808 static void test_fsubs (void)
1810 __asm__ __volatile__ ("fsubs 17, 14, 15");
1813 static void test_fmul (void)
1815 __asm__ __volatile__ ("fmul 17, 14, 15");
1818 static void test_fmuls (void)
1820 __asm__ __volatile__ ("fmuls 17, 14, 15");
1823 static void test_fdiv (void)
1825 __asm__ __volatile__ ("fdiv 17, 14, 15");
1828 static void test_fdivs (void)
1830 __asm__ __volatile__ ("fdivs 17, 14, 15");
1833 static test_t tests_fa_ops_two[] = {
1834 { &test_fadd , " fadd", },
1835 { &test_fadds , " fadds", },
1836 { &test_fsub , " fsub", },
1837 { &test_fsubs , " fsubs", },
1838 { &test_fmul , " fmul", },
1839 { &test_fmuls , " fmuls", },
1840 { &test_fdiv , " fdiv", },
1841 { &test_fdivs , " fdivs", },
1844 #endif /* !defined (NO_FLOAT) */
1846 #if !defined (NO_FLOAT)
1847 static void test_fadd_ (void)
1849 __asm__ __volatile__ ("fadd. 17, 14, 15");
1852 static void test_fadds_ (void)
1854 __asm__ __volatile__ ("fadds. 17, 14, 15");
1857 static void test_fsub_ (void)
1859 __asm__ __volatile__ ("fsub. 17, 14, 15");
1862 static void test_fsubs_ (void)
1864 __asm__ __volatile__ ("fsubs. 17, 14, 15");
1867 static void test_fmul_ (void)
1869 __asm__ __volatile__ ("fmul. 17, 14, 15");
1872 static void test_fmuls_ (void)
1874 __asm__ __volatile__ ("fmuls. 17, 14, 15");
1877 static void test_fdiv_ (void)
1879 __asm__ __volatile__ ("fdiv. 17, 14, 15");
1882 static void test_fdivs_ (void)
1884 __asm__ __volatile__ ("fdivs. 17, 14, 15");
1887 static test_t tests_far_ops_two[] = {
1888 { &test_fadd_ , " fadd.", },
1889 { &test_fadds_ , " fadds.", },
1890 { &test_fsub_ , " fsub.", },
1891 { &test_fsubs_ , " fsubs.", },
1892 { &test_fmul_ , " fmul.", },
1893 { &test_fmuls_ , " fmuls.", },
1894 { &test_fdiv_ , " fdiv.", },
1895 { &test_fdivs_ , " fdivs.", },
1898 #endif /* !defined (NO_FLOAT) */
1900 #if !defined (NO_FLOAT)
1901 static void test_fcmpo (void)
1903 __asm__ __volatile__ ("fcmpo 2, 14, 15");
1906 static void test_fcmpu (void)
1908 __asm__ __volatile__ ("fcmpu 2, 14, 15");
1911 static test_t tests_fcr_ops_two[] = {
1912 { &test_fcmpo , " fcmpo", },
1913 { &test_fcmpu , " fcmpu", },
1916 #endif /* !defined (NO_FLOAT) */
1918 #if !defined (NO_FLOAT)
1920 #if 0 // TODO: Not yet supported
1921 static void test_fres (void)
1923 __asm__ __volatile__ ("fres 17, 14");
1926 static void test_frsqrte (void)
1928 __asm__ __volatile__ ("frsqrte 17, 14");
1932 static void test_frsp (void)
1934 __asm__ __volatile__ ("frsp 17, 14");
1937 static void test_fctiw (void)
1939 __asm__ __volatile__ ("fctiw 17, 14");
1942 static void test_fctiwz (void)
1944 __asm__ __volatile__ ("fctiwz 17, 14");
1947 static void test_fmr (void)
1949 __asm__ __volatile__ ("fmr 17, 14");
1952 static void test_fneg (void)
1954 __asm__ __volatile__ ("fneg 17, 14");
1957 static void test_fabs (void)
1959 __asm__ __volatile__ ("fabs 17, 14");
1962 static void test_fnabs (void)
1964 __asm__ __volatile__ ("fnabs 17, 14");
1967 static void test_fsqrt (void)
1969 __asm__ __volatile__ ("fsqrt 17, 14");
1972 #ifdef __powerpc64__
1973 static void test_fcfid (void)
1975 __asm__ __volatile__ ("fcfid 17, 14");
1978 static void test_fctid (void)
1980 __asm__ __volatile__ ("fctid 17, 14");
1983 static void test_fctidz (void)
1985 __asm__ __volatile__ ("fctidz 17, 14");
1987 #endif // #ifdef __powerpc64__
1989 static test_t tests_fa_ops_one[] = {
1990 // { &test_fres , " fres", }, // TODO: Not yet supported
1991 // { &test_frsqrte , " frsqrte", }, // TODO: Not yet supported
1992 { &test_frsp , " frsp", },
1993 { &test_fctiw , " fctiw", },
1994 { &test_fctiwz , " fctiwz", },
1995 { &test_fmr , " fmr", },
1996 { &test_fneg , " fneg", },
1997 { &test_fabs , " fabs", },
1998 { &test_fnabs , " fnabs", },
1999 { &test_fsqrt , " fsqrt", },
2000 #ifdef __powerpc64__
2001 { &test_fcfid , " fcfid", },
2002 { &test_fctid , " fctid", },
2003 { &test_fctidz , " fctidz", },
2004 #endif // #ifdef __powerpc64__
2007 #endif /* !defined (NO_FLOAT) */
2009 #if !defined (NO_FLOAT)
2011 #if 0 // TODO: Not yet supported
2012 static void test_fres_ (void)
2014 __asm__ __volatile__ ("fres. 17, 14");
2017 static void test_frsqrte_ (void)
2019 __asm__ __volatile__ ("frsqrte. 17, 14");
2023 static void test_frsp_ (void)
2025 __asm__ __volatile__ ("frsp. 17, 14");
2028 static void test_fctiw_ (void)
2030 __asm__ __volatile__ ("fctiw. 17, 14");
2033 static void test_fctiwz_ (void)
2035 __asm__ __volatile__ ("fctiwz. 17, 14");
2038 static void test_fmr_ (void)
2040 __asm__ __volatile__ ("fmr. 17, 14");
2043 static void test_fneg_ (void)
2045 __asm__ __volatile__ ("fneg. 17, 14");
2048 static void test_fabs_ (void)
2050 __asm__ __volatile__ ("fabs. 17, 14");
2053 static void test_fnabs_ (void)
2055 __asm__ __volatile__ ("fnabs. 17, 14");
2058 #ifdef __powerpc64__
2059 static void test_fcfid_ (void)
2061 __asm__ __volatile__ ("fcfid. 17, 14");
2064 static void test_fctid_ (void)
2066 __asm__ __volatile__ ("fctid. 17, 14");
2069 static void test_fctidz_ (void)
2071 __asm__ __volatile__ ("fctidz. 17, 14");
2073 #endif // #ifdef __powerpc64__
2075 static test_t tests_far_ops_one[] = {
2076 // { &test_fres_ , " fres.", }, // TODO: Not yet supported
2077 // { &test_frsqrte_ , " frsqrte.", }, // TODO: Not yet supported
2078 { &test_frsp_ , " frsp.", },
2079 { &test_fctiw_ , " fctiw.", },
2080 { &test_fctiwz_ , " fctiwz.", },
2081 { &test_fmr_ , " fmr.", },
2082 { &test_fneg_ , " fneg.", },
2083 { &test_fabs_ , " fabs.", },
2084 { &test_fnabs_ , " fnabs.", },
2085 #ifdef __powerpc64__
2086 { &test_fcfid_ , " fcfid.", },
2087 { &test_fctid_ , " fctid.", },
2088 { &test_fctidz_ , " fctidz.", },
2089 #endif // #ifdef __powerpc64__
2092 #endif /* !defined (NO_FLOAT) */
2094 #if !defined (NO_FLOAT)
2095 static test_t tests_fl_ops_spe[] = {
2098 #endif /* !defined (NO_FLOAT) */
2100 #if !defined (NO_FLOAT)
2101 static test_t tests_flr_ops_spe[] = {
2104 #endif /* !defined (NO_FLOAT) */
2107 #if !defined (NO_FLOAT)
2108 extern void test_lfs (void);
2109 ASSEMBLY_FUNC("test_lfs", "lfs 17,0(14)");
2111 extern void test_lfsu (void);
2112 ASSEMBLY_FUNC("test_lfsu", "lfsu 17,0(14)");
2114 extern void test_lfd (void);
2115 ASSEMBLY_FUNC("test_lfd", "lfd 17,0(14)");
2117 extern void test_lfdu (void);
2118 ASSEMBLY_FUNC("test_lfdu", "lfdu 17,0(14)");
2120 static test_t tests_fld_ops_two_i16[] = {
2121 { &test_lfs , " lfs", },
2122 { &test_lfsu , " lfsu", },
2123 { &test_lfd , " lfd", },
2124 { &test_lfdu , " lfdu", },
2127 #endif /* !defined (NO_FLOAT) */
2129 #if !defined (NO_FLOAT)
2130 static void test_lfsx (void)
2132 __asm__ __volatile__ ("lfsx 17,14,15");
2135 static void test_lfsux (void)
2137 __asm__ __volatile__ ("lfsux 17,14,15");
2140 static void test_lfdx (void)
2142 __asm__ __volatile__ ("lfdx 17,14,15");
2145 static void test_lfdux (void)
2147 __asm__ __volatile__ ("lfdux 17,14,15");
2150 static test_t tests_fld_ops_two[] = {
2151 { &test_lfsx , " lfsx", },
2152 { &test_lfsux , " lfsux", },
2153 { &test_lfdx , " lfdx", },
2154 { &test_lfdux , " lfdux", },
2157 #endif /* !defined (NO_FLOAT) */
2159 #if !defined (NO_FLOAT)
2160 extern void test_stfs (void);
2161 ASSEMBLY_FUNC("test_stfs", "stfs 14,0(15)");
2163 extern void test_stfsu (void);
2164 ASSEMBLY_FUNC("test_stfsu", "stfsu 14,0(15)");
2166 extern void test_stfd (void);
2167 ASSEMBLY_FUNC("test_stfd", "stfd 14,0(15)");
2169 extern void test_stfdu (void);
2170 ASSEMBLY_FUNC("test_stfdu", "stfdu 14,0(15)");
2172 static test_t tests_fst_ops_three_i16[] = {
2173 { &test_stfs , " stfs", },
2174 { &test_stfsu , " stfsu", },
2175 { &test_stfd , " stfd", },
2176 { &test_stfdu , " stfdu", },
2179 #endif /* !defined (NO_FLOAT) */
2181 #if !defined (NO_FLOAT)
2182 static void test_stfsx (void)
2184 __asm__ __volatile__ ("stfsx 14,15,16");
2187 static void test_stfsux (void)
2189 __asm__ __volatile__ ("stfsux 14,15,16");
2192 static void test_stfdx (void)
2194 __asm__ __volatile__ ("stfdx 14,15,16");
2197 static void test_stfdux (void)
2199 __asm__ __volatile__ ("stfdux 14,15,16");
2202 static test_t tests_fst_ops_three[] = {
2203 { &test_stfsx , " stfsx", },
2204 { &test_stfsux , " stfsux", },
2205 { &test_stfdx , " stfdx", },
2206 { &test_stfdux , " stfdux", },
2209 #endif /* !defined (NO_FLOAT) */
2212 #if defined (HAS_ALTIVEC)
2213 static void test_vmhaddshs (void)
2215 __asm__ __volatile__ ("vmhaddshs 17, 14, 15, 16");
2218 static void test_vmhraddshs (void)
2220 __asm__ __volatile__ ("vmhraddshs 17, 14, 15, 16");
2223 static void test_vmladduhm (void)
2225 __asm__ __volatile__ ("vmladduhm 17, 14, 15, 16");
2228 static void test_vmsumubm (void)
2230 __asm__ __volatile__ ("vmsumubm 17, 14, 15, 16");
2233 static void test_vmsumuhm (void)
2235 __asm__ __volatile__ ("vmsumuhm 17, 14, 15, 16");
2238 static void test_vmsumshs (void)
2240 __asm__ __volatile__ ("vmsumshs 17, 14, 15, 16");
2243 static void test_vmsumuhs (void)
2245 __asm__ __volatile__ ("vmsumuhs 17, 14, 15, 16");
2248 static void test_vmsummbm (void)
2250 __asm__ __volatile__ ("vmsummbm 17, 14, 15, 16");
2253 static void test_vmsumshm (void)
2255 __asm__ __volatile__ ("vmsumshm 17, 14, 15, 16");
2258 static test_t tests_aa_ops_three[] = {
2259 { &test_vmhaddshs , " vmhaddshs", },
2260 { &test_vmhraddshs , " vmhraddshs", },
2261 { &test_vmladduhm , " vmladduhm", },
2262 { &test_vmsumubm , " vmsumubm", },
2263 { &test_vmsumuhm , " vmsumuhm", },
2264 { &test_vmsumshs , " vmsumshs", },
2265 { &test_vmsumuhs , " vmsumuhs", },
2266 { &test_vmsummbm , " vmsummbm", },
2267 { &test_vmsumshm , " vmsumshm", },
2270 #endif /* defined (HAS_ALTIVEC) */
2272 #if defined (HAS_ALTIVEC)
2273 static void test_vperm (void)
2275 __asm__ __volatile__ ("vperm 17, 14, 15, 16");
2278 static void test_vsel (void)
2280 __asm__ __volatile__ ("vsel 17, 14, 15, 16");
2283 static test_t tests_al_ops_three[] = {
2284 { &test_vperm , " vperm", },
2285 { &test_vsel , " vsel", },
2288 #endif /* defined (HAS_ALTIVEC) */
2290 #if defined (HAS_ALTIVEC)
2291 static void test_vaddubm (void)
2293 __asm__ __volatile__ ("vaddubm 17, 14, 15");
2296 static void test_vadduhm (void)
2298 __asm__ __volatile__ ("vadduhm 17, 14, 15");
2301 static void test_vadduwm (void)
2303 __asm__ __volatile__ ("vadduwm 17, 14, 15");
2306 static void test_vaddubs (void)
2308 __asm__ __volatile__ ("vaddubs 17, 14, 15");
2311 static void test_vadduhs (void)
2313 __asm__ __volatile__ ("vadduhs 17, 14, 15");
2316 static void test_vadduws (void)
2318 __asm__ __volatile__ ("vadduws 17, 14, 15");
2321 static void test_vaddsbs (void)
2323 __asm__ __volatile__ ("vaddsbs 17, 14, 15");
2326 static void test_vaddshs (void)
2328 __asm__ __volatile__ ("vaddshs 17, 14, 15");
2331 static void test_vaddsws (void)
2333 __asm__ __volatile__ ("vaddsws 17, 14, 15");
2336 static void test_vaddcuw (void)
2338 __asm__ __volatile__ ("vaddcuw 17, 14, 15");
2341 static void test_vsububm (void)
2343 __asm__ __volatile__ ("vsububm 17, 14, 15");
2346 static void test_vsubuhm (void)
2348 __asm__ __volatile__ ("vsubuhm 17, 14, 15");
2351 static void test_vsubuwm (void)
2353 __asm__ __volatile__ ("vsubuwm 17, 14, 15");
2356 static void test_vsububs (void)
2358 __asm__ __volatile__ ("vsububs 17, 14, 15");
2361 static void test_vsubuhs (void)
2363 __asm__ __volatile__ ("vsubuhs 17, 14, 15");
2366 static void test_vsubuws (void)
2368 __asm__ __volatile__ ("vsubuws 17, 14, 15");
2371 static void test_vsubsbs (void)
2373 __asm__ __volatile__ ("vsubsbs 17, 14, 15");
2376 static void test_vsubshs (void)
2378 __asm__ __volatile__ ("vsubshs 17, 14, 15");
2381 static void test_vsubsws (void)
2383 __asm__ __volatile__ ("vsubsws 17, 14, 15");
2386 static void test_vsubcuw (void)
2388 __asm__ __volatile__ ("vsubcuw 17, 14, 15");
2391 static void test_vmuloub (void)
2393 __asm__ __volatile__ ("vmuloub 17, 14, 15");
2396 static void test_vmulouh (void)
2398 __asm__ __volatile__ ("vmulouh 17, 14, 15");
2401 static void test_vmulosb (void)
2403 __asm__ __volatile__ ("vmulosb 17, 14, 15");
2406 static void test_vmulosh (void)
2408 __asm__ __volatile__ ("vmulosh 17, 14, 15");
2411 static void test_vmuleub (void)
2413 __asm__ __volatile__ ("vmuleub 17, 14, 15");
2416 static void test_vmuleuh (void)
2418 __asm__ __volatile__ ("vmuleuh 17, 14, 15");
2421 static void test_vmulesb (void)
2423 __asm__ __volatile__ ("vmulesb 17, 14, 15");
2426 static void test_vmulesh (void)
2428 __asm__ __volatile__ ("vmulesh 17, 14, 15");
2431 static void test_vsumsws (void)
2433 __asm__ __volatile__ ("vsumsws 17, 14, 15");
2436 static void test_vsum2sws (void)
2438 __asm__ __volatile__ ("vsum2sws 17, 14, 15");
2441 static void test_vsum4ubs (void)
2443 __asm__ __volatile__ ("vsum4ubs 17, 14, 15");
2446 static void test_vsum4sbs (void)
2448 __asm__ __volatile__ ("vsum4sbs 17, 14, 15");
2451 static void test_vsum4shs (void)
2453 __asm__ __volatile__ ("vsum4shs 17, 14, 15");
2456 static void test_vavgub (void)
2458 __asm__ __volatile__ ("vavgub 17, 14, 15");
2461 static void test_vavguh (void)
2463 __asm__ __volatile__ ("vavguh 17, 14, 15");
2466 static void test_vavguw (void)
2468 __asm__ __volatile__ ("vavguw 17, 14, 15");
2471 static void test_vavgsb (void)
2473 __asm__ __volatile__ ("vavgsb 17, 14, 15");
2476 static void test_vavgsh (void)
2478 __asm__ __volatile__ ("vavgsh 17, 14, 15");
2481 static void test_vavgsw (void)
2483 __asm__ __volatile__ ("vavgsw 17, 14, 15");
2486 static void test_vmaxub (void)
2488 __asm__ __volatile__ ("vmaxub 17, 14, 15");
2491 static void test_vmaxuh (void)
2493 __asm__ __volatile__ ("vmaxuh 17, 14, 15");
2496 static void test_vmaxuw (void)
2498 __asm__ __volatile__ ("vmaxuw 17, 14, 15");
2501 static void test_vmaxsb (void)
2503 __asm__ __volatile__ ("vmaxsb 17, 14, 15");
2506 static void test_vmaxsh (void)
2508 __asm__ __volatile__ ("vmaxsh 17, 14, 15");
2511 static void test_vmaxsw (void)
2513 __asm__ __volatile__ ("vmaxsw 17, 14, 15");
2516 static void test_vminub (void)
2518 __asm__ __volatile__ ("vminub 17, 14, 15");
2521 static void test_vminuh (void)
2523 __asm__ __volatile__ ("vminuh 17, 14, 15");
2526 static void test_vminuw (void)
2528 __asm__ __volatile__ ("vminuw 17, 14, 15");
2531 static void test_vminsb (void)
2533 __asm__ __volatile__ ("vminsb 17, 14, 15");
2536 static void test_vminsh (void)
2538 __asm__ __volatile__ ("vminsh 17, 14, 15");
2541 static void test_vminsw (void)
2543 __asm__ __volatile__ ("vminsw 17, 14, 15");
2546 static test_t tests_aa_ops_two[] = {
2547 { &test_vaddubm , " vaddubm", },
2548 { &test_vadduhm , " vadduhm", },
2549 { &test_vadduwm , " vadduwm", },
2550 { &test_vaddubs , " vaddubs", },
2551 { &test_vadduhs , " vadduhs", },
2552 { &test_vadduws , " vadduws", },
2553 { &test_vaddsbs , " vaddsbs", },
2554 { &test_vaddshs , " vaddshs", },
2555 { &test_vaddsws , " vaddsws", },
2556 { &test_vaddcuw , " vaddcuw", },
2557 { &test_vsububm , " vsububm", },
2558 { &test_vsubuhm , " vsubuhm", },
2559 { &test_vsubuwm , " vsubuwm", },
2560 { &test_vsububs , " vsububs", },
2561 { &test_vsubuhs , " vsubuhs", },
2562 { &test_vsubuws , " vsubuws", },
2563 { &test_vsubsbs , " vsubsbs", },
2564 { &test_vsubshs , " vsubshs", },
2565 { &test_vsubsws , " vsubsws", },
2566 { &test_vsubcuw , " vsubcuw", },
2567 { &test_vmuloub , " vmuloub", },
2568 { &test_vmulouh , " vmulouh", },
2569 { &test_vmulosb , " vmulosb", },
2570 { &test_vmulosh , " vmulosh", },
2571 { &test_vmuleub , " vmuleub", },
2572 { &test_vmuleuh , " vmuleuh", },
2573 { &test_vmulesb , " vmulesb", },
2574 { &test_vmulesh , " vmulesh", },
2575 { &test_vsumsws , " vsumsws", },
2576 { &test_vsum2sws , " vsum2sws", },
2577 { &test_vsum4ubs , " vsum4ubs", },
2578 { &test_vsum4sbs , " vsum4sbs", },
2579 { &test_vsum4shs , " vsum4shs", },
2580 { &test_vavgub , " vavgub", },
2581 { &test_vavguh , " vavguh", },
2582 { &test_vavguw , " vavguw", },
2583 { &test_vavgsb , " vavgsb", },
2584 { &test_vavgsh , " vavgsh", },
2585 { &test_vavgsw , " vavgsw", },
2586 { &test_vmaxub , " vmaxub", },
2587 { &test_vmaxuh , " vmaxuh", },
2588 { &test_vmaxuw , " vmaxuw", },
2589 { &test_vmaxsb , " vmaxsb", },
2590 { &test_vmaxsh , " vmaxsh", },
2591 { &test_vmaxsw , " vmaxsw", },
2592 { &test_vminub , " vminub", },
2593 { &test_vminuh , " vminuh", },
2594 { &test_vminuw , " vminuw", },
2595 { &test_vminsb , " vminsb", },
2596 { &test_vminsh , " vminsh", },
2597 { &test_vminsw , " vminsw", },
2600 #endif /* defined (HAS_ALTIVEC) */
2602 #if defined (HAS_ALTIVEC)
2603 static void test_vand (void)
2605 __asm__ __volatile__ ("vand 17, 14, 15");
2608 static void test_vor (void)
2610 __asm__ __volatile__ ("vor 17, 14, 15");
2613 static void test_vxor (void)
2615 __asm__ __volatile__ ("vxor 17, 14, 15");
2618 static void test_vandc (void)
2620 __asm__ __volatile__ ("vandc 17, 14, 15");
2623 static void test_vnor (void)
2625 __asm__ __volatile__ ("vnor 17, 14, 15");
2628 static void test_vrlb (void)
2630 __asm__ __volatile__ ("vrlb 17, 14, 15");
2633 static void test_vrlh (void)
2635 __asm__ __volatile__ ("vrlh 17, 14, 15");
2638 static void test_vrlw (void)
2640 __asm__ __volatile__ ("vrlw 17, 14, 15");
2643 static void test_vslb (void)
2645 __asm__ __volatile__ ("vslb 17, 14, 15");
2648 static void test_vslh (void)
2650 __asm__ __volatile__ ("vslh 17, 14, 15");
2653 static void test_vslw (void)
2655 __asm__ __volatile__ ("vslw 17, 14, 15");
2658 static void test_vsrb (void)
2660 __asm__ __volatile__ ("vsrb 17, 14, 15");
2663 static void test_vsrh (void)
2665 __asm__ __volatile__ ("vsrh 17, 14, 15");
2668 static void test_vsrw (void)
2670 __asm__ __volatile__ ("vsrw 17, 14, 15");
2673 static void test_vsrab (void)
2675 __asm__ __volatile__ ("vsrab 17, 14, 15");
2678 static void test_vsrah (void)
2680 __asm__ __volatile__ ("vsrah 17, 14, 15");
2683 static void test_vsraw (void)
2685 __asm__ __volatile__ ("vsraw 17, 14, 15");
2688 static void test_vpkuhum (void)
2690 __asm__ __volatile__ ("vpkuhum 17, 14, 15");
2693 static void test_vpkuwum (void)
2695 __asm__ __volatile__ ("vpkuwum 17, 14, 15");
2698 static void test_vpkuhus (void)
2700 __asm__ __volatile__ ("vpkuhus 17, 14, 15");
2703 static void test_vpkuwus (void)
2705 __asm__ __volatile__ ("vpkuwus 17, 14, 15");
2708 static void test_vpkshus (void)
2710 __asm__ __volatile__ ("vpkshus 17, 14, 15");
2713 static void test_vpkswus (void)
2715 __asm__ __volatile__ ("vpkswus 17, 14, 15");
2718 static void test_vpkshss (void)
2720 __asm__ __volatile__ ("vpkshss 17, 14, 15");
2723 static void test_vpkswss (void)
2725 __asm__ __volatile__ ("vpkswss 17, 14, 15");
2728 static void test_vpkpx (void)
2730 __asm__ __volatile__ ("vpkpx 17, 14, 15");
2733 static void test_vmrghb (void)
2735 __asm__ __volatile__ ("vmrghb 17, 14, 15");
2738 static void test_vmrghh (void)
2740 __asm__ __volatile__ ("vmrghh 17, 14, 15");
2743 static void test_vmrghw (void)
2745 __asm__ __volatile__ ("vmrghw 17, 14, 15");
2748 static void test_vmrglb (void)
2750 __asm__ __volatile__ ("vmrglb 17, 14, 15");
2753 static void test_vmrglh (void)
2755 __asm__ __volatile__ ("vmrglh 17, 14, 15");
2758 static void test_vmrglw (void)
2760 __asm__ __volatile__ ("vmrglw 17, 14, 15");
2763 static void test_vslo (void)
2765 __asm__ __volatile__ ("vslo 17, 14, 15");
2768 static void test_vsro (void)
2770 __asm__ __volatile__ ("vsro 17, 14, 15");
2773 static test_t tests_al_ops_two[] = {
2774 { &test_vand , " vand", },
2775 { &test_vor , " vor", },
2776 { &test_vxor , " vxor", },
2777 { &test_vandc , " vandc", },
2778 { &test_vnor , " vnor", },
2779 { &test_vrlb , " vrlb", },
2780 { &test_vrlh , " vrlh", },
2781 { &test_vrlw , " vrlw", },
2782 { &test_vslb , " vslb", },
2783 { &test_vslh , " vslh", },
2784 { &test_vslw , " vslw", },
2785 { &test_vsrb , " vsrb", },
2786 { &test_vsrh , " vsrh", },
2787 { &test_vsrw , " vsrw", },
2788 { &test_vsrab , " vsrab", },
2789 { &test_vsrah , " vsrah", },
2790 { &test_vsraw , " vsraw", },
2791 { &test_vpkuhum , " vpkuhum", },
2792 { &test_vpkuwum , " vpkuwum", },
2793 { &test_vpkuhus , " vpkuhus", },
2794 { &test_vpkuwus , " vpkuwus", },
2795 { &test_vpkshus , " vpkshus", },
2796 { &test_vpkswus , " vpkswus", },
2797 { &test_vpkshss , " vpkshss", },
2798 { &test_vpkswss , " vpkswss", },
2799 { &test_vpkpx , " vpkpx", },
2800 { &test_vmrghb , " vmrghb", },
2801 { &test_vmrghh , " vmrghh", },
2802 { &test_vmrghw , " vmrghw", },
2803 { &test_vmrglb , " vmrglb", },
2804 { &test_vmrglh , " vmrglh", },
2805 { &test_vmrglw , " vmrglw", },
2806 { &test_vslo , " vslo", },
2807 { &test_vsro , " vsro", },
2810 #endif /* defined (HAS_ALTIVEC) */
2812 #if defined (HAS_ALTIVEC)
2813 static void test_vupkhsb (void)
2815 __asm__ __volatile__ ("vupkhsb 17, 14");
2818 static void test_vupkhsh (void)
2820 __asm__ __volatile__ ("vupkhsh 17, 14");
2823 static void test_vupkhpx (void)
2825 __asm__ __volatile__ ("vupkhpx 17, 14");
2828 static void test_vupklsb (void)
2830 __asm__ __volatile__ ("vupklsb 17, 14");
2833 static void test_vupklsh (void)
2835 __asm__ __volatile__ ("vupklsh 17, 14");
2838 static void test_vupklpx (void)
2840 __asm__ __volatile__ ("vupklpx 17, 14");
2843 static test_t tests_al_ops_one[] = {
2844 { &test_vupkhsb , " vupkhsb", },
2845 { &test_vupkhsh , " vupkhsh", },
2846 { &test_vupkhpx , " vupkhpx", },
2847 { &test_vupklsb , " vupklsb", },
2848 { &test_vupklsh , " vupklsh", },
2849 { &test_vupklpx , " vupklpx", },
2852 #endif /* defined (HAS_ALTIVEC) */
2854 #if defined (HAS_ALTIVEC)
2855 static void test_vcmpgtub (void)
2857 __asm__ __volatile__ ("vcmpgtub 17, 14, 15");
2860 static void test_vcmpgtuh (void)
2862 __asm__ __volatile__ ("vcmpgtuh 17, 14, 15");
2865 static void test_vcmpgtuw (void)
2867 __asm__ __volatile__ ("vcmpgtuw 17, 14, 15");
2870 static void test_vcmpgtsb (void)
2872 __asm__ __volatile__ ("vcmpgtsb 17, 14, 15");
2875 static void test_vcmpgtsh (void)
2877 __asm__ __volatile__ ("vcmpgtsh 17, 14, 15");
2880 static void test_vcmpgtsw (void)
2882 __asm__ __volatile__ ("vcmpgtsw 17, 14, 15");
2885 static void test_vcmpequb (void)
2887 __asm__ __volatile__ ("vcmpequb 17, 14, 15");
2890 static void test_vcmpequh (void)
2892 __asm__ __volatile__ ("vcmpequh 17, 14, 15");
2895 static void test_vcmpequw (void)
2897 __asm__ __volatile__ ("vcmpequw 17, 14, 15");
2900 static test_t tests_ac_ops_two[] = {
2901 { &test_vcmpgtub , " vcmpgtub", },
2902 { &test_vcmpgtuh , " vcmpgtuh", },
2903 { &test_vcmpgtuw , " vcmpgtuw", },
2904 { &test_vcmpgtsb , " vcmpgtsb", },
2905 { &test_vcmpgtsh , " vcmpgtsh", },
2906 { &test_vcmpgtsw , " vcmpgtsw", },
2907 { &test_vcmpequb , " vcmpequb", },
2908 { &test_vcmpequh , " vcmpequh", },
2909 { &test_vcmpequw , " vcmpequw", },
2912 #endif /* defined (HAS_ALTIVEC) */
2914 #if defined (HAS_ALTIVEC)
2915 static void test_vcmpgtub_ (void)
2917 __asm__ __volatile__ ("vcmpgtub. 17, 14, 15");
2920 static void test_vcmpgtuh_ (void)
2922 __asm__ __volatile__ ("vcmpgtuh. 17, 14, 15");
2925 static void test_vcmpgtuw_ (void)
2927 __asm__ __volatile__ ("vcmpgtuw. 17, 14, 15");
2930 static void test_vcmpgtsb_ (void)
2932 __asm__ __volatile__ ("vcmpgtsb. 17, 14, 15");
2935 static void test_vcmpgtsh_ (void)
2937 __asm__ __volatile__ ("vcmpgtsh. 17, 14, 15");
2940 static void test_vcmpgtsw_ (void)
2942 __asm__ __volatile__ ("vcmpgtsw. 17, 14, 15");
2945 static void test_vcmpequb_ (void)
2947 __asm__ __volatile__ ("vcmpequb. 17, 14, 15");
2950 static void test_vcmpequh_ (void)
2952 __asm__ __volatile__ ("vcmpequh. 17, 14, 15");
2955 static void test_vcmpequw_ (void)
2957 __asm__ __volatile__ ("vcmpequw. 17, 14, 15");
2960 static test_t tests_acr_ops_two[] = {
2961 { &test_vcmpgtub_ , " vcmpgtub.", },
2962 { &test_vcmpgtuh_ , " vcmpgtuh.", },
2963 { &test_vcmpgtuw_ , " vcmpgtuw.", },
2964 { &test_vcmpgtsb_ , " vcmpgtsb.", },
2965 { &test_vcmpgtsh_ , " vcmpgtsh.", },
2966 { &test_vcmpgtsw_ , " vcmpgtsw.", },
2967 { &test_vcmpequb_ , " vcmpequb.", },
2968 { &test_vcmpequh_ , " vcmpequh.", },
2969 { &test_vcmpequw_ , " vcmpequw.", },
2972 #endif /* defined (HAS_ALTIVEC) */
2974 #if defined (HAS_ALTIVEC)
2975 static void test_vsl (void)
2977 __asm__ __volatile__ ("vsl 17, 14, 15");
2980 static void test_vsr (void)
2982 __asm__ __volatile__ ("vsr 17, 14, 15");
2985 extern void test_vspltb (void);
2986 ASSEMBLY_FUNC("test_vspltb", "vspltb 17, 14, 0");
2988 extern void test_vsplth (void);
2989 ASSEMBLY_FUNC("test_vsplth", "vsplth 17, 14, 0");
2991 extern void test_vspltw (void);
2992 ASSEMBLY_FUNC("test_vspltw", "vspltw 17, 14, 0");
2994 extern void test_vspltisb (void);
2995 ASSEMBLY_FUNC("test_vspltisb", "vspltisb 17, 0");
2997 extern void test_vspltish (void);
2998 ASSEMBLY_FUNC("test_vspltish", "vspltish 17, 0");
3000 extern void test_vspltisw (void);
3001 ASSEMBLY_FUNC("test_vspltisw", "vspltisw 17, 0");
3003 extern void test_vsldoi (void);
3004 ASSEMBLY_FUNC("test_vsldoi", "vsldoi 17, 14, 15, 0");
3006 static void test_lvsl (void)
3008 __asm__ __volatile__ ("lvsl 17, 14, 15");
3011 static void test_lvsr (void)
3013 __asm__ __volatile__ ("lvsr 17, 14, 15");
3016 static test_t tests_av_int_ops_spe[] = {
3017 { &test_vsl , " vsl", },
3018 { &test_vsr , " vsr", },
3019 { &test_vspltb , " vspltb", },
3020 { &test_vsplth , " vsplth", },
3021 { &test_vspltw , " vspltw", },
3022 { &test_vspltisb , " vspltisb", },
3023 { &test_vspltish , " vspltish", },
3024 { &test_vspltisw , " vspltisw", },
3025 { &test_vsldoi , " vsldoi", },
3026 { &test_lvsl , " lvsl", },
3027 { &test_lvsr , " lvsr", },
3030 #endif /* defined (HAS_ALTIVEC) */
3032 #if defined (HAS_ALTIVEC)
3033 static void test_lvebx (void)
3035 __asm__ __volatile__ ("lvebx 17,14,15");
3038 static void test_lvehx (void)
3040 __asm__ __volatile__ ("lvehx 17,14,15");
3043 static void test_lvewx (void)
3045 __asm__ __volatile__ ("lvewx 17,14,15");
3048 static void test_lvx (void)
3050 __asm__ __volatile__ ("lvx 17,14,15");
3053 static void test_lvxl (void)
3055 __asm__ __volatile__ ("lvxl 17,14,15");
3058 static test_t tests_ald_ops_two[] = {
3059 { &test_lvebx , " lvebx", },
3060 { &test_lvehx , " lvehx", },
3061 { &test_lvewx , " lvewx", },
3062 { &test_lvx , " lvx", },
3063 { &test_lvxl , " lvxl", },
3066 #endif /* defined (HAS_ALTIVEC) */
3068 #if defined (HAS_ALTIVEC)
3069 static void test_stvebx (void)
3071 __asm__ __volatile__ ("stvebx 14,15,16");
3074 static void test_stvehx (void)
3076 __asm__ __volatile__ ("stvehx 14,15,16");
3079 static void test_stvewx (void)
3081 __asm__ __volatile__ ("stvewx 14,15,16");
3084 static void test_stvx (void)
3086 __asm__ __volatile__ ("stvx 14,15,16");
3089 static void test_stvxl (void)
3091 __asm__ __volatile__ ("stvxl 14,15,16");
3094 static test_t tests_ast_ops_three[] = {
3095 { &test_stvebx , " stvebx", },
3096 { &test_stvehx , " stvehx", },
3097 { &test_stvewx , " stvewx", },
3098 { &test_stvx , " stvx", },
3099 { &test_stvxl , " stvxl", },
3102 #endif /* defined (HAS_ALTIVEC) */
3104 #if defined (HAS_ALTIVEC)
3106 static void test_vmaddfp (void)
3108 __asm__ __volatile__ ("vmaddfp 17, 14, 15, 16");
3111 static void test_vnmsubfp (void)
3113 __asm__ __volatile__ ("vnmsubfp 17, 14, 15, 16");
3117 static test_t tests_afa_ops_three[] = {
3118 // { &test_vmaddfp , " vmaddfp", }, // TODO: Not yet supported
3119 // { &test_vnmsubfp , " vnmsubfp", }, // TODO: Not yet supported
3122 #endif /* defined (HAS_ALTIVEC) */
3124 #if defined (HAS_ALTIVEC)
3125 static void test_vaddfp (void)
3127 __asm__ __volatile__ ("vaddfp 17, 14, 15");
3130 static void test_vsubfp (void)
3132 __asm__ __volatile__ ("vsubfp 17, 14, 15");
3135 static void test_vmaxfp (void)
3137 __asm__ __volatile__ ("vmaxfp 17, 14, 15");
3140 static void test_vminfp (void)
3142 __asm__ __volatile__ ("vminfp 17, 14, 15");
3145 static test_t tests_afa_ops_two[] = {
3146 { &test_vaddfp , " vaddfp", },
3147 { &test_vsubfp , " vsubfp", },
3148 { &test_vmaxfp , " vmaxfp", },
3149 { &test_vminfp , " vminfp", },
3152 #endif /* defined (HAS_ALTIVEC) */
3154 #if defined (HAS_ALTIVEC)
3155 static void test_vrfin (void)
3157 __asm__ __volatile__ ("vrfin 17, 14");
3160 static void test_vrfiz (void)
3162 __asm__ __volatile__ ("vrfiz 17, 14");
3165 static void test_vrfip (void)
3167 __asm__ __volatile__ ("vrfip 17, 14");
3170 static void test_vrfim (void)
3172 __asm__ __volatile__ ("vrfim 17, 14");
3175 static void test_vrefp (void)
3177 __asm__ __volatile__ ("vrefp 17, 14");
3180 static void test_vrsqrtefp (void)
3182 __asm__ __volatile__ ("vrsqrtefp 17, 14");
3185 #if 0 // TODO: Not yet supported
3186 static void test_vlogefp (void)
3188 __asm__ __volatile__ ("vlogefp 17, 14");
3191 static void test_vexptefp (void)
3193 __asm__ __volatile__ ("vexptefp 17, 14");
3197 static test_t tests_afa_ops_one[] = {
3198 { &test_vrfin , " vrfin", },
3199 { &test_vrfiz , " vrfiz", },
3200 { &test_vrfip , " vrfip", },
3201 { &test_vrfim , " vrfim", },
3202 { &test_vrefp , " vrefp", },
3203 { &test_vrsqrtefp , " vrsqrtefp", },
3204 // { &test_vlogefp , " vlogefp", }, // TODO: Not yet supported
3205 // { &test_vexptefp , " vexptefp", }, // TODO: Not yet supported
3208 #endif /* defined (HAS_ALTIVEC) */
3210 #if defined (HAS_ALTIVEC)
3211 static void test_vcmpgtfp (void)
3213 __asm__ __volatile__ ("vcmpgtfp 17, 14, 15");
3216 static void test_vcmpeqfp (void)
3218 __asm__ __volatile__ ("vcmpeqfp 17, 14, 15");
3221 static void test_vcmpgefp (void)
3223 __asm__ __volatile__ ("vcmpgefp 17, 14, 15");
3226 static void test_vcmpbfp (void)
3228 __asm__ __volatile__ ("vcmpbfp 17, 14, 15");
3231 static test_t tests_afc_ops_two[] = {
3232 { &test_vcmpgtfp , " vcmpgtfp", },
3233 { &test_vcmpeqfp , " vcmpeqfp", },
3234 { &test_vcmpgefp , " vcmpgefp", },
3235 { &test_vcmpbfp , " vcmpbfp", },
3238 #endif /* defined (HAS_ALTIVEC) */
3240 #if defined (HAS_ALTIVEC)
3241 static void test_vcmpgtfp_ (void)
3243 __asm__ __volatile__ ("vcmpgtfp. 17, 14, 15");
3246 static void test_vcmpeqfp_ (void)
3248 __asm__ __volatile__ ("vcmpeqfp. 17, 14, 15");
3251 static void test_vcmpgefp_ (void)
3253 __asm__ __volatile__ ("vcmpgefp. 17, 14, 15");
3256 static void test_vcmpbfp_ (void)
3258 __asm__ __volatile__ ("vcmpbfp. 17, 14, 15");
3261 static test_t tests_afcr_ops_two[] = {
3262 { &test_vcmpgtfp_ , " vcmpgtfp.", },
3263 { &test_vcmpeqfp_ , " vcmpeqfp.", },
3264 { &test_vcmpgefp_ , " vcmpgefp.", },
3265 { &test_vcmpbfp_ , " vcmpbfp.", },
3268 #endif /* defined (HAS_ALTIVEC) */
3270 #if defined (HAS_ALTIVEC)
3271 extern void test_vcfux (void);
3272 ASSEMBLY_FUNC("test_vcfux", "vcfux 17, 14, 0");
3274 extern void test_vcfsx (void);
3275 ASSEMBLY_FUNC("test_vcfsx", "vcfsx 17, 14, 0");
3277 extern void test_vctuxs (void);
3278 ASSEMBLY_FUNC("test_vctuxs", "vctuxs 17, 14, 0");
3280 extern void test_vctsxs (void);
3281 ASSEMBLY_FUNC("test_vctsxs", "vctsxs 17, 14, 0");
3283 static test_t tests_av_float_ops_spe[] = {
3284 { &test_vcfux , " vcfux", },
3285 { &test_vcfsx , " vcfsx", },
3286 { &test_vctuxs , " vctuxs", },
3287 { &test_vctsxs , " vctsxs", },
3290 #endif /* defined (HAS_ALTIVEC) */
3292 #if defined (IS_PPC405)
3293 static void test_macchw (void)
3295 __asm__ __volatile__ ("macchw 17, 14, 15");
3298 static void test_macchwo (void)
3300 __asm__ __volatile__ ("macchwo 17, 14, 15");
3303 static void test_macchws (void)
3305 __asm__ __volatile__ ("macchws 17, 14, 15");
3308 static void test_macchwso (void)
3310 __asm__ __volatile__ ("macchwso 17, 14, 15");
3313 static void test_macchwsu (void)
3315 __asm__ __volatile__ ("macchwsu 17, 14, 15");
3318 static void test_macchwsuo (void)
3320 __asm__ __volatile__ ("macchwsuo 17, 14, 15");
3323 static void test_macchwu (void)
3325 __asm__ __volatile__ ("macchwu 17, 14, 15");
3328 static void test_macchwuo (void)
3330 __asm__ __volatile__ ("macchwuo 17, 14, 15");
3333 static void test_machhw (void)
3335 __asm__ __volatile__ ("machhw 17, 14, 15");
3338 static void test_machhwo (void)
3340 __asm__ __volatile__ ("machhwo 17, 14, 15");
3343 static void test_machhws (void)
3345 __asm__ __volatile__ ("machhws 17, 14, 15");
3348 static void test_machhwso (void)
3350 __asm__ __volatile__ ("machhwso 17, 14, 15");
3353 static void test_machhwsu (void)
3355 __asm__ __volatile__ ("machhwsu 17, 14, 15");
3358 static void test_machhwsuo (void)
3360 __asm__ __volatile__ ("machhwsuo 17, 14, 15");
3363 static void test_machhwu (void)
3365 __asm__ __volatile__ ("machhwu 17, 14, 15");
3368 static void test_machhwuo (void)
3370 __asm__ __volatile__ ("machhwuo 17, 14, 15");
3373 static void test_maclhw (void)
3375 __asm__ __volatile__ ("maclhw 17, 14, 15");
3378 static void test_maclhwo (void)
3380 __asm__ __volatile__ ("maclhwo 17, 14, 15");
3383 static void test_maclhws (void)
3385 __asm__ __volatile__ ("maclhws 17, 14, 15");
3388 static void test_maclhwso (void)
3390 __asm__ __volatile__ ("maclhwso 17, 14, 15");
3393 static void test_maclhwsu (void)
3395 __asm__ __volatile__ ("maclhwsu 17, 14, 15");
3398 static void test_maclhwsuo (void)
3400 __asm__ __volatile__ ("maclhwsuo 17, 14, 15");
3403 static void test_maclhwu (void)
3405 __asm__ __volatile__ ("maclhwu 17, 14, 15");
3408 static void test_maclhwuo (void)
3410 __asm__ __volatile__ ("maclhwuo 17, 14, 15");
3413 static void test_mulchw (void)
3415 __asm__ __volatile__ ("mulchw 17, 14, 15");
3418 static void test_mulchwu (void)
3420 __asm__ __volatile__ ("mulchwu 17, 14, 15");
3423 static void test_mulhhw (void)
3425 __asm__ __volatile__ ("mulhhw 17, 14, 15");
3428 static void test_mulhhwu (void)
3430 __asm__ __volatile__ ("mulhhwu 17, 14, 15");
3433 static void test_mullhw (void)
3435 __asm__ __volatile__ ("mullhw 17, 14, 15");
3438 static void test_mullhwu (void)
3440 __asm__ __volatile__ ("mullhwu 17, 14, 15");
3443 static void test_nmacchw (void)
3445 __asm__ __volatile__ ("nmacchw 17, 14, 15");
3448 static void test_nmacchwo (void)
3450 __asm__ __volatile__ ("nmacchwo 17, 14, 15");
3453 static void test_nmacchws (void)
3455 __asm__ __volatile__ ("nmacchws 17, 14, 15");
3458 static void test_nmacchwso (void)
3460 __asm__ __volatile__ ("nmacchwso 17, 14, 15");
3463 static void test_nmachhw (void)
3465 __asm__ __volatile__ ("nmachhw 17, 14, 15");
3468 static void test_nmachhwo (void)
3470 __asm__ __volatile__ ("nmachhwo 17, 14, 15");
3473 static void test_nmachhws (void)
3475 __asm__ __volatile__ ("nmachhws 17, 14, 15");
3478 static void test_nmachhwso (void)
3480 __asm__ __volatile__ ("nmachhwso 17, 14, 15");
3483 static void test_nmaclhw (void)
3485 __asm__ __volatile__ ("nmaclhw 17, 14, 15");
3488 static void test_nmaclhwo (void)
3490 __asm__ __volatile__ ("nmaclhwo 17, 14, 15");
3493 static void test_nmaclhws (void)
3495 __asm__ __volatile__ ("nmaclhws 17, 14, 15");
3498 static void test_nmaclhwso (void)
3500 __asm__ __volatile__ ("nmaclhwso 17, 14, 15");
3503 static test_t tests_p4m_ops_two[] = {
3504 { &test_macchw , " macchw", },
3505 { &test_macchwo , " macchwo", },
3506 { &test_macchws , " macchws", },
3507 { &test_macchwso , " macchwso", },
3508 { &test_macchwsu , " macchwsu", },
3509 { &test_macchwsuo , " macchwsuo", },
3510 { &test_macchwu , " macchwu", },
3511 { &test_macchwuo , " macchwuo", },
3512 { &test_machhw , " machhw", },
3513 { &test_machhwo , " machhwo", },
3514 { &test_machhws , " machhws", },
3515 { &test_machhwso , " machhwso", },
3516 { &test_machhwsu , " machhwsu", },
3517 { &test_machhwsuo , " machhwsuo", },
3518 { &test_machhwu , " machhwu", },
3519 { &test_machhwuo , " machhwuo", },
3520 { &test_maclhw , " maclhw", },
3521 { &test_maclhwo , " maclhwo", },
3522 { &test_maclhws , " maclhws", },
3523 { &test_maclhwso , " maclhwso", },
3524 { &test_maclhwsu , " maclhwsu", },
3525 { &test_maclhwsuo , " maclhwsuo", },
3526 { &test_maclhwu , " maclhwu", },
3527 { &test_maclhwuo , " maclhwuo", },
3528 { &test_mulchw , " mulchw", },
3529 { &test_mulchwu , " mulchwu", },
3530 { &test_mulhhw , " mulhhw", },
3531 { &test_mulhhwu , " mulhhwu", },
3532 { &test_mullhw , " mullhw", },
3533 { &test_mullhwu , " mullhwu", },
3534 { &test_nmacchw , " nmacchw", },
3535 { &test_nmacchwo , " nmacchwo", },
3536 { &test_nmacchws , " nmacchws", },
3537 { &test_nmacchwso , " nmacchwso", },
3538 { &test_nmachhw , " nmachhw", },
3539 { &test_nmachhwo , " nmachhwo", },
3540 { &test_nmachhws , " nmachhws", },
3541 { &test_nmachhwso , " nmachhwso", },
3542 { &test_nmaclhw , " nmaclhw", },
3543 { &test_nmaclhwo , " nmaclhwo", },
3544 { &test_nmaclhws , " nmaclhws", },
3545 { &test_nmaclhwso , " nmaclhwso", },
3548 #endif /* defined (IS_PPC405) */
3550 #if defined (IS_PPC405)
3551 static void test_macchw_ (void)
3553 __asm__ __volatile__ ("macchw. 17, 14, 15");
3556 static void test_macchwo_ (void)
3558 __asm__ __volatile__ ("macchwo. 17, 14, 15");
3561 static void test_macchws_ (void)
3563 __asm__ __volatile__ ("macchws. 17, 14, 15");
3566 static void test_macchwso_ (void)
3568 __asm__ __volatile__ ("macchwso. 17, 14, 15");
3571 static void test_macchwsu_ (void)
3573 __asm__ __volatile__ ("macchwsu. 17, 14, 15");
3576 static void test_macchwsuo_ (void)
3578 __asm__ __volatile__ ("macchwsuo. 17, 14, 15");
3581 static void test_macchwu_ (void)
3583 __asm__ __volatile__ ("macchwu. 17, 14, 15");
3586 static void test_macchwuo_ (void)
3588 __asm__ __volatile__ ("macchwuo. 17, 14, 15");
3591 static void test_machhw_ (void)
3593 __asm__ __volatile__ ("machhw. 17, 14, 15");
3596 static void test_machhwo_ (void)
3598 __asm__ __volatile__ ("machhwo. 17, 14, 15");
3601 static void test_machhws_ (void)
3603 __asm__ __volatile__ ("machhws. 17, 14, 15");
3606 static void test_machhwso_ (void)
3608 __asm__ __volatile__ ("machhwso. 17, 14, 15");
3611 static void test_machhwsu_ (void)
3613 __asm__ __volatile__ ("machhwsu. 17, 14, 15");
3616 static void test_machhwsuo_ (void)
3618 __asm__ __volatile__ ("machhwsuo. 17, 14, 15");
3621 static void test_machhwu_ (void)
3623 __asm__ __volatile__ ("machhwu. 17, 14, 15");
3626 static void test_machhwuo_ (void)
3628 __asm__ __volatile__ ("machhwuo. 17, 14, 15");
3631 static void test_maclhw_ (void)
3633 __asm__ __volatile__ ("maclhw. 17, 14, 15");
3636 static void test_maclhwo_ (void)
3638 __asm__ __volatile__ ("maclhwo. 17, 14, 15");
3641 static void test_maclhws_ (void)
3643 __asm__ __volatile__ ("maclhws. 17, 14, 15");
3646 static void test_maclhwso_ (void)
3648 __asm__ __volatile__ ("maclhwso. 17, 14, 15");
3651 static void test_maclhwsu_ (void)
3653 __asm__ __volatile__ ("maclhwsu. 17, 14, 15");
3656 static void test_maclhwsuo_ (void)
3658 __asm__ __volatile__ ("maclhwsuo. 17, 14, 15");
3661 static void test_maclhwu_ (void)
3663 __asm__ __volatile__ ("maclhwu. 17, 14, 15");
3666 static void test_maclhwuo_ (void)
3668 __asm__ __volatile__ ("maclhwuo. 17, 14, 15");
3671 static void test_mulchw_ (void)
3673 __asm__ __volatile__ ("mulchw. 17, 14, 15");
3676 static void test_mulchwu_ (void)
3678 __asm__ __volatile__ ("mulchwu. 17, 14, 15");
3681 static void test_mulhhw_ (void)
3683 __asm__ __volatile__ ("mulhhw. 17, 14, 15");
3686 static void test_mulhhwu_ (void)
3688 __asm__ __volatile__ ("mulhhwu. 17, 14, 15");
3691 static void test_mullhw_ (void)
3693 __asm__ __volatile__ ("mullhw. 17, 14, 15");
3696 static void test_mullhwu_ (void)
3698 __asm__ __volatile__ ("mullhwu. 17, 14, 15");
3701 static void test_nmacchw_ (void)
3703 __asm__ __volatile__ ("nmacchw. 17, 14, 15");
3706 static void test_nmacchwo_ (void)
3708 __asm__ __volatile__ ("nmacchwo. 17, 14, 15");
3711 static void test_nmacchws_ (void)
3713 __asm__ __volatile__ ("nmacchws. 17, 14, 15");
3716 static void test_nmacchwso_ (void)
3718 __asm__ __volatile__ ("nmacchwso. 17, 14, 15");
3721 static void test_nmachhw_ (void)
3723 __asm__ __volatile__ ("nmachhw. 17, 14, 15");
3726 static void test_nmachhwo_ (void)
3728 __asm__ __volatile__ ("nmachhwo. 17, 14, 15");
3731 static void test_nmachhws_ (void)
3733 __asm__ __volatile__ ("nmachhws. 17, 14, 15");
3736 static void test_nmachhwso_ (void)
3738 __asm__ __volatile__ ("nmachhwso. 17, 14, 15");
3741 static void test_nmaclhw_ (void)
3743 __asm__ __volatile__ ("nmaclhw. 17, 14, 15");
3746 static void test_nmaclhwo_ (void)
3748 __asm__ __volatile__ ("nmaclhwo. 17, 14, 15");
3751 static void test_nmaclhws_ (void)
3753 __asm__ __volatile__ ("nmaclhws. 17, 14, 15");
3756 static void test_nmaclhwso_ (void)
3758 __asm__ __volatile__ ("nmaclhwso. 17, 14, 15");
3761 static test_t tests_p4mc_ops_two[] = {
3762 { &test_macchw_ , " macchw.", },
3763 { &test_macchwo_ , " macchwo.", },
3764 { &test_macchws_ , " macchws.", },
3765 { &test_macchwso_ , " macchwso.", },
3766 { &test_macchwsu_ , " macchwsu.", },
3767 { &test_macchwsuo_ , " macchwsuo.", },
3768 { &test_macchwu_ , " macchwu.", },
3769 { &test_macchwuo_ , " macchwuo.", },
3770 { &test_machhw_ , " machhw.", },
3771 { &test_machhwo_ , " machhwo.", },
3772 { &test_machhws_ , " machhws.", },
3773 { &test_machhwso_ , " machhwso.", },
3774 { &test_machhwsu_ , " machhwsu.", },
3775 { &test_machhwsuo_ , " machhwsuo.", },
3776 { &test_machhwu_ , " machhwu.", },
3777 { &test_machhwuo_ , " machhwuo.", },
3778 { &test_maclhw_ , " maclhw.", },
3779 { &test_maclhwo_ , " maclhwo.", },
3780 { &test_maclhws_ , " maclhws.", },
3781 { &test_maclhwso_ , " maclhwso.", },
3782 { &test_maclhwsu_ , " maclhwsu.", },
3783 { &test_maclhwsuo_ , " maclhwsuo.", },
3784 { &test_maclhwu_ , " maclhwu.", },
3785 { &test_maclhwuo_ , " maclhwuo.", },
3786 { &test_mulchw_ , " mulchw.", },
3787 { &test_mulchwu_ , " mulchwu.", },
3788 { &test_mulhhw_ , " mulhhw.", },
3789 { &test_mulhhwu_ , " mulhhwu.", },
3790 { &test_mullhw_ , " mullhw.", },
3791 { &test_mullhwu_ , " mullhwu.", },
3792 { &test_nmacchw_ , " nmacchw.", },
3793 { &test_nmacchwo_ , " nmacchwo.", },
3794 { &test_nmacchws_ , " nmacchws.", },
3795 { &test_nmacchwso_ , " nmacchwso.", },
3796 { &test_nmachhw_ , " nmachhw.", },
3797 { &test_nmachhwo_ , " nmachhwo.", },
3798 { &test_nmachhws_ , " nmachhws.", },
3799 { &test_nmachhwso_ , " nmachhwso.", },
3800 { &test_nmaclhw_ , " nmaclhw.", },
3801 { &test_nmaclhwo_ , " nmaclhwo.", },
3802 { &test_nmaclhws_ , " nmaclhws.", },
3803 { &test_nmaclhwso_ , " nmaclhwso.", },
3806 #endif /* defined (IS_PPC405) */
3808 static test_table_t all_tests[] = {
3811 "PPC integer arith insns with two args",
3816 "PPC integer arith insns with two args with flags update",
3821 "PPC integer arith insns with two args and carry",
3825 tests_iacr_ops_two ,
3826 "PPC integer arith insns with two args and carry with flags update",
3831 "PPC integer logical insns with two args",
3836 "PPC integer logical insns with two args with flags update",
3841 "PPC integer compare insns (two args)",
3845 tests_icr_ops_two_i16 ,
3846 "PPC integer compare with immediate insns (two args)",
3850 tests_ia_ops_two_i16 ,
3851 "PPC integer arith insns\n with one register + one 16 bits immediate args",
3855 tests_iar_ops_two_i16 ,
3856 "PPC integer arith insns\n with one register + one 16 bits immediate args with flags update",
3860 tests_il_ops_two_i16 ,
3861 "PPC integer logical insns\n with one register + one 16 bits immediate args",
3865 tests_ilr_ops_two_i16 ,
3866 "PPC integer logical insns\n with one register + one 16 bits immediate args with flags update",
3871 "PPC condition register logical insns - two operands",
3876 "PPC integer arith insns with one arg and carry",
3880 tests_iacr_ops_one ,
3881 "PPC integer arith insns with one arg and carry with flags update",
3886 "PPC integer logical insns with one arg",
3891 "PPC integer logical insns with one arg with flags update",
3896 "PPC logical insns with special forms",
3901 "PPC logical insns with special forms with flags update",
3905 tests_ild_ops_two_i16 ,
3906 "PPC integer load insns\n with one register + one 16 bits immediate args with flags update",
3911 "PPC integer load insns with two register args",
3915 tests_ist_ops_three_i16,
3916 "PPC integer store insns\n with one register + one 16 bits immediate args with flags update",
3920 tests_ist_ops_three ,
3921 "PPC integer store insns with three register args",
3924 #if !defined (NO_FLOAT)
3926 tests_fa_ops_three ,
3927 "PPC floating point arith insns with three args",
3930 #endif /* !defined (NO_FLOAT) */
3931 #if !defined (NO_FLOAT)
3933 tests_far_ops_three ,
3934 "PPC floating point arith insns\n with three args with flags update",
3937 #endif /* !defined (NO_FLOAT) */
3938 #if !defined (NO_FLOAT)
3941 "PPC floating point arith insns with two args",
3944 #endif /* !defined (NO_FLOAT) */
3945 #if !defined (NO_FLOAT)
3948 "PPC floating point arith insns\n with two args with flags update",
3951 #endif /* !defined (NO_FLOAT) */
3952 #if !defined (NO_FLOAT)
3955 "PPC floating point compare insns (two args)",
3958 #endif /* !defined (NO_FLOAT) */
3959 #if !defined (NO_FLOAT)
3962 "PPC floating point arith insns with one arg",
3965 #endif /* !defined (NO_FLOAT) */
3966 #if !defined (NO_FLOAT)
3969 "PPC floating point arith insns\n with one arg with flags update",
3972 #endif /* !defined (NO_FLOAT) */
3973 #if !defined (NO_FLOAT)
3976 "PPC floating point status register manipulation insns",
3979 #endif /* !defined (NO_FLOAT) */
3980 #if !defined (NO_FLOAT)
3983 "PPC floating point status register manipulation insns\n with flags update",
3986 #endif /* !defined (NO_FLOAT) */
3987 #if !defined (NO_FLOAT)
3989 tests_fld_ops_two_i16 ,
3990 "PPC float load insns\n with one register + one 16 bits immediate args with flags update",
3993 #endif /* !defined (NO_FLOAT) */
3994 #if !defined (NO_FLOAT)
3997 "PPC float load insns with two register args",
4000 #endif /* !defined (NO_FLOAT) */
4001 #if !defined (NO_FLOAT)
4003 tests_fst_ops_three_i16,
4004 "PPC float store insns\n with one register + one 16 bits immediate args with flags update",
4007 #endif /* !defined (NO_FLOAT) */
4008 #if !defined (NO_FLOAT)
4010 tests_fst_ops_three ,
4011 "PPC float store insns with three register args",
4014 #endif /* !defined (NO_FLOAT) */
4015 #if defined (HAS_ALTIVEC)
4017 tests_aa_ops_three ,
4018 "PPC altivec integer arith insns with three args",
4021 #endif /* defined (HAS_ALTIVEC) */
4022 #if defined (HAS_ALTIVEC)
4024 tests_al_ops_three ,
4025 "PPC altivec integer logical insns with three args",
4028 #endif /* defined (HAS_ALTIVEC) */
4029 #if defined (HAS_ALTIVEC)
4032 "PPC altivec integer arith insns with two args",
4035 #endif /* defined (HAS_ALTIVEC) */
4036 #if defined (HAS_ALTIVEC)
4039 "PPC altivec integer logical insns with two args",
4042 #endif /* defined (HAS_ALTIVEC) */
4043 #if defined (HAS_ALTIVEC)
4046 "PPC altivec integer logical insns with one arg",
4049 #endif /* defined (HAS_ALTIVEC) */
4050 #if defined (HAS_ALTIVEC)
4053 "Altivec integer compare insns",
4056 #endif /* defined (HAS_ALTIVEC) */
4057 #if defined (HAS_ALTIVEC)
4060 "Altivec integer compare insns with flags update",
4063 #endif /* defined (HAS_ALTIVEC) */
4064 #if defined (HAS_ALTIVEC)
4066 tests_av_int_ops_spe ,
4067 "Altivec integer special insns",
4070 #endif /* defined (HAS_ALTIVEC) */
4071 #if defined (HAS_ALTIVEC)
4074 "Altivec load insns with two register args",
4077 #endif /* defined (HAS_ALTIVEC) */
4078 #if defined (HAS_ALTIVEC)
4080 tests_ast_ops_three ,
4081 "Altivec store insns with three register args",
4084 #endif /* defined (HAS_ALTIVEC) */
4085 #if defined (HAS_ALTIVEC)
4087 tests_afa_ops_three ,
4088 "Altivec floating point arith insns with three args",
4091 #endif /* defined (HAS_ALTIVEC) */
4092 #if defined (HAS_ALTIVEC)
4095 "Altivec floating point arith insns with two args",
4098 #endif /* defined (HAS_ALTIVEC) */
4099 #if defined (HAS_ALTIVEC)
4102 "Altivec floating point arith insns with one arg",
4105 #endif /* defined (HAS_ALTIVEC) */
4106 #if defined (HAS_ALTIVEC)
4109 "Altivec floating point compare insns",
4112 #endif /* defined (HAS_ALTIVEC) */
4113 #if defined (HAS_ALTIVEC)
4115 tests_afcr_ops_two ,
4116 "Altivec floating point compare insns with flags update",
4119 #endif /* defined (HAS_ALTIVEC) */
4120 #if defined (HAS_ALTIVEC)
4122 tests_av_float_ops_spe,
4123 "Altivec float special insns",
4126 #endif /* defined (HAS_ALTIVEC) */
4127 #if defined (IS_PPC405)
4130 "PPC 405 mac insns with three args",
4133 #endif /* defined (IS_PPC405) */
4134 #if defined (IS_PPC405)
4136 tests_p4mc_ops_two ,
4137 "PPC 405 mac insns with three args with flags update",
4140 #endif /* defined (IS_PPC405) */
4141 { NULL, NULL, 0x00000000, },
4144 /* -------------- END #include "ops-ppc.c" -------------- */
4146 static int verbose = 0;
4147 static int arg_list_size = 0;
4149 static double *fargs = NULL;
4150 static int nb_fargs = 0;
4151 static int nb_normal_fargs = 0;
4152 static HWord_t *iargs = NULL;
4153 static int nb_iargs = 0;
4154 static uint16_t *ii16 = NULL;
4155 static int nb_ii16 = 0;
4157 #if defined (HAS_ALTIVEC)
4158 static vector unsigned int* viargs = NULL;
4159 static int nb_viargs = 0;
4160 static vector float* vfargs = NULL;
4161 static int nb_vfargs = 0;
4163 //#define TEST_VSCR_SAT
4166 static inline void register_farg (void *farg,
4167 int s, uint16_t _exp, uint64_t mant)
4171 tmp = ((uint64_t)s << 63) | ((uint64_t)_exp << 52) | mant;
4172 *(uint64_t *)farg = tmp;
4173 #ifndef __powerpc64__
4174 AB_DPRINTF("%d %03x %013llx => %016llx %0e\n",
4176 AB_DPRINTF("%d %03x %013lx => %016lx %0e\n",
4178 s, _exp, mant, *(uint64_t *)farg, *(double *)farg);
4181 static void build_fargs_table (void)
4183 /* Double precision:
4184 * Sign goes from zero to one (1 bit)
4185 * Exponent goes from 0 to ((1 << 12) - 1) (11 bits)
4186 * Mantissa goes from 1 to ((1 << 52) - 1) (52 bits)
4188 * +0.0 : 0 0x000 0x0000000000000 => 0x0000000000000000
4189 * -0.0 : 1 0x000 0x0000000000000 => 0x8000000000000000
4190 * +infinity : 0 0x7FF 0x0000000000000 => 0x7FF0000000000000
4191 * -infinity : 1 0x7FF 0x0000000000000 => 0xFFF0000000000000
4192 * +QNaN : 0 0x7FF 0x7FFFFFFFFFFFF => 0x7FF7FFFFFFFFFFFF
4193 * -QNaN : 1 0x7FF 0x7FFFFFFFFFFFF => 0xFFF7FFFFFFFFFFFF
4194 * +SNaN : 0 0x7FF 0x8000000000000 => 0x7FF8000000000000
4195 * -SNaN : 1 0x7FF 0x8000000000000 => 0xFFF8000000000000
4203 * +0.0 : 0 0x00 0x000000 => 0x00000000
4204 * -0.0 : 1 0x00 0x000000 => 0x80000000
4205 * +infinity : 0 0xFF 0x000000 => 0x7F800000
4206 * -infinity : 1 0xFF 0x000000 => 0xFF800000
4207 * +QNaN : 0 0xFF 0x3FFFFF => 0x7FBFFFFF
4208 * -QNaN : 1 0xFF 0x3FFFFF => 0xFFBFFFFF
4209 * +SNaN : 0 0xFF 0x400000 => 0x7FC00000
4210 * -SNaN : 1 0xFF 0x400000 => 0xFFC00000
4213 uint16_t _exp, e0, e1;
4217 /* Note: VEX isn't so hot with denormals, so don't bother
4218 testing them: set _exp > 0
4221 if ( arg_list_size == 1 ) { // Large
4222 fargs = malloc(200 * sizeof(double));
4223 for (s=0; s<2; s++) {
4224 for (e0=0; e0<2; e0++) {
4225 for (e1=0x001; ; e1 = ((e1 + 1) << 2) + 6) {
4228 _exp = (e0 << 10) | e1;
4229 for (mant = 0x0000000000001ULL; mant < (1ULL << 52);
4230 /* Add 'random' bits */
4231 mant = ((mant + 0x4A6) << 13) + 0x359) {
4232 register_farg(&fargs[i++], s, _exp, mant);
4240 fargs = malloc(16 * sizeof(double));
4241 for (s=0; s<2; s++) { // x2
4242 // for (e0=0; e0<2; e0++) {
4243 for (e1=0x001; ; e1 = ((e1 + 1) << 13) + 7) { // x2
4244 // for (e1=0x001; ; e1 = ((e1 + 1) << 5) + 7) { // x3
4247 // _exp = (e0 << 10) | e1;
4249 for (mant = 0x0000000000001ULL; mant < (1ULL << 52);
4250 /* Add 'random' bits */
4251 mant = ((mant + 0x4A6) << 29) + 0x359) { // x2
4252 register_farg(&fargs[i++], s, _exp, mant);
4261 /* To iterate over non-special values only */
4262 nb_normal_fargs = i;
4265 /* Special values */
4266 /* +0.0 : 0 0x000 0x0000000000000 */
4269 mant = 0x0000000000000ULL;
4270 register_farg(&fargs[i++], s, _exp, mant);
4271 /* -0.0 : 1 0x000 0x0000000000000 */
4274 mant = 0x0000000000000ULL;
4275 register_farg(&fargs[i++], s, _exp, mant);
4276 /* +infinity : 0 0x7FF 0x0000000000000 */
4279 mant = 0x0000000000000ULL;
4280 register_farg(&fargs[i++], s, _exp, mant);
4281 /* -infinity : 1 0x7FF 0x0000000000000 */
4284 mant = 0x0000000000000ULL;
4285 register_farg(&fargs[i++], s, _exp, mant);
4286 /* +QNaN : 0 0x7FF 0x7FFFFFFFFFFFF */
4289 mant = 0x7FFFFFFFFFFFFULL;
4290 register_farg(&fargs[i++], s, _exp, mant);
4291 /* -QNaN : 1 0x7FF 0x7FFFFFFFFFFFF */
4294 mant = 0x7FFFFFFFFFFFFULL;
4295 register_farg(&fargs[i++], s, _exp, mant);
4296 /* +SNaN : 0 0x7FF 0x8000000000000 */
4299 mant = 0x8000000000000ULL;
4300 register_farg(&fargs[i++], s, _exp, mant);
4301 /* -SNaN : 1 0x7FF 0x8000000000000 */
4304 mant = 0x8000000000000ULL;
4305 register_farg(&fargs[i++], s, _exp, mant);
4306 AB_DPRINTF("Registered %d fargs values\n", i);
4311 static void build_iargs_table (void)
4316 #ifndef __powerpc64__
4317 if (arg_list_size == 1) { // Large
4318 iargs = malloc(400 * sizeof(HWord_t));
4319 for (tmp=0; ; tmp = tmp + 1 + (tmp >> 1)) {
4320 if (tmp >= 0x100000000ULL)
4322 iargs[i++] = (HWord_t)tmp;
4323 AB_DPRINTF("val %08x\n", (HWord_t)tmp);
4324 if (tmp == 0xFFFFFFFF)
4328 iargs = malloc(10 * sizeof(HWord_t));
4329 // for (tmp = 0; ; tmp = 71*tmp + 1 + (tmp>>1)) { // gives 8
4330 // for (tmp = 0; ; tmp = 100000*tmp + 1 + (tmp>>1)) { // gives 4
4331 for (tmp=0; ; tmp = 999999*tmp + 999999) { // gives 3
4332 if (tmp >= 0x100000000ULL)
4334 iargs[i++] = (HWord_t)tmp;
4335 AB_DPRINTF("val %08x\n", (HWord_t)tmp);
4336 if (tmp == 0xFFFFFFFF)
4341 if (arg_list_size == 1) { // Large
4342 iargs = malloc(800 * sizeof(HWord_t));
4343 for (tmp=0; ; tmp = 2*tmp + 1 + (tmp >> 2)) {
4345 tmp = 0xFFFFFFFFFFFFFFFFULL;
4347 AB_DPRINTF("val %016lx\n", tmp);
4348 if (tmp == 0xFFFFFFFFFFFFFFFFULL)
4352 iargs = malloc(20 * sizeof(HWord_t));
4353 // for (tmp=0; ; tmp = 9999*tmp + 999999) { // gives 6
4354 for (tmp = 0; ; tmp = 123456789*tmp + 123456789999) { // gives 3
4356 tmp = 0xFFFFFFFFFFFFFFFFULL;
4358 AB_DPRINTF("val %016lx\n", tmp);
4359 if (tmp == 0xFFFFFFFFFFFFFFFFULL)
4363 #endif // #ifndef __powerpc64__
4365 AB_DPRINTF("Registered %d iargs values\n", i);
4369 static void build_ii16_table (void)
4374 if (arg_list_size == 1) { // Large
4375 ii16 = malloc(200 * sizeof(uint32_t));
4376 for (tmp=0; ; tmp = tmp + 1 + (tmp >> 2)) {
4380 AB_DPRINTF("val %04x\n", tmp);
4385 ii16 = malloc(10 * sizeof(uint32_t));
4386 for (tmp=0; ; tmp = 999*tmp + 999) { // gives 3
4390 AB_DPRINTF("val %04x\n", tmp);
4395 AB_DPRINTF("Registered %d ii16 values\n", i);
4399 #if defined (HAS_ALTIVEC)
4400 static void build_viargs_table (void)
4402 #if !defined (ALTIVEC_ARGS_LARGE)
4404 viargs = memalign16(i * sizeof(vector unsigned int));
4405 viargs[0] = (vector unsigned int) { 0x01020304,0x05060708,0x090A0B0C,0x0E0D0E0F };
4406 AB_DPRINTF_VEC32x4( viargs[0] );
4407 viargs[1] = (vector unsigned int) { 0xF1F2F3F4,0xF5F6F7F8,0xF9FAFBFC,0xFEFDFEFF };
4408 AB_DPRINTF_VEC32x4( viargs[1] );
4411 // build from iargs table (large/default already set)
4412 viargs = malloc(nb_iargs * sizeof(vector unsigned int));
4413 for (i=0; i<nb_iargs; i++) {
4415 viargs[i] = (vector unsigned int){ j, j*2, j*3, j*4 };
4416 AB_DPRINTF_VEC32x4( viargs[i] );
4420 AB_DPRINTF("Registered %d viargs values\n", i);
4424 static inline void register_vfarg (vector float* vfarg,
4425 int s, uint8_t _exp, uint32_t mant)
4428 vector uint32_t* vfargI = (vector uint32_t*)vfarg;
4430 tmp = ((uint64_t)s << 31) | ((uint64_t)_exp << 23) | mant;
4431 *vfargI = (vector uint32_t){ tmp,tmp,tmp,tmp };
4432 AB_DPRINTF("%d %02x %06x => %08x %0e\n",
4433 s, _exp, mant, *((uint32_t*)&tmp), *(float*)&tmp);
4436 static void build_vfargs_table (void)
4438 /* Sign goes from zero to one
4439 * Exponent goes from 0 to ((1 << 9) - 1)
4440 * Mantissa goes from 1 to ((1 << 24) - 1)
4442 * +0.0 : 0 0x00 0x000000 => 0x00000000
4443 * -0.0 : 1 0x00 0x000000 => 0x80000000
4444 * +infinity : 0 0xFF 0x000000 => 0x7F800000
4445 * -infinity : 1 0xFF 0x000000 => 0xFF800000
4446 * +SNaN : 0 0xFF 0x7FFFFF (non-zero) => 0x7FFFFFFF
4447 * -SNaN : 1 0xFF 0x7FFFFF (non-zero) => 0xFFFFFFFF
4448 * +QNaN : 0 0xFF 0x3FFFFF (non-zero) => 0x7FBFFFFF
4449 * -QNaN : 1 0xFF 0x3FFFFF (non-zero) => 0xFFBFFFFF
4458 #if !defined (ALTIVEC_ARGS_LARGE)
4460 vfargs = memalign16(nb_vfargs * sizeof(vector float));
4463 for (s=0; s<2; s++) {
4464 for (_exp=0x5; ; _exp += 0x9D ) {
4467 for (mant = 0x3FFFFF; mant < 0x7FFFFF;
4468 mant = /* random */ ((mant + 0x1A6) << 31) + 0x159) {
4469 register_vfarg(&vfargs[i++], s, (uint8_t)_exp, mant);
4475 vfargs = memalign16(nb_vfargs * sizeof(vector float));
4477 for (s=0; s<2; s++) {
4478 for (_exp=0x0; ; _exp += 0x3F ) {
4479 // for (_exp=0; ; _exp = ((_exp + 1) << 1) + 3) {
4482 for (mant = 0x0; mant < 0x7FFFFF;
4483 mant = /* random */ ((mant + 0x4A6) << 5) + 0x359) {
4484 register_vfarg(&vfargs[i++], s, (uint8_t)_exp, mant);
4492 /* Special values */
4493 /* +0.0 : 0 0x00 0x000000 */
4497 register_vfarg(&vfargs[i++], s, _exp, mant);
4498 /* -0.0 : 1 0x00 0x000000 */
4502 register_vfarg(&vfargs[i++], s, _exp, mant);
4504 /* +infinity : 0 0xFF 0x000000 */
4508 register_vfarg(&vfargs[i++], s, _exp, mant);
4509 /* -infinity : 1 0xFF 0x000000 */
4513 register_vfarg(&vfargs[i++], s, _exp, mant);
4515 /* NaN: _exponent all 1s, non-zero fraction */
4516 /* SNaN is a NaN with the most significant fraction bit clear.*/
4517 /* +SNaN : 0 0xFF 0x7FFFFF */
4521 register_vfarg(&vfargs[i++], s, _exp, mant);
4522 /* -SNaN : 1 0xFF 0x7FFFFF */
4526 register_vfarg(&vfargs[i++], s, _exp, mant);
4528 /* QNaN is a NaN with the most significant fraction bit set */
4529 /* +QNaN : 0 0xFF 0x3F0000 */
4533 register_vfarg(&vfargs[i++], s, _exp, mant);
4534 /* -QNaN : 1 0xFF 0x3F0000 */
4538 register_vfarg(&vfargs[i++], s, _exp, mant);
4539 AB_DPRINTF("Registered %d vfargs values\n", i);
4541 assert(i <= nb_vfargs);
4547 static void dump_iargs (void)
4550 for (i = 0; i < nb_iargs; i++) {
4551 printf("iarg %d: %08x %08x %08x\n", i, iargs[i],
4552 (unsigned int)&iargs[i], (unsigned int)iargs);
4556 static void dump_iargs16 (void)
4559 for (i = 0; i < nb_ii16; i++) {
4560 printf("iarg16 %d: %08x %08x %08x\n", i, ii16[i],
4561 (unsigned int)&ii16[i], (unsigned int)ii16);
4565 static void dump_vfargs (void)
4570 for (i=0; i<nb_vfargs; i++) {
4571 vf = (vector float)vfargs[i];
4572 f = ((float*)&vf)[0];
4573 printf("vfarg %3d: %24f : %08x\n", i, f, ((unsigned int*)&f)[0]);
4578 static void test_int_three_args (const char* name, test_func_t func,
4579 unused uint32_t test_flags)
4581 volatile HWord_t res;
4582 volatile uint32_t flags, xer;
4585 for (i=0; i<nb_iargs; i++) {
4586 for (j=0; j<nb_iargs; j++) {
4587 for (k=0; k<nb_iargs; k++) {
4594 GET_CR_XER(flags,xer);
4597 #ifndef __powerpc64__
4598 printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
4600 printf("%s %016lx, %016lx, %016lx => %016lx (%08x %08x)\n",
4602 name, iargs[i], iargs[j], iargs[k], res, flags, xer);
4604 if (verbose) printf("\n");
4609 static void test_int_two_args (const char* name, test_func_t func,
4610 uint32_t test_flags)
4612 volatile HWord_t res;
4613 volatile uint32_t flags, xer, xer_orig;
4614 int i, j, is_div, zap_hi32;
4616 // catches div, divwu, divo, divwu, divwuo, and . variants
4617 is_div = strstr(name, "divw") != NULL;
4619 zap_hi32 = strstr(name, "mulhw") != NULL;
4621 xer_orig = 0x00000000;
4623 for (i=0; i<nb_iargs; i++) {
4624 for (j=0; j<nb_iargs; j++) {
4626 /* result of division by zero is implementation dependent.
4628 if (is_div && iargs[j] == 0)
4637 GET_CR_XER(flags,xer);
4640 #ifndef __powerpc64__
4641 printf("%s %08x, %08x => %08x (%08x %08x)\n",
4643 if (zap_hi32) res &= 0xFFFFFFFFULL;
4644 printf("%s %016lx, %016lx => %016lx (%08x %08x)\n",
4646 name, iargs[i], iargs[j], res, flags, xer);
4648 if (verbose) printf("\n");
4650 if ((test_flags & PPC_XER_CA) && xer_orig == 0x00000000) {
4651 xer_orig = 0x20000000;
4656 static void test_int_one_arg (const char* name, test_func_t func,
4657 uint32_t test_flags)
4659 volatile HWord_t res;
4660 volatile uint32_t flags, xer, xer_orig;
4663 xer_orig = 0x00000000;
4665 for (i=0; i<nb_iargs; i++) {
4671 GET_CR_XER(flags,xer);
4673 #ifndef __powerpc64__
4674 printf("%s %08x => %08x (%08x %08x)\n",
4676 printf("%s %016lx => %016lx (%08x %08x)\n",
4678 name, iargs[i], res, flags, xer);
4680 if ((test_flags & PPC_XER_CA) && xer_orig == 0x00000000) {
4681 xer_orig = 0x20000000;
4686 static inline void invalidate_icache ( void *ptr, int nbytes )
4688 HWord_t startaddr = (HWord_t) ptr;
4689 HWord_t endaddr = startaddr + nbytes;
4690 HWord_t cls = 32; /*VG_(cache_line_size_ppc32);*/
4693 startaddr &= ~(cls - 1);
4694 for (addr = startaddr; addr < endaddr; addr += cls)
4695 asm volatile("dcbst 0,%0" : : "r" (addr));
4696 asm volatile("sync");
4697 for (addr = startaddr; addr < endaddr; addr += cls)
4698 asm volatile("icbi 0,%0" : : "r" (addr));
4699 asm volatile("sync; isync");
4702 /* for god knows what reason, if this isn't inlined, the
4703 program segfaults. */
4705 void _patch_op_imm (uint32_t *p_insn, uint16_t imm, int sh, int len)
4707 uint32_t mask = ((1 << len) - 1) << sh;
4708 *p_insn = (*p_insn & ~mask) | ((imm<<sh) & mask);
4712 void patch_op_imm (uint32_t* p_insn, uint16_t imm, int sh, int len)
4714 _patch_op_imm(p_insn, imm, sh, len);
4715 invalidate_icache(p_insn, 4);
4719 void patch_op_imm16 (uint32_t *p_insn, uint16_t imm)
4721 patch_op_imm(p_insn, imm, 0, 16);
4725 /* Copy the 2 insn function starting at p_func_F to func_buf[], and
4726 return a possibly different pointer, which, when called, runs the
4727 copy in func_buf[]. */
4729 test_func_t init_function( test_func_t p_func_F, uint32_t func_buf[] )
4731 uint32_t* p_func = (uint32_t*)p_func_F;
4732 #ifndef __powerpc64__
4733 func_buf[0] = p_func[0];
4734 func_buf[1] = p_func[1];
4735 return (test_func_t)&func_buf[0];
4737 /* p_func points to a function descriptor, the first word of which
4738 points to the real code. Copy the code itself but not the
4739 descriptor, and just swizzle the descriptor's entry pointer. */
4740 uint64_t* descr = (uint64_t*)p_func;
4741 uint32_t* entry = (uint32_t*)(descr[0]);
4742 func_buf[0] = entry[0];
4743 func_buf[1] = entry[1];
4744 descr[0] = (uint64_t)&func_buf[0];
4745 return (test_func_t)descr;
4746 #endif // #ifndef __powerpc64__
4750 static void test_int_one_reg_imm16 (const char* name,
4751 test_func_t func_IN,
4752 unused uint32_t test_flags)
4754 volatile test_func_t func;
4755 uint32_t* func_buf = get_rwx_area();
4756 volatile HWord_t res;
4757 volatile uint32_t flags, xer;
4760 for (i=0; i<nb_iargs; i++) {
4761 for (j=0; j<nb_ii16; j++) {
4762 /* Patch up the instruction */
4763 func = init_function( func_IN, func_buf );
4764 patch_op_imm16(&func_buf[0], ii16[j]);
4770 GET_CR_XER(flags,xer);
4773 #ifndef __powerpc64__
4774 printf("%s %08x, %08x => %08x (%08x %08x)\n",
4776 printf("%s %016lx, %08x => %016lx (%08x %08x)\n",
4778 name, iargs[i], ii16[j], res, flags, xer);
4780 if (verbose) printf("\n");
4784 /* Special test cases for:
4802 * rldicl rA,rS,SH,MB
4803 * rldicr rA,rS,SH,ME
4804 * rldimi rA,rS,SH,MB
4808 static void rlwi_cb (const char* name, test_func_t func_IN,
4809 unused uint32_t test_flags)
4811 volatile test_func_t func;
4812 uint32_t* func_buf = get_rwx_area();
4813 volatile HWord_t res;
4814 volatile uint32_t flags, xer;
4815 int i, j, k, l, arg_step;
4817 arg_step = (arg_list_size == 0) ? 31 : 3;
4819 r17 = 0; // rlwimi takes r17 as input: start with a clean slate.
4821 for (i=0; i<nb_iargs; i++) {
4822 for (j=0; j<32; j+=arg_step) {
4823 for (k=0; k<32; k+=arg_step) {
4824 for (l=0; l<32; l+=arg_step) {
4825 /* Patch up the instruction */
4826 func = init_function( func_IN, func_buf );
4827 _patch_op_imm(&func_buf[0], j, 11, 5);
4828 _patch_op_imm(&func_buf[0], k, 6, 5);
4829 patch_op_imm(&func_buf[0], l, 1, 5);
4835 GET_CR_XER(flags,xer);
4838 #ifndef __powerpc64__
4839 printf("%s %08x, %2d, %2d, %2d => %08x (%08x %08x)\n",
4841 printf("%s %016lx, %2d, %2d, %2d => %016lx (%08x %08x)\n",
4843 name, iargs[i], j, k, l, res, flags, xer);
4845 if (verbose) printf("\n");
4851 static void rlwnm_cb (const char* name, test_func_t func_IN,
4852 unused uint32_t test_flags)
4854 volatile test_func_t func;
4855 uint32_t* func_buf = get_rwx_area();
4856 volatile HWord_t res;
4857 volatile uint32_t flags, xer;
4858 int i, j, k, l, arg_step;
4860 arg_step = (arg_list_size == 0) ? 31 : 3;
4862 for (i=0; i<nb_iargs; i++) {
4863 for (j=0; j<nb_iargs; j++) {
4864 for (k=0; k<32; k+=arg_step) {
4865 for (l=0; l<32; l+=arg_step) {
4866 /* Patch up the instruction */
4867 func = init_function( func_IN, func_buf );
4868 _patch_op_imm(&func_buf[0], k, 6, 5);
4869 patch_op_imm(&func_buf[0], l, 1, 5);
4876 GET_CR_XER(flags,xer);
4879 #ifndef __powerpc64__
4880 printf("%s %08x, %08x, %2d, %2d => %08x (%08x %08x)\n",
4882 printf("%s %016lx, %016lx, %2d, %2d => %016lx (%08x %08x)\n",
4884 name, iargs[i], iargs[j], k, l, res, flags, xer);
4886 if (verbose) printf("\n");
4892 static void srawi_cb (const char* name, test_func_t func_IN,
4893 unused uint32_t test_flags)
4895 volatile test_func_t func;
4896 uint32_t* func_buf = get_rwx_area();
4897 volatile HWord_t res;
4898 volatile uint32_t flags, xer;
4901 arg_step = (arg_list_size == 0) ? 31 : 1;
4903 for (i=0; i<nb_iargs; i++) {
4904 for (j=0; j<32; j+=arg_step) {
4905 /* Patch up the instruction */
4906 func = init_function( func_IN, func_buf );
4907 patch_op_imm(&func_buf[0], j, 11, 5);
4913 GET_CR_XER(flags,xer);
4916 #ifndef __powerpc64__
4917 printf("%s %08x, %2d => %08x (%08x %08x)\n",
4919 printf("%s %016lx, %2d => %016lx (%08x %08x)\n",
4921 name, iargs[i], j, res, flags, xer);
4923 if (verbose) printf("\n");
4927 static void mcrf_cb (const char* name, test_func_t func_IN,
4928 unused uint32_t test_flags)
4930 volatile test_func_t func;
4931 uint32_t* func_buf = get_rwx_area();
4932 volatile uint32_t flags, xer;
4933 int i, j, k, arg_step;
4935 arg_step = (arg_list_size == 0) ? 7 : 1;
4937 for (i=0; i<nb_iargs; i++) {
4938 for (j=0; j<8; j+=arg_step) {
4939 for (k=0; k<8; k+=arg_step) {
4940 /* Patch up the instruction */
4941 func = init_function( func_IN, func_buf );
4942 _patch_op_imm(&func_buf[0], j, 23, 3);
4943 patch_op_imm(&func_buf[0], k, 18, 3);
4950 GET_CR_XER(flags,xer);
4952 #ifndef __powerpc64__
4953 printf("%s %d, %d (%08x) => (%08x %08x)\n",
4955 printf("%s %d, %d (%016lx) => (%08x %08x)\n",
4957 name, j, k, iargs[i], flags, xer);
4959 if (verbose) printf("\n");
4964 static void mcrxr_cb (const char* name, test_func_t func_IN,
4965 unused uint32_t test_flags)
4967 volatile test_func_t func;
4968 uint32_t* func_buf = get_rwx_area();
4969 volatile uint32_t flags, xer;
4970 int i, j, k, arg_step;
4972 arg_step = 1; //(arg_list_size == 0) ? 7 : 1;
4974 for (i=0; i<16; i+=arg_step) {
4976 for (k=0; k<8; k+=arg_step) {
4977 /* Patch up the instruction */
4978 func = init_function( func_IN, func_buf );
4979 patch_op_imm(&func_buf[0], k, 23, 3);
4986 GET_CR_XER(flags,xer);
4988 printf("%s %d (%08x) => (%08x %08x)\n",
4989 name, k, j, flags, xer);
4991 if (verbose) printf("\n");
4995 static void mfcr_cb (const char* name, test_func_t func,
4996 unused uint32_t test_flags)
4998 volatile HWord_t res;
4999 volatile uint32_t flags, xer;
5002 for (i=0; i<nb_iargs; i++) {
5005 /* Set up flags for test */
5009 GET_CR_XER(flags,xer);
5012 #ifndef __powerpc64__
5013 printf("%s (%08x) => %08x (%08x %08x)\n",
5015 printf("%s (%016lx) => %016lx (%08x %08x)\n",
5017 name, iargs[i], res, flags, xer);
5021 // NOTE: Not using func: calling function kills lr
5022 static void mfspr_cb (const char* name, test_func_t func,
5023 unused uint32_t test_flags)
5025 //volatile uint32_t res, flags, xer, ctr, lr, tmpcr, tmpxer;
5026 volatile HWord_t res;
5028 func = func; // just to stop compiler complaining
5030 // mtxer followed by mfxer
5031 for (k=0; k<nb_iargs; k++) {
5033 __asm__ __volatile__(
5036 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"xer"
5038 res &= 0xE000007F; /* rest of the bits are undefined */
5040 #ifndef __powerpc64__
5041 printf("%s 1 (%08x) -> mtxer -> mfxer => %08x\n",
5043 printf("%s 1 (%08x) -> mtxer -> mfxer => %016lx\n",
5048 // mtlr followed by mflr
5049 for (k=0; k<nb_iargs; k++) {
5051 __asm__ __volatile__(
5054 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"lr"
5057 #ifndef __powerpc64__
5058 printf("%s 8 (%08x) -> mtlr -> mflr => %08x\n",
5060 printf("%s 8 (%08x) -> mtlr -> mflr => %016lx\n",
5065 // mtctr followed by mfctr
5066 for (k=0; k<nb_iargs; k++) {
5068 __asm__ __volatile__(
5071 : /*out*/"=b"(res) : /*in*/"b"(j) : /*trashed*/"ctr"
5074 #ifndef __powerpc64__
5075 printf("%s 9 (%08x) -> mtctr -> mfctr => %08x\n",
5077 printf("%s 9 (%08x) -> mtctr -> mfctr => %016lx\n",
5083 static void mtcrf_cb (const char* name, test_func_t func_IN,
5084 unused uint32_t test_flags)
5086 volatile test_func_t func;
5087 uint32_t* func_buf = get_rwx_area();
5088 volatile uint32_t flags, xer;
5091 arg_step = (arg_list_size == 0) ? 99 : 1;
5093 for (i=0; i<nb_iargs; i++) {
5094 for (j=0; j<256; j+=arg_step) {
5095 /* Patch up the instruction */
5096 func = init_function( func_IN, func_buf );
5097 patch_op_imm(&func_buf[0], j, 12, 8);
5103 GET_CR_XER(flags,xer);
5105 #ifndef __powerpc64__
5106 printf("%s %3d, %08x => (%08x %08x)\n",
5108 printf("%s %3d, %016lx => (%08x %08x)\n",
5110 name, j, iargs[i], flags, xer);
5112 if (verbose) printf("\n");
5116 // NOTE: Not using func: calling function kills lr
5117 static void mtspr_cb (const char* name, test_func_t func,
5118 unused uint32_t test_flags)
5122 #ifdef __powerpc64__
5123 static void rldc_cb (const char* name, test_func_t func_IN,
5124 unused uint32_t test_flags)
5126 volatile test_func_t func;
5127 uint32_t* func_buf = get_rwx_area();
5128 volatile HWord_t res;
5129 volatile uint32_t flags, xer;
5130 int i, j, k, arg_step;
5132 arg_step = (arg_list_size == 0) ? 7 : 3;
5134 for (i=0; i<nb_iargs; i++) {
5135 for (j=0; j<nb_iargs; j++) {
5136 for (k=0; k<64; k+=arg_step) {
5137 /* Patch up the instruction */
5138 func = init_function( func_IN, func_buf );
5139 patch_op_imm(&func_buf[0], (((k & 0x1F)<<1) | ((k>>5)&1)), 5, 6);
5146 GET_CR_XER(flags,xer);
5149 printf("%s %016lx, %016lx, %2d => %016lx (%08x %08x)\n",
5150 name, iargs[i], iargs[j], k, res, flags, xer);
5152 if (verbose) printf("\n");
5157 static void rldi_cb (const char* name, test_func_t func_IN,
5158 unused uint32_t test_flags)
5160 volatile test_func_t func;
5161 uint32_t* func_buf = get_rwx_area();
5162 volatile HWord_t res;
5163 volatile uint32_t flags, xer;
5164 int i, j, k, arg_step;
5166 arg_step = (arg_list_size == 0) ? 7 : 3;
5168 for (i=0; i<nb_iargs; i++) {
5169 for (j=0; j<64; j+=arg_step) { // SH
5170 for (k=0; k<64; k+=arg_step) { // MB|ME
5171 /* Patch up the instruction */
5172 func = init_function( func_IN, func_buf );
5173 _patch_op_imm(&func_buf[0], (j & 0x1F), 11, 5);
5174 _patch_op_imm(&func_buf[0], ((j>>5)&1), 1, 1);
5175 patch_op_imm(&func_buf[0], (((k & 0x1F)<<1) | ((k>>5)&1)), 5, 6);
5181 GET_CR_XER(flags,xer);
5184 printf("%s %016lx, %2d, %2d => %016lx (%08x %08x)\n",
5185 name, iargs[i], j, k, res, flags, xer);
5187 if (verbose) printf("\n");
5192 static void sradi_cb (const char* name, test_func_t func_IN,
5193 unused uint32_t test_flags)
5195 volatile test_func_t func;
5196 uint32_t* func_buf = get_rwx_area();
5197 volatile HWord_t res;
5198 volatile uint32_t flags, xer;
5201 arg_step = (arg_list_size == 0) ? 7 : 3;
5203 for (i=0; i<nb_iargs; i++) {
5204 for (j=0; j<64; j+=arg_step) { // SH
5205 /* Patch up the instruction */
5206 func = init_function( func_IN, func_buf );
5207 _patch_op_imm(&func_buf[0], (j & 0x1F), 11, 5);
5208 patch_op_imm(&func_buf[0], ((j>>5)&1), 1, 1);
5214 GET_CR_XER(flags,xer);
5217 printf("%s %016lx, %2d => %016lx (%08x %08x)\n",
5218 name, iargs[i], j, res, flags, xer);
5220 if (verbose) printf("\n");
5223 #endif // #ifdef __powerpc64__
5226 typedef struct special_t special_t;
5230 void (*test_cb)(const char* name, test_func_t func,
5231 unused uint32_t test_flags);
5234 static void test_special (special_t *table,
5235 const char* name, test_func_t func,
5236 unused uint32_t test_flags)
5241 for (tmp = name; isspace(*tmp); tmp++)
5243 for (i=0; table[i].name != NULL; i++) {
5245 fprintf(stderr, "look for handler for '%s' (%s)\n", name,
5248 if (strcmp(table[i].name, tmp) == 0) {
5249 (*table[i].test_cb)(name, func, test_flags);
5253 fprintf(stderr, "ERROR: no test found for op '%s'\n", name);
5256 static special_t special_int_ops[] = {
5258 "rlwimi", /* One register + 3 5 bits immediate arguments */
5262 "rlwimi.", /* One register + 3 5 bits immediate arguments */
5266 "rlwinm", /* One register + 3 5 bits immediate arguments */
5270 "rlwinm.", /* One register + 3 5 bits immediate arguments */
5274 "rlwnm", /* Two registers + 2 5 bits immediate arguments */
5278 "rlwnm.", /* Two registers + 2 5 bits immediate arguments */
5282 "srawi", /* One register + 1 5 bits immediate arguments */
5286 "srawi.", /* One register + 1 5 bits immediate arguments */
5290 "mcrf", /* 2 3 bits immediate arguments */
5295 "mcrfs", /* 2 3 bits immediate arguments */
5300 "mcrxr", /* 1 3 bits immediate argument */
5304 "mfcr", /* No arguments */
5308 "mfspr", /* 1 10 bits immediate argument */
5312 { // Move from time base
5313 "mftb", /* 1 10 bits immediate arguments */
5318 "mtcrf", /* One register + 1 8 bits immediate arguments */
5322 "mtspr", /* One register + 1 10 bits immediate arguments */
5325 #ifdef __powerpc64__
5327 "rldcl", /* Two registers + 1 6 bit immediate argument */
5331 "rldcl.", /* Two registers + 1 6 bit immediate argument */
5335 "rldcr", /* Two registers + 1 6 bit immediate argument */
5339 "rldcr.", /* Two registers + 1 6 bit immediate argument */
5343 "rldic", /* One register + 2 6 bit immediate arguments */
5347 "rldic.", /* One register + 2 6 bit immediate arguments */
5351 "rldicl", /* One register + 2 6 bit immediate arguments */
5355 "rldicl.", /* One register + 2 6 bit immediate arguments */
5359 "rldicr", /* One register + 2 6 bit immediate arguments */
5363 "rldicr.", /* One register + 2 6 bit immediate arguments */
5367 "rldimi", /* One register + 2 6 bit immediate arguments */
5371 "rldimi.", /* One register + 2 6 bit immediate arguments */
5375 "sradi", /* One register + 1 6 bit immediate argument */
5379 "sradi.", /* One register + 1 6 bit immediate argument */
5382 #endif // #ifdef __powerpc64__
5389 static void test_int_special (const char* name, test_func_t func,
5390 uint32_t test_flags)
5392 test_special(special_int_ops, name, func, test_flags);
5396 static void test_int_ld_one_reg_imm16 (const char* name,
5397 test_func_t func_IN,
5398 unused uint32_t test_flags)
5400 volatile test_func_t func;
5401 uint32_t* func_buf = get_rwx_area();
5402 volatile HWord_t res, base;
5403 volatile uint32_t flags, xer;
5404 int i, offs, is_lwa=0;
5406 #ifdef __powerpc64__
5407 is_lwa = strstr(name, "lwa") != NULL;
5411 base = (HWord_t)&iargs[0];
5412 for (i=0; i<nb_iargs; i++) {
5413 offs = i * sizeof(HWord_t);
5415 /* Patch up the instruction */
5416 func = init_function( func_IN, func_buf );
5418 patch_op_imm(&func_buf[0], offs>>2, 2, 14);
5420 patch_op_imm16(&func_buf[0], offs);
5426 GET_CR_XER(flags,xer);
5429 #ifndef __powerpc64__
5430 printf("%s %2d, (%08x) => %08x, %2d (%08x %08x)\n",
5432 printf("%s %3d, (%016lx) => %016lx, %3ld (%08x %08x)\n",
5434 name, offs, iargs[i], res, r14-base, flags, xer);
5436 if (verbose) printf("\n");
5439 base = (HWord_t)&iargs[nb_iargs-1];
5440 for (i = -nb_iargs+1; i<=0; i++) {
5441 offs = i * sizeof(HWord_t);
5443 /* Patch up the instruction */
5444 func = init_function( func, func_buf );
5445 patch_op_imm16(&func_buf[0], offs);
5451 GET_CR_XER(flags,xer);
5454 #ifndef __powerpc64__
5455 printf("%s %2d, (%08x) => %08x, %2d (%08x %08x)\n",
5457 printf("%s %3d, (%016lx) => %016lx, %3ld (%08x %08x)\n",
5459 name, offs, iargs[nb_iargs-1+i], res, r14-base, flags, xer);
5463 static void test_int_ld_two_regs (const char* name,
5465 unused uint32_t test_flags)
5467 volatile HWord_t res, base;
5468 volatile uint32_t flags, xer;
5472 base = (HWord_t)&iargs[0];
5473 for (i=0; i<nb_iargs; i++) {
5474 offs = i * sizeof(HWord_t);
5480 GET_CR_XER(flags,xer);
5483 #ifndef __powerpc64__
5484 printf("%s %d (%08x) => %08x, %d (%08x %08x)\n",
5486 printf("%s %3d, (%016lx) => %016lx, %2ld (%08x %08x)\n",
5488 name, offs, iargs[i], res, r14-base, flags, xer);
5492 static void test_int_st_two_regs_imm16 (const char* name,
5493 test_func_t func_IN,
5494 unused uint32_t test_flags)
5496 volatile test_func_t func;
5497 uint32_t* func_buf = get_rwx_area();
5498 volatile uint32_t flags, xer;
5500 HWord_t *iargs_priv, base;
5502 // private iargs table to store to
5503 iargs_priv = malloc(nb_iargs * sizeof(HWord_t));
5506 base = (HWord_t)&iargs_priv[0];
5507 for (i=0; i<nb_iargs; i++) {
5508 for (k=0; k<nb_iargs; k++) // clear array
5511 offs = i * sizeof(HWord_t);
5513 /* Patch up the instruction */
5514 func = init_function( func_IN, func_buf );
5515 patch_op_imm16(&func_buf[0], offs);
5517 r14 = iargs[i]; // read from iargs
5518 r15 = base; // store to r15 + offs
5522 GET_CR_XER(flags,xer);
5524 #ifndef __powerpc64__
5525 printf("%s %08x, %2d => %08x, %2d (%08x %08x)\n",
5527 printf("%s %016lx, %3d => %016lx, %3ld (%08x %08x)\n",
5529 name, iargs[i], offs, iargs_priv[i], r15-base, flags, xer);
5531 if (verbose) printf("\n");
5534 base = (HWord_t)&iargs_priv[nb_iargs-1];
5535 for (i = -nb_iargs+1; i<=0; i++) {
5536 for (k=0; k<nb_iargs; k++) // clear array
5539 offs = i * sizeof(HWord_t);
5541 /* Patch up the instruction */
5542 func = init_function( func, func_buf );
5543 patch_op_imm16(&func_buf[0], offs);
5545 r14 = iargs[nb_iargs-1+i]; // read from iargs
5546 r15 = base; // store to r15 + offs
5550 GET_CR_XER(flags,xer);
5552 #ifndef __powerpc64__
5553 printf("%s %08x, %2d => %08x, %2d (%08x %08x)\n",
5555 printf("%s %016lx, %3d => %016lx, %3ld (%08x %08x)\n",
5557 name, iargs[nb_iargs-1+i], offs, iargs_priv[nb_iargs-1+i],
5558 r15-base, flags, xer);
5563 static void test_int_st_three_regs (const char* name,
5565 unused uint32_t test_flags)
5567 volatile uint32_t flags, xer;
5569 HWord_t *iargs_priv, base;
5571 // private iargs table to store to
5572 iargs_priv = malloc(nb_iargs * sizeof(HWord_t));
5574 base = (HWord_t)&iargs_priv[0];
5575 for (i=0; i<nb_iargs; i++) {
5576 for (k=0; k<nb_iargs; k++) // clear array
5579 offs = i * sizeof(HWord_t);
5580 r14 = iargs[i]; // read from iargs
5581 r15 = base; // store to r15 + offs
5586 GET_CR_XER(flags,xer);
5588 #ifndef __powerpc64__
5589 printf("%s %08x, %d => %08x, %d (%08x %08x)\n",
5591 printf("%s %016lx, %3d => %016lx, %2ld (%08x %08x)\n",
5593 name, iargs[i], offs, iargs_priv[i], r15-base, flags, xer);
5599 /* Used in do_tests, indexed by flags->nb_args
5600 Elements correspond to enum test_flags::num args
5602 static test_loop_t int_loops[] = {
5605 &test_int_three_args,
5607 &test_int_one_reg_imm16,
5608 &test_int_one_reg_imm16,
5610 &test_int_ld_one_reg_imm16,
5611 &test_int_ld_two_regs,
5612 &test_int_st_two_regs_imm16,
5613 &test_int_st_three_regs,
5616 #if !defined (NO_FLOAT)
5617 static void test_float_three_args (const char* name, test_func_t func,
5618 unused uint32_t test_flags)
5621 uint64_t u0, u1, u2, ur;
5622 volatile uint32_t flags;
5625 /* Note: using nb_normal_fargs:
5626 - not testing special values for these insns
5629 for (i=0; i<nb_normal_fargs; i+=3) {
5630 for (j=0; j<nb_normal_fargs; j+=5) {
5631 for (k=0; k<nb_normal_fargs; k+=7) {
5632 u0 = *(uint64_t *)(&fargs[i]);
5633 u1 = *(uint64_t *)(&fargs[j]);
5634 u2 = *(uint64_t *)(&fargs[k]);
5644 ur = *(uint64_t *)(&res);
5646 /* Note: zapping the bottom byte of the result,
5647 as vex's accuracy isn't perfect */
5648 ur &= 0xFFFFFFFFFFFFFF00ULL;
5650 #ifndef __powerpc64__
5651 printf("%s %016llx, %016llx, %016llx => %016llx",
5653 printf("%s %016lx, %016lx, %016lx => %016lx",
5655 name, u0, u1, u2, ur);
5656 #if defined TEST_FLOAT_FLAGS
5657 printf(" (%08x)", flags);
5661 if (verbose) printf("\n");
5666 static void test_float_two_args (const char* name, test_func_t func,
5667 unused uint32_t test_flags)
5670 uint64_t u0, u1, ur;
5671 volatile uint32_t flags;
5674 for (i=0; i<nb_fargs; i+=3) {
5675 for (j=0; j<nb_fargs; j+=5) {
5676 u0 = *(uint64_t *)(&fargs[i]);
5677 u1 = *(uint64_t *)(&fargs[j]);
5686 ur = *(uint64_t *)(&res);
5688 #ifndef __powerpc64__
5689 printf("%s %016llx, %016llx => %016llx",
5691 printf("%s %016lx, %016lx => %016lx",
5694 #if defined TEST_FLOAT_FLAGS
5695 printf(" (%08x)", flags);
5699 if (verbose) printf("\n");
5703 static void test_float_one_arg (const char* name, test_func_t func,
5704 unused uint32_t test_flags)
5708 volatile uint32_t flags;
5709 int i, zap_hi_32bits;
5711 /* if we're testing fctiw or fctiwz, zap the hi 32bits,
5712 as they're undefined */
5713 zap_hi_32bits = strstr(name, "fctiw") != NULL;
5715 for (i=0; i<nb_fargs; i++) {
5716 u0 = *(uint64_t *)(&fargs[i]);
5724 ur = *(uint64_t *)(&res);
5727 ur &= 0xFFFFFFFFULL;
5729 #ifndef __powerpc64__
5730 printf("%s %016llx => %016llx",
5732 printf("%s %016lx => %016lx",
5735 #if defined TEST_FLOAT_FLAGS
5736 printf(" (%08x)", flags);
5742 /* Special test cases for:
5747 static special_t special_float_ops[] = {
5750 "mffs", /* One 5 bits immediate argument */
5754 "mffs.", /* One 5 bits immediate argument */
5758 "mtfsb0", /* One 5 bits immediate argument */
5762 "mtfsb0.", /* One 5 bits immediate argument */
5766 "mtfsb1", /* One 5 bits immediate argument */
5770 "mtfsb1.", /* One 5 bits immediate argument */
5774 "mtfsf", /* One register + 1 8 bits immediate argument */
5778 "mtfsf.", /* One register + 1 8 bits immediate argument */
5782 "mtfsfi", /* One 5 bits argument + 1 5 bits argument */
5786 "mtfsfi.", /* One 5 bits argument + 1 5 bits argument */
5796 static void test_float_special (const char* name, test_func_t func,
5797 uint32_t test_flags)
5799 test_special(special_float_ops, name, func, test_flags);
5803 static void test_float_ld_one_reg_imm16 (const char* name,
5804 test_func_t func_IN,
5805 unused uint32_t test_flags)
5807 volatile test_func_t func;
5808 uint32_t* func_buf = get_rwx_area();
5810 volatile uint32_t flags, xer;
5811 volatile double src, res;
5814 /* offset within [1-nb_fargs:nb_fargs] */
5815 for (i=1-nb_fargs; i<nb_fargs; i++) {
5816 offs = i * 8; // offset = i * sizeof(double)
5818 src = fargs[nb_fargs-1 + i];
5819 base = (HWord_t)&fargs[nb_fargs-1];
5822 base = (HWord_t)&fargs[0];
5825 /* Patch up the instruction */
5826 func = init_function( func_IN, func_buf );
5827 patch_op_imm16(&func_buf[0], offs);
5829 // load from fargs[idx] => r14 + offs
5834 GET_CR_XER(flags,xer);
5837 #ifndef __powerpc64__
5838 printf("%s %016llx, %4d => %016llx, %4d",
5840 printf("%s %016lx, %4d => %016lx, %4ld",
5842 name, double_to_bits(src), offs,
5843 double_to_bits(res), r14-base);
5844 #if defined TEST_FLOAT_FLAGS
5845 printf(" (%08x %08x)", flags, xer);
5849 if (verbose) printf("\n");
5852 static void test_float_ld_two_regs (const char* name,
5854 unused uint32_t test_flags)
5856 volatile HWord_t base;
5857 volatile uint32_t flags, xer;
5858 volatile double src, res;
5861 /* offset within [1-nb_fargs:nb_fargs] */
5862 for (i=1-nb_fargs; i<nb_fargs; i++) {
5863 offs = i * 8; // offset = i * sizeof(double)
5864 if (i < 0) { // base reg = start of array
5865 src = fargs[nb_fargs-1 + i];
5866 base = (HWord_t)&fargs[nb_fargs-1];
5869 base = (HWord_t)&fargs[0];
5877 GET_CR_XER(flags,xer);
5880 #ifndef __powerpc64__
5881 printf("%s %016llx, %4d => %016llx, %4d",
5883 printf("%s %016lx, %4ld => %016lx, %4ld",
5885 name, double_to_bits(src), r15/*offs*/,
5886 double_to_bits(res), r14-base);
5887 #if defined TEST_FLOAT_FLAGS
5888 printf(" (%08x %08x)", flags, xer);
5894 static void test_float_st_two_regs_imm16 (const char* name,
5895 test_func_t func_IN,
5896 unused uint32_t test_flags)
5898 volatile test_func_t func;
5899 uint32_t* func_buf = get_rwx_area();
5901 volatile uint32_t flags, xer;
5905 int nb_tmp_fargs = nb_fargs;
5908 /* if we're storing an fp single-precision, don't want nans
5909 - the vex implementation doesn't like them (yet)
5910 Note: This is actually a bigger problem: the vex implementation
5911 rounds these insns twice. This leads to many rounding errors.
5912 For the small fargs set, however, this doesn't show up.
5914 if (strstr(name, "stfs") != NULL)
5915 nb_tmp_fargs = nb_normal_fargs;
5918 // private fargs table to store to
5919 fargs_priv = malloc(nb_tmp_fargs * sizeof(double));
5921 /* offset within [1-nb_tmp_fargs:nb_tmp_fargs] */
5922 for (i=1-nb_tmp_fargs; i<nb_tmp_fargs; i++) {
5923 offs = i * 8; // offset = i * sizeof(double)
5925 src = fargs [nb_tmp_fargs-1 + i];
5926 p_dst = &fargs_priv[nb_tmp_fargs-1 + i];
5927 base = (HWord_t)&fargs_priv[nb_tmp_fargs-1];
5930 p_dst = &fargs_priv[i];
5931 base = (HWord_t)&fargs_priv[0];
5933 *p_dst = 0; // clear dst
5935 /* Patch up the instruction */
5936 func = init_function( func_IN, func_buf );
5937 patch_op_imm16(&func_buf[0], offs);
5939 // read from fargs[idx] => f14
5940 // store to fargs_priv[idx] => r15 + offs
5946 GET_CR_XER(flags,xer);
5948 #ifndef __powerpc64__
5949 printf("%s %016llx, %4d => %016llx, %4d",
5951 printf("%s %016lx, %4d => %016lx, %4ld",
5953 name, double_to_bits(src), offs,
5954 double_to_bits(*p_dst), r15-base);
5955 #if defined TEST_FLOAT_FLAGS
5956 printf(" (%08x %08x)", flags, xer);
5963 static void test_float_st_three_regs (const char* name,
5965 unused uint32_t test_flags)
5967 volatile HWord_t base;
5968 volatile uint32_t flags, xer;
5972 int nb_tmp_fargs = nb_fargs;
5975 /* if we're storing an fp single-precision, don't want nans
5976 - the vex implementation doesn't like them (yet)
5977 Note: This is actually a bigger problem: the vex implementation
5978 rounds these insns twice. This leads to many rounding errors.
5979 For the small fargs set, however, this doesn't show up.
5981 if (strstr(name, "stfs") != NULL) // stfs(u)(x)
5982 nb_tmp_fargs = nb_normal_fargs;
5985 // private fargs table to store to
5986 fargs_priv = malloc(nb_tmp_fargs * sizeof(double));
5988 // /* offset within [1-nb_tmp_fargs:nb_tmp_fargs] */
5989 // for (i=1-nb_tmp_fargs; i<nb_tmp_fargs; i++) {
5990 for (i=0; i<nb_tmp_fargs; i++) {
5991 offs = i * 8; // offset = i * sizeof(double)
5993 src = fargs [nb_tmp_fargs-1 + i];
5994 p_dst = &fargs_priv[nb_tmp_fargs-1 + i];
5995 base = (HWord_t)&fargs_priv[nb_tmp_fargs-1];
5998 p_dst = &fargs_priv[i];
5999 base = (HWord_t)&fargs_priv[0];
6001 *p_dst = 0; // clear dst
6003 f14 = src; // read from fargs
6004 r15 = base; // store to r15 + offs
6009 GET_CR_XER(flags,xer);
6011 #ifndef __powerpc64__
6012 printf("%s %016llx, %4d => %016llx, %4d",
6014 printf("%s %016lx, %4ld => %016lx, %4ld",
6016 name, double_to_bits(src), r16/*offs*/,
6017 double_to_bits(*p_dst), r15-base);
6018 #if defined TEST_FLOAT_FLAGS
6019 printf(" (%08x %08x)", flags, xer);
6025 // print double precision result
6026 #ifndef __powerpc64__
6027 printf("%s %016llx (%014e), %4d => %016llx (%014e), %08x (%08x %08x)\n",
6029 printf("%s %016lx (%014e), %4d => %016lx (%014e), %08x (%08x %08x)\n",
6031 name, double_to_bits(src), src, offs,
6032 double_to_bits(*p_dst), *p_dst, r15, flags, xer);
6034 // print single precision result
6035 #ifndef __powerpc64__
6036 printf("%s %016llx (%014e), %4d => %08x (%f), %08x (%08x %08x)\n",
6038 printf("%s %016lx (%014e), %4d => %08x (%f), %08x (%08x %08x)\n",
6040 name, double_to_bits(src), src, offs,
6041 (uint32_t)(double_to_bits(*p_dst) >> 32),
6042 bits_to_float( (uint32_t)(double_to_bits(*p_dst) >> 32) ),
6050 /* Used in do_tests, indexed by flags->nb_args
6051 Elements correspond to enum test_flags::num args
6053 static test_loop_t float_loops[] = {
6054 &test_float_one_arg,
6055 &test_float_two_args,
6056 &test_float_three_args,
6057 &test_float_two_args,
6060 &test_float_special,
6061 &test_float_ld_one_reg_imm16,
6062 &test_float_ld_two_regs,
6063 &test_float_st_two_regs_imm16,
6064 &test_float_st_three_regs,
6066 #endif /* !defined (NO_FLOAT) */
6069 #if defined (HAS_ALTIVEC)
6071 /* Ref: vector insns to test setting CR, VSCR:
6072 volatile vector unsigned int v1 =
6073 // (vector unsigned int){ 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
6074 (vector unsigned int){ 0x80808080,0x80808080,0x80808080,0x80808080 };
6075 volatile vector unsigned int v2 =
6076 // (vector unsigned int){ 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF };
6077 (vector unsigned int){ 0x01010101,0x01010101,0x01010101,0x01010101 };
6078 //__asm__ __volatile__ ("vcmpequw. 31,%0,%1" : : "vr" (v1), "vr" (v2)); // sets CR[6]
6079 //__asm__ __volatile__ ("vpkswss 31,%0,%1" : : "vr" (v1), "vr" (v2)); // sets VSCR[SAT]
6080 __asm__ __volatile__ ("vsubsbs 31,%0,%1" : : "vr" (v1), "vr" (v2)); // sets VSCR[SAT]
6083 //#define DEFAULT_VSCR 0x00010000
6084 #define DEFAULT_VSCR 0x0
6086 static void test_av_int_one_arg (const char* name, test_func_t func,
6087 unused uint32_t test_flags)
6089 volatile uint32_t flags, tmpcr;
6090 volatile vector unsigned int tmpvscr;
6091 volatile vector unsigned int vec_in, vec_out, vscr;
6092 unsigned int *src, *dst;
6094 #if defined TEST_VSCR_SAT
6095 unsigned int* p_vscr;
6098 for (i=0; i<nb_viargs; i++) {
6100 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6101 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6103 vec_in = (vector unsigned int)viargs[i];
6104 vec_out = (vector unsigned int){ 0,0,0,0 };
6106 // reset VSCR and CR
6107 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6109 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6110 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6112 // load input -> r14
6113 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in));
6118 // retrieve output <- r17
6119 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6121 // get CR,VSCR flags
6122 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6123 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6126 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6127 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6129 src = (unsigned int*)&vec_in;
6130 dst = (unsigned int*)&vec_out;
6132 printf("%s: %08x %08x %08x %08x\n", name,
6133 src[0], src[1], src[2], src[3]);
6134 printf("%s: => %08x %08x %08x %08x ", name,
6135 dst[0], dst[1], dst[2], dst[3]);
6136 #if defined TEST_VSCR_SAT
6137 p_vscr = (unsigned int*)𝓋
6138 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6140 printf("(%08x)\n", flags);
6145 static void test_av_int_two_args (const char* name, test_func_t func,
6146 unused uint32_t test_flags)
6148 volatile uint32_t flags, tmpcr;
6149 volatile vector unsigned int tmpvscr;
6150 volatile vector unsigned int vec_in1, vec_in2, vec_out, vscr;
6151 unsigned int *src1, *src2, *dst;
6153 #if defined TEST_VSCR_SAT
6154 unsigned int* p_vscr;
6157 for (i=0; i<nb_viargs; i++) {
6158 vec_in1 = (vector unsigned int)viargs[i];
6159 for (j=0; j<nb_viargs; j++) {
6160 vec_in2 = (vector unsigned int)viargs[j];
6161 vec_out = (vector unsigned int){ 0,0,0,0 };
6164 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6165 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6167 // reset VSCR and CR
6168 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6170 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6171 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6173 // load inputs -> r14,r15
6174 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6175 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_in2));
6180 // retrieve output <- r17
6181 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6183 // get CR,VSCR flags
6184 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6185 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6188 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6189 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6191 src1 = (unsigned int*)&vec_in1;
6192 src2 = (unsigned int*)&vec_in2;
6193 dst = (unsigned int*)&vec_out;
6195 printf("%s: ", name);
6196 printf("%08x%08x%08x%08x, ", src1[0], src1[1], src1[2], src1[3]);
6197 printf("%08x%08x%08x%08x\n", src2[0], src2[1], src2[2], src2[3]);
6198 printf("%s: => %08x %08x %08x %08x ", name,
6199 dst[0], dst[1], dst[2], dst[3]);
6200 #if defined TEST_VSCR_SAT
6201 p_vscr = (unsigned int*)𝓋
6202 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6204 printf("(%08x)\n", flags);
6207 if (verbose) printf("\n");
6211 static void test_av_int_three_args (const char* name, test_func_t func,
6212 unused uint32_t test_flags)
6214 volatile uint32_t flags, tmpcr;
6215 volatile vector unsigned int tmpvscr;
6216 volatile vector unsigned int vec_in1, vec_in2, vec_in3, vec_out, vscr;
6217 unsigned int *src1, *src2, *src3, *dst;
6219 #if defined TEST_VSCR_SAT
6220 unsigned int* p_vscr;
6223 for (i=0; i<nb_viargs; i++) {
6224 vec_in1 = (vector unsigned int)viargs[i];
6225 for (j=0; j<nb_viargs; j++) {
6226 vec_in2 = (vector unsigned int)viargs[j];
6227 for (k=0; k<nb_viargs; k++) {
6228 vec_in3 = (vector unsigned int)viargs[k];
6229 vec_out = (vector unsigned int){ 0,0,0,0 };
6232 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6233 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6235 // reset VSCR and CR
6236 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6238 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6239 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6241 // load inputs -> r14,r15,r16
6242 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6243 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_in2));
6244 __asm__ __volatile__ ("vor 16,%0,%0" : : "vr" (vec_in3));
6249 // retrieve output <- r17
6250 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6252 // get CR,VSCR flags
6253 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6254 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6257 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6258 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6260 src1 = (unsigned int*)&vec_in1;
6261 src2 = (unsigned int*)&vec_in2;
6262 src3 = (unsigned int*)&vec_in3;
6263 dst = (unsigned int*)&vec_out;
6265 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
6266 src1[0], src1[1], src1[2], src1[3],
6267 src2[0], src2[1], src2[2], src2[3],
6268 src3[0], src3[1], src3[2], src3[3]);
6270 printf("%s: => %08x%08x%08x%08x ", name,
6271 dst[0], dst[1], dst[2], dst[3]);
6272 #if defined TEST_VSCR_SAT
6273 p_vscr = (unsigned int*)𝓋
6274 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6276 printf("(%08x)\n", flags);
6279 if (verbose) printf("\n");
6285 static void vs128_cb (const char* name, test_func_t func,
6286 unused uint32_t test_flags)
6288 volatile uint32_t flags, tmpcr;
6289 volatile vector unsigned int tmpvscr;
6290 volatile vector unsigned char vec_shft;
6291 volatile vector unsigned int vec_in1, vec_out, vscr;
6292 unsigned int *src1, *src2, *dst;
6294 #if defined TEST_VSCR_SAT
6295 unsigned int* p_vscr;
6298 for (i=0; i<nb_viargs; i++) {
6299 vec_in1 = (vector unsigned int)viargs[i];
6300 for (j=0; j<8; j++) {
6301 /* low-order 3bits of every byte must be the same for the shift vector */
6302 vec_shft = (vector unsigned char) { j,j,j,j, j,j,j,j, j,j,j,j, j,j,j,j };
6303 vec_out = (vector unsigned int){ 0,0,0,0 };
6306 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6307 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6309 // reset VSCR and CR
6310 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6312 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6313 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6315 // load inputs -> r14,r15
6316 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6317 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_shft));
6322 // retrieve output <- r17
6323 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6325 // get CR,VSCR flags
6326 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6327 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6330 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6331 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6333 src1 = (unsigned int*)&vec_in1;
6334 src2 = (unsigned int*)&vec_shft;
6335 dst = (unsigned int*)&vec_out;
6337 printf("%s: ", name);
6338 printf("%08x%08x%08x%08x, ", src1[0], src1[1], src1[2], src1[3]);
6339 printf("%08x%08x%08x%08x\n", src2[0], src2[1], src2[2], src2[3]);
6341 printf("%s: => %08x %08x %08x %08x ", name,
6342 dst[0], dst[1], dst[2], dst[3]);
6343 #if defined TEST_VSCR_SAT
6344 p_vscr = (unsigned int*)𝓋
6345 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6347 printf("(%08x)\n", flags);
6350 if (verbose) printf("\n");
6354 static void vsplt_cb (const char* name, test_func_t func_IN,
6355 unused uint32_t test_flags)
6357 volatile test_func_t func;
6358 uint32_t* func_buf = get_rwx_area();
6359 volatile uint32_t flags, tmpcr;
6360 volatile vector unsigned int tmpvscr;
6361 volatile vector unsigned int vec_in1, vec_out, vscr;
6362 unsigned int *src1, *dst;
6364 #if defined TEST_VSCR_SAT
6365 unsigned int* p_vscr;
6368 for (i=0; i<nb_viargs; i++) {
6369 vec_in1 = (vector unsigned int)viargs[i];
6371 for (j=0; j<16; j+=3) {
6372 vec_out = (vector unsigned int){ 0,0,0,0 };
6374 /* Patch up the instruction */
6375 func = init_function( func_IN, func_buf );
6376 patch_op_imm(&func_buf[0], j, 16, 5);
6379 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6380 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6382 // reset VSCR and CR
6383 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6385 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6386 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6388 // load input -> r14
6389 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6394 // retrieve output <- r17
6395 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6397 // get CR,VSCR flags
6398 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6399 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6402 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6403 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6405 src1 = (unsigned int*)&vec_in1;
6406 dst = (unsigned int*)&vec_out;
6408 printf("%s: ", name);
6409 printf("%08x %08x %08x %08x, %u\n", src1[0], src1[1], src1[2], src1[3], j);
6411 printf("%s: => %08x %08x %08x %08x ", name,
6412 dst[0], dst[1], dst[2], dst[3]);
6413 #if defined TEST_VSCR_SAT
6414 p_vscr = (unsigned int*)𝓋
6415 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6417 printf("(%08x)\n", flags);
6420 if (verbose) printf("\n");
6424 static void vspltis_cb (const char* name, test_func_t func_IN,
6425 unused uint32_t test_flags)
6427 volatile test_func_t func;
6428 uint32_t* func_buf = get_rwx_area();
6429 volatile uint32_t flags, tmpcr;
6430 volatile vector unsigned int tmpvscr;
6431 volatile vector unsigned int vec_out, vscr;
6434 #if defined TEST_VSCR_SAT
6435 unsigned int* p_vscr;
6438 for (i=0; i<32; i++) {
6439 vec_out = (vector unsigned int){ 0,0,0,0 };
6441 /* Patch up the instruction */
6442 func = init_function( func_IN, func_buf );
6443 patch_op_imm(&func_buf[0], i, 16, 5);
6446 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6447 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6449 // reset VSCR and CR
6450 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6452 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6453 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6458 // retrieve output <- r17
6459 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6461 // get CR,VSCR flags
6462 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6463 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6466 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6467 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6469 dst = (unsigned int*)&vec_out;
6471 printf("%s: %2d => ", name, i);
6472 printf("%08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6473 #if defined TEST_VSCR_SAT
6474 p_vscr = (unsigned int*)𝓋
6475 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6477 printf("(%08x)\n", flags);
6482 static void vsldoi_cb (const char* name, test_func_t func_IN,
6483 unused uint32_t test_flags)
6485 volatile test_func_t func;
6486 uint32_t* func_buf = get_rwx_area();
6487 volatile uint32_t flags, tmpcr;
6488 volatile vector unsigned int tmpvscr;
6489 volatile vector unsigned int vec_in1, vec_in2, vec_out, vscr;
6490 unsigned int *src1, *src2, *dst;
6492 #if defined TEST_VSCR_SAT
6493 unsigned int* p_vscr;
6496 for (i=0; i<nb_viargs; i++) {
6497 vec_in1 = (vector unsigned int)viargs[i];
6498 for (j=0; j<nb_viargs; j++) {
6499 vec_in2 = (vector unsigned int)viargs[j];
6500 for (k=0; k<16; k+=14) {
6501 vec_out = (vector unsigned int){ 0,0,0,0 };
6503 /* Patch up the instruction */
6504 func = init_function( func_IN, func_buf );
6505 patch_op_imm(&func_buf[0], k, 6, 4);
6508 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6509 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6511 // reset VSCR and CR
6512 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6514 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6515 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6517 // load inputs -> r14,r15
6518 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6519 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_in2));
6524 // retrieve output <- r17
6525 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6527 // get CR,VSCR flags
6528 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6529 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6532 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6533 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6535 src1 = (unsigned int*)&vec_in1;
6536 src2 = (unsigned int*)&vec_in2;
6537 dst = (unsigned int*)&vec_out;
6539 printf("%s: ", name);
6540 printf("%08x%08x%08x%08x, %08x%08x%08x%08x, %u\n",
6541 src1[0], src1[1], src1[2], src1[3],
6542 src2[0], src2[1], src2[2], src2[3], k);
6544 printf("%s: => %08x %08x %08x %08x] ", name,
6545 dst[0], dst[1], dst[2], dst[3]);
6546 #if defined TEST_VSCR_SAT
6547 p_vscr = (unsigned int*)𝓋
6548 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6550 printf("(%08x)\n", flags);
6553 if (verbose) printf("\n");
6559 static void lvs_cb (const char *name, test_func_t func,
6560 unused uint32_t test_flags)
6562 volatile uint32_t flags, tmpcr;
6563 volatile vector unsigned int tmpvscr;
6564 volatile vector unsigned int vec_out, vscr;
6567 #if defined TEST_VSCR_SAT
6568 unsigned int* p_vscr;
6571 for (i=-1; i<17; i++) {
6572 vec_out = (vector unsigned int){ 0,0,0,0 };
6574 // make sure start address is 16 aligned - use viargs[0]
6575 r15 = (HWord_t)&viargs[0];
6579 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6580 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6582 // reset VSCR and CR
6583 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6585 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6586 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6591 // retrieve output <- r17
6592 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6594 // get CR,VSCR flags
6595 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6596 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6599 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6600 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6602 dst = (unsigned int*)&vec_out;
6604 printf("%s %3d, %3d", name, i, 0);
6605 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6606 printf("(%08x)\n", flags);
6608 if (verbose) printf("\n");
6611 static special_t special_av_int_ops[] = {
6613 "vsr", /* Two registers arguments */
6617 "vsl", /* Two registers arguments */
6621 "vspltb", /* One reg, one 5-bit uimm arguments */
6625 "vsplth", /* One reg, one 5-bit uimm arguments */
6629 "vspltw", /* One reg, one 5-bit uimm arguments */
6633 "vspltisb", /* One reg, one 5-bit uimm arguments */
6637 "vspltish", /* One reg, one 5-bit uimm arguments */
6641 "vspltisw", /* One reg, one 5-bit uimm arguments */
6645 "vsldoi", /* Two regs, one 4-bit uimm arguments */
6649 "lvsl", /* Two regs */
6653 "lvsr", /* Two regs */
6662 static void test_av_int_special (const char* name, test_func_t func,
6663 uint32_t test_flags)
6665 test_special(special_av_int_ops, name, func, test_flags);
6668 static void test_av_int_ld_two_regs (const char *name,
6670 unused uint32_t test_flags)
6672 volatile uint32_t flags, tmpcr;
6673 volatile vector unsigned int tmpvscr;
6674 volatile vector unsigned int vec_in, vec_out, vscr;
6675 unsigned int *src, *dst;
6676 int i,j, k, do_mask;
6679 if (strstr(name, "lvebx") != NULL) do_mask = 1;
6680 if (strstr(name, "lvehx") != NULL) do_mask = 2;
6681 if (strstr(name, "lvewx") != NULL) do_mask = 4;
6683 for (i=0; i<nb_viargs; i++) {
6684 for (j=0; j<16; j+=7) {
6685 vec_out = (vector unsigned int){ 0,0,0,0 };
6687 // load from viargs array + some dis-alignment
6688 r15 = (HWord_t)&viargs[0];
6692 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6693 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6695 // reset VSCR and CR
6696 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6698 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6699 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6704 // retrieve output <- r17
6705 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6707 // get CR,VSCR flags
6708 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6709 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6712 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6713 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6715 vec_in = (vector unsigned int)viargs[i];
6716 src = (unsigned int*)&vec_in;
6717 dst = (unsigned int*)&vec_out;
6719 /* For lvebx/lvehx/lvewx, as per the documentation, all of
6720 the dest reg except the loaded bits are undefined
6721 afterwards. And different CPUs really do produce
6722 different results. So mask out bits of the result that
6723 are undefined so as to make the test work reliably. */
6725 char* p = (char*)dst;
6726 for (k = 0; k < 16; k++)
6731 short* p = (short*)dst;
6732 for (k = 0; k < 8; k++)
6738 for (k = 0; k < 4; k++)
6743 printf("%s %3d, %08x %08x %08x %08x", name, j, src[0], src[1], src[2], src[3]);
6744 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6745 printf("(%08x)\n", flags);
6747 if (verbose) printf("\n");
6752 static void test_av_int_st_three_regs (const char *name,
6754 unused uint32_t test_flags)
6756 volatile uint32_t flags, tmpcr;
6757 volatile vector unsigned int tmpvscr;
6758 volatile vector unsigned int vec_in, vec_out, vscr;
6759 unsigned int *src, *dst;
6761 vector unsigned int* viargs_priv;
6763 // private viargs table to store to
6764 viargs_priv = memalign16(nb_viargs * sizeof(vector unsigned int));
6765 for (i=0; i<nb_viargs; i++)
6766 viargs_priv[i] = (vector unsigned int) { 0,0,0,0 };
6768 for (i=0; i<nb_viargs; i++) {
6769 for (j=0; j<16; j+=7) {
6771 vec_in = (vector unsigned int)viargs[i];
6773 // store to viargs_priv[0] + some dis-alignment
6774 r16 = (HWord_t)&viargs_priv[0];
6778 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6779 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6781 // reset VSCR and CR
6782 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6784 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6785 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6787 // load inputs -> r14
6788 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in));
6793 // Output stored in viargs_priv
6795 // get CR,VSCR flags
6796 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6797 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6800 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6801 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6803 vec_out = (vector unsigned int)viargs_priv[i];
6804 src = (unsigned int*)&vec_in;
6805 dst = (unsigned int*)&vec_out;
6807 printf("%s %3d, %08x %08x %08x %08x", name, j, src[0], src[1], src[2], src[3]);
6808 printf(" => %08x %08x %08x %08x ", dst[0], dst[1], dst[2], dst[3]);
6809 printf("(%08x)\n", flags);
6811 if (verbose) printf("\n");
6815 /* Used in do_tests, indexed by flags->nb_args
6816 Elements correspond to enum test_flags::num args
6818 static test_loop_t altivec_int_loops[] = {
6819 &test_av_int_one_arg,
6820 &test_av_int_two_args,
6821 &test_av_int_three_args,
6822 &test_av_int_two_args,
6825 &test_av_int_special,
6827 &test_av_int_ld_two_regs,
6829 test_av_int_st_three_regs,
6833 static void test_av_float_one_arg (const char* name, test_func_t func,
6834 unused uint32_t test_flags)
6836 volatile uint32_t flags, tmpcr;
6837 volatile vector unsigned int tmpvscr;
6838 volatile vector float vec_in, vec_out;
6839 volatile vector unsigned int vscr;
6840 unsigned int *src, *dst;
6842 #if defined TEST_VSCR_SAT
6843 unsigned int* p_vscr;
6846 /* if we're doing an estimation operation, arrange to zap the
6847 bottom byte of the result as it's basically garbage, and differs
6850 = (strstr(name,"vrsqrtefp") != NULL ||
6851 strstr(name, "vrefp") != NULL)
6852 ? 0xFFFFFF00 : 0xFFFFFFFF;
6854 for (i=0; i<nb_vfargs; i++) {
6855 vec_in = (vector float)vfargs[i];
6856 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
6859 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6860 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6862 // reset VSCR and CR
6863 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6865 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6866 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6868 // load input -> r14
6869 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in));
6874 // retrieve output <- r17
6875 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6877 // get CR,VSCR flags
6878 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6879 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6882 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6883 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6885 src = (unsigned int*)&vec_in;
6886 dst = (unsigned int*)&vec_out;
6888 printf("%s: %08x %08x %08x %08x\n", name,
6889 src[0], src[1], src[2], src[3]);
6890 printf("%s: => %08x %08x %08x %08x ", name,
6891 dst[0] & mask, dst[1] & mask, dst[2] & mask, dst[3] & mask);
6892 #if defined TEST_VSCR_SAT
6893 p_vscr = (unsigned int*)𝓋
6894 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6896 printf("(%08x)\n", flags);
6901 static void test_av_float_two_args (const char* name, test_func_t func,
6902 unused uint32_t test_flags)
6904 volatile uint32_t flags, tmpcr;
6905 volatile vector unsigned int tmpvscr;
6906 volatile vector float vec_in1, vec_in2, vec_out;
6907 volatile vector unsigned int vscr;
6908 unsigned int *src1, *src2, *dst;
6910 #if defined TEST_VSCR_SAT
6911 unsigned int* p_vscr;
6914 for (i=0; i<nb_vfargs; i++) {
6915 for (j=0; j<nb_vfargs; j+=3) {
6916 vec_in1 = (vector float)vfargs[i];
6917 vec_in2 = (vector float)vfargs[j];
6918 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
6921 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6922 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6924 // reset VSCR and CR
6925 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6927 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6928 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6930 // load inputs -> r14,r15
6931 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
6932 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_in2));
6937 // retrieve output <- r17
6938 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
6940 // get CR,VSCR flags
6941 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
6942 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
6945 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
6946 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
6948 src1 = (unsigned int*)&vec_in1;
6949 src2 = (unsigned int*)&vec_in2;
6950 dst = (unsigned int*)&vec_out;
6952 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
6953 src1[0], src1[1], src1[2], src1[3],
6954 src2[0], src2[1], src2[2], src2[3]);
6955 printf("%s: => %08x %08x %08x %08x ", name,
6956 dst[0], dst[1], dst[2], dst[3]);
6957 #if defined TEST_VSCR_SAT
6958 p_vscr = (unsigned int*)𝓋
6959 printf("(%08x, %08x)\n", flags, p_vscr[3]);
6961 printf("(%08x)\n", flags);
6964 if (verbose) printf("\n");
6968 static void test_av_float_three_args (const char* name, test_func_t func,
6969 unused uint32_t test_flags)
6971 volatile uint32_t flags, tmpcr;
6972 volatile vector unsigned int tmpvscr;
6973 volatile vector float vec_in1, vec_in2, vec_in3, vec_out;
6974 volatile vector unsigned int vscr;
6975 unsigned int *src1, *src2, *src3, *dst;
6977 #if defined TEST_VSCR_SAT
6978 unsigned int* p_vscr;
6981 for (i=0; i<nb_vfargs; i++) {
6982 for (j=0; j<nb_vfargs; j+=3) {
6983 for (k=0; k<nb_vfargs; k+=5) {
6984 vec_in1 = (vector float)vfargs[i];
6985 vec_in2 = (vector float)vfargs[j];
6986 vec_in3 = (vector float)vfargs[k];
6987 vec_out = (vector float){ 0.0, 0.0, 0.0, 0.0 };
6990 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
6991 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
6993 // reset VSCR and CR
6994 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
6996 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
6997 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
6999 // load inputs -> r14,r15,r16
7000 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in1));
7001 __asm__ __volatile__ ("vor 15,%0,%0" : : "vr" (vec_in2));
7002 __asm__ __volatile__ ("vor 16,%0,%0" : : "vr" (vec_in3));
7007 // retrieve output <- r17
7008 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
7010 // get CR,VSCR flags
7011 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
7012 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
7015 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
7016 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
7018 src1 = (unsigned int*)&vec_in1;
7019 src2 = (unsigned int*)&vec_in2;
7020 src3 = (unsigned int*)&vec_in3;
7021 dst = (unsigned int*)&vec_out;
7023 printf("%s: %08x%08x%08x%08x, %08x%08x%08x%08x, %08x%08x%08x%08x\n", name,
7024 src1[0], src1[1], src1[2], src1[3],
7025 src2[0], src2[1], src2[2], src2[3],
7026 src3[0], src3[1], src3[2], src3[3]);
7027 printf("%s: => %08x %08x %08x %08x ", name,
7028 dst[0], dst[1], dst[2], dst[3]);
7029 #if defined TEST_VSCR_SAT
7030 p_vscr = (unsigned int*)𝓋
7031 printf("(%08x, %08x)\n", flags, p_vscr[3]);
7033 printf("(%08x)\n", flags);
7036 if (verbose) printf("\n");
7041 static void vcvt_cb (const char* name, test_func_t func_IN,
7042 unused uint32_t test_flags)
7044 volatile test_func_t func;
7045 uint32_t* func_buf = get_rwx_area();
7046 volatile uint32_t flags, tmpcr;
7047 volatile vector unsigned int tmpvscr;
7048 volatile vector unsigned int vec_in, vec_out, vscr;
7049 unsigned int *src, *dst;
7051 #if defined TEST_VSCR_SAT
7052 unsigned int* p_vscr;
7055 for (i=0; i<nb_vfargs; i++) {
7056 vec_in = (vector unsigned int)vfargs[i];
7058 for (j=0; j<32; j+=9) {
7059 vec_out = (vector unsigned int){ 0,0,0,0 };
7061 /* Patch up the instruction */
7062 func = init_function( func_IN, func_buf );
7063 patch_op_imm(&func_buf[0], j, 16, 5);
7066 __asm__ __volatile__ ("mfcr %0" : "=r" (tmpcr));
7067 __asm__ __volatile__ ("mfvscr %0" : "=vr" (tmpvscr));
7069 // reset VSCR and CR
7070 vscr = (vector unsigned int){ 0,0,0,DEFAULT_VSCR };
7072 __asm__ __volatile__ ("mtvscr %0" : : "vr" (vscr) );
7073 __asm__ __volatile__ ("mtcr %0" : : "r" (flags));
7075 // load input -> r14
7076 __asm__ __volatile__ ("vor 14,%0,%0" : : "vr" (vec_in));
7081 // retrieve output <- r17
7082 __asm__ __volatile__ ("vor %0,17,17" : "=vr" (vec_out));
7084 // get CR,VSCR flags
7085 __asm__ __volatile__ ("mfcr %0" : "=r" (flags));
7086 __asm__ __volatile__ ("mfvscr %0" : "=vr" (vscr));
7089 __asm__ __volatile__ ("mtcr %0" : : "r" (tmpcr));
7090 __asm__ __volatile__ ("mtvscr %0" : : "vr" (tmpvscr));
7092 src = (unsigned int*)&vec_in;
7093 dst = (unsigned int*)&vec_out;
7095 printf("%s: %08x (%13e), %2u", name, src[0], *(float*)(&src[0]), j);
7096 printf(" => %08x (%13e) ", dst[0], *(float*)(&dst[0]));
7097 // printf(" => %08x ", dst[0]);
7098 #if defined TEST_VSCR_SAT
7099 p_vscr = (unsigned int*)𝓋
7100 printf("(%08x, %08x)\n", flags, p_vscr[3]);
7102 printf("(%08x)\n", flags);
7105 if (verbose) printf("\n");
7109 static special_t special_av_float_ops[] = {
7111 "vcfux", /* One reg, one 5-bit uimm argument */
7115 "vcfsx", /* One reg, one 5-bit uimm argument */
7119 "vctuxs", /* One reg, one 5-bit uimm argument */
7123 "vcfux", /* One reg, one 5-bit uimm argument */
7127 "vctsxs", /* One reg, one 5-bit uimm argument */
7136 static void test_av_float_special (const char* name, test_func_t func,
7137 uint32_t test_flags)
7139 test_special(special_av_float_ops, name, func, test_flags);
7142 /* Used in do_tests, indexed by flags->nb_args
7143 Elements correspond to enum test_flags::num args
7145 static test_loop_t altivec_float_loops[] = {
7146 &test_av_float_one_arg,
7147 &test_av_float_two_args,
7148 &test_av_float_three_args,
7149 &test_av_float_two_args,
7152 &test_av_float_special,
7159 #endif /* defined (HAS_ALTIVEC) */
7162 #if defined (IS_PPC405)
7163 static void test_ppc405 (const char* name, test_func_t func,
7164 unused uint32_t test_flags)
7166 volatile uint32_t res, flags, xer, tmpcr, tmpxer;
7169 for (i=0; i<nb_iargs; i++) {
7170 for (j=0; j<nb_iargs; j++) {
7171 for (k=0; k<nb_iargs; k++) {
7174 /* Beware: the third argument and the result
7175 * are in the same register
7180 __asm__ __volatile__ ("mfcr 18");
7182 __asm__ __volatile__ ("mfxer 18");
7185 /* Set up flags for test */
7187 __asm__ __volatile__ ("mtcr 18");
7188 __asm__ __volatile__ ("mtxer 18");
7190 __asm__ __volatile__ ("mfcr 18");
7192 __asm__ __volatile__ ("mfxer 18");
7198 __asm__ __volatile__ ("mtcr 18");
7200 __asm__ __volatile__ ("mtxer 18");
7202 printf("%s %08x, %08x, %08x => %08x (%08x %08x)\n",
7203 name, iargs[i], iargs[j], iargs[k], res, flags, xer);
7205 if (verbose) printf("\n");
7209 #endif /* defined (IS_PPC405) */
7211 static int check_filter (char *filter)
7216 if (filter != NULL) {
7217 c = strchr(filter, '*');
7227 static int check_name (const char* name, const char *filter,
7233 if (filter != NULL) {
7234 for (; isspace(*name); name++)
7236 FDPRINTF("Check '%s' againt '%s' (%s match)\n",
7237 name, filter, exact ? "exact" : "starting");
7238 nlen = strlen(name);
7239 flen = strlen(filter);
7241 if (nlen == flen && memcmp(name, filter, flen) == 0)
7244 if (flen <= nlen && memcmp(name, filter, flen) == 0)
7255 typedef struct insn_sel_flags_t_struct {
7256 int one_arg, two_args, three_args;
7257 int arith, logical, compare, ldst;
7258 int integer, floats, p405, altivec, faltivec;
7262 static void do_tests ( insn_sel_flags_t seln_flags,
7265 #if defined (IS_PPC405)
7270 int nb_args, type, family;
7274 exact = check_filter(filter);
7276 for (i=0; all_tests[i].name != NULL; i++) {
7277 nb_args = all_tests[i].flags & PPC_NB_ARGS;
7278 /* Check number of arguments */
7279 if ((nb_args == 1 && !seln_flags.one_arg) ||
7280 (nb_args == 2 && !seln_flags.two_args) ||
7281 (nb_args == 3 && !seln_flags.three_args))
7283 /* Check instruction type */
7284 type = all_tests[i].flags & PPC_TYPE;
7285 if ((type == PPC_ARITH && !seln_flags.arith) ||
7286 (type == PPC_LOGICAL && !seln_flags.logical) ||
7287 (type == PPC_COMPARE && !seln_flags.compare) ||
7288 (type == PPC_LDST && !seln_flags.ldst))
7290 /* Check instruction family */
7291 family = all_tests[i].flags & PPC_FAMILY;
7292 if ((family == PPC_INTEGER && !seln_flags.integer) ||
7293 (family == PPC_FLOAT && !seln_flags.floats) ||
7294 (family == PPC_405 && !seln_flags.p405) ||
7295 (family == PPC_ALTIVEC && !seln_flags.altivec) ||
7296 (family == PPC_FALTIVEC && !seln_flags.faltivec))
7298 /* Check flags update */
7299 if (((all_tests[i].flags & PPC_CR) && seln_flags.cr == 0) ||
7300 (!(all_tests[i].flags & PPC_CR) && seln_flags.cr == 1))
7302 /* All passed, do the tests */
7303 tests = all_tests[i].tests;
7304 /* Select the test loop */
7307 loop = &int_loops[nb_args - 1];
7310 #if !defined (NO_FLOAT)
7311 loop = &float_loops[nb_args - 1];
7314 fprintf(stderr, "Sorry. "
7315 "PPC floating point instructions tests "
7316 "are disabled on your host\n");
7317 #endif /* !defined (NO_FLOAT) */
7320 #if defined (IS_PPC405)
7321 tmpl = &test_ppc405;
7325 fprintf(stderr, "Sorry. "
7326 "PPC405 instructions tests are disabled on your host\n");
7328 #endif /* defined (IS_PPC405) */
7330 #if defined (HAS_ALTIVEC)
7331 loop = &altivec_int_loops[nb_args - 1];
7334 fprintf(stderr, "Sorry. "
7335 "Altivec instructions tests are disabled on your host\n");
7339 #if defined (HAS_ALTIVEC)
7340 loop = &altivec_float_loops[nb_args - 1];
7343 fprintf(stderr, "Sorry. "
7344 "Altivec float instructions tests "
7345 "are disabled on your host\n");
7349 printf("ERROR: unknown insn family %08x\n", family);
7352 if (1 || verbose > 0)
7353 printf("%s:\n", all_tests[i].name);
7354 for (j=0; tests[j].name != NULL; j++) {
7355 if (check_name(tests[j].name, filter, exact)) {
7357 printf("Test instruction %s\n", tests[j].name);
7358 (*loop)(tests[j].name, tests[j].func, all_tests[i].flags);
7363 if (verbose) printf("\n");
7365 printf("All done. Tested %d different instructions\n", n);
7369 static void usage (void)
7371 #if !defined (USAGE_SIMPLE)
7373 "jm-insns [-1] [-2] [-3] [-*] [-t <type>] [-f <family>] [-u] "
7374 "[-n <filter>] [-r <test_rigour>] [-h]\n"
7375 "\t-1: test opcodes with one argument\n"
7376 "\t-2: test opcodes with two arguments\n"
7377 "\t-3: test opcodes with three arguments\n"
7378 "\t-*: launch test without checking the number of arguments\n"
7379 "\t-t: launch test for instructions of type <type>\n"
7380 "\t recognized types:\n"
7381 "\t\tarith (or a)\n"
7382 "\t\tlogical (or l)\n"
7383 "\t\tcompare (or c)\n"
7384 "\t\tstoreload (or s)\n"
7385 "\t-f: launch test for instructions of family <family>\n"
7386 "\t recognized families:\n"
7387 "\t\tinteger (or i)\n"
7388 "\t\tfloat (or f)\n"
7389 "\t\tppc405 (or mac)\n"
7390 "\t\taltivec (or a)\n"
7391 "\t-u: test instructions that update flags\n"
7392 "\t-n: filter instructions with <filter>\n"
7393 "\t <filter> can be in two forms:\n"
7394 "\t\tname : filter functions that exactly match <name>\n"
7395 "\t\tname* : filter functions that start with <name>\n"
7396 "\t-r: set size of arg tables to use to define <test_rigour>\n"
7397 "\t recognized types:\n"
7398 "\t\tlarge (or l)\n"
7399 "\t\tsmall (or s) - default\n"
7400 "\t-v: verbose (-v -v for more)\n"
7401 "\t-h: print this help\n"
7403 #else // #if !defined (USAGE_SIMPLE)
7405 "Usage: jm-insns [OPTION]\n"
7406 "\t-i: test integer instructions (default)\n"
7407 "\t-f: test floating point instructions\n"
7408 "\t-a: test altivec instructions\n"
7409 "\t-A: test all (int, fp, altivec) instructions\n"
7410 "\t-v: be verbose\n"
7411 "\t-h: display this help and exit\n"
7413 #endif // #if !defined (USAGE_SIMPLE)
7418 int main (int argc, char **argv)
7420 #if !defined (USAGE_SIMPLE)
7421 ////////////////////////////////////////////////////////////////////////
7422 unsigned char *tmp, *filter = NULL;
7423 insn_sel_flags_t flags;
7426 // check HWord_t really is a host word
7427 assert(sizeof(void*) == sizeof(HWord_t));
7431 flags.three_args = 0;
7443 while ((c = getopt(argc, argv, "123t:f:n:r:uvh")) != -1) {
7452 flags.three_args = 1;
7456 if (strcmp(tmp, "arith") == 0 || strcmp(tmp, "a") == 0) {
7458 } else if (strcmp(tmp, "logical") == 0 || strcmp(tmp, "l") == 0) {
7460 } else if (strcmp(tmp, "compare") == 0 || strcmp(tmp, "c") == 0) {
7462 } else if (strcmp(tmp, "storeload") == 0 || strcmp(tmp, "s") == 0) {
7470 if (strcmp(tmp, "integer") == 0 || strcmp(tmp, "i") == 0) {
7472 } else if (strcmp(tmp, "float") == 0 || strcmp(tmp, "f") == 0) {
7474 } else if (strcmp(tmp, "ppc405") == 0 || strcmp(tmp, "mac") == 0) {
7476 } else if (strcmp(tmp, "altivec") == 0 || strcmp(tmp, "a") == 0) {
7488 if (strcmp(tmp, "large") == 0 || strcmp(tmp, "l") == 0) {
7490 } else if (strcmp(tmp, "small") == 0 || strcmp(tmp, "s") == 0) {
7508 fprintf(stderr, "Unknown argument: '%c'\n", c);
7512 fprintf(stderr, "Bad argument for '%c': '%s'\n", c, tmp);
7516 if (argc != optind) {
7518 fprintf(stderr, "Bad number of arguments\n");
7523 if (flags.one_arg == 0 && flags.two_args == 0 && flags.three_args == 0) {
7526 flags.three_args = 1;
7529 if (flags.arith == 0 && flags.logical == 0 &&
7530 flags.compare == 0 && flags.ldst == 0) {
7537 if (flags.integer == 0 && flags.floats == 0 &&
7538 flags.p405 == 0 && flags.altivec == 0 && flags.faltivec == 0) {
7545 // Default cr update
7547 flags.cr = 2; // both
7549 #else // #if !defined (USAGE_SIMPLE)
7550 ////////////////////////////////////////////////////////////////////////
7552 ./jm-insns -i => int insns
7553 ./jm-insns -f => fp insns
7554 ./jm-insns -a => av insns
7555 ./jm-insns -A => int, fp and avinsns
7557 char *filter = NULL;
7558 insn_sel_flags_t flags;
7564 flags.three_args = 1;
7579 while ((c = getopt(argc, argv, "ifahvA")) != -1) {
7605 fprintf(stderr, "Unknown argument: '%c'\n", c);
7611 #endif // #if !defined (USAGE_SIMPLE)
7614 build_iargs_table();
7615 build_fargs_table();
7617 #if defined (HAS_ALTIVEC)
7618 if (flags.altivec || flags.faltivec) {
7619 build_viargs_table();
7620 build_vfargs_table();
7628 printf("\nInstruction Selection:\n");
7629 printf(" n_args: \n");
7630 printf(" one_arg = %d\n", flags.one_arg);
7631 printf(" two_args = %d\n", flags.two_args);
7632 printf(" three_args = %d\n", flags.three_args);
7633 printf(" type: \n");
7634 printf(" arith = %d\n", flags.arith);
7635 printf(" logical = %d\n", flags.logical);
7636 printf(" compare = %d\n", flags.compare);
7637 printf(" ldst = %d\n", flags.ldst);
7638 printf(" family: \n");
7639 printf(" integer = %d\n", flags.integer);
7640 printf(" floats = %d\n", flags.floats);
7641 printf(" p405 = %d\n", flags.p405);
7642 printf(" altivec = %d\n", flags.altivec);
7643 printf(" faltivec = %d\n", flags.faltivec);
7644 printf(" cr update: \n");
7645 printf(" cr = %d\n", flags.cr);
7647 printf(" num args: \n");
7648 printf(" iargs - %d\n", nb_iargs);
7649 printf(" fargs - %d\n", nb_fargs);
7650 #if defined (HAS_ALTIVEC)
7651 printf(" viargs - %d\n", nb_viargs);
7652 printf(" vfargs - %d\n", nb_vfargs);
7657 do_tests( flags, filter );