1 /* Test functions for direct move support. */
6 extern void abort (void);
9 #define VSX_REG_ATTR "wa"
12 void __attribute__((__noinline__
))
13 copy (TYPE
*a
, TYPE
*b
)
19 void __attribute__((__noinline__
))
20 load_gpr (TYPE
*a
, TYPE
*b
)
23 __asm__ ("# gpr, reg = %0" : "+b" (c
));
29 void __attribute__((__noinline__
))
30 load_fpr (TYPE
*a
, TYPE
*b
)
33 __asm__ ("# fpr, reg = %0" : "+d" (c
));
39 void __attribute__((__noinline__
))
40 load_altivec (TYPE
*a
, TYPE
*b
)
43 __asm__ ("# altivec, reg = %0" : "+v" (c
));
49 void __attribute__((__noinline__
))
50 load_vsx (TYPE
*a
, TYPE
*b
)
53 __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (c
));
59 void __attribute__((__noinline__
))
60 load_gpr_to_vsx (TYPE
*a
, TYPE
*b
)
64 __asm__ ("# gpr, reg = %0" : "+b" (c
));
66 __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (d
));
72 void __attribute__((__noinline__
))
73 load_vsx_to_gpr (TYPE
*a
, TYPE
*b
)
77 __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (c
));
79 __asm__ ("# gpr, reg = %0" : "+b" (d
));
85 typedef void (fn_type (TYPE
*, TYPE
*));
92 const struct test_struct test_functions
[] = {
95 { load_gpr
, "load_gpr" },
98 { load_fpr
, "load_fpr" },
101 { load_altivec
, "load_altivec" },
104 { load_vsx
, "load_vsx" },
106 #ifndef NO_GPR_TO_VSX
107 { load_gpr_to_vsx
, "load_gpr_to_vsx" },
109 #ifndef NO_VSX_TO_GPR
110 { load_vsx_to_gpr
, "load_vsx_to_gpr" },
114 /* Test a given value for each of the functions. */
115 void __attribute__((__noinline__
))
120 for (i
= 0; i
< sizeof (test_functions
) / sizeof (test_functions
[0]); i
++)
124 test_functions
[i
].func (&a
, &b
);
125 if (memcmp ((void *)&a
, (void *)&b
, sizeof (TYPE
)) != 0)
137 unsigned char bytes
[sizeof (TYPE
)];
141 TYPE value
= (TYPE
)-5;
142 for (i
= 0; i
< 12; i
++)
148 for (i
= 0; i
< 8*sizeof (TYPE
); i
++)
149 test_value (((TYPE
)1) << i
);
152 TYPE value
= (TYPE
)0;
153 for (i
= 0; i
< 10; i
++)
156 test_value (~ value
);
160 for (i
= 0; i
< 8*sizeof (TYPE
); i
++)
161 test_value (((TYPE
)1) << i
);
164 TYPE value
= (TYPE
)-5;
165 for (i
= 0; i
< 12; i
++)
171 test_value ((TYPE
)3.1415926535);
172 test_value ((TYPE
)1.23456);
173 test_value ((TYPE
)(-0.0));
174 test_value ((TYPE
)NAN
);
175 test_value ((TYPE
)+INFINITY
);
176 test_value ((TYPE
)-INFINITY
);
179 for (j
= 0; j
< 10; j
++)
181 for (i
= 0; i
< sizeof (TYPE
); i
++)
182 u
.bytes
[i
] = (unsigned char) (rand () >> 4);
184 test_value (u
.value
);