1 /* Helper file for i386 platform. Runtime check for MMX/SSE/SSE2 support.
2 Used by 20020523-2.c and i386-sse-6.c, and possibly others. */
3 /* Plagarized from 20020523-2.c. */
5 #define bit_MMX (1 << 23)
6 #define bit_SSE (1 << 25)
7 #define bit_SSE2 (1 << 26)
10 #define NOINLINE __attribute__ ((noinline))
13 unsigned int i386_cpuid (void) NOINLINE;
20 /* See if we can use cpuid. */
21 __asm__ ("pushfl; pushfl; popl %0; movl %0,%1; xorl %2,%0;"
22 "pushl %0; popfl; pushfl; popl %0; popfl"
23 : "=&r" (fl1), "=&r" (fl2)
25 if (((fl1 ^ fl2) & 0x00200000) == 0)
28 /* Host supports cpuid. See if cpuid gives capabilities, try
29 CPUID(0). Preserve %ebx and %ecx; cpuid insn clobbers these, we
30 don't need their CPUID values here, and %ebx may be the PIC
32 __asm__ ("push %%ecx ; push %%ebx ; cpuid ; pop %%ebx ; pop %%ecx"
33 : "=a" (fl1) : "0" (0) : "edx", "cc");
37 /* Invoke CPUID(1), return %edx; caller can examine bits to
38 determine what's supported. */
39 __asm__ ("push %%ecx ; push %%ebx ; cpuid ; pop %%ebx ; pop %%ecx" : "=d" (fl2) : "a" (1) : "cc");