For CPUID, save EBX on the stack instead of in a register.

This fixes GCC running out of registers when compiling for x86
in release mode.

Thanks to kiesel.
This commit is contained in:
Maarten ter Huurne 2011-12-12 02:14:56 +01:00
parent d75f45979b
commit ee5a29e6f2
1 changed files with 8 additions and 10 deletions

View File

@ -43,29 +43,27 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
// Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to
// restored at the end of the asm block.
__asm__ (
"mov %%rbx,%%rdi;"
"pushq %%rbx;"
"cpuid;"
"movl %%ebx,%1;"
"mov %%rdi,%%rbx;"
"popq %%rbx;"
: "=a" (*eax),
"=r" (*ebx),
"=S" (*ebx),
"=c" (*ecx),
"=d" (*edx)
: "a" (*eax)
: "rdi", "rbx"
);
#else
__asm__(
"movl %%ebx,%%edi;"
__asm__ (
"pushl %%ebx;"
"cpuid;"
"movl %%ebx,%1;"
"movl %%edi,%%ebx;"
"movl %%ebx,%1;"
"popl %%ebx;"
: "=a" (*eax),
"=r" (*ebx),
"=S" (*ebx),
"=c" (*ecx),
"=d" (*edx)
: "a" (*eax)
: "edi", "ebx"
);
#endif
}