1/* Subroutines for the gcc driver.
2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
--- 24 unchanged lines hidden (view full) ---
35#define bit_CMPXCHG8B (1 << 8)
36#define bit_CMOV (1 << 15)
37#define bit_MMX (1 << 23)
38#define bit_SSE (1 << 25)
39#define bit_SSE2 (1 << 26)
40
41#define bit_SSE3 (1 << 0)
42#define bit_SSSE3 (1 << 9)
43#define bit_SSE4a (1 << 6)
44#define bit_CMPXCHG16B (1 << 13)
45
46#define bit_3DNOW (1 << 31)
47#define bit_3DNOWP (1 << 30)
48#define bit_LM (1 << 29)
49
50/* This will be called by the spec parser in gcc.c when it sees
51 a %:local_cpu_detect(args) construct. Currently it will be called
--- 12 unchanged lines hidden (view full) ---
64 const char *cpu = NULL;
65 enum processor_type processor = PROCESSOR_I386;
66 unsigned int eax, ebx, ecx, edx;
67 unsigned int max_level;
68 unsigned int vendor;
69 unsigned int ext_level;
70 unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
71 unsigned char has_sse2 = 0, has_sse3 = 0, has_ssse3 = 0, has_cmov = 0;
72 unsigned char has_longmode = 0, has_cmpxchg8b = 0, has_sse4a = 0;
73 unsigned char is_amd = 0;
74 unsigned int family = 0;
75 bool arch;
76
77 if (argc < 1)
78 return NULL;
79
80 arch = strcmp (argv[0], "arch") == 0;
--- 35 unchanged lines hidden (view full) ---
116 cpuid (0x80000000, eax, ebx, ecx, edx);
117 ext_level = eax;
118 if (ext_level >= 0x80000000)
119 {
120 cpuid (0x80000001, eax, ebx, ecx, edx);
121 has_3dnow = !!(edx & bit_3DNOW);
122 has_3dnowp = !!(edx & bit_3DNOWP);
123 has_longmode = !!(edx & bit_LM);
124 has_sse4a = !!(ecx & bit_SSE4a);
125 }
126
127 is_amd = vendor == *(unsigned int*)"Auth";
128
129 if (is_amd)
130 {
131 if (has_mmx)
132 processor = PROCESSOR_K6;
133 if (has_3dnowp)
134 processor = PROCESSOR_ATHLON;
135 if (has_sse2 || has_longmode)
136 processor = PROCESSOR_K8;
137 if (has_sse4a)
138 processor = PROCESSOR_AMDFAM10;
139 }
140 else
141 {
142 switch (family)
143 {
144 case 5:
145 /* Default is PROCESSOR_PENTIUM. */
146 break;
--- 118 unchanged lines hidden (view full) ---
265 cpu = "pentium4";
266 break;
267 case PROCESSOR_K8:
268 cpu = "k8";
269 break;
270 case PROCESSOR_NOCONA:
271 cpu = "nocona";
272 break;
273 case PROCESSOR_AMDFAM10:
274 cpu = "amdfam10";
275 break;
276 case PROCESSOR_GENERIC32:
277 case PROCESSOR_GENERIC64:
278 cpu = "generic";
279 break;
280 default:
281 abort ();
282 break;
283 }
--- 31 unchanged lines hidden ---
2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
--- 24 unchanged lines hidden (view full) ---
35#define bit_CMPXCHG8B (1 << 8)
36#define bit_CMOV (1 << 15)
37#define bit_MMX (1 << 23)
38#define bit_SSE (1 << 25)
39#define bit_SSE2 (1 << 26)
40
41#define bit_SSE3 (1 << 0)
42#define bit_SSSE3 (1 << 9)
43#define bit_SSE4a (1 << 6)
44#define bit_CMPXCHG16B (1 << 13)
45
46#define bit_3DNOW (1 << 31)
47#define bit_3DNOWP (1 << 30)
48#define bit_LM (1 << 29)
49
50/* This will be called by the spec parser in gcc.c when it sees
51 a %:local_cpu_detect(args) construct. Currently it will be called
--- 12 unchanged lines hidden (view full) ---
64 const char *cpu = NULL;
65 enum processor_type processor = PROCESSOR_I386;
66 unsigned int eax, ebx, ecx, edx;
67 unsigned int max_level;
68 unsigned int vendor;
69 unsigned int ext_level;
70 unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
71 unsigned char has_sse2 = 0, has_sse3 = 0, has_ssse3 = 0, has_cmov = 0;
72 unsigned char has_longmode = 0, has_cmpxchg8b = 0, has_sse4a = 0;
73 unsigned char is_amd = 0;
74 unsigned int family = 0;
75 bool arch;
76
77 if (argc < 1)
78 return NULL;
79
80 arch = strcmp (argv[0], "arch") == 0;
--- 35 unchanged lines hidden (view full) ---
116 cpuid (0x80000000, eax, ebx, ecx, edx);
117 ext_level = eax;
118 if (ext_level >= 0x80000000)
119 {
120 cpuid (0x80000001, eax, ebx, ecx, edx);
121 has_3dnow = !!(edx & bit_3DNOW);
122 has_3dnowp = !!(edx & bit_3DNOWP);
123 has_longmode = !!(edx & bit_LM);
124 has_sse4a = !!(ecx & bit_SSE4a);
125 }
126
127 is_amd = vendor == *(unsigned int*)"Auth";
128
129 if (is_amd)
130 {
131 if (has_mmx)
132 processor = PROCESSOR_K6;
133 if (has_3dnowp)
134 processor = PROCESSOR_ATHLON;
135 if (has_sse2 || has_longmode)
136 processor = PROCESSOR_K8;
137 if (has_sse4a)
138 processor = PROCESSOR_AMDFAM10;
139 }
140 else
141 {
142 switch (family)
143 {
144 case 5:
145 /* Default is PROCESSOR_PENTIUM. */
146 break;
--- 118 unchanged lines hidden (view full) ---
265 cpu = "pentium4";
266 break;
267 case PROCESSOR_K8:
268 cpu = "k8";
269 break;
270 case PROCESSOR_NOCONA:
271 cpu = "nocona";
272 break;
273 case PROCESSOR_AMDFAM10:
274 cpu = "amdfam10";
275 break;
276 case PROCESSOR_GENERIC32:
277 case PROCESSOR_GENERIC64:
278 cpu = "generic";
279 break;
280 default:
281 abort ();
282 break;
283 }
--- 31 unchanged lines hidden ---