Stop only if there aren't any usable algorithms
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / isa-check.h
blob8ddbf4dfc2b87805ac06d3ffcd74b7063717b1d1
1 #include "cpuid.h"
3 extern void exit (int) __attribute__((noreturn));
5 /* Determine what instruction set we've been compiled for,
6 and detect that we're running with it. */
7 static void __attribute__((constructor))
8 check_isa (void)
10 int a, b, c, d;
11 int c1, d1, c1e, d1e;
13 c1 = d1 = c1e = d1e = 0;
15 #ifdef __MMX__
16 d1 |= bit_MMX;
17 #endif
18 #ifdef __3dNOW__
19 d1e |= bit_3DNOW;
20 #endif
21 #ifdef __3dNOW_A__
22 d1e |= bit_3DNOWP;
23 #endif
24 #ifdef __SSE__
25 d1 |= bit_SSE;
26 #endif
27 #ifdef __SSE2__
28 d1 |= bit_SSE2;
29 #endif
30 #ifdef __SSE3__
31 c1 |= bit_SSE3;
32 #endif
33 #ifdef __SSSE3__
34 c1 |= bit_SSSE3;
35 #endif
36 #ifdef __SSE4_1__
37 c1 |= bit_SSE4_1;
38 #endif
39 #ifdef __SSE4_2__
40 c1 |= bit_SSE4_2;
41 #endif
42 #ifdef __AES__
43 c1 |= bit_AES;
44 #endif
45 #ifdef __PCLMUL__
46 c1 |= bit_PCLMUL;
47 #endif
48 #ifdef __AVX__
49 c1 |= bit_AVX;
50 #endif
51 #ifdef __FMA__
52 c1 |= bit_FMA;
53 #endif
54 #ifdef __SSE4A__
55 c1e |= bit_SSE4a;
56 #endif
57 #ifdef __FMA4__
58 c1e |= bit_FMA4;
59 #endif
60 #ifdef __XOP__
61 c1e |= bit_XOP;
62 #endif
63 #ifdef __LWP__
64 c1e |= bit_LWP;
65 #endif
67 if (c1 | d1)
69 if (!__get_cpuid (1, &a, &b, &c, &d))
70 goto fail;
71 if ((c & c1) != c1 || (d & d1) != d1)
72 goto fail;
74 if (c1e | d1e)
76 if (!__get_cpuid (0x80000001, &a, &b, &c, &d))
77 goto fail;
78 if ((c & c1e) != c1e || (d & d1e) != d1e)
79 goto fail;
81 return;
83 fail:
84 exit (0);