1/* Subroutines for the gcc driver.
2 Copyright (C) 2006 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_CMPXCHG16B (1 << 13)
44
45#define bit_3DNOW (1 << 31)
46#define bit_3DNOWP (1 << 30)
47#define bit_LM (1 << 29)
48
49/* This will be called by the spec parser in gcc.c when it sees
50 a %:local_cpu_detect(args) construct. Currently it will be called
--- 12 unchanged lines hidden (view full) ---
63 const char *cpu = NULL;
64 enum processor_type processor = PROCESSOR_I386;
65 unsigned int eax, ebx, ecx, edx;
66 unsigned int max_level;
67 unsigned int vendor;
68 unsigned int ext_level;
69 unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
70 unsigned char has_sse2 = 0, has_sse3 = 0, has_ssse3 = 0, has_cmov = 0;
71 unsigned char has_longmode = 0, has_cmpxchg8b = 0;
72 unsigned char is_amd = 0;
73 unsigned int family = 0;
74 bool arch;
75
76 if (argc < 1)
77 return NULL;
78
79 arch = strcmp (argv[0], "arch") == 0;
--- 35 unchanged lines hidden (view full) ---
115 cpuid (0x80000000, eax, ebx, ecx, edx);
116 ext_level = eax;
117 if (ext_level >= 0x80000000)
118 {
119 cpuid (0x80000001, eax, ebx, ecx, edx);
120 has_3dnow = !!(edx & bit_3DNOW);
121 has_3dnowp = !!(edx & bit_3DNOWP);
122 has_longmode = !!(edx & bit_LM);
123 }
124
125 is_amd = vendor == *(unsigned int*)"Auth";
126
127 if (is_amd)
128 {
129 if (has_mmx)
130 processor = PROCESSOR_K6;
131 if (has_3dnowp)
132 processor = PROCESSOR_ATHLON;
133 if (has_sse2 || has_longmode)
134 processor = PROCESSOR_K8;
135 }
136 else
137 {
138 switch (family)
139 {
140 case 5:
141 /* Default is PROCESSOR_PENTIUM. */
142 break;
--- 118 unchanged lines hidden (view full) ---
261 cpu = "pentium4";
262 break;
263 case PROCESSOR_K8:
264 cpu = "k8";
265 break;
266 case PROCESSOR_NOCONA:
267 cpu = "nocona";
268 break;
269 case PROCESSOR_GENERIC32:
270 case PROCESSOR_GENERIC64:
271 cpu = "generic";
272 break;
273 default:
274 abort ();
275 break;
276 }
--- 31 unchanged lines hidden ---
2 Copyright (C) 2006 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_CMPXCHG16B (1 << 13)
44
45#define bit_3DNOW (1 << 31)
46#define bit_3DNOWP (1 << 30)
47#define bit_LM (1 << 29)
48
49/* This will be called by the spec parser in gcc.c when it sees
50 a %:local_cpu_detect(args) construct. Currently it will be called
--- 12 unchanged lines hidden (view full) ---
63 const char *cpu = NULL;
64 enum processor_type processor = PROCESSOR_I386;
65 unsigned int eax, ebx, ecx, edx;
66 unsigned int max_level;
67 unsigned int vendor;
68 unsigned int ext_level;
69 unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
70 unsigned char has_sse2 = 0, has_sse3 = 0, has_ssse3 = 0, has_cmov = 0;
71 unsigned char has_longmode = 0, has_cmpxchg8b = 0;
72 unsigned char is_amd = 0;
73 unsigned int family = 0;
74 bool arch;
75
76 if (argc < 1)
77 return NULL;
78
79 arch = strcmp (argv[0], "arch") == 0;
--- 35 unchanged lines hidden (view full) ---
115 cpuid (0x80000000, eax, ebx, ecx, edx);
116 ext_level = eax;
117 if (ext_level >= 0x80000000)
118 {
119 cpuid (0x80000001, eax, ebx, ecx, edx);
120 has_3dnow = !!(edx & bit_3DNOW);
121 has_3dnowp = !!(edx & bit_3DNOWP);
122 has_longmode = !!(edx & bit_LM);
123 }
124
125 is_amd = vendor == *(unsigned int*)"Auth";
126
127 if (is_amd)
128 {
129 if (has_mmx)
130 processor = PROCESSOR_K6;
131 if (has_3dnowp)
132 processor = PROCESSOR_ATHLON;
133 if (has_sse2 || has_longmode)
134 processor = PROCESSOR_K8;
135 }
136 else
137 {
138 switch (family)
139 {
140 case 5:
141 /* Default is PROCESSOR_PENTIUM. */
142 break;
--- 118 unchanged lines hidden (view full) ---
261 cpu = "pentium4";
262 break;
263 case PROCESSOR_K8:
264 cpu = "k8";
265 break;
266 case PROCESSOR_NOCONA:
267 cpu = "nocona";
268 break;
269 case PROCESSOR_GENERIC32:
270 case PROCESSOR_GENERIC64:
271 cpu = "generic";
272 break;
273 default:
274 abort ();
275 break;
276 }
--- 31 unchanged lines hidden ---