From e81ccd7f33a3bac7453f63008c8343cc02ebaa57 Mon Sep 17 00:00:00 2001 From: pierre Date: Sat, 12 Feb 2011 18:40:02 +0000 Subject: [PATCH] Common: Change cpuid code again Looks like compilers tend to use EBX for parameters if not told otherwise and don't bother to update SP in leaf functions, so PUSH/POP kill local variables. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7151 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/CPUDetect.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index bb3cc28220..45aed22d17 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -37,29 +37,31 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, { #ifdef _LP64 // 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__( - "push %%rbx;" + // restored at the end of the asm block. + __asm__ ( + "mov %%rbx,%%rdi;" "cpuid;" "movl %%ebx,%1;" - "pop %%rbx;" + "mov %%rdi,%%rbx;" : "=a" (*eax), - "=r" (*ebx), + "=g" (*ebx), "=c" (*ecx), "=d" (*edx) - : "a" (*eax) + : "a" (*eax) + : "rdi", "rbx" ); #else __asm__( - "pushl %%ebx;" + "movl %%ebx,%%edi;" "cpuid;" "movl %%ebx,%1;" - "popl %%ebx;" + "movl %%edi,%%ebx;" : "=a" (*eax), - "=r" (*ebx), + "=g" (*ebx), "=c" (*ecx), "=d" (*edx) - : "a" (*eax) + : "a" (*eax) + : "edi", "ebx" ); #endif }