LCOV - code coverage report
Current view: top level - gcc/config/i386 - i386-options.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 79.3 % 1638 1299
Test Date: 2026-12-05 16:10:02 Functions: 90.0 % 40 36
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Copyright (C) 1988-2026 Free Software Foundation, Inc.
       2              : 
       3              : This file is part of GCC.
       4              : 
       5              : GCC is free software; you can redistribute it and/or modify
       6              : it under the terms of the GNU General Public License as published by
       7              : the Free Software Foundation; either version 3, or (at your option)
       8              : any later version.
       9              : 
      10              : GCC is distributed in the hope that it will be useful,
      11              : but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13              : GNU General Public License for more details.
      14              : 
      15              : You should have received a copy of the GNU General Public License
      16              : along with GCC; see the file COPYING3.  If not see
      17              : <http://www.gnu.org/licenses/>.  */
      18              : 
      19              : #define IN_TARGET_CODE 1
      20              : 
      21              : #include "config.h"
      22              : #include "system.h"
      23              : #include "coretypes.h"
      24              : #include "backend.h"
      25              : #include "rtl.h"
      26              : #include "tree.h"
      27              : #include "memmodel.h"
      28              : #include "gimple.h"
      29              : #include "cfghooks.h"
      30              : #include "cfgloop.h"
      31              : #include "df.h"
      32              : #include "tm_p.h"
      33              : #include "stringpool.h"
      34              : #include "expmed.h"
      35              : #include "optabs.h"
      36              : #include "regs.h"
      37              : #include "emit-rtl.h"
      38              : #include "recog.h"
      39              : #include "cgraph.h"
      40              : #include "diagnostic.h"
      41              : #include "cfgbuild.h"
      42              : #include "alias.h"
      43              : #include "fold-const.h"
      44              : #include "attribs.h"
      45              : #include "calls.h"
      46              : #include "stor-layout.h"
      47              : #include "varasm.h"
      48              : #include "output.h"
      49              : #include "insn-attr.h"
      50              : #include "flags.h"
      51              : #include "except.h"
      52              : #include "explow.h"
      53              : #include "expr.h"
      54              : #include "cfgrtl.h"
      55              : #include "common/common-target.h"
      56              : #include "langhooks.h"
      57              : #include "reload.h"
      58              : #include "gimplify.h"
      59              : #include "dwarf2.h"
      60              : #include "tm-constrs.h"
      61              : #include "cselib.h"
      62              : #include "sched-int.h"
      63              : #include "opts.h"
      64              : #include "tree-pass.h"
      65              : #include "context.h"
      66              : #include "pass_manager.h"
      67              : #include "target-globals.h"
      68              : #include "gimple-iterator.h"
      69              : #include "shrink-wrap.h"
      70              : #include "builtins.h"
      71              : #include "rtl-iter.h"
      72              : #include "tree-iterator.h"
      73              : #include "dbgcnt.h"
      74              : #include "case-cfn-macros.h"
      75              : #include "dojump.h"
      76              : #include "fold-const-call.h"
      77              : #include "tree-vrp.h"
      78              : #include "tree-ssanames.h"
      79              : #include "selftest.h"
      80              : #include "selftest-rtl.h"
      81              : #include "print-rtl.h"
      82              : #include "intl.h"
      83              : #include "ifcvt.h"
      84              : #include "symbol-summary.h"
      85              : #include "sreal.h"
      86              : #include "ipa-cp.h"
      87              : #include "ipa-prop.h"
      88              : #include "ipa-fnsummary.h"
      89              : #include "wide-int-bitmask.h"
      90              : #include "tree-vector-builder.h"
      91              : #include "debug.h"
      92              : #include "dwarf2out.h"
      93              : #include "i386-options.h"
      94              : 
      95              : #include "x86-tune-costs.h"
      96              : 
      97              : #ifndef SUBTARGET32_DEFAULT_CPU
      98              : #define SUBTARGET32_DEFAULT_CPU "i386"
      99              : #endif
     100              : 
     101              : /* Processor feature/optimization bitmasks.  */
     102              : #define m_NONE HOST_WIDE_INT_0U
     103              : #define m_ALL (~HOST_WIDE_INT_0U)
     104              : #define m_386 (HOST_WIDE_INT_1U<<PROCESSOR_I386)
     105              : #define m_486 (HOST_WIDE_INT_1U<<PROCESSOR_I486)
     106              : #define m_PENT (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM)
     107              : #define m_LAKEMONT (HOST_WIDE_INT_1U<<PROCESSOR_LAKEMONT)
     108              : #define m_PPRO (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUMPRO)
     109              : #define m_PENT4 (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM4)
     110              : #define m_NOCONA (HOST_WIDE_INT_1U<<PROCESSOR_NOCONA)
     111              : #define m_P4_NOCONA (m_PENT4 | m_NOCONA)
     112              : #define m_CORE2 (HOST_WIDE_INT_1U<<PROCESSOR_CORE2)
     113              : #define m_NEHALEM (HOST_WIDE_INT_1U<<PROCESSOR_NEHALEM)
     114              : #define m_SANDYBRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_SANDYBRIDGE)
     115              : #define m_HASWELL (HOST_WIDE_INT_1U<<PROCESSOR_HASWELL)
     116              : #define m_BONNELL (HOST_WIDE_INT_1U<<PROCESSOR_BONNELL)
     117              : #define m_SILVERMONT (HOST_WIDE_INT_1U<<PROCESSOR_SILVERMONT)
     118              : #define m_SKYLAKE (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE)
     119              : #define m_SKYLAKE_AVX512 (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE_AVX512)
     120              : #define m_CANNONLAKE (HOST_WIDE_INT_1U<<PROCESSOR_CANNONLAKE)
     121              : #define m_ICELAKE_CLIENT (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_CLIENT)
     122              : #define m_ICELAKE_SERVER (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_SERVER)
     123              : #define m_CASCADELAKE (HOST_WIDE_INT_1U<<PROCESSOR_CASCADELAKE)
     124              : #define m_TIGERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_TIGERLAKE)
     125              : #define m_COOPERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_COOPERLAKE)
     126              : #define m_SAPPHIRERAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_SAPPHIRERAPIDS)
     127              : #define m_ALDERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ALDERLAKE)
     128              : #define m_ROCKETLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ROCKETLAKE)
     129              : #define m_GRANITERAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_GRANITERAPIDS)
     130              : #define m_GRANITERAPIDS_D (HOST_WIDE_INT_1U<<PROCESSOR_GRANITERAPIDS_D)
     131              : #define m_ARROWLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ARROWLAKE)
     132              : #define m_ARROWLAKE_S (HOST_WIDE_INT_1U<<PROCESSOR_ARROWLAKE_S)
     133              : #define m_PANTHERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_PANTHERLAKE)
     134              : #define m_DIAMONDRAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_DIAMONDRAPIDS)
     135              : #define m_NOVALAKE (HOST_WIDE_INT_1U<<PROCESSOR_NOVALAKE)
     136              : #define m_CORE_AVX512 (m_SKYLAKE_AVX512 | m_CANNONLAKE \
     137              :                        | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
     138              :                        | m_TIGERLAKE | m_COOPERLAKE | m_SAPPHIRERAPIDS \
     139              :                        | m_ROCKETLAKE | m_GRANITERAPIDS | m_GRANITERAPIDS_D \
     140              :                        | m_DIAMONDRAPIDS)
     141              : #define m_CORE_AVX2 (m_HASWELL | m_SKYLAKE | m_CORE_AVX512)
     142              : #define m_CORE_ALL (m_CORE2 | m_NEHALEM  | m_SANDYBRIDGE | m_CORE_AVX2)
     143              : #define m_CORE_HYBRID (m_ALDERLAKE | m_ARROWLAKE | m_ARROWLAKE_S \
     144              :                        | m_PANTHERLAKE | m_NOVALAKE)
     145              : #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
     146              : #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
     147              : #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
     148              : #define m_SIERRAFOREST (HOST_WIDE_INT_1U<<PROCESSOR_SIERRAFOREST)
     149              : #define m_GRANDRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_GRANDRIDGE)
     150              : #define m_CLEARWATERFOREST (HOST_WIDE_INT_1U<<PROCESSOR_CLEARWATERFOREST)
     151              : #define m_CORE_ATOM (m_SIERRAFOREST | m_GRANDRIDGE | m_CLEARWATERFOREST)
     152              : #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
     153              : /* Gather Data Sampling / CVE-2022-40982 / INTEL-SA-00828.
     154              :    Software mitigation.  */
     155              : #define m_GDS (m_SKYLAKE | m_SKYLAKE_AVX512 | m_CANNONLAKE \
     156              :                | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
     157              :                | m_TIGERLAKE | m_COOPERLAKE | m_ROCKETLAKE)
     158              : 
     159              : #define m_LUJIAZUI (HOST_WIDE_INT_1U<<PROCESSOR_LUJIAZUI)
     160              : #define m_YONGFENG (HOST_WIDE_INT_1U<<PROCESSOR_YONGFENG)
     161              : #define m_SHIJIDADAO (HOST_WIDE_INT_1U<<PROCESSOR_SHIJIDADAO)
     162              : #define m_ZHAOXIN  (m_LUJIAZUI | m_YONGFENG | m_SHIJIDADAO)
     163              : 
     164              : #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
     165              : #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
     166              : #define m_K6_GEODE (m_K6 | m_GEODE)
     167              : #define m_K8 (HOST_WIDE_INT_1U<<PROCESSOR_K8)
     168              : #define m_ATHLON (HOST_WIDE_INT_1U<<PROCESSOR_ATHLON)
     169              : #define m_ATHLON_K8 (m_K8 | m_ATHLON)
     170              : #define m_AMDFAM10 (HOST_WIDE_INT_1U<<PROCESSOR_AMDFAM10)
     171              : #define m_BDVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER1)
     172              : #define m_BDVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER2)
     173              : #define m_BDVER3 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER3)
     174              : #define m_BDVER4 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER4)
     175              : #define m_ZNVER1 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER1)
     176              : #define m_ZNVER2 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER2)
     177              : #define m_ZNVER3 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER3)
     178              : #define m_ZNVER4 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER4)
     179              : #define m_ZNVER5 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER5)
     180              : #define m_ZNVER6 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER6)
     181              : #define m_BTVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER1)
     182              : #define m_BTVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER2)
     183              : #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4)
     184              : #define m_BTVER (m_BTVER1 | m_BTVER2)
     185              : #define m_ZNVER (m_ZNVER1 | m_ZNVER2 | m_ZNVER3 | m_ZNVER4 | m_ZNVER5 | m_ZNVER6)
     186              : #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \
     187              :                         | m_ZNVER)
     188              : #define m_C86_4G_M4 (HOST_WIDE_INT_1U<<PROCESSOR_C86_4G_M4)
     189              : #define m_C86_4G_M6 (HOST_WIDE_INT_1U<<PROCESSOR_C86_4G_M6)
     190              : #define m_C86_4G_M7 (HOST_WIDE_INT_1U<<PROCESSOR_C86_4G_M7)
     191              : #define m_C86_4G_M8 (HOST_WIDE_INT_1U<<PROCESSOR_C86_4G_M8)
     192              : #define m_C86_4G (m_C86_4G_M4 | m_C86_4G_M6 | m_C86_4G_M7 \
     193              :                   | m_C86_4G_M8)
     194              : 
     195              : #define m_GENERIC (HOST_WIDE_INT_1U<<PROCESSOR_GENERIC)
     196              : 
     197              : const char* ix86_tune_feature_names[X86_TUNE_LAST] = {
     198              : #undef DEF_TUNE
     199              : #define DEF_TUNE(tune, name, selector) name,
     200              : #include "x86-tune.def"
     201              : #undef DEF_TUNE
     202              : };
     203              : 
     204              : /* Feature tests against the various tunings.  */
     205              : unsigned char ix86_tune_features[X86_TUNE_LAST];
     206              : 
     207              : /* Feature tests against the various tunings used to create ix86_tune_features
     208              :    based on the processor mask.  */
     209              : static unsigned HOST_WIDE_INT initial_ix86_tune_features[X86_TUNE_LAST] = {
     210              : #undef DEF_TUNE
     211              : #define DEF_TUNE(tune, name, selector) selector,
     212              : #include "x86-tune.def"
     213              : #undef DEF_TUNE
     214              : };
     215              : 
     216              : /* Feature tests against the various architecture variations.  */
     217              : unsigned char ix86_arch_features[X86_ARCH_LAST];
     218              : 
     219              : struct ix86_target_opts
     220              : {
     221              :   const char *option;           /* option string */
     222              :   HOST_WIDE_INT mask;           /* isa mask options */
     223              : };
     224              : 
     225              : /* This table is ordered so that options like -msse4.2 that imply other
     226              :    ISAs come first.  Target string will be displayed in the same order.  */
     227              : static struct ix86_target_opts isa2_opts[] =
     228              : {
     229              :   { "-mcx16",         OPTION_MASK_ISA2_CX16 },
     230              :   { "-mvaes",         OPTION_MASK_ISA2_VAES },
     231              :   { "-mrdpid",                OPTION_MASK_ISA2_RDPID },
     232              :   { "-mpconfig",      OPTION_MASK_ISA2_PCONFIG },
     233              :   { "-mwbnoinvd",     OPTION_MASK_ISA2_WBNOINVD },
     234              :   { "-mavx512vp2intersect", OPTION_MASK_ISA2_AVX512VP2INTERSECT },
     235              :   { "-msgx",          OPTION_MASK_ISA2_SGX },
     236              :   { "-mhle",          OPTION_MASK_ISA2_HLE },
     237              :   { "-mmovbe",                OPTION_MASK_ISA2_MOVBE },
     238              :   { "-mclzero",               OPTION_MASK_ISA2_CLZERO },
     239              :   { "-mmwaitx",               OPTION_MASK_ISA2_MWAITX },
     240              :   { "-mmwait",                OPTION_MASK_ISA2_MWAIT },
     241              :   { "-mmovdir64b",    OPTION_MASK_ISA2_MOVDIR64B },
     242              :   { "-mwaitpkg",      OPTION_MASK_ISA2_WAITPKG },
     243              :   { "-mcldemote",     OPTION_MASK_ISA2_CLDEMOTE },
     244              :   { "-mptwrite",      OPTION_MASK_ISA2_PTWRITE },
     245              :   { "-mavx512bf16",   OPTION_MASK_ISA2_AVX512BF16 },
     246              :   { "-menqcmd",               OPTION_MASK_ISA2_ENQCMD },
     247              :   { "-mserialize",    OPTION_MASK_ISA2_SERIALIZE },
     248              :   { "-mtsxldtrk",     OPTION_MASK_ISA2_TSXLDTRK },
     249              :   { "-mamx-tile",     OPTION_MASK_ISA2_AMX_TILE },
     250              :   { "-mamx-int8",     OPTION_MASK_ISA2_AMX_INT8 },
     251              :   { "-mamx-bf16",     OPTION_MASK_ISA2_AMX_BF16 },
     252              :   { "-muintr",                OPTION_MASK_ISA2_UINTR },
     253              :   { "-mhreset",               OPTION_MASK_ISA2_HRESET },
     254              :   { "-mkl",           OPTION_MASK_ISA2_KL },
     255              :   { "-mwidekl",       OPTION_MASK_ISA2_WIDEKL },
     256              :   { "-mavxvnni",      OPTION_MASK_ISA2_AVXVNNI },
     257              :   { "-mavx512fp16",   OPTION_MASK_ISA2_AVX512FP16 },
     258              :   { "-mavxifma",      OPTION_MASK_ISA2_AVXIFMA },
     259              :   { "-mavxvnniint8",  OPTION_MASK_ISA2_AVXVNNIINT8 },
     260              :   { "-mavxneconvert",   OPTION_MASK_ISA2_AVXNECONVERT },
     261              :   { "-mcmpccxadd",      OPTION_MASK_ISA2_CMPCCXADD },
     262              :   { "-mamx-fp16",       OPTION_MASK_ISA2_AMX_FP16 },
     263              :   { "-mprefetchi",      OPTION_MASK_ISA2_PREFETCHI },
     264              :   { "-mraoint",       OPTION_MASK_ISA2_RAOINT },
     265              :   { "-mamx-complex",  OPTION_MASK_ISA2_AMX_COMPLEX },
     266              :   { "-mavxvnniint16", OPTION_MASK_ISA2_AVXVNNIINT16 },
     267              :   { "-msm3",          OPTION_MASK_ISA2_SM3 },
     268              :   { "-msha512",               OPTION_MASK_ISA2_SHA512 },
     269              :   { "-msm4",            OPTION_MASK_ISA2_SM4 },
     270              :   { "-musermsr",      OPTION_MASK_ISA2_USER_MSR },
     271              :   { "-mavx10.1",      OPTION_MASK_ISA2_AVX10_1 },
     272              :   { "-mavx10.2",      OPTION_MASK_ISA2_AVX10_2 },
     273              :   { "-mamx-avx512",   OPTION_MASK_ISA2_AMX_AVX512 },
     274              :   { "-mamx-fp8",      OPTION_MASK_ISA2_AMX_FP8 },
     275              :   { "-mmovrs",                OPTION_MASK_ISA2_MOVRS },
     276              :   { "-mamx-movrs",    OPTION_MASK_ISA2_AMX_MOVRS },
     277              :   { "-mavx512bmm",    OPTION_MASK_ISA2_AVX512BMM },
     278              :   { "-mavx10v2aux",   OPTION_MASK_ISA2_AVX10V2AUX },
     279              :   { "-macev1",                OPTION_MASK_ISA2_ACEV1 },
     280              :   { "-mavx10v1aux",   OPTION_MASK_ISA2_AVX10V1AUX }
     281              : };
     282              : static struct ix86_target_opts isa_opts[] =
     283              : {
     284              :   { "-mavx512vpopcntdq", OPTION_MASK_ISA_AVX512VPOPCNTDQ },
     285              :   { "-mavx512bitalg", OPTION_MASK_ISA_AVX512BITALG },
     286              :   { "-mvpclmulqdq",   OPTION_MASK_ISA_VPCLMULQDQ },
     287              :   { "-mgfni",         OPTION_MASK_ISA_GFNI },
     288              :   { "-mavx512vnni",   OPTION_MASK_ISA_AVX512VNNI },
     289              :   { "-mavx512vbmi2",  OPTION_MASK_ISA_AVX512VBMI2 },
     290              :   { "-mavx512vbmi",   OPTION_MASK_ISA_AVX512VBMI },
     291              :   { "-mavx512ifma",   OPTION_MASK_ISA_AVX512IFMA },
     292              :   { "-mavx512vl",     OPTION_MASK_ISA_AVX512VL },
     293              :   { "-mavx512bw",     OPTION_MASK_ISA_AVX512BW },
     294              :   { "-mavx512dq",     OPTION_MASK_ISA_AVX512DQ },
     295              :   { "-mavx512cd",     OPTION_MASK_ISA_AVX512CD },
     296              :   { "-mavx512f",      OPTION_MASK_ISA_AVX512F },
     297              :   { "-mavx2",         OPTION_MASK_ISA_AVX2 },
     298              :   { "-mfma",          OPTION_MASK_ISA_FMA },
     299              :   { "-mxop",          OPTION_MASK_ISA_XOP },
     300              :   { "-mfma4",         OPTION_MASK_ISA_FMA4 },
     301              :   { "-mf16c",         OPTION_MASK_ISA_F16C },
     302              :   { "-mavx",          OPTION_MASK_ISA_AVX },
     303              : /*{ "-msse4"          OPTION_MASK_ISA_SSE4 }, */
     304              :   { "-msse4.2",               OPTION_MASK_ISA_SSE4_2 },
     305              :   { "-msse4.1",               OPTION_MASK_ISA_SSE4_1 },
     306              :   { "-msse4a",                OPTION_MASK_ISA_SSE4A },
     307              :   { "-mssse3",                OPTION_MASK_ISA_SSSE3 },
     308              :   { "-msse3",         OPTION_MASK_ISA_SSE3 },
     309              :   { "-maes",          OPTION_MASK_ISA_AES },
     310              :   { "-msha",          OPTION_MASK_ISA_SHA },
     311              :   { "-mpclmul",               OPTION_MASK_ISA_PCLMUL },
     312              :   { "-msse2",         OPTION_MASK_ISA_SSE2 },
     313              :   { "-msse",          OPTION_MASK_ISA_SSE },
     314              :   { "-m3dnowa",               OPTION_MASK_ISA_3DNOW_A },
     315              :   { "-m3dnow",                OPTION_MASK_ISA_3DNOW },
     316              :   { "-mmmx",          OPTION_MASK_ISA_MMX },
     317              :   { "-mrtm",          OPTION_MASK_ISA_RTM },
     318              :   { "-mprfchw",               OPTION_MASK_ISA_PRFCHW },
     319              :   { "-mrdseed",               OPTION_MASK_ISA_RDSEED },
     320              :   { "-madx",          OPTION_MASK_ISA_ADX },
     321              :   { "-mclflushopt",   OPTION_MASK_ISA_CLFLUSHOPT },
     322              :   { "-mxsaves",               OPTION_MASK_ISA_XSAVES },
     323              :   { "-mxsavec",               OPTION_MASK_ISA_XSAVEC },
     324              :   { "-mxsaveopt",     OPTION_MASK_ISA_XSAVEOPT },
     325              :   { "-mxsave",                OPTION_MASK_ISA_XSAVE },
     326              :   { "-mabm",          OPTION_MASK_ISA_ABM },
     327              :   { "-mbmi",          OPTION_MASK_ISA_BMI },
     328              :   { "-mbmi2",         OPTION_MASK_ISA_BMI2 },
     329              :   { "-mlzcnt",                OPTION_MASK_ISA_LZCNT },
     330              :   { "-mtbm",          OPTION_MASK_ISA_TBM },
     331              :   { "-mpopcnt",               OPTION_MASK_ISA_POPCNT },
     332              :   { "-msahf",         OPTION_MASK_ISA_SAHF },
     333              :   { "-mcrc32",                OPTION_MASK_ISA_CRC32 },
     334              :   { "-mfsgsbase",     OPTION_MASK_ISA_FSGSBASE },
     335              :   { "-mrdrnd",                OPTION_MASK_ISA_RDRND },
     336              :   { "-mpku",          OPTION_MASK_ISA_PKU },
     337              :   { "-mlwp",          OPTION_MASK_ISA_LWP },
     338              :   { "-mfxsr",         OPTION_MASK_ISA_FXSR },
     339              :   { "-mclwb",         OPTION_MASK_ISA_CLWB },
     340              :   { "-mshstk",                OPTION_MASK_ISA_SHSTK },
     341              :   { "-mmovdiri",      OPTION_MASK_ISA_MOVDIRI }
     342              : };
     343              : 
     344              : /* Return 1 if TRAIT NAME is present in the OpenMP context's
     345              :    device trait set, return 0 if not present in any OpenMP context in the
     346              :    whole translation unit, or -1 if not present in the current OpenMP context
     347              :    but might be present in another OpenMP context in the same TU.  */
     348              : 
     349              : int
     350         1972 : ix86_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
     351              :                                const char *name)
     352              : {
     353         1972 :   switch (trait)
     354              :     {
     355          363 :     case omp_device_kind:
     356          363 :       return strcmp (name, "cpu") == 0;
     357          792 :     case omp_device_arch:
     358          792 :       if (strcmp (name, "x86") == 0)
     359              :         return 1;
     360          788 :       if (TARGET_64BIT)
     361              :         {
     362          788 :           if (TARGET_X32)
     363            0 :             return strcmp (name, "x32") == 0;
     364              :           else
     365          788 :             return strcmp (name, "x86_64") == 0;
     366              :         }
     367            0 :       if (strcmp (name, "ia32") == 0 || strcmp (name, "i386") == 0)
     368              :         return 1;
     369            0 :       if (strcmp (name, "i486") == 0)
     370            0 :         return ix86_arch != PROCESSOR_I386 ? 1 : -1;
     371            0 :       if (strcmp (name, "i586") == 0)
     372            0 :         return (ix86_arch != PROCESSOR_I386
     373            0 :                 && ix86_arch != PROCESSOR_I486) ? 1 : -1;
     374            0 :       if (strcmp (name, "i686") == 0)
     375            0 :         return (ix86_arch != PROCESSOR_I386
     376            0 :                 && ix86_arch != PROCESSOR_I486
     377            0 :                 && ix86_arch != PROCESSOR_LAKEMONT
     378            0 :                 && ix86_arch != PROCESSOR_PENTIUM) ? 1 : -1;
     379              :       return 0;
     380              :     case omp_device_isa:
     381          917 :       for (int i = 0; i < 2; i++)
     382              :         {
     383          867 :           struct ix86_target_opts *opts = i ? isa2_opts : isa_opts;
     384           50 :           size_t nopts = i ? ARRAY_SIZE (isa2_opts) : ARRAY_SIZE (isa_opts);
     385          867 :           HOST_WIDE_INT mask = i ? ix86_isa_flags2 : ix86_isa_flags;
     386        16381 :           for (size_t n = 0; n < nopts; n++)
     387              :             {
     388              :               /* Handle sse4 as an alias to sse4.2.  */
     389        16281 :               if (opts[n].mask == OPTION_MASK_ISA_SSE4_2)
     390              :                 {
     391          229 :                   if (strcmp (name, "sse4") == 0)
     392           29 :                     return (mask & opts[n].mask) != 0 ? 1 : -1;
     393              :                 }
     394        16252 :               if (strcmp (name, opts[n].option + 2) == 0)
     395          738 :                 return (mask & opts[n].mask) != 0 ? 1 : -1;
     396              :             }
     397              :         }
     398              :       return 0;
     399            0 :     default:
     400            0 :       gcc_unreachable ();
     401              :     }
     402              : }
     403              : 
     404              : /* Return a string that documents the current -m options.  The caller is
     405              :    responsible for freeing the string.  */
     406              : 
     407              : char *
     408           23 : ix86_target_string (HOST_WIDE_INT isa, HOST_WIDE_INT isa2,
     409              :                     int flags, int flags2,
     410              :                     const char *arch, const char *tune,
     411              :                     enum fpmath_unit fpmath,
     412              :                     enum prefer_vector_width pvw,
     413              :                     enum prefer_vector_width move_max,
     414              :                     bool add_nl_p, bool add_abi_p)
     415              : {
     416              :   /* Flag options.  */
     417           23 :   static struct ix86_target_opts flag_opts[] =
     418              :   {
     419              :     { "-m128bit-long-double",         MASK_128BIT_LONG_DOUBLE },
     420              :     { "-mlong-double-128",            MASK_LONG_DOUBLE_128 },
     421              :     { "-mlong-double-64",             MASK_LONG_DOUBLE_64 },
     422              :     { "-m80387",                      MASK_80387 },
     423              :     { "-maccumulate-outgoing-args",   MASK_ACCUMULATE_OUTGOING_ARGS },
     424              :     { "-malign-double",                       MASK_ALIGN_DOUBLE },
     425              :     { "-mcld",                                MASK_CLD },
     426              :     { "-mfp-ret-in-387",              MASK_FLOAT_RETURNS },
     427              :     { "-mieee-fp",                    MASK_IEEE_FP },
     428              :     { "-minline-all-stringops",               MASK_INLINE_ALL_STRINGOPS },
     429              :     { "-minline-stringops-dynamically",       MASK_INLINE_STRINGOPS_DYNAMICALLY },
     430              :     { "-mms-bitfields",                       MASK_MS_BITFIELD_LAYOUT },
     431              :     { "-mno-align-stringops",         MASK_NO_ALIGN_STRINGOPS },
     432              :     { "-mno-fancy-math-387",          MASK_NO_FANCY_MATH_387 },
     433              :     { "-mno-push-args",                       MASK_NO_PUSH_ARGS },
     434              :     { "-mno-red-zone",                        MASK_NO_RED_ZONE },
     435              :     { "-momit-leaf-frame-pointer",    MASK_OMIT_LEAF_FRAME_POINTER },
     436              :     { "-mrecip",                      MASK_RECIP },
     437              :     { "-mrtd",                                MASK_RTD },
     438              :     { "-msseregparm",                 MASK_SSEREGPARM },
     439              :     { "-mstack-arg-probe",            MASK_STACK_PROBE },
     440              :     { "-mtls-direct-seg-refs",                MASK_TLS_DIRECT_SEG_REFS },
     441              :     { "-mvect8-ret-in-mem",           MASK_VECT8_RETURNS },
     442              :     { "-m8bit-idiv",                  MASK_USE_8BIT_IDIV },
     443              :     { "-mvzeroupper",                 MASK_VZEROUPPER },
     444              :     { "-mstv",                                MASK_STV },
     445              :     { "-mavx256-split-unaligned-load",        MASK_AVX256_SPLIT_UNALIGNED_LOAD },
     446              :     { "-mavx256-split-unaligned-store",       MASK_AVX256_SPLIT_UNALIGNED_STORE },
     447              :     { "-mcall-ms2sysv-xlogues",               MASK_CALL_MS2SYSV_XLOGUES },
     448              :     { "-mrelax-cmpxchg-loop",         MASK_RELAX_CMPXCHG_LOOP }
     449              :   };
     450              : 
     451              :   /* Additional flag options.  */
     452           23 :   static struct ix86_target_opts flag2_opts[] =
     453              :   {
     454              :     { "-mgeneral-regs-only",          OPTION_MASK_GENERAL_REGS_ONLY }
     455              :   };
     456              : 
     457           23 :   const char *opts[ARRAY_SIZE (isa_opts) + ARRAY_SIZE (isa2_opts)
     458              :                    + ARRAY_SIZE (flag_opts) + ARRAY_SIZE (flag2_opts) + 6][2];
     459              : 
     460           23 :   char isa_other[40];
     461           23 :   char isa2_other[40];
     462           23 :   char flags_other[40];
     463           23 :   char flags2_other[40];
     464           23 :   unsigned num = 0;
     465           23 :   unsigned i, j;
     466           23 :   char *ret;
     467           23 :   char *ptr;
     468           23 :   size_t len;
     469           23 :   size_t line_len;
     470           23 :   size_t sep_len;
     471           23 :   const char *abi;
     472              : 
     473           23 :   memset (opts, '\0', sizeof (opts));
     474              : 
     475              :   /* Add -march= option.  */
     476           23 :   if (arch)
     477              :     {
     478            0 :       opts[num][0] = "-march=";
     479            0 :       opts[num++][1] = arch;
     480              :     }
     481              : 
     482              :   /* Add -mtune= option.  */
     483           23 :   if (tune)
     484              :     {
     485            0 :       opts[num][0] = "-mtune=";
     486            0 :       opts[num++][1] = tune;
     487              :     }
     488              : 
     489              :   /* Add -m32/-m64/-mx32.  */
     490           23 :   if (add_abi_p)
     491              :     {
     492            2 :       if ((isa & OPTION_MASK_ISA_64BIT) != 0)
     493              :         {
     494            2 :           if ((isa & OPTION_MASK_ABI_64) != 0)
     495              :             abi = "-m64";
     496              :           else
     497            0 :             abi = "-mx32";
     498              :         }
     499              :       else
     500              :         abi = "-m32";
     501            2 :       opts[num++][0] = abi;
     502              :     }
     503           23 :   isa &= ~(OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
     504              : 
     505              :   /* Pick out the options in isa2 options.  */
     506         1219 :   for (i = 0; i < ARRAY_SIZE (isa2_opts); i++)
     507              :     {
     508         1196 :       if ((isa2 & isa2_opts[i].mask) != 0)
     509              :         {
     510            5 :           opts[num++][0] = isa2_opts[i].option;
     511            5 :           isa2 &= ~ isa2_opts[i].mask;
     512              :         }
     513              :     }
     514              : 
     515           23 :   if (isa2 && add_nl_p)
     516              :     {
     517            0 :       opts[num++][0] = isa2_other;
     518            0 :       sprintf (isa2_other, "(other isa2: %#" HOST_WIDE_INT_PRINT "x)", isa2);
     519              :     }
     520              : 
     521              :   /* Pick out the options in isa options.  */
     522         1334 :   for (i = 0; i < ARRAY_SIZE (isa_opts); i++)
     523              :     {
     524         1311 :       if ((isa & isa_opts[i].mask) != 0)
     525              :         {
     526           36 :           opts[num++][0] = isa_opts[i].option;
     527           36 :           isa &= ~ isa_opts[i].mask;
     528              :         }
     529              :     }
     530              : 
     531           23 :   if (isa && add_nl_p)
     532              :     {
     533            0 :       opts[num++][0] = isa_other;
     534            0 :       sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)", isa);
     535              :     }
     536              : 
     537              :   /* Add flag options.  */
     538          713 :   for (i = 0; i < ARRAY_SIZE (flag_opts); i++)
     539              :     {
     540          690 :       if ((flags & flag_opts[i].mask) != 0)
     541              :         {
     542            0 :           opts[num++][0] = flag_opts[i].option;
     543            0 :           flags &= ~ flag_opts[i].mask;
     544              :         }
     545              :     }
     546              : 
     547           23 :   if (flags && add_nl_p)
     548              :     {
     549            0 :       opts[num++][0] = flags_other;
     550            0 :       sprintf (flags_other, "(other flags: %#x)", flags);
     551              :     }
     552              : 
     553              :     /* Add additional flag options.  */
     554           46 :   for (i = 0; i < ARRAY_SIZE (flag2_opts); i++)
     555              :     {
     556           23 :       if ((flags2 & flag2_opts[i].mask) != 0)
     557              :         {
     558            0 :           opts[num++][0] = flag2_opts[i].option;
     559            0 :           flags2 &= ~ flag2_opts[i].mask;
     560              :         }
     561              :     }
     562              : 
     563           23 :   if (flags2 && add_nl_p)
     564              :     {
     565            0 :       opts[num++][0] = flags2_other;
     566            0 :       sprintf (flags2_other, "(other flags2: %#x)", flags2);
     567              :     }
     568              : 
     569              :   /* Add -mfpmath= option.  */
     570           23 :   if (fpmath)
     571              :     {
     572            0 :       opts[num][0] = "-mfpmath=";
     573            0 :       switch ((int) fpmath)
     574              :         {
     575            0 :         case FPMATH_387:
     576            0 :           opts[num++][1] = "387";
     577            0 :           break;
     578              : 
     579            0 :         case FPMATH_SSE:
     580            0 :           opts[num++][1] = "sse";
     581            0 :           break;
     582              : 
     583            0 :         case FPMATH_387 | FPMATH_SSE:
     584            0 :           opts[num++][1] = "sse+387";
     585            0 :           break;
     586              : 
     587            0 :         default:
     588            0 :           gcc_unreachable ();
     589              :         }
     590              :     }
     591              : 
     592           23 :   auto add_vector_width = [&opts, &num] (prefer_vector_width pvw,
     593              :                                          const char *cmd)
     594              :     {
     595            0 :       opts[num][0] = cmd;
     596            0 :       switch ((int) pvw)
     597              :         {
     598            0 :         case PVW_AVX128:
     599            0 :           opts[num++][1] = "128";
     600            0 :           break;
     601              : 
     602            0 :         case PVW_AVX256:
     603            0 :           opts[num++][1] = "256";
     604            0 :           break;
     605              : 
     606            0 :         case PVW_AVX512:
     607            0 :           opts[num++][1] = "512";
     608            0 :           break;
     609              : 
     610            0 :         default:
     611            0 :           gcc_unreachable ();
     612              :         }
     613           23 :     };
     614              : 
     615              :   /* Add -mprefer-vector-width= option.  */
     616           23 :   if (pvw)
     617            0 :     add_vector_width (pvw, "-mprefer-vector-width=");
     618              : 
     619              :   /* Add -mmove-max= option.  */
     620           23 :   if (move_max)
     621            0 :     add_vector_width (move_max, "-mmove-max=");
     622              : 
     623              :   /* Any options?  */
     624           23 :   if (num == 0)
     625              :     return NULL;
     626              : 
     627           23 :   gcc_assert (num < ARRAY_SIZE (opts));
     628              : 
     629              :   /* Size the string.  */
     630           23 :   len = 0;
     631           23 :   sep_len = (add_nl_p) ? 3 : 1;
     632           66 :   for (i = 0; i < num; i++)
     633              :     {
     634           43 :       len += sep_len;
     635          129 :       for (j = 0; j < 2; j++)
     636           86 :         if (opts[i][j])
     637           43 :           len += strlen (opts[i][j]);
     638              :     }
     639              : 
     640              :   /* Build the string.  */
     641           23 :   ret = ptr = (char *) xmalloc (len);
     642           23 :   line_len = 0;
     643              : 
     644           89 :   for (i = 0; i < num; i++)
     645              :     {
     646              :       size_t len2[2];
     647              : 
     648          129 :       for (j = 0; j < 2; j++)
     649           86 :         len2[j] = (opts[i][j]) ? strlen (opts[i][j]) : 0;
     650              : 
     651           43 :       if (i != 0)
     652              :         {
     653           20 :           *ptr++ = ' ';
     654           20 :           line_len++;
     655              : 
     656           20 :           if (add_nl_p && line_len + len2[0] + len2[1] > 70)
     657              :             {
     658            0 :               *ptr++ = '\\';
     659            0 :               *ptr++ = '\n';
     660            0 :               line_len = 0;
     661              :             }
     662              :         }
     663              : 
     664          129 :       for (j = 0; j < 2; j++)
     665           86 :         if (opts[i][j])
     666              :           {
     667           43 :             memcpy (ptr, opts[i][j], len2[j]);
     668           43 :             ptr += len2[j];
     669           43 :             line_len += len2[j];
     670              :           }
     671              :     }
     672              : 
     673           23 :   *ptr = '\0';
     674           23 :   gcc_assert (ret + len >= ptr);
     675              : 
     676              :   return ret;
     677              : }
     678              : 
     679              : /* Function that is callable from the debugger to print the current
     680              :    options.  */
     681              : void ATTRIBUTE_UNUSED
     682            0 : ix86_debug_options (void)
     683              : {
     684            0 :   char *opts = ix86_target_string (ix86_isa_flags, ix86_isa_flags2,
     685              :                                    target_flags, ix86_target_flags,
     686              :                                    ix86_arch_string, ix86_tune_string,
     687              :                                    ix86_fpmath, prefer_vector_width_type,
     688              :                                    ix86_move_max, true, true);
     689              : 
     690            0 :   if (opts)
     691              :     {
     692            0 :       fprintf (stderr, "%s\n\n", opts);
     693            0 :       free (opts);
     694              :     }
     695              :   else
     696            0 :     fputs ("<no options>\n\n", stderr);
     697              : 
     698            0 :   return;
     699              : }
     700              : 
     701              : /* Save the current options */
     702              : 
     703              : void
     704     79436093 : ix86_function_specific_save (struct cl_target_option *ptr,
     705              :                              struct gcc_options *opts,
     706              :                              struct gcc_options */* opts_set */)
     707              : {
     708     79436093 :   ptr->arch = ix86_arch;
     709     79436093 :   ptr->schedule = ix86_schedule;
     710     79436093 :   ptr->prefetch_sse = ix86_prefetch_sse;
     711     79436093 :   ptr->tune = ix86_tune;
     712     79436093 :   ptr->branch_cost = ix86_branch_cost;
     713     79436093 :   ptr->tune_defaulted = ix86_tune_defaulted;
     714     79436093 :   ptr->arch_specified = ix86_arch_specified;
     715     79436093 :   ptr->x_ix86_apx_features = opts->x_ix86_apx_features;
     716     79436093 :   ptr->x_ix86_isa_flags_explicit = opts->x_ix86_isa_flags_explicit;
     717     79436093 :   ptr->x_ix86_isa_flags2_explicit = opts->x_ix86_isa_flags2_explicit;
     718     79436093 :   ptr->x_recip_mask_explicit = opts->x_recip_mask_explicit;
     719     79436093 :   ptr->x_ix86_arch_string = opts->x_ix86_arch_string;
     720     79436093 :   ptr->x_ix86_tune_string = opts->x_ix86_tune_string;
     721     79436093 :   ptr->x_ix86_asm_dialect = opts->x_ix86_asm_dialect;
     722     79436093 :   ptr->x_ix86_dump_tunes = opts->x_ix86_dump_tunes;
     723     79436093 :   ptr->x_ix86_force_drap = opts->x_ix86_force_drap;
     724     79436093 :   ptr->x_ix86_recip_name = opts->x_ix86_recip_name;
     725     79436093 :   ptr->x_ix86_section_threshold = opts->x_ix86_section_threshold;
     726     79436093 :   ptr->x_ix86_sse2avx = opts->x_ix86_sse2avx;
     727     79436093 :   ptr->x_ix86_stringop_alg = opts->x_ix86_stringop_alg;
     728     79436093 :   ptr->x_ix86_tls_dialect = opts->x_ix86_tls_dialect;
     729     79436093 :   ptr->x_ix86_tune_ctrl_string = opts->x_ix86_tune_ctrl_string;
     730     79436093 :   ptr->x_ix86_tune_memcpy_strategy = opts->x_ix86_tune_memcpy_strategy;
     731     79436093 :   ptr->x_ix86_tune_memset_strategy = opts->x_ix86_tune_memset_strategy;
     732     79436093 :   ptr->x_ix86_tune_no_default = opts->x_ix86_tune_no_default;
     733              : 
     734              :   /* The fields are char but the variables are not; make sure the
     735              :      values fit in the fields.  */
     736     79436093 :   gcc_assert (ptr->arch == ix86_arch);
     737     79436093 :   gcc_assert (ptr->schedule == ix86_schedule);
     738     79436093 :   gcc_assert (ptr->tune == ix86_tune);
     739     79436093 :   gcc_assert (ptr->branch_cost == ix86_branch_cost);
     740     79436093 : }
     741              : 
     742              : /* Feature tests against the various architecture variations, used to create
     743              :    ix86_arch_features based on the processor mask.  */
     744              : static unsigned HOST_WIDE_INT initial_ix86_arch_features[X86_ARCH_LAST] = {
     745              :   /* X86_ARCH_CMOV: Conditional move was added for pentiumpro.  */
     746              :   ~(m_386 | m_486 | m_PENT | m_LAKEMONT | m_K6),
     747              : 
     748              :   /* X86_ARCH_CMPXCHG: Compare and exchange was added for 80486.  */
     749              :   ~m_386,
     750              : 
     751              :   /* X86_ARCH_CMPXCHG8B: Compare and exchange 8 bytes was added for pentium. */
     752              :   ~(m_386 | m_486),
     753              : 
     754              :   /* X86_ARCH_XADD: Exchange and add was added for 80486.  */
     755              :   ~m_386,
     756              : 
     757              :   /* X86_ARCH_BSWAP: Byteswap was added for 80486.  */
     758              :   ~m_386,
     759              : };
     760              : 
     761              : /* This table must be in sync with enum processor_type in i386.h.  */
     762              : static const struct processor_costs *processor_cost_table[] =
     763              : {
     764              :   &generic_cost,    /* PROCESSOR_GENERIC.           */
     765              :   &i386_cost,               /* PROCESSOR_I386.              */
     766              :   &i486_cost,               /* PROCESSOR_I486.              */
     767              :   &pentium_cost,    /* PROCESSOR_PENTIUM.           */
     768              :   &lakemont_cost,   /* PROCESSOR_LAKEMONT.          */
     769              :   &pentiumpro_cost, /* PROCESSOR_PENTIUMPRO.        */
     770              :   &pentium4_cost,   /* PROCESSOR_PENTIUM4.          */
     771              :   &nocona_cost,             /* PROCESSOR_NOCONA.            */
     772              :   &core_cost,               /* PROCESSOR_CORE2.             */
     773              :   &core_cost,               /* PROCESSOR_NEHALEM.           */
     774              :   &core_cost,               /* PROCESSOR_SANDYBRIDGE.       */
     775              :   &core_cost,               /* PROCESSOR_HASWELL.           */
     776              :   &atom_cost,               /* PROCESSOR_BONNELL.           */
     777              :   &slm_cost,                /* PROCESSOR_SILVERMONT.        */
     778              :   &slm_cost,                /* PROCESSOR_GOLDMONT.          */
     779              :   &slm_cost,                /* PROCESSOR_GOLDMONT_PLUS.     */
     780              :   &tremont_cost,    /* PROCESSOR_TREMONT.           */
     781              :   &alderlake_cost,  /* PROCESSOR_SIERRAFOREST.      */
     782              :   &alderlake_cost,  /* PROCESSOR_GRANDRIDGE.        */
     783              :   &alderlake_cost,  /* PROCESSOR_CLEARWATERFOREST.  */
     784              :   &skylake_cost,    /* PROCESSOR_SKYLAKE.   */
     785              :   &skylake_cost,    /* PROCESSOR_SKYLAKE_AVX512.    */
     786              :   &icelake_cost,    /* PROCESSOR_CANNONLAKE.        */
     787              :   &icelake_cost,    /* PROCESSOR_ICELAKE_CLIENT.    */
     788              :   &icelake_cost,    /* PROCESSOR_ICELAKE_SERVER.    */
     789              :   &skylake_cost,    /* PROCESSOR_CASCADELAKE.       */
     790              :   &icelake_cost,    /* PROCESSOR_TIGERLAKE.         */
     791              :   &skylake_cost,    /* PROCESSOR_COOPERLAKE.        */
     792              :   &icelake_cost,    /* PROCESSOR_SAPPHIRERAPIDS.    */
     793              :   &alderlake_cost,  /* PROCESSOR_ALDERLAKE.         */
     794              :   &icelake_cost,    /* PROCESSOR_ROCKETLAKE.        */
     795              :   &icelake_cost,    /* PROCESSOR_GRANITERAPIDS.     */
     796              :   &icelake_cost,    /* PROCESSOR_GRANITERAPIDS_D.   */
     797              :   &alderlake_cost,  /* PROCESSOR_ARROWLAKE.         */
     798              :   &alderlake_cost,  /* PROCESSOR_ARROWLAKE_S.       */
     799              :   &alderlake_cost,  /* PROCESSOR_PANTHERLAKE.       */
     800              :   &icelake_cost,    /* PROCESSOR_DIAMONDRAPIDS.     */
     801              :   &alderlake_cost,  /* PROCESSOR_NOVALAKE.          */
     802              :   &alderlake_cost,  /* PROCESSOR_INTEL.             */
     803              :   &lujiazui_cost,   /* PROCESSOR_LUJIAZUI.          */
     804              :   &yongfeng_cost,   /* PROCESSOR_YONGFENG.          */
     805              :   &shijidadao_cost, /* PROCESSOR_SHIJIDADAO.        */
     806              :   &geode_cost,              /* PROCESSOR_GEODE.             */
     807              :   &k6_cost,         /* PROCESSOR_K6.                */
     808              :   &athlon_cost,             /* PROCESSOR_ATHLON.            */
     809              :   &k8_cost,         /* PROCESSOR_K8.                */
     810              :   &amdfam10_cost,   /* PROCESSOR_AMDFAM10.          */
     811              :   &bdver_cost,              /* PROCESSOR_BDVER1.            */
     812              :   &bdver_cost,              /* PROCESSOR_BDVER2.            */
     813              :   &bdver_cost,              /* PROCESSOR_BDVER3.            */
     814              :   &bdver_cost,              /* PROCESSOR_BDVER4.            */
     815              :   &btver1_cost,             /* PROCESSOR_BTVER1.            */
     816              :   &btver2_cost,             /* PROCESSOR_BTVER2.            */
     817              :   &znver1_cost,             /* PROCESSOR_ZNVER1.            */
     818              :   &znver2_cost,             /* PROCESSOR_ZNVER2.            */
     819              :   &znver3_cost,             /* PROCESSOR_ZNVER3.            */
     820              :   &znver4_cost,             /* PROCESSOR_ZNVER4.            */
     821              :   &znver5_cost,             /* PROCESSOR_ZNVER5.            */
     822              :   &znver5_cost,             /* PROCESSOR_ZNVER6.            */
     823              :   &c86_4g_m4_cost,  /* PROCESSOR_C86_4G_M4.         */
     824              :   &c86_4g_m6_cost,  /* PROCESSOR_C86_4G_M6.         */
     825              :   &c86_4g_m7_cost,  /* PROCESSOR_C86_4G_M7.         */
     826              :   &c86_4g_m8_cost   /* PROCESSOR_C86_4G_M8.         */
     827              : };
     828              : 
     829              : /* Guarantee that the array is aligned with enum processor_type.  */
     830              : STATIC_ASSERT (ARRAY_SIZE (processor_cost_table) == PROCESSOR_max);
     831              : 
     832              : static bool
     833              : ix86_option_override_internal (bool main_args_p,
     834              :                                struct gcc_options *opts,
     835              :                                struct gcc_options *opts_set);
     836              : static void
     837              : set_ix86_tune_features (struct gcc_options *opts,
     838              :                         enum processor_type ix86_tune, bool dump);
     839              : 
     840              : /* Restore the current options */
     841              : 
     842              : void
     843     55329139 : ix86_function_specific_restore (struct gcc_options *opts,
     844              :                                 struct gcc_options */* opts_set */,
     845              :                                 struct cl_target_option *ptr)
     846              : {
     847     55329139 :   enum processor_type old_tune = ix86_tune;
     848     55329139 :   enum processor_type old_arch = ix86_arch;
     849     55329139 :   unsigned HOST_WIDE_INT ix86_arch_mask;
     850     55329139 :   int i;
     851              : 
     852              :   /* We don't change -fPIC.  */
     853     55329139 :   opts->x_flag_pic = flag_pic;
     854              : 
     855     55329139 :   ix86_arch = (enum processor_type) ptr->arch;
     856     55329139 :   ix86_schedule = (enum attr_cpu) ptr->schedule;
     857     55329139 :   ix86_tune = (enum processor_type) ptr->tune;
     858     55329139 :   ix86_prefetch_sse = ptr->prefetch_sse;
     859     55329139 :   ix86_tune_defaulted = ptr->tune_defaulted;
     860     55329139 :   ix86_arch_specified = ptr->arch_specified;
     861     55329139 :   opts->x_ix86_apx_features = ptr->x_ix86_apx_features;
     862     55329139 :   opts->x_ix86_isa_flags_explicit = ptr->x_ix86_isa_flags_explicit;
     863     55329139 :   opts->x_ix86_isa_flags2_explicit = ptr->x_ix86_isa_flags2_explicit;
     864     55329139 :   opts->x_recip_mask_explicit = ptr->x_recip_mask_explicit;
     865     55329139 :   opts->x_ix86_arch_string = ptr->x_ix86_arch_string;
     866     55329139 :   opts->x_ix86_tune_string = ptr->x_ix86_tune_string;
     867     55329139 :   opts->x_ix86_asm_dialect = ptr->x_ix86_asm_dialect;
     868     55329139 :   opts->x_ix86_dump_tunes = ptr->x_ix86_dump_tunes;
     869     55329139 :   opts->x_ix86_force_drap = ptr->x_ix86_force_drap;
     870     55329139 :   opts->x_ix86_recip_name = ptr->x_ix86_recip_name;
     871     55329139 :   opts->x_ix86_section_threshold = ptr->x_ix86_section_threshold;
     872     55329139 :   opts->x_ix86_sse2avx = ptr->x_ix86_sse2avx;
     873     55329139 :   opts->x_ix86_stringop_alg = ptr->x_ix86_stringop_alg;
     874     55329139 :   opts->x_ix86_tls_dialect = ptr->x_ix86_tls_dialect;
     875     55329139 :   opts->x_ix86_tune_ctrl_string = ptr->x_ix86_tune_ctrl_string;
     876     55329139 :   opts->x_ix86_tune_memcpy_strategy = ptr->x_ix86_tune_memcpy_strategy;
     877     55329139 :   opts->x_ix86_tune_memset_strategy = ptr->x_ix86_tune_memset_strategy;
     878     55329139 :   opts->x_ix86_tune_no_default = ptr->x_ix86_tune_no_default;
     879     55329139 :   ix86_tune_cost = processor_cost_table[ix86_tune];
     880              :   /* TODO: ix86_cost should be chosen at instruction or function granularity
     881              :      so for cold code we use size_cost even in !optimize_size compilation.  */
     882     55329139 :   if (opts->x_optimize_size)
     883              :     ix86_cost = &ix86_size_cost;
     884              :   else
     885     54600715 :     ix86_cost = ix86_tune_cost;
     886              : 
     887              :   /* Recreate the arch feature tests if the arch changed */
     888     55329139 :   if (old_arch != ix86_arch)
     889              :     {
     890        34710 :       ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
     891       208260 :       for (i = 0; i < X86_ARCH_LAST; ++i)
     892       173550 :         ix86_arch_features[i]
     893       173550 :           = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
     894              :     }
     895              : 
     896              :   /* Recreate the tune optimization tests */
     897     55329139 :   if (old_tune != ix86_tune)
     898        34957 :     set_ix86_tune_features (opts, ix86_tune, false);
     899     55329139 : }
     900              : 
     901              : /* Adjust target options after streaming them in.  This is mainly about
     902              :    reconciling them with global options.  */
     903              : 
     904              : void
     905        23535 : ix86_function_specific_post_stream_in (struct cl_target_option *ptr)
     906              : {
     907              :   /* flag_pic is a global option, but ix86_cmodel is target saved option
     908              :      partly computed from flag_pic.  If flag_pic is on, adjust x_ix86_cmodel
     909              :      for PIC, or error out.  */
     910        23535 :   if (flag_pic)
     911          352 :     switch (ptr->x_ix86_cmodel)
     912              :       {
     913           93 :       case CM_SMALL:
     914           93 :         ptr->x_ix86_cmodel = CM_SMALL_PIC;
     915           93 :         break;
     916              : 
     917            0 :       case CM_MEDIUM:
     918            0 :         ptr->x_ix86_cmodel = CM_MEDIUM_PIC;
     919            0 :         break;
     920              : 
     921            0 :       case CM_LARGE:
     922            0 :         ptr->x_ix86_cmodel = CM_LARGE_PIC;
     923            0 :         break;
     924              : 
     925            0 :       case CM_KERNEL:
     926            0 :         error ("code model %s does not support PIC mode", "kernel");
     927            0 :         break;
     928              : 
     929              :       default:
     930              :         break;
     931              :       }
     932              :   else
     933        23183 :     switch (ptr->x_ix86_cmodel)
     934              :       {
     935          102 :       case CM_SMALL_PIC:
     936          102 :         ptr->x_ix86_cmodel = CM_SMALL;
     937          102 :         break;
     938              : 
     939            0 :       case CM_MEDIUM_PIC:
     940            0 :         ptr->x_ix86_cmodel = CM_MEDIUM;
     941            0 :         break;
     942              : 
     943            0 :       case CM_LARGE_PIC:
     944            0 :         ptr->x_ix86_cmodel = CM_LARGE;
     945            0 :         break;
     946              : 
     947              :       default:
     948              :         break;
     949              :       }
     950        23535 : }
     951              : 
     952              : /* Print the current options */
     953              : 
     954              : void
     955            0 : ix86_function_specific_print (FILE *file, int indent,
     956              :                               struct cl_target_option *ptr)
     957              : {
     958            0 :   char *target_string
     959            0 :     = ix86_target_string (ptr->x_ix86_isa_flags, ptr->x_ix86_isa_flags2,
     960              :                           ptr->x_target_flags, ptr->x_ix86_target_flags,
     961              :                           NULL, NULL, ptr->x_ix86_fpmath,
     962              :                           ptr->x_prefer_vector_width_type,
     963              :                           ptr->x_ix86_move_max, false, true);
     964              : 
     965            0 :   gcc_assert (ptr->arch < PROCESSOR_max);
     966            0 :   fprintf (file, "%*sarch = %d (%s)\n",
     967              :            indent, "",
     968            0 :            ptr->arch, processor_names[ptr->arch]);
     969              : 
     970            0 :   gcc_assert (ptr->tune < PROCESSOR_max);
     971            0 :   fprintf (file, "%*stune = %d (%s)\n",
     972              :            indent, "",
     973            0 :            ptr->tune, processor_names[ptr->tune]);
     974              : 
     975            0 :   fprintf (file, "%*sbranch_cost = %d\n", indent, "", ptr->branch_cost);
     976              : 
     977            0 :   if (target_string)
     978              :     {
     979            0 :       fprintf (file, "%*s%s\n", indent, "", target_string);
     980            0 :       free (target_string);
     981              :     }
     982            0 : }
     983              : 
     984              : 
     985              : /* Inner function to process the attribute((target(...))), take an argument and
     986              :    set the current options from the argument. If we have a list, recursively go
     987              :    over the list.  */
     988              : 
     989              : static bool
     990    103098503 : ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
     991              :                                      struct gcc_options *opts,
     992              :                                      struct gcc_options *opts_set,
     993              :                                      struct gcc_options *enum_opts_set,
     994              :                                      bool target_clone_attr)
     995              : {
     996    103098503 :   char *next_optstr;
     997    103098503 :   bool ret = true;
     998              : 
     999              : #define IX86_ATTR_ISA(S,O)   { S, sizeof (S)-1, ix86_opt_isa, O, 0 }
    1000              : #define IX86_ATTR_STR(S,O)   { S, sizeof (S)-1, ix86_opt_str, O, 0 }
    1001              : #define IX86_ATTR_ENUM(S,O)  { S, sizeof (S)-1, ix86_opt_enum, O, 0 }
    1002              : #define IX86_ATTR_YES(S,O,M) { S, sizeof (S)-1, ix86_opt_yes, O, M }
    1003              : #define IX86_ATTR_NO(S,O,M)  { S, sizeof (S)-1, ix86_opt_no,  O, M }
    1004              : #define IX86_ATTR_IX86_YES(S,O,M) \
    1005              :   { S, sizeof (S)-1, ix86_opt_ix86_yes, O, M }
    1006              : #define IX86_ATTR_IX86_NO(S,O,M) \
    1007              :   { S, sizeof (S)-1, ix86_opt_ix86_no,  O, M }
    1008              : 
    1009    103098503 :   enum ix86_opt_type
    1010              :   {
    1011              :     ix86_opt_unknown,
    1012              :     ix86_opt_yes,
    1013              :     ix86_opt_no,
    1014              :     ix86_opt_ix86_yes,
    1015              :     ix86_opt_ix86_no,
    1016              :     ix86_opt_str,
    1017              :     ix86_opt_enum,
    1018              :     ix86_opt_isa
    1019              :   };
    1020              : 
    1021    103098503 :   static const struct
    1022              :   {
    1023              :     const char *string;
    1024              :     size_t len;
    1025              :     enum ix86_opt_type type;
    1026              :     int opt;
    1027              :     int mask;
    1028              :   } attrs[] = {
    1029              :     /* isa options */
    1030              :     IX86_ATTR_ISA ("pconfig", OPT_mpconfig),
    1031              :     IX86_ATTR_ISA ("wbnoinvd",        OPT_mwbnoinvd),
    1032              :     IX86_ATTR_ISA ("sgx",     OPT_msgx),
    1033              :     IX86_ATTR_ISA ("avx512vpopcntdq", OPT_mavx512vpopcntdq),
    1034              :     IX86_ATTR_ISA ("avx512vbmi2", OPT_mavx512vbmi2),
    1035              :     IX86_ATTR_ISA ("avx512vnni", OPT_mavx512vnni),
    1036              :     IX86_ATTR_ISA ("avx512bitalg", OPT_mavx512bitalg),
    1037              :     IX86_ATTR_ISA ("avx512vp2intersect", OPT_mavx512vp2intersect),
    1038              : 
    1039              :     IX86_ATTR_ISA ("avx512vbmi", OPT_mavx512vbmi),
    1040              :     IX86_ATTR_ISA ("avx512ifma", OPT_mavx512ifma),
    1041              :     IX86_ATTR_ISA ("avx512vl",        OPT_mavx512vl),
    1042              :     IX86_ATTR_ISA ("avx512bw",        OPT_mavx512bw),
    1043              :     IX86_ATTR_ISA ("avx512dq",        OPT_mavx512dq),
    1044              :     IX86_ATTR_ISA ("avx512cd",        OPT_mavx512cd),
    1045              :     IX86_ATTR_ISA ("avx512f", OPT_mavx512f),
    1046              :     IX86_ATTR_ISA ("avx2",    OPT_mavx2),
    1047              :     IX86_ATTR_ISA ("fma",     OPT_mfma),
    1048              :     IX86_ATTR_ISA ("xop",     OPT_mxop),
    1049              :     IX86_ATTR_ISA ("fma4",    OPT_mfma4),
    1050              :     IX86_ATTR_ISA ("f16c",    OPT_mf16c),
    1051              :     IX86_ATTR_ISA ("avx",     OPT_mavx),
    1052              :     IX86_ATTR_ISA ("sse4",    OPT_msse4),
    1053              :     IX86_ATTR_ISA ("sse4.2",  OPT_msse4_2),
    1054              :     IX86_ATTR_ISA ("sse4.1",  OPT_msse4_1),
    1055              :     IX86_ATTR_ISA ("sse4a",   OPT_msse4a),
    1056              :     IX86_ATTR_ISA ("ssse3",   OPT_mssse3),
    1057              :     IX86_ATTR_ISA ("sse3",    OPT_msse3),
    1058              :     IX86_ATTR_ISA ("aes",     OPT_maes),
    1059              :     IX86_ATTR_ISA ("sha",     OPT_msha),
    1060              :     IX86_ATTR_ISA ("pclmul",  OPT_mpclmul),
    1061              :     IX86_ATTR_ISA ("sse2",    OPT_msse2),
    1062              :     IX86_ATTR_ISA ("sse",     OPT_msse),
    1063              :     IX86_ATTR_ISA ("3dnowa",  OPT_m3dnowa),
    1064              :     IX86_ATTR_ISA ("3dnow",   OPT_m3dnow),
    1065              :     IX86_ATTR_ISA ("mmx",     OPT_mmmx),
    1066              :     IX86_ATTR_ISA ("rtm",     OPT_mrtm),
    1067              :     IX86_ATTR_ISA ("prfchw",  OPT_mprfchw),
    1068              :     IX86_ATTR_ISA ("rdseed",  OPT_mrdseed),
    1069              :     IX86_ATTR_ISA ("adx",     OPT_madx),
    1070              :     IX86_ATTR_ISA ("clflushopt", OPT_mclflushopt),
    1071              :     IX86_ATTR_ISA ("xsaves",  OPT_mxsaves),
    1072              :     IX86_ATTR_ISA ("xsavec",  OPT_mxsavec),
    1073              :     IX86_ATTR_ISA ("xsaveopt",        OPT_mxsaveopt),
    1074              :     IX86_ATTR_ISA ("xsave",   OPT_mxsave),
    1075              :     IX86_ATTR_ISA ("abm",     OPT_mabm),
    1076              :     IX86_ATTR_ISA ("bmi",     OPT_mbmi),
    1077              :     IX86_ATTR_ISA ("bmi2",    OPT_mbmi2),
    1078              :     IX86_ATTR_ISA ("lzcnt",   OPT_mlzcnt),
    1079              :     IX86_ATTR_ISA ("tbm",     OPT_mtbm),
    1080              :     IX86_ATTR_ISA ("popcnt",  OPT_mpopcnt),
    1081              :     IX86_ATTR_ISA ("cx16",    OPT_mcx16),
    1082              :     IX86_ATTR_ISA ("sahf",    OPT_msahf),
    1083              :     IX86_ATTR_ISA ("movbe",   OPT_mmovbe),
    1084              :     IX86_ATTR_ISA ("crc32",   OPT_mcrc32),
    1085              :     IX86_ATTR_ISA ("fsgsbase",        OPT_mfsgsbase),
    1086              :     IX86_ATTR_ISA ("rdrnd",   OPT_mrdrnd),
    1087              :     IX86_ATTR_ISA ("mwaitx",  OPT_mmwaitx),
    1088              :     IX86_ATTR_ISA ("mwait",   OPT_mmwait),
    1089              :     IX86_ATTR_ISA ("clzero",  OPT_mclzero),
    1090              :     IX86_ATTR_ISA ("pku",     OPT_mpku),
    1091              :     IX86_ATTR_ISA ("lwp",     OPT_mlwp),
    1092              :     IX86_ATTR_ISA ("hle",     OPT_mhle),
    1093              :     IX86_ATTR_ISA ("fxsr",    OPT_mfxsr),
    1094              :     IX86_ATTR_ISA ("clwb",    OPT_mclwb),
    1095              :     IX86_ATTR_ISA ("rdpid",   OPT_mrdpid),
    1096              :     IX86_ATTR_ISA ("gfni",    OPT_mgfni),
    1097              :     IX86_ATTR_ISA ("shstk",   OPT_mshstk),
    1098              :     IX86_ATTR_ISA ("vaes",    OPT_mvaes),
    1099              :     IX86_ATTR_ISA ("vpclmulqdq", OPT_mvpclmulqdq),
    1100              :     IX86_ATTR_ISA ("movdiri", OPT_mmovdiri),
    1101              :     IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b),
    1102              :     IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg),
    1103              :     IX86_ATTR_ISA ("cldemote", OPT_mcldemote),
    1104              :     IX86_ATTR_ISA ("uintr", OPT_muintr),
    1105              :     IX86_ATTR_ISA ("ptwrite",   OPT_mptwrite),
    1106              :     IX86_ATTR_ISA ("kl", OPT_mkl),
    1107              :     IX86_ATTR_ISA ("widekl",  OPT_mwidekl),
    1108              :     IX86_ATTR_ISA ("avx512bf16",   OPT_mavx512bf16),
    1109              :     IX86_ATTR_ISA ("enqcmd", OPT_menqcmd),
    1110              :     IX86_ATTR_ISA ("serialize", OPT_mserialize),
    1111              :     IX86_ATTR_ISA ("tsxldtrk", OPT_mtsxldtrk),
    1112              :     IX86_ATTR_ISA ("amx-tile", OPT_mamx_tile),
    1113              :     IX86_ATTR_ISA ("amx-int8", OPT_mamx_int8),
    1114              :     IX86_ATTR_ISA ("amx-bf16", OPT_mamx_bf16),
    1115              :     IX86_ATTR_ISA ("hreset", OPT_mhreset),
    1116              :     IX86_ATTR_ISA ("avxvnni",   OPT_mavxvnni),
    1117              :     IX86_ATTR_ISA ("avx512fp16", OPT_mavx512fp16),
    1118              :     IX86_ATTR_ISA ("avxifma", OPT_mavxifma),
    1119              :     IX86_ATTR_ISA ("avxvnniint8", OPT_mavxvnniint8),
    1120              :     IX86_ATTR_ISA ("avxneconvert", OPT_mavxneconvert),
    1121              :     IX86_ATTR_ISA ("cmpccxadd",   OPT_mcmpccxadd),
    1122              :     IX86_ATTR_ISA ("amx-fp16", OPT_mamx_fp16),
    1123              :     IX86_ATTR_ISA ("prefetchi",   OPT_mprefetchi),
    1124              :     IX86_ATTR_ISA ("raoint", OPT_mraoint),
    1125              :     IX86_ATTR_ISA ("amx-complex", OPT_mamx_complex),
    1126              :     IX86_ATTR_ISA ("avxvnniint16", OPT_mavxvnniint16),
    1127              :     IX86_ATTR_ISA ("sm3", OPT_msm3),
    1128              :     IX86_ATTR_ISA ("sha512", OPT_msha512),
    1129              :     IX86_ATTR_ISA ("sm4", OPT_msm4),
    1130              :     IX86_ATTR_ISA ("apxf", OPT_mapxf),
    1131              :     IX86_ATTR_ISA ("usermsr", OPT_musermsr),
    1132              :     IX86_ATTR_ISA ("avx10.1", OPT_mavx10_1),
    1133              :     IX86_ATTR_ISA ("avx10.2", OPT_mavx10_2),
    1134              :     IX86_ATTR_ISA ("amx-avx512", OPT_mamx_avx512),
    1135              :     IX86_ATTR_ISA ("amx-fp8", OPT_mamx_fp8),
    1136              :     IX86_ATTR_ISA ("movrs", OPT_mmovrs),
    1137              :     IX86_ATTR_ISA ("amx-movrs", OPT_mamx_movrs),
    1138              :     IX86_ATTR_ISA ("avx512bmm", OPT_mavx512bmm),
    1139              :     IX86_ATTR_ISA ("avx10v2aux", OPT_mavx10v2aux),
    1140              :     IX86_ATTR_ISA ("acev1", OPT_macev1),
    1141              :     IX86_ATTR_ISA ("avx10v1aux", OPT_mavx10v1aux),
    1142              : 
    1143              :     /* enum options */
    1144              :     IX86_ATTR_ENUM ("fpmath=",        OPT_mfpmath_),
    1145              :     IX86_ATTR_ENUM ("prefer-vector-width=", OPT_mprefer_vector_width_),
    1146              : 
    1147              :     /* string options */
    1148              :     IX86_ATTR_STR ("arch=",   IX86_FUNCTION_SPECIFIC_ARCH),
    1149              :     IX86_ATTR_STR ("tune=",   IX86_FUNCTION_SPECIFIC_TUNE),
    1150              : 
    1151              :     /* flag options */
    1152              :     IX86_ATTR_YES ("cld",
    1153              :                    OPT_mcld,
    1154              :                    MASK_CLD),
    1155              : 
    1156              :     IX86_ATTR_NO ("fancy-math-387",
    1157              :                   OPT_mfancy_math_387,
    1158              :                   MASK_NO_FANCY_MATH_387),
    1159              : 
    1160              :     IX86_ATTR_YES ("ieee-fp",
    1161              :                    OPT_mieee_fp,
    1162              :                    MASK_IEEE_FP),
    1163              : 
    1164              :     IX86_ATTR_YES ("inline-all-stringops",
    1165              :                    OPT_minline_all_stringops,
    1166              :                    MASK_INLINE_ALL_STRINGOPS),
    1167              : 
    1168              :     IX86_ATTR_YES ("inline-stringops-dynamically",
    1169              :                    OPT_minline_stringops_dynamically,
    1170              :                    MASK_INLINE_STRINGOPS_DYNAMICALLY),
    1171              : 
    1172              :     IX86_ATTR_NO ("align-stringops",
    1173              :                   OPT_mno_align_stringops,
    1174              :                   MASK_NO_ALIGN_STRINGOPS),
    1175              : 
    1176              :     IX86_ATTR_YES ("recip",
    1177              :                    OPT_mrecip,
    1178              :                    MASK_RECIP),
    1179              : 
    1180              :     IX86_ATTR_YES ("80387",
    1181              :                    OPT_m80387,
    1182              :                    MASK_80387),
    1183              : 
    1184              :     IX86_ATTR_IX86_YES ("general-regs-only",
    1185              :                         OPT_mgeneral_regs_only,
    1186              :                         OPTION_MASK_GENERAL_REGS_ONLY),
    1187              : 
    1188              :     IX86_ATTR_YES ("relax-cmpxchg-loop",
    1189              :                    OPT_mrelax_cmpxchg_loop,
    1190              :                    MASK_RELAX_CMPXCHG_LOOP),
    1191              :   };
    1192              : 
    1193    103098503 :   location_t loc
    1194    103098503 :     = fndecl == NULL ? UNKNOWN_LOCATION : DECL_SOURCE_LOCATION (fndecl);
    1195    103098503 :   const char *attr_name = target_clone_attr ? "target_clone" : "target";
    1196              : 
    1197              :   /* If this is a list, recurse to get the options.  */
    1198    103098503 :   if (TREE_CODE (args) == TREE_LIST)
    1199              :     {
    1200    103093504 :       for (; args; args = TREE_CHAIN (args))
    1201     52351336 :         if (TREE_VALUE (args)
    1202     52351336 :             && !ix86_valid_target_attribute_inner_p (fndecl, TREE_VALUE (args),
    1203              :                                                      p_strings, opts, opts_set,
    1204              :                                                      enum_opts_set,
    1205              :                                                      target_clone_attr))
    1206              :           ret = false;
    1207              : 
    1208              :       return ret;
    1209              :     }
    1210              : 
    1211     52356335 :   else if (TREE_CODE (args) != STRING_CST)
    1212              :     {
    1213            9 :       error_at (loc, "attribute %qs argument is not a string", attr_name);
    1214            9 :       return false;
    1215              :     }
    1216              : 
    1217              :   /* Handle multiple arguments separated by commas.  */
    1218     52356326 :   next_optstr = ASTRDUP (TREE_STRING_POINTER (args));
    1219              : 
    1220    121516987 :   while (next_optstr && *next_optstr != '\0')
    1221              :     {
    1222     69160663 :       char *p = next_optstr;
    1223     69160663 :       char *orig_p = p;
    1224     69160663 :       char *comma = strchr (next_optstr, ',');
    1225     69160663 :       size_t len, opt_len;
    1226     69160663 :       int opt;
    1227     69160663 :       bool opt_set_p;
    1228     69160663 :       char ch;
    1229     69160663 :       unsigned i;
    1230     69160663 :       enum ix86_opt_type type = ix86_opt_unknown;
    1231     69160663 :       int mask = 0;
    1232              : 
    1233     69160663 :       if (comma)
    1234              :         {
    1235     16804339 :           *comma = '\0';
    1236     16804339 :           len = comma - next_optstr;
    1237     16804339 :           next_optstr = comma + 1;
    1238              :         }
    1239              :       else
    1240              :         {
    1241     52356324 :           len = strlen (p);
    1242     52356324 :           next_optstr = NULL;
    1243              :         }
    1244              : 
    1245              :       /* Recognize no-xxx.  */
    1246     69160663 :       if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-')
    1247              :         {
    1248         1600 :           opt_set_p = false;
    1249         1600 :           p += 3;
    1250         1600 :           len -= 3;
    1251              :         }
    1252              :       else
    1253              :         opt_set_p = true;
    1254              : 
    1255              :       /* Find the option.  */
    1256     69160663 :       ch = *p;
    1257     69160663 :       opt = N_OPTS;
    1258   3028673609 :       for (i = 0; i < ARRAY_SIZE (attrs); i++)
    1259              :         {
    1260   3028673493 :           type = attrs[i].type;
    1261   3028673493 :           opt_len = attrs[i].len;
    1262   3028673493 :           if (ch == attrs[i].string[0]
    1263    961597567 :               && ((type != ix86_opt_str && type != ix86_opt_enum)
    1264    961597567 :                   ? len == opt_len
    1265              :                   : len > opt_len)
    1266    174565361 :               && memcmp (p, attrs[i].string, opt_len) == 0)
    1267              :             {
    1268     69160547 :               opt = attrs[i].opt;
    1269     69160547 :               mask = attrs[i].mask;
    1270     69160547 :               break;
    1271              :             }
    1272              :         }
    1273              : 
    1274              :       /* Process the option.  */
    1275     69160663 :       if (opt == N_OPTS)
    1276              :         {
    1277          116 :           error_at (loc, "attribute %qs argument %qs is unknown",
    1278              :                     attr_name, orig_p);
    1279          116 :           ret = false;
    1280              :         }
    1281              : 
    1282     69160547 :       else if (type == ix86_opt_isa)
    1283              :         {
    1284     67146649 :           struct cl_decoded_option decoded;
    1285              : 
    1286     67146649 :           generate_option (opt, NULL, opt_set_p, CL_TARGET, &decoded);
    1287     67146649 :           ix86_handle_option (opts, opts_set,
    1288              :                               &decoded, input_location);
    1289              :         }
    1290              : 
    1291              :       else if (type == ix86_opt_yes || type == ix86_opt_no)
    1292              :         {
    1293           53 :           opts_set->x_target_flags |= mask;
    1294              : 
    1295           53 :           if (type == ix86_opt_no)
    1296           12 :             opt_set_p = !opt_set_p;
    1297              : 
    1298           53 :           if (opt_set_p)
    1299           44 :             opts->x_target_flags |= mask;
    1300              :           else
    1301            9 :             opts->x_target_flags &= ~mask;
    1302              :         }
    1303              : 
    1304              :       else if (type == ix86_opt_ix86_yes || type == ix86_opt_ix86_no)
    1305              :         {
    1306      1992758 :           if (mask == OPTION_MASK_GENERAL_REGS_ONLY)
    1307              :             {
    1308      1992758 :               if (!opt_set_p)
    1309              :                 {
    1310            2 :                   error_at (loc, "pragma or attribute %<target(\"%s\")%> "
    1311              :                             "does not allow a negated form", p);
    1312            2 :                   return false;
    1313              :                 }
    1314              : 
    1315      1992756 :               if (type != ix86_opt_ix86_yes)
    1316            0 :                 gcc_unreachable ();
    1317              : 
    1318      1992756 :               opts->x_ix86_target_flags |= mask;
    1319              : 
    1320      1992756 :               struct cl_decoded_option decoded;
    1321      1992756 :               generate_option (opt, NULL, opt_set_p, CL_TARGET,
    1322              :                                &decoded);
    1323      1992756 :               ix86_handle_option (opts, opts_set, &decoded,
    1324              :                                   input_location);
    1325              :             }
    1326              :           else
    1327              :             {
    1328            0 :               if (type == ix86_opt_ix86_no)
    1329            0 :                 opt_set_p = !opt_set_p;
    1330              : 
    1331            0 :               if (opt_set_p)
    1332            0 :                 opts->x_ix86_target_flags |= mask;
    1333              :               else
    1334            0 :                 opts->x_ix86_target_flags &= ~mask;
    1335              :             }
    1336              :         }
    1337              : 
    1338              :       else if (type == ix86_opt_str)
    1339              :         {
    1340        20900 :           if (p_strings[opt])
    1341              :             {
    1342            1 :               error_at (loc, "attribute value %qs was already specified "
    1343              :                         "in %qs attribute", orig_p, attr_name);
    1344            1 :               ret = false;
    1345              :             }
    1346              :           else
    1347              :             {
    1348        20899 :               p_strings[opt] = xstrdup (p + opt_len);
    1349        20899 :               if (opt == IX86_FUNCTION_SPECIFIC_ARCH)
    1350              :                 {
    1351              :                   /* If arch= is set,  clear all bits in x_ix86_isa_flags,
    1352              :                      except for ISA_64BIT, ABI_64, ABI_X32, and CODE16
    1353              :                      and all bits in x_ix86_isa_flags2.  */
    1354        20865 :                   opts->x_ix86_isa_flags &= (OPTION_MASK_ISA_64BIT
    1355              :                                              | OPTION_MASK_ABI_64
    1356              :                                              | OPTION_MASK_ABI_X32
    1357              :                                              | OPTION_MASK_CODE16);
    1358        20865 :                   opts->x_ix86_isa_flags_explicit &= (OPTION_MASK_ISA_64BIT
    1359              :                                                       | OPTION_MASK_ABI_64
    1360              :                                                       | OPTION_MASK_ABI_X32
    1361              :                                                       | OPTION_MASK_CODE16);
    1362        20865 :                   opts->x_ix86_isa_flags2 = 0;
    1363        20865 :                   opts->x_ix86_isa_flags2_explicit = 0;
    1364              :                 }
    1365              :             }
    1366              :         }
    1367              : 
    1368              :       else if (type == ix86_opt_enum)
    1369              :         {
    1370          187 :           bool arg_ok;
    1371          187 :           int value;
    1372              : 
    1373          187 :           arg_ok = opt_enum_arg_to_value (opt, p + opt_len, &value, CL_TARGET);
    1374          187 :           if (arg_ok)
    1375          187 :             set_option (opts, enum_opts_set, opt, value,
    1376              :                         p + opt_len,
    1377              :                         static_cast<int> (diagnostics::kind::unspecified),
    1378              :                         input_location,
    1379              :                         global_dc);
    1380              :           else
    1381              :             {
    1382            0 :               error_at (loc, "attribute value %qs is unknown in %qs attribute",
    1383              :                         orig_p, attr_name);
    1384            0 :               ret = false;
    1385              :             }
    1386              :         }
    1387              : 
    1388              :       else
    1389            0 :         gcc_unreachable ();
    1390              :     }
    1391              : 
    1392              :   return ret;
    1393              : }
    1394              : 
    1395              : /* Release allocated strings.  */
    1396              : static void
    1397     50746529 : release_options_strings (char **option_strings)
    1398              : {
    1399              :   /* Free up memory allocated to hold the strings */
    1400    152239587 :   for (unsigned i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
    1401    101493058 :     free (option_strings[i]);
    1402     50746529 : }
    1403              : 
    1404              : /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL.  */
    1405              : 
    1406              : tree
    1407     50747167 : ix86_valid_target_attribute_tree (tree fndecl, tree args,
    1408              :                                   struct gcc_options *opts,
    1409              :                                   struct gcc_options *opts_set,
    1410              :                                   bool target_clone_attr)
    1411              : {
    1412     50747167 :   const char *orig_arch_string = opts->x_ix86_arch_string;
    1413     50747167 :   const char *orig_tune_string = opts->x_ix86_tune_string;
    1414     50747167 :   enum fpmath_unit orig_fpmath_set = opts_set->x_ix86_fpmath;
    1415     50747167 :   enum prefer_vector_width orig_pvw_set = opts_set->x_prefer_vector_width_type;
    1416     50747167 :   enum prefer_vector_width orig_ix86_move_max_set
    1417              :     = opts_set->x_ix86_move_max;
    1418     50747167 :   int orig_tune_defaulted = ix86_tune_defaulted;
    1419     50747167 :   int orig_arch_specified = ix86_arch_specified;
    1420     50747167 :   char *option_strings[IX86_FUNCTION_SPECIFIC_MAX] = { NULL, NULL };
    1421     50747167 :   tree t = NULL_TREE;
    1422     50747167 :   struct cl_target_option *def
    1423     50747167 :     = TREE_TARGET_OPTION (target_option_default_node);
    1424     50747167 :   struct gcc_options enum_opts_set;
    1425              : 
    1426     50747167 :   memset (&enum_opts_set, 0, sizeof (enum_opts_set));
    1427              : 
    1428              :   /* Process each of the options on the chain.  */
    1429     50747167 :   if (!ix86_valid_target_attribute_inner_p (fndecl, args, option_strings, opts,
    1430              :                                             opts_set, &enum_opts_set,
    1431              :                                             target_clone_attr))
    1432          125 :     return error_mark_node;
    1433              : 
    1434              :   /* If the changed options are different from the default, rerun
    1435              :      ix86_option_override_internal, and then save the options away.
    1436              :      The string options are attribute options, and will be undone
    1437              :      when we copy the save structure.  */
    1438     50747042 :   if (opts->x_ix86_isa_flags != def->x_ix86_isa_flags
    1439      1972778 :       || opts->x_ix86_isa_flags2 != def->x_ix86_isa_flags2
    1440         1887 :       || opts->x_target_flags != def->x_target_flags
    1441          729 :       || option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
    1442          729 :       || option_strings[IX86_FUNCTION_SPECIFIC_TUNE]
    1443          695 :       || enum_opts_set.x_ix86_fpmath
    1444          526 :       || enum_opts_set.x_prefer_vector_width_type)
    1445              :     {
    1446              :       /* If we are using the default tune= or arch=, undo the string assigned,
    1447              :          and use the default.  */
    1448     50746529 :       if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH])
    1449        20864 :         opts->x_ix86_arch_string
    1450        20864 :           = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_ARCH]);
    1451     50725665 :       else if (!orig_arch_specified)
    1452            0 :         opts->x_ix86_arch_string = NULL;
    1453              : 
    1454     50746529 :       if (option_strings[IX86_FUNCTION_SPECIFIC_TUNE])
    1455           34 :         opts->x_ix86_tune_string
    1456           34 :           = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_TUNE]);
    1457              :       /* If we have explicit arch string and no tune string specified, set
    1458              :          tune_string to NULL and later it will be overridden by arch_string
    1459              :          so target clones can get proper optimization.  */
    1460     50746495 :       else if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
    1461     50725631 :                || orig_tune_defaulted)
    1462        20864 :         opts->x_ix86_tune_string = NULL;
    1463              : 
    1464              :       /* If fpmath= is not set, and we now have sse2 on 32-bit, use it.  */
    1465     50746529 :       if (enum_opts_set.x_ix86_fpmath)
    1466          169 :         opts_set->x_ix86_fpmath = (enum fpmath_unit) 1;
    1467     50746529 :       if (enum_opts_set.x_prefer_vector_width_type)
    1468           17 :         opts_set->x_prefer_vector_width_type = (enum prefer_vector_width) 1;
    1469              : 
    1470              :       /* Do any overrides, such as arch=xxx, or tune=xxx support.  */
    1471     50746529 :       bool r = ix86_option_override_internal (false, opts, opts_set);
    1472     50746529 :       if (!r)
    1473              :         {
    1474            3 :           release_options_strings (option_strings);
    1475            3 :           return error_mark_node;
    1476              :         }
    1477              : 
    1478              :       /* Add any builtin functions with the new isa if any.  */
    1479     50746526 :       ix86_add_new_builtins (opts->x_ix86_isa_flags, opts->x_ix86_isa_flags2);
    1480              : 
    1481     50746526 :       enum excess_precision orig_ix86_excess_precision
    1482              :         = opts->x_ix86_excess_precision;
    1483     50746526 :       bool orig_ix86_unsafe_math_optimizations
    1484              :         = opts->x_ix86_unsafe_math_optimizations;
    1485     50746526 :       opts->x_ix86_excess_precision = opts->x_flag_excess_precision;
    1486     50746526 :       opts->x_ix86_unsafe_math_optimizations
    1487     50746526 :         = opts->x_flag_unsafe_math_optimizations;
    1488              : 
    1489              :       /* Save the current options unless we are validating options for
    1490              :          #pragma.  */
    1491     50746526 :       t = build_target_option_node (opts, opts_set);
    1492              : 
    1493     50746526 :       opts->x_ix86_arch_string = orig_arch_string;
    1494     50746526 :       opts->x_ix86_tune_string = orig_tune_string;
    1495     50746526 :       opts_set->x_ix86_fpmath = orig_fpmath_set;
    1496     50746526 :       opts_set->x_prefer_vector_width_type = orig_pvw_set;
    1497     50746526 :       opts_set->x_ix86_move_max = orig_ix86_move_max_set;
    1498     50746526 :       opts->x_ix86_excess_precision = orig_ix86_excess_precision;
    1499     50746526 :       opts->x_ix86_unsafe_math_optimizations
    1500     50746526 :         = orig_ix86_unsafe_math_optimizations;
    1501              : 
    1502     50746526 :       release_options_strings (option_strings);
    1503              :     }
    1504              : 
    1505              :   return t;
    1506              : }
    1507              : 
    1508              : static GTY(()) tree target_attribute_cache[3];
    1509              : 
    1510              : /* Hook to validate attribute((target("string"))).  */
    1511              : 
    1512              : bool
    1513     50168036 : ix86_valid_target_attribute_p (tree fndecl,
    1514              :                                tree ARG_UNUSED (name),
    1515              :                                tree args,
    1516              :                                int flags)
    1517              : {
    1518     50168036 :   struct gcc_options func_options, func_options_set;
    1519     50168036 :   tree new_target, new_optimize;
    1520     50168036 :   bool ret = true;
    1521              : 
    1522              :   /* attribute((target("default"))) does nothing, beyond
    1523              :      affecting multi-versioning.  */
    1524     50168036 :   if (TREE_VALUE (args)
    1525     50168036 :       && TREE_CODE (TREE_VALUE (args)) == STRING_CST
    1526     50168030 :       && TREE_CHAIN (args) == NULL_TREE
    1527     98769485 :       && strcmp (TREE_STRING_POINTER (TREE_VALUE (args)), "default") == 0)
    1528              :     return true;
    1529              : 
    1530     50167823 :   if ((DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == target_attribute_cache[1]
    1531     50165446 :        || DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == NULL_TREE)
    1532         6604 :       && (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
    1533         6604 :           == target_attribute_cache[2]
    1534          454 :           || DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) == NULL_TREE)
    1535     50174393 :       && simple_cst_list_equal (args, target_attribute_cache[0]))
    1536              :     {
    1537         1331 :       DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = target_attribute_cache[1];
    1538         1331 :       DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
    1539         1331 :         = target_attribute_cache[2];
    1540         1331 :       return true;
    1541              :     }
    1542              : 
    1543     50166492 :   tree old_optimize = build_optimization_node (&global_options,
    1544              :                                                &global_options_set);
    1545              : 
    1546              :   /* Get the optimization options of the current function.  */
    1547     50166492 :   tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
    1548              : 
    1549     50166492 :   if (!func_optimize)
    1550         5239 :     func_optimize = old_optimize;
    1551              : 
    1552              :   /* Init func_options.  */
    1553     50166492 :   memset (&func_options, 0, sizeof (func_options));
    1554     50166492 :   init_options_struct (&func_options, NULL);
    1555     50166492 :   lang_hooks.init_options_struct (&func_options);
    1556     50166492 :   memset (&func_options_set, 0, sizeof (func_options_set));
    1557              : 
    1558     50166492 :   cl_optimization_restore (&func_options, &func_options_set,
    1559     50166492 :                            TREE_OPTIMIZATION (func_optimize));
    1560              : 
    1561              :   /* Initialize func_options to the default before its target options can
    1562              :      be set.  */
    1563     50166492 :   tree old_target = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
    1564     50166492 :   if (old_target == NULL_TREE)
    1565         5268 :     old_target = target_option_default_node;
    1566     50166492 :   cl_target_option_restore (&func_options, &func_options_set,
    1567     50166492 :                             TREE_TARGET_OPTION (old_target));
    1568              : 
    1569              :   /* FLAGS == 1 is used for target_clones attribute.  */
    1570     50166492 :   new_target
    1571     50166492 :     = ix86_valid_target_attribute_tree (fndecl, args, &func_options,
    1572              :                                         &func_options_set, flags == 1);
    1573              : 
    1574     50166492 :   new_optimize = build_optimization_node (&func_options, &func_options_set);
    1575              : 
    1576     50166492 :   if (new_target == error_mark_node)
    1577              :     ret = false;
    1578              : 
    1579     50166368 :   else if (new_target)
    1580              :     {
    1581     50166120 :       if (DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == NULL_TREE
    1582     50166120 :           && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) == NULL_TREE)
    1583              :         {
    1584         4883 :           target_attribute_cache[0] = copy_list (args);
    1585         4883 :           target_attribute_cache[1] = new_target;
    1586         4883 :           target_attribute_cache[2]
    1587         9289 :             = old_optimize != new_optimize ? new_optimize : NULL_TREE;
    1588              :         }
    1589              : 
    1590     50166120 :       DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_target;
    1591              : 
    1592     50166120 :       if (old_optimize != new_optimize)
    1593        15667 :         DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize;
    1594              :     }
    1595              : 
    1596              :   return ret;
    1597              : }
    1598              : 
    1599              : const char *stringop_alg_names[] = {
    1600              : #define DEF_ALG(alg, name) #name,
    1601              : #include "stringop.def"
    1602              : #undef DEF_ALG
    1603              : };
    1604              : 
    1605              : /* Parse parameter string passed to -mmemcpy-strategy= or -mmemset-strategy=.
    1606              :    The string is of the following form (or comma separated list of it):
    1607              : 
    1608              :      strategy_alg:max_size:[align|noalign]
    1609              : 
    1610              :    where the full size range for the strategy is either [0, max_size] or
    1611              :    [min_size, max_size], in which min_size is the max_size + 1 of the
    1612              :    preceding range.  The last size range must have max_size == -1.
    1613              : 
    1614              :    Examples:
    1615              : 
    1616              :     1.
    1617              :        -mmemcpy-strategy=libcall:-1:noalign
    1618              : 
    1619              :       this is equivalent to (for known size memcpy) -mstringop-strategy=libcall
    1620              : 
    1621              : 
    1622              :    2.
    1623              :       -mmemset-strategy=rep_8byte:16:noalign,vector_loop:2048:align,libcall:-1:noalign
    1624              : 
    1625              :       This is to tell the compiler to use the following strategy for memset
    1626              :       1) when the expected size is between [1, 16], use rep_8byte strategy;
    1627              :       2) when the size is between [17, 2048], use vector_loop;
    1628              :       3) when the size is > 2048, use libcall.  */
    1629              : 
    1630              : struct stringop_size_range
    1631              : {
    1632              :   int max;
    1633              :   stringop_alg alg;
    1634              :   bool noalign;
    1635              : };
    1636              : 
    1637              : static void
    1638           52 : ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset)
    1639              : {
    1640           52 :   const struct stringop_algs *default_algs;
    1641           52 :   stringop_size_range input_ranges[MAX_STRINGOP_ALGS];
    1642           52 :   char *curr_range_str, *next_range_str;
    1643           52 :   const char *opt = is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy=";
    1644           52 :   int i = 0, n = 0;
    1645              : 
    1646           52 :   if (is_memset)
    1647           34 :     default_algs = &ix86_cost->memset[TARGET_64BIT != 0];
    1648              :   else
    1649           18 :     default_algs = &ix86_cost->memcpy[TARGET_64BIT != 0];
    1650              : 
    1651           52 :   curr_range_str = strategy_str;
    1652              : 
    1653           94 :   do
    1654              :     {
    1655           94 :       int maxs;
    1656           94 :       char alg_name[128];
    1657           94 :       char align[16];
    1658           94 :       next_range_str = strchr (curr_range_str, ',');
    1659           94 :       if (next_range_str)
    1660           42 :         *next_range_str++ = '\0';
    1661              : 
    1662           94 :       if (sscanf (curr_range_str, "%20[^:]:%d:%10s", alg_name, &maxs,
    1663              :                   align) != 3)
    1664              :         {
    1665            0 :           error ("wrong argument %qs to option %qs", curr_range_str, opt);
    1666            1 :           return;
    1667              :         }
    1668              : 
    1669           94 :       if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1))
    1670              :         {
    1671            0 :           error ("size ranges of option %qs should be increasing", opt);
    1672            0 :           return;
    1673              :         }
    1674              : 
    1675          471 :       for (i = 0; i < last_alg; i++)
    1676          470 :         if (!strcmp (alg_name, stringop_alg_names[i]))
    1677              :           break;
    1678              : 
    1679           93 :       if (i == last_alg)
    1680              :         {
    1681            1 :           error ("wrong strategy name %qs specified for option %qs",
    1682              :                  alg_name, opt);
    1683              : 
    1684            1 :           auto_vec <const char *> candidates;
    1685           10 :           for (i = 0; i < last_alg; i++)
    1686            9 :             if ((stringop_alg) i != rep_prefix_8_byte || TARGET_64BIT)
    1687            9 :               candidates.safe_push (stringop_alg_names[i]);
    1688              : 
    1689            1 :           char *s;
    1690            1 :           const char *hint
    1691            1 :             = candidates_list_and_hint (alg_name, s, candidates);
    1692            1 :           if (hint)
    1693            1 :             inform (input_location,
    1694              :                     "valid arguments to %qs are: %s; did you mean %qs?",
    1695              :                     opt, s, hint);
    1696              :           else
    1697            0 :             inform (input_location, "valid arguments to %qs are: %s",
    1698              :                     opt, s);
    1699            1 :           XDELETEVEC (s);
    1700            1 :           return;
    1701            1 :         }
    1702              : 
    1703           93 :       if ((stringop_alg) i == rep_prefix_8_byte
    1704            3 :           && !TARGET_64BIT)
    1705              :         {
    1706              :           /* rep; movq isn't available in 32-bit code.  */
    1707            0 :           error ("strategy name %qs specified for option %qs "
    1708              :                  "not supported for 32-bit code", alg_name, opt);
    1709            0 :           return;
    1710              :         }
    1711              : 
    1712           93 :       input_ranges[n].max = maxs;
    1713           93 :       input_ranges[n].alg = (stringop_alg) i;
    1714           93 :       if (!strcmp (align, "align"))
    1715           18 :         input_ranges[n].noalign = false;
    1716           75 :       else if (!strcmp (align, "noalign"))
    1717           75 :         input_ranges[n].noalign = true;
    1718              :       else
    1719              :         {
    1720            0 :           error ("unknown alignment %qs specified for option %qs", align, opt);
    1721            0 :           return;
    1722              :         }
    1723           93 :       n++;
    1724           93 :       curr_range_str = next_range_str;
    1725              :     }
    1726           93 :   while (curr_range_str);
    1727              : 
    1728           51 :   if (input_ranges[n - 1].max != -1)
    1729              :     {
    1730            0 :       error ("the max value for the last size range should be -1"
    1731              :              " for option %qs", opt);
    1732            0 :       return;
    1733              :     }
    1734              : 
    1735           51 :   if (n > MAX_STRINGOP_ALGS)
    1736              :     {
    1737            0 :       error ("too many size ranges specified in option %qs", opt);
    1738            0 :       return;
    1739              :     }
    1740              : 
    1741              :   /* Now override the default algs array.  */
    1742          144 :   for (i = 0; i < n; i++)
    1743              :     {
    1744           93 :       *const_cast<int *>(&default_algs->size[i].max) = input_ranges[i].max;
    1745           93 :       *const_cast<stringop_alg *>(&default_algs->size[i].alg)
    1746           93 :           = input_ranges[i].alg;
    1747           93 :       *const_cast<int *>(&default_algs->size[i].noalign)
    1748           93 :           = input_ranges[i].noalign;
    1749              :     }
    1750              : }
    1751              : 
    1752              : 
    1753              : /* parse -mtune-ctrl= option. When DUMP is true,
    1754              :    print the features that are explicitly set.  */
    1755              : 
    1756              : static void
    1757     51084462 : parse_mtune_ctrl_str (struct gcc_options *opts, bool dump)
    1758              : {
    1759     51084462 :   if (!opts->x_ix86_tune_ctrl_string)
    1760              :     return;
    1761              : 
    1762        75138 :   char *next_feature_string = NULL;
    1763        75138 :   char *curr_feature_string = xstrdup (opts->x_ix86_tune_ctrl_string);
    1764        75138 :   char *orig = curr_feature_string;
    1765        75262 :   int i;
    1766        75262 :   do
    1767              :     {
    1768        75262 :       bool clear = false;
    1769              : 
    1770        75262 :       next_feature_string = strchr (curr_feature_string, ',');
    1771        75262 :       if (next_feature_string)
    1772          124 :         *next_feature_string++ = '\0';
    1773        75262 :       if (*curr_feature_string == '^')
    1774              :         {
    1775        14073 :           curr_feature_string++;
    1776        14073 :           clear = true;
    1777              :         }
    1778              : 
    1779        75262 :       if (!strcmp (curr_feature_string, "use_gather"))
    1780              :         {
    1781            4 :           ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = !clear;
    1782            4 :           ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = !clear;
    1783            4 :           ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = !clear;
    1784            4 :           if (dump)
    1785            0 :             fprintf (stderr, "Explicitly %s features use_gather_2parts,"
    1786              :                      " use_gather_4parts, use_gather_8parts\n",
    1787              :                      clear ? "clear" : "set");
    1788              : 
    1789              :         }
    1790        75258 :       else if (!strcmp (curr_feature_string, "use_scatter"))
    1791              :         {
    1792            0 :           ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = !clear;
    1793            0 :           ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = !clear;
    1794            0 :           ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = !clear;
    1795            0 :           if (dump)
    1796            0 :             fprintf (stderr, "Explicitly %s features use_scatter_2parts,"
    1797              :                      " use_scatter_4parts, use_scatter_8parts\n",
    1798              :                      clear ? "clear" : "set");
    1799              :         }
    1800              :       else
    1801              :         {
    1802      2545372 :           for (i = 0; i < X86_TUNE_LAST; i++)
    1803              :             {
    1804      2545372 :               if (!strcmp (curr_feature_string, ix86_tune_feature_names[i]))
    1805              :                 {
    1806        75258 :                   ix86_tune_features[i] = !clear;
    1807        75258 :                   if (dump)
    1808            0 :                     fprintf (stderr, "Explicitly %s feature %s\n",
    1809              :                              clear ? "clear" : "set", ix86_tune_feature_names[i]);
    1810              :                   break;
    1811              :                 }
    1812              :             }
    1813              : 
    1814        75258 :           if (i == X86_TUNE_LAST)
    1815            0 :             error ("unknown parameter to option %<-mtune-ctrl%>: %s",
    1816              :                    clear ? curr_feature_string - 1 : curr_feature_string);
    1817              :         }
    1818        75262 :       curr_feature_string = next_feature_string;
    1819              :     }
    1820        75262 :   while (curr_feature_string);
    1821        75138 :   free (orig);
    1822              : }
    1823              : 
    1824              : /* Helper function to set ix86_tune_features. IX86_TUNE is the
    1825              :    processor type.  */
    1826              : 
    1827              : static void
    1828     51084462 : set_ix86_tune_features (struct gcc_options *opts,
    1829              :                         enum processor_type ix86_tune, bool dump)
    1830              : {
    1831     51084462 :   unsigned HOST_WIDE_INT ix86_tune_mask = HOST_WIDE_INT_1U << ix86_tune;
    1832     51084462 :   int i;
    1833              : 
    1834   6487726674 :   for (i = 0; i < X86_TUNE_LAST; ++i)
    1835              :     {
    1836   6436642212 :       if (ix86_tune_no_default)
    1837              :         ix86_tune_features[i] = 0;
    1838              :       else
    1839   6436642212 :         ix86_tune_features[i]
    1840   6436642212 :           = !!(initial_ix86_tune_features[i] & ix86_tune_mask);
    1841              :     }
    1842              : 
    1843     51084462 :   if (dump)
    1844              :     {
    1845            0 :       fprintf (stderr, "List of x86 specific tuning parameter names:\n");
    1846            0 :       for (i = 0; i < X86_TUNE_LAST; i++)
    1847            0 :         fprintf (stderr, "%s : %s\n", ix86_tune_feature_names[i],
    1848            0 :                  ix86_tune_features[i] ? "on" : "off");
    1849              :     }
    1850              : 
    1851     51084462 :   parse_mtune_ctrl_str (opts, dump);
    1852              : 
    1853              :   /* mgather/mscatter option would overwrite -mtune-crtl option.  */
    1854     51084462 :   if (OPTION_SET_P (ix86_use_gather))
    1855              :     {
    1856       103099 :       ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = ix86_use_gather;
    1857       103099 :       ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = ix86_use_gather;
    1858       103099 :       ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = ix86_use_gather;
    1859              :     }
    1860              : 
    1861     51084462 :   if (OPTION_SET_P (ix86_use_scatter))
    1862              :     {
    1863            0 :       ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = ix86_use_scatter;
    1864            0 :       ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = ix86_use_scatter;
    1865            0 :       ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = ix86_use_scatter;
    1866              :     }
    1867     51084462 : }
    1868              : 
    1869              : 
    1870              : /* Default align_* from the processor table.  */
    1871              : 
    1872              : static void
    1873    105864776 : ix86_default_align (struct gcc_options *opts)
    1874              : {
    1875              :   /* -falign-foo without argument: supply one.  */
    1876    105864776 :   if (opts->x_flag_align_loops && !opts->x_str_align_loops)
    1877       138033 :     opts->x_str_align_loops = processor_cost_table[ix86_tune]->align_loop;
    1878    105864776 :   if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
    1879       138034 :     opts->x_str_align_jumps = processor_cost_table[ix86_tune]->align_jump;
    1880    105864776 :   if (opts->x_flag_align_labels && !opts->x_str_align_labels)
    1881       138034 :     opts->x_str_align_labels = processor_cost_table[ix86_tune]->align_label;
    1882    105864776 :   if (opts->x_flag_align_functions && !opts->x_str_align_functions)
    1883       138029 :     opts->x_str_align_functions = processor_cost_table[ix86_tune]->align_func;
    1884    105864776 : }
    1885              : 
    1886              : #ifndef USE_IX86_FRAME_POINTER
    1887              : #define USE_IX86_FRAME_POINTER 0
    1888              : #endif
    1889              : 
    1890              : /* (Re)compute option overrides affected by optimization levels in
    1891              :    target-specific ways.  */
    1892              : 
    1893              : static void
    1894    105864776 : ix86_recompute_optlev_based_flags (struct gcc_options *opts,
    1895              :                                    struct gcc_options *opts_set)
    1896              : {
    1897              :   /* Set the default values for switches whose default depends on TARGET_64BIT
    1898              :      in case they weren't overwritten by command line options.  */
    1899    105864776 :   if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    1900              :     {
    1901    103898993 :       if (opts->x_optimize >= 1)
    1902     99782900 :         SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
    1903              :                              !USE_IX86_FRAME_POINTER);
    1904    103898993 :       if (opts->x_flag_asynchronous_unwind_tables
    1905    103898993 :           && TARGET_64BIT_MS_ABI)
    1906       277912 :         SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1);
    1907    103898993 :       if (opts->x_flag_asynchronous_unwind_tables == 2)
    1908       295791 :         opts->x_flag_unwind_tables
    1909       295791 :           = opts->x_flag_asynchronous_unwind_tables = 1;
    1910    103898993 :       if (opts->x_flag_pcc_struct_return == 2)
    1911       295828 :         opts->x_flag_pcc_struct_return = 0;
    1912              :     }
    1913              :   else
    1914              :     {
    1915      1965783 :       if (opts->x_optimize >= 1)
    1916      1965297 :           SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
    1917              :                                !(USE_IX86_FRAME_POINTER || opts->x_optimize_size));
    1918      1965783 :       if (opts->x_flag_asynchronous_unwind_tables == 2)
    1919         7135 :         opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
    1920      1965783 :       if (opts->x_flag_pcc_struct_return == 2)
    1921              :         {
    1922              :           /* Intel MCU psABI specifies that -freg-struct-return should
    1923              :              be on.  Instead of setting DEFAULT_PCC_STRUCT_RETURN to 0,
    1924              :              we check -miamcu so that -freg-struct-return is always
    1925              :              turned on if -miamcu is used.  */
    1926         7141 :           if (TARGET_IAMCU_P (opts->x_target_flags))
    1927            0 :             opts->x_flag_pcc_struct_return = 0;
    1928              :           else
    1929         7141 :             opts->x_flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
    1930              :         }
    1931              :     }
    1932              : 
    1933              :   /* Keep nonleaf frame pointers.  */
    1934    105864776 :   if (opts->x_flag_omit_frame_pointer)
    1935    101260675 :     opts->x_target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER;
    1936      4604101 :   else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts->x_target_flags))
    1937            0 :     opts->x_flag_omit_frame_pointer = 1;
    1938    105864776 : }
    1939              : 
    1940              : /* Implement part of TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook.  */
    1941              : 
    1942              : static void
    1943    105864776 : ix86_override_options_after_change_1 (struct gcc_options *opts,
    1944              :                                       struct gcc_options *opts_set)
    1945              : {
    1946              : #define OPTS_SET_P(OPTION) opts_set->x_ ## OPTION
    1947              : #define OPTS(OPTION) opts->x_ ## OPTION
    1948              : 
    1949              :   /* Disable unrolling small loops when there's explicit
    1950              :      -f{,no}unroll-loop.  */
    1951    105864776 :   if ((OPTS_SET_P (flag_unroll_loops))
    1952    105113396 :      || (OPTS_SET_P (flag_unroll_all_loops)
    1953          127 :          && OPTS (flag_unroll_all_loops)))
    1954              :     {
    1955       751507 :       if (!OPTS_SET_P (ix86_unroll_only_small_loops))
    1956       751507 :         OPTS (ix86_unroll_only_small_loops) = 0;
    1957              :       /* Re-enable -frename-registers and -fweb if funroll-loops
    1958              :          enabled.  */
    1959       751507 :       if (!OPTS_SET_P (flag_web))
    1960       751499 :         OPTS (flag_web) = OPTS (flag_unroll_loops);
    1961       751507 :       if (!OPTS_SET_P (flag_rename_registers))
    1962       751505 :         OPTS (flag_rename_registers) = OPTS (flag_unroll_loops);
    1963              :       /* -fcunroll-grow-size default follows -f[no]-unroll-loops.  */
    1964       751507 :       if (!OPTS_SET_P (flag_cunroll_grow_size))
    1965       751507 :         OPTS (flag_cunroll_grow_size)
    1966      1503014 :           = (OPTS (flag_unroll_loops)
    1967           44 :              || OPTS (flag_peel_loops)
    1968      1503014 :              || OPTS (optimize) >= 3);
    1969              :     }
    1970              :   else
    1971              :     {
    1972    105113269 :       if (!OPTS_SET_P (flag_cunroll_grow_size))
    1973    105113269 :         OPTS (flag_cunroll_grow_size)
    1974    210226538 :           = (OPTS (flag_peel_loops)
    1975    109550715 :              || OPTS (optimize) >= 3);
    1976              :     }
    1977              : 
    1978              : #undef OPTS
    1979              : #undef OPTS_SET_P
    1980    105864776 : }
    1981              : 
    1982              : /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook.  */
    1983              : 
    1984              : void
    1985     54815271 : ix86_override_options_after_change (void)
    1986              : {
    1987     54815271 :   ix86_default_align (&global_options);
    1988              : 
    1989     54815271 :   ix86_recompute_optlev_based_flags (&global_options, &global_options_set);
    1990              : 
    1991     54815271 :   ix86_override_options_after_change_1 (&global_options, &global_options_set);
    1992     54815271 : }
    1993              : 
    1994              : /* Clear stack slot assignments remembered from previous functions.
    1995              :    This is called from INIT_EXPANDERS once before RTL is emitted for each
    1996              :    function.  */
    1997              : 
    1998              : static struct machine_function *
    1999    206059641 : ix86_init_machine_status (void)
    2000              : {
    2001    206059641 :   struct machine_function *f;
    2002              : 
    2003    206059641 :   f = ggc_cleared_alloc<machine_function> ();
    2004    206059641 :   f->call_abi = ix86_abi;
    2005    206059641 :   f->stack_frame_required = true;
    2006    206059641 :   f->silent_p = true;
    2007              : 
    2008    206059641 :   return f;
    2009              : }
    2010              : 
    2011              : /* Override various settings based on options.  If MAIN_ARGS_P, the
    2012              :    options are from the command line, otherwise they are from
    2013              :    attributes.  Return true if there's an error related to march
    2014              :    option.  */
    2015              : 
    2016              : static bool
    2017     51049509 : ix86_option_override_internal (bool main_args_p,
    2018              :                                struct gcc_options *opts,
    2019              :                                struct gcc_options *opts_set)
    2020              : {
    2021     51049509 :   unsigned int i;
    2022     51049509 :   unsigned HOST_WIDE_INT ix86_arch_mask;
    2023     51049509 :   const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL);
    2024              : 
    2025              :   /* -mrecip options.  */
    2026     51049509 :   static struct
    2027              :     {
    2028              :       const char *string;           /* option name */
    2029              :       unsigned int mask;            /* mask bits to set */
    2030              :     }
    2031              :   const recip_options[] =
    2032              :     {
    2033              :       { "all",       RECIP_MASK_ALL },
    2034              :       { "none",      RECIP_MASK_NONE },
    2035              :       { "div",       RECIP_MASK_DIV },
    2036              :       { "sqrt",      RECIP_MASK_SQRT },
    2037              :       { "vec-div",   RECIP_MASK_VEC_DIV },
    2038              :       { "vec-sqrt",  RECIP_MASK_VEC_SQRT },
    2039              :     };
    2040              : 
    2041              :   /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
    2042              :      TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false.  */
    2043     51049509 :   if (TARGET_64BIT_DEFAULT && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2044       627624 :     opts->x_ix86_isa_flags &= ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
    2045              : #ifdef TARGET_BI_ARCH
    2046              :   else
    2047              :     {
    2048              : #if TARGET_BI_ARCH == 1
    2049              :       /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
    2050              :          is on and OPTION_MASK_ABI_X32 is off.  We turn off
    2051              :          OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
    2052              :          -mx32.  */
    2053     50421885 :       if (TARGET_X32_P (opts->x_ix86_isa_flags))
    2054           99 :         opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
    2055              : #else
    2056              :       /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
    2057              :          on and OPTION_MASK_ABI_64 is off.  We turn off
    2058              :          OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
    2059              :          -m64 or OPTION_MASK_CODE16 is turned on by -m16.  */
    2060              :       if (TARGET_LP64_P (opts->x_ix86_isa_flags)
    2061              :           || TARGET_16BIT_P (opts->x_ix86_isa_flags))
    2062              :         opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
    2063              : #endif
    2064     50421885 :       if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2065     50421885 :           && TARGET_IAMCU_P (opts->x_target_flags))
    2066            0 :         sorry ("Intel MCU psABI isn%'t supported in %s mode",
    2067              :                TARGET_X32_P (opts->x_ix86_isa_flags) ? "x32" : "64-bit");
    2068              :     }
    2069              : #endif
    2070              : 
    2071     51049509 :   if (TARGET_X32_P (opts->x_ix86_isa_flags))
    2072              :     {
    2073              :       /* Always turn on OPTION_MASK_ISA_64BIT and turn off
    2074              :          OPTION_MASK_ABI_64 for TARGET_X32.  */
    2075           99 :       opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
    2076           99 :       opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
    2077              :     }
    2078     51049410 :   else if (TARGET_16BIT_P (opts->x_ix86_isa_flags))
    2079            6 :     opts->x_ix86_isa_flags &= ~(OPTION_MASK_ISA_64BIT
    2080              :                                 | OPTION_MASK_ABI_X32
    2081              :                                 | OPTION_MASK_ABI_64);
    2082     51049404 :   else if (TARGET_LP64_P (opts->x_ix86_isa_flags))
    2083              :     {
    2084              :       /* Always turn on OPTION_MASK_ISA_64BIT and turn off
    2085              :          OPTION_MASK_ABI_X32 for TARGET_LP64.  */
    2086     50421780 :       opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
    2087     50421780 :       opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
    2088              :     }
    2089              : 
    2090              : #ifdef SUBTARGET_OVERRIDE_OPTIONS
    2091              :   SUBTARGET_OVERRIDE_OPTIONS;
    2092              : #endif
    2093              : 
    2094              : #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
    2095              :   SUBSUBTARGET_OVERRIDE_OPTIONS;
    2096              : #endif
    2097              : 
    2098              : #ifdef HAVE_LD_BROKEN_PE_DWARF5
    2099              :   /* If the PE linker has broken DWARF 5 support, make
    2100              :      DWARF 4 the default.  */
    2101              :   if (TARGET_PECOFF)
    2102              :     SET_OPTION_IF_UNSET (opts, opts_set, dwarf_version, 4);
    2103              : #endif
    2104              : 
    2105              :   /* -fPIC is the default for x86_64.  */
    2106     51049509 :   if (TARGET_MACHO && TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2107              :     opts->x_flag_pic = 2;
    2108              : 
    2109              :   /* Need to check -mtune=generic first.  */
    2110     51049509 :   if (opts->x_ix86_tune_string)
    2111              :     {
    2112              :       /* As special support for cross compilers we read -mtune=native
    2113              :              as -mtune=generic.  With native compilers we won't see the
    2114              :              -mtune=native, as it was changed by the driver.  */
    2115     51027361 :       if (!strcmp (opts->x_ix86_tune_string, "native"))
    2116            0 :         opts->x_ix86_tune_string = "generic";
    2117     51027361 :       else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
    2118            0 :         warning (OPT_Wdeprecated,
    2119              :                  main_args_p
    2120              :                  ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
    2121              :                       "or %<-mtune=generic%> instead as appropriate")
    2122              :                  : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
    2123              :                       "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
    2124              :                       " instead as appropriate"));
    2125              :     }
    2126              :   else
    2127              :     {
    2128        22148 :       if (opts->x_ix86_arch_string)
    2129        22148 :         opts->x_ix86_tune_string = opts->x_ix86_arch_string;
    2130        22148 :       if (!opts->x_ix86_tune_string)
    2131              :         {
    2132            0 :           opts->x_ix86_tune_string = processor_names[TARGET_CPU_DEFAULT];
    2133            0 :           ix86_tune_defaulted = 1;
    2134              :         }
    2135              : 
    2136              :       /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
    2137              :          or defaulted.  We need to use a sensible tune option.  */
    2138        22148 :       if (startswith (opts->x_ix86_tune_string, "x86-64")
    2139        22148 :           && (opts->x_ix86_tune_string[6] == '\0'
    2140          446 :               || (!strcmp (opts->x_ix86_tune_string + 6, "-v2")
    2141          398 :                   || !strcmp (opts->x_ix86_tune_string + 6, "-v3")
    2142          169 :                   || !strcmp (opts->x_ix86_tune_string + 6, "-v4"))))
    2143          749 :         opts->x_ix86_tune_string = "generic";
    2144              :     }
    2145              : 
    2146     51049509 :   if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
    2147           10 :       && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2148              :     {
    2149              :       /* rep; movq isn't available in 32-bit code.  */
    2150            0 :       error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
    2151            0 :       opts->x_ix86_stringop_alg = no_stringop;
    2152              :     }
    2153              : 
    2154     51049509 :   if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
    2155        51528 :       && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2156            0 :     error ("%<-mapxf%> is not supported for 32-bit code");
    2157     51049509 :   else if (opts->x_ix86_apx_features != apx_none
    2158        51543 :            && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2159            0 :     error ("%<-mapx-features=%> option is not supported for 32-bit code");
    2160              : 
    2161     51049509 :   if (TARGET_UINTR_P (opts->x_ix86_isa_flags2)
    2162        86068 :       && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2163            0 :     error ("%<-muintr%> not supported for 32-bit code");
    2164              : 
    2165     51049509 :   if (ix86_lam_type && !TARGET_LP64_P (opts->x_ix86_isa_flags))
    2166            0 :     error ("%<-mlam=%> option: [u48|u57] not supported for 32-bit code");
    2167              : 
    2168     51049509 :   if (!opts->x_ix86_arch_string)
    2169            0 :     opts->x_ix86_arch_string
    2170            0 :       = TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2171            0 :         ? "x86-64" : SUBTARGET32_DEFAULT_CPU;
    2172              :   else
    2173     51049509 :     ix86_arch_specified = 1;
    2174              : 
    2175     51049509 :   if (opts_set->x_ix86_pmode)
    2176              :     {
    2177           57 :       if ((TARGET_LP64_P (opts->x_ix86_isa_flags)
    2178            0 :            && opts->x_ix86_pmode == PMODE_SI)
    2179           57 :           || (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2180            0 :                && opts->x_ix86_pmode == PMODE_DI))
    2181            0 :         error ("address mode %qs not supported in the %s bit mode",
    2182              :                TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "short" : "long",
    2183              :                TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "64" : "32");
    2184              :     }
    2185              :   else
    2186     51049452 :     opts->x_ix86_pmode = TARGET_LP64_P (opts->x_ix86_isa_flags)
    2187     51049452 :                          ? PMODE_DI : PMODE_SI;
    2188              : 
    2189     51049509 :   SET_OPTION_IF_UNSET (opts, opts_set, ix86_abi, DEFAULT_ABI);
    2190              : 
    2191     51049509 :   if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
    2192            1 :     error ("%<-mabi=ms%> not supported with X32 ABI");
    2193     51049509 :   gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
    2194              : 
    2195     51049509 :   const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv";
    2196     51049509 :   if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
    2197         3116 :       && opts->x_ix86_abi != DEFAULT_ABI)
    2198            7 :     error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name);
    2199     51049509 :   if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
    2200          144 :       && opts->x_ix86_abi != DEFAULT_ABI)
    2201            0 :     error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
    2202              :            abi_name);
    2203     51049509 :   if ((opts->x_flag_sanitize & SANITIZE_THREAD)
    2204          387 :       && opts->x_ix86_abi != DEFAULT_ABI)
    2205            2 :     error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name);
    2206              : 
    2207              :   /* Hwasan is supported with lam_u57 only.  */
    2208     51049509 :   if (opts->x_flag_sanitize & SANITIZE_HWADDRESS)
    2209              :     {
    2210          566 :       if (ix86_lam_type == lam_u48)
    2211            0 :         warning (0, "%<-mlam=u48%> is not compatible with Hardware-assisted "
    2212              :                  "AddressSanitizer, override to %<-mlam=u57%>");
    2213          566 :       ix86_lam_type = lam_u57;
    2214              :     }
    2215              : 
    2216              :   /* For targets using ms ABI enable ms-extensions, if not
    2217              :      explicit turned off.  For non-ms ABI we turn off this
    2218              :      option.  */
    2219     51049509 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_ms_extensions,
    2220              :                        (MS_ABI == DEFAULT_ABI));
    2221              : 
    2222     51049509 :   if (opts_set->x_ix86_cmodel)
    2223              :     {
    2224        36776 :       switch (opts->x_ix86_cmodel)
    2225              :         {
    2226            1 :         case CM_SMALL:
    2227            1 :         case CM_SMALL_PIC:
    2228            1 :           if (opts->x_flag_pic)
    2229            0 :             opts->x_ix86_cmodel = CM_SMALL_PIC;
    2230            1 :           if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2231            0 :             error ("code model %qs not supported in the %s bit mode",
    2232              :                    "small", "32");
    2233              :           break;
    2234              : 
    2235        23257 :         case CM_MEDIUM:
    2236        23257 :         case CM_MEDIUM_PIC:
    2237        23257 :           if (opts->x_flag_pic)
    2238        23243 :             opts->x_ix86_cmodel = CM_MEDIUM_PIC;
    2239        23257 :           if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2240            0 :             error ("code model %qs not supported in the %s bit mode",
    2241              :                    "medium", "32");
    2242        23257 :           else if (TARGET_X32_P (opts->x_ix86_isa_flags))
    2243            0 :             error ("code model %qs not supported in x32 mode",
    2244              :                    "medium");
    2245              :           break;
    2246              : 
    2247        13517 :         case CM_LARGE:
    2248        13517 :         case CM_LARGE_PIC:
    2249        13517 :           if (opts->x_flag_pic)
    2250           29 :             opts->x_ix86_cmodel = CM_LARGE_PIC;
    2251        13517 :           if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2252            0 :             error ("code model %qs not supported in the %s bit mode",
    2253              :                    "large", "32");
    2254        13517 :           else if (TARGET_X32_P (opts->x_ix86_isa_flags))
    2255            0 :             error ("code model %qs not supported in x32 mode",
    2256              :                    "large");
    2257              :           break;
    2258              : 
    2259            0 :         case CM_32:
    2260            0 :           if (opts->x_flag_pic)
    2261            0 :             error ("code model %s does not support PIC mode", "32");
    2262            0 :           if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2263            0 :             error ("code model %qs not supported in the %s bit mode",
    2264              :                    "32", "64");
    2265              :           break;
    2266              : 
    2267            1 :         case CM_KERNEL:
    2268            1 :           if (opts->x_flag_pic)
    2269              :             {
    2270            0 :               error ("code model %s does not support PIC mode", "kernel");
    2271            0 :               opts->x_ix86_cmodel = CM_32;
    2272              :             }
    2273            1 :           if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2274            0 :             error ("code model %qs not supported in the %s bit mode",
    2275              :                    "kernel", "32");
    2276              :           break;
    2277              : 
    2278            0 :         default:
    2279            0 :           gcc_unreachable ();
    2280              :         }
    2281              :     }
    2282              :   else
    2283              :     {
    2284              :       /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
    2285              :          use of rip-relative addressing.  This eliminates fixups that
    2286              :          would otherwise be needed if this object is to be placed in a
    2287              :          DLL, and is essentially just as efficient as direct addressing.  */
    2288     51012733 :       if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2289              :           && (TARGET_RDOS || TARGET_PECOFF))
    2290              :         opts->x_ix86_cmodel = CM_MEDIUM_PIC, opts->x_flag_pic = 1;
    2291     51012733 :       else if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2292    100398158 :         opts->x_ix86_cmodel = opts->x_flag_pic ? CM_SMALL_PIC : CM_SMALL;
    2293              :       else
    2294       627630 :         opts->x_ix86_cmodel = CM_32;
    2295              :     }
    2296     51049509 :   if (TARGET_MACHO && opts->x_ix86_asm_dialect == ASM_INTEL)
    2297              :     {
    2298              :       error ("%<-masm=intel%> not supported in this configuration");
    2299              :       opts->x_ix86_asm_dialect = ASM_ATT;
    2300              :     }
    2301     51049509 :   if ((TARGET_64BIT_P (opts->x_ix86_isa_flags) != 0)
    2302              :       != ((opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) != 0))
    2303              :     sorry ("%i-bit mode not compiled in",
    2304              :            (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32);
    2305              : 
    2306     51049509 :   processor_vendor ix86_vendor = VENDOR_OTHER;
    2307     51049509 :   processor_types ix86_type = CPU_TYPE_MAX;
    2308     51049509 :   processor_subtypes ix86_subtype = CPU_SUBTYPE_MAX;
    2309     51049509 :   wide_int_bitmask ix86_pta = 0;
    2310              : 
    2311              :   /* Last processor_alias_table must point to "generic" entry.  */
    2312     51049509 :   gcc_checking_assert (strcmp (processor_alias_table[pta_size - 1].name,
    2313              :                                "generic") == 0);
    2314   4071034719 :   for (i = 0; i < pta_size; i++)
    2315   4071034692 :     if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
    2316              :       {
    2317     51049482 :         if (!strcmp (opts->x_ix86_arch_string, "generic"))
    2318              :           {
    2319            2 :             error (main_args_p
    2320              :                    ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
    2321              :                         "switch")
    2322              :                    : G_("%<generic%> CPU can be used only for "
    2323              :                         "%<target(\"tune=\")%> attribute"));
    2324            2 :             return false;
    2325              :           }
    2326     51049480 :         else if (!strcmp (opts->x_ix86_arch_string, "intel"))
    2327              :           {
    2328            1 :             error (main_args_p
    2329              :                    ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
    2330              :                         "switch")
    2331              :                    : G_("%<intel%> CPU can be used only for "
    2332              :                         "%<target(\"tune=\")%> attribute"));
    2333            1 :             return false;
    2334              :           }
    2335              : 
    2336     51049479 :         if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2337     51049479 :             && !((processor_alias_table[i].flags & PTA_64BIT) != 0))
    2338              :           {
    2339            1 :             error ("CPU you selected does not support x86-64 "
    2340              :                    "instruction set");
    2341            1 :             return false;
    2342              :           }
    2343              : 
    2344     51049478 :         ix86_schedule = processor_alias_table[i].schedule;
    2345     51049478 :         ix86_arch = processor_alias_table[i].processor;
    2346     51049478 :         ix86_pta = processor_alias_table[i].flags;
    2347              : 
    2348     51049478 :         ix86_decode_cpu_info (processor_alias_table[i].model,
    2349              :                               ix86_vendor, ix86_type, ix86_subtype);
    2350              : 
    2351              :         /* Default cpu tuning to the architecture, unless the table
    2352              :            entry requests not to do this.  Used by the x86-64 psABI
    2353              :            micro-architecture levels.  */
    2354    101704212 :         if ((processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
    2355     50654734 :           ix86_tune = ix86_arch;
    2356              :         else
    2357              :           ix86_tune = PROCESSOR_GENERIC;
    2358              : 
    2359              :         /* Enable PTA flags that are enabled by default by a -march option.  */
    2360              : #define TARGET_EXPLICIT_NO_SAHF_P(opts) (false)
    2361              : #define SET_TARGET_NO_SAHF(opts) {}
    2362              : #define TARGET_EXPLICIT_PREFETCH_SSE_P(opts) (false)
    2363              : #define SET_TARGET_PREFETCH_SSE(opts) {}
    2364              : #define TARGET_EXPLICIT_NO_TUNE_P(opts) (false)
    2365              : #define SET_TARGET_NO_TUNE(opts) {}
    2366              : #define TARGET_EXPLICIT_NO_80387_P(opts) (false)
    2367              : #define SET_TARGET_NO_80387(opts) {}
    2368              : 
    2369              : #define DEF_PTA(NAME) \
    2370              :         if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
    2371              :             && PTA_ ## NAME != PTA_64BIT \
    2372              :             && (TARGET_64BIT || (PTA_ ## NAME != PTA_UINTR \
    2373              :                                  && PTA_ ## NAME != PTA_APX_F))\
    2374              :             && !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
    2375              :           SET_TARGET_ ## NAME (opts);
    2376              : #include "i386-isa.def"
    2377              : #undef DEF_PTA
    2378              : 
    2379              : 
    2380     51049478 :        if (!(TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2381     50421848 :              && ((processor_alias_table[i].flags & PTA_NO_SAHF) != 0))
    2382     51824594 :            && !TARGET_EXPLICIT_SAHF_P (opts))
    2383      1402733 :             SET_TARGET_SAHF (opts);
    2384              : 
    2385     51049478 :         if (((processor_alias_table[i].flags & PTA_ABM) != 0)
    2386         6192 :             && !TARGET_EXPLICIT_ABM_P (opts))
    2387              :           {
    2388         6179 :             if (!TARGET_EXPLICIT_LZCNT_P (opts))
    2389         6178 :               SET_TARGET_LZCNT (opts);
    2390         6179 :             if (!TARGET_EXPLICIT_POPCNT_P (opts))
    2391         5746 :               SET_TARGET_POPCNT (opts);
    2392              :           }
    2393              : 
    2394              :         /* Enable apx if apxf or apx_features are not
    2395              :            explicitly set for -march.  */
    2396     51049478 :         if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2397     50421848 :              && ((processor_alias_table[i].flags & PTA_APX_F) != 0)
    2398          274 :              && !TARGET_EXPLICIT_APX_F_P (opts)
    2399     51049750 :              && !OPTION_SET_P (ix86_apx_features))
    2400          272 :           opts->x_ix86_apx_features = apx_all;
    2401              : 
    2402     51049478 :         if ((processor_alias_table[i].flags
    2403     51049478 :            & (PTA_PREFETCH_SSE | PTA_SSE)) != 0)
    2404     51049478 :           ix86_prefetch_sse = true;
    2405              : 
    2406              :         /* Don't enable x87 instructions if only general registers are
    2407              :            allowed by target("general-regs-only") function attribute or
    2408              :            -mgeneral-regs-only.  */
    2409     51049478 :         if (!(opts->x_ix86_target_flags & OPTION_MASK_GENERAL_REGS_ONLY)
    2410     48777863 :             && !(opts_set->x_target_flags & MASK_80387))
    2411              :           {
    2412     48777828 :             if (((processor_alias_table[i].flags & PTA_NO_80387) != 0))
    2413            0 :               opts->x_target_flags &= ~MASK_80387;
    2414              :             else
    2415     48777828 :               opts->x_target_flags |= MASK_80387;
    2416              :           }
    2417              :         break;
    2418              :       }
    2419              : 
    2420     51049505 :   if (i == pta_size)
    2421              :     {
    2422           29 :       error (main_args_p
    2423              :              ? G_("bad value %qs for %<-march=%> switch")
    2424              :              : G_("bad value %qs for %<target(\"arch=\")%> attribute"),
    2425              :              opts->x_ix86_arch_string);
    2426              : 
    2427           27 :       auto_vec <const char *> candidates;
    2428         3267 :       for (i = 0; i < pta_size; i++)
    2429         3240 :         if (strcmp (processor_alias_table[i].name, "generic")
    2430         3213 :             && strcmp (processor_alias_table[i].name, "intel")
    2431         6426 :             && (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2432         5562 :                 || ((processor_alias_table[i].flags & PTA_64BIT) != 0)))
    2433         2322 :           candidates.safe_push (processor_alias_table[i].name);
    2434              : 
    2435              : #ifdef HAVE_LOCAL_CPU_DETECT
    2436              :       /* Add also "native" as possible value.  */
    2437           27 :       candidates.safe_push ("native");
    2438              : #endif
    2439              : 
    2440           27 :       char *s;
    2441           27 :       const char *hint
    2442           27 :         = candidates_list_and_hint (opts->x_ix86_arch_string, s, candidates);
    2443           27 :       if (hint)
    2444            3 :         inform (input_location,
    2445              :                 main_args_p
    2446              :                 ? G_("valid arguments to %<-march=%> switch are: "
    2447              :                      "%s; did you mean %qs?")
    2448              :                 : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
    2449              :                      "%s; did you mean %qs?"), s, hint);
    2450              :       else
    2451           26 :         inform (input_location,
    2452              :                 main_args_p
    2453              :                 ? G_("valid arguments to %<-march=%> switch are: %s")
    2454              :                 : G_("valid arguments to %<target(\"arch=\")%> attribute "
    2455              :                      "are: %s"), s);
    2456           27 :       XDELETEVEC (s);
    2457           27 :     }
    2458              : 
    2459     51049505 :   ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
    2460    306297030 :   for (i = 0; i < X86_ARCH_LAST; ++i)
    2461    255247525 :     ix86_arch_features[i] = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
    2462              : 
    2463   6068317991 :   for (i = 0; i < pta_size; i++)
    2464   6068317960 :     if (! strcmp (opts->x_ix86_tune_string, processor_alias_table[i].name)
    2465   6068317960 :         && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
    2466              :       {
    2467     51049474 :         ix86_schedule = processor_alias_table[i].schedule;
    2468     51049474 :         ix86_tune = processor_alias_table[i].processor;
    2469     51049474 :         if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2470              :           {
    2471     50421844 :             if (!((processor_alias_table[i].flags & PTA_64BIT) != 0))
    2472              :               {
    2473            0 :                 if (ix86_tune_defaulted)
    2474              :                   {
    2475            0 :                     opts->x_ix86_tune_string = "x86-64";
    2476            0 :                     for (i = 0; i < pta_size; i++)
    2477            0 :                       if (! strcmp (opts->x_ix86_tune_string,
    2478            0 :                                     processor_alias_table[i].name))
    2479              :                         break;
    2480            0 :                     ix86_schedule = processor_alias_table[i].schedule;
    2481            0 :                     ix86_tune = processor_alias_table[i].processor;
    2482              :                   }
    2483              :                 else
    2484            0 :                   error ("CPU you selected does not support x86-64 "
    2485              :                          "instruction set");
    2486              :               }
    2487              :           }
    2488              :         /* Intel CPUs have always interpreted SSE prefetch instructions as
    2489              :            NOPs; so, we can enable SSE prefetch instructions even when
    2490              :            -mtune (rather than -march) points us to a processor that has them.
    2491              :            However, the VIA C3 gives a SIGILL, so we only do that for i686 and
    2492              :            higher processors.  */
    2493     51049474 :         if (TARGET_CMOV
    2494     51049474 :             && ((processor_alias_table[i].flags
    2495     51049474 :               & (PTA_PREFETCH_SSE | PTA_SSE)) != 0))
    2496       816392 :           ix86_prefetch_sse = true;
    2497              :         break;
    2498              :       }
    2499              : 
    2500     51049505 :   if (ix86_tune_specified && i == pta_size)
    2501              :     {
    2502           28 :       error (main_args_p
    2503              :              ? G_("bad value %qs for %<-mtune=%> switch")
    2504              :              : G_("bad value %qs for %<target(\"tune=\")%> attribute"),
    2505              :              opts->x_ix86_tune_string);
    2506              : 
    2507           26 :       auto_vec <const char *> candidates;
    2508         3146 :       for (i = 0; i < pta_size; i++)
    2509         3120 :         if ((!TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2510         3120 :              || ((processor_alias_table[i].flags & PTA_64BIT) != 0))
    2511         8450 :             && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
    2512         2210 :           candidates.safe_push (processor_alias_table[i].name);
    2513              : 
    2514              : #ifdef HAVE_LOCAL_CPU_DETECT
    2515              :       /* Add also "native" as possible value.  */
    2516           26 :       candidates.safe_push ("native");
    2517              : #endif
    2518              : 
    2519           26 :       char *s;
    2520           26 :       const char *hint
    2521           26 :         = candidates_list_and_hint (opts->x_ix86_tune_string, s, candidates);
    2522           26 :       if (hint)
    2523            1 :         inform (input_location,
    2524              :                 main_args_p
    2525              :                 ? G_("valid arguments to %<-mtune=%> switch are: "
    2526              :                      "%s; did you mean %qs?")
    2527              :                 : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
    2528              :                      "%s; did you mean %qs?"), s, hint);
    2529              :       else
    2530           27 :         inform (input_location,
    2531              :                 main_args_p
    2532              :                 ? G_("valid arguments to %<-mtune=%> switch are: %s")
    2533              :                 : G_("valid arguments to %<target(\"tune=\")%> attribute "
    2534              :                      "are: %s"), s);
    2535           26 :       XDELETEVEC (s);
    2536           26 :     }
    2537              : 
    2538              :   /* Disable -m128bit-atomic if not set on command-line.  */
    2539     51049505 :   if (!TARGET_128BIT_ATOMIC_P (opts_set->x_ix86_target_flags))
    2540     51035047 :     opts->x_ix86_target_flags &= ~OPTION_MASK_128BIT_ATOMIC;
    2541              : 
    2542     51049505 :   if (TARGET_128BIT_ATOMIC_P (opts->x_ix86_target_flags))
    2543              :     {
    2544        14457 :       if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2545            0 :         error ("%<-m128bit-atomic%> not supported for 32-bit code");
    2546        14457 :       else if (!TARGET_CX16_P (opts_set->x_ix86_isa_flags2))
    2547              :         {
    2548              :           /* Enable CMPXCHG16B when -m128bit-atomic is enabled.  */
    2549        14455 :           opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_CX16;
    2550              :         }
    2551              :     }
    2552     51035048 :   else if (!TARGET_128BIT_ATOMIC_P (opts_set->x_ix86_target_flags)
    2553     51035047 :            && TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2554    101442465 :            && ((TARGET_AVX_P (opts->x_ix86_isa_flags)
    2555     47743592 :                 && (ix86_vendor == VENDOR_INTEL
    2556     47743592 :                     || ix86_vendor == VENDOR_AMD
    2557     47384683 :                     || ix86_vendor == VENDOR_HYGON
    2558     47384570 :                     || ix86_vendor == VENDOR_ZHAOXIN))
    2559     50048350 :                || (ix86_pta & PTA_X86_64_V3) == PTA_X86_64_V3
    2560     49665228 :                || ix86_type == AMDFAM17H
    2561              :                || ix86_type == AMDFAM19H
    2562              :                || ix86_type == AMDFAM1AH
    2563              :                || ix86_type == HYGONFAM18H
    2564              :                || (ix86_type >= INTEL_SIERRAFOREST
    2565              :                    && ix86_type <= INTEL_CLEARWATERFOREST)
    2566     49665228 :                || ix86_subtype == INTEL_COREI7_SANDYBRIDGE
    2567              :                || (ix86_subtype >= AMDFAM17H_ZNVER1
    2568              :                    && ix86_subtype <= INTEL_COREI7_ROCKETLAKE)
    2569              :                || (ix86_subtype >= AMDFAM19H_ZNVER4
    2570              :                    && ix86_subtype <= HYGONFAM18H_C86_4G_M8)))
    2571              :     {
    2572              :       /* Turn on -m128bit-atomic in 64-bit mode by default if supported
    2573              :          by the targeting processor, which is one of x86-64-v3 capable
    2574              :          processors as well as AVX capable processors from Intel, AMD,
    2575              :          Hygon and Zhaoxin.  */
    2576       742191 :       opts->x_ix86_target_flags |= OPTION_MASK_128BIT_ATOMIC;
    2577              :     }
    2578              : 
    2579     51049505 :   set_ix86_tune_features (opts, ix86_tune, opts->x_ix86_dump_tunes);
    2580              : 
    2581     51049505 :   ix86_recompute_optlev_based_flags (opts, opts_set);
    2582              : 
    2583     51049505 :   ix86_override_options_after_change_1 (opts, opts_set);
    2584              : 
    2585     51049505 :   ix86_tune_cost = processor_cost_table[ix86_tune];
    2586              :   /* TODO: ix86_cost should be chosen at instruction or function granularity
    2587              :      so for cold code we use size_cost even in !optimize_size compilation.  */
    2588     51049505 :   if (opts->x_optimize_size)
    2589              :     ix86_cost = &ix86_size_cost;
    2590              :   else
    2591     50328233 :     ix86_cost = ix86_tune_cost;
    2592              : 
    2593              :   /* Arrange to set up i386_stack_locals for all functions.  */
    2594     51049505 :   init_machine_status = ix86_init_machine_status;
    2595              : 
    2596              :   /* Override APX flag here if ISA bit is set.  */
    2597     51049505 :   if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
    2598        51800 :       && !OPTION_SET_P (ix86_apx_features))
    2599        51800 :     opts->x_ix86_apx_features = apx_all;
    2600              : 
    2601              :   /* Validate -mregparm= value.  */
    2602     51049505 :   if (opts_set->x_ix86_regparm)
    2603              :     {
    2604            0 :       if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2605            0 :         warning (0, "%<-mregparm%> is ignored in 64-bit mode");
    2606            0 :       else if (TARGET_IAMCU_P (opts->x_target_flags))
    2607            0 :         warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
    2608            0 :       if (opts->x_ix86_regparm > REGPARM_MAX)
    2609              :         {
    2610            0 :           error ("%<-mregparm=%d%> is not between 0 and %d",
    2611            0 :                  opts->x_ix86_regparm, REGPARM_MAX);
    2612            0 :           opts->x_ix86_regparm = 0;
    2613              :         }
    2614              :     }
    2615     51049505 :   if (TARGET_IAMCU_P (opts->x_target_flags)
    2616     51049505 :       || TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2617    100772614 :     opts->x_ix86_regparm = REGPARM_MAX;
    2618              : 
    2619              :   /* Default align_* from the processor table.  */
    2620     51049505 :   ix86_default_align (&global_options);
    2621              : 
    2622              :   /* Provide default for -mbranch-cost= value.  */
    2623     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, ix86_branch_cost,
    2624              :                        ix86_tune_cost->branch_cost);
    2625              : 
    2626     51049505 :   if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2627              :     {
    2628     50421875 :       opts->x_target_flags
    2629     50421875 :         |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
    2630              : 
    2631     50421875 :       if (!ix86_arch_specified)
    2632            0 :         opts->x_ix86_isa_flags
    2633            0 :           |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
    2634              : 
    2635     50421875 :       if (!TARGET_128BIT_LONG_DOUBLE_P (opts->x_target_flags))
    2636            1 :         error ("%<-m96bit-long-double%> is not compatible with this target");
    2637              : 
    2638     50421875 :       if (TARGET_RTD_P (opts->x_target_flags))
    2639            0 :         warning (0,
    2640              :                  main_args_p
    2641              :                  ? G_("%<-mrtd%> is ignored in 64bit mode")
    2642              :                  : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
    2643              :     }
    2644              :   else
    2645              :     {
    2646       627630 :       opts->x_target_flags
    2647              :         |= TARGET_SUBTARGET32_DEFAULT & ~opts_set->x_target_flags;
    2648              : 
    2649       627630 :       if (!ix86_arch_specified)
    2650       627630 :         opts->x_ix86_isa_flags
    2651              :           |= TARGET_SUBTARGET32_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
    2652              : 
    2653              :       /* i386 ABI does not specify red zone.  It still makes sense to use it
    2654              :          when programmer takes care to stack from being destroyed.  */
    2655       627630 :       if (!(opts_set->x_target_flags & MASK_NO_RED_ZONE))
    2656       627630 :         opts->x_target_flags |= MASK_NO_RED_ZONE;
    2657              :     }
    2658              : 
    2659              :   /* If we're doing fast math, we don't care about comparison order
    2660              :      wrt NaNs.  This lets us use a shorter comparison sequence.  */
    2661     51049505 :   if (opts->x_flag_finite_math_only)
    2662      1040458 :     opts->x_target_flags &= ~MASK_IEEE_FP;
    2663              : 
    2664              :   /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
    2665              :      since the insns won't need emulation.  */
    2666     51049505 :   if (ix86_tune_features [X86_TUNE_ALWAYS_FANCY_MATH_387])
    2667     51049505 :     opts->x_target_flags &= ~MASK_NO_FANCY_MATH_387;
    2668              : 
    2669              :   /* Likewise, if the target doesn't have a 387, or we've specified
    2670              :      software floating point, don't use 387 inline intrinsics.  */
    2671     51049505 :   if (!TARGET_80387_P (opts->x_target_flags))
    2672      2271641 :     opts->x_target_flags |= MASK_NO_FANCY_MATH_387;
    2673              : 
    2674              :   /* Turn on MMX builtins for -msse.  */
    2675     51049505 :   if (TARGET_SSE_P (opts->x_ix86_isa_flags))
    2676     48837784 :     opts->x_ix86_isa_flags
    2677     48837784 :       |= OPTION_MASK_ISA_MMX & ~opts->x_ix86_isa_flags_explicit;
    2678              : 
    2679              :   /* Enable SSE prefetch.  */
    2680     51049505 :   if (TARGET_SSE_P (opts->x_ix86_isa_flags)
    2681      2211721 :       || (TARGET_PRFCHW_P (opts->x_ix86_isa_flags)
    2682        18765 :           && !TARGET_3DNOW_P (opts->x_ix86_isa_flags)))
    2683     48856549 :     ix86_prefetch_sse = true;
    2684              : 
    2685              :   /* Enable mwait/monitor instructions for -msse3.  */
    2686     51049505 :   if (TARGET_SSE3_P (opts->x_ix86_isa_flags))
    2687     48475591 :     opts->x_ix86_isa_flags2
    2688     48475591 :       |= OPTION_MASK_ISA2_MWAIT & ~opts->x_ix86_isa_flags2_explicit;
    2689              : 
    2690              :   /* Enable popcnt instruction for -msse4.2 or -mabm.  */
    2691     51049505 :   if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags)
    2692      2680169 :       || TARGET_ABM_P (opts->x_ix86_isa_flags))
    2693     48375419 :     opts->x_ix86_isa_flags
    2694     48375419 :       |= OPTION_MASK_ISA_POPCNT & ~opts->x_ix86_isa_flags_explicit;
    2695              : 
    2696              :   /* Enable crc32 instruction for -msse4.2.  */
    2697     51049505 :   if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags))
    2698     48369336 :     opts->x_ix86_isa_flags
    2699     48369336 :       |= OPTION_MASK_ISA_CRC32 & ~opts->x_ix86_isa_flags_explicit;
    2700              : 
    2701              :   /* Enable lzcnt instruction for -mabm.  */
    2702     51049505 :   if (TARGET_ABM_P(opts->x_ix86_isa_flags))
    2703        70494 :     opts->x_ix86_isa_flags
    2704        70494 :       |= OPTION_MASK_ISA_LZCNT & ~opts->x_ix86_isa_flags_explicit;
    2705              : 
    2706              :   /* Disable BMI, BMI2 and TBM instructions for -m16.  */
    2707     51049505 :   if (TARGET_16BIT_P(opts->x_ix86_isa_flags))
    2708            6 :     opts->x_ix86_isa_flags
    2709            6 :       &= ~((OPTION_MASK_ISA_BMI | OPTION_MASK_ISA_BMI2 | OPTION_MASK_ISA_TBM)
    2710            6 :            & ~opts->x_ix86_isa_flags_explicit);
    2711              : 
    2712              :   /* Validate -mpreferred-stack-boundary= value or default it to
    2713              :      PREFERRED_STACK_BOUNDARY_DEFAULT.  */
    2714     51049505 :   ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
    2715     51049505 :   if (opts_set->x_ix86_preferred_stack_boundary_arg)
    2716              :     {
    2717         1656 :       int min = TARGET_64BIT_P (opts->x_ix86_isa_flags)? 3 : 2;
    2718         1656 :       int max = TARGET_SEH ? 4 : 12;
    2719              : 
    2720         1656 :       if (opts->x_ix86_preferred_stack_boundary_arg < min
    2721         1656 :           || opts->x_ix86_preferred_stack_boundary_arg > max)
    2722              :         {
    2723            0 :           if (min == max)
    2724              :             error ("%<-mpreferred-stack-boundary%> is not supported "
    2725              :                    "for this target");
    2726              :           else
    2727            0 :             error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
    2728              :                    opts->x_ix86_preferred_stack_boundary_arg, min, max);
    2729              :         }
    2730              :       else
    2731         1656 :         ix86_preferred_stack_boundary
    2732         1656 :           = (1 << opts->x_ix86_preferred_stack_boundary_arg) * BITS_PER_UNIT;
    2733              :     }
    2734              : 
    2735              :   /* Set the default value for -mstackrealign.  */
    2736     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, ix86_force_align_arg_pointer,
    2737              :                        STACK_REALIGN_DEFAULT);
    2738              : 
    2739     51049505 :   ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY;
    2740              : 
    2741              :   /* Validate -mincoming-stack-boundary= value or default it to
    2742              :      MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY.  */
    2743     51049505 :   ix86_incoming_stack_boundary = ix86_default_incoming_stack_boundary;
    2744     51049505 :   if (opts_set->x_ix86_incoming_stack_boundary_arg)
    2745              :     {
    2746           15 :       int min = TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 3 : 2;
    2747              : 
    2748           15 :       if (opts->x_ix86_incoming_stack_boundary_arg < min
    2749           15 :           || opts->x_ix86_incoming_stack_boundary_arg > 12)
    2750            0 :         error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
    2751              :                opts->x_ix86_incoming_stack_boundary_arg, min);
    2752              :       else
    2753              :         {
    2754           15 :           ix86_user_incoming_stack_boundary
    2755           15 :             = (1 << opts->x_ix86_incoming_stack_boundary_arg) * BITS_PER_UNIT;
    2756           15 :           ix86_incoming_stack_boundary
    2757           15 :             = ix86_user_incoming_stack_boundary;
    2758              :         }
    2759              :     }
    2760              : 
    2761              : #ifndef NO_PROFILE_COUNTERS
    2762              :   if (flag_nop_mcount)
    2763              :     error ("%<-mnop-mcount%> is not compatible with this target");
    2764              : #endif
    2765     51049505 :   if (flag_nop_mcount && flag_pic && !flag_plt)
    2766            0 :     error ("%<-mnop-mcount%> is not implemented for %<-fno-plt%>");
    2767              : 
    2768              :   /* Accept -msseregparm only if at least SSE support is enabled.  */
    2769     51049505 :   if (TARGET_SSEREGPARM_P (opts->x_target_flags)
    2770            0 :       && ! TARGET_SSE_P (opts->x_ix86_isa_flags))
    2771            0 :     error (main_args_p
    2772              :            ? G_("%<-msseregparm%> used without SSE enabled")
    2773              :            : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
    2774              : 
    2775     51049505 :   if (opts_set->x_ix86_fpmath)
    2776              :     {
    2777      1347809 :       if (opts->x_ix86_fpmath & FPMATH_SSE)
    2778              :         {
    2779      1303968 :           if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
    2780              :             {
    2781        45559 :               if (TARGET_80387_P (opts->x_target_flags))
    2782              :                 {
    2783            0 :                   warning (0, "SSE instruction set disabled, using 387 arithmetics");
    2784            0 :                   opts->x_ix86_fpmath = FPMATH_387;
    2785              :                 }
    2786              :             }
    2787      1258409 :           else if ((opts->x_ix86_fpmath & FPMATH_387)
    2788           90 :                    && !TARGET_80387_P (opts->x_target_flags))
    2789              :             {
    2790            0 :               warning (0, "387 instruction set disabled, using SSE arithmetics");
    2791            0 :               opts->x_ix86_fpmath = FPMATH_SSE;
    2792              :             }
    2793              :         }
    2794        43841 :       else if ((opts->x_ix86_fpmath & FPMATH_387)
    2795        43841 :                && !TARGET_80387_P (opts->x_target_flags)
    2796         1423 :                && TARGET_SSE_P (opts->x_ix86_isa_flags))
    2797              :         {
    2798            1 :           warning (0, "387 instruction set disabled, using SSE arithmetics");
    2799            1 :           opts->x_ix86_fpmath = FPMATH_SSE;
    2800              :         }
    2801              :     }
    2802              :   /* For all chips supporting SSE2, -mfpmath=sse performs better than
    2803              :      fpmath=387.  The second is however default at many targets since the
    2804              :      extra 80bit precision of temporaries is considered to be part of ABI.
    2805              :      Overwrite the default at least for -ffast-math.
    2806              :      TODO: -mfpmath=both seems to produce same performing code with bit
    2807              :      smaller binaries.  It is however not clear if register allocation is
    2808              :      ready for this setting.
    2809              :      Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
    2810              :      codegen.  We may switch to 387 with -ffast-math for size optimized
    2811              :      functions. */
    2812     49701696 :   else if (fast_math_flags_set_p (&global_options)
    2813     49701696 :            && TARGET_SSE2_P (opts->x_ix86_isa_flags))
    2814       951905 :     opts->x_ix86_fpmath = FPMATH_SSE;
    2815              :   else
    2816     51528132 :     opts->x_ix86_fpmath = TARGET_FPMATH_DEFAULT_P (opts->x_ix86_isa_flags);
    2817              : 
    2818              :   /* Use external vectorized library in vectorizing intrinsics.  */
    2819     51049505 :   if (opts_set->x_ix86_veclibabi_type)
    2820            9 :     switch (opts->x_ix86_veclibabi_type)
    2821              :       {
    2822            3 :       case ix86_veclibabi_type_svml:
    2823            3 :         ix86_veclib_handler = &ix86_veclibabi_svml;
    2824            3 :         break;
    2825              : 
    2826            2 :       case ix86_veclibabi_type_acml:
    2827            2 :         ix86_veclib_handler = &ix86_veclibabi_acml;
    2828            2 :         break;
    2829              : 
    2830            1 :       case ix86_veclibabi_type_aocl:
    2831            1 :         ix86_veclib_handler = &ix86_veclibabi_aocl;
    2832            1 :         break;
    2833              : 
    2834            3 :       case ix86_veclibabi_type_hvml:
    2835            3 :         ix86_veclib_handler = &ix86_veclibabi_hvml;
    2836            3 :         break;
    2837              : 
    2838            0 :       default:
    2839            0 :         gcc_unreachable ();
    2840              :       }
    2841              : 
    2842     51049505 :   if (ix86_tune_features [X86_TUNE_ACCUMULATE_OUTGOING_ARGS]
    2843       237459 :       && !(opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
    2844       237459 :     opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
    2845              : 
    2846              :   /* If stack probes are required, the space used for large function
    2847              :      arguments on the stack must also be probed, so enable
    2848              :      -maccumulate-outgoing-args so this happens in the prologue.  */
    2849     51049505 :   if (TARGET_STACK_PROBE_P (opts->x_target_flags)
    2850           22 :       && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
    2851              :     {
    2852           22 :       if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
    2853            0 :         warning (0,
    2854              :                  main_args_p
    2855              :                  ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
    2856              :                       "for correctness")
    2857              :                  : G_("stack probing requires "
    2858              :                       "%<target(\"accumulate-outgoing-args\")%> for "
    2859              :                       "correctness"));
    2860           22 :       opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
    2861              :     }
    2862              : 
    2863              :   /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
    2864              :      so enable -maccumulate-outgoing-args when %ebp is fixed.  */
    2865     51049505 :   if (fixed_regs[BP_REG]
    2866        10228 :       && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
    2867              :     {
    2868            5 :       if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
    2869            2 :         warning (0,
    2870              :                  main_args_p
    2871              :                  ? G_("fixed ebp register requires "
    2872              :                       "%<-maccumulate-outgoing-args%>")
    2873              :                  : G_("fixed ebp register requires "
    2874              :                       "%<target(\"accumulate-outgoing-args\")%>"));
    2875            5 :       opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
    2876              :     }
    2877              : 
    2878              :   /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix.  */
    2879     51049505 :   {
    2880     51049505 :     char *p;
    2881     51049505 :     ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix, "LX", 0);
    2882     51049505 :     p = strchr (internal_label_prefix, 'X');
    2883     51049505 :     internal_label_prefix_len = p - internal_label_prefix;
    2884     51049505 :     *p = '\0';
    2885              :   }
    2886              : 
    2887              :   /* When scheduling description is not available, disable scheduler pass
    2888              :      so it won't slow down the compilation and make x87 code slower.  */
    2889     51049505 :   if (!TARGET_SCHEDULE)
    2890           12 :     opts->x_flag_schedule_insns_after_reload = opts->x_flag_schedule_insns = 0;
    2891              : 
    2892     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_simultaneous_prefetches,
    2893              :                        ix86_tune_cost->simultaneous_prefetches);
    2894     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_line_size,
    2895              :                        ix86_tune_cost->prefetch_block);
    2896     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_size,
    2897              :                        ix86_tune_cost->l1_cache_size);
    2898     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_l2_cache_size,
    2899              :                        ix86_tune_cost->l2_cache_size);
    2900              : 
    2901              :   /* 64B is the accepted value for these for all x86.  */
    2902     51049505 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    2903              :                        param_destruct_interfere_size, 64);
    2904     51049505 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
    2905              :                        param_construct_interfere_size, 64);
    2906              : 
    2907              :   /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful.  */
    2908     51049505 :   if (opts->x_flag_prefetch_loop_arrays < 0
    2909     51049444 :       && HAVE_prefetch
    2910     51049419 :       && (opts->x_optimize >= 3 || opts->x_flag_profile_use)
    2911      2587411 :       && !opts->x_optimize_size
    2912      2587407 :       && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL)
    2913           50 :     opts->x_flag_prefetch_loop_arrays = 1;
    2914              : 
    2915              :   /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
    2916              :      can be opts->x_optimized to ap = __builtin_next_arg (0).  */
    2917     51049505 :   if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && !opts->x_flag_split_stack)
    2918        15596 :     targetm.expand_builtin_va_start = NULL;
    2919              : 
    2920              : #ifdef USE_IX86_CLD
    2921              :   /* Use -mcld by default for 32-bit code if configured with --enable-cld.  */
    2922              :   if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
    2923              :     opts->x_target_flags |= MASK_CLD & ~opts_set->x_target_flags;
    2924              : #endif
    2925              : 
    2926              :   /* Set the default value for -mfentry.  */
    2927     51049505 :   if (!opts_set->x_flag_fentry)
    2928     51049456 :     opts->x_flag_fentry = (TARGET_SEH
    2929     51049456 :                            || (TARGET_64BIT_P (opts->x_ix86_isa_flags)
    2930              :                                && ENABLE_X86_64_MFENTRY));
    2931              :   else
    2932              :     {
    2933           49 :       if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
    2934            0 :           && opts->x_flag_fentry)
    2935            0 :         sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
    2936              :                "with %<-fpic%>");
    2937              :       else if (TARGET_SEH && !opts->x_flag_fentry)
    2938              :         sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
    2939              :     }
    2940              : 
    2941              : #ifdef OPTION_GLIBC_P
    2942              :   /* -mfentry is supported only on glibc targets.  */
    2943     51049505 :   if (!opts->x_flag_fentry
    2944       627643 :       && OPTION_GLIBC_P (opts)
    2945       627643 :       && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
    2946       314481 :       && opts->x_flag_shrink_wrap
    2947       313986 :       && opts->x_profile_flag)
    2948            2 :     warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
    2949              :              "shrink wrapping");
    2950              : #endif
    2951              : 
    2952     51049505 :   if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
    2953              :     sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
    2954              : 
    2955     51049505 :   if (!(opts_set->x_target_flags & MASK_VZEROUPPER)
    2956     50840001 :       && flag_expensive_optimizations
    2957     47117195 :       && !optimize_size)
    2958     46395926 :     opts->x_target_flags |= MASK_VZEROUPPER;
    2959     51049505 :   if (!(opts_set->x_target_flags & MASK_STV))
    2960     51044142 :     opts->x_target_flags |= MASK_STV;
    2961              :   /* Disable STV if -mpreferred-stack-boundary={2,3} or
    2962              :      -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
    2963              :      stack realignment will be extra cost the pass doesn't take into
    2964              :      account and the pass can't realign the stack.  */
    2965     51049505 :   if (ix86_preferred_stack_boundary < 128
    2966     51049497 :       || ix86_incoming_stack_boundary < 128
    2967     51049496 :       || opts->x_ix86_force_align_arg_pointer)
    2968         1659 :     opts->x_target_flags &= ~MASK_STV;
    2969     51049505 :   if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL]
    2970        14947 :       && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD))
    2971        14947 :     opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_LOAD;
    2972     51034558 :   else if (!main_args_p
    2973     50731636 :            && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL])
    2974     50731636 :     opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_LOAD;
    2975              : 
    2976     51049505 :   if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL]
    2977        15703 :       && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_STORE))
    2978        15703 :     opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_STORE;
    2979     51033802 :   else if (!main_args_p
    2980     50730929 :            && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL])
    2981     50730929 :     opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_STORE;
    2982              : 
    2983              :   /* Enable 128-bit AVX instruction generation
    2984              :      for the auto-vectorizer.  */
    2985     51049505 :   if (ix86_tune_features[X86_TUNE_AVX128_OPTIMAL]
    2986          853 :       && (opts_set->x_prefer_vector_width_type == PVW_NONE))
    2987          842 :     opts->x_prefer_vector_width_type = PVW_AVX128;
    2988              : 
    2989              :   /* Use 256-bit AVX instruction generation
    2990              :      in the auto-vectorizer.  */
    2991     51049505 :   if (ix86_tune_features[X86_TUNE_AVX256_OPTIMAL]
    2992       230433 :       && (opts_set->x_prefer_vector_width_type == PVW_NONE))
    2993        95242 :     opts->x_prefer_vector_width_type = PVW_AVX256;
    2994              : 
    2995     51049505 :   if (opts_set->x_ix86_move_max == PVW_NONE)
    2996              :     {
    2997              :       /* Set the maximum number of bits can be moved from memory to
    2998              :          memory efficiently.  */
    2999     51049492 :       if (opts_set->x_prefer_vector_width_type != PVW_NONE)
    3000      1200344 :         opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
    3001     49849148 :       else if (ix86_tune_features[X86_TUNE_AVX512_MOVE_BY_PIECES])
    3002         4715 :         opts->x_ix86_move_max = PVW_AVX512;
    3003     49844433 :       else if (ix86_tune_features[X86_TUNE_AVX256_MOVE_BY_PIECES])
    3004       422108 :         opts->x_ix86_move_max = PVW_AVX256;
    3005              :       else
    3006              :         {
    3007     49422325 :           opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
    3008     49422325 :           if (opts->x_ix86_move_max == PVW_NONE)
    3009              :             {
    3010     49421549 :               if (TARGET_AVX512F_P (opts->x_ix86_isa_flags))
    3011     45442356 :                 opts->x_ix86_move_max = PVW_AVX512;
    3012              :               /* Align with vectorizer to avoid potential STLF issue.  */
    3013      3979193 :               else if (TARGET_AVX_P (opts->x_ix86_isa_flags))
    3014      1356518 :                 opts->x_ix86_move_max = PVW_AVX256;
    3015              :               else
    3016      2622675 :                 opts->x_ix86_move_max = PVW_AVX128;
    3017              :             }
    3018              :         }
    3019              :     }
    3020              : 
    3021     51049505 :   if (opts->x_ix86_recip_name)
    3022              :     {
    3023            0 :       char *p = ASTRDUP (opts->x_ix86_recip_name);
    3024            0 :       char *q;
    3025            0 :       unsigned int mask;
    3026            0 :       bool invert;
    3027              : 
    3028            0 :       while ((q = strtok (p, ",")) != NULL)
    3029              :         {
    3030            0 :           p = NULL;
    3031            0 :           if (*q == '!')
    3032              :             {
    3033            0 :               invert = true;
    3034            0 :               q++;
    3035              :             }
    3036              :           else
    3037              :             invert = false;
    3038              : 
    3039            0 :           if (!strcmp (q, "default"))
    3040              :             mask = RECIP_MASK_ALL;
    3041              :           else
    3042              :             {
    3043            0 :               for (i = 0; i < ARRAY_SIZE (recip_options); i++)
    3044            0 :                 if (!strcmp (q, recip_options[i].string))
    3045              :                   {
    3046            0 :                     mask = recip_options[i].mask;
    3047            0 :                     break;
    3048              :                   }
    3049              : 
    3050            0 :               if (i == ARRAY_SIZE (recip_options))
    3051              :                 {
    3052            0 :                   error ("unknown option for %<-mrecip=%s%>", q);
    3053            0 :                   invert = false;
    3054            0 :                   mask = RECIP_MASK_NONE;
    3055              :                 }
    3056              :             }
    3057              : 
    3058            0 :           opts->x_recip_mask_explicit |= mask;
    3059            0 :           if (invert)
    3060            0 :             opts->x_recip_mask &= ~mask;
    3061              :           else
    3062            0 :             opts->x_recip_mask |= mask;
    3063              :         }
    3064              :     }
    3065              : 
    3066     51049505 :   if (TARGET_RECIP_P (opts->x_target_flags))
    3067        13480 :     opts->x_recip_mask |= RECIP_MASK_ALL & ~opts->x_recip_mask_explicit;
    3068     51036025 :   else if (opts_set->x_target_flags & MASK_RECIP)
    3069            2 :     opts->x_recip_mask &= ~(RECIP_MASK_ALL & ~opts->x_recip_mask_explicit);
    3070              : 
    3071              :   /* Default long double to 64-bit for 32-bit Bionic and to __float128
    3072              :      for 64-bit Bionic.  Also default long double to 64-bit for Intel
    3073              :      MCU psABI.  */
    3074     51049505 :   if ((TARGET_HAS_BIONIC || TARGET_IAMCU)
    3075            8 :       && !(opts_set->x_target_flags
    3076              :            & (MASK_LONG_DOUBLE_64 | MASK_LONG_DOUBLE_128)))
    3077            2 :     opts->x_target_flags |= (TARGET_64BIT
    3078            2 :                              ? MASK_LONG_DOUBLE_128
    3079              :                              : MASK_LONG_DOUBLE_64);
    3080              : 
    3081              :   /* Only one of them can be active.  */
    3082     51049505 :   gcc_assert ((opts->x_target_flags & MASK_LONG_DOUBLE_64) == 0
    3083              :               || (opts->x_target_flags & MASK_LONG_DOUBLE_128) == 0);
    3084              : 
    3085              :   /* Handle stack protector */
    3086     51049505 :   if (!opts_set->x_ix86_stack_protector_guard)
    3087              :     {
    3088              : #ifdef TARGET_THREAD_SSP_OFFSET
    3089     51049467 :       if (!TARGET_HAS_BIONIC)
    3090     51049459 :         opts->x_ix86_stack_protector_guard = SSP_TLS;
    3091              :       else
    3092              : #endif
    3093            8 :         opts->x_ix86_stack_protector_guard = SSP_GLOBAL;
    3094              :     }
    3095              : 
    3096     51049505 :   if (opts_set->x_ix86_stack_protector_guard_offset_str)
    3097              :     {
    3098            1 :       char *endp;
    3099            1 :       const char *str = opts->x_ix86_stack_protector_guard_offset_str;
    3100              : 
    3101            1 :       errno = 0;
    3102            1 :       int64_t offset;
    3103              : 
    3104              : #if defined(INT64_T_IS_LONG)
    3105            1 :       offset = strtol (str, &endp, 0);
    3106              : #else
    3107              :       offset = strtoll (str, &endp, 0);
    3108              : #endif
    3109              : 
    3110            1 :       if (!*str || *endp || errno)
    3111            0 :         error ("%qs is not a valid number "
    3112              :                "in %<-mstack-protector-guard-offset=%>", str);
    3113              : 
    3114            1 :       if (!IN_RANGE (offset, HOST_WIDE_INT_C (-0x80000000),
    3115              :                      HOST_WIDE_INT_C (0x7fffffff)))
    3116            0 :         error ("%qs is not a valid offset "
    3117              :                "in %<-mstack-protector-guard-offset=%>", str);
    3118              : 
    3119            1 :       opts->x_ix86_stack_protector_guard_offset = offset;
    3120              :     }
    3121              : #ifdef TARGET_THREAD_SSP_OFFSET
    3122              :   else
    3123    101471279 :     opts->x_ix86_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET;
    3124              : #endif
    3125              : 
    3126     51049505 :   if (opts_set->x_ix86_stack_protector_guard_reg_str)
    3127              :     {
    3128            2 :       const char *str = opts->x_ix86_stack_protector_guard_reg_str;
    3129            2 :       addr_space_t seg = ADDR_SPACE_GENERIC;
    3130              : 
    3131              :       /* Discard optional register prefix.  */
    3132            2 :       if (str[0] == '%')
    3133            0 :         str++;
    3134              : 
    3135            2 :       if (strlen (str) == 2 && str[1] == 's')
    3136              :         {
    3137            2 :           if (str[0] == 'f')
    3138              :             seg = ADDR_SPACE_SEG_FS;
    3139            2 :           else if (str[0] == 'g')
    3140              :             seg = ADDR_SPACE_SEG_GS;
    3141              :         }
    3142              : 
    3143              :       if (seg == ADDR_SPACE_GENERIC)
    3144            0 :         error ("%qs is not a valid base register "
    3145              :                "in %<-mstack-protector-guard-reg=%>",
    3146              :                opts->x_ix86_stack_protector_guard_reg_str);
    3147              : 
    3148            2 :       opts->x_ix86_stack_protector_guard_reg = seg;
    3149              :     }
    3150              :   else
    3151              :     {
    3152     51049503 :       opts->x_ix86_stack_protector_guard_reg = DEFAULT_TLS_SEG_REG;
    3153              : 
    3154              :       /* The kernel uses a different segment register for performance
    3155              :          reasons; a system call would not have to trash the userspace
    3156              :          segment register, which would be expensive.  */
    3157     51049503 :       if (opts->x_ix86_cmodel == CM_KERNEL)
    3158            1 :         opts->x_ix86_stack_protector_guard_reg = ADDR_SPACE_SEG_GS;
    3159              :     }
    3160              : 
    3161              :   /* Handle -mmemcpy-strategy= and -mmemset-strategy=  */
    3162     51049505 :   if (opts->x_ix86_tune_memcpy_strategy)
    3163              :     {
    3164           18 :       char *str = xstrdup (opts->x_ix86_tune_memcpy_strategy);
    3165           18 :       ix86_parse_stringop_strategy_string (str, false);
    3166           18 :       free (str);
    3167              :     }
    3168              : 
    3169     51049505 :   if (opts->x_ix86_tune_memset_strategy)
    3170              :     {
    3171           34 :       char *str = xstrdup (opts->x_ix86_tune_memset_strategy);
    3172           34 :       ix86_parse_stringop_strategy_string (str, true);
    3173           34 :       free (str);
    3174              :     }
    3175              : 
    3176              :   /* Save the initial options in case the user does function specific
    3177              :      options.  */
    3178     51049505 :   if (main_args_p)
    3179              :     {
    3180       302979 :       opts->x_ix86_excess_precision
    3181       302979 :         = opts->x_flag_excess_precision;
    3182       302979 :       opts->x_ix86_unsafe_math_optimizations
    3183       302979 :         = opts->x_flag_unsafe_math_optimizations;
    3184       605958 :       target_option_default_node = target_option_current_node
    3185       302979 :         = build_target_option_node (opts, opts_set);
    3186              :     }
    3187              : 
    3188     51049505 :   const bool cf_okay_p = (TARGET_64BIT || TARGET_CMOV);
    3189              :   /* When -fhardened, enable -fcf-protection=full, but only when it's
    3190              :      compatible with this target, and when it wasn't already specified
    3191              :      on the command line.  */
    3192     51049505 :   if (opts->x_flag_hardened && cf_okay_p)
    3193              :     {
    3194           92 :       if (!opts_set->x_flag_cf_protection)
    3195           91 :         opts->x_flag_cf_protection = CF_FULL;
    3196            1 :       else if (opts->x_flag_cf_protection != CF_FULL)
    3197            1 :         warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    3198              :                     "%<-fcf-protection=full%> is not enabled by "
    3199              :                     "%<-fhardened%> because it was specified on the command "
    3200              :                     "line");
    3201              :     }
    3202              : 
    3203     51049505 :   if (opts->x_flag_cf_protection != CF_NONE)
    3204              :     {
    3205        42739 :       if ((opts->x_flag_cf_protection & CF_BRANCH) == CF_BRANCH
    3206        42604 :           && !cf_okay_p)
    3207            0 :         error ("%<-fcf-protection%> is not compatible with this target");
    3208              : 
    3209        42739 :       opts->x_flag_cf_protection
    3210        42739 :       = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
    3211              :     }
    3212              : 
    3213     51049505 :   if (ix86_tune_features [X86_TUNE_AVOID_512FMA_CHAINS])
    3214          115 :     SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 512);
    3215     51049390 :   else if (ix86_tune_features [X86_TUNE_AVOID_256FMA_CHAINS])
    3216     50276262 :     SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 256);
    3217       773128 :   else if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
    3218          116 :     SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 128);
    3219              : 
    3220              :   /* PR86952: jump table usage with retpolines is slow.
    3221              :      The PR provides some numbers about the slowness.  */
    3222     51049505 :   if (ix86_indirect_branch != indirect_branch_keep)
    3223           50 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_jump_tables, 0);
    3224              : 
    3225     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_ira_consider_dup_in_all_alts, 0);
    3226              : 
    3227              :   /* Fully masking the main or the epilogue vectorized loop is not
    3228              :      profitable generally so leave it disabled until we get more
    3229              :      fine grained control & costing.  */
    3230     51049505 :   SET_OPTION_IF_UNSET (opts, opts_set, param_vect_partial_vector_usage, 0);
    3231              : 
    3232              :   return true;
    3233              : }
    3234              : 
    3235              : /* Implement the TARGET_OPTION_OVERRIDE hook.  */
    3236              : 
    3237              : void
    3238       302980 : ix86_option_override (void)
    3239              : {
    3240       302980 :   ix86_option_override_internal (true, &global_options, &global_options_set);
    3241       302980 : }
    3242              : 
    3243              : /* Remember the last target of ix86_set_current_function.  */
    3244              : static GTY(()) tree ix86_previous_fndecl;
    3245              : 
    3246              : /* Set targets globals to the default (or current #pragma GCC target
    3247              :    if active).  Invalidate ix86_previous_fndecl cache.  */
    3248              : 
    3249              : void
    3250      2396977 : ix86_reset_previous_fndecl (void)
    3251              : {
    3252      2396977 :   tree new_tree = target_option_current_node;
    3253      2396977 :   cl_target_option_restore (&global_options, &global_options_set,
    3254      2396977 :                             TREE_TARGET_OPTION (new_tree));
    3255      2396977 :   if (TREE_TARGET_GLOBALS (new_tree))
    3256       591378 :     restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
    3257      1805599 :   else if (new_tree == target_option_default_node)
    3258      1308006 :     restore_target_globals (&default_target_globals);
    3259              :   else
    3260       497593 :     TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
    3261      2396977 :   ix86_previous_fndecl = NULL_TREE;
    3262      2396977 : }
    3263              : 
    3264              : /* Add target attribute to SIMD clone NODE if needed.  */
    3265              : 
    3266              : void
    3267         7421 : ix86_simd_clone_adjust (struct cgraph_node *node)
    3268              : {
    3269         7421 :   const char *str = NULL;
    3270              : 
    3271              :   /* Attributes need to be adjusted for definitions, not declarations.  */
    3272         7421 :   if (!node->definition)
    3273              :     return;
    3274              : 
    3275         4521 :   gcc_assert (node->decl == cfun->decl);
    3276         4521 :   switch (node->simdclone->vecsize_mangle)
    3277              :     {
    3278         1128 :     case 'b':
    3279         1128 :       if (!TARGET_SSE2)
    3280              :         str = "sse2";
    3281              :       break;
    3282         1188 :     case 'c':
    3283         1188 :       if (TARGET_PREFER_AVX128)
    3284              :         {
    3285            1 :           if (!TARGET_AVX)
    3286              :             str = "avx,prefer-vector-width=256";
    3287              :           else
    3288              :             str = "prefer-vector-width=256";
    3289              :         }
    3290         1187 :       else if (!TARGET_AVX)
    3291              :         str = "avx";
    3292              :       break;
    3293         1103 :     case 'd':
    3294         1103 :       if (TARGET_PREFER_AVX128)
    3295              :         {
    3296            1 :           if (!TARGET_AVX2)
    3297              :             str = "avx2,prefer-vector-width=256";
    3298              :           else
    3299              :             str = "prefer-vector-width=256";
    3300              :         }
    3301         1102 :       else if (!TARGET_AVX2)
    3302              :         str = "avx2";
    3303              :       break;
    3304         1102 :     case 'e':
    3305         1102 :       if (TARGET_PREFER_AVX256)
    3306              :         {
    3307            4 :           if (!TARGET_AVX512F)
    3308              :             str = "avx512f,prefer-vector-width=512";
    3309              :           else
    3310            2 :             str = "prefer-vector-width=512";
    3311              :         }
    3312         1098 :       else if (!TARGET_AVX512F)
    3313              :         str = "avx512f";
    3314              :       break;
    3315            0 :     default:
    3316            0 :       gcc_unreachable ();
    3317              :     }
    3318            2 :   if (str == NULL)
    3319              :     return;
    3320         2895 :   push_cfun (NULL);
    3321         2895 :   tree args = build_tree_list (NULL_TREE, build_string (strlen (str), str));
    3322         2895 :   bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0);
    3323         2895 :   gcc_assert (ok);
    3324         2895 :   pop_cfun ();
    3325         2895 :   ix86_reset_previous_fndecl ();
    3326         2895 :   ix86_set_current_function (node->decl);
    3327              : }
    3328              : 
    3329              : /* Return the call_saved_registers_type for function type FNTYPE.
    3330              :    If LOC is nonnull, report incompatible attributes against that
    3331              :    location, otherwise remain silent.  */
    3332              : 
    3333              : call_saved_registers_type
    3334    586737805 : ix86_fntype_call_saved_registers (const_tree fntype, location_t *loc)
    3335              : {
    3336    586737805 :   auto call_saved_registers = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
    3337    586737805 :   const char *interrupt_conflict = nullptr;
    3338    586737805 :   if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (fntype)))
    3339              :     {
    3340              :       call_saved_registers = TYPE_PRESERVE_NONE;
    3341              :       interrupt_conflict = "preserve_none";
    3342              :     }
    3343    586735799 :   else if (lookup_attribute ("no_callee_saved_registers",
    3344    586735799 :                              TYPE_ATTRIBUTES (fntype)))
    3345              :     {
    3346              :       call_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
    3347              :       interrupt_conflict = "no_callee_saved_registers";
    3348              :     }
    3349    586734643 :   else if (lookup_attribute ("no_caller_saved_registers",
    3350    586734643 :                              TYPE_ATTRIBUTES (fntype)))
    3351         3080 :     call_saved_registers = TYPE_NO_CALLER_SAVED_REGISTERS;
    3352              : 
    3353    586737805 :   if (lookup_attribute ("interrupt", TYPE_ATTRIBUTES (fntype)))
    3354              :     {
    3355          281 :       if (loc && interrupt_conflict)
    3356            2 :         error_at (*loc, "%qs and %qs attributes are not compatible",
    3357              :                   "interrupt", interrupt_conflict);
    3358              :       return TYPE_NO_CALLER_SAVED_REGISTERS;
    3359              :     }
    3360              : 
    3361              :   return call_saved_registers;
    3362              : }
    3363              : 
    3364              : /* Set the func_type field from the function FNDECL.  */
    3365              : 
    3366              : static void
    3367    410059702 : ix86_set_func_type (tree fndecl)
    3368              : {
    3369    410059702 :   if (cfun->machine->func_type != TYPE_UNKNOWN)
    3370              :     return;
    3371              : 
    3372    411666922 :   cfun->machine->call_saved_registers
    3373    205833461 :     = ix86_fntype_call_saved_registers (TREE_TYPE (fndecl),
    3374    205833461 :                                         &DECL_SOURCE_LOCATION (fndecl));
    3375              : 
    3376              :   /* No need to save and restore callee-saved registers for a noreturn
    3377              :      function with nothrow or compiled with -fno-exceptions unless when
    3378              :      compiling with -O0 or -Og, except that it interferes with debugging
    3379              :      of callers.  So that backtrace works for those at least
    3380              :      in most cases, save the bp register if it is used, because it often
    3381              :      is used in callers to compute CFA.
    3382              : 
    3383              :      NB: Can't use just TREE_THIS_VOLATILE to check if this is a noreturn
    3384              :      function.  The local-pure-const pass turns an interrupt function
    3385              :      into a noreturn function by setting TREE_THIS_VOLATILE.  Normally
    3386              :      the local-pure-const pass is run after ix86_set_func_type is called.
    3387              :      When the local-pure-const pass is enabled for LTO, the interrupt
    3388              :      function is marked with TREE_THIS_VOLATILE in the IR output, which
    3389              :      leads to the incompatible attribute error in LTO1.  Ignore the
    3390              :      interrupt function in this case.  */
    3391    205833461 :   if (cfun->machine->call_saved_registers == TYPE_DEFAULT_CALL_SAVED_REGISTERS
    3392    205833158 :       && ix86_noreturn_no_callee_saved_registers
    3393           11 :       && TREE_THIS_VOLATILE (fndecl)
    3394           11 :       && optimize
    3395           10 :       && !optimize_debug
    3396            9 :       && (TREE_NOTHROW (fndecl) || !flag_exceptions))
    3397            9 :     cfun->machine->call_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
    3398              : 
    3399    205833461 :   if (lookup_attribute ("interrupt",
    3400    205833461 :                         TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
    3401              :     {
    3402          154 :       if (ix86_function_naked (fndecl))
    3403            1 :         error_at (DECL_SOURCE_LOCATION (fndecl),
    3404              :                   "interrupt and naked attributes are not compatible");
    3405              : 
    3406          154 :       int nargs = 0;
    3407          154 :       for (tree arg = DECL_ARGUMENTS (fndecl);
    3408          389 :            arg;
    3409          235 :            arg = TREE_CHAIN (arg))
    3410          235 :         nargs++;
    3411          154 :       cfun->machine->func_type = nargs == 2 ? TYPE_EXCEPTION : TYPE_INTERRUPT;
    3412              : 
    3413          154 :       ix86_optimize_mode_switching[X86_DIRFLAG] = 1;
    3414              : 
    3415              :       /* Only dwarf2out.cc can handle -WORD(AP) as a pointer argument.  */
    3416          154 :       if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
    3417            0 :         sorry ("only DWARF debug format is supported for interrupt "
    3418              :                "service routine");
    3419              :     }
    3420              :   else
    3421    205833307 :     cfun->machine->func_type = TYPE_NORMAL;
    3422              : }
    3423              : 
    3424              : /* Set the indirect_branch_type field from the function FNDECL.  */
    3425              : 
    3426              : static void
    3427    410059702 : ix86_set_indirect_branch_type (tree fndecl)
    3428              : {
    3429    410059702 :   if (cfun->machine->indirect_branch_type == indirect_branch_unset)
    3430              :     {
    3431    205833461 :       tree attr = lookup_attribute ("indirect_branch",
    3432    205833461 :                                     DECL_ATTRIBUTES (fndecl));
    3433    205833461 :       if (attr != NULL)
    3434              :         {
    3435           17 :           tree args = TREE_VALUE (attr);
    3436           17 :           if (args == NULL)
    3437            0 :             gcc_unreachable ();
    3438           17 :           tree cst = TREE_VALUE (args);
    3439           17 :           if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
    3440            2 :             cfun->machine->indirect_branch_type = indirect_branch_keep;
    3441           15 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
    3442            5 :             cfun->machine->indirect_branch_type = indirect_branch_thunk;
    3443           10 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
    3444            3 :             cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
    3445            7 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
    3446            7 :             cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
    3447              :           else
    3448            0 :             gcc_unreachable ();
    3449              :         }
    3450              :       else
    3451    205833444 :         cfun->machine->indirect_branch_type = ix86_indirect_branch;
    3452              : 
    3453              :       /* -mcmodel=large is not compatible with -mindirect-branch=thunk
    3454              :          nor -mindirect-branch=thunk-extern.  */
    3455    205833461 :       if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
    3456         7672 :           && ((cfun->machine->indirect_branch_type
    3457         7672 :                == indirect_branch_thunk_extern)
    3458         7670 :               || (cfun->machine->indirect_branch_type
    3459              :                   == indirect_branch_thunk)))
    3460            6 :         error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
    3461              :                "compatible",
    3462              :                ((cfun->machine->indirect_branch_type
    3463              :                  == indirect_branch_thunk_extern)
    3464              :                 ? "thunk-extern" : "thunk"));
    3465              : 
    3466    205833461 :       if (cfun->machine->indirect_branch_type != indirect_branch_keep
    3467           80 :           && (cfun->machine->indirect_branch_type
    3468              :               != indirect_branch_thunk_extern)
    3469           52 :           && (flag_cf_protection & CF_RETURN))
    3470            3 :         error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
    3471              :                "compatible");
    3472              :     }
    3473              : 
    3474    410059702 :   if (cfun->machine->function_return_type == indirect_branch_unset)
    3475              :     {
    3476    205833461 :       tree attr = lookup_attribute ("function_return",
    3477    205833461 :                                     DECL_ATTRIBUTES (fndecl));
    3478    205833461 :       if (attr != NULL)
    3479              :         {
    3480           12 :           tree args = TREE_VALUE (attr);
    3481           12 :           if (args == NULL)
    3482            0 :             gcc_unreachable ();
    3483           12 :           tree cst = TREE_VALUE (args);
    3484           12 :           if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
    3485            2 :             cfun->machine->function_return_type = indirect_branch_keep;
    3486           10 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
    3487            4 :             cfun->machine->function_return_type = indirect_branch_thunk;
    3488            6 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
    3489            3 :             cfun->machine->function_return_type = indirect_branch_thunk_inline;
    3490            3 :           else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
    3491            3 :             cfun->machine->function_return_type = indirect_branch_thunk_extern;
    3492              :           else
    3493            0 :             gcc_unreachable ();
    3494              :         }
    3495              :       else
    3496    205833449 :         cfun->machine->function_return_type = ix86_function_return;
    3497              : 
    3498              :       /* -mcmodel=large is not compatible with -mfunction-return=thunk
    3499              :          nor -mfunction-return=thunk-extern.  */
    3500    205833461 :       if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
    3501         7672 :           && ((cfun->machine->function_return_type
    3502         7672 :                == indirect_branch_thunk_extern)
    3503         7670 :               || (cfun->machine->function_return_type
    3504              :                   == indirect_branch_thunk)))
    3505            6 :         error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
    3506              :                "compatible",
    3507              :                ((cfun->machine->function_return_type
    3508              :                  == indirect_branch_thunk_extern)
    3509              :                 ? "thunk-extern" : "thunk"));
    3510              : 
    3511    205833461 :       if (cfun->machine->function_return_type != indirect_branch_keep
    3512           32 :           && (cfun->machine->function_return_type
    3513              :               != indirect_branch_thunk_extern)
    3514           24 :           && (flag_cf_protection & CF_RETURN))
    3515            3 :         error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
    3516              :                "compatible");
    3517              :     }
    3518    410059702 : }
    3519              : 
    3520              : /* Establish appropriate back-end context for processing the function
    3521              :    FNDECL.  The argument might be NULL to indicate processing at top
    3522              :    level, outside of any function scope.  */
    3523              : void
    3524    814444705 : ix86_set_current_function (tree fndecl)
    3525              : {
    3526              :   /* Only change the context if the function changes.  This hook is called
    3527              :      several times in the course of compiling a function, and we don't want to
    3528              :      slow things down too much or call target_reinit when it isn't safe.  */
    3529    814444705 :   if (fndecl == ix86_previous_fndecl)
    3530              :     {
    3531              :       /* There may be 2 function bodies for the same function FNDECL,
    3532              :          one is extern inline and one isn't.  Call ix86_set_func_type
    3533              :          to set the func_type field.  */
    3534     94839320 :       if (fndecl != NULL_TREE)
    3535              :         {
    3536     94839267 :           ix86_set_func_type (fndecl);
    3537     94839267 :           ix86_set_indirect_branch_type (fndecl);
    3538              :         }
    3539              :       return;
    3540              :     }
    3541              : 
    3542    719605385 :   tree old_tree;
    3543    719605385 :   if (ix86_previous_fndecl == NULL_TREE)
    3544      2075627 :     old_tree = target_option_current_node;
    3545    717529758 :   else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl))
    3546              :     old_tree = DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl);
    3547              :   else
    3548    656017342 :     old_tree = target_option_default_node;
    3549              : 
    3550    719605385 :   if (fndecl == NULL_TREE)
    3551              :     {
    3552    404384950 :       if (old_tree != target_option_current_node)
    3553      1247985 :         ix86_reset_previous_fndecl ();
    3554              :       return;
    3555              :     }
    3556              : 
    3557    315220435 :   ix86_set_func_type (fndecl);
    3558    315220435 :   ix86_set_indirect_branch_type (fndecl);
    3559              : 
    3560    315220435 :   tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
    3561    315220435 :   if (new_tree == NULL_TREE)
    3562    283826149 :     new_tree = target_option_default_node;
    3563              : 
    3564    315220435 :   bool fp_flag_change
    3565    315220435 :     = (flag_unsafe_math_optimizations
    3566    315220435 :        != TREE_TARGET_OPTION (new_tree)->x_ix86_unsafe_math_optimizations
    3567    315220435 :        || (flag_excess_precision
    3568    315220322 :            != TREE_TARGET_OPTION (new_tree)->x_ix86_excess_precision));
    3569    315220435 :   if (old_tree != new_tree || fp_flag_change)
    3570              :     {
    3571      1248060 :       cl_target_option_restore (&global_options, &global_options_set,
    3572      1248060 :                                 TREE_TARGET_OPTION (new_tree));
    3573      1248060 :       if (fp_flag_change)
    3574              :         {
    3575          113 :           ix86_excess_precision = flag_excess_precision;
    3576          113 :           ix86_unsafe_math_optimizations = flag_unsafe_math_optimizations;
    3577          113 :           DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_tree
    3578          113 :             = build_target_option_node (&global_options, &global_options_set);
    3579              :         }
    3580      1248060 :       if (TREE_TARGET_GLOBALS (new_tree))
    3581      1209927 :         restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
    3582        38133 :       else if (new_tree == target_option_default_node)
    3583        20542 :         restore_target_globals (&default_target_globals);
    3584              :       else
    3585        17591 :         TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
    3586              :     }
    3587    315220435 :   ix86_previous_fndecl = fndecl;
    3588              : 
    3589    315220435 :   if (cfun->machine->func_type != TYPE_NORMAL
    3590    315216295 :       || (cfun->machine->call_saved_registers
    3591    315216295 :           == TYPE_NO_CALLER_SAVED_REGISTERS))
    3592              :     {
    3593              :       /* Don't allow AVX, AVX512, MMX nor x87 instructions since they
    3594              :          may change processor state.  Don't allow SSE instructions in
    3595              :          exception/interrupt service routines.  */
    3596         5430 :       const char *isa;
    3597         5430 :       if (TARGET_SSE)
    3598              :         {
    3599          470 :           if (TARGET_AVX512F)
    3600              :             isa = "AVX512";
    3601          470 :           else if (TARGET_AVX)
    3602              :             isa = "AVX";
    3603          470 :           else if (cfun->machine->func_type != TYPE_NORMAL)
    3604              :             isa = "SSE";
    3605          469 :           else if (TARGET_MMX)
    3606              :             isa = "MMX/3Dnow";
    3607          468 :           else if (TARGET_80387)
    3608              :             isa = "80387";
    3609              :           else
    3610              :             isa = NULL;
    3611              :         }
    3612         4960 :       else if (TARGET_MMX)
    3613              :         isa = "MMX/3Dnow";
    3614         4957 :       else if (TARGET_80387)
    3615              :         isa = "80387";
    3616              :       else
    3617              :         isa = NULL;
    3618              :       if (isa != NULL)
    3619              :         {
    3620            9 :           if (cfun->machine->func_type != TYPE_NORMAL)
    3621            7 :             sorry (cfun->machine->func_type == TYPE_EXCEPTION
    3622              :                    ? G_("%s instructions aren%'t allowed in an"
    3623              :                         " exception service routine")
    3624              :                    : G_("%s instructions aren%'t allowed in an"
    3625              :                         " interrupt service routine"),
    3626              :                    isa);
    3627              :           else
    3628            4 :             sorry ("%s instructions aren%'t allowed in a function with "
    3629              :                    "the %<no_caller_saved_registers%> attribute", isa);
    3630              :           /* Don't issue the same error twice.  */
    3631            9 :           cfun->machine->func_type = TYPE_NORMAL;
    3632            9 :           cfun->machine->call_saved_registers
    3633            9 :             = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
    3634              :         }
    3635              :     }
    3636              : }
    3637              : 
    3638              : /* Implement the TARGET_OFFLOAD_OPTIONS hook.  */
    3639              : char *
    3640            0 : ix86_offload_options (void)
    3641              : {
    3642            0 :   if (TARGET_LP64)
    3643            0 :     return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-m64");
    3644            0 :   return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-m32");
    3645              : }
    3646              : 
    3647              : /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
    3648              :    and "sseregparm" calling convention attributes;
    3649              :    arguments as in struct attribute_spec.handler.  */
    3650              : 
    3651              : static tree
    3652        11867 : ix86_handle_cconv_attribute (tree *node, tree name, tree args, int,
    3653              :                              bool *no_add_attrs)
    3654              : {
    3655        11867 :   if (TREE_CODE (*node) != FUNCTION_TYPE
    3656        11867 :       && TREE_CODE (*node) != METHOD_TYPE
    3657              :       && TREE_CODE (*node) != FIELD_DECL
    3658              :       && TREE_CODE (*node) != TYPE_DECL)
    3659              :     {
    3660            0 :       warning (OPT_Wattributes, "%qE attribute only applies to functions",
    3661              :                name);
    3662            0 :       *no_add_attrs = true;
    3663            0 :       return NULL_TREE;
    3664              :     }
    3665              : 
    3666        11867 :   if (TARGET_64BIT)
    3667              :     {
    3668              :       /* Do not warn when emulating the MS ABI.  */
    3669          791 :       if ((TREE_CODE (*node) != FUNCTION_TYPE
    3670              :            && TREE_CODE (*node) != METHOD_TYPE)
    3671          791 :           || ix86_function_type_abi (*node) != MS_ABI)
    3672          788 :         warning (OPT_Wattributes, "%qE attribute ignored",
    3673              :                  name);
    3674          791 :       *no_add_attrs = true;
    3675          791 :       return NULL_TREE;
    3676              :     }
    3677              : 
    3678              :   /* Can combine regparm with all attributes but fastcall, and thiscall.  */
    3679        11076 :   if (is_attribute_p ("regparm", name))
    3680              :     {
    3681        11074 :       tree cst;
    3682              : 
    3683        11074 :       if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
    3684              :         {
    3685            0 :           error ("fastcall and regparm attributes are not compatible");
    3686              :         }
    3687              : 
    3688        11074 :       if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
    3689              :         {
    3690            0 :           error ("regparm and thiscall attributes are not compatible");
    3691              :         }
    3692              : 
    3693        11074 :       cst = TREE_VALUE (args);
    3694        11074 :       if (TREE_CODE (cst) != INTEGER_CST)
    3695              :         {
    3696            0 :           warning (OPT_Wattributes,
    3697              :                    "%qE attribute requires an integer constant argument",
    3698              :                    name);
    3699            0 :           *no_add_attrs = true;
    3700              :         }
    3701        11074 :       else if (compare_tree_int (cst, REGPARM_MAX) > 0)
    3702              :         {
    3703            0 :           warning (OPT_Wattributes, "argument to %qE attribute larger than %d",
    3704            0 :                    name, REGPARM_MAX);
    3705            0 :           *no_add_attrs = true;
    3706              :         }
    3707              : 
    3708              :       return NULL_TREE;
    3709              :     }
    3710              : 
    3711              :   /* Can combine fastcall with sseregparm.  */
    3712            2 :   if (is_attribute_p ("fastcall", name))
    3713              :     {
    3714            2 :       if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
    3715              :         {
    3716            0 :           error ("fastcall and cdecl attributes are not compatible");
    3717              :         }
    3718            2 :       if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
    3719              :         {
    3720            0 :           error ("fastcall and stdcall attributes are not compatible");
    3721              :         }
    3722            2 :       if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
    3723              :         {
    3724            0 :           error ("fastcall and regparm attributes are not compatible");
    3725              :         }
    3726            2 :       if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
    3727              :         {
    3728            0 :           error ("fastcall and thiscall attributes are not compatible");
    3729              :         }
    3730              :     }
    3731              : 
    3732              :   /* Can combine stdcall with regparm and sseregparm.  */
    3733            0 :   else if (is_attribute_p ("stdcall", name))
    3734              :     {
    3735            0 :       if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
    3736              :         {
    3737            0 :           error ("stdcall and cdecl attributes are not compatible");
    3738              :         }
    3739            0 :       if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
    3740              :         {
    3741            0 :           error ("stdcall and fastcall attributes are not compatible");
    3742              :         }
    3743            0 :       if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
    3744              :         {
    3745            0 :           error ("stdcall and thiscall attributes are not compatible");
    3746              :         }
    3747              :     }
    3748              : 
    3749              :   /* Can combine cdecl with regparm and sseregparm.  */
    3750            0 :   else if (is_attribute_p ("cdecl", name))
    3751              :     {
    3752            0 :       if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
    3753              :         {
    3754            0 :           error ("stdcall and cdecl attributes are not compatible");
    3755              :         }
    3756            0 :       if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
    3757              :         {
    3758            0 :           error ("fastcall and cdecl attributes are not compatible");
    3759              :         }
    3760            0 :       if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
    3761              :         {
    3762            0 :           error ("cdecl and thiscall attributes are not compatible");
    3763              :         }
    3764              :     }
    3765            0 :   else if (is_attribute_p ("thiscall", name))
    3766              :     {
    3767            0 :       if (TREE_CODE (*node) != METHOD_TYPE && pedantic)
    3768            0 :         warning (OPT_Wattributes, "%qE attribute is used for non-class method",
    3769              :                  name);
    3770            0 :       if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
    3771              :         {
    3772            0 :           error ("stdcall and thiscall attributes are not compatible");
    3773              :         }
    3774            0 :       if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
    3775              :         {
    3776            0 :           error ("fastcall and thiscall attributes are not compatible");
    3777              :         }
    3778            0 :       if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
    3779              :         {
    3780            0 :           error ("cdecl and thiscall attributes are not compatible");
    3781              :         }
    3782            0 :       if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
    3783              :         {
    3784            0 :           error ("regparm and thiscall attributes are not compatible");
    3785              :         }
    3786              :     }
    3787              : 
    3788              :   /* Can combine sseregparm with all attributes.  */
    3789              : 
    3790              :   return NULL_TREE;
    3791              : }
    3792              : 
    3793              : #ifndef CHECK_STACK_LIMIT
    3794              : #define CHECK_STACK_LIMIT (-1)
    3795              : #endif
    3796              : 
    3797              : /* The transactional memory builtins are implicitly regparm or fastcall
    3798              :    depending on the ABI.  Override the generic do-nothing attribute that
    3799              :    these builtins were declared with, and replace it with one of the two
    3800              :    attributes that we expect elsewhere.  */
    3801              : 
    3802              : static tree
    3803        35604 : ix86_handle_tm_regparm_attribute (tree *node, tree, tree,
    3804              :                                   int flags, bool *no_add_attrs)
    3805              : {
    3806        35604 :   tree alt;
    3807              : 
    3808              :   /* In no case do we want to add the placeholder attribute.  */
    3809        35604 :   *no_add_attrs = true;
    3810              : 
    3811              :   /* The 64-bit ABI is unchanged for transactional memory.  */
    3812        35604 :   if (TARGET_64BIT)
    3813              :     return NULL_TREE;
    3814              : 
    3815              :   /* ??? Is there a better way to validate 32-bit windows?  We have
    3816              :      cfun->machine->call_abi, but that seems to be set only for 64-bit.  */
    3817            0 :   if (CHECK_STACK_LIMIT > 0)
    3818              :     alt = tree_cons (get_identifier ("fastcall"), NULL, NULL);
    3819              :   else
    3820              :     {
    3821            0 :       alt = tree_cons (NULL, build_int_cst (integer_type_node, 2), NULL);
    3822            0 :       alt = tree_cons (get_identifier ("regparm"), alt, NULL);
    3823              :     }
    3824            0 :   decl_attributes (node, alt, flags);
    3825              : 
    3826            0 :   return NULL_TREE;
    3827              : }
    3828              : 
    3829              : /* Handle a "force_align_arg_pointer" attribute.  */
    3830              : 
    3831              : static tree
    3832         5131 : ix86_handle_force_align_arg_pointer_attribute (tree *node, tree name,
    3833              :                                                tree, int, bool *no_add_attrs)
    3834              : {
    3835         5131 :   if (TREE_CODE (*node) != FUNCTION_TYPE
    3836         5131 :       && TREE_CODE (*node) != METHOD_TYPE
    3837              :       && TREE_CODE (*node) != FIELD_DECL
    3838              :       && TREE_CODE (*node) != TYPE_DECL)
    3839              :     {
    3840            0 :       warning (OPT_Wattributes, "%qE attribute only applies to functions",
    3841              :                name);
    3842            0 :       *no_add_attrs = true;
    3843              :     }
    3844              : 
    3845         5131 :   return NULL_TREE;
    3846              : }
    3847              : 
    3848              : /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
    3849              :    struct attribute_spec.handler.  */
    3850              : 
    3851              : static tree
    3852           74 : ix86_handle_struct_attribute (tree *node, tree name, tree, int,
    3853              :                               bool *no_add_attrs)
    3854              : {
    3855           74 :   tree *type = NULL;
    3856           74 :   if (DECL_P (*node))
    3857              :     {
    3858            0 :       if (TREE_CODE (*node) == TYPE_DECL)
    3859            0 :         type = &TREE_TYPE (*node);
    3860              :     }
    3861              :   else
    3862              :     type = node;
    3863              : 
    3864           74 :   if (!(type && RECORD_OR_UNION_TYPE_P (*type)))
    3865              :     {
    3866            0 :       warning (OPT_Wattributes, "%qE attribute ignored",
    3867              :                name);
    3868            0 :       *no_add_attrs = true;
    3869              :     }
    3870              : 
    3871           74 :   else if ((is_attribute_p ("ms_struct", name)
    3872           62 :             && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type)))
    3873          136 :            || ((is_attribute_p ("gcc_struct", name)
    3874           12 :                 && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type)))))
    3875              :     {
    3876            0 :       warning (OPT_Wattributes, "%qE incompatible attribute ignored",
    3877              :                name);
    3878            0 :       *no_add_attrs = true;
    3879              :     }
    3880              : 
    3881           74 :   return NULL_TREE;
    3882              : }
    3883              : 
    3884              : /* Handle a "callee_pop_aggregate_return" attribute; arguments as
    3885              :    in struct attribute_spec handler.  */
    3886              : 
    3887              : static tree
    3888            0 : ix86_handle_callee_pop_aggregate_return (tree *node, tree name, tree args, int,
    3889              :                                          bool *no_add_attrs)
    3890              : {
    3891            0 :   if (TREE_CODE (*node) != FUNCTION_TYPE
    3892            0 :       && TREE_CODE (*node) != METHOD_TYPE
    3893              :       && TREE_CODE (*node) != FIELD_DECL
    3894              :       && TREE_CODE (*node) != TYPE_DECL)
    3895              :     {
    3896            0 :       warning (OPT_Wattributes, "%qE attribute only applies to functions",
    3897              :                name);
    3898            0 :       *no_add_attrs = true;
    3899            0 :       return NULL_TREE;
    3900              :     }
    3901            0 :   if (TARGET_64BIT)
    3902              :     {
    3903            0 :       warning (OPT_Wattributes, "%qE attribute only available for 32-bit",
    3904              :                name);
    3905            0 :       *no_add_attrs = true;
    3906            0 :       return NULL_TREE;
    3907              :     }
    3908            0 :   if (is_attribute_p ("callee_pop_aggregate_return", name))
    3909              :     {
    3910            0 :       tree cst;
    3911              : 
    3912            0 :       cst = TREE_VALUE (args);
    3913            0 :       if (TREE_CODE (cst) != INTEGER_CST)
    3914              :         {
    3915            0 :           warning (OPT_Wattributes,
    3916              :                    "%qE attribute requires an integer constant argument",
    3917              :                    name);
    3918            0 :           *no_add_attrs = true;
    3919              :         }
    3920            0 :       else if (compare_tree_int (cst, 0) != 0
    3921            0 :                && compare_tree_int (cst, 1) != 0)
    3922              :         {
    3923            0 :           warning (OPT_Wattributes,
    3924              :                    "argument to %qE attribute is neither zero, nor one",
    3925              :                    name);
    3926            0 :           *no_add_attrs = true;
    3927              :         }
    3928              : 
    3929              :       return NULL_TREE;
    3930              :     }
    3931              : 
    3932              :   return NULL_TREE;
    3933              : }
    3934              : 
    3935              : /* Handle a "ms_abi" or "sysv" attribute; arguments as in
    3936              :    struct attribute_spec.handler.  */
    3937              : 
    3938              : static tree
    3939      1691795 : ix86_handle_abi_attribute (tree *node, tree name, tree, int,
    3940              :                            bool *no_add_attrs)
    3941              : {
    3942      1691795 :   if (TREE_CODE (*node) != FUNCTION_TYPE
    3943      1691795 :       && TREE_CODE (*node) != METHOD_TYPE
    3944              :       && TREE_CODE (*node) != FIELD_DECL
    3945              :       && TREE_CODE (*node) != TYPE_DECL)
    3946              :     {
    3947            0 :       warning (OPT_Wattributes, "%qE attribute only applies to functions",
    3948              :                name);
    3949            0 :       *no_add_attrs = true;
    3950            0 :       return NULL_TREE;
    3951              :     }
    3952              : 
    3953              :   /* Can combine regparm with all attributes but fastcall.  */
    3954      1691795 :   if (is_attribute_p ("ms_abi", name))
    3955              :     {
    3956       866153 :       if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node)))
    3957              :         {
    3958            0 :           error ("%qs and %qs attributes are not compatible",
    3959              :                  "ms_abi", "sysv_abi");
    3960              :         }
    3961              : 
    3962              :       return NULL_TREE;
    3963              :     }
    3964       825642 :   else if (is_attribute_p ("sysv_abi", name))
    3965              :     {
    3966       825642 :       if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node)))
    3967              :         {
    3968            0 :           error ("%qs and %qs attributes are not compatible",
    3969              :                  "ms_abi", "sysv_abi");
    3970              :         }
    3971              : 
    3972              :       return NULL_TREE;
    3973              :     }
    3974              : 
    3975              :   return NULL_TREE;
    3976              : }
    3977              : 
    3978              : static tree
    3979          127 : ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
    3980              :                               bool *no_add_attrs)
    3981              : {
    3982          127 :   if (TREE_CODE (*node) != FUNCTION_DECL)
    3983              :     {
    3984            0 :       warning (OPT_Wattributes, "%qE attribute only applies to functions",
    3985              :                name);
    3986            0 :       *no_add_attrs = true;
    3987              :     }
    3988              : 
    3989          127 :   if (is_attribute_p ("indirect_branch", name))
    3990              :     {
    3991           17 :       tree cst = TREE_VALUE (args);
    3992           17 :       if (TREE_CODE (cst) != STRING_CST)
    3993              :         {
    3994            0 :           warning (OPT_Wattributes,
    3995              :                    "%qE attribute requires a string constant argument",
    3996              :                    name);
    3997            0 :           *no_add_attrs = true;
    3998              :         }
    3999           17 :       else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
    4000           15 :                && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
    4001           10 :                && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
    4002           24 :                && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
    4003              :         {
    4004            0 :           warning (OPT_Wattributes,
    4005              :                    "argument to %qE attribute is not "
    4006              :                    "(keep|thunk|thunk-inline|thunk-extern)", name);
    4007            0 :           *no_add_attrs = true;
    4008              :         }
    4009              :     }
    4010              : 
    4011          127 :   if (is_attribute_p ("function_return", name))
    4012              :     {
    4013           12 :       tree cst = TREE_VALUE (args);
    4014           12 :       if (TREE_CODE (cst) != STRING_CST)
    4015              :         {
    4016            0 :           warning (OPT_Wattributes,
    4017              :                    "%qE attribute requires a string constant argument",
    4018              :                    name);
    4019            0 :           *no_add_attrs = true;
    4020              :         }
    4021           12 :       else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
    4022           10 :                && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
    4023            6 :                && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
    4024           15 :                && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
    4025              :         {
    4026            0 :           warning (OPT_Wattributes,
    4027              :                    "argument to %qE attribute is not "
    4028              :                    "(keep|thunk|thunk-inline|thunk-extern)", name);
    4029            0 :           *no_add_attrs = true;
    4030              :         }
    4031              :     }
    4032              : 
    4033          127 :   return NULL_TREE;
    4034              : }
    4035              : 
    4036              : static tree
    4037          248 : ix86_handle_call_saved_registers_attribute (tree *node, tree name, tree,
    4038              :                                             int, bool *)
    4039              : {
    4040          248 :   const char *attr1 = nullptr;
    4041          248 :   const char *attr2 = nullptr;
    4042              : 
    4043          248 :   if (is_attribute_p ("no_callee_saved_registers", name))
    4044              :     {
    4045              :       /* Disallow preserve_none and no_caller_saved_registers
    4046              :          attributes.  */
    4047           92 :       attr1 = "no_callee_saved_registers";
    4048           92 :       if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
    4049              :         attr2 = "preserve_none";
    4050           91 :       else if (lookup_attribute ("no_caller_saved_registers",
    4051           91 :                                  TYPE_ATTRIBUTES (*node)))
    4052              :         attr2 = "no_caller_saved_registers";
    4053              :     }
    4054          156 :   else if (is_attribute_p ("no_caller_saved_registers", name))
    4055              :     {
    4056              :       /* Disallow preserve_none and no_callee_saved_registers
    4057              :          attributes.  */
    4058           76 :       attr1 = "no_caller_saved_registers";
    4059           76 :       if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
    4060              :         attr2 = "preserve_none";
    4061           75 :       else if (lookup_attribute ("no_callee_saved_registers",
    4062           75 :                                  TYPE_ATTRIBUTES (*node)))
    4063              :         attr2 = "no_callee_saved_registers";
    4064              :     }
    4065           80 :   else if (is_attribute_p ("preserve_none", name))
    4066              :     {
    4067              :       /* Disallow no_callee_saved_registers and no_caller_saved_registers
    4068              :          attributes.  */
    4069           80 :       attr1 = "preserve_none";
    4070           80 :       if (lookup_attribute ("no_callee_saved_registers",
    4071           80 :                             TYPE_ATTRIBUTES (*node)))
    4072              :         attr2 = "no_caller_saved_registers";
    4073           80 :       else if (lookup_attribute ("no_callee_saved_registers",
    4074           80 :                                  TYPE_ATTRIBUTES (*node)))
    4075              :         attr2 = "no_callee_saved_registers";
    4076              :     }
    4077              : 
    4078              :   if (attr2)
    4079            3 :     error ("%qs and %qs attributes are not compatible", attr1, attr2);
    4080              : 
    4081          248 :   return NULL_TREE;
    4082              : }
    4083              : 
    4084              : static tree
    4085          129 : ix86_handle_interrupt_attribute (tree *node, tree, tree, int, bool *)
    4086              : {
    4087              :   /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
    4088              :      but the function type contains args and return type data.  */
    4089          129 :   tree func_type = *node;
    4090          129 :   tree return_type = TREE_TYPE (func_type);
    4091              : 
    4092          129 :   int nargs = 0;
    4093          129 :   tree current_arg_type = TYPE_ARG_TYPES (func_type);
    4094          129 :   while (current_arg_type
    4095          642 :          && ! VOID_TYPE_P (TREE_VALUE (current_arg_type)))
    4096              :     {
    4097          192 :       if (nargs == 0)
    4098              :         {
    4099          128 :           if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type)))
    4100            2 :             error ("interrupt service routine should have a pointer "
    4101              :                    "as the first argument");
    4102              :         }
    4103           64 :       else if (nargs == 1)
    4104              :         {
    4105           64 :           if (TREE_CODE (TREE_VALUE (current_arg_type)) != INTEGER_TYPE
    4106           64 :               || TYPE_MODE (TREE_VALUE (current_arg_type)) != word_mode)
    4107            2 :             error ("interrupt service routine should have %qs "
    4108              :                    "as the second argument",
    4109            2 :                    TARGET_64BIT
    4110            2 :                    ? (TARGET_X32 ? "unsigned long long int"
    4111              :                                  : "unsigned long int")
    4112              :                    : "unsigned int");
    4113              :         }
    4114          192 :       nargs++;
    4115          192 :       current_arg_type = TREE_CHAIN (current_arg_type);
    4116              :     }
    4117          129 :   if (!nargs || nargs > 2)
    4118            1 :     error ("interrupt service routine can only have a pointer argument "
    4119              :            "and an optional integer argument");
    4120          129 :   if (! VOID_TYPE_P (return_type))
    4121            1 :     error ("interrupt service routine must return %<void%>");
    4122              : 
    4123          129 :   return NULL_TREE;
    4124              : }
    4125              : 
    4126              : /* Handle fentry_name / fentry_section attribute.  */
    4127              : 
    4128              : static tree
    4129            4 : ix86_handle_fentry_name (tree *node, tree name, tree args,
    4130              :                          int, bool *no_add_attrs)
    4131              : {
    4132            4 :   if (TREE_CODE (*node) == FUNCTION_DECL
    4133            8 :       && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
    4134              :     /* Do nothing else, just set the attribute.  We'll get at
    4135              :        it later with lookup_attribute.  */
    4136              :     ;
    4137              :   else
    4138              :     {
    4139            0 :       warning (OPT_Wattributes, "%qE attribute ignored", name);
    4140            0 :       *no_add_attrs = true;
    4141              :     }
    4142              : 
    4143            4 :   return NULL_TREE;
    4144              : }
    4145              : 
    4146              : /* Handle a "nodirect_extern_access" attribute; arguments as in
    4147              :    struct attribute_spec.handler.  */
    4148              : 
    4149              : static tree
    4150           11 : handle_nodirect_extern_access_attribute (tree *pnode, tree name,
    4151              :                                          tree ARG_UNUSED (args),
    4152              :                                          int ARG_UNUSED (flags),
    4153              :                                          bool *no_add_attrs)
    4154              : {
    4155           11 :   tree node = *pnode;
    4156              : 
    4157           11 :   if (VAR_OR_FUNCTION_DECL_P (node))
    4158              :     {
    4159            7 :       if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
    4160           18 :            && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
    4161              :         {
    4162            0 :           warning (OPT_Wattributes,
    4163              :                    "%qE attribute have effect only on public objects", name);
    4164            0 :           *no_add_attrs = true;
    4165              :         }
    4166              :     }
    4167              :   else
    4168              :     {
    4169            0 :       warning (OPT_Wattributes, "%qE attribute ignored", name);
    4170            0 :       *no_add_attrs = true;
    4171              :     }
    4172              : 
    4173           11 :   return NULL_TREE;
    4174              : }
    4175              : 
    4176              : /* Table of valid machine attributes.  */
    4177              : static const attribute_spec ix86_gnu_attributes[] =
    4178              : {
    4179              :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    4180              :        affects_type_identity, handler, exclude } */
    4181              :   /* Stdcall attribute says callee is responsible for popping arguments
    4182              :      if they are not variable.  */
    4183              :   { "stdcall",   0, 0, false, true,  true,  true, ix86_handle_cconv_attribute,
    4184              :     NULL },
    4185              :   /* Fastcall attribute says callee is responsible for popping arguments
    4186              :      if they are not variable.  */
    4187              :   { "fastcall",  0, 0, false, true,  true,  true, ix86_handle_cconv_attribute,
    4188              :     NULL },
    4189              :   /* Thiscall attribute says callee is responsible for popping arguments
    4190              :      if they are not variable.  */
    4191              :   { "thiscall",  0, 0, false, true,  true,  true, ix86_handle_cconv_attribute,
    4192              :     NULL },
    4193              :   /* Cdecl attribute says the callee is a normal C declaration */
    4194              :   { "cdecl",     0, 0, false, true,  true,  true, ix86_handle_cconv_attribute,
    4195              :     NULL },
    4196              :   /* Regparm attribute specifies how many integer arguments are to be
    4197              :      passed in registers.  */
    4198              :   { "regparm",   1, 1, false, true,  true,  true, ix86_handle_cconv_attribute,
    4199              :     NULL },
    4200              :   /* Sseregparm attribute says we are using x86_64 calling conventions
    4201              :      for FP arguments.  */
    4202              :   { "sseregparm", 0, 0, false, true, true,  true, ix86_handle_cconv_attribute,
    4203              :     NULL },
    4204              :   /* The transactional memory builtins are implicitly regparm or fastcall
    4205              :      depending on the ABI.  Override the generic do-nothing attribute that
    4206              :      these builtins were declared with.  */
    4207              :   { "*tm regparm", 0, 0, false, true, true, true,
    4208              :     ix86_handle_tm_regparm_attribute, NULL },
    4209              :   /* force_align_arg_pointer says this function realigns the stack at entry.  */
    4210              :   { "force_align_arg_pointer", 0, 0,
    4211              :     false, true,  true, false, ix86_handle_force_align_arg_pointer_attribute,
    4212              :     NULL },
    4213              : #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
    4214              :   { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute,
    4215              :     NULL },
    4216              :   { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute,
    4217              :     NULL },
    4218              :   { "shared",    0, 0, true,  false, false, false,
    4219              :     ix86_handle_shared_attribute, NULL },
    4220              : #endif
    4221              :   { "ms_struct", 0, 0, false, false,  false, false,
    4222              :     ix86_handle_struct_attribute, NULL },
    4223              :   { "gcc_struct", 0, 0, false, false,  false, false,
    4224              :     ix86_handle_struct_attribute, NULL },
    4225              : #ifdef SUBTARGET_ATTRIBUTE_TABLE
    4226              :   SUBTARGET_ATTRIBUTE_TABLE,
    4227              : #endif
    4228              :   /* ms_abi and sysv_abi calling convention function attributes.  */
    4229              :   { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute, NULL },
    4230              :   { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute,
    4231              :     NULL },
    4232              :   { "ms_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
    4233              :   { "sysv_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
    4234              :   { "ms_hook_prologue", 0, 0, true, false, false, false,
    4235              :     ix86_handle_fndecl_attribute, NULL },
    4236              :   { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
    4237              :     ix86_handle_callee_pop_aggregate_return, NULL },
    4238              :   { "interrupt", 0, 0, false, true, true, false,
    4239              :     ix86_handle_interrupt_attribute, NULL },
    4240              :   { "no_caller_saved_registers", 0, 0, false, true, true, false,
    4241              :     ix86_handle_call_saved_registers_attribute, NULL },
    4242              :   { "preserve_none", 0, 0, false, true, true, true,
    4243              :     ix86_handle_call_saved_registers_attribute, NULL },
    4244              :   { "no_callee_saved_registers", 0, 0, false, true, true, true,
    4245              :     ix86_handle_call_saved_registers_attribute, NULL },
    4246              :   { "naked", 0, 0, true, false, false, false,
    4247              :     ix86_handle_fndecl_attribute, NULL },
    4248              :   { "indirect_branch", 1, 1, true, false, false, false,
    4249              :     ix86_handle_fndecl_attribute, NULL },
    4250              :   { "function_return", 1, 1, true, false, false, false,
    4251              :     ix86_handle_fndecl_attribute, NULL },
    4252              :   { "indirect_return", 0, 0, false, true, true, false,
    4253              :     NULL, NULL },
    4254              :   { "fentry_name", 1, 1, true, false, false, false,
    4255              :     ix86_handle_fentry_name, NULL },
    4256              :   { "fentry_section", 1, 1, true, false, false, false,
    4257              :     ix86_handle_fentry_name, NULL },
    4258              :   { "cf_check", 0, 0, true, false, false, false,
    4259              :     ix86_handle_fndecl_attribute, NULL },
    4260              :   { "nodirect_extern_access", 0, 0, true, false, false, false,
    4261              :     handle_nodirect_extern_access_attribute, NULL }
    4262              : };
    4263              : 
    4264              : const scoped_attribute_specs ix86_gnu_attribute_table =
    4265              : {
    4266              :   "gnu", { ix86_gnu_attributes }
    4267              : };
    4268              : 
    4269              : #include "gt-i386-options.h"
        

Generated by: LCOV version 2.6-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.