annotate gcc/config/i386/cpuid.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /*
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 * Copyright (C) 2007-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 * This file is free software; you can redistribute it and/or modify it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 * under the terms of the GNU General Public License as published by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 * Free Software Foundation; either version 3, or (at your option) any
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 * later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 * This file is distributed in the hope that it will be useful, but
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 * General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 * Under Section 7 of GPL version 3, you are granted additional
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 * permissions described in the GCC Runtime Library Exception, version
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 * 3.1, as published by the Free Software Foundation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 * a copy of the GCC Runtime Library Exception along with this program;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 * <http://www.gnu.org/licenses/>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
24 /* %eax */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
25 #define bit_AVX512BF16 (1 << 5)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
26
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 /* %ecx */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #define bit_SSE3 (1 << 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #define bit_PCLMUL (1 << 1)
111
kono
parents: 67
diff changeset
30 #define bit_LZCNT (1 << 5)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #define bit_SSSE3 (1 << 9)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #define bit_FMA (1 << 12)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #define bit_CMPXCHG16B (1 << 13)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 #define bit_SSE4_1 (1 << 19)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #define bit_SSE4_2 (1 << 20)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
36 #define bit_MOVBE (1 << 22)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #define bit_POPCNT (1 << 23)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 #define bit_AES (1 << 25)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #define bit_XSAVE (1 << 26)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #define bit_OSXSAVE (1 << 27)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #define bit_AVX (1 << 28)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
42 #define bit_F16C (1 << 29)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
43 #define bit_RDRND (1 << 30)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 /* %edx */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 #define bit_CMPXCHG8B (1 << 8)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 #define bit_CMOV (1 << 15)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 #define bit_MMX (1 << 23)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 #define bit_FXSAVE (1 << 24)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 #define bit_SSE (1 << 25)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 #define bit_SSE2 (1 << 26)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
111
kono
parents: 67
diff changeset
53 /* Extended Features (%eax == 0x80000001) */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 /* %ecx */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 #define bit_LAHF_LM (1 << 0)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
56 #define bit_ABM (1 << 5)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 #define bit_SSE4a (1 << 6)
111
kono
parents: 67
diff changeset
58 #define bit_PRFCHW (1 << 8)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
59 #define bit_XOP (1 << 11)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
60 #define bit_LWP (1 << 15)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
61 #define bit_FMA4 (1 << 16)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
62 #define bit_TBM (1 << 21)
111
kono
parents: 67
diff changeset
63 #define bit_MWAITX (1 << 29)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 /* %edx */
111
kono
parents: 67
diff changeset
66 #define bit_MMXEXT (1 << 22)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 #define bit_LM (1 << 29)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 #define bit_3DNOWP (1 << 30)
111
kono
parents: 67
diff changeset
69 #define bit_3DNOW (1u << 31)
kono
parents: 67
diff changeset
70
kono
parents: 67
diff changeset
71 /* %ebx */
kono
parents: 67
diff changeset
72 #define bit_CLZERO (1 << 0)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 #define bit_WBNOINVD (1 << 9)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
75 /* Extended Features (%eax == 7) */
111
kono
parents: 67
diff changeset
76 /* %ebx */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
77 #define bit_FSGSBASE (1 << 0)
111
kono
parents: 67
diff changeset
78 #define bit_SGX (1 << 2)
kono
parents: 67
diff changeset
79 #define bit_BMI (1 << 3)
kono
parents: 67
diff changeset
80 #define bit_HLE (1 << 4)
kono
parents: 67
diff changeset
81 #define bit_AVX2 (1 << 5)
kono
parents: 67
diff changeset
82 #define bit_BMI2 (1 << 8)
kono
parents: 67
diff changeset
83 #define bit_RTM (1 << 11)
kono
parents: 67
diff changeset
84 #define bit_MPX (1 << 14)
kono
parents: 67
diff changeset
85 #define bit_AVX512F (1 << 16)
kono
parents: 67
diff changeset
86 #define bit_AVX512DQ (1 << 17)
kono
parents: 67
diff changeset
87 #define bit_RDSEED (1 << 18)
kono
parents: 67
diff changeset
88 #define bit_ADX (1 << 19)
kono
parents: 67
diff changeset
89 #define bit_AVX512IFMA (1 << 21)
kono
parents: 67
diff changeset
90 #define bit_CLFLUSHOPT (1 << 23)
kono
parents: 67
diff changeset
91 #define bit_CLWB (1 << 24)
kono
parents: 67
diff changeset
92 #define bit_AVX512PF (1 << 26)
kono
parents: 67
diff changeset
93 #define bit_AVX512ER (1 << 27)
kono
parents: 67
diff changeset
94 #define bit_AVX512CD (1 << 28)
kono
parents: 67
diff changeset
95 #define bit_SHA (1 << 29)
kono
parents: 67
diff changeset
96 #define bit_AVX512BW (1 << 30)
kono
parents: 67
diff changeset
97 #define bit_AVX512VL (1u << 31)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
111
kono
parents: 67
diff changeset
99 /* %ecx */
kono
parents: 67
diff changeset
100 #define bit_PREFETCHWT1 (1 << 0)
kono
parents: 67
diff changeset
101 #define bit_AVX512VBMI (1 << 1)
kono
parents: 67
diff changeset
102 #define bit_PKU (1 << 3)
kono
parents: 67
diff changeset
103 #define bit_OSPKE (1 << 4)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 #define bit_WAITPKG (1 << 5)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 #define bit_AVX512VBMI2 (1 << 6)
111
kono
parents: 67
diff changeset
106 #define bit_SHSTK (1 << 7)
kono
parents: 67
diff changeset
107 #define bit_GFNI (1 << 8)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 #define bit_VAES (1 << 9)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 #define bit_AVX512VNNI (1 << 11)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 #define bit_VPCLMULQDQ (1 << 10)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 #define bit_AVX512BITALG (1 << 12)
111
kono
parents: 67
diff changeset
112 #define bit_AVX512VPOPCNTDQ (1 << 14)
kono
parents: 67
diff changeset
113 #define bit_RDPID (1 << 22)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 #define bit_MOVDIRI (1 << 27)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 #define bit_MOVDIR64B (1 << 28)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
116 #define bit_ENQCMD (1 << 29)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 #define bit_CLDEMOTE (1 << 25)
111
kono
parents: 67
diff changeset
118
kono
parents: 67
diff changeset
119 /* %edx */
kono
parents: 67
diff changeset
120 #define bit_AVX5124VNNIW (1 << 2)
kono
parents: 67
diff changeset
121 #define bit_AVX5124FMAPS (1 << 3)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
122 #define bit_AVX512VP2INTERSECT (1 << 8)
111
kono
parents: 67
diff changeset
123 #define bit_IBT (1 << 20)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 #define bit_PCONFIG (1 << 18)
111
kono
parents: 67
diff changeset
125 /* XFEATURE_ENABLED_MASK register bits (%eax == 13, %ecx == 0) */
kono
parents: 67
diff changeset
126 #define bit_BNDREGS (1 << 3)
kono
parents: 67
diff changeset
127 #define bit_BNDCSR (1 << 4)
kono
parents: 67
diff changeset
128
kono
parents: 67
diff changeset
129 /* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */
kono
parents: 67
diff changeset
130 #define bit_XSAVEOPT (1 << 0)
kono
parents: 67
diff changeset
131 #define bit_XSAVEC (1 << 1)
kono
parents: 67
diff changeset
132 #define bit_XSAVES (1 << 3)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
134 /* PT sub leaf (%eax == 14, %ecx == 0) */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
135 /* %ebx */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
136 #define bit_PTWRITE (1 << 4)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137
111
kono
parents: 67
diff changeset
138 /* Signatures for different CPU implementations as returned in uses
kono
parents: 67
diff changeset
139 of cpuid with level 0. */
kono
parents: 67
diff changeset
140 #define signature_AMD_ebx 0x68747541
kono
parents: 67
diff changeset
141 #define signature_AMD_ecx 0x444d4163
kono
parents: 67
diff changeset
142 #define signature_AMD_edx 0x69746e65
kono
parents: 67
diff changeset
143
kono
parents: 67
diff changeset
144 #define signature_CENTAUR_ebx 0x746e6543
kono
parents: 67
diff changeset
145 #define signature_CENTAUR_ecx 0x736c7561
kono
parents: 67
diff changeset
146 #define signature_CENTAUR_edx 0x48727561
kono
parents: 67
diff changeset
147
kono
parents: 67
diff changeset
148 #define signature_CYRIX_ebx 0x69727943
kono
parents: 67
diff changeset
149 #define signature_CYRIX_ecx 0x64616574
kono
parents: 67
diff changeset
150 #define signature_CYRIX_edx 0x736e4978
kono
parents: 67
diff changeset
151
kono
parents: 67
diff changeset
152 #define signature_INTEL_ebx 0x756e6547
kono
parents: 67
diff changeset
153 #define signature_INTEL_ecx 0x6c65746e
kono
parents: 67
diff changeset
154 #define signature_INTEL_edx 0x49656e69
kono
parents: 67
diff changeset
155
kono
parents: 67
diff changeset
156 #define signature_TM1_ebx 0x6e617254
kono
parents: 67
diff changeset
157 #define signature_TM1_ecx 0x55504361
kono
parents: 67
diff changeset
158 #define signature_TM1_edx 0x74656d73
kono
parents: 67
diff changeset
159
kono
parents: 67
diff changeset
160 #define signature_TM2_ebx 0x756e6547
kono
parents: 67
diff changeset
161 #define signature_TM2_ecx 0x3638784d
kono
parents: 67
diff changeset
162 #define signature_TM2_edx 0x54656e69
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
111
kono
parents: 67
diff changeset
164 #define signature_NSC_ebx 0x646f6547
kono
parents: 67
diff changeset
165 #define signature_NSC_ecx 0x43534e20
kono
parents: 67
diff changeset
166 #define signature_NSC_edx 0x79622065
kono
parents: 67
diff changeset
167
kono
parents: 67
diff changeset
168 #define signature_NEXGEN_ebx 0x4778654e
kono
parents: 67
diff changeset
169 #define signature_NEXGEN_ecx 0x6e657669
kono
parents: 67
diff changeset
170 #define signature_NEXGEN_edx 0x72446e65
kono
parents: 67
diff changeset
171
kono
parents: 67
diff changeset
172 #define signature_RISE_ebx 0x65736952
kono
parents: 67
diff changeset
173 #define signature_RISE_ecx 0x65736952
kono
parents: 67
diff changeset
174 #define signature_RISE_edx 0x65736952
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 #define signature_SIS_ebx 0x20536953
kono
parents: 67
diff changeset
177 #define signature_SIS_ecx 0x20536953
kono
parents: 67
diff changeset
178 #define signature_SIS_edx 0x20536953
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 #define signature_UMC_ebx 0x20434d55
kono
parents: 67
diff changeset
181 #define signature_UMC_ecx 0x20434d55
kono
parents: 67
diff changeset
182 #define signature_UMC_edx 0x20434d55
kono
parents: 67
diff changeset
183
kono
parents: 67
diff changeset
184 #define signature_VIA_ebx 0x20414956
kono
parents: 67
diff changeset
185 #define signature_VIA_ecx 0x20414956
kono
parents: 67
diff changeset
186 #define signature_VIA_edx 0x20414956
kono
parents: 67
diff changeset
187
kono
parents: 67
diff changeset
188 #define signature_VORTEX_ebx 0x74726f56
kono
parents: 67
diff changeset
189 #define signature_VORTEX_ecx 0x436f5320
kono
parents: 67
diff changeset
190 #define signature_VORTEX_edx 0x36387865
kono
parents: 67
diff changeset
191
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
192 #ifndef __x86_64__
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
193 /* At least one cpu (Winchip 2) does not set %ebx and %ecx
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
194 for cpuid leaf 1. Forcibly zero the two registers before
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
195 calling cpuid as a precaution. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
196 #define __cpuid(level, a, b, c, d) \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
197 do { \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
198 if (__builtin_constant_p (level) && (level) != 1) \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
199 __asm__ ("cpuid\n\t" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
200 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
201 : "0" (level)); \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 else \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
203 __asm__ ("cpuid\n\t" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
204 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 : "0" (level), "1" (0), "2" (0)); \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
206 } while (0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 #else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 #define __cpuid(level, a, b, c, d) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 __asm__ ("cpuid\n\t" \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 : "0" (level))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 #define __cpuid_count(level, count, a, b, c, d) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 __asm__ ("cpuid\n\t" \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 : "0" (level), "2" (count))
111
kono
parents: 67
diff changeset
218
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 /* Return highest supported input value for cpuid instruction. ext can
111
kono
parents: 67
diff changeset
221 be either 0x0 or 0x80000000 to return highest supported value for
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 basic or extended cpuid information. Function returns 0 if cpuid
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 is not supported or whatever cpuid returns in eax register. If sig
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 pointer is non-null, then first four bytes of the signature
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 (as found in ebx register) are returned in location pointed by sig. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 static __inline unsigned int
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 unsigned int __eax, __ebx, __ecx, __edx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 #ifndef __x86_64__
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
233 /* See if we can use cpuid. On AMD64 we always can. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 #if __GNUC__ >= 3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 __asm__ ("pushf{l|d}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 "pushf{l|d}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 "pop{l}\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 "mov{l}\t{%0, %1|%1, %0}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 "xor{l}\t{%2, %0|%0, %2}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 "push{l}\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 "popf{l|d}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 "pushf{l|d}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 "pop{l}\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 "popf{l|d}\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 : "=&r" (__eax), "=&r" (__ebx)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 : "i" (0x00200000));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 #else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 /* Host GCCs older than 3.0 weren't supporting Intel asm syntax
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 nor alternatives in i386 code. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 __asm__ ("pushfl\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 "pushfl\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 "popl\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 "movl\t%0, %1\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 "xorl\t%2, %0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 "pushl\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 "popfl\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 "pushfl\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 "popl\t%0\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 "popfl\n\t"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 : "=&r" (__eax), "=&r" (__ebx)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 : "i" (0x00200000));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 if (!((__eax ^ __ebx) & 0x00200000))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 /* Host supports cpuid. Return highest supported cpuid input value. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 __cpuid (__ext, __eax, __ebx, __ecx, __edx);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 if (__sig)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 *__sig = __ebx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 return __eax;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276
111
kono
parents: 67
diff changeset
277 /* Return cpuid data for requested cpuid leaf, as found in returned
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 eax, ebx, ecx and edx registers. The function checks if cpuid is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 supported and returns 1 for valid cpuid information or 0 for
111
kono
parents: 67
diff changeset
280 unsupported cpuid leaf. All pointers are required to be non-null. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 static __inline int
111
kono
parents: 67
diff changeset
283 __get_cpuid (unsigned int __leaf,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 unsigned int *__eax, unsigned int *__ebx,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 unsigned int *__ecx, unsigned int *__edx)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 {
111
kono
parents: 67
diff changeset
287 unsigned int __ext = __leaf & 0x80000000;
kono
parents: 67
diff changeset
288 unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289
111
kono
parents: 67
diff changeset
290 if (__maxlevel == 0 || __maxlevel < __leaf)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292
111
kono
parents: 67
diff changeset
293 __cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 return 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 }
111
kono
parents: 67
diff changeset
296
kono
parents: 67
diff changeset
297 /* Same as above, but sub-leaf can be specified. */
kono
parents: 67
diff changeset
298
kono
parents: 67
diff changeset
299 static __inline int
kono
parents: 67
diff changeset
300 __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
kono
parents: 67
diff changeset
301 unsigned int *__eax, unsigned int *__ebx,
kono
parents: 67
diff changeset
302 unsigned int *__ecx, unsigned int *__edx)
kono
parents: 67
diff changeset
303 {
kono
parents: 67
diff changeset
304 unsigned int __ext = __leaf & 0x80000000;
kono
parents: 67
diff changeset
305 unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
kono
parents: 67
diff changeset
306
kono
parents: 67
diff changeset
307 if (__maxlevel == 0 || __maxlevel < __leaf)
kono
parents: 67
diff changeset
308 return 0;
kono
parents: 67
diff changeset
309
kono
parents: 67
diff changeset
310 __cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
kono
parents: 67
diff changeset
311 return 1;
kono
parents: 67
diff changeset
312 }