LCOV - code coverage report
Current view: top level - gcc/config/i386 - i386-builtins.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 95.2 % 847 806
Test Date: 2026-03-28 14:25:54 Functions: 96.0 % 25 24
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-builtins.h"
      94              : #include "common/config/i386/i386-isas.h"
      95              : 
      96              : #undef BDESC
      97              : #undef BDESC_FIRST
      98              : #undef BDESC_END
      99              : 
     100              : /* Macros for verification of enum ix86_builtins order.  */
     101              : #define BDESC_VERIFY(x, y, z) \
     102              :   gcc_checking_assert ((x) == (enum ix86_builtins) ((y) + (z)))
     103              : #define BDESC_VERIFYS(x, y, z) \
     104              :   STATIC_ASSERT ((x) == (enum ix86_builtins) ((y) + (z)))
     105              : 
     106              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_PCMPESTR_FIRST,
     107              :                IX86_BUILTIN__BDESC_COMI_LAST, 1);
     108              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_PCMPISTR_FIRST,
     109              :                IX86_BUILTIN__BDESC_PCMPESTR_LAST, 1);
     110              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_SPECIAL_ARGS_FIRST,
     111              :                IX86_BUILTIN__BDESC_PCMPISTR_LAST, 1);
     112              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_PURE_ARGS_FIRST,
     113              :                IX86_BUILTIN__BDESC_SPECIAL_ARGS_LAST, 1);
     114              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_ARGS_FIRST,
     115              :                IX86_BUILTIN__BDESC_PURE_ARGS_LAST, 1);
     116              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_ROUND_ARGS_FIRST,
     117              :                IX86_BUILTIN__BDESC_ARGS_LAST, 1);
     118              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_MULTI_ARG_FIRST,
     119              :                IX86_BUILTIN__BDESC_ROUND_ARGS_LAST, 1);
     120              : BDESC_VERIFYS (IX86_BUILTIN__BDESC_CET_FIRST,
     121              :                IX86_BUILTIN__BDESC_MULTI_ARG_LAST, 1);
     122              : BDESC_VERIFYS (IX86_BUILTIN_MAX,
     123              :                IX86_BUILTIN__BDESC_CET_LAST, 1);
     124              : 
     125              : 
     126              : /* Table for the ix86 builtin non-function types.  */
     127              : static GTY(()) tree ix86_builtin_type_tab[(int) IX86_BT_LAST_CPTR + 1];
     128              : 
     129              : tree ix86_float16_type_node = NULL_TREE;
     130              : tree ix86_bf16_type_node = NULL_TREE;
     131              : 
     132              : /* Retrieve an element from the above table, building some of
     133              :    the types lazily.  */
     134              : 
     135              : static tree
     136    339059294 : ix86_get_builtin_type (enum ix86_builtin_type tcode)
     137              : {
     138    339059294 :   unsigned int index;
     139    339059294 :   tree type, itype;
     140              : 
     141    339059294 :   gcc_assert ((unsigned)tcode < ARRAY_SIZE(ix86_builtin_type_tab));
     142              : 
     143    339059294 :   type = ix86_builtin_type_tab[(int) tcode];
     144    339059294 :   if (type != NULL)
     145              :     return type;
     146              : 
     147     12113445 :   gcc_assert (tcode > IX86_BT_LAST_PRIM);
     148     12113445 :   if (tcode <= IX86_BT_LAST_VECT)
     149              :     {
     150      5153223 :       machine_mode mode;
     151              : 
     152      5153223 :       index = tcode - IX86_BT_LAST_PRIM - 1;
     153      5153223 :       itype = ix86_get_builtin_type (ix86_builtin_type_vect_base[index]);
     154      5153223 :       mode = ix86_builtin_type_vect_mode[index];
     155              : 
     156      5153223 :       type = build_vector_type_for_mode (itype, mode);
     157              :     }
     158              :   else
     159              :     {
     160      6960222 :       int quals;
     161              : 
     162      6960222 :       index = tcode - IX86_BT_LAST_VECT - 1;
     163      6960222 :       if (tcode <= IX86_BT_LAST_PTR)
     164              :         quals = TYPE_UNQUALIFIED;
     165              :       else
     166      2915376 :         quals = TYPE_QUAL_CONST;
     167              : 
     168      6960222 :       itype = ix86_get_builtin_type (ix86_builtin_type_ptr_base[index]);
     169      6960222 :       if (quals != TYPE_UNQUALIFIED)
     170      2915376 :         itype = build_qualified_type (itype, quals);
     171              : 
     172      6960222 :       type = build_pointer_type (itype);
     173              :     }
     174              : 
     175     12113445 :   ix86_builtin_type_tab[(int) tcode] = type;
     176     12113445 :   return type;
     177              : }
     178              : 
     179              : /* Table for the ix86 builtin function types.  */
     180              : static GTY(()) tree ix86_builtin_func_type_tab[(int) IX86_BT_LAST_ALIAS + 1];
     181              : 
     182              : /* Retrieve an element from the above table, building some of
     183              :    the types lazily.  */
     184              : 
     185              : static tree
     186    313164747 : ix86_get_builtin_func_type (enum ix86_builtin_func_type tcode)
     187              : {
     188    313164747 :   tree type;
     189              : 
     190    313164747 :   gcc_assert ((unsigned)tcode < ARRAY_SIZE (ix86_builtin_func_type_tab));
     191              : 
     192    313164747 :   type = ix86_builtin_func_type_tab[(int) tcode];
     193    313164747 :   if (type != NULL)
     194              :     return type;
     195              : 
     196     97109406 :   if (tcode <= IX86_BT_LAST_FUNC)
     197              :     {
     198     88735164 :       unsigned start = ix86_builtin_func_start[(int) tcode];
     199     88735164 :       unsigned after = ix86_builtin_func_start[(int) tcode + 1];
     200     88735164 :       tree rtype, atype, args = void_list_node;
     201     88735164 :       unsigned i;
     202              : 
     203     88735164 :       rtype = ix86_get_builtin_type (ix86_builtin_func_args[start]);
     204    326945849 :       for (i = after - 1; i > start; --i)
     205              :         {
     206    238210685 :           atype = ix86_get_builtin_type (ix86_builtin_func_args[i]);
     207    238210685 :           args = tree_cons (NULL, atype, args);
     208              :         }
     209              : 
     210     88735164 :       type = build_function_type (rtype, args);
     211              :     }
     212              :   else
     213              :     {
     214      8374242 :       unsigned index = tcode - IX86_BT_LAST_FUNC - 1;
     215      8374242 :       enum ix86_builtin_func_type icode;
     216              : 
     217      8374242 :       icode = ix86_builtin_func_alias_base[index];
     218      8374242 :       type = ix86_get_builtin_func_type (icode);
     219              :     }
     220              : 
     221     97109406 :   ix86_builtin_func_type_tab[(int) tcode] = type;
     222     97109406 :   return type;
     223              : }
     224              : 
     225              : /* Table for the ix86 builtin decls.  */
     226              : static GTY(()) tree ix86_builtins[(int) IX86_BUILTIN_MAX + 1];
     227              : 
     228              : struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX];
     229              : 
     230        43728 : tree get_ix86_builtin (enum ix86_builtins c)
     231              : {
     232        43728 :   return ix86_builtins[c];
     233              : }
     234              : 
     235              : /* Bits that can still enable any inclusion of a builtin.  */
     236              : HOST_WIDE_INT deferred_isa_values = 0;
     237              : HOST_WIDE_INT deferred_isa_values2 = 0;
     238              : 
     239              : /* Add an ix86 target builtin function with CODE, NAME and TYPE.  Save the
     240              :    MASK and MASK2 of which isa_flags and ix86_isa_flags2 to use in the
     241              :    ix86_builtins_isa array.  Stores the function decl in the ix86_builtins
     242              :    array.  Returns the function decl or NULL_TREE, if the builtin was not
     243              :    added.
     244              : 
     245              :    If the front end has a special hook for builtin functions, delay adding
     246              :    builtin functions that aren't in the current ISA until the ISA is changed
     247              :    with function specific optimization.  Doing so, can save about 300K for the
     248              :    default compiler.  When the builtin is expanded, check at that time whether
     249              :    it is valid.
     250              : 
     251              :    If the front end doesn't have a special hook, record all builtins, even if
     252              :    it isn't an instruction set in the current ISA in case the user uses
     253              :    function specific options for a different ISA, so that we don't get scope
     254              :    errors if a builtin is added in the middle of a function scope.  */
     255              : 
     256              : static inline tree
     257    953820099 : def_builtin (HOST_WIDE_INT mask, HOST_WIDE_INT mask2,
     258              :              const char *name,
     259              :              enum ix86_builtin_func_type tcode,
     260              :              enum ix86_builtins code)
     261              : {
     262    953820099 :   tree decl = NULL_TREE;
     263              : 
     264              :   /* An instruction may be 64bit only regardless of ISAs.  */
     265    953820099 :   if (!(mask & OPTION_MASK_ISA_64BIT) || TARGET_64BIT)
     266              :     {
     267    953259148 :       ix86_builtins_isa[(int) code].isa = mask;
     268    953259148 :       ix86_builtins_isa[(int) code].isa2 = mask2;
     269              : 
     270    953259148 :       mask &= ~OPTION_MASK_ISA_64BIT;
     271              : 
     272              :       /* Filter out the masks most often ored together with others.  */
     273    953259148 :       if ((mask & ix86_isa_flags & OPTION_MASK_ISA_AVX512VL)
     274      2373519 :           && mask != OPTION_MASK_ISA_AVX512VL)
     275       840498 :         mask &= ~OPTION_MASK_ISA_AVX512VL;
     276    953259148 :       if ((mask & ix86_isa_flags & OPTION_MASK_ISA_AVX512BW)
     277       683508 :           && mask != OPTION_MASK_ISA_AVX512BW)
     278       205258 :         mask &= ~OPTION_MASK_ISA_AVX512BW;
     279              : 
     280    953259148 :       if (((mask2 == 0 || (mask2 & ix86_isa_flags2) != 0)
     281    741735456 :            && (mask == 0 || (mask & ix86_isa_flags) != 0))
     282    846061844 :           || ((mask & OPTION_MASK_ISA_MMX) != 0 && TARGET_MMX_WITH_SSE)
     283              :           /* "Unified" builtin used by either AVXVNNI/AVXIFMA/AES/
     284              :              AVXVNNIINT{8,16} intrinsics or AVX512VNNIVL/AVX512IFMAVL/VAESVL/
     285              :              AVX10.2 non-mask intrinsics should be defined whenever avxvnni/
     286              :              avxifma/aes/avxvnniint{8,16} or avx512vnni && avx512vl/avx512ifma
     287              :              && avx512vl/vaes && avx512vl/avx10.2 exist.  */
     288    845931341 :           || (mask2 == OPTION_MASK_ISA2_AVXVNNI)
     289    845931341 :           || (mask2 == OPTION_MASK_ISA2_AVXIFMA)
     290    842796881 :           || (mask2 == (OPTION_MASK_ISA2_AVXNECONVERT
     291              :                         | OPTION_MASK_ISA2_AVX512BF16))
     292    842274819 :           || ((mask2 & OPTION_MASK_ISA2_VAES) != 0)
     293    838096331 :           || ((mask2 & OPTION_MASK_ISA2_AVXVNNIINT8) != 0)
     294    834963143 :           || ((mask2 & OPTION_MASK_ISA2_AVXVNNIINT16) != 0)
     295    831829907 :           || (lang_hooks.builtin_function
     296    831829907 :               == lang_hooks.builtin_function_ext_scope))
     297              :         {
     298    291961912 :           tree type = ix86_get_builtin_func_type (tcode);
     299    291961912 :           decl = add_builtin_function (name, type, code, BUILT_IN_MD,
     300              :                                        NULL, NULL_TREE);
     301    291961912 :           ix86_builtins[(int) code] = decl;
     302    291961912 :           ix86_builtins_isa[(int) code].set_and_not_built_p = false;
     303    291961912 :           if (!flag_non_call_exceptions)
     304    291491521 :             TREE_NOTHROW (decl) = 1;
     305    291961912 :           if (ix86_builtins[(int) IX86_BUILTIN_MAX] == NULL_TREE)
     306       261249 :             ix86_builtins[(int) IX86_BUILTIN_MAX]
     307       261249 :               = build_tree_list (get_identifier ("leaf"), NULL_TREE);
     308    291961912 :           DECL_ATTRIBUTES (decl) = ix86_builtins[(int) IX86_BUILTIN_MAX];
     309    291961912 :         }
     310              :       else
     311              :         {
     312              :           /* Just MASK and MASK2 where set_and_not_built_p == true can potentially
     313              :              include a builtin.  */
     314    661297236 :           deferred_isa_values |= mask;
     315    661297236 :           deferred_isa_values2 |= mask2;
     316    661297236 :           ix86_builtins[(int) code] = NULL_TREE;
     317    661297236 :           ix86_builtins_isa[(int) code].tcode = tcode;
     318    661297236 :           ix86_builtins_isa[(int) code].name = name;
     319    661297236 :           ix86_builtins_isa[(int) code].const_p = false;
     320    661297236 :           ix86_builtins_isa[(int) code].pure_p = false;
     321    661297236 :           ix86_builtins_isa[(int) code].set_and_not_built_p = true;
     322              :         }
     323              :     }
     324              : 
     325    953820099 :   return decl;
     326              : }
     327              : 
     328              : /* Like def_builtin, but also marks the function decl "const".  */
     329              : 
     330              : static inline tree
     331    825546840 : def_builtin_const (HOST_WIDE_INT mask, HOST_WIDE_INT mask2, const char *name,
     332              :                    enum ix86_builtin_func_type tcode, enum ix86_builtins code)
     333              : {
     334    825546840 :   tree decl = def_builtin (mask, mask2, name, tcode, code);
     335    825546840 :   if (decl)
     336    254861742 :     TREE_READONLY (decl) = 1;
     337              :   else
     338    570685098 :     ix86_builtins_isa[(int) code].const_p = true;
     339              : 
     340    825546840 :   return decl;
     341              : }
     342              : 
     343              : /* Like def_builtin, but also marks the function decl "pure".  */
     344              : 
     345              : static inline tree
     346     15936189 : def_builtin_pure (HOST_WIDE_INT mask, HOST_WIDE_INT mask2, const char *name,
     347              :                   enum ix86_builtin_func_type tcode, enum ix86_builtins code)
     348              : {
     349     15936189 :   tree decl = def_builtin (mask, mask2, name, tcode, code);
     350     15936189 :   if (decl)
     351      3713865 :     DECL_PURE_P (decl) = 1;
     352              :   else
     353     12222324 :     ix86_builtins_isa[(int) code].pure_p = true;
     354              : 
     355     15936189 :   return decl;
     356              : }
     357              : 
     358              : /* Add any new builtin functions for a given ISA that may not have been
     359              :    declared.  This saves a bit of space compared to adding all of the
     360              :    declarations to the tree, even if we didn't use them.  */
     361              : 
     362              : void
     363     48316364 : ix86_add_new_builtins (HOST_WIDE_INT isa, HOST_WIDE_INT isa2)
     364              : {
     365     48316364 :   isa &= ~OPTION_MASK_ISA_64BIT;
     366              : 
     367     48316364 :   if ((isa & deferred_isa_values) == 0
     368     48145205 :       && (isa2 & deferred_isa_values2) == 0
     369     47999668 :       && ((deferred_isa_values & OPTION_MASK_ISA_MMX) == 0
     370        14341 :           || !(TARGET_64BIT && (isa & OPTION_MASK_ISA_SSE2) != 0)))
     371              :     return;
     372              : 
     373              :   /* Bits in ISA value can be removed from potential isa values.  */
     374       316696 :   deferred_isa_values &= ~isa;
     375       316696 :   deferred_isa_values2 &= ~isa2;
     376       316696 :   if (TARGET_64BIT && (isa & OPTION_MASK_ISA_SSE2) != 0)
     377       142508 :     deferred_isa_values &= ~OPTION_MASK_ISA_MMX;
     378              : 
     379       316696 :   int i;
     380       316696 :   tree saved_current_target_pragma = current_target_pragma;
     381       316696 :   current_target_pragma = NULL_TREE;
     382              : 
     383   1161957624 :   for (i = 0; i < (int)IX86_BUILTIN_MAX; i++)
     384              :     {
     385   1161640928 :       if (((ix86_builtins_isa[i].isa & isa) != 0
     386    926563115 :            || (ix86_builtins_isa[i].isa2 & isa2) != 0
     387    917606308 :            || ((ix86_builtins_isa[i].isa & OPTION_MASK_ISA_MMX) != 0
     388     16568088 :                && TARGET_64BIT
     389     16435608 :                && (isa & OPTION_MASK_ISA_SSE2) != 0))
     390    244052517 :           && ix86_builtins_isa[i].set_and_not_built_p)
     391              :         {
     392     11253339 :           tree decl, type;
     393              : 
     394              :           /* Don't define the builtin again.  */
     395     11253339 :           ix86_builtins_isa[i].set_and_not_built_p = false;
     396              : 
     397     11253339 :           type = ix86_get_builtin_func_type (ix86_builtins_isa[i].tcode);
     398     11253339 :           decl = add_builtin_function_ext_scope (ix86_builtins_isa[i].name,
     399              :                                                  type, i, BUILT_IN_MD, NULL,
     400              :                                                  NULL_TREE);
     401              : 
     402     11253339 :           ix86_builtins[i] = decl;
     403     11253339 :           if (ix86_builtins_isa[i].const_p)
     404      9667673 :             TREE_READONLY (decl) = 1;
     405     11253339 :           if (ix86_builtins_isa[i].pure_p)
     406       148033 :             DECL_PURE_P (decl) = 1;
     407     11253339 :           if (!flag_non_call_exceptions)
     408     11230090 :             TREE_NOTHROW (decl) = 1;
     409     11253339 :           if (ix86_builtins[(int) IX86_BUILTIN_MAX] == NULL_TREE)
     410            0 :             ix86_builtins[(int) IX86_BUILTIN_MAX]
     411            0 :               = build_tree_list (get_identifier ("leaf"), NULL_TREE);
     412     11253339 :           DECL_ATTRIBUTES (decl) = ix86_builtins[(int) IX86_BUILTIN_MAX];
     413              :         }
     414              :     }
     415              : 
     416       316696 :   current_target_pragma = saved_current_target_pragma;
     417              : }
     418              : 
     419              : /* TM vector builtins.  */
     420              : 
     421              : /* Reuse the existing x86-specific `struct builtin_description' cause
     422              :    we're lazy.  Add casts to make them fit.  */
     423              : static const struct builtin_description bdesc_tm[] =
     424              : {
     425              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_WM64", (enum ix86_builtins) BUILT_IN_TM_STORE_M64, UNKNOWN, VOID_FTYPE_PV2SI_V2SI },
     426              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_WaRM64", (enum ix86_builtins) BUILT_IN_TM_STORE_WAR_M64, UNKNOWN, VOID_FTYPE_PV2SI_V2SI },
     427              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_WaWM64", (enum ix86_builtins) BUILT_IN_TM_STORE_WAW_M64, UNKNOWN, VOID_FTYPE_PV2SI_V2SI },
     428              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_RM64", (enum ix86_builtins) BUILT_IN_TM_LOAD_M64, UNKNOWN, V2SI_FTYPE_PCV2SI },
     429              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_RaRM64", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAR_M64, UNKNOWN, V2SI_FTYPE_PCV2SI },
     430              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_RaWM64", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAW_M64, UNKNOWN, V2SI_FTYPE_PCV2SI },
     431              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_RfWM64", (enum ix86_builtins) BUILT_IN_TM_LOAD_RFW_M64, UNKNOWN, V2SI_FTYPE_PCV2SI },
     432              : 
     433              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_WM128", (enum ix86_builtins) BUILT_IN_TM_STORE_M128, UNKNOWN, VOID_FTYPE_PV4SF_V4SF },
     434              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_WaRM128", (enum ix86_builtins) BUILT_IN_TM_STORE_WAR_M128, UNKNOWN, VOID_FTYPE_PV4SF_V4SF },
     435              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_WaWM128", (enum ix86_builtins) BUILT_IN_TM_STORE_WAW_M128, UNKNOWN, VOID_FTYPE_PV4SF_V4SF },
     436              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_RM128", (enum ix86_builtins) BUILT_IN_TM_LOAD_M128, UNKNOWN, V4SF_FTYPE_PCV4SF },
     437              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_RaRM128", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAR_M128, UNKNOWN, V4SF_FTYPE_PCV4SF },
     438              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_RaWM128", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAW_M128, UNKNOWN, V4SF_FTYPE_PCV4SF },
     439              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_RfWM128", (enum ix86_builtins) BUILT_IN_TM_LOAD_RFW_M128, UNKNOWN, V4SF_FTYPE_PCV4SF },
     440              : 
     441              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_WM256", (enum ix86_builtins) BUILT_IN_TM_STORE_M256, UNKNOWN, VOID_FTYPE_PV8SF_V8SF },
     442              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_WaRM256", (enum ix86_builtins) BUILT_IN_TM_STORE_WAR_M256, UNKNOWN, VOID_FTYPE_PV8SF_V8SF },
     443              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_WaWM256", (enum ix86_builtins) BUILT_IN_TM_STORE_WAW_M256, UNKNOWN, VOID_FTYPE_PV8SF_V8SF },
     444              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_RM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
     445              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_RaRM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAR_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
     446              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_RaWM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RAW_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
     447              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_RfWM256", (enum ix86_builtins) BUILT_IN_TM_LOAD_RFW_M256, UNKNOWN, V8SF_FTYPE_PCV8SF },
     448              : 
     449              :   { OPTION_MASK_ISA_MMX, 0, CODE_FOR_nothing, "__builtin__ITM_LM64", (enum ix86_builtins) BUILT_IN_TM_LOG_M64, UNKNOWN, VOID_FTYPE_PCVOID },
     450              :   { OPTION_MASK_ISA_SSE, 0, CODE_FOR_nothing, "__builtin__ITM_LM128", (enum ix86_builtins) BUILT_IN_TM_LOG_M128, UNKNOWN, VOID_FTYPE_PCVOID },
     451              :   { OPTION_MASK_ISA_AVX, 0, CODE_FOR_nothing, "__builtin__ITM_LM256", (enum ix86_builtins) BUILT_IN_TM_LOG_M256, UNKNOWN, VOID_FTYPE_PCVOID },
     452              : };
     453              : 
     454              : /* Initialize the transactional memory vector load/store builtins.  */
     455              : 
     456              : static void
     457       261249 : ix86_init_tm_builtins (void)
     458              : {
     459       261249 :   enum ix86_builtin_func_type ftype;
     460       261249 :   const struct builtin_description *d;
     461       261249 :   size_t i;
     462       261249 :   tree decl;
     463       261249 :   tree attrs_load, attrs_type_load, attrs_store, attrs_type_store;
     464       261249 :   tree attrs_log, attrs_type_log;
     465              : 
     466       261249 :   if (!flag_tm)
     467              :     return;
     468              : 
     469              :   /* If there are no builtins defined, we must be compiling in a
     470              :      language without trans-mem support.  */
     471          485 :   if (!builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1))
     472              :     return;
     473              : 
     474              :   /* Use whatever attributes a normal TM load has.  */
     475          484 :   decl = builtin_decl_explicit (BUILT_IN_TM_LOAD_1);
     476          484 :   attrs_load = DECL_ATTRIBUTES (decl);
     477          484 :   attrs_type_load = TYPE_ATTRIBUTES (TREE_TYPE (decl));
     478              :   /* Use whatever attributes a normal TM store has.  */
     479          484 :   decl = builtin_decl_explicit (BUILT_IN_TM_STORE_1);
     480          484 :   attrs_store = DECL_ATTRIBUTES (decl);
     481          484 :   attrs_type_store = TYPE_ATTRIBUTES (TREE_TYPE (decl));
     482              :   /* Use whatever attributes a normal TM log has.  */
     483          484 :   decl = builtin_decl_explicit (BUILT_IN_TM_LOG);
     484          484 :   attrs_log = DECL_ATTRIBUTES (decl);
     485          484 :   attrs_type_log = TYPE_ATTRIBUTES (TREE_TYPE (decl));
     486              : 
     487          484 :   for (i = 0, d = bdesc_tm;
     488        12100 :        i < ARRAY_SIZE (bdesc_tm);
     489        11616 :        i++, d++)
     490              :     {
     491        11616 :       if ((d->mask & ix86_isa_flags) != 0
     492         3872 :           || ((d->mask & OPTION_MASK_ISA_MMX) != 0 && TARGET_MMX_WITH_SSE)
     493         3872 :           || (lang_hooks.builtin_function
     494         3872 :               == lang_hooks.builtin_function_ext_scope))
     495              :         {
     496         7760 :           tree type, attrs, attrs_type;
     497         7760 :           enum built_in_function code = (enum built_in_function) d->code;
     498              : 
     499         7760 :           ftype = (enum ix86_builtin_func_type) d->flag;
     500         7760 :           type = ix86_get_builtin_func_type (ftype);
     501              : 
     502         7760 :           if (BUILTIN_TM_LOAD_P (code))
     503              :             {
     504              :               attrs = attrs_load;
     505              :               attrs_type = attrs_type_load;
     506              :             }
     507         3880 :           else if (BUILTIN_TM_STORE_P (code))
     508              :             {
     509              :               attrs = attrs_store;
     510              :               attrs_type = attrs_type_store;
     511              :             }
     512              :           else
     513              :             {
     514          970 :               attrs = attrs_log;
     515          970 :               attrs_type = attrs_type_log;
     516              :             }
     517        15520 :           decl = add_builtin_function (d->name, type, code, BUILT_IN_NORMAL,
     518              :                                        /* The builtin without the prefix for
     519              :                                           calling it directly.  */
     520         7760 :                                        d->name + strlen ("__builtin_"),
     521              :                                        attrs);
     522              :           /* add_builtin_function() will set the DECL_ATTRIBUTES, now
     523              :              set the TYPE_ATTRIBUTES.  */
     524         7760 :           decl_attributes (&TREE_TYPE (decl), attrs_type, ATTR_FLAG_BUILT_IN);
     525              : 
     526         7760 :           set_builtin_decl (code, decl, false);
     527              :         }
     528              :     }
     529              : }
     530              : 
     531              : /* Set up all the MMX/SSE builtins, even builtins for instructions that are not
     532              :    in the current target ISA to allow the user to compile particular modules
     533              :    with different target specific options that differ from the command line
     534              :    options.  */
     535              : static void
     536       261249 : ix86_init_mmx_sse_builtins (void)
     537              : {
     538       261249 :   const struct builtin_description * d;
     539       261249 :   enum ix86_builtin_func_type ftype;
     540       261249 :   size_t i;
     541              : 
     542              :   /* Add all special builtins with variable number of operands.  */
     543       261249 :   for (i = 0, d = bdesc_special_args;
     544     91959648 :        i < ARRAY_SIZE (bdesc_special_args);
     545     91698399 :        i++, d++)
     546              :     {
     547     91698399 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_SPECIAL_ARGS_FIRST, i);
     548     91698399 :       if (d->name == 0)
     549       261249 :         continue;
     550              : 
     551     91437150 :       ftype = (enum ix86_builtin_func_type) d->flag;
     552     91437150 :       def_builtin (d->mask, d->mask2, d->name, ftype, d->code);
     553              :     }
     554              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_SPECIAL_ARGS_LAST,
     555              :                  IX86_BUILTIN__BDESC_SPECIAL_ARGS_FIRST,
     556              :                  ARRAY_SIZE (bdesc_special_args) - 1);
     557              : 
     558              :   /* Add all pure builtins with variable number of operands.  */
     559              :   for (i = 0, d = bdesc_pure_args;
     560      2351241 :        i < ARRAY_SIZE (bdesc_pure_args);
     561      2089992 :        i++, d++)
     562              :     {
     563      2089992 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_PURE_ARGS_FIRST, i);
     564      2089992 :       if (d->name == 0)
     565            0 :         continue;
     566              : 
     567      2089992 :       ftype = (enum ix86_builtin_func_type) d->flag;
     568      2089992 :       def_builtin_pure (d->mask, d->mask2, d->name, ftype, d->code);
     569              :     }
     570              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_PURE_ARGS_LAST,
     571              :                  IX86_BUILTIN__BDESC_PURE_ARGS_FIRST,
     572              :                  ARRAY_SIZE (bdesc_pure_args) - 1);
     573              : 
     574              :   /* Add all const builtins with variable number of operands.  */
     575              :   for (i = 0, d = bdesc_args;
     576    685778625 :        i < ARRAY_SIZE (bdesc_args);
     577    685517376 :        i++, d++)
     578              :     {
     579    685517376 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_ARGS_FIRST, i);
     580    685517376 :       if (d->name == 0)
     581      4179984 :         continue;
     582              : 
     583    681337392 :       ftype = (enum ix86_builtin_func_type) d->flag;
     584    681337392 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
     585              :     }
     586              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_ARGS_LAST,
     587              :                  IX86_BUILTIN__BDESC_ARGS_FIRST,
     588              :                  ARRAY_SIZE (bdesc_args) - 1);
     589              : 
     590              :   /* Add all builtins with rounding.  */
     591              :   for (i = 0, d = bdesc_round_args;
     592     83599680 :        i < ARRAY_SIZE (bdesc_round_args);
     593     83338431 :        i++, d++)
     594              :     {
     595     83338431 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_ROUND_ARGS_FIRST, i);
     596     83338431 :       if (d->name == 0)
     597            0 :         continue;
     598              : 
     599     83338431 :       ftype = (enum ix86_builtin_func_type) d->flag;
     600     83338431 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
     601              :     }
     602              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_ROUND_ARGS_LAST,
     603              :                  IX86_BUILTIN__BDESC_ROUND_ARGS_FIRST,
     604              :                  ARRAY_SIZE (bdesc_round_args) - 1);
     605              : 
     606              :   /* pcmpestr[im] insns.  */
     607              :   for (i = 0, d = bdesc_pcmpestr;
     608      2089992 :        i < ARRAY_SIZE (bdesc_pcmpestr);
     609      1828743 :        i++, d++)
     610              :     {
     611      1828743 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_PCMPESTR_FIRST, i);
     612      1828743 :       if (d->code == IX86_BUILTIN_PCMPESTRM128)
     613              :         ftype = V16QI_FTYPE_V16QI_INT_V16QI_INT_INT;
     614              :       else
     615      1567494 :         ftype = INT_FTYPE_V16QI_INT_V16QI_INT_INT;
     616      1828743 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
     617              :     }
     618              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_PCMPESTR_LAST,
     619              :                  IX86_BUILTIN__BDESC_PCMPESTR_FIRST,
     620              :                  ARRAY_SIZE (bdesc_pcmpestr) - 1);
     621              : 
     622              :   /* pcmpistr[im] insns.  */
     623              :   for (i = 0, d = bdesc_pcmpistr;
     624      2089992 :        i < ARRAY_SIZE (bdesc_pcmpistr);
     625      1828743 :        i++, d++)
     626              :     {
     627      1828743 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_PCMPISTR_FIRST, i);
     628      1828743 :       if (d->code == IX86_BUILTIN_PCMPISTRM128)
     629              :         ftype = V16QI_FTYPE_V16QI_V16QI_INT;
     630              :       else
     631      1567494 :         ftype = INT_FTYPE_V16QI_V16QI_INT;
     632      1828743 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
     633              :     }
     634              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_PCMPISTR_LAST,
     635              :                  IX86_BUILTIN__BDESC_PCMPISTR_FIRST,
     636              :                  ARRAY_SIZE (bdesc_pcmpistr) - 1);
     637              : 
     638              :   /* comi/ucomi insns.  */
     639      6531225 :   for (i = 0, d = bdesc_comi; i < ARRAY_SIZE (bdesc_comi); i++, d++)
     640              :     {
     641      6269976 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_COMI_FIRST, i);
     642      6269976 :       if (d->mask == OPTION_MASK_ISA_SSE2)
     643              :         ftype = INT_FTYPE_V2DF_V2DF;
     644              :       else
     645      3134988 :         ftype = INT_FTYPE_V4SF_V4SF;
     646      6269976 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
     647              :     }
     648       261249 :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_COMI_LAST,
     649              :                  IX86_BUILTIN__BDESC_COMI_FIRST,
     650              :                  ARRAY_SIZE (bdesc_comi) - 1);
     651              : 
     652              :   /* SSE */
     653       261249 :   def_builtin (OPTION_MASK_ISA_SSE, 0,  "__builtin_ia32_ldmxcsr",
     654              :                VOID_FTYPE_UNSIGNED, IX86_BUILTIN_LDMXCSR);
     655       261249 :   def_builtin_pure (OPTION_MASK_ISA_SSE, 0, "__builtin_ia32_stmxcsr",
     656              :                     UNSIGNED_FTYPE_VOID, IX86_BUILTIN_STMXCSR);
     657              : 
     658              :   /* SSE or 3DNow!A */
     659       261249 :   def_builtin (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_3DNOW_A
     660              :                /* As it uses V4HImode, we have to require -mmmx too.  */
     661              :                | OPTION_MASK_ISA_MMX, 0,
     662              :                "__builtin_ia32_maskmovq", VOID_FTYPE_V8QI_V8QI_PCHAR,
     663              :                IX86_BUILTIN_MASKMOVQ);
     664              : 
     665              :   /* SSE2 */
     666       261249 :   def_builtin (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_maskmovdqu",
     667              :                VOID_FTYPE_V16QI_V16QI_PCHAR, IX86_BUILTIN_MASKMOVDQU);
     668              : 
     669       261249 :   def_builtin (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_clflush",
     670              :                VOID_FTYPE_PCVOID, IX86_BUILTIN_CLFLUSH);
     671       261249 :   x86_mfence = def_builtin (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_mfence",
     672              :                             VOID_FTYPE_VOID, IX86_BUILTIN_MFENCE);
     673              : 
     674              :   /* SSE3.  */
     675       261249 :   def_builtin (0, OPTION_MASK_ISA2_MWAIT, "__builtin_ia32_monitor",
     676              :                VOID_FTYPE_PCVOID_UNSIGNED_UNSIGNED, IX86_BUILTIN_MONITOR);
     677       261249 :   def_builtin (0, OPTION_MASK_ISA2_MWAIT, "__builtin_ia32_mwait",
     678              :                VOID_FTYPE_UNSIGNED_UNSIGNED, IX86_BUILTIN_MWAIT);
     679              : 
     680              :   /* AES */
     681       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2
     682              :                      | OPTION_MASK_ISA_AVX512VL,
     683              :                      OPTION_MASK_ISA2_VAES,
     684              :                      "__builtin_ia32_aesenc128",
     685              :                      V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESENC128);
     686       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2
     687              :                      | OPTION_MASK_ISA_AVX512VL,
     688              :                      OPTION_MASK_ISA2_VAES,
     689              :                      "__builtin_ia32_aesenclast128",
     690              :                      V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESENCLAST128);
     691       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2
     692              :                      | OPTION_MASK_ISA_AVX512VL,
     693              :                      OPTION_MASK_ISA2_VAES,
     694              :                      "__builtin_ia32_aesdec128",
     695              :                      V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESDEC128);
     696       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2
     697              :                      | OPTION_MASK_ISA_AVX512VL,
     698              :                      OPTION_MASK_ISA2_VAES,
     699              :                      "__builtin_ia32_aesdeclast128",
     700              :                      V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESDECLAST128);
     701       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, 0,
     702              :                      "__builtin_ia32_aesimc128",
     703              :                      V2DI_FTYPE_V2DI, IX86_BUILTIN_AESIMC128);
     704       261249 :   def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, 0,
     705              :                      "__builtin_ia32_aeskeygenassist128",
     706              :                      V2DI_FTYPE_V2DI_INT, IX86_BUILTIN_AESKEYGENASSIST128);
     707              : 
     708              :   /* PCLMUL */
     709       261249 :   def_builtin_const (OPTION_MASK_ISA_PCLMUL | OPTION_MASK_ISA_SSE2, 0,
     710              :                      "__builtin_ia32_pclmulqdq128",
     711              :                      V2DI_FTYPE_V2DI_V2DI_INT, IX86_BUILTIN_PCLMULQDQ128);
     712              : 
     713              :   /* RDRND */
     714       261249 :   def_builtin (OPTION_MASK_ISA_RDRND, 0, "__builtin_ia32_rdrand16_step",
     715              :                INT_FTYPE_PUSHORT, IX86_BUILTIN_RDRAND16_STEP);
     716       261249 :   def_builtin (OPTION_MASK_ISA_RDRND, 0,  "__builtin_ia32_rdrand32_step",
     717              :                INT_FTYPE_PUNSIGNED, IX86_BUILTIN_RDRAND32_STEP);
     718       261249 :   def_builtin (OPTION_MASK_ISA_RDRND | OPTION_MASK_ISA_64BIT, 0,
     719              :                "__builtin_ia32_rdrand64_step", INT_FTYPE_PULONGLONG,
     720              :                IX86_BUILTIN_RDRAND64_STEP);
     721              : 
     722              :   /* AVX2 */
     723       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv2df",
     724              :                     V2DF_FTYPE_V2DF_PCDOUBLE_V4SI_V2DF_INT,
     725              :                     IX86_BUILTIN_GATHERSIV2DF);
     726              : 
     727       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv4df",
     728              :                     V4DF_FTYPE_V4DF_PCDOUBLE_V4SI_V4DF_INT,
     729              :                     IX86_BUILTIN_GATHERSIV4DF);
     730              : 
     731       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv2df",
     732              :                     V2DF_FTYPE_V2DF_PCDOUBLE_V2DI_V2DF_INT,
     733              :                     IX86_BUILTIN_GATHERDIV2DF);
     734              : 
     735       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4df",
     736              :                     V4DF_FTYPE_V4DF_PCDOUBLE_V4DI_V4DF_INT,
     737              :                     IX86_BUILTIN_GATHERDIV4DF);
     738              : 
     739       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv4sf",
     740              :                     V4SF_FTYPE_V4SF_PCFLOAT_V4SI_V4SF_INT,
     741              :                     IX86_BUILTIN_GATHERSIV4SF);
     742              : 
     743       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv8sf",
     744              :                     V8SF_FTYPE_V8SF_PCFLOAT_V8SI_V8SF_INT,
     745              :                     IX86_BUILTIN_GATHERSIV8SF);
     746              : 
     747       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4sf",
     748              :                     V4SF_FTYPE_V4SF_PCFLOAT_V2DI_V4SF_INT,
     749              :                     IX86_BUILTIN_GATHERDIV4SF);
     750              : 
     751       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4sf256",
     752              :                     V4SF_FTYPE_V4SF_PCFLOAT_V4DI_V4SF_INT,
     753              :                     IX86_BUILTIN_GATHERDIV8SF);
     754              : 
     755       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv2di",
     756              :                     V2DI_FTYPE_V2DI_PCINT64_V4SI_V2DI_INT,
     757              :                     IX86_BUILTIN_GATHERSIV2DI);
     758              : 
     759       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv4di",
     760              :                     V4DI_FTYPE_V4DI_PCINT64_V4SI_V4DI_INT,
     761              :                     IX86_BUILTIN_GATHERSIV4DI);
     762              : 
     763       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv2di",
     764              :                     V2DI_FTYPE_V2DI_PCINT64_V2DI_V2DI_INT,
     765              :                     IX86_BUILTIN_GATHERDIV2DI);
     766              : 
     767       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4di",
     768              :                     V4DI_FTYPE_V4DI_PCINT64_V4DI_V4DI_INT,
     769              :                     IX86_BUILTIN_GATHERDIV4DI);
     770              : 
     771       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv4si",
     772              :                     V4SI_FTYPE_V4SI_PCINT_V4SI_V4SI_INT,
     773              :                     IX86_BUILTIN_GATHERSIV4SI);
     774              : 
     775       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gathersiv8si",
     776              :                     V8SI_FTYPE_V8SI_PCINT_V8SI_V8SI_INT,
     777              :                     IX86_BUILTIN_GATHERSIV8SI);
     778              : 
     779       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4si",
     780              :                     V4SI_FTYPE_V4SI_PCINT_V2DI_V4SI_INT,
     781              :                     IX86_BUILTIN_GATHERDIV4SI);
     782              : 
     783       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatherdiv4si256",
     784              :                     V4SI_FTYPE_V4SI_PCINT_V4DI_V4SI_INT,
     785              :                     IX86_BUILTIN_GATHERDIV8SI);
     786              : 
     787       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatheraltsiv4df ",
     788              :                     V4DF_FTYPE_V4DF_PCDOUBLE_V8SI_V4DF_INT,
     789              :                     IX86_BUILTIN_GATHERALTSIV4DF);
     790              : 
     791       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatheraltdiv8sf ",
     792              :                     V8SF_FTYPE_V8SF_PCFLOAT_V4DI_V8SF_INT,
     793              :                     IX86_BUILTIN_GATHERALTDIV8SF);
     794              : 
     795       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatheraltsiv4di ",
     796              :                     V4DI_FTYPE_V4DI_PCINT64_V8SI_V4DI_INT,
     797              :                     IX86_BUILTIN_GATHERALTSIV4DI);
     798              : 
     799       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX2, 0, "__builtin_ia32_gatheraltdiv8si ",
     800              :                     V8SI_FTYPE_V8SI_PCINT_V4DI_V8SI_INT,
     801              :                     IX86_BUILTIN_GATHERALTDIV8SI);
     802              : 
     803              :   /* AVX512F */
     804       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     805              :                     "__builtin_ia32_gathersiv16sf",
     806              :                     V16SF_FTYPE_V16SF_PCVOID_V16SI_HI_INT,
     807              :                     IX86_BUILTIN_GATHER3SIV16SF);
     808              : 
     809       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     810              :                     "__builtin_ia32_gathersiv8df",
     811              :                     V8DF_FTYPE_V8DF_PCVOID_V8SI_QI_INT,
     812              :                     IX86_BUILTIN_GATHER3SIV8DF);
     813              : 
     814       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     815              :                     "__builtin_ia32_gatherdiv16sf",
     816              :                     V8SF_FTYPE_V8SF_PCVOID_V8DI_QI_INT,
     817              :                     IX86_BUILTIN_GATHER3DIV16SF);
     818              : 
     819       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     820              :                     "__builtin_ia32_gatherdiv8df",
     821              :                     V8DF_FTYPE_V8DF_PCVOID_V8DI_QI_INT,
     822              :                     IX86_BUILTIN_GATHER3DIV8DF);
     823              : 
     824       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     825              :                     "__builtin_ia32_gathersiv16si",
     826              :                     V16SI_FTYPE_V16SI_PCVOID_V16SI_HI_INT,
     827              :                     IX86_BUILTIN_GATHER3SIV16SI);
     828              : 
     829       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     830              :                     "__builtin_ia32_gathersiv8di",
     831              :                     V8DI_FTYPE_V8DI_PCVOID_V8SI_QI_INT,
     832              :                     IX86_BUILTIN_GATHER3SIV8DI);
     833              : 
     834       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     835              :                     "__builtin_ia32_gatherdiv16si",
     836              :                     V8SI_FTYPE_V8SI_PCVOID_V8DI_QI_INT,
     837              :                     IX86_BUILTIN_GATHER3DIV16SI);
     838              : 
     839       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     840              :                     "__builtin_ia32_gatherdiv8di",
     841              :                     V8DI_FTYPE_V8DI_PCVOID_V8DI_QI_INT,
     842              :                     IX86_BUILTIN_GATHER3DIV8DI);
     843              : 
     844       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     845              :                     "__builtin_ia32_gather3altsiv8df ",
     846              :                     V8DF_FTYPE_V8DF_PCDOUBLE_V16SI_QI_INT,
     847              :                     IX86_BUILTIN_GATHER3ALTSIV8DF);
     848              : 
     849       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     850              :                     "__builtin_ia32_gather3altdiv16sf ",
     851              :                     V16SF_FTYPE_V16SF_PCFLOAT_V8DI_HI_INT,
     852              :                     IX86_BUILTIN_GATHER3ALTDIV16SF);
     853              : 
     854       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     855              :                     "__builtin_ia32_gather3altsiv8di ",
     856              :                     V8DI_FTYPE_V8DI_PCINT64_V16SI_QI_INT,
     857              :                     IX86_BUILTIN_GATHER3ALTSIV8DI);
     858              : 
     859       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512F, 0,
     860              :                     "__builtin_ia32_gather3altdiv16si ",
     861              :                     V16SI_FTYPE_V16SI_PCINT_V8DI_HI_INT,
     862              :                     IX86_BUILTIN_GATHER3ALTDIV16SI);
     863              : 
     864       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     865              :                "__builtin_ia32_scattersiv16sf",
     866              :                VOID_FTYPE_PVOID_HI_V16SI_V16SF_INT,
     867              :                IX86_BUILTIN_SCATTERSIV16SF);
     868              : 
     869       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     870              :                "__builtin_ia32_scattersiv8df",
     871              :                VOID_FTYPE_PVOID_QI_V8SI_V8DF_INT,
     872              :                IX86_BUILTIN_SCATTERSIV8DF);
     873              : 
     874       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     875              :                "__builtin_ia32_scatterdiv16sf",
     876              :                VOID_FTYPE_PVOID_QI_V8DI_V8SF_INT,
     877              :                IX86_BUILTIN_SCATTERDIV16SF);
     878              : 
     879       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     880              :                "__builtin_ia32_scatterdiv8df",
     881              :                VOID_FTYPE_PVOID_QI_V8DI_V8DF_INT,
     882              :                IX86_BUILTIN_SCATTERDIV8DF);
     883              : 
     884       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     885              :                "__builtin_ia32_scattersiv16si",
     886              :                VOID_FTYPE_PVOID_HI_V16SI_V16SI_INT,
     887              :                IX86_BUILTIN_SCATTERSIV16SI);
     888              : 
     889       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     890              :                "__builtin_ia32_scattersiv8di",
     891              :                VOID_FTYPE_PVOID_QI_V8SI_V8DI_INT,
     892              :                IX86_BUILTIN_SCATTERSIV8DI);
     893              : 
     894       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     895              :                "__builtin_ia32_scatterdiv16si",
     896              :                VOID_FTYPE_PVOID_QI_V8DI_V8SI_INT,
     897              :                IX86_BUILTIN_SCATTERDIV16SI);
     898              : 
     899       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
     900              :                "__builtin_ia32_scatterdiv8di",
     901              :                VOID_FTYPE_PVOID_QI_V8DI_V8DI_INT,
     902              :                IX86_BUILTIN_SCATTERDIV8DI);
     903              : 
     904              :   /* AVX512VL */
     905       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv2df",
     906              :                     V2DF_FTYPE_V2DF_PCVOID_V4SI_QI_INT,
     907              :                     IX86_BUILTIN_GATHER3SIV2DF);
     908              : 
     909       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv4df",
     910              :                     V4DF_FTYPE_V4DF_PCVOID_V4SI_QI_INT,
     911              :                     IX86_BUILTIN_GATHER3SIV4DF);
     912              : 
     913       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div2df",
     914              :                     V2DF_FTYPE_V2DF_PCVOID_V2DI_QI_INT,
     915              :                     IX86_BUILTIN_GATHER3DIV2DF);
     916              : 
     917       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div4df",
     918              :                     V4DF_FTYPE_V4DF_PCVOID_V4DI_QI_INT,
     919              :                     IX86_BUILTIN_GATHER3DIV4DF);
     920              : 
     921       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv4sf",
     922              :                     V4SF_FTYPE_V4SF_PCVOID_V4SI_QI_INT,
     923              :                     IX86_BUILTIN_GATHER3SIV4SF);
     924              : 
     925       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv8sf",
     926              :                     V8SF_FTYPE_V8SF_PCVOID_V8SI_QI_INT,
     927              :                     IX86_BUILTIN_GATHER3SIV8SF);
     928              : 
     929       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div4sf",
     930              :                     V4SF_FTYPE_V4SF_PCVOID_V2DI_QI_INT,
     931              :                     IX86_BUILTIN_GATHER3DIV4SF);
     932              : 
     933       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div8sf",
     934              :                     V4SF_FTYPE_V4SF_PCVOID_V4DI_QI_INT,
     935              :                     IX86_BUILTIN_GATHER3DIV8SF);
     936              : 
     937       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv2di",
     938              :                     V2DI_FTYPE_V2DI_PCVOID_V4SI_QI_INT,
     939              :                     IX86_BUILTIN_GATHER3SIV2DI);
     940              : 
     941       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv4di",
     942              :                     V4DI_FTYPE_V4DI_PCVOID_V4SI_QI_INT,
     943              :                     IX86_BUILTIN_GATHER3SIV4DI);
     944              : 
     945       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div2di",
     946              :                     V2DI_FTYPE_V2DI_PCVOID_V2DI_QI_INT,
     947              :                     IX86_BUILTIN_GATHER3DIV2DI);
     948              : 
     949       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div4di",
     950              :                     V4DI_FTYPE_V4DI_PCVOID_V4DI_QI_INT,
     951              :                     IX86_BUILTIN_GATHER3DIV4DI);
     952              : 
     953       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv4si",
     954              :                     V4SI_FTYPE_V4SI_PCVOID_V4SI_QI_INT,
     955              :                     IX86_BUILTIN_GATHER3SIV4SI);
     956              : 
     957       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3siv8si",
     958              :                     V8SI_FTYPE_V8SI_PCVOID_V8SI_QI_INT,
     959              :                     IX86_BUILTIN_GATHER3SIV8SI);
     960              : 
     961       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div4si",
     962              :                     V4SI_FTYPE_V4SI_PCVOID_V2DI_QI_INT,
     963              :                     IX86_BUILTIN_GATHER3DIV4SI);
     964              : 
     965       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3div8si",
     966              :                     V4SI_FTYPE_V4SI_PCVOID_V4DI_QI_INT,
     967              :                     IX86_BUILTIN_GATHER3DIV8SI);
     968              : 
     969       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3altsiv4df ",
     970              :                     V4DF_FTYPE_V4DF_PCDOUBLE_V8SI_QI_INT,
     971              :                     IX86_BUILTIN_GATHER3ALTSIV4DF);
     972              : 
     973       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3altdiv8sf ",
     974              :                     V8SF_FTYPE_V8SF_PCFLOAT_V4DI_QI_INT,
     975              :                     IX86_BUILTIN_GATHER3ALTDIV8SF);
     976              : 
     977       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3altsiv4di ",
     978              :                     V4DI_FTYPE_V4DI_PCINT64_V8SI_QI_INT,
     979              :                     IX86_BUILTIN_GATHER3ALTSIV4DI);
     980              : 
     981       261249 :   def_builtin_pure (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_gather3altdiv8si ",
     982              :                     V8SI_FTYPE_V8SI_PCINT_V4DI_QI_INT,
     983              :                     IX86_BUILTIN_GATHER3ALTDIV8SI);
     984              : 
     985       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv8sf",
     986              :                VOID_FTYPE_PVOID_QI_V8SI_V8SF_INT,
     987              :                IX86_BUILTIN_SCATTERSIV8SF);
     988              : 
     989       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv4sf",
     990              :                VOID_FTYPE_PVOID_QI_V4SI_V4SF_INT,
     991              :                IX86_BUILTIN_SCATTERSIV4SF);
     992              : 
     993       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv4df",
     994              :                VOID_FTYPE_PVOID_QI_V4SI_V4DF_INT,
     995              :                IX86_BUILTIN_SCATTERSIV4DF);
     996              : 
     997       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv2df",
     998              :                VOID_FTYPE_PVOID_QI_V4SI_V2DF_INT,
     999              :                IX86_BUILTIN_SCATTERSIV2DF);
    1000              : 
    1001       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv8sf",
    1002              :                VOID_FTYPE_PVOID_QI_V4DI_V4SF_INT,
    1003              :                IX86_BUILTIN_SCATTERDIV8SF);
    1004              : 
    1005       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv4sf",
    1006              :                VOID_FTYPE_PVOID_QI_V2DI_V4SF_INT,
    1007              :                IX86_BUILTIN_SCATTERDIV4SF);
    1008              : 
    1009       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv4df",
    1010              :                VOID_FTYPE_PVOID_QI_V4DI_V4DF_INT,
    1011              :                IX86_BUILTIN_SCATTERDIV4DF);
    1012              : 
    1013       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv2df",
    1014              :                VOID_FTYPE_PVOID_QI_V2DI_V2DF_INT,
    1015              :                IX86_BUILTIN_SCATTERDIV2DF);
    1016              : 
    1017       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv8si",
    1018              :                VOID_FTYPE_PVOID_QI_V8SI_V8SI_INT,
    1019              :                IX86_BUILTIN_SCATTERSIV8SI);
    1020              : 
    1021       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv4si",
    1022              :                VOID_FTYPE_PVOID_QI_V4SI_V4SI_INT,
    1023              :                IX86_BUILTIN_SCATTERSIV4SI);
    1024              : 
    1025       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv4di",
    1026              :                VOID_FTYPE_PVOID_QI_V4SI_V4DI_INT,
    1027              :                IX86_BUILTIN_SCATTERSIV4DI);
    1028              : 
    1029       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scattersiv2di",
    1030              :                VOID_FTYPE_PVOID_QI_V4SI_V2DI_INT,
    1031              :                IX86_BUILTIN_SCATTERSIV2DI);
    1032              : 
    1033       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv8si",
    1034              :                VOID_FTYPE_PVOID_QI_V4DI_V4SI_INT,
    1035              :                IX86_BUILTIN_SCATTERDIV8SI);
    1036              : 
    1037       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv4si",
    1038              :                VOID_FTYPE_PVOID_QI_V2DI_V4SI_INT,
    1039              :                IX86_BUILTIN_SCATTERDIV4SI);
    1040              : 
    1041       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv4di",
    1042              :                VOID_FTYPE_PVOID_QI_V4DI_V4DI_INT,
    1043              :                IX86_BUILTIN_SCATTERDIV4DI);
    1044              : 
    1045       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatterdiv2di",
    1046              :                VOID_FTYPE_PVOID_QI_V2DI_V2DI_INT,
    1047              :                IX86_BUILTIN_SCATTERDIV2DI);
    1048              : 
    1049       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
    1050              :                "__builtin_ia32_scatteraltsiv8df ",
    1051              :                VOID_FTYPE_PDOUBLE_QI_V16SI_V8DF_INT,
    1052              :                IX86_BUILTIN_SCATTERALTSIV8DF);
    1053              : 
    1054       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
    1055              :                "__builtin_ia32_scatteraltdiv16sf ",
    1056              :                VOID_FTYPE_PFLOAT_HI_V8DI_V16SF_INT,
    1057              :                IX86_BUILTIN_SCATTERALTDIV16SF);
    1058              : 
    1059       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
    1060              :                "__builtin_ia32_scatteraltsiv8di ",
    1061              :                VOID_FTYPE_PLONGLONG_QI_V16SI_V8DI_INT,
    1062              :                IX86_BUILTIN_SCATTERALTSIV8DI);
    1063              : 
    1064       261249 :   def_builtin (OPTION_MASK_ISA_AVX512F, 0,
    1065              :                "__builtin_ia32_scatteraltdiv16si ",
    1066              :                VOID_FTYPE_PINT_HI_V8DI_V16SI_INT,
    1067              :                IX86_BUILTIN_SCATTERALTDIV16SI);
    1068              : 
    1069       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltsiv4df ",
    1070              :                VOID_FTYPE_PDOUBLE_QI_V8SI_V4DF_INT,
    1071              :                IX86_BUILTIN_SCATTERALTSIV4DF);
    1072              : 
    1073       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltdiv8sf ",
    1074              :                VOID_FTYPE_PFLOAT_QI_V4DI_V8SF_INT,
    1075              :                IX86_BUILTIN_SCATTERALTDIV8SF);
    1076              : 
    1077       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltsiv4di ",
    1078              :                VOID_FTYPE_PLONGLONG_QI_V8SI_V4DI_INT,
    1079              :                IX86_BUILTIN_SCATTERALTSIV4DI);
    1080              : 
    1081       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltdiv8si ",
    1082              :                VOID_FTYPE_PINT_QI_V4DI_V8SI_INT,
    1083              :                IX86_BUILTIN_SCATTERALTDIV8SI);
    1084              : 
    1085       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltsiv2df ",
    1086              :                VOID_FTYPE_PDOUBLE_QI_V4SI_V2DF_INT,
    1087              :                IX86_BUILTIN_SCATTERALTSIV2DF);
    1088              : 
    1089       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltdiv4sf ",
    1090              :                VOID_FTYPE_PFLOAT_QI_V2DI_V4SF_INT,
    1091              :                IX86_BUILTIN_SCATTERALTDIV4SF);
    1092              : 
    1093       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltsiv2di ",
    1094              :                VOID_FTYPE_PLONGLONG_QI_V4SI_V2DI_INT,
    1095              :                IX86_BUILTIN_SCATTERALTSIV2DI);
    1096              : 
    1097       261249 :   def_builtin (OPTION_MASK_ISA_AVX512VL, 0, "__builtin_ia32_scatteraltdiv4si ",
    1098              :                VOID_FTYPE_PINT_QI_V2DI_V4SI_INT,
    1099              :                IX86_BUILTIN_SCATTERALTDIV4SI);
    1100              : 
    1101              :   /* SHA */
    1102       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha1msg1",
    1103              :                      V4SI_FTYPE_V4SI_V4SI, IX86_BUILTIN_SHA1MSG1);
    1104       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha1msg2",
    1105              :                      V4SI_FTYPE_V4SI_V4SI, IX86_BUILTIN_SHA1MSG2);
    1106       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha1nexte",
    1107              :                      V4SI_FTYPE_V4SI_V4SI, IX86_BUILTIN_SHA1NEXTE);
    1108       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha1rnds4",
    1109              :                      V4SI_FTYPE_V4SI_V4SI_INT, IX86_BUILTIN_SHA1RNDS4);
    1110       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha256msg1",
    1111              :                      V4SI_FTYPE_V4SI_V4SI, IX86_BUILTIN_SHA256MSG1);
    1112       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha256msg2",
    1113              :                      V4SI_FTYPE_V4SI_V4SI, IX86_BUILTIN_SHA256MSG2);
    1114       261249 :   def_builtin_const (OPTION_MASK_ISA_SHA, 0, "__builtin_ia32_sha256rnds2",
    1115              :                      V4SI_FTYPE_V4SI_V4SI_V4SI, IX86_BUILTIN_SHA256RNDS2);
    1116              : 
    1117              :   /* RTM.  */
    1118       261249 :   def_builtin (OPTION_MASK_ISA_RTM, 0, "__builtin_ia32_xabort",
    1119              :                VOID_FTYPE_UNSIGNED, IX86_BUILTIN_XABORT);
    1120              : 
    1121              :   /* MMX access to the vec_init patterns.  */
    1122       261249 :   def_builtin_const (OPTION_MASK_ISA_MMX, 0,
    1123              :                      "__builtin_ia32_vec_init_v2si",
    1124              :                      V2SI_FTYPE_INT_INT, IX86_BUILTIN_VEC_INIT_V2SI);
    1125              : 
    1126       261249 :   def_builtin_const (OPTION_MASK_ISA_MMX, 0,
    1127              :                      "__builtin_ia32_vec_init_v4hi",
    1128              :                      V4HI_FTYPE_HI_HI_HI_HI,
    1129              :                      IX86_BUILTIN_VEC_INIT_V4HI);
    1130              : 
    1131       261249 :   def_builtin_const (OPTION_MASK_ISA_MMX, 0,
    1132              :                      "__builtin_ia32_vec_init_v8qi",
    1133              :                      V8QI_FTYPE_QI_QI_QI_QI_QI_QI_QI_QI,
    1134              :                      IX86_BUILTIN_VEC_INIT_V8QI);
    1135              : 
    1136              :   /* Access to the vec_extract patterns.  */
    1137       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_ext_v2df",
    1138              :                      DOUBLE_FTYPE_V2DF_INT, IX86_BUILTIN_VEC_EXT_V2DF);
    1139       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_ext_v2di",
    1140              :                      DI_FTYPE_V2DI_INT, IX86_BUILTIN_VEC_EXT_V2DI);
    1141       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE, 0, "__builtin_ia32_vec_ext_v4sf",
    1142              :                      FLOAT_FTYPE_V4SF_INT, IX86_BUILTIN_VEC_EXT_V4SF);
    1143       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_ext_v4si",
    1144              :                      SI_FTYPE_V4SI_INT, IX86_BUILTIN_VEC_EXT_V4SI);
    1145       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_ext_v8hi",
    1146              :                      HI_FTYPE_V8HI_INT, IX86_BUILTIN_VEC_EXT_V8HI);
    1147              : 
    1148       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_3DNOW_A
    1149              :                      /* As it uses V4HImode, we have to require -mmmx too.  */
    1150              :                      | OPTION_MASK_ISA_MMX, 0,
    1151              :                      "__builtin_ia32_vec_ext_v4hi",
    1152              :                      HI_FTYPE_V4HI_INT, IX86_BUILTIN_VEC_EXT_V4HI);
    1153              : 
    1154       261249 :   def_builtin_const (OPTION_MASK_ISA_MMX, 0,
    1155              :                      "__builtin_ia32_vec_ext_v2si",
    1156              :                      SI_FTYPE_V2SI_INT, IX86_BUILTIN_VEC_EXT_V2SI);
    1157              : 
    1158       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_ext_v16qi",
    1159              :                      QI_FTYPE_V16QI_INT, IX86_BUILTIN_VEC_EXT_V16QI);
    1160              : 
    1161              :   /* Access to the vec_set patterns.  */
    1162       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE4_1 | OPTION_MASK_ISA_64BIT, 0,
    1163              :                      "__builtin_ia32_vec_set_v2di",
    1164              :                      V2DI_FTYPE_V2DI_DI_INT, IX86_BUILTIN_VEC_SET_V2DI);
    1165              : 
    1166       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE4_1, 0, "__builtin_ia32_vec_set_v4sf",
    1167              :                      V4SF_FTYPE_V4SF_FLOAT_INT, IX86_BUILTIN_VEC_SET_V4SF);
    1168              : 
    1169       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE4_1, 0, "__builtin_ia32_vec_set_v4si",
    1170              :                      V4SI_FTYPE_V4SI_SI_INT, IX86_BUILTIN_VEC_SET_V4SI);
    1171              : 
    1172       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE2, 0, "__builtin_ia32_vec_set_v8hi",
    1173              :                      V8HI_FTYPE_V8HI_HI_INT, IX86_BUILTIN_VEC_SET_V8HI);
    1174              : 
    1175       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_3DNOW_A
    1176              :                      /* As it uses V4HImode, we have to require -mmmx too.  */
    1177              :                      | OPTION_MASK_ISA_MMX, 0,
    1178              :                      "__builtin_ia32_vec_set_v4hi",
    1179              :                      V4HI_FTYPE_V4HI_HI_INT, IX86_BUILTIN_VEC_SET_V4HI);
    1180              : 
    1181       261249 :   def_builtin_const (OPTION_MASK_ISA_SSE4_1, 0, "__builtin_ia32_vec_set_v16qi",
    1182              :                      V16QI_FTYPE_V16QI_QI_INT, IX86_BUILTIN_VEC_SET_V16QI);
    1183              : 
    1184              :   /* RDSEED */
    1185       261249 :   def_builtin (OPTION_MASK_ISA_RDSEED, 0, "__builtin_ia32_rdseed_hi_step",
    1186              :                INT_FTYPE_PUSHORT, IX86_BUILTIN_RDSEED16_STEP);
    1187       261249 :   def_builtin (OPTION_MASK_ISA_RDSEED, 0, "__builtin_ia32_rdseed_si_step",
    1188              :                INT_FTYPE_PUNSIGNED, IX86_BUILTIN_RDSEED32_STEP);
    1189       261249 :   def_builtin (OPTION_MASK_ISA_RDSEED | OPTION_MASK_ISA_64BIT, 0,
    1190              :                "__builtin_ia32_rdseed_di_step",
    1191              :                INT_FTYPE_PULONGLONG, IX86_BUILTIN_RDSEED64_STEP);
    1192              : 
    1193              :   /* ADCX */
    1194       261249 :   def_builtin (0, 0, "__builtin_ia32_addcarryx_u32",
    1195              :                UCHAR_FTYPE_UCHAR_UINT_UINT_PUNSIGNED, IX86_BUILTIN_ADDCARRYX32);
    1196       261249 :   def_builtin (OPTION_MASK_ISA_64BIT, 0,
    1197              :                "__builtin_ia32_addcarryx_u64",
    1198              :                UCHAR_FTYPE_UCHAR_ULONGLONG_ULONGLONG_PULONGLONG,
    1199              :                IX86_BUILTIN_ADDCARRYX64);
    1200              : 
    1201              :   /* SBB */
    1202       261249 :   def_builtin (0, 0, "__builtin_ia32_sbb_u32",
    1203              :                UCHAR_FTYPE_UCHAR_UINT_UINT_PUNSIGNED, IX86_BUILTIN_SBB32);
    1204       261249 :   def_builtin (OPTION_MASK_ISA_64BIT, 0,
    1205              :                "__builtin_ia32_sbb_u64",
    1206              :                UCHAR_FTYPE_UCHAR_ULONGLONG_ULONGLONG_PULONGLONG,
    1207              :                IX86_BUILTIN_SBB64);
    1208              : 
    1209              :   /* Read/write FLAGS.  */
    1210       261249 :   if (TARGET_64BIT)
    1211              :     {
    1212       255466 :       def_builtin (OPTION_MASK_ISA_64BIT, 0, "__builtin_ia32_readeflags_u64",
    1213              :                    UINT64_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
    1214       255466 :       def_builtin (OPTION_MASK_ISA_64BIT, 0, "__builtin_ia32_writeeflags_u64",
    1215              :                    VOID_FTYPE_UINT64, IX86_BUILTIN_WRITE_FLAGS);
    1216              :     }
    1217              :   else
    1218              :     {
    1219         5783 :       def_builtin (0, 0, "__builtin_ia32_readeflags_u32",
    1220              :                    UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
    1221         5783 :       def_builtin (0, 0, "__builtin_ia32_writeeflags_u32",
    1222              :                    VOID_FTYPE_UNSIGNED, IX86_BUILTIN_WRITE_FLAGS);
    1223              :     }
    1224              : 
    1225              :   /* CLFLUSHOPT.  */
    1226       261249 :   def_builtin (OPTION_MASK_ISA_CLFLUSHOPT, 0, "__builtin_ia32_clflushopt",
    1227              :                VOID_FTYPE_PCVOID, IX86_BUILTIN_CLFLUSHOPT);
    1228              : 
    1229              :   /* CLWB.  */
    1230       261249 :   def_builtin (OPTION_MASK_ISA_CLWB, 0, "__builtin_ia32_clwb",
    1231              :                VOID_FTYPE_PCVOID, IX86_BUILTIN_CLWB);
    1232              : 
    1233              :   /* MONITORX and MWAITX.  */
    1234       261249 :   def_builtin (0, OPTION_MASK_ISA2_MWAITX, "__builtin_ia32_monitorx",
    1235              :                 VOID_FTYPE_PCVOID_UNSIGNED_UNSIGNED, IX86_BUILTIN_MONITORX);
    1236       261249 :   def_builtin (0, OPTION_MASK_ISA2_MWAITX, "__builtin_ia32_mwaitx",
    1237              :                 VOID_FTYPE_UNSIGNED_UNSIGNED_UNSIGNED, IX86_BUILTIN_MWAITX);
    1238              : 
    1239              :   /* CLZERO.  */
    1240       261249 :   def_builtin (0, OPTION_MASK_ISA2_CLZERO, "__builtin_ia32_clzero",
    1241              :                 VOID_FTYPE_PCVOID, IX86_BUILTIN_CLZERO);
    1242              : 
    1243              :   /* WAITPKG.  */
    1244       261249 :   def_builtin (0, OPTION_MASK_ISA2_WAITPKG, "__builtin_ia32_umonitor",
    1245              :                VOID_FTYPE_PVOID, IX86_BUILTIN_UMONITOR);
    1246       261249 :   def_builtin (0, OPTION_MASK_ISA2_WAITPKG, "__builtin_ia32_umwait",
    1247              :                UINT8_FTYPE_UNSIGNED_UINT64, IX86_BUILTIN_UMWAIT);
    1248       261249 :   def_builtin (0, OPTION_MASK_ISA2_WAITPKG, "__builtin_ia32_tpause",
    1249              :                UINT8_FTYPE_UNSIGNED_UINT64, IX86_BUILTIN_TPAUSE);
    1250              : 
    1251              :   /* UINTR.  */
    1252       261249 :   def_builtin (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_UINTR,
    1253              :                "__builtin_ia32_testui",
    1254              :                UINT8_FTYPE_VOID, IX86_BUILTIN_TESTUI);
    1255              : 
    1256              :   /* USER_MSR.  */
    1257       261249 :   def_builtin (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_USER_MSR,
    1258              :                "__builtin_ia32_urdmsr", UINT64_FTYPE_UINT64,
    1259              :                IX86_BUILTIN_URDMSR);
    1260       261249 :   def_builtin (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_USER_MSR,
    1261              :                "__builtin_ia32_uwrmsr", VOID_FTYPE_UINT64_UINT64,
    1262              :                IX86_BUILTIN_UWRMSR);
    1263              : 
    1264              :   /* CLDEMOTE.  */
    1265       261249 :   def_builtin (0, OPTION_MASK_ISA2_CLDEMOTE, "__builtin_ia32_cldemote",
    1266              :                VOID_FTYPE_PCVOID, IX86_BUILTIN_CLDEMOTE);
    1267              : 
    1268              :   /* Add FMA4 multi-arg argument instructions */
    1269     42844836 :   for (i = 0, d = bdesc_multi_arg; i < ARRAY_SIZE (bdesc_multi_arg); i++, d++)
    1270              :     {
    1271     42322338 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_MULTI_ARG_FIRST, i);
    1272     42322338 :       if (d->name == 0)
    1273            0 :         continue;
    1274              : 
    1275     42322338 :       ftype = (enum ix86_builtin_func_type) d->flag;
    1276     42322338 :       def_builtin_const (d->mask, d->mask2, d->name, ftype, d->code);
    1277              :     }
    1278              :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_MULTI_ARG_LAST,
    1279              :                  IX86_BUILTIN__BDESC_MULTI_ARG_FIRST,
    1280              :                  ARRAY_SIZE (bdesc_multi_arg) - 1);
    1281              : 
    1282              :   /* Add CET inrinsics.  */
    1283      3396237 :   for (i = 0, d = bdesc_cet; i < ARRAY_SIZE (bdesc_cet); i++, d++)
    1284              :     {
    1285      3134988 :       BDESC_VERIFY (d->code, IX86_BUILTIN__BDESC_CET_FIRST, i);
    1286      3134988 :       if (d->name == 0)
    1287            0 :         continue;
    1288              : 
    1289      3134988 :       ftype = (enum ix86_builtin_func_type) d->flag;
    1290      3134988 :       def_builtin (d->mask, d->mask2, d->name, ftype, d->code);
    1291              :     }
    1292       261249 :   BDESC_VERIFYS (IX86_BUILTIN__BDESC_CET_LAST,
    1293              :                  IX86_BUILTIN__BDESC_CET_FIRST,
    1294              :                  ARRAY_SIZE (bdesc_cet) - 1);
    1295       261249 : }
    1296              : 
    1297              : #undef BDESC_VERIFY
    1298              : #undef BDESC_VERIFYS
    1299              : 
    1300              : /* Make builtins to detect cpu type and features supported.  NAME is
    1301              :    the builtin name, CODE is the builtin code, and FTYPE is the function
    1302              :    type of the builtin.  */
    1303              : 
    1304              : static void
    1305       783747 : make_cpu_type_builtin (const char* name, int code,
    1306              :                        enum ix86_builtin_func_type ftype, bool is_const)
    1307              : {
    1308       783747 :   tree decl;
    1309       783747 :   tree type;
    1310              : 
    1311       783747 :   type = ix86_get_builtin_func_type (ftype);
    1312       783747 :   decl = add_builtin_function (name, type, code, BUILT_IN_MD,
    1313              :                                NULL, NULL_TREE);
    1314       783747 :   gcc_assert (decl != NULL_TREE);
    1315       783747 :   ix86_builtins[(int) code] = decl;
    1316       783747 :   TREE_READONLY (decl) = is_const;
    1317       783747 : }
    1318              : 
    1319              : /* Make builtins to get CPU type and features supported.  The created
    1320              :    builtins are :
    1321              : 
    1322              :    __builtin_cpu_init (), to detect cpu type and features,
    1323              :    __builtin_cpu_is ("<CPUNAME>"), to check if cpu is of type <CPUNAME>,
    1324              :    __builtin_cpu_supports ("<FEATURE>"), to check if cpu supports <FEATURE>
    1325              :    */
    1326              : 
    1327              : static void
    1328       261249 : ix86_init_platform_type_builtins (void)
    1329              : {
    1330       261249 :   make_cpu_type_builtin ("__builtin_cpu_init", IX86_BUILTIN_CPU_INIT,
    1331              :                          INT_FTYPE_VOID, false);
    1332       261249 :   make_cpu_type_builtin ("__builtin_cpu_is", IX86_BUILTIN_CPU_IS,
    1333              :                          INT_FTYPE_PCCHAR, true);
    1334       261249 :   make_cpu_type_builtin ("__builtin_cpu_supports", IX86_BUILTIN_CPU_SUPPORTS,
    1335              :                          INT_FTYPE_PCCHAR, true);
    1336       261249 : }
    1337              : 
    1338              : /* Internal method for ix86_init_builtins.  */
    1339              : 
    1340              : static void
    1341       255374 : ix86_init_builtins_va_builtins_abi (void)
    1342              : {
    1343       255374 :   tree ms_va_ref, sysv_va_ref;
    1344       255374 :   tree fnvoid_va_end_ms, fnvoid_va_end_sysv;
    1345       255374 :   tree fnvoid_va_start_ms, fnvoid_va_start_sysv;
    1346       255374 :   tree fnvoid_va_copy_ms, fnvoid_va_copy_sysv;
    1347       255374 :   tree fnattr_ms = NULL_TREE, fnattr_sysv = NULL_TREE;
    1348              : 
    1349       255374 :   if (!TARGET_64BIT)
    1350              :     return;
    1351              :   /* The va builtins are both nothrow and leaf. */
    1352       255374 :   tree fnattr = NULL_TREE;
    1353       255374 :   fnattr = tree_cons (get_identifier ("nothrow"), NULL_TREE, fnattr);
    1354       255374 :   fnattr = tree_cons (get_identifier ("leaf"), NULL_TREE, fnattr);
    1355              : 
    1356       255374 :   fnattr_ms = tree_cons (get_identifier ("ms_abi"), NULL_TREE, fnattr);
    1357       255374 :   fnattr_sysv = tree_cons (get_identifier ("sysv_abi"), NULL_TREE, fnattr);
    1358       255374 :   ms_va_ref = build_reference_type (ms_va_list_type_node);
    1359       255374 :   sysv_va_ref = build_pointer_type (TREE_TYPE (sysv_va_list_type_node));
    1360              : 
    1361       255374 :   fnvoid_va_end_ms = build_function_type_list (void_type_node, ms_va_ref,
    1362              :                                                NULL_TREE);
    1363       255374 :   fnvoid_va_start_ms
    1364       255374 :     = build_varargs_function_type_list (void_type_node, ms_va_ref, NULL_TREE);
    1365       255374 :   fnvoid_va_end_sysv
    1366       255374 :     = build_function_type_list (void_type_node, sysv_va_ref, NULL_TREE);
    1367       255374 :   fnvoid_va_start_sysv
    1368       255374 :     = build_varargs_function_type_list (void_type_node, sysv_va_ref,
    1369              :                                         NULL_TREE);
    1370       255374 :   fnvoid_va_copy_ms
    1371       255374 :     = build_function_type_list (void_type_node, ms_va_ref,
    1372              :                                 ms_va_list_type_node, NULL_TREE);
    1373       255374 :   fnvoid_va_copy_sysv
    1374       255374 :     = build_function_type_list (void_type_node, sysv_va_ref,
    1375              :                                 sysv_va_ref, NULL_TREE);
    1376              : 
    1377       255374 :   add_builtin_function ("__builtin_ms_va_start", fnvoid_va_start_ms,
    1378              :                         BUILT_IN_VA_START, BUILT_IN_NORMAL, NULL, fnattr_ms);
    1379       255374 :   add_builtin_function ("__builtin_ms_va_end", fnvoid_va_end_ms,
    1380              :                         BUILT_IN_VA_END, BUILT_IN_NORMAL, NULL, fnattr_ms);
    1381       255374 :   add_builtin_function ("__builtin_ms_va_copy", fnvoid_va_copy_ms,
    1382              :                         BUILT_IN_VA_COPY, BUILT_IN_NORMAL, NULL, fnattr_ms);
    1383       255374 :   add_builtin_function ("__builtin_sysv_va_start", fnvoid_va_start_sysv,
    1384              :                         BUILT_IN_VA_START, BUILT_IN_NORMAL, NULL, fnattr_sysv);
    1385       255374 :   add_builtin_function ("__builtin_sysv_va_end", fnvoid_va_end_sysv,
    1386              :                         BUILT_IN_VA_END, BUILT_IN_NORMAL, NULL, fnattr_sysv);
    1387       255374 :   add_builtin_function ("__builtin_sysv_va_copy", fnvoid_va_copy_sysv,
    1388              :                         BUILT_IN_VA_COPY, BUILT_IN_NORMAL, NULL, fnattr_sysv);
    1389              : }
    1390              : 
    1391              : static void
    1392       261249 : ix86_register_float16_builtin_type (void)
    1393              : {
    1394              :   /* Provide the _Float16 type and float16_type_node if needed so that
    1395              :      it can be used in AVX512FP16 intrinsics and builtins.  */
    1396       261249 :   if (!float16_type_node)
    1397              :     {
    1398            0 :       ix86_float16_type_node = make_node (REAL_TYPE);
    1399            0 :       TYPE_PRECISION (ix86_float16_type_node) = 16;
    1400            0 :       SET_TYPE_MODE (ix86_float16_type_node, HFmode);
    1401            0 :       layout_type (ix86_float16_type_node);
    1402              :     }
    1403              :   else
    1404       261249 :     ix86_float16_type_node = float16_type_node;
    1405              : 
    1406       261249 :   if (!maybe_get_identifier ("_Float16"))
    1407        53088 :     lang_hooks.types.register_builtin_type (ix86_float16_type_node,
    1408              :                                             "_Float16");
    1409       261249 : }
    1410              : 
    1411              : static void
    1412       261249 : ix86_register_bf16_builtin_type (void)
    1413              : {
    1414       261249 :   if (bfloat16_type_node == NULL_TREE)
    1415              :     {
    1416            0 :       ix86_bf16_type_node = make_node (REAL_TYPE);
    1417            0 :       TYPE_PRECISION (ix86_bf16_type_node) = 16;
    1418            0 :       SET_TYPE_MODE (ix86_bf16_type_node, BFmode);
    1419            0 :       layout_type (ix86_bf16_type_node);
    1420              :     }
    1421              :   else
    1422       261249 :     ix86_bf16_type_node = bfloat16_type_node;
    1423              : 
    1424       261249 :   if (!maybe_get_identifier ("__bf16"))
    1425       261249 :     lang_hooks.types.register_builtin_type (ix86_bf16_type_node, "__bf16");
    1426       261249 : }
    1427              : 
    1428              : static void
    1429       261249 : ix86_init_builtin_types (void)
    1430              : {
    1431       261249 :   tree float80_type_node, const_string_type_node;
    1432              : 
    1433              :   /* The __float80 type.  */
    1434       261249 :   float80_type_node = long_double_type_node;
    1435       261249 :   if (TYPE_MODE (float80_type_node) != XFmode)
    1436              :     {
    1437           22 :       if (float64x_type_node != NULL_TREE
    1438           22 :           && TYPE_MODE (float64x_type_node) == XFmode)
    1439            0 :         float80_type_node = float64x_type_node;
    1440              :       else
    1441              :         {
    1442              :           /* The __float80 type.  */
    1443           22 :           float80_type_node = make_node (REAL_TYPE);
    1444              : 
    1445           22 :           TYPE_PRECISION (float80_type_node) = 80;
    1446           22 :           layout_type (float80_type_node);
    1447              :         }
    1448              :     }
    1449       261249 :   lang_hooks.types.register_builtin_type (float80_type_node, "__float80");
    1450              : 
    1451              :   /* The __float128 type.  The node has already been created as
    1452              :      _Float128, so for C we only need to register the __float128 name for
    1453              :      it.  For C++, we create a distinct type which will mangle differently
    1454              :      (g) vs. _Float128 (DF128_) and behave backwards compatibly.  */
    1455       261249 :   if (float128t_type_node == NULL_TREE)
    1456              :     {
    1457        98033 :       float128t_type_node = make_node (REAL_TYPE);
    1458        98033 :       TYPE_PRECISION (float128t_type_node)
    1459        98033 :         = TYPE_PRECISION (float128_type_node);
    1460        98033 :       SET_TYPE_MODE (float128t_type_node, TYPE_MODE (float128_type_node));
    1461        98033 :       layout_type (float128t_type_node);
    1462              :     }
    1463       261249 :   lang_hooks.types.register_builtin_type (float128t_type_node, "__float128");
    1464              : 
    1465       261249 :   ix86_register_float16_builtin_type ();
    1466              : 
    1467       261249 :   ix86_register_bf16_builtin_type ();
    1468              : 
    1469       261249 :   const_string_type_node
    1470       261249 :     = build_pointer_type (build_qualified_type
    1471              :                           (char_type_node, TYPE_QUAL_CONST));
    1472              : 
    1473              :   /* This macro is built by i386-builtin-types.awk.  */
    1474       261249 :   DEFINE_BUILTIN_PRIMITIVE_TYPES;
    1475       261249 : }
    1476              : 
    1477              : void
    1478       261249 : ix86_init_builtins (void)
    1479              : {
    1480       261249 :   tree ftype, decl;
    1481              : 
    1482       261249 :   ix86_init_builtin_types ();
    1483              : 
    1484              :   /* Builtins to get CPU type and features. */
    1485       261249 :   ix86_init_platform_type_builtins ();
    1486              : 
    1487              :   /* TFmode support builtins.  */
    1488       261249 :   def_builtin_const (0, 0, "__builtin_infq",
    1489              :                      FLOAT128_FTYPE_VOID, IX86_BUILTIN_INFQ);
    1490       261249 :   def_builtin_const (0, 0, "__builtin_huge_valq",
    1491              :                      FLOAT128_FTYPE_VOID, IX86_BUILTIN_HUGE_VALQ);
    1492              : 
    1493       261249 :   ftype = ix86_get_builtin_func_type (FLOAT128_FTYPE_CONST_STRING);
    1494       261249 :   decl = add_builtin_function ("__builtin_nanq", ftype, IX86_BUILTIN_NANQ,
    1495              :                                BUILT_IN_MD, "nanq", NULL_TREE);
    1496       261249 :   TREE_READONLY (decl) = 1;
    1497       261249 :   ix86_builtins[(int) IX86_BUILTIN_NANQ] = decl;
    1498              : 
    1499       261249 :   decl = add_builtin_function ("__builtin_nansq", ftype, IX86_BUILTIN_NANSQ,
    1500              :                                BUILT_IN_MD, "nansq", NULL_TREE);
    1501       261249 :   TREE_READONLY (decl) = 1;
    1502       261249 :   ix86_builtins[(int) IX86_BUILTIN_NANSQ] = decl;
    1503              : 
    1504              :   /* We will expand them to normal call if SSE isn't available since
    1505              :      they are used by libgcc. */
    1506       261249 :   ftype = ix86_get_builtin_func_type (FLOAT128_FTYPE_FLOAT128);
    1507       261249 :   decl = add_builtin_function ("__builtin_fabsq", ftype, IX86_BUILTIN_FABSQ,
    1508              :                                BUILT_IN_MD, "__fabstf2", NULL_TREE);
    1509       261249 :   TREE_READONLY (decl) = 1;
    1510       261249 :   ix86_builtins[(int) IX86_BUILTIN_FABSQ] = decl;
    1511              : 
    1512       261249 :   ftype = ix86_get_builtin_func_type (FLOAT128_FTYPE_FLOAT128_FLOAT128);
    1513       261249 :   decl = add_builtin_function ("__builtin_copysignq", ftype,
    1514              :                                IX86_BUILTIN_COPYSIGNQ, BUILT_IN_MD,
    1515              :                                "__copysigntf3", NULL_TREE);
    1516       261249 :   TREE_READONLY (decl) = 1;
    1517       261249 :   ix86_builtins[(int) IX86_BUILTIN_COPYSIGNQ] = decl;
    1518              : 
    1519       261249 :   ix86_init_tm_builtins ();
    1520       261249 :   ix86_init_mmx_sse_builtins ();
    1521              : 
    1522       261249 :   if (TARGET_LP64)
    1523       255374 :     ix86_init_builtins_va_builtins_abi ();
    1524              : 
    1525              : #ifdef SUBTARGET_INIT_BUILTINS
    1526              :   SUBTARGET_INIT_BUILTINS;
    1527              : #endif
    1528       261249 : }
    1529              : 
    1530              : /* Return the ix86 builtin for CODE.  */
    1531              : 
    1532              : tree
    1533         1748 : ix86_builtin_decl (unsigned code, bool)
    1534              : {
    1535         1748 :   if (code >= IX86_BUILTIN_MAX)
    1536            0 :     return error_mark_node;
    1537              : 
    1538         1748 :   return ix86_builtins[code];
    1539              : }
    1540              : 
    1541              : /* This returns the target-specific builtin with code CODE if
    1542              :    current_function_decl has visibility on this builtin, which is checked
    1543              :    using isa flags.  Returns NULL_TREE otherwise.  */
    1544              : 
    1545         1600 : static tree ix86_get_builtin (enum ix86_builtins code)
    1546              : {
    1547         1600 :   struct cl_target_option *opts;
    1548         1600 :   tree target_tree = NULL_TREE;
    1549              : 
    1550              :   /* Determine the isa flags of current_function_decl.  */
    1551              : 
    1552         1600 :   if (current_function_decl)
    1553         1600 :     target_tree = DECL_FUNCTION_SPECIFIC_TARGET (current_function_decl);
    1554              : 
    1555         1600 :   if (target_tree == NULL)
    1556         1419 :     target_tree = target_option_default_node;
    1557              : 
    1558         1600 :   opts = TREE_TARGET_OPTION (target_tree);
    1559              : 
    1560         1600 :   if ((ix86_builtins_isa[(int) code].isa & opts->x_ix86_isa_flags)
    1561            0 :       || (ix86_builtins_isa[(int) code].isa2 & opts->x_ix86_isa_flags2))
    1562         1600 :     return ix86_builtin_decl (code, true);
    1563              :   else
    1564              :     return NULL_TREE;
    1565              : }
    1566              : 
    1567              : /* Vectorization library interface and handlers.  */
    1568              : tree (*ix86_veclib_handler) (combined_fn, tree, tree);
    1569              : 
    1570              : /* Returns a function decl for a vectorized version of the combined function
    1571              :    with combined_fn code FN and the result vector type TYPE, or NULL_TREE
    1572              :    if it is not available.  */
    1573              : 
    1574              : tree
    1575         5929 : ix86_builtin_vectorized_function (unsigned int fn, tree type_out,
    1576              :                                   tree type_in)
    1577              : {
    1578         5929 :   machine_mode in_mode, out_mode;
    1579         5929 :   int in_n, out_n;
    1580              : 
    1581         5929 :   if (TREE_CODE (type_out) != VECTOR_TYPE
    1582         5929 :       || TREE_CODE (type_in) != VECTOR_TYPE)
    1583              :     return NULL_TREE;
    1584              : 
    1585         5929 :   out_mode = TYPE_MODE (TREE_TYPE (type_out));
    1586         5929 :   out_n = TYPE_VECTOR_SUBPARTS (type_out);
    1587         5929 :   in_mode = TYPE_MODE (TREE_TYPE (type_in));
    1588         5929 :   in_n = TYPE_VECTOR_SUBPARTS (type_in);
    1589              : 
    1590         5929 :   switch (fn)
    1591              :     {
    1592           21 :     CASE_CFN_IFLOOR:
    1593           21 :     CASE_CFN_LFLOOR:
    1594              :       /* The round insn does not trap on denormals.  */
    1595           21 :       if (flag_trapping_math || !TARGET_SSE4_1)
    1596              :         break;
    1597              : 
    1598              :       /* PR106910, currently vectorizer doesn't go direct internal fn way
    1599              :          when out_n != in_n, so let's still keep this.
    1600              :          Otherwise, it relies on expander of
    1601              :          lceilmn2/lfloormn2/lroundmn2/lrintmn2.  */
    1602           21 :       if (out_mode == SImode && in_mode == DFmode)
    1603              :         {
    1604           21 :           if (out_n == 4 && in_n == 2)
    1605           10 :             return ix86_get_builtin (IX86_BUILTIN_FLOORPD_VEC_PACK_SFIX);
    1606           11 :           else if (out_n == 8 && in_n == 4)
    1607            7 :             return ix86_get_builtin (IX86_BUILTIN_FLOORPD_VEC_PACK_SFIX256);
    1608            4 :           else if (out_n == 16 && in_n == 8)
    1609            4 :             return ix86_get_builtin (IX86_BUILTIN_FLOORPD_VEC_PACK_SFIX512);
    1610              :         }
    1611              :       break;
    1612              : 
    1613           21 :     CASE_CFN_ICEIL:
    1614           21 :     CASE_CFN_LCEIL:
    1615              :       /* The round insn does not trap on denormals.  */
    1616           21 :       if (flag_trapping_math || !TARGET_SSE4_1)
    1617              :         break;
    1618              : 
    1619           21 :       if (out_mode == SImode && in_mode == DFmode)
    1620              :         {
    1621           21 :           if (out_n == 4 && in_n == 2)
    1622           10 :             return ix86_get_builtin (IX86_BUILTIN_CEILPD_VEC_PACK_SFIX);
    1623           11 :           else if (out_n == 8 && in_n == 4)
    1624            7 :             return ix86_get_builtin (IX86_BUILTIN_CEILPD_VEC_PACK_SFIX256);
    1625            4 :           else if (out_n == 16 && in_n == 8)
    1626            4 :             return ix86_get_builtin (IX86_BUILTIN_CEILPD_VEC_PACK_SFIX512);
    1627              :         }
    1628              :       break;
    1629              : 
    1630           99 :     CASE_CFN_IRINT:
    1631           99 :     CASE_CFN_LRINT:
    1632           99 :       if (out_mode == SImode && in_mode == DFmode)
    1633              :         {
    1634           21 :           if (out_n == 4 && in_n == 2)
    1635           10 :             return ix86_get_builtin (IX86_BUILTIN_VEC_PACK_SFIX);
    1636           11 :           else if (out_n == 8 && in_n == 4)
    1637            7 :             return ix86_get_builtin (IX86_BUILTIN_VEC_PACK_SFIX256);
    1638            4 :           else if (out_n == 16 && in_n == 8)
    1639            4 :             return ix86_get_builtin (IX86_BUILTIN_VEC_PACK_SFIX512);
    1640              :         }
    1641              :       break;
    1642              : 
    1643           43 :     CASE_CFN_IROUND:
    1644           43 :     CASE_CFN_LROUND:
    1645              :       /* The round insn does not trap on denormals.  */
    1646           43 :       if (flag_trapping_math || !TARGET_SSE4_1)
    1647              :         break;
    1648              : 
    1649           21 :       if (out_mode == SImode && in_mode == DFmode)
    1650              :         {
    1651           21 :           if (out_n == 4 && in_n == 2)
    1652           10 :             return ix86_get_builtin (IX86_BUILTIN_ROUNDPD_AZ_VEC_PACK_SFIX);
    1653           11 :           else if (out_n == 8 && in_n == 4)
    1654            7 :             return ix86_get_builtin (IX86_BUILTIN_ROUNDPD_AZ_VEC_PACK_SFIX256);
    1655            4 :           else if (out_n == 16 && in_n == 8)
    1656            4 :             return ix86_get_builtin (IX86_BUILTIN_ROUNDPD_AZ_VEC_PACK_SFIX512);
    1657              :         }
    1658              :       break;
    1659              : 
    1660              : 
    1661              :     default:
    1662              :       break;
    1663              :     }
    1664              : 
    1665              :   /* Dispatch to a handler for a vectorization library.  */
    1666         5845 :   if (ix86_veclib_handler)
    1667          233 :     return ix86_veclib_handler (combined_fn (fn), type_out, type_in);
    1668              : 
    1669              :   return NULL_TREE;
    1670              : }
    1671              : 
    1672              : /* Returns a decl of a function that implements gather load with
    1673              :    memory type MEM_VECTYPE and index type INDEX_VECTYPE and SCALE.
    1674              :    Return NULL_TREE if it is not available.  */
    1675              : 
    1676              : tree
    1677       356196 : ix86_vectorize_builtin_gather (const_tree mem_vectype,
    1678              :                                const_tree index_type, int scale)
    1679              : {
    1680       356196 :   bool si;
    1681       356196 :   enum ix86_builtins code;
    1682       356196 :   const machine_mode mode = TYPE_MODE (TREE_TYPE (mem_vectype));
    1683              : 
    1684       699078 :   if (!TARGET_AVX512F && GET_MODE_SIZE (mode) == 64)
    1685              :     return NULL_TREE;
    1686              : 
    1687       356196 :   if (! TARGET_AVX2
    1688       356196 :       || (known_eq (TYPE_VECTOR_SUBPARTS (mem_vectype), 2u)
    1689        17609 :           ? !TARGET_USE_GATHER_2PARTS
    1690        13797 :           : (known_eq (TYPE_VECTOR_SUBPARTS (mem_vectype), 4u)
    1691        13797 :              ? !TARGET_USE_GATHER_4PARTS
    1692         8983 :              : !TARGET_USE_GATHER_8PARTS)))
    1693       353749 :     return NULL_TREE;
    1694              : 
    1695         2447 :   if ((TREE_CODE (index_type) != INTEGER_TYPE
    1696          128 :        && !POINTER_TYPE_P (index_type))
    1697         2575 :       || (TYPE_MODE (index_type) != SImode
    1698          784 :           && TYPE_MODE (index_type) != DImode))
    1699            0 :     return NULL_TREE;
    1700              : 
    1701         2467 :   if (TYPE_PRECISION (index_type) > POINTER_SIZE)
    1702              :     return NULL_TREE;
    1703              : 
    1704              :   /* v*gather* insn sign extends index to pointer mode.  */
    1705         2447 :   if (TYPE_PRECISION (index_type) < POINTER_SIZE
    1706         2447 :       && TYPE_UNSIGNED (index_type))
    1707              :     return NULL_TREE;
    1708              : 
    1709         1759 :   if (scale <= 0
    1710         1759 :       || scale > 8
    1711         1705 :       || (scale & (scale - 1)) != 0)
    1712              :     return NULL_TREE;
    1713              : 
    1714         1705 :   si = TYPE_MODE (index_type) == SImode;
    1715         1705 :   switch (TYPE_MODE (mem_vectype))
    1716              :     {
    1717           91 :     case E_V2DFmode:
    1718           91 :       if (TARGET_AVX512VL)
    1719           68 :         code = si ? IX86_BUILTIN_GATHER3SIV2DF : IX86_BUILTIN_GATHER3DIV2DF;
    1720              :       else
    1721           23 :         code = si ? IX86_BUILTIN_GATHERSIV2DF : IX86_BUILTIN_GATHERDIV2DF;
    1722              :       break;
    1723          150 :     case E_V4DFmode:
    1724          150 :       if (TARGET_AVX512VL)
    1725           43 :         code = si ? IX86_BUILTIN_GATHER3ALTSIV4DF : IX86_BUILTIN_GATHER3DIV4DF;
    1726              :       else
    1727          107 :         code = si ? IX86_BUILTIN_GATHERALTSIV4DF : IX86_BUILTIN_GATHERDIV4DF;
    1728              :       break;
    1729          117 :     case E_V2DImode:
    1730          117 :       if (TARGET_AVX512VL)
    1731           87 :         code = si ? IX86_BUILTIN_GATHER3SIV2DI : IX86_BUILTIN_GATHER3DIV2DI;
    1732              :       else
    1733           30 :         code = si ? IX86_BUILTIN_GATHERSIV2DI : IX86_BUILTIN_GATHERDIV2DI;
    1734              :       break;
    1735          110 :     case E_V4DImode:
    1736          110 :       if (TARGET_AVX512VL)
    1737           52 :         code = si ? IX86_BUILTIN_GATHER3ALTSIV4DI : IX86_BUILTIN_GATHER3DIV4DI;
    1738              :       else
    1739           58 :         code = si ? IX86_BUILTIN_GATHERALTSIV4DI : IX86_BUILTIN_GATHERDIV4DI;
    1740              :       break;
    1741          124 :     case E_V4SFmode:
    1742          124 :       if (TARGET_AVX512VL)
    1743           66 :         code = si ? IX86_BUILTIN_GATHER3SIV4SF : IX86_BUILTIN_GATHER3DIV4SF;
    1744              :       else
    1745           58 :         code = si ? IX86_BUILTIN_GATHERSIV4SF : IX86_BUILTIN_GATHERDIV4SF;
    1746              :       break;
    1747          162 :     case E_V8SFmode:
    1748          162 :       if (TARGET_AVX512VL)
    1749           38 :         code = si ? IX86_BUILTIN_GATHER3SIV8SF : IX86_BUILTIN_GATHER3ALTDIV8SF;
    1750              :       else
    1751          124 :         code = si ? IX86_BUILTIN_GATHERSIV8SF : IX86_BUILTIN_GATHERALTDIV8SF;
    1752              :       break;
    1753          136 :     case E_V4SImode:
    1754          136 :       if (TARGET_AVX512VL)
    1755           71 :         code = si ? IX86_BUILTIN_GATHER3SIV4SI : IX86_BUILTIN_GATHER3DIV4SI;
    1756              :       else
    1757           65 :         code = si ? IX86_BUILTIN_GATHERSIV4SI : IX86_BUILTIN_GATHERDIV4SI;
    1758              :       break;
    1759          109 :     case E_V8SImode:
    1760          109 :       if (TARGET_AVX512VL)
    1761           43 :         code = si ? IX86_BUILTIN_GATHER3SIV8SI : IX86_BUILTIN_GATHER3ALTDIV8SI;
    1762              :       else
    1763           66 :         code = si ? IX86_BUILTIN_GATHERSIV8SI : IX86_BUILTIN_GATHERALTDIV8SI;
    1764              :       break;
    1765          132 :     case E_V8DFmode:
    1766          132 :       code = si ? IX86_BUILTIN_GATHER3ALTSIV8DF : IX86_BUILTIN_GATHER3DIV8DF;
    1767              :       break;
    1768          118 :     case E_V8DImode:
    1769          118 :       code = si ? IX86_BUILTIN_GATHER3ALTSIV8DI : IX86_BUILTIN_GATHER3DIV8DI;
    1770              :       break;
    1771          163 :     case E_V16SFmode:
    1772          163 :       code = si ? IX86_BUILTIN_GATHER3SIV16SF : IX86_BUILTIN_GATHER3ALTDIV16SF;
    1773              :       break;
    1774          104 :     case E_V16SImode:
    1775          104 :       code = si ? IX86_BUILTIN_GATHER3SIV16SI : IX86_BUILTIN_GATHER3ALTDIV16SI;
    1776              :       break;
    1777              :     default:
    1778              :       return NULL_TREE;
    1779              :     }
    1780              : 
    1781         1516 :   return ix86_get_builtin (code);
    1782              : }
    1783              : 
    1784              : /* Returns a code for a target-specific builtin that implements
    1785              :    reciprocal of the function, or NULL_TREE if not available.  */
    1786              : 
    1787              : tree
    1788            0 : ix86_builtin_reciprocal (tree fndecl)
    1789              : {
    1790            0 :   enum ix86_builtins fn_code
    1791            0 :     = (enum ix86_builtins) DECL_MD_FUNCTION_CODE (fndecl);
    1792            0 :   switch (fn_code)
    1793              :     {
    1794              :       /* Vectorized version of sqrt to rsqrt conversion.  */
    1795            0 :     case IX86_BUILTIN_SQRTPS_NR:
    1796            0 :       return ix86_get_builtin (IX86_BUILTIN_RSQRTPS_NR);
    1797              : 
    1798            0 :     case IX86_BUILTIN_SQRTPS_NR256:
    1799            0 :       return ix86_get_builtin (IX86_BUILTIN_RSQRTPS_NR256);
    1800              : 
    1801              :     default:
    1802              :       return NULL_TREE;
    1803              :     }
    1804              : }
    1805              : 
    1806              : /* This parses the attribute arguments to target in DECL and determines
    1807              :    the right builtin to use to match the platform specification.
    1808              :    It returns the priority value for this version decl.  If PREDICATE_LIST
    1809              :    is not NULL, it stores the list of cpu features that need to be checked
    1810              :    before dispatching this function.  */
    1811              : 
    1812              : unsigned int
    1813        12260 : get_builtin_code_for_version (tree decl, tree *predicate_list)
    1814              : {
    1815        12260 :   tree attrs;
    1816        12260 :   struct cl_target_option cur_target;
    1817        12260 :   tree target_node;
    1818        12260 :   struct cl_target_option *new_target;
    1819        12260 :   const char *arg_str = NULL;
    1820        12260 :   const char *attrs_str = NULL;
    1821        12260 :   char *tok_str = NULL;
    1822        12260 :   char *token;
    1823              : 
    1824        12260 :   enum feature_priority priority = P_NONE;
    1825              : 
    1826        12260 :   static unsigned int NUM_FEATURES = ARRAY_SIZE (isa_names_table);
    1827              : 
    1828        12260 :   unsigned int i;
    1829              : 
    1830        12260 :   tree predicate_chain = NULL_TREE;
    1831        12260 :   tree predicate_decl, predicate_arg;
    1832              : 
    1833        12260 :   attrs = lookup_attribute ("target", DECL_ATTRIBUTES (decl));
    1834        12260 :   gcc_assert (attrs != NULL);
    1835              : 
    1836        12260 :   attrs = TREE_VALUE (TREE_VALUE (attrs));
    1837              : 
    1838        12260 :   gcc_assert (TREE_CODE (attrs) == STRING_CST);
    1839        12260 :   attrs_str = TREE_STRING_POINTER (attrs);
    1840              : 
    1841              :   /* Return priority zero for default function.  */
    1842        12260 :   if (strcmp (attrs_str, "default") == 0)
    1843              :     return 0;
    1844              : 
    1845              :   /* Handle arch= if specified.  For priority, set it to be 1 more than
    1846              :      the best instruction set the processor can handle.  For instance, if
    1847              :      there is a version for atom and a version for ssse3 (the highest ISA
    1848              :      priority for atom), the atom version must be checked for dispatch
    1849              :      before the ssse3 version. */
    1850        11142 :   if (strstr (attrs_str, "arch=") != NULL)
    1851              :     {
    1852         4837 :       cl_target_option_save (&cur_target, &global_options,
    1853              :                              &global_options_set);
    1854         4837 :       target_node
    1855         4837 :         = ix86_valid_target_attribute_tree (decl, attrs, &global_options,
    1856              :                                             &global_options_set, 0);
    1857              : 
    1858         4837 :       gcc_assert (target_node);
    1859         4837 :       if (target_node == error_mark_node)
    1860              :         return 0;
    1861         4837 :       new_target = TREE_TARGET_OPTION (target_node);
    1862         4837 :       gcc_assert (new_target);
    1863         4837 :       enum ix86_builtins builtin_fn = IX86_BUILTIN_CPU_IS;
    1864              : 
    1865              :       /* Special case x86-64 micro-level architectures.  */
    1866         4837 :       const char *arch_name = attrs_str + strlen ("arch=");
    1867         4837 :       if (startswith (arch_name, "x86-64"))
    1868              :         {
    1869          120 :           arg_str = arch_name;
    1870          120 :           builtin_fn = IX86_BUILTIN_CPU_SUPPORTS;
    1871          120 :           if (strcmp (arch_name, "x86-64") == 0)
    1872              :             priority = P_X86_64_BASELINE;
    1873           91 :           else if (strcmp (arch_name, "x86-64-v2") == 0)
    1874              :             priority = P_X86_64_V2;
    1875           58 :           else if (strcmp (arch_name, "x86-64-v3") == 0)
    1876              :             priority = P_X86_64_V3;
    1877           32 :           else if (strcmp (arch_name, "x86-64-v4") == 0)
    1878           32 :             priority = P_X86_64_V4;
    1879              :         }
    1880         4717 :       else if (new_target->arch_specified && new_target->arch > 0)
    1881       272883 :         for (i = 0; i < pta_size; i++)
    1882       272883 :           if (processor_alias_table[i].processor == new_target->arch)
    1883              :             {
    1884         4717 :               const pta *arch_info = &processor_alias_table[i];
    1885         4717 :               switch (arch_info->priority)
    1886              :                 {
    1887         3232 :                 default:
    1888         3232 :                   arg_str = arch_info->name;
    1889         3232 :                   priority = arch_info->priority;
    1890         3232 :                   break;
    1891         1485 :                 case P_PROC_DYNAMIC:
    1892         1485 :                   switch (new_target->arch)
    1893              :                     {
    1894          777 :                     case PROCESSOR_NEHALEM:
    1895          777 :                       if (TARGET_PCLMUL_P (new_target->x_ix86_isa_flags))
    1896              :                         {
    1897              :                           arg_str = "westmere";
    1898              :                           priority = P_PCLMUL;
    1899              :                         }
    1900              :                       else
    1901              :                         {
    1902              :                           /* We translate "arch=corei7" and "arch=nehalem"
    1903              :                              to "corei7" so that it will be mapped to
    1904              :                              M_INTEL_COREI7 as cpu type to cover all
    1905              :                              M_INTEL_COREI7_XXXs.  */
    1906          684 :                           arg_str = "corei7";
    1907          684 :                           priority = P_PROC_SSE4_2;
    1908              :                         }
    1909              :                       break;
    1910          196 :                     case PROCESSOR_SANDYBRIDGE:
    1911          196 :                       if (TARGET_F16C_P (new_target->x_ix86_isa_flags))
    1912              :                         arg_str = "ivybridge";
    1913              :                       else
    1914          100 :                         arg_str = "sandybridge";
    1915              :                       priority = P_PROC_AVX;
    1916              :                       break;
    1917          233 :                     case PROCESSOR_HASWELL:
    1918          233 :                       if (TARGET_ADX_P (new_target->x_ix86_isa_flags))
    1919              :                         arg_str = "broadwell";
    1920              :                       else
    1921          164 :                         arg_str = "haswell";
    1922              :                       priority = P_PROC_AVX2;
    1923              :                       break;
    1924              :                     case PROCESSOR_AMDFAM10:
    1925              :                       arg_str = "amdfam10h";
    1926              :                       priority = P_PROC_SSE4_A;
    1927              :                       break;
    1928            0 :                     default:
    1929            0 :                       gcc_unreachable ();
    1930              :                     }
    1931              :                   break;
    1932              :                 case P_NONE:
    1933              :                   break;
    1934              :                 }
    1935              :               break;
    1936              :             }
    1937              : 
    1938         4837 :       cl_target_option_restore (&global_options, &global_options_set,
    1939              :                                 &cur_target);
    1940              : 
    1941         4837 :       if (predicate_list && arg_str == NULL)
    1942              :         {
    1943            0 :           error_at (DECL_SOURCE_LOCATION (decl),
    1944              :                     "no dispatcher found for the versioning attributes");
    1945            0 :           return 0;
    1946              :         }
    1947              : 
    1948         4837 :       if (predicate_list)
    1949              :         {
    1950          353 :           predicate_decl = ix86_builtins [(int) builtin_fn];
    1951              :           /* For a C string literal the length includes the trailing NULL.  */
    1952          353 :           predicate_arg = build_string_literal (strlen (arg_str) + 1, arg_str);
    1953          353 :           predicate_chain = tree_cons (predicate_decl, predicate_arg,
    1954              :                                        predicate_chain);
    1955              :         }
    1956              :     }
    1957              : 
    1958              :   /* Process feature name.  */
    1959        11142 :   tok_str =  (char *) xmalloc (strlen (attrs_str) + 1);
    1960        11142 :   strcpy (tok_str, attrs_str);
    1961        11142 :   token = strtok (tok_str, ",");
    1962        11142 :   predicate_decl = ix86_builtins [(int) IX86_BUILTIN_CPU_SUPPORTS];
    1963              : 
    1964        22964 :   while (token != NULL)
    1965              :     {
    1966              :       /* Do not process "arch="  */
    1967        11979 :       if (startswith (token, "arch="))
    1968              :         {
    1969         4837 :           token = strtok (NULL, ",");
    1970         4837 :           continue;
    1971              :         }
    1972       208238 :       for (i = 0; i < NUM_FEATURES; ++i)
    1973              :         {
    1974       207106 :           if (strcmp (token, isa_names_table[i].name) == 0)
    1975              :             {
    1976         6010 :               if (predicate_list)
    1977              :                 {
    1978          814 :                   predicate_arg = build_string_literal (
    1979          407 :                                   strlen (isa_names_table[i].name) + 1,
    1980              :                                   isa_names_table[i].name);
    1981          407 :                   predicate_chain = tree_cons (predicate_decl, predicate_arg,
    1982              :                                                predicate_chain);
    1983              :                 }
    1984              :               /* Find the maximum priority feature.  */
    1985         6010 :               if (isa_names_table[i].priority > priority)
    1986         5274 :                 priority = isa_names_table[i].priority;
    1987              : 
    1988              :               break;
    1989              :             }
    1990              :         }
    1991         7142 :       if (predicate_list && priority == P_NONE)
    1992              :         {
    1993          157 :           error_at (DECL_SOURCE_LOCATION (decl),
    1994              :                     "ISA %qs is not supported in %<target%> attribute, "
    1995              :                     "use %<arch=%> syntax", token);
    1996          157 :           return 0;
    1997              :         }
    1998         6985 :       token = strtok (NULL, ",");
    1999              :     }
    2000        10985 :   free (tok_str);
    2001              : 
    2002        10985 :   if (predicate_list && predicate_chain == NULL_TREE)
    2003              :     {
    2004            0 :       error_at (DECL_SOURCE_LOCATION (decl),
    2005              :                 "no dispatcher found for the versioning attributes: %s",
    2006              :                 attrs_str);
    2007            0 :       return 0;
    2008              :     }
    2009        10985 :   else if (predicate_list)
    2010              :     {
    2011          625 :       predicate_chain = nreverse (predicate_chain);
    2012          625 :       *predicate_list = predicate_chain;
    2013              :     }
    2014              : 
    2015              :   return priority;
    2016              : }
    2017              : 
    2018              : /* This builds the processor_model struct type defined in
    2019              :    libgcc/config/i386/cpuinfo.c  */
    2020              : 
    2021              : static tree
    2022         1961 : build_processor_model_struct (void)
    2023              : {
    2024         1961 :   const char *field_name[] = {"__cpu_vendor", "__cpu_type", "__cpu_subtype",
    2025              :                               "__cpu_features"};
    2026         1961 :   tree field = NULL_TREE, field_chain = NULL_TREE;
    2027         1961 :   int i;
    2028         1961 :   tree type = make_node (RECORD_TYPE);
    2029              : 
    2030              :   /* The first 3 fields are unsigned int.  */
    2031         9805 :   for (i = 0; i < 3; ++i)
    2032              :     {
    2033         5883 :       field = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
    2034              :                           get_identifier (field_name[i]), unsigned_type_node);
    2035         5883 :       if (field_chain != NULL_TREE)
    2036         3922 :         DECL_CHAIN (field) = field_chain;
    2037         5883 :       field_chain = field;
    2038              :     }
    2039              : 
    2040              :   /* The last field is an array of unsigned integers of size one.  */
    2041         1961 :   field = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
    2042              :                       get_identifier (field_name[3]),
    2043              :                       build_array_type (unsigned_type_node,
    2044              :                                         build_index_type (size_one_node)));
    2045         1961 :   if (field_chain != NULL_TREE)
    2046         1961 :     DECL_CHAIN (field) = field_chain;
    2047         1961 :   field_chain = field;
    2048              : 
    2049         1961 :   finish_builtin_struct (type, "__processor_model", field_chain, NULL_TREE);
    2050         1961 :   return type;
    2051              : }
    2052              : 
    2053              : /* Returns a extern, comdat VAR_DECL of type TYPE and name NAME. */
    2054              : 
    2055              : static tree
    2056         2360 : make_var_decl (tree type, const char *name)
    2057              : {
    2058         2360 :   tree new_decl;
    2059              : 
    2060         2360 :   new_decl = build_decl (UNKNOWN_LOCATION,
    2061              :                          VAR_DECL,
    2062              :                          get_identifier(name),
    2063              :                          type);
    2064              : 
    2065         2360 :   DECL_EXTERNAL (new_decl) = 1;
    2066         2360 :   TREE_STATIC (new_decl) = 1;
    2067         2360 :   TREE_PUBLIC (new_decl) = 1;
    2068         2360 :   DECL_INITIAL (new_decl) = 0;
    2069         2360 :   DECL_ARTIFICIAL (new_decl) = 0;
    2070         2360 :   DECL_PRESERVE_P (new_decl) = 1;
    2071              : 
    2072         2360 :   make_decl_one_only (new_decl, DECL_ASSEMBLER_NAME (new_decl));
    2073         2360 :   assemble_variable (new_decl, 0, 0, 0);
    2074              : 
    2075         2360 :   return new_decl;
    2076              : }
    2077              : 
    2078              : static GTY(()) tree ix86_cpu_model_type_node;
    2079              : static GTY(()) tree ix86_cpu_model_var;
    2080              : static GTY(()) tree ix86_cpu_features2_type_node;
    2081              : static GTY(()) tree ix86_cpu_features2_var;
    2082              : 
    2083              : /* FNDECL is a __builtin_cpu_is or a __builtin_cpu_supports call that is folded
    2084              :    into an integer defined in libgcc/config/i386/cpuinfo.c */
    2085              : 
    2086              : tree
    2087         9348 : fold_builtin_cpu (tree fndecl, tree *args)
    2088              : {
    2089         9348 :   unsigned int i;
    2090         9348 :   enum ix86_builtins fn_code
    2091         9348 :     = (enum ix86_builtins) DECL_MD_FUNCTION_CODE (fndecl);
    2092         9348 :   tree param_string_cst = NULL;
    2093              : 
    2094         9348 :   if (ix86_cpu_model_var == nullptr)
    2095              :     {
    2096              :       /* Build a single __cpu_model variable for all references to
    2097              :          __cpu_model so that GIMPLE level optimizers can CSE the loads
    2098              :          of __cpu_model and optimize bit-operations properly.  */
    2099         1961 :       ix86_cpu_model_type_node = build_processor_model_struct ();
    2100         1961 :       ix86_cpu_model_var = make_var_decl (ix86_cpu_model_type_node,
    2101              :                                           "__cpu_model");
    2102         1961 :       varpool_node::add (ix86_cpu_model_var);
    2103              :     }
    2104              : 
    2105         9348 :   gcc_assert ((args != NULL) && (*args != NULL));
    2106              : 
    2107              :   param_string_cst = *args;
    2108              :   while (param_string_cst
    2109        28044 :          && TREE_CODE (param_string_cst) !=  STRING_CST)
    2110              :     {
    2111              :       /* *args must be a expr that can contain other EXPRS leading to a
    2112              :          STRING_CST.   */
    2113        18696 :       if (!EXPR_P (param_string_cst))
    2114              :         {
    2115            0 :           error ("parameter to builtin must be a string constant or literal");
    2116            0 :           return integer_zero_node;
    2117              :         }
    2118        18696 :       param_string_cst = TREE_OPERAND (EXPR_CHECK (param_string_cst), 0);
    2119              :     }
    2120              : 
    2121         9348 :   gcc_assert (param_string_cst);
    2122              : 
    2123         9348 :   if (fn_code == IX86_BUILTIN_CPU_IS)
    2124              :     {
    2125              :       tree ref;
    2126              :       tree field;
    2127              :       tree final;
    2128              : 
    2129       224238 :       unsigned int field_val = 0;
    2130              : 
    2131       224238 :       for (i = 0; i < num_arch_names; i++)
    2132       224238 :         if (processor_alias_table[i].model != 0
    2133       224238 :             && strcmp (processor_alias_table[i].name,
    2134        98022 :                        TREE_STRING_POINTER (param_string_cst)) == 0)
    2135              :           break;
    2136              : 
    2137         3508 :       if (i == num_arch_names)
    2138              :         {
    2139            0 :           error ("parameter to builtin not valid: %s",
    2140            0 :                  TREE_STRING_POINTER (param_string_cst));
    2141            0 :           return integer_zero_node;
    2142              :         }
    2143              : 
    2144         3508 :       field = TYPE_FIELDS (ix86_cpu_model_type_node);
    2145         3508 :       field_val = processor_alias_table[i].model;
    2146              : 
    2147              :       /* CPU types are stored in the next field.  */
    2148         3508 :       if (field_val > M_CPU_TYPE_START
    2149         3508 :           && field_val < M_CPU_SUBTYPE_START)
    2150              :         {
    2151         1491 :           field = DECL_CHAIN (field);
    2152         1491 :           field_val -= M_CPU_TYPE_START;
    2153              :         }
    2154              : 
    2155              :       /* CPU subtypes are stored in the next field.  */
    2156         3508 :       if (field_val > M_CPU_SUBTYPE_START)
    2157              :         {
    2158         1913 :           field = DECL_CHAIN ( DECL_CHAIN (field));
    2159         1913 :           field_val -= M_CPU_SUBTYPE_START;
    2160              :         }
    2161              : 
    2162              :       /* Get the appropriate field in __cpu_model.  */
    2163         3508 :       ref = build3 (COMPONENT_REF, TREE_TYPE (field), ix86_cpu_model_var,
    2164              :                     field, NULL_TREE);
    2165              : 
    2166              :       /* Check the value.  */
    2167         3508 :       final = build2 (EQ_EXPR, unsigned_type_node, ref,
    2168         3508 :                       build_int_cstu (unsigned_type_node, field_val));
    2169         3508 :       return build1 (NOP_EXPR, integer_type_node, final);
    2170              :     }
    2171         5840 :   else if (fn_code == IX86_BUILTIN_CPU_SUPPORTS)
    2172              :     {
    2173              :       tree ref;
    2174              :       tree array_elt;
    2175              :       tree field;
    2176              :       tree final;
    2177              : 
    2178       142522 :       unsigned int field_val = 0;
    2179              :       unsigned int NUM_ISA_NAMES = ARRAY_SIZE (isa_names_table);
    2180              : 
    2181       142522 :       for (i = 0; i < NUM_ISA_NAMES; i++)
    2182       142522 :         if (strcmp (isa_names_table[i].name,
    2183       142522 :             TREE_STRING_POINTER (param_string_cst)) == 0)
    2184              :           break;
    2185              : 
    2186         5840 :       if (i == NUM_ISA_NAMES)
    2187              :         {
    2188            0 :           error ("parameter to builtin not valid: %s",
    2189            0 :                  TREE_STRING_POINTER (param_string_cst));
    2190            0 :           return integer_zero_node;
    2191              :         }
    2192              : 
    2193         5840 :       unsigned feature = isa_names_table[i].feature;
    2194         5840 :       if (feature >= INT_TYPE_SIZE)
    2195              :         {
    2196          786 :           if (ix86_cpu_features2_var == nullptr)
    2197              :             {
    2198              :               /* Build a single __cpu_features2 variable for all
    2199              :                  references to __cpu_features2 so that GIMPLE level
    2200              :                  optimizers can CSE the loads of __cpu_features2 and
    2201              :                  optimize bit-operations properly.  */
    2202          399 :               tree index_type
    2203          399 :                 = build_index_type (size_int (SIZE_OF_CPU_FEATURES));
    2204          399 :               ix86_cpu_features2_type_node
    2205          399 :                 = build_array_type (unsigned_type_node, index_type);
    2206          399 :               ix86_cpu_features2_var
    2207          399 :                 = make_var_decl (ix86_cpu_features2_type_node,
    2208              :                                  "__cpu_features2");
    2209          399 :               varpool_node::add (ix86_cpu_features2_var);
    2210              :             }
    2211              : 
    2212              :           /* Skip __cpu_features[0].  */
    2213          786 :           feature -= INT_TYPE_SIZE;
    2214          786 :           tree index = size_int (feature / INT_TYPE_SIZE);
    2215          786 :           feature = feature % INT_TYPE_SIZE;
    2216          786 :           array_elt = build4 (ARRAY_REF, unsigned_type_node,
    2217              :                               ix86_cpu_features2_var,
    2218              :                               index, NULL_TREE, NULL_TREE);
    2219              :           /* Return __cpu_features2[index] & field_val  */
    2220              :         }
    2221              :       else
    2222              :         {
    2223         5054 :           field = TYPE_FIELDS (ix86_cpu_model_type_node);
    2224              :           /* Get the last field, which is __cpu_features.  */
    2225        20216 :           while (DECL_CHAIN (field))
    2226        15162 :             field = DECL_CHAIN (field);
    2227              : 
    2228              :           /* Get the appropriate field: __cpu_model.__cpu_features  */
    2229         5054 :           ref = build3 (COMPONENT_REF, TREE_TYPE (field), ix86_cpu_model_var,
    2230              :                         field, NULL_TREE);
    2231              : 
    2232              :           /* Access the 0th element of __cpu_features array.  */
    2233         5054 :           array_elt = build4 (ARRAY_REF, unsigned_type_node, ref,
    2234              :                               integer_zero_node, NULL_TREE, NULL_TREE);
    2235              : 
    2236              :           /* Return __cpu_model.__cpu_features[0] & field_val  */
    2237              :         }
    2238              : 
    2239         5840 :       field_val = 1U << feature;
    2240         5840 :       final = build2 (BIT_AND_EXPR, unsigned_type_node, array_elt,
    2241         5840 :                       build_int_cstu (unsigned_type_node, field_val));
    2242         5840 :       if (feature == INT_TYPE_SIZE - 1)
    2243           84 :         return build2 (NE_EXPR, integer_type_node, final,
    2244              :                        build_int_cst (unsigned_type_node, 0));
    2245              :       else
    2246         5756 :         return build1 (NOP_EXPR, integer_type_node, final);
    2247              :     }
    2248            0 :   gcc_unreachable ();
    2249              : }
    2250              : 
    2251              : #include "gt-i386-builtins.h"
        

Generated by: LCOV version 2.4-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.