OSDN Git Service

d966e238a104a701c0e9b338fcf5ff946864d223
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / powerpc / altivec_check.h
1 /* A runtime check for AltiVec capability.  */
2 /* Contributed by Ziemowit Laski  <zlaski@apple.com>  */
3
4 #include <signal.h>
5 extern void exit (int);
6 extern void abort (void);
7
8 void 
9 sig_ill_handler (int sig)
10 {
11     exit (0);
12 }
13
14 void altivec_check(void) {
15
16   /* Exit on systems without AltiVec.  */
17   signal (SIGILL, sig_ill_handler);
18 #ifdef __MACH__
19   asm volatile ("vor v0,v0,v0");
20 #else
21   asm volatile ("vor 0,0,0");
22 #endif
23   signal (SIGILL, SIG_DFL);
24 }
25
26 void altivec_cell_check (void)
27 {
28 #ifdef __PPU__
29   /* Exit on systems without the Cell Altivec instructions.  */
30   signal (SIGILL, sig_ill_handler);
31 #ifdef __MACH__
32   asm volatile ("vor v0,v0,v0");
33   asm volatile ("lvlx v0,r0,r0");
34 #else
35   asm volatile ("vor 0,0,0");
36   asm volatile ("lvlx 0,0,0");
37 #endif
38   signal (SIGILL, SIG_DFL);
39 #else
40   /* altivec_cell_check shouldn't be called without -mcpu=cell.  */
41   abort ();
42 #endif
43 }