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