comparison gcc/config/i386/driver-i386.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Subroutines for the gcc driver. 1 /* Subroutines for the gcc driver.
2 Copyright (C) 2006-2017 Free Software Foundation, Inc. 2 Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify 6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see 17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
19
20 #define IN_TARGET_CODE 1
19 21
20 #include "config.h" 22 #include "config.h"
21 #include "system.h" 23 #include "system.h"
22 #include "coretypes.h" 24 #include "coretypes.h"
23 #include "tm.h" 25 #include "tm.h"
403 unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0, has_avx2 = 0; 405 unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0, has_avx2 = 0;
404 unsigned int has_pclmul = 0, has_abm = 0, has_lwp = 0; 406 unsigned int has_pclmul = 0, has_abm = 0, has_lwp = 0;
405 unsigned int has_fma = 0, has_fma4 = 0, has_xop = 0; 407 unsigned int has_fma = 0, has_fma4 = 0, has_xop = 0;
406 unsigned int has_bmi = 0, has_bmi2 = 0, has_tbm = 0, has_lzcnt = 0; 408 unsigned int has_bmi = 0, has_bmi2 = 0, has_tbm = 0, has_lzcnt = 0;
407 unsigned int has_hle = 0, has_rtm = 0, has_sgx = 0; 409 unsigned int has_hle = 0, has_rtm = 0, has_sgx = 0;
410 unsigned int has_pconfig = 0, has_wbnoinvd = 0;
408 unsigned int has_rdrnd = 0, has_f16c = 0, has_fsgsbase = 0; 411 unsigned int has_rdrnd = 0, has_f16c = 0, has_fsgsbase = 0;
409 unsigned int has_rdseed = 0, has_prfchw = 0, has_adx = 0; 412 unsigned int has_rdseed = 0, has_prfchw = 0, has_adx = 0;
410 unsigned int has_osxsave = 0, has_fxsr = 0, has_xsave = 0, has_xsaveopt = 0; 413 unsigned int has_osxsave = 0, has_fxsr = 0, has_xsave = 0, has_xsaveopt = 0;
411 unsigned int has_avx512er = 0, has_avx512pf = 0, has_avx512cd = 0; 414 unsigned int has_avx512er = 0, has_avx512pf = 0, has_avx512cd = 0;
412 unsigned int has_avx512f = 0, has_sha = 0, has_prefetchwt1 = 0; 415 unsigned int has_avx512f = 0, has_sha = 0, has_prefetchwt1 = 0;
413 unsigned int has_clflushopt = 0, has_xsavec = 0, has_xsaves = 0; 416 unsigned int has_clflushopt = 0, has_xsavec = 0, has_xsaves = 0;
414 unsigned int has_avx512dq = 0, has_avx512bw = 0, has_avx512vl = 0; 417 unsigned int has_avx512dq = 0, has_avx512bw = 0, has_avx512vl = 0;
415 unsigned int has_avx512vbmi = 0, has_avx512ifma = 0, has_clwb = 0; 418 unsigned int has_avx512vbmi = 0, has_avx512ifma = 0, has_clwb = 0;
416 unsigned int has_mwaitx = 0, has_clzero = 0, has_pku = 0, has_rdpid = 0; 419 unsigned int has_mwaitx = 0, has_clzero = 0, has_pku = 0, has_rdpid = 0;
417 unsigned int has_avx5124fmaps = 0, has_avx5124vnniw = 0; 420 unsigned int has_avx5124fmaps = 0, has_avx5124vnniw = 0;
418 unsigned int has_gfni = 0; 421 unsigned int has_gfni = 0, has_avx512vbmi2 = 0;
419 unsigned int has_ibt = 0, has_shstk = 0; 422 unsigned int has_avx512bitalg = 0;
423 unsigned int has_shstk = 0;
424 unsigned int has_avx512vnni = 0, has_vaes = 0;
425 unsigned int has_vpclmulqdq = 0;
426 unsigned int has_movdiri = 0, has_movdir64b = 0;
427 unsigned int has_waitpkg = 0;
428 unsigned int has_cldemote = 0;
420 429
421 bool arch; 430 bool arch;
422 431
423 unsigned int l2sizekb = 0; 432 unsigned int l2sizekb = 0;
424 433
503 has_avx512ifma = ebx & bit_AVX512IFMA; 512 has_avx512ifma = ebx & bit_AVX512IFMA;
504 513
505 has_prefetchwt1 = ecx & bit_PREFETCHWT1; 514 has_prefetchwt1 = ecx & bit_PREFETCHWT1;
506 has_avx512vbmi = ecx & bit_AVX512VBMI; 515 has_avx512vbmi = ecx & bit_AVX512VBMI;
507 has_pku = ecx & bit_OSPKE; 516 has_pku = ecx & bit_OSPKE;
517 has_avx512vbmi2 = ecx & bit_AVX512VBMI2;
518 has_avx512vnni = ecx & bit_AVX512VNNI;
508 has_rdpid = ecx & bit_RDPID; 519 has_rdpid = ecx & bit_RDPID;
509 has_gfni = ecx & bit_GFNI; 520 has_gfni = ecx & bit_GFNI;
521 has_vaes = ecx & bit_VAES;
522 has_vpclmulqdq = ecx & bit_VPCLMULQDQ;
523 has_avx512bitalg = ecx & bit_AVX512BITALG;
524 has_movdiri = ecx & bit_MOVDIRI;
525 has_movdir64b = ecx & bit_MOVDIR64B;
526 has_cldemote = ecx & bit_CLDEMOTE;
510 527
511 has_avx5124vnniw = edx & bit_AVX5124VNNIW; 528 has_avx5124vnniw = edx & bit_AVX5124VNNIW;
512 has_avx5124fmaps = edx & bit_AVX5124FMAPS; 529 has_avx5124fmaps = edx & bit_AVX5124FMAPS;
513 530
514 has_shstk = ecx & bit_SHSTK; 531 has_shstk = ecx & bit_SHSTK;
515 has_ibt = edx & bit_IBT; 532 has_pconfig = edx & bit_PCONFIG;
533 has_waitpkg = ecx & bit_WAITPKG;
516 } 534 }
517 535
518 if (max_level >= 13) 536 if (max_level >= 13)
519 { 537 {
520 __cpuid_count (13, 1, eax, ebx, ecx, edx); 538 __cpuid_count (13, 1, eax, ebx, ecx, edx);
549 567
550 if (ext_level >= 0x80000008) 568 if (ext_level >= 0x80000008)
551 { 569 {
552 __cpuid (0x80000008, eax, ebx, ecx, edx); 570 __cpuid (0x80000008, eax, ebx, ecx, edx);
553 has_clzero = ebx & bit_CLZERO; 571 has_clzero = ebx & bit_CLZERO;
572 has_wbnoinvd = ebx & bit_WBNOINVD;
554 } 573 }
555 574
556 /* Get XCR_XFEATURE_ENABLED_MASK register with xgetbv. */ 575 /* Get XCR_XFEATURE_ENABLED_MASK register with xgetbv. */
557 #define XCR_XFEATURE_ENABLED_MASK 0x0 576 #define XCR_XFEATURE_ENABLED_MASK 0x0
558 #define XSTATE_FP 0x1 577 #define XSTATE_FP 0x1
738 case 0x5a: 757 case 0x5a:
739 case 0x5d: 758 case 0x5d:
740 /* Silvermont. */ 759 /* Silvermont. */
741 cpu = "silvermont"; 760 cpu = "silvermont";
742 break; 761 break;
762 case 0x5c:
763 case 0x5f:
764 /* Goldmont. */
765 cpu = "goldmont";
766 break;
767 case 0x7a:
768 /* Goldmont Plus. */
769 cpu = "goldmont-plus";
770 break;
743 case 0x0f: 771 case 0x0f:
744 /* Merom. */ 772 /* Merom. */
745 case 0x17: 773 case 0x17:
746 case 0x1d: 774 case 0x1d:
747 /* Penryn. */ 775 /* Penryn. */
790 case 0x8e: 818 case 0x8e:
791 case 0x9e: 819 case 0x9e:
792 /* Kaby Lake. */ 820 /* Kaby Lake. */
793 cpu = "skylake"; 821 cpu = "skylake";
794 break; 822 break;
823 case 0x55:
824 /* Skylake with AVX-512. */
825 cpu = "skylake-avx512";
826 break;
795 case 0x57: 827 case 0x57:
796 /* Knights Landing. */ 828 /* Knights Landing. */
797 cpu = "knl"; 829 cpu = "knl";
798 break; 830 break;
831 case 0x66:
832 /* Cannon Lake. */
833 cpu = "cannonlake";
834 break;
799 case 0x85: 835 case 0x85:
800 /* Knights Mill. */ 836 /* Knights Mill. */
801 cpu = "knm"; 837 cpu = "knm";
802 break; 838 break;
803 default: 839 default:
804 if (arch) 840 if (arch)
805 { 841 {
806 /* This is unknown family 0x6 CPU. */ 842 /* This is unknown family 0x6 CPU. */
807 /* Assume Knights Landing. */ 843 /* Assume Ice Lake Server. */
808 if (has_avx512f) 844 if (has_wbnoinvd)
809 cpu = "knl"; 845 cpu = "icelake-server";
810 /* Assume Knights Mill */ 846 /* Assume Ice Lake. */
847 else if (has_gfni)
848 cpu = "icelake-client";
849 /* Assume Cannon Lake. */
850 else if (has_avx512vbmi)
851 cpu = "cannonlake";
852 /* Assume Knights Mill. */
811 else if (has_avx5124vnniw) 853 else if (has_avx5124vnniw)
812 cpu = "knm"; 854 cpu = "knm";
855 /* Assume Knights Landing. */
856 else if (has_avx512er)
857 cpu = "knl";
858 /* Assume Skylake with AVX-512. */
859 else if (has_avx512f)
860 cpu = "skylake-avx512";
813 /* Assume Skylake. */ 861 /* Assume Skylake. */
814 else if (has_clflushopt) 862 else if (has_clflushopt)
815 cpu = "skylake"; 863 cpu = "skylake";
816 /* Assume Broadwell. */ 864 /* Assume Broadwell. */
817 else if (has_adx) 865 else if (has_adx)
822 else if (has_avx) 870 else if (has_avx)
823 /* Assume Sandy Bridge. */ 871 /* Assume Sandy Bridge. */
824 cpu = "sandybridge"; 872 cpu = "sandybridge";
825 else if (has_sse4_2) 873 else if (has_sse4_2)
826 { 874 {
827 if (has_movbe) 875 if (has_gfni)
876 /* Assume Tremont. */
877 cpu = "tremont";
878 else if (has_sgx)
879 /* Assume Goldmont Plus. */
880 cpu = "goldmont-plus";
881 else if (has_xsave)
882 /* Assume Goldmont. */
883 cpu = "goldmont";
884 else if (has_movbe)
828 /* Assume Silvermont. */ 885 /* Assume Silvermont. */
829 cpu = "silvermont"; 886 cpu = "silvermont";
830 else 887 else
831 /* Assume Nehalem. */ 888 /* Assume Nehalem. */
832 cpu = "nehalem"; 889 cpu = "nehalem";
1013 const char *lwp = has_lwp ? " -mlwp" : " -mno-lwp"; 1070 const char *lwp = has_lwp ? " -mlwp" : " -mno-lwp";
1014 const char *fma = has_fma ? " -mfma" : " -mno-fma"; 1071 const char *fma = has_fma ? " -mfma" : " -mno-fma";
1015 const char *fma4 = has_fma4 ? " -mfma4" : " -mno-fma4"; 1072 const char *fma4 = has_fma4 ? " -mfma4" : " -mno-fma4";
1016 const char *xop = has_xop ? " -mxop" : " -mno-xop"; 1073 const char *xop = has_xop ? " -mxop" : " -mno-xop";
1017 const char *bmi = has_bmi ? " -mbmi" : " -mno-bmi"; 1074 const char *bmi = has_bmi ? " -mbmi" : " -mno-bmi";
1075 const char *pconfig = has_pconfig ? " -mpconfig" : " -mno-pconfig";
1076 const char *wbnoinvd = has_wbnoinvd ? " -mwbnoinvd" : " -mno-wbnoinvd";
1018 const char *sgx = has_sgx ? " -msgx" : " -mno-sgx"; 1077 const char *sgx = has_sgx ? " -msgx" : " -mno-sgx";
1019 const char *bmi2 = has_bmi2 ? " -mbmi2" : " -mno-bmi2"; 1078 const char *bmi2 = has_bmi2 ? " -mbmi2" : " -mno-bmi2";
1020 const char *tbm = has_tbm ? " -mtbm" : " -mno-tbm"; 1079 const char *tbm = has_tbm ? " -mtbm" : " -mno-tbm";
1021 const char *avx = has_avx ? " -mavx" : " -mno-avx"; 1080 const char *avx = has_avx ? " -mavx" : " -mno-avx";
1022 const char *avx2 = has_avx2 ? " -mavx2" : " -mno-avx2"; 1081 const char *avx2 = has_avx2 ? " -mavx2" : " -mno-avx2";
1046 const char *avx512bw = has_avx512bw ? " -mavx512bw" : " -mno-avx512bw"; 1105 const char *avx512bw = has_avx512bw ? " -mavx512bw" : " -mno-avx512bw";
1047 const char *avx512vl = has_avx512vl ? " -mavx512vl" : " -mno-avx512vl"; 1106 const char *avx512vl = has_avx512vl ? " -mavx512vl" : " -mno-avx512vl";
1048 const char *avx512ifma = has_avx512ifma ? " -mavx512ifma" : " -mno-avx512ifma"; 1107 const char *avx512ifma = has_avx512ifma ? " -mavx512ifma" : " -mno-avx512ifma";
1049 const char *avx512vbmi = has_avx512vbmi ? " -mavx512vbmi" : " -mno-avx512vbmi"; 1108 const char *avx512vbmi = has_avx512vbmi ? " -mavx512vbmi" : " -mno-avx512vbmi";
1050 const char *avx5124vnniw = has_avx5124vnniw ? " -mavx5124vnniw" : " -mno-avx5124vnniw"; 1109 const char *avx5124vnniw = has_avx5124vnniw ? " -mavx5124vnniw" : " -mno-avx5124vnniw";
1110 const char *avx512vbmi2 = has_avx512vbmi2 ? " -mavx512vbmi2" : " -mno-avx512vbmi2";
1111 const char *avx512vnni = has_avx512vnni ? " -mavx512vnni" : " -mno-avx512vnni";
1051 const char *avx5124fmaps = has_avx5124fmaps ? " -mavx5124fmaps" : " -mno-avx5124fmaps"; 1112 const char *avx5124fmaps = has_avx5124fmaps ? " -mavx5124fmaps" : " -mno-avx5124fmaps";
1052 const char *clwb = has_clwb ? " -mclwb" : " -mno-clwb"; 1113 const char *clwb = has_clwb ? " -mclwb" : " -mno-clwb";
1053 const char *mwaitx = has_mwaitx ? " -mmwaitx" : " -mno-mwaitx"; 1114 const char *mwaitx = has_mwaitx ? " -mmwaitx" : " -mno-mwaitx";
1054 const char *clzero = has_clzero ? " -mclzero" : " -mno-clzero"; 1115 const char *clzero = has_clzero ? " -mclzero" : " -mno-clzero";
1055 const char *pku = has_pku ? " -mpku" : " -mno-pku"; 1116 const char *pku = has_pku ? " -mpku" : " -mno-pku";
1056 const char *rdpid = has_rdpid ? " -mrdpid" : " -mno-rdpid"; 1117 const char *rdpid = has_rdpid ? " -mrdpid" : " -mno-rdpid";
1057 const char *gfni = has_gfni ? " -mgfni" : " -mno-gfni"; 1118 const char *gfni = has_gfni ? " -mgfni" : " -mno-gfni";
1058 const char *ibt = has_ibt ? " -mibt" : " -mno-ibt";
1059 const char *shstk = has_shstk ? " -mshstk" : " -mno-shstk"; 1119 const char *shstk = has_shstk ? " -mshstk" : " -mno-shstk";
1120 const char *vaes = has_vaes ? " -mvaes" : " -mno-vaes";
1121 const char *vpclmulqdq = has_vpclmulqdq ? " -mvpclmulqdq" : " -mno-vpclmulqdq";
1122 const char *avx512bitalg = has_avx512bitalg ? " -mavx512bitalg" : " -mno-avx512bitalg";
1123 const char *movdiri = has_movdiri ? " -mmovdiri" : " -mno-movdiri";
1124 const char *movdir64b = has_movdir64b ? " -mmovdir64b" : " -mno-movdir64b";
1125 const char *waitpkg = has_waitpkg ? " -mwaitpkg" : " -mno-waitpkg";
1126 const char *cldemote = has_cldemote ? " -mcldemote" : " -mno-cldemote";
1060 options = concat (options, mmx, mmx3dnow, sse, sse2, sse3, ssse3, 1127 options = concat (options, mmx, mmx3dnow, sse, sse2, sse3, ssse3,
1061 sse4a, cx16, sahf, movbe, aes, sha, pclmul, 1128 sse4a, cx16, sahf, movbe, aes, sha, pclmul,
1062 popcnt, abm, lwp, fma, fma4, xop, bmi, sgx, bmi2, 1129 popcnt, abm, lwp, fma, fma4, xop, bmi, sgx, bmi2,
1130 pconfig, wbnoinvd,
1063 tbm, avx, avx2, sse4_2, sse4_1, lzcnt, rtm, 1131 tbm, avx, avx2, sse4_2, sse4_1, lzcnt, rtm,
1064 hle, rdrnd, f16c, fsgsbase, rdseed, prfchw, adx, 1132 hle, rdrnd, f16c, fsgsbase, rdseed, prfchw, adx,
1065 fxsr, xsave, xsaveopt, avx512f, avx512er, 1133 fxsr, xsave, xsaveopt, avx512f, avx512er,
1066 avx512cd, avx512pf, prefetchwt1, clflushopt, 1134 avx512cd, avx512pf, prefetchwt1, clflushopt,
1067 xsavec, xsaves, avx512dq, avx512bw, avx512vl, 1135 xsavec, xsaves, avx512dq, avx512bw, avx512vl,
1068 avx512ifma, avx512vbmi, avx5124fmaps, avx5124vnniw, 1136 avx512ifma, avx512vbmi, avx5124fmaps, avx5124vnniw,
1069 clwb, mwaitx, clzero, pku, rdpid, gfni, ibt, shstk, NULL); 1137 clwb, mwaitx, clzero, pku, rdpid, gfni, shstk,
1138 avx512vbmi2, avx512vnni, vaes, vpclmulqdq,
1139 avx512bitalg, movdiri, movdir64b, waitpkg, cldemote,
1140 NULL);
1070 } 1141 }
1071 1142
1072 done: 1143 done:
1073 return concat (cache, "-m", argv[0], "=", cpu, options, NULL); 1144 return concat (cache, "-m", argv[0], "=", cpu, options, NULL);
1074 } 1145 }