Patchwork symbolic names for processor IDs

login
register
mail settings
Submitter Ulrich Drepper
Date Sept. 8, 2012, 1:45 a.m.
Message ID <CAOPLpQcC3GfXsd_=0KP3ZDCLaDQhmL4RrOtdYTMc_PsEbi0_gw@mail.gmail.com>
Download mbox | patch
Permalink /patch/182495/
State New
Headers show

Comments

Ulrich Drepper - Sept. 8, 2012, 1:45 a.m.
The x86 cpuid instruction returns a processor ID and the
__get_cpuid_max function even explicitly makes the %ebx value directly
available.  But users of that function have to use a cryptic constant.
 How about adding a few macros to make this more transparent?

Patch

Index: gcc/config/i386/cpuid.h
===================================================================
--- gcc/config/i386/cpuid.h	(revision 191084)
+++ gcc/config/i386/cpuid.h	(working copy)
@@ -75,6 +75,16 @@ 
 #define bit_RDSEED	(1 << 18)
 #define bit_ADX		(1 << 19)

+/* Signatures for different CPU implementations as returned in uses
+   of cpuid with level 0.  */
+#define signature_INTEL_ebx	0x756e6547
+#define signature_INTEL_ecx	0x6c65746e
+#define signature_INTEL_edx	0x49656e69
+
+#define signature_AMD_ebx	0x68747541
+#define signature_AMD_ecx	0x444d4163
+#define signature_AMD_edx	0x69746e65
+
 #if defined(__i386__) && defined(__PIC__)
 /* %ebx may be the PIC register.  */
 #if __GNUC__ >= 3