aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2016-09-29 20:44:32 +0200
committerUros Bizjak <uros@gcc.gnu.org>2016-09-29 20:44:32 +0200
commit2488ebe5ef1788616c2fbc61e05af09f0749ebbe (patch)
treea2e01bfac39fbf7a7b780b5ac05e4d7f81c2b335 /gcc/config
parentf90b32b95bac7d534a96a032af466f1b5087371b (diff)
downloadgcc-2488ebe5ef1788616c2fbc61e05af09f0749ebbe.zip
gcc-2488ebe5ef1788616c2fbc61e05af09f0749ebbe.tar.gz
gcc-2488ebe5ef1788616c2fbc61e05af09f0749ebbe.tar.bz2
re PR target/77756 (__get_cpuid() returns wrong values for level 7 (extended features))
PR target/77756 * config/i386/cpuid.h (__get_cpuid_count): New. (__get_cpuid): Rename __level to __leaf. testsuite/ChangeLog: PR target/77756 * gcc.target/i386/pr77756.c: New test. From-SVN: r240629
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/i386/cpuid.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h
index a4f658a..4ea3f74 100644
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -229,31 +229,37 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
return __eax;
}
-/* Return cpuid data for requested cpuid level, as found in returned
+/* Return cpuid data for requested cpuid leaf, as found in returned
eax, ebx, ecx and edx registers. The function checks if cpuid is
supported and returns 1 for valid cpuid information or 0 for
- unsupported cpuid level. All pointers are required to be non-null. */
+ unsupported cpuid leaf. All pointers are required to be non-null. */
static __inline int
-__get_cpuid (unsigned int __level,
+__get_cpuid (unsigned int __leaf,
unsigned int *__eax, unsigned int *__ebx,
unsigned int *__ecx, unsigned int *__edx)
{
- unsigned int __ext = __level & 0x80000000;
+ unsigned int __ext = __leaf & 0x80000000;
- if (__get_cpuid_max (__ext, 0) < __level)
+ if (__get_cpuid_max (__ext, 0) < __leaf)
return 0;
- if (__ext)
- __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);
- else
- {
- if (__level >= 13)
- __cpuid_count (__level, 1, *__eax, *__ebx, *__ecx, *__edx);
- else if (__level >= 7)
- __cpuid_count (__level, 0, *__eax, *__ebx, *__ecx, *__edx);
- else
- __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);
- }
+ __cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
+ return 1;
+}
+
+/* Same as above, but sub-leaf can be specified. */
+
+static __inline int
+__get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
+ unsigned int *__eax, unsigned int *__ebx,
+ unsigned int *__ecx, unsigned int *__edx)
+{
+ unsigned int __ext = __leaf & 0x80000000;
+
+ if (__get_cpuid_max (__ext, 0) < __leaf)
+ return 0;
+
+ __cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}