Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/i386/driver-i386.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | 58ad6c70ea60 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
44 char size[100], line[100], size2[100]; | 44 char size[100], line[100], size2[100]; |
45 | 45 |
46 /* At the moment, gcc does not use the information | 46 /* At the moment, gcc does not use the information |
47 about the associativity of the cache. */ | 47 about the associativity of the cache. */ |
48 | 48 |
49 sprintf (size, "--param l1-cache-size=%u", level1.sizekb); | 49 snprintf (size, sizeof (size), |
50 sprintf (line, "--param l1-cache-line-size=%u", level1.line); | 50 "--param l1-cache-size=%u ", level1.sizekb); |
51 | 51 snprintf (line, sizeof (line), |
52 sprintf (size2, "--param l2-cache-size=%u", level2.sizekb); | 52 "--param l1-cache-line-size=%u ", level1.line); |
53 | 53 |
54 return concat (size, " ", line, " ", size2, " ", NULL); | 54 snprintf (size2, sizeof (size2), |
55 "--param l2-cache-size=%u ", level2.sizekb); | |
56 | |
57 return concat (size, line, size2, NULL); | |
55 } | 58 } |
56 | 59 |
57 /* Detect L2 cache parameters using CPUID extended function 0x80000006. */ | 60 /* Detect L2 cache parameters using CPUID extended function 0x80000006. */ |
58 | 61 |
59 static void | 62 static void |
376 unsigned int has_cmpxchg8b, has_cmov, has_mmx, has_sse, has_sse2; | 379 unsigned int has_cmpxchg8b, has_cmov, has_mmx, has_sse, has_sse2; |
377 | 380 |
378 /* Extended features */ | 381 /* Extended features */ |
379 unsigned int has_lahf_lm = 0, has_sse4a = 0; | 382 unsigned int has_lahf_lm = 0, has_sse4a = 0; |
380 unsigned int has_longmode = 0, has_3dnowp = 0, has_3dnow = 0; | 383 unsigned int has_longmode = 0, has_3dnowp = 0, has_3dnow = 0; |
381 unsigned int has_sse4_1 = 0, has_sse4_2 = 0; | 384 unsigned int has_movbe = 0, has_sse4_1 = 0, has_sse4_2 = 0; |
382 unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0; | 385 unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0; |
383 unsigned int has_pclmul = 0; | 386 unsigned int has_pclmul = 0, has_abm = 0, has_lwp = 0; |
384 | 387 |
385 bool arch; | 388 bool arch; |
386 | 389 |
387 if (argc < 1) | 390 if (argc < 1) |
388 return NULL; | 391 return NULL; |
396 if (max_level < 1) | 399 if (max_level < 1) |
397 goto done; | 400 goto done; |
398 | 401 |
399 __cpuid (1, eax, ebx, ecx, edx); | 402 __cpuid (1, eax, ebx, ecx, edx); |
400 | 403 |
401 /* We don't care for extended family. */ | |
402 model = (eax >> 4) & 0x0f; | 404 model = (eax >> 4) & 0x0f; |
403 family = (eax >> 8) & 0x0f; | 405 family = (eax >> 8) & 0x0f; |
406 if (vendor == SIG_INTEL) | |
407 { | |
408 unsigned int extended_model, extended_family; | |
409 | |
410 extended_model = (eax >> 12) & 0xf0; | |
411 extended_family = (eax >> 20) & 0xff; | |
412 if (family == 0x0f) | |
413 { | |
414 family += extended_family; | |
415 model += extended_model; | |
416 } | |
417 else if (family == 0x06) | |
418 model += extended_model; | |
419 } | |
404 | 420 |
405 has_sse3 = ecx & bit_SSE3; | 421 has_sse3 = ecx & bit_SSE3; |
406 has_ssse3 = ecx & bit_SSSE3; | 422 has_ssse3 = ecx & bit_SSSE3; |
407 has_sse4_1 = ecx & bit_SSE4_1; | 423 has_sse4_1 = ecx & bit_SSE4_1; |
408 has_sse4_2 = ecx & bit_SSE4_2; | 424 has_sse4_2 = ecx & bit_SSE4_2; |
409 has_avx = ecx & bit_AVX; | 425 has_avx = ecx & bit_AVX; |
410 has_cmpxchg16b = ecx & bit_CMPXCHG16B; | 426 has_cmpxchg16b = ecx & bit_CMPXCHG16B; |
427 has_movbe = ecx & bit_MOVBE; | |
411 has_popcnt = ecx & bit_POPCNT; | 428 has_popcnt = ecx & bit_POPCNT; |
412 has_aes = ecx & bit_AES; | 429 has_aes = ecx & bit_AES; |
413 has_pclmul = ecx & bit_PCLMUL; | 430 has_pclmul = ecx & bit_PCLMUL; |
414 | 431 |
415 has_cmpxchg8b = edx & bit_CMPXCHG8B; | 432 has_cmpxchg8b = edx & bit_CMPXCHG8B; |
425 { | 442 { |
426 __cpuid (0x80000001, eax, ebx, ecx, edx); | 443 __cpuid (0x80000001, eax, ebx, ecx, edx); |
427 | 444 |
428 has_lahf_lm = ecx & bit_LAHF_LM; | 445 has_lahf_lm = ecx & bit_LAHF_LM; |
429 has_sse4a = ecx & bit_SSE4a; | 446 has_sse4a = ecx & bit_SSE4a; |
447 has_abm = ecx & bit_ABM; | |
448 has_lwp = ecx & bit_LWP; | |
430 | 449 |
431 has_longmode = edx & bit_LM; | 450 has_longmode = edx & bit_LM; |
432 has_3dnowp = edx & bit_3DNOWP; | 451 has_3dnowp = edx & bit_3DNOWP; |
433 has_3dnow = edx & bit_3DNOW; | 452 has_3dnow = edx & bit_3DNOW; |
434 } | 453 } |
503 else | 522 else |
504 cpu = "pentium"; | 523 cpu = "pentium"; |
505 break; | 524 break; |
506 case PROCESSOR_PENTIUMPRO: | 525 case PROCESSOR_PENTIUMPRO: |
507 if (has_longmode) | 526 if (has_longmode) |
508 /* It is Core 2 Duo. */ | 527 /* It is Core 2 or Atom. */ |
509 cpu = "core2"; | 528 cpu = (model == 28) ? "atom" : "core2"; |
510 else if (arch) | 529 else if (arch) |
511 { | 530 { |
512 if (has_sse3) | 531 if (has_sse3) |
513 /* It is Core Duo. */ | 532 /* It is Core Duo. */ |
514 cpu = "prescott"; | 533 cpu = "prescott"; |
592 } | 611 } |
593 | 612 |
594 if (arch) | 613 if (arch) |
595 { | 614 { |
596 if (has_cmpxchg16b) | 615 if (has_cmpxchg16b) |
597 options = concat (options, "-mcx16 ", NULL); | 616 options = concat (options, " -mcx16", NULL); |
598 if (has_lahf_lm) | 617 if (has_lahf_lm) |
599 options = concat (options, "-msahf ", NULL); | 618 options = concat (options, " -msahf", NULL); |
619 if (has_movbe) | |
620 options = concat (options, " -mmovbe", NULL); | |
600 if (has_aes) | 621 if (has_aes) |
601 options = concat (options, "-maes ", NULL); | 622 options = concat (options, " -maes", NULL); |
602 if (has_pclmul) | 623 if (has_pclmul) |
603 options = concat (options, "-mpclmul ", NULL); | 624 options = concat (options, " -mpclmul", NULL); |
604 if (has_popcnt) | 625 if (has_popcnt) |
605 options = concat (options, "-mpopcnt ", NULL); | 626 options = concat (options, " -mpopcnt", NULL); |
627 if (has_abm) | |
628 options = concat (options, " -mabm", NULL); | |
629 if (has_lwp) | |
630 options = concat (options, " -mlwp", NULL); | |
631 | |
606 if (has_avx) | 632 if (has_avx) |
607 options = concat (options, "-mavx ", NULL); | 633 options = concat (options, " -mavx", NULL); |
608 else if (has_sse4_2) | 634 else if (has_sse4_2) |
609 options = concat (options, "-msse4.2 ", NULL); | 635 options = concat (options, " -msse4.2", NULL); |
610 else if (has_sse4_1) | 636 else if (has_sse4_1) |
611 options = concat (options, "-msse4.1 ", NULL); | 637 options = concat (options, " -msse4.1", NULL); |
612 } | 638 } |
613 | 639 |
614 done: | 640 done: |
615 return concat (cache, "-m", argv[0], "=", cpu, " ", options, NULL); | 641 return concat (cache, "-m", argv[0], "=", cpu, options, NULL); |
616 } | 642 } |
617 #else | 643 #else |
618 | 644 |
619 /* If we aren't compiling with GCC we just provide a minimal | 645 /* If we aren't compiling with GCC then the driver will just ignore |
620 default value. */ | 646 -march and -mtune "native" target and will leave to the newly |
621 | 647 built compiler to generate code for its default target. */ |
622 const char *host_detect_local_cpu (int argc, const char **argv) | 648 |
623 { | 649 const char *host_detect_local_cpu (int argc ATTRIBUTE_UNUSED, |
624 const char *cpu; | 650 const char **argv ATTRIBUTE_UNUSED) |
625 bool arch; | 651 { |
626 | 652 return NULL; |
627 if (argc < 1) | |
628 return NULL; | |
629 | |
630 arch = !strcmp (argv[0], "arch"); | |
631 | |
632 if (!arch && strcmp (argv[0], "tune")) | |
633 return NULL; | |
634 | |
635 if (arch) | |
636 { | |
637 /* FIXME: i386 is wrong for 64bit compiler. How can we tell if | |
638 we are generating 64bit or 32bit code? */ | |
639 cpu = "i386"; | |
640 } | |
641 else | |
642 cpu = "generic"; | |
643 | |
644 return concat ("-m", argv[0], "=", cpu, NULL); | |
645 } | 653 } |
646 #endif /* __GNUC__ */ | 654 #endif /* __GNUC__ */ |