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