Reduced the push/pop sequence to a single pair, and ported this fix over to the other architectures.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404240
This commit is contained in:
parent
604fbcb387
commit
3e860cdcf9
1 changed files with 16 additions and 16 deletions
|
@ -153,17 +153,17 @@ CPU_getCPUIDFeatures(void)
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
#if defined(__GNUC__) && defined(i386)
|
#if defined(__GNUC__) && defined(i386)
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" pushl %%ebx\n"
|
|
||||||
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
||||||
|
" pushl %%ebx \n"
|
||||||
" cpuid # Get and save vendor ID \n"
|
" cpuid # Get and save vendor ID \n"
|
||||||
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
||||||
" jl 1f # We dont have the CPUID instruction\n"
|
" jl 1f # We dont have the CPUID instruction\n"
|
||||||
" xorl %%eax,%%eax \n"
|
" xorl %%eax,%%eax \n"
|
||||||
" incl %%eax \n"
|
" incl %%eax \n"
|
||||||
" cpuid # Get family/model/stepping/features\n"
|
" cpuid # Get family/model/stepping/features\n"
|
||||||
|
" popl %%ebx \n"
|
||||||
" movl %%edx,%0 \n"
|
" movl %%edx,%0 \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
" popl %%ebx\n"
|
|
||||||
: "=m" (features)
|
: "=m" (features)
|
||||||
:
|
:
|
||||||
: "%eax", "%ecx", "%edx"
|
: "%eax", "%ecx", "%edx"
|
||||||
|
@ -173,12 +173,10 @@ CPU_getCPUIDFeatures(void)
|
||||||
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
||||||
" pushq %%rbx\n"
|
" pushq %%rbx\n"
|
||||||
" cpuid # Get and save vendor ID \n"
|
" cpuid # Get and save vendor ID \n"
|
||||||
" popq %%rbx\n"
|
|
||||||
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
||||||
" jl 1f # We dont have the CPUID instruction\n"
|
" jl 1f # We dont have the CPUID instruction\n"
|
||||||
" xorl %%eax,%%eax \n"
|
" xorl %%eax,%%eax \n"
|
||||||
" incl %%eax \n"
|
" incl %%eax \n"
|
||||||
" pushq %%rbx\n"
|
|
||||||
" cpuid # Get family/model/stepping/features\n"
|
" cpuid # Get family/model/stepping/features\n"
|
||||||
" popq %%rbx\n"
|
" popq %%rbx\n"
|
||||||
" movl %%edx,%0 \n"
|
" movl %%edx,%0 \n"
|
||||||
|
@ -190,32 +188,34 @@ CPU_getCPUIDFeatures(void)
|
||||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
||||||
__asm {
|
__asm {
|
||||||
xor eax, eax ; Set up for CPUID instruction
|
xor eax, eax ; Set up for CPUID instruction
|
||||||
|
push ebx
|
||||||
cpuid ; Get and save vendor ID
|
cpuid ; Get and save vendor ID
|
||||||
cmp eax, 1 ; Make sure 1 is valid input for CPUID
|
cmp eax, 1 ; Make sure 1 is valid input for CPUID
|
||||||
jl done ; We dont have the CPUID instruction
|
jl done ; We dont have the CPUID instruction
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
cpuid ; Get family/model/stepping/features
|
cpuid ; Get family/model/stepping/features
|
||||||
|
pop ebx
|
||||||
mov features, edx
|
mov features, edx
|
||||||
done:
|
done:
|
||||||
}
|
}
|
||||||
#elif defined(__sun) && (defined(__i386) || defined(__amd64))
|
#elif defined(__sun) && (defined(__i386) || defined(__amd64))
|
||||||
__asm(
|
__asm(
|
||||||
" movl %ebx,%edi\n"
|
|
||||||
" xorl %eax,%eax \n"
|
" xorl %eax,%eax \n"
|
||||||
|
" pushl %ebx \n"
|
||||||
" cpuid \n"
|
" cpuid \n"
|
||||||
" cmpl $1,%eax \n"
|
" cmpl $1,%eax \n"
|
||||||
" jl 1f \n"
|
" jl 1f \n"
|
||||||
" xorl %eax,%eax \n"
|
" xorl %eax,%eax \n"
|
||||||
" incl %eax \n"
|
" incl %eax \n"
|
||||||
" cpuid \n"
|
" cpuid \n"
|
||||||
|
" popl %ebx \n"
|
||||||
#ifdef __i386
|
#ifdef __i386
|
||||||
" movl %edx,-8(%ebp) \n"
|
" movl %edx,-8(%ebp) \n"
|
||||||
#else
|
#else
|
||||||
" movl %edx,-8(%rbp) \n"
|
" movl %edx,-8(%rbp) \n"
|
||||||
#endif
|
#endif
|
||||||
"1: \n"
|
"1: \n"
|
||||||
" movl %edi,%ebx\n" );
|
|
||||||
#endif
|
#endif
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
return features;
|
return features;
|
||||||
|
@ -228,16 +228,16 @@ CPU_getCPUIDFeaturesExt(void)
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
#if defined(__GNUC__) && defined(i386)
|
#if defined(__GNUC__) && defined(i386)
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" pushl %%ebx\n"
|
|
||||||
" movl $0x80000000,%%eax # Query for extended functions \n"
|
" movl $0x80000000,%%eax # Query for extended functions \n"
|
||||||
|
" pushl %%ebx \n"
|
||||||
" cpuid # Get extended function limit \n"
|
" cpuid # Get extended function limit \n"
|
||||||
" cmpl $0x80000001,%%eax \n"
|
" cmpl $0x80000001,%%eax \n"
|
||||||
" jl 1f # Nope, we dont have function 800000001h\n"
|
" jl 1f # Nope, we dont have function 800000001h\n"
|
||||||
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
||||||
" cpuid # and get the information \n"
|
" cpuid # and get the information \n"
|
||||||
|
" popl %%ebx \n"
|
||||||
" movl %%edx,%0 \n"
|
" movl %%edx,%0 \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
" popl %%ebx\n"
|
|
||||||
: "=m" (features)
|
: "=m" (features)
|
||||||
:
|
:
|
||||||
: "%eax", "%ecx", "%edx"
|
: "%eax", "%ecx", "%edx"
|
||||||
|
@ -245,15 +245,13 @@ CPU_getCPUIDFeaturesExt(void)
|
||||||
#elif defined(__GNUC__) && defined (__x86_64__)
|
#elif defined(__GNUC__) && defined (__x86_64__)
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" movl $0x80000000,%%eax # Query for extended functions \n"
|
" movl $0x80000000,%%eax # Query for extended functions \n"
|
||||||
" pushq %%rbx\n"
|
" pushq %%rbx \n"
|
||||||
" cpuid # Get extended function limit \n"
|
" cpuid # Get extended function limit \n"
|
||||||
" popq %%rbx\n"
|
|
||||||
" cmpl $0x80000001,%%eax \n"
|
" cmpl $0x80000001,%%eax \n"
|
||||||
" jl 1f # Nope, we dont have function 800000001h\n"
|
" jl 1f # Nope, we dont have function 800000001h\n"
|
||||||
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
||||||
" pushq %%rbx\n"
|
|
||||||
" cpuid # and get the information \n"
|
" cpuid # and get the information \n"
|
||||||
" popq %%rbx\n"
|
" popq %%rbx \n"
|
||||||
" movl %%edx,%0 \n"
|
" movl %%edx,%0 \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
: "=m" (features)
|
: "=m" (features)
|
||||||
|
@ -263,30 +261,32 @@ CPU_getCPUIDFeaturesExt(void)
|
||||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,80000000h ; Query for extended functions
|
mov eax,80000000h ; Query for extended functions
|
||||||
|
push ebx
|
||||||
cpuid ; Get extended function limit
|
cpuid ; Get extended function limit
|
||||||
cmp eax,80000001h
|
cmp eax,80000001h
|
||||||
jl done ; Nope, we dont have function 800000001h
|
jl done ; Nope, we dont have function 800000001h
|
||||||
mov eax,80000001h ; Setup extended function 800000001h
|
mov eax,80000001h ; Setup extended function 800000001h
|
||||||
cpuid ; and get the information
|
cpuid ; and get the information
|
||||||
|
pop ebx
|
||||||
mov features,edx
|
mov features,edx
|
||||||
done:
|
done:
|
||||||
}
|
}
|
||||||
#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
|
#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
|
||||||
__asm (
|
__asm (
|
||||||
" movl %ebx,%edi\n"
|
|
||||||
" movl $0x80000000,%eax \n"
|
" movl $0x80000000,%eax \n"
|
||||||
|
" pushl %ebx \n"
|
||||||
" cpuid \n"
|
" cpuid \n"
|
||||||
" cmpl $0x80000001,%eax \n"
|
" cmpl $0x80000001,%eax \n"
|
||||||
" jl 1f \n"
|
" jl 1f \n"
|
||||||
" movl $0x80000001,%eax \n"
|
" movl $0x80000001,%eax \n"
|
||||||
" cpuid \n"
|
" cpuid \n"
|
||||||
|
" popl %ebx \n"
|
||||||
#ifdef __i386
|
#ifdef __i386
|
||||||
" movl %edx,-8(%ebp) \n"
|
" movl %edx,-8(%ebp) \n"
|
||||||
#else
|
#else
|
||||||
" movl %edx,-8(%rbp) \n"
|
" movl %edx,-8(%rbp) \n"
|
||||||
#endif
|
#endif
|
||||||
"1: \n"
|
"1: \n"
|
||||||
" movl %edi,%ebx\n"
|
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue