diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2019-05-21 17:17:57 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2019-05-21 17:17:57 +0200 |
commit | 8c365be6e199bcd3e20b36f7907ce5303af105a1 (patch) | |
tree | 3ee590834867bbc1ade00c51d69e9f01cef9264b /gcc | |
parent | 1a815b1822c1ee00a3e48f68d445598c576d9edf (diff) | |
download | gcc-8c365be6e199bcd3e20b36f7907ce5303af105a1.zip gcc-8c365be6e199bcd3e20b36f7907ce5303af105a1.tar.gz gcc-8c365be6e199bcd3e20b36f7907ce5303af105a1.tar.bz2 |
cpuid.h (__cpuid): For 32bit targets...
* config/i386/cpuid.h (__cpuid): For 32bit targets, zero
%ebx and %ecx bafore calling cpuid with leaf 1 or
non-constant leaf argument.
From-SVN: r271469
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/i386/cpuid.h | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eff11af..38f9046 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-05-21 Uroš Bizjak <ubizjak@gmail.com> + + * config/i386/cpuid.h (__cpuid): For 32bit targets, zero + %ebx and %ecx bafore calling cpuid with leaf 1 or + non-constant leaf argument. + 2019-05-21 Alan Modra <amodra@gmail.com> PR target/90545 diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 8ddd425..1d6ef33 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -187,10 +187,27 @@ #define signature_VORTEX_ecx 0x436f5320 #define signature_VORTEX_edx 0x36387865 +#ifndef __x86_64__ +/* At least one cpu (Winchip 2) does not set %ebx and %ecx + for cpuid leaf 1. Forcibly zero the two registers before + calling cpuid as a precaution. */ +#define __cpuid(level, a, b, c, d) \ + do { \ + if (__builtin_constant_p (level) && (level) != 1) \ + __asm__ ("cpuid\n\t" \ + : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ + : "0" (level)); \ + else \ + __asm__ ("cpuid\n\t" \ + : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ + : "0" (level), "1" (0), "2" (0)); \ + } while (0) +#else #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)) +#endif #define __cpuid_count(level, count, a, b, c, d) \ __asm__ ("cpuid\n\t" \ |