1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
13 /* 2. Redistributions in binary form must reproduce the above */
14 /* copyright notice, this list of conditions and the following */
15 /* disclaimer in the documentation and/or other materials */
16 /* provided with the distribution. */
18 /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19 /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23 /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27 /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30 /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31 /* POSSIBILITY OF SUCH DAMAGE. */
33 /* The views and conclusions contained in the software and */
34 /* documentation are those of the authors and should not be */
35 /* interpreted as representing official policies, either expressed */
36 /* or implied, of The University of Texas at Austin. */
37 /*********************************************************************/
44 #define CPUTYPE_SANDYBRIDGE CPUTYPE_NEHALEM
45 #define CORE_SANDYBRIDGE CORE_NEHALEM
46 #define CPUTYPE_BULLDOZER CPUTYPE_BARCELONA
47 #define CORE_BULLDOZER CORE_BARCELONA
52 #if defined(__APPLE__) && defined(__i386__)
53 void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx);
55 static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx){
57 ("cpuid": "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (op) : "cc");
65 unsigned int id, a, b, c, d;
74 extern idlist_t idlist[];
75 extern vendor_t vendor[];
77 static int cv = VENDOR;
79 void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx){
81 static int current = 0;
83 int start = vendor[cv].start;
84 int stop = vendor[cv].stop;
85 int count = stop - start;
87 if ((current < start) || (current > stop)) current = start;
89 while ((count > 0) && (idlist[current].id != op)) {
92 if (current > stop) current = start;
97 *eax = idlist[current].a;
98 *ebx = idlist[current].b;
99 *ecx = idlist[current].c;
100 *edx = idlist[current].d;
105 static inline int have_cpuid(void){
106 int eax, ebx, ecx, edx;
108 cpuid(0, &eax, &ebx, &ecx, &edx);
112 static inline int have_excpuid(void){
113 int eax, ebx, ecx, edx;
115 cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
120 static inline void xgetbv(int op, int * eax, int * edx){
122 ("xgetbv": "=a" (*eax), "=d" (*edx) : "c" (op) : "cc");
128 int eax, ebx, ecx, edx;
131 cpuid(1, &eax, &ebx, &ecx, &edx);
132 if ((ecx & (1 << 28)) != 0 && (ecx & (1 << 27)) != 0){
133 xgetbv(0, &eax, &edx);
135 ret=1; //OS support AVX
145 int get_vendor(void){
146 int eax, ebx, ecx, edx;
149 cpuid(0, &eax, &ebx, &ecx, &edx);
151 *(int *)(&vendor[0]) = ebx;
152 *(int *)(&vendor[4]) = edx;
153 *(int *)(&vendor[8]) = ecx;
154 vendor[12] = (char)0;
156 if (!strcmp(vendor, "GenuineIntel")) return VENDOR_INTEL;
157 if (!strcmp(vendor, " UMC UMC UMC")) return VENDOR_UMC;
158 if (!strcmp(vendor, "AuthenticAMD")) return VENDOR_AMD;
159 if (!strcmp(vendor, "CyrixInstead")) return VENDOR_CYRIX;
160 if (!strcmp(vendor, "NexGenDriven")) return VENDOR_NEXGEN;
161 if (!strcmp(vendor, "CentaurHauls")) return VENDOR_CENTAUR;
162 if (!strcmp(vendor, "RiseRiseRise")) return VENDOR_RISE;
163 if (!strcmp(vendor, " SiS SiS SiS")) return VENDOR_SIS;
164 if (!strcmp(vendor, "GenuineTMx86")) return VENDOR_TRANSMETA;
165 if (!strcmp(vendor, "Geode by NSC")) return VENDOR_NSC;
167 if ((eax == 0) || ((eax & 0x500) != 0)) return VENDOR_INTEL;
169 return VENDOR_UNKNOWN;
172 int get_cputype(int gettype){
173 int eax, ebx, ecx, edx;
174 int extend_family, family;
175 int extend_model, model;
179 cpuid(1, &eax, &ebx, &ecx, &edx);
183 return BITMASK(eax, 20, 0xff);
185 return BITMASK(eax, 16, 0x0f);
187 return BITMASK(eax, 12, 0x03);
189 return BITMASK(eax, 8, 0x0f);
191 return BITMASK(eax, 4, 0x0f);
193 return BITMASK(ebx, 24, 0x0f);
195 return BITMASK(ebx, 16, 0x0f);
197 return BITMASK(ebx, 8, 0x0f);
199 return BITMASK(eax, 0, 0x0f);
201 return BITMASK(ebx, 0, 0xff);
203 if (have_cpuid() < 4) return 0;
204 cpuid(4, &eax, &ebx, &ecx, &edx);
205 return BITMASK(eax, 14, 0xfff);
207 if (have_cpuid() < 4) return 0;
208 cpuid(4, &eax, &ebx, &ecx, &edx);
209 return BITMASK(eax, 26, 0x3f);
212 if ((edx & (1 << 3)) != 0) feature |= HAVE_PSE;
213 if ((edx & (1 << 15)) != 0) feature |= HAVE_CMOV;
214 if ((edx & (1 << 19)) != 0) feature |= HAVE_CFLUSH;
215 if ((edx & (1 << 23)) != 0) feature |= HAVE_MMX;
216 if ((edx & (1 << 25)) != 0) feature |= HAVE_SSE;
217 if ((edx & (1 << 26)) != 0) feature |= HAVE_SSE2;
218 if ((edx & (1 << 27)) != 0) {
219 if (BITMASK(ebx, 16, 0x0f) > 0) feature |= HAVE_HIT;
221 if ((ecx & (1 << 0)) != 0) feature |= HAVE_SSE3;
222 if ((ecx & (1 << 9)) != 0) feature |= HAVE_SSSE3;
223 if ((ecx & (1 << 19)) != 0) feature |= HAVE_SSE4_1;
224 if ((ecx & (1 << 20)) != 0) feature |= HAVE_SSE4_2;
226 if (support_avx()) feature |= HAVE_AVX;
229 if (have_excpuid() >= 0x01) {
230 cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
231 if ((ecx & (1 << 6)) != 0) feature |= HAVE_SSE4A;
232 if ((ecx & (1 << 7)) != 0) feature |= HAVE_MISALIGNSSE;
234 if ((ecx & (1 << 16)) != 0) feature |= HAVE_FMA4;
236 if ((edx & (1 << 30)) != 0) feature |= HAVE_3DNOWEX;
237 if ((edx & (1 << 31)) != 0) feature |= HAVE_3DNOW;
240 if (have_excpuid() >= 0x1a) {
241 cpuid(0x8000001a, &eax, &ebx, &ecx, &edx);
242 if ((eax & (1 << 0)) != 0) feature |= HAVE_128BITFPU;
243 if ((eax & (1 << 1)) != 0) feature |= HAVE_FASTMOVU;
250 int get_cacheinfo(int type, cache_info_t *cacheinfo){
251 int eax, ebx, ecx, edx, cpuid_level;
254 cache_info_t LC1, LD1, L2, L3,
255 ITB, DTB, LITB, LDTB,
256 L2ITB, L2DTB, L2LITB, L2LDTB;
258 LC1.size = 0; LC1.associative = 0; LC1.linesize = 0; LC1.shared = 0;
259 LD1.size = 0; LD1.associative = 0; LD1.linesize = 0; LD1.shared = 0;
260 L2.size = 0; L2.associative = 0; L2.linesize = 0; L2.shared = 0;
261 L3.size = 0; L3.associative = 0; L3.linesize = 0; L3.shared = 0;
262 ITB.size = 0; ITB.associative = 0; ITB.linesize = 0; ITB.shared = 0;
263 DTB.size = 0; DTB.associative = 0; DTB.linesize = 0; DTB.shared = 0;
264 LITB.size = 0; LITB.associative = 0; LITB.linesize = 0; LITB.shared = 0;
265 LDTB.size = 0; LDTB.associative = 0; LDTB.linesize = 0; LDTB.shared = 0;
266 L2ITB.size = 0; L2ITB.associative = 0; L2ITB.linesize = 0; L2ITB.shared = 0;
267 L2DTB.size = 0; L2DTB.associative = 0; L2DTB.linesize = 0; L2DTB.shared = 0;
268 L2LITB.size = 0; L2LITB.associative = 0; L2LITB.linesize = 0; L2LITB.shared = 0;
269 L2LDTB.size = 0; L2LDTB.associative = 0; L2LDTB.linesize = 0; L2LDTB.shared = 0;
271 cpuid(0, &cpuid_level, &ebx, &ecx, &edx);
273 if (cpuid_level > 1) {
275 cpuid(2, &eax, &ebx, &ecx, &edx);
277 info[ 0] = BITMASK(eax, 8, 0xff);
278 info[ 1] = BITMASK(eax, 16, 0xff);
279 info[ 2] = BITMASK(eax, 24, 0xff);
281 info[ 3] = BITMASK(ebx, 0, 0xff);
282 info[ 4] = BITMASK(ebx, 8, 0xff);
283 info[ 5] = BITMASK(ebx, 16, 0xff);
284 info[ 6] = BITMASK(ebx, 24, 0xff);
286 info[ 7] = BITMASK(ecx, 0, 0xff);
287 info[ 8] = BITMASK(ecx, 8, 0xff);
288 info[ 9] = BITMASK(ecx, 16, 0xff);
289 info[10] = BITMASK(ecx, 24, 0xff);
291 info[11] = BITMASK(edx, 0, 0xff);
292 info[12] = BITMASK(edx, 8, 0xff);
293 info[13] = BITMASK(edx, 16, 0xff);
294 info[14] = BITMASK(edx, 24, 0xff);
296 for (i = 0; i < 15; i++){
300 /* This table is from http://www.sandpile.org/ia32/cpuid.htm */
309 LITB.associative = 0;
319 LDTB.associative = 4;
324 LDTB.associative = 4;
483 if ((get_cputype(GET_FAMILY) == 0x0f) && (get_cputype(GET_MODEL) == 0x06)) {
528 LITB.associative = 0;
537 LITB.associative = 0;
546 LITB.associative = 0;
552 LITB.associative = 0;
558 LDTB.associative = 4;
563 LDTB.associative = 4;
571 LDTB.associative = 0;
580 LDTB.associative = 0;
589 LDTB.associative = 0;
741 L2DTB.associative = 0;
751 LITB.associative = 4;
838 if (get_vendor() == VENDOR_INTEL) {
839 cpuid(0x80000000, &cpuid_level, &ebx, &ecx, &edx);
840 if (cpuid_level >= 0x80000006) {
841 cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
843 L2.size = BITMASK(ecx, 16, 0xffff);
844 L2.associative = BITMASK(ecx, 12, 0x0f);
845 L2.linesize = BITMASK(ecx, 0, 0xff);
849 if ((get_vendor() == VENDOR_AMD) || (get_vendor() == VENDOR_CENTAUR)) {
850 cpuid(0x80000005, &eax, &ebx, &ecx, &edx);
853 LDTB.associative = BITMASK(eax, 24, 0xff);
854 if (LDTB.associative == 0xff) LDTB.associative = 0;
855 LDTB.linesize = BITMASK(eax, 16, 0xff);
858 LITB.associative = BITMASK(eax, 8, 0xff);
859 if (LITB.associative == 0xff) LITB.associative = 0;
860 LITB.linesize = BITMASK(eax, 0, 0xff);
863 DTB.associative = BITMASK(ebx, 24, 0xff);
864 if (DTB.associative == 0xff) DTB.associative = 0;
865 DTB.linesize = BITMASK(ebx, 16, 0xff);
868 ITB.associative = BITMASK(ebx, 8, 0xff);
869 if (ITB.associative == 0xff) ITB.associative = 0;
870 ITB.linesize = BITMASK(ebx, 0, 0xff);
872 LD1.size = BITMASK(ecx, 24, 0xff);
873 LD1.associative = BITMASK(ecx, 16, 0xff);
874 if (LD1.associative == 0xff) LD1.associative = 0;
875 LD1.linesize = BITMASK(ecx, 0, 0xff);
877 LC1.size = BITMASK(ecx, 24, 0xff);
878 LC1.associative = BITMASK(ecx, 16, 0xff);
879 if (LC1.associative == 0xff) LC1.associative = 0;
880 LC1.linesize = BITMASK(ecx, 0, 0xff);
882 cpuid(0x80000006, &eax, &ebx, &ecx, &edx);
885 L2LDTB.associative = BITMASK(eax, 24, 0xff);
886 if (L2LDTB.associative == 0xff) L2LDTB.associative = 0;
887 L2LDTB.linesize = BITMASK(eax, 16, 0xff);
890 L2LITB.associative = BITMASK(eax, 8, 0xff);
891 if (L2LITB.associative == 0xff) L2LITB.associative = 0;
892 L2LITB.linesize = BITMASK(eax, 0, 0xff);
895 L2DTB.associative = BITMASK(ebx, 24, 0xff);
896 if (L2DTB.associative == 0xff) L2DTB.associative = 0;
897 L2DTB.linesize = BITMASK(ebx, 16, 0xff);
900 L2ITB.associative = BITMASK(ebx, 8, 0xff);
901 if (L2ITB.associative == 0xff) L2ITB.associative = 0;
902 L2ITB.linesize = BITMASK(ebx, 0, 0xff);
904 L2.size = BITMASK(ecx, 16, 0xffff);
905 L2.associative = BITMASK(ecx, 12, 0xf);
906 if (L2.associative == 0xff) L2.associative = 0;
907 L2.linesize = BITMASK(ecx, 0, 0xff);
909 L3.size = BITMASK(edx, 18, 0x3fff) * 512;
910 L3.associative = BITMASK(edx, 12, 0xf);
911 if (L3.associative == 0xff) L2.associative = 0;
912 L3.linesize = BITMASK(edx, 0, 0xff);
918 case CACHE_INFO_L1_I :
921 case CACHE_INFO_L1_D :
930 case CACHE_INFO_L1_DTB :
933 case CACHE_INFO_L1_ITB :
936 case CACHE_INFO_L1_LDTB :
939 case CACHE_INFO_L1_LITB :
942 case CACHE_INFO_L2_DTB :
945 case CACHE_INFO_L2_ITB :
948 case CACHE_INFO_L2_LDTB :
951 case CACHE_INFO_L2_LITB :
958 int get_cpuname(void){
960 int family, exfamily, model, vendor, exmodel;
962 if (!have_cpuid()) return CPUTYPE_80386;
964 family = get_cputype(GET_FAMILY);
965 exfamily = get_cputype(GET_EXFAMILY);
966 model = get_cputype(GET_MODEL);
967 exmodel = get_cputype(GET_EXMODEL);
969 vendor = get_vendor();
971 if (vendor == VENDOR_INTEL){
974 return CPUTYPE_80486;
976 return CPUTYPE_PENTIUM;
985 return CPUTYPE_PENTIUM2;
990 return CPUTYPE_PENTIUM3;
994 return CPUTYPE_PENTIUMM;
996 return CPUTYPE_CORE2;
1002 return CPUTYPE_CORE2;
1004 return CPUTYPE_PENRYN;
1009 return CPUTYPE_NEHALEM;
1011 return CPUTYPE_ATOM;
1013 return CPUTYPE_DUNNINGTON;
1019 //Intel Core (Clarkdale) / Core (Arrandale)
1020 // Pentium (Clarkdale) / Pentium Mobile (Arrandale)
1021 // Xeon (Clarkdale), 32nm
1022 return CPUTYPE_NEHALEM;
1024 //Intel Core i5-2000 /i7-2000 (Sandy Bridge)
1026 return CPUTYPE_SANDYBRIDGE;
1028 return CPUTYPE_NEHALEM; //OS doesn't support AVX
1030 //Xeon Processor 5600 (Westmere-EP)
1031 return CPUTYPE_NEHALEM;
1033 //Intel Core i7-3000 / Xeon E5 (Sandy Bridge)
1035 return CPUTYPE_SANDYBRIDGE;
1037 return CPUTYPE_NEHALEM;
1039 //Xeon Processor E7 (Westmere-EX)
1040 return CPUTYPE_NEHALEM;
1047 return CPUTYPE_SANDYBRIDGE;
1049 return CPUTYPE_NEHALEM;
1055 return CPUTYPE_ITANIUM;
1059 return CPUTYPE_PENTIUM4;
1061 return CPUTYPE_ITANIUM;
1065 return CPUTYPE_INTEL_UNKNOWN;
1068 if (vendor == VENDOR_AMD){
1071 return CPUTYPE_AMD5X86;
1073 return CPUTYPE_AMDK6;
1075 return CPUTYPE_ATHLON;
1080 return CPUTYPE_OPTERON;
1083 return CPUTYPE_BARCELONA;
1084 case 6: //AMD Bulldozer Opteron 6200 / Opteron 4200 / AMD FX-Series
1086 return CPUTYPE_BULLDOZER;
1088 return CPUTYPE_BARCELONA; //OS don't support AVX.
1090 return CPUTYPE_BOBCAT;
1094 return CPUTYPE_AMD_UNKNOWN;
1097 if (vendor == VENDOR_CYRIX){
1100 return CPUTYPE_CYRIX5X86;
1102 return CPUTYPE_CYRIXM1;
1104 return CPUTYPE_CYRIXM2;
1106 return CPUTYPE_CYRIX_UNKNOWN;
1109 if (vendor == VENDOR_NEXGEN){
1112 return CPUTYPE_NEXGENNX586;
1114 return CPUTYPE_NEXGEN_UNKNOWN;
1117 if (vendor == VENDOR_CENTAUR){
1120 return CPUTYPE_CENTAURC6;
1123 return CPUTYPE_NANO;
1127 return CPUTYPE_VIAC3;
1130 if (vendor == VENDOR_RISE){
1133 return CPUTYPE_RISEMP6;
1135 return CPUTYPE_RISE_UNKNOWN;
1138 if (vendor == VENDOR_SIS){
1141 return CPUTYPE_SYS55X;
1143 return CPUTYPE_SIS_UNKNOWN;
1146 if (vendor == VENDOR_TRANSMETA){
1149 return CPUTYPE_CRUSOETM3X;
1151 return CPUTYPE_TRANSMETA_UNKNOWN;
1154 if (vendor == VENDOR_NSC){
1157 return CPUTYPE_NSGEODE;
1159 return CPUTYPE_NSC_UNKNOWN;
1162 return CPUTYPE_UNKNOWN;
1165 static char *cpuname[] = {
1175 "TRANSMETA_UNKNOWN",
1215 static char *lowercpuname[] = {
1225 "transmeta_unknown",
1264 static char *corename[] = {
1290 static char *corename_lower[] = {
1317 char *get_cpunamechar(void){
1318 return cpuname[get_cpuname()];
1321 char *get_lower_cpunamechar(void){
1322 return lowercpuname[get_cpuname()];
1326 int get_coretype(void){
1328 int family, exfamily, model, exmodel, vendor;
1330 if (!have_cpuid()) return CORE_80486;
1332 family = get_cputype(GET_FAMILY);
1333 exfamily = get_cputype(GET_EXFAMILY);
1334 model = get_cputype(GET_MODEL);
1335 exmodel = get_cputype(GET_EXMODEL);
1337 vendor = get_vendor();
1339 if (vendor == VENDOR_INTEL){
1362 return CORE_COPPERMINE;
1381 return CORE_NEHALEM;
1385 return CORE_DUNNINGTON;
1391 //Intel Core (Clarkdale) / Core (Arrandale)
1392 // Pentium (Clarkdale) / Pentium Mobile (Arrandale)
1393 // Xeon (Clarkdale), 32nm
1394 return CORE_NEHALEM;
1396 //Intel Core i5-2000 /i7-2000 (Sandy Bridge)
1398 return CORE_SANDYBRIDGE;
1400 return CORE_NEHALEM; //OS doesn't support AVX
1402 //Xeon Processor 5600 (Westmere-EP)
1403 return CORE_NEHALEM;
1405 //Intel Core i7-3000 / Xeon E5 (Sandy Bridge)
1407 return CORE_SANDYBRIDGE;
1409 return CORE_NEHALEM; //OS doesn't support AVX
1411 //Xeon Processor E7 (Westmere-EX)
1412 return CORE_NEHALEM;
1419 return CORE_SANDYBRIDGE;
1421 return CORE_NEHALEM; //OS doesn't support AVX
1428 if (model <= 0x2) return CORE_NORTHWOOD;
1429 else return CORE_PRESCOTT;
1433 if (vendor == VENDOR_AMD){
1434 if (family <= 0x5) return CORE_80486;
1435 if (family <= 0xe) return CORE_ATHLON;
1437 if ((exfamily == 0) || (exfamily == 2)) return CORE_OPTERON;
1438 else if (exfamily == 5) return CORE_BOBCAT;
1439 else if (exfamily == 6) {
1440 //AMD Bulldozer Opteron 6200 / Opteron 4200 / AMD FX-Series
1442 return CORE_BULLDOZER;
1444 return CORE_BARCELONA; //OS don't support AVX. Use old kernels.
1445 }else return CORE_BARCELONA;
1449 if (vendor == VENDOR_CENTAUR) {
1458 return CORE_UNKNOWN;
1461 void get_cpuconfig(void){
1466 printf("#define %s\n", cpuname[get_cpuname()]);
1469 if (get_coretype() != CORE_P5) {
1471 get_cacheinfo(CACHE_INFO_L1_I, &info);
1472 if (info.size > 0) {
1473 printf("#define L1_CODE_SIZE %d\n", info.size * 1024);
1474 printf("#define L1_CODE_ASSOCIATIVE %d\n", info.associative);
1475 printf("#define L1_CODE_LINESIZE %d\n", info.linesize);
1478 get_cacheinfo(CACHE_INFO_L1_D, &info);
1479 if (info.size > 0) {
1480 printf("#define L1_DATA_SIZE %d\n", info.size * 1024);
1481 printf("#define L1_DATA_ASSOCIATIVE %d\n", info.associative);
1482 printf("#define L1_DATA_LINESIZE %d\n", info.linesize);
1485 get_cacheinfo(CACHE_INFO_L2, &info);
1486 if (info.size > 0) {
1487 printf("#define L2_SIZE %d\n", info.size * 1024);
1488 printf("#define L2_ASSOCIATIVE %d\n", info.associative);
1489 printf("#define L2_LINESIZE %d\n", info.linesize);
1492 get_cacheinfo(CACHE_INFO_L3, &info);
1493 if (info.size > 0) {
1494 printf("#define L3_SIZE %d\n", info.size * 1024);
1495 printf("#define L3_ASSOCIATIVE %d\n", info.associative);
1496 printf("#define L3_LINESIZE %d\n", info.linesize);
1499 get_cacheinfo(CACHE_INFO_L1_ITB, &info);
1500 if (info.size > 0) {
1501 printf("#define ITB_SIZE %d\n", info.size * 1024);
1502 printf("#define ITB_ASSOCIATIVE %d\n", info.associative);
1503 printf("#define ITB_ENTRIES %d\n", info.linesize);
1506 get_cacheinfo(CACHE_INFO_L1_DTB, &info);
1507 if (info.size > 0) {
1508 printf("#define DTB_SIZE %d\n", info.size * 1024);
1509 printf("#define DTB_ASSOCIATIVE %d\n", info.associative);
1510 printf("#define DTB_DEFAULT_ENTRIES %d\n", info.linesize);
1513 features = get_cputype(GET_FEATURE);
1515 if (features & HAVE_CMOV ) printf("#define HAVE_CMOV\n");
1516 if (features & HAVE_MMX ) printf("#define HAVE_MMX\n");
1517 if (features & HAVE_SSE ) printf("#define HAVE_SSE\n");
1518 if (features & HAVE_SSE2 ) printf("#define HAVE_SSE2\n");
1519 if (features & HAVE_SSE3 ) printf("#define HAVE_SSE3\n");
1520 if (features & HAVE_SSSE3) printf("#define HAVE_SSSE3\n");
1521 if (features & HAVE_SSE4_1) printf("#define HAVE_SSE4_1\n");
1522 if (features & HAVE_SSE4_2) printf("#define HAVE_SSE4_2\n");
1523 if (features & HAVE_SSE4A) printf("#define HAVE_SSE4A\n");
1524 if (features & HAVE_SSE5 ) printf("#define HAVE_SSSE5\n");
1525 if (features & HAVE_AVX ) printf("#define HAVE_AVX\n");
1526 if (features & HAVE_3DNOWEX) printf("#define HAVE_3DNOWEX\n");
1527 if (features & HAVE_3DNOW) printf("#define HAVE_3DNOW\n");
1528 if (features & HAVE_CFLUSH) printf("#define HAVE_CFLUSH\n");
1529 if (features & HAVE_HIT) printf("#define HAVE_HIT 1\n");
1530 if (features & HAVE_MISALIGNSSE) printf("#define HAVE_MISALIGNSSE\n");
1531 if (features & HAVE_128BITFPU) printf("#define HAVE_128BITFPU\n");
1532 if (features & HAVE_FASTMOVU) printf("#define HAVE_FASTMOVU\n");
1534 printf("#define NUM_SHAREDCACHE %d\n", get_cputype(GET_NUMSHARE) + 1);
1535 printf("#define NUM_CORES %d\n", get_cputype(GET_NUMCORES) + 1);
1537 features = get_coretype();
1538 if (features > 0) printf("#define CORE_%s\n", corename[features]);
1540 printf("#define DTB_DEFAULT_ENTRIES 16\n");
1541 printf("#define L1_CODE_SIZE 8192\n");
1542 printf("#define L1_DATA_SIZE 8192\n");
1543 printf("#define L2_SIZE 0\n");
1547 void get_architecture(void){
1555 void get_subarchitecture(void){
1556 printf("%s", get_cpunamechar());
1559 void get_subdirname(void){
1567 char *get_corename(void){
1568 return corename[get_coretype()];
1571 void get_libname(void){
1572 printf("%s", corename_lower[get_coretype()]);
1575 /* This if for Makefile */
1580 features = get_cputype(GET_FEATURE);
1582 if (features & HAVE_MMX ) printf("HAVE_MMX=1\n");
1583 if (features & HAVE_SSE ) printf("HAVE_SSE=1\n");
1584 if (features & HAVE_SSE2 ) printf("HAVE_SSE2=1\n");
1585 if (features & HAVE_SSE3 ) printf("HAVE_SSE3=1\n");
1586 if (features & HAVE_SSSE3) printf("HAVE_SSSE3=1\n");
1587 if (features & HAVE_SSE4_1) printf("HAVE_SSE4_1=1\n");
1588 if (features & HAVE_SSE4_2) printf("HAVE_SSE4_2=1\n");
1589 if (features & HAVE_SSE4A) printf("HAVE_SSE4A=1\n");
1590 if (features & HAVE_SSE5 ) printf("HAVE_SSSE5=1\n");
1591 if (features & HAVE_AVX ) printf("HAVE_AVX=1\n");
1592 if (features & HAVE_3DNOWEX) printf("HAVE_3DNOWEX=1\n");
1593 if (features & HAVE_3DNOW) printf("HAVE_3DNOW=1\n");