Line data Source code
1 : /* gfortran backend interface
2 : Copyright (C) 2000-2026 Free Software Foundation, Inc.
3 : Contributed by Paul Brook.
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 : /* f95-lang.cc-- GCC backend interface stuff */
22 :
23 : /* declare required prototypes: */
24 :
25 : #include "config.h"
26 : #include "system.h"
27 : #include "coretypes.h"
28 : #include "target.h"
29 : #include "function.h"
30 : #include "tree.h"
31 : #include "gfortran.h"
32 : #include "trans.h"
33 : #include "stringpool.h"
34 : #include "diagnostic.h" /* For errorcount/warningcount */
35 : #include "langhooks.h"
36 : #include "langhooks-def.h"
37 : #include "toplev.h"
38 : #include "debug.h"
39 : #include "cpp.h"
40 : #include "trans-types.h"
41 : #include "trans-const.h"
42 : #include "attribs.h"
43 :
44 : /* Language-dependent contents of an identifier. */
45 :
46 : struct GTY(())
47 : lang_identifier {
48 : struct tree_identifier common;
49 : };
50 :
51 : /* The resulting tree type. */
52 :
53 : union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
54 : chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
55 : lang_tree_node {
56 : union tree_node GTY((tag ("0"),
57 : desc ("tree_node_structure (&%h)"))) generic;
58 : struct lang_identifier GTY((tag ("1"))) identifier;
59 : };
60 :
61 : /* Save and restore the variables in this file and elsewhere
62 : that keep track of the progress of compilation of the current function.
63 : Used for nested functions. */
64 :
65 : struct GTY(())
66 : language_function {
67 : /* struct gfc_language_function base; */
68 : struct binding_level *binding_level;
69 : };
70 :
71 : static void gfc_init_decl_processing (void);
72 : static void gfc_init_builtin_functions (void);
73 : static bool global_bindings_p (void);
74 :
75 : /* Each front end provides its own. */
76 : static bool gfc_init (void);
77 : static void gfc_finish (void);
78 : static void gfc_be_parse_file (void);
79 : static void gfc_init_ts (void);
80 : static tree gfc_builtin_function (tree);
81 :
82 : /* Handle an "omp declare target" attribute; arguments as in
83 : struct attribute_spec.handler. */
84 : static tree
85 1362 : gfc_handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *)
86 : {
87 1362 : return NULL_TREE;
88 : }
89 :
90 : /* Table of valid Fortran attributes. */
91 : static const attribute_spec gfc_gnu_attributes[] =
92 : {
93 : /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
94 : affects_type_identity, handler, exclude } */
95 : { "omp declare target", 0, -1, true, false, false, false,
96 : gfc_handle_omp_declare_target_attribute, NULL },
97 : { "omp declare target link", 0, 0, true, false, false, false,
98 : gfc_handle_omp_declare_target_attribute, NULL },
99 : { "omp declare target indirect", 0, 0, true, false, false, false,
100 : gfc_handle_omp_declare_target_attribute, NULL },
101 : { "oacc function", 0, -1, true, false, false, false,
102 : gfc_handle_omp_declare_target_attribute, NULL },
103 : };
104 :
105 : static const scoped_attribute_specs gfc_gnu_attribute_table =
106 : {
107 : "gnu", { gfc_gnu_attributes }
108 : };
109 :
110 : static const scoped_attribute_specs *const gfc_attribute_table[] =
111 : {
112 : &gfc_gnu_attribute_table
113 : };
114 :
115 : /* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property,
116 : based on the list in SARIF v2.1.0 Appendix J. */
117 :
118 : static const char *
119 2 : gfc_get_sarif_source_language (const char *)
120 : {
121 2 : return "fortran";
122 : }
123 :
124 : #undef LANG_HOOKS_NAME
125 : #undef LANG_HOOKS_INIT
126 : #undef LANG_HOOKS_FINISH
127 : #undef LANG_HOOKS_OPTION_LANG_MASK
128 : #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
129 : #undef LANG_HOOKS_INIT_OPTIONS
130 : #undef LANG_HOOKS_HANDLE_OPTION
131 : #undef LANG_HOOKS_POST_OPTIONS
132 : #undef LANG_HOOKS_PARSE_FILE
133 : #undef LANG_HOOKS_MARK_ADDRESSABLE
134 : #undef LANG_HOOKS_TYPE_FOR_MODE
135 : #undef LANG_HOOKS_TYPE_FOR_SIZE
136 : #undef LANG_HOOKS_INIT_TS
137 : #undef LANG_HOOKS_OMP_ARRAY_DATA
138 : #undef LANG_HOOKS_OMP_ARRAY_DATA_PRIVATIZE
139 : #undef LANG_HOOKS_OMP_ARRAY_SIZE
140 : #undef LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR
141 : #undef LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT
142 : #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
143 : #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
144 : #undef LANG_HOOKS_OMP_PREDETERMINED_MAPPING
145 : #undef LANG_HOOKS_OMP_REPORT_DECL
146 : #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR
147 : #undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR
148 : #undef LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP
149 : #undef LANG_HOOKS_OMP_CLAUSE_LINEAR_CTOR
150 : #undef LANG_HOOKS_OMP_CLAUSE_DTOR
151 : #undef LANG_HOOKS_OMP_FINISH_CLAUSE
152 : #undef LANG_HOOKS_OMP_DEEP_MAPPING
153 : #undef LANG_HOOKS_OMP_DEEP_MAPPING_P
154 : #undef LANG_HOOKS_OMP_DEEP_MAPPING_CNT
155 : #undef LANG_HOOKS_OMP_ALLOCATABLE_P
156 : #undef LANG_HOOKS_OMP_SCALAR_TARGET_P
157 : #undef LANG_HOOKS_OMP_SCALAR_P
158 : #undef LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR
159 : #undef LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE
160 : #undef LANG_HOOKS_OMP_PRIVATE_OUTER_REF
161 : #undef LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES
162 : #undef LANG_HOOKS_BUILTIN_FUNCTION
163 : #undef LANG_HOOKS_BUILTIN_FUNCTION
164 : #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO
165 : #undef LANG_HOOKS_ATTRIBUTE_TABLE
166 : #undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE
167 :
168 : /* Define lang hooks. */
169 : #define LANG_HOOKS_NAME "GNU Fortran"
170 : #define LANG_HOOKS_INIT gfc_init
171 : #define LANG_HOOKS_FINISH gfc_finish
172 : #define LANG_HOOKS_OPTION_LANG_MASK gfc_option_lang_mask
173 : #define LANG_HOOKS_INIT_OPTIONS_STRUCT gfc_init_options_struct
174 : #define LANG_HOOKS_INIT_OPTIONS gfc_init_options
175 : #define LANG_HOOKS_HANDLE_OPTION gfc_handle_option
176 : #define LANG_HOOKS_POST_OPTIONS gfc_post_options
177 : #define LANG_HOOKS_PARSE_FILE gfc_be_parse_file
178 : #define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode
179 : #define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size
180 : #define LANG_HOOKS_INIT_TS gfc_init_ts
181 : #define LANG_HOOKS_OMP_ARRAY_DATA gfc_omp_array_data
182 : #define LANG_HOOKS_OMP_ARRAY_DATA_PRIVATIZE gfc_omp_array_data_privatize
183 : #define LANG_HOOKS_OMP_ARRAY_SIZE gfc_omp_array_size
184 : #define LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR gfc_omp_is_allocatable_or_ptr
185 : #define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT gfc_omp_check_optional_argument
186 : #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference
187 : #define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing
188 : #define LANG_HOOKS_OMP_PREDETERMINED_MAPPING gfc_omp_predetermined_mapping
189 : #define LANG_HOOKS_OMP_REPORT_DECL gfc_omp_report_decl
190 : #define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR gfc_omp_clause_default_ctor
191 : #define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR gfc_omp_clause_copy_ctor
192 : #define LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP gfc_omp_clause_assign_op
193 : #define LANG_HOOKS_OMP_CLAUSE_LINEAR_CTOR gfc_omp_clause_linear_ctor
194 : #define LANG_HOOKS_OMP_CLAUSE_DTOR gfc_omp_clause_dtor
195 : #define LANG_HOOKS_OMP_FINISH_CLAUSE gfc_omp_finish_clause
196 : #define LANG_HOOKS_OMP_DEEP_MAPPING gfc_omp_deep_mapping
197 : #define LANG_HOOKS_OMP_DEEP_MAPPING_P gfc_omp_deep_mapping_p
198 : #define LANG_HOOKS_OMP_DEEP_MAPPING_CNT gfc_omp_deep_mapping_cnt
199 : #define LANG_HOOKS_OMP_ALLOCATABLE_P gfc_omp_allocatable_p
200 : #define LANG_HOOKS_OMP_SCALAR_P gfc_omp_scalar_p
201 : #define LANG_HOOKS_OMP_SCALAR_TARGET_P gfc_omp_scalar_target_p
202 : #define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR gfc_omp_disregard_value_expr
203 : #define LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE gfc_omp_private_debug_clause
204 : #define LANG_HOOKS_OMP_PRIVATE_OUTER_REF gfc_omp_private_outer_ref
205 : #define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
206 : gfc_omp_firstprivatize_type_sizes
207 : #define LANG_HOOKS_BUILTIN_FUNCTION gfc_builtin_function
208 : #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gfc_get_array_descr_info
209 : #define LANG_HOOKS_ATTRIBUTE_TABLE gfc_attribute_table
210 : #define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE gfc_get_sarif_source_language
211 :
212 : struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
213 :
214 : #define NULL_BINDING_LEVEL (struct binding_level *) NULL
215 :
216 : /* A chain of binding_level structures awaiting reuse. */
217 :
218 : static GTY(()) struct binding_level *free_binding_level;
219 :
220 : /* True means we've initialized exception handling. */
221 : static bool gfc_eh_initialized_p;
222 :
223 : /* The current translation unit. */
224 : static GTY(()) tree current_translation_unit;
225 :
226 :
227 : static void
228 31766 : gfc_create_decls (void)
229 : {
230 : /* GCC builtins. */
231 31766 : gfc_init_builtin_functions ();
232 :
233 : /* Runtime/IO library functions. */
234 31766 : gfc_build_builtin_function_decls ();
235 :
236 31766 : gfc_init_constants ();
237 :
238 : /* Build our translation-unit decl. */
239 31766 : current_translation_unit
240 31766 : = build_translation_unit_decl (get_identifier (main_input_filename));
241 31766 : debug_hooks->register_main_translation_unit (current_translation_unit);
242 31766 : }
243 :
244 :
245 : static void
246 31766 : gfc_be_parse_file (void)
247 : {
248 31766 : gfc_create_decls ();
249 31766 : gfc_parse_file ();
250 31755 : gfc_generate_constructors ();
251 :
252 : /* Clear the binding level stack. */
253 31755 : while (!global_bindings_p ())
254 7 : poplevel (0, 0);
255 :
256 : /* Finalize all of the globals.
257 :
258 : Emulated tls lowering needs to see all TLS variables before we
259 : call finalize_compilation_unit. The C/C++ front ends manage this
260 : by calling decl_rest_of_compilation on each global and static
261 : variable as they are seen. The Fortran front end waits until
262 : here. */
263 142765866 : for (tree decl = getdecls (); decl ; decl = DECL_CHAIN (decl))
264 142734111 : rest_of_decl_compilation (decl, true, true);
265 :
266 : /* Switch to the default tree diagnostics here, because there may be
267 : diagnostics before gfc_finish(). */
268 31755 : gfc_diagnostics_finish ();
269 :
270 31755 : global_decl_processing ();
271 31755 : }
272 :
273 :
274 : /* Initialize everything. */
275 :
276 : static bool
277 31783 : gfc_init (void)
278 : {
279 31783 : if (!gfc_cpp_enabled () || gfc_option.flag_preprocessed)
280 : {
281 30606 : linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1);
282 30606 : linemap_add (line_table, LC_RENAME, false, special_fname_builtin (), 0);
283 : }
284 : else
285 1177 : gfc_cpp_init_0 ();
286 :
287 31783 : gfc_init_decl_processing ();
288 31783 : gfc_static_ctors = NULL_TREE;
289 :
290 31783 : if (gfc_cpp_enabled () && !gfc_option.flag_preprocessed)
291 1177 : gfc_cpp_init ();
292 :
293 31783 : gfc_init_1 ();
294 :
295 : /* Calls exit in case of a fail. */
296 31783 : gfc_new_file ();
297 :
298 31779 : if (flag_preprocess_only)
299 13 : return false;
300 :
301 : return true;
302 : }
303 :
304 :
305 : static void
306 31764 : gfc_finish (void)
307 : {
308 31764 : gfc_cpp_done ();
309 31764 : gfc_done_1 ();
310 31764 : gfc_release_include_path ();
311 31764 : return;
312 : }
313 :
314 : /* These functions and variables deal with binding contours. We only
315 : need these functions for the list of PARM_DECLs, but we leave the
316 : functions more general; these are a simplified version of the
317 : functions from GNAT. */
318 :
319 : /* For each binding contour we allocate a binding_level structure which
320 : records the entities defined or declared in that contour. Contours
321 : include:
322 :
323 : the global one
324 : one for each subprogram definition
325 : one for each compound statement (declare block)
326 :
327 : Binding contours are used to create GCC tree BLOCK nodes. */
328 :
329 : struct GTY(())
330 : binding_level {
331 : /* A chain of ..._DECL nodes for all variables, constants, functions,
332 : parameters and type declarations. These ..._DECL nodes are chained
333 : through the DECL_CHAIN field. */
334 : tree names;
335 : /* For each level (except the global one), a chain of BLOCK nodes for all
336 : the levels that were entered and exited one level down from this one. */
337 : tree blocks;
338 : /* The binding level containing this one (the enclosing binding level). */
339 : struct binding_level *level_chain;
340 : /* True if nreverse has been already called on names; if false, names
341 : are ordered from newest declaration to oldest one. */
342 : bool reversed;
343 : };
344 :
345 : /* The binding level currently in effect. */
346 : static GTY(()) struct binding_level *current_binding_level = NULL;
347 :
348 : /* The outermost binding level. This binding level is created when the
349 : compiler is started and it will exist through the entire compilation. */
350 : static GTY(()) struct binding_level *global_binding_level;
351 :
352 : /* Binding level structures are initialized by copying this one. */
353 : static struct binding_level clear_binding_level = { NULL, NULL, NULL, false };
354 :
355 :
356 : /* Return true if we are in the global binding level. */
357 :
358 : bool
359 145068275 : global_bindings_p (void)
360 : {
361 31762 : return current_binding_level == global_binding_level;
362 : }
363 :
364 : tree
365 4894301 : getdecls (void)
366 : {
367 4894301 : if (!current_binding_level->reversed)
368 : {
369 2465578 : current_binding_level->reversed = true;
370 2465578 : current_binding_level->names = nreverse (current_binding_level->names);
371 : }
372 4894301 : return current_binding_level->names;
373 : }
374 :
375 : /* Enter a new binding level. */
376 :
377 : void
378 2465606 : pushlevel (void)
379 : {
380 2465606 : struct binding_level *newlevel = ggc_alloc<binding_level> ();
381 :
382 2465606 : *newlevel = clear_binding_level;
383 :
384 : /* Add this level to the front of the chain (stack) of levels that are
385 : active. */
386 2465606 : newlevel->level_chain = current_binding_level;
387 2465606 : current_binding_level = newlevel;
388 2465606 : }
389 :
390 : /* Exit a binding level.
391 : Pop the level off, and restore the state of the identifier-decl mappings
392 : that were in effect when this level was entered.
393 :
394 : If KEEP is nonzero, this level had explicit declarations, so
395 : and create a "block" (a BLOCK node) for the level
396 : to record its declarations and subblocks for symbol table output.
397 :
398 : If FUNCTIONBODY is nonzero, this level is the body of a function,
399 : so create a block as if KEEP were set and also clear out all
400 : label names. */
401 :
402 : tree
403 2433823 : poplevel (int keep, int functionbody)
404 : {
405 : /* Points to a BLOCK tree node. This is the BLOCK node constructed for the
406 : binding level that we are about to exit and which is returned by this
407 : routine. */
408 2433823 : tree block_node = NULL_TREE;
409 2433823 : tree decl_chain = getdecls ();
410 2433823 : tree subblock_chain = current_binding_level->blocks;
411 2433823 : tree subblock_node;
412 :
413 : /* If there were any declarations in the current binding level, or if this
414 : binding level is a function body, or if there are any nested blocks then
415 : create a BLOCK node to record them for the life of this function. */
416 2433823 : if (keep || functionbody)
417 725366 : block_node = build_block (keep ? decl_chain : 0, subblock_chain, 0, 0);
418 :
419 : /* Record the BLOCK node just built as the subblock its enclosing scope. */
420 3472727 : for (subblock_node = subblock_chain; subblock_node;
421 1038904 : subblock_node = BLOCK_CHAIN (subblock_node))
422 1038904 : BLOCK_SUPERCONTEXT (subblock_node) = block_node;
423 :
424 : /* Clear out the meanings of the local variables of this level. */
425 :
426 4459640 : for (subblock_node = decl_chain; subblock_node;
427 2025817 : subblock_node = DECL_CHAIN (subblock_node))
428 2025817 : if (DECL_NAME (subblock_node) != 0)
429 : /* If the identifier was used or addressed via a local extern decl,
430 : don't forget that fact. */
431 924632 : if (DECL_EXTERNAL (subblock_node))
432 : {
433 290 : if (TREE_USED (subblock_node))
434 69 : TREE_USED (DECL_NAME (subblock_node)) = 1;
435 290 : if (TREE_ADDRESSABLE (subblock_node))
436 57 : TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (subblock_node)) = 1;
437 : }
438 :
439 : /* Pop the current level. */
440 2433823 : current_binding_level = current_binding_level->level_chain;
441 :
442 2433823 : if (functionbody)
443 : /* This is the top level block of a function. */
444 114101 : DECL_INITIAL (current_function_decl) = block_node;
445 2319722 : else if (current_binding_level == global_binding_level)
446 : /* When using gfc_start_block/gfc_finish_block from middle-end hooks,
447 : don't add newly created BLOCKs as subblocks of global_binding_level. */
448 : ;
449 2315780 : else if (block_node)
450 : {
451 608424 : current_binding_level->blocks
452 608424 : = block_chainon (current_binding_level->blocks, block_node);
453 : }
454 :
455 : /* If we did not make a block for the level just exited, any blocks made for
456 : inner levels (since they cannot be recorded as subblocks in that level)
457 : must be carried forward so they will later become subblocks of something
458 : else. */
459 1707356 : else if (subblock_chain)
460 202503 : current_binding_level->blocks
461 202503 : = block_chainon (current_binding_level->blocks, subblock_chain);
462 2433823 : if (block_node)
463 725366 : TREE_USED (block_node) = 1;
464 :
465 2433823 : return block_node;
466 : }
467 :
468 :
469 : /* Records a ..._DECL node DECL as belonging to the current lexical scope.
470 : Returns the ..._DECL node. */
471 :
472 : tree
473 144825469 : pushdecl (tree decl)
474 : {
475 144825469 : if (global_bindings_p ())
476 142799652 : DECL_CONTEXT (decl) = current_translation_unit;
477 : else
478 : {
479 : /* External objects aren't nested. For debug info insert a copy
480 : of the decl into the binding level. */
481 2025817 : if (DECL_EXTERNAL (decl))
482 : {
483 290 : tree orig = decl;
484 290 : decl = copy_node (decl);
485 290 : DECL_CONTEXT (orig) = NULL_TREE;
486 : }
487 2025817 : DECL_CONTEXT (decl) = current_function_decl;
488 : }
489 :
490 : /* Put the declaration on the list. */
491 144825469 : DECL_CHAIN (decl) = current_binding_level->names;
492 144825469 : current_binding_level->names = decl;
493 :
494 : /* For the declaration of a type, set its name if it is not already set. */
495 :
496 144825469 : if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0)
497 : {
498 699637 : if (DECL_SOURCE_LINE (decl) == 0)
499 699637 : TYPE_NAME (TREE_TYPE (decl)) = decl;
500 : else
501 0 : TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl);
502 : }
503 :
504 144825469 : return decl;
505 : }
506 :
507 :
508 : /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL. */
509 :
510 : tree
511 21785 : pushdecl_top_level (tree x)
512 : {
513 21785 : tree t;
514 21785 : struct binding_level *b = current_binding_level;
515 :
516 21785 : current_binding_level = global_binding_level;
517 21785 : t = pushdecl (x);
518 21785 : current_binding_level = b;
519 21785 : return t;
520 : }
521 :
522 : #ifndef CHAR_TYPE_SIZE
523 : #define CHAR_TYPE_SIZE BITS_PER_UNIT
524 : #endif
525 :
526 : #ifndef INT_TYPE_SIZE
527 : #define INT_TYPE_SIZE BITS_PER_WORD
528 : #endif
529 :
530 : #undef SIZE_TYPE
531 : #define SIZE_TYPE "long unsigned int"
532 :
533 : /* Create tree nodes for the basic scalar types of Fortran 95,
534 : and some nodes representing standard constants (0, 1, (void *) 0).
535 : Initialize the global binding level.
536 : Make definitions for built-in primitive functions. */
537 : static void
538 31783 : gfc_init_decl_processing (void)
539 : {
540 31783 : current_function_decl = NULL;
541 31783 : current_binding_level = NULL_BINDING_LEVEL;
542 31783 : free_binding_level = NULL_BINDING_LEVEL;
543 :
544 : /* Make the binding_level structure for global names. We move all
545 : variables that are in a COMMON block to this binding level. */
546 31783 : pushlevel ();
547 31783 : global_binding_level = current_binding_level;
548 :
549 : /* Build common tree nodes. char_type_node is unsigned because we
550 : only use it for actual characters, not for INTEGER(1). */
551 31783 : build_common_tree_nodes (false);
552 :
553 : /* Set up F95 type nodes. */
554 31783 : gfc_init_kinds ();
555 31783 : gfc_init_types ();
556 31783 : gfc_init_c_interop_kinds ();
557 31783 : }
558 :
559 :
560 : /* Builtin function initialization. */
561 :
562 : static tree
563 137169451 : gfc_builtin_function (tree decl)
564 : {
565 137169451 : pushdecl (decl);
566 137169451 : return decl;
567 : }
568 :
569 : /* So far we need just these 12 attribute types. */
570 : #define ATTR_NULL 0
571 : #define ATTR_LEAF_LIST (ECF_LEAF)
572 : #define ATTR_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF)
573 : #define ATTR_NOTHROW_LEAF_MALLOC_LIST (ECF_NOTHROW | ECF_LEAF | ECF_MALLOC)
574 : #define ATTR_CONST_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_CONST)
575 : #define ATTR_PURE_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_PURE)
576 : #define ATTR_NOTHROW_LIST (ECF_NOTHROW)
577 : #define ATTR_CONST_NOTHROW_LIST (ECF_NOTHROW | ECF_CONST)
578 : #define ATTR_ALLOC_WARN_UNUSED_RESULT_SIZE_2_NOTHROW_LIST \
579 : (ECF_NOTHROW | ECF_LEAF | ECF_MALLOC)
580 : #define ATTR_ALLOC_WARN_UNUSED_RESULT_SIZE_2_NOTHROW_LEAF_LIST \
581 : (ECF_NOTHROW | ECF_LEAF)
582 : #define ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST \
583 : (ECF_COLD | ECF_NORETURN | \
584 : ECF_NOTHROW | ECF_LEAF)
585 : #define ATTR_CALLBACK_GOMP_LIST (ECF_CB_1_2 | ATTR_NOTHROW_LIST)
586 : #define ATTR_PURE_NOTHROW_LIST (ECF_PURE | ECF_NOTHROW)
587 :
588 : static void
589 19439884 : gfc_define_builtin (const char *name, tree type, enum built_in_function code,
590 : const char *library_name, int attr)
591 : {
592 19439884 : tree decl;
593 :
594 19439884 : decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
595 : library_name, NULL_TREE);
596 19439884 : set_call_expr_flags (decl, attr);
597 :
598 19439884 : set_builtin_decl (code, decl, true);
599 19439884 : }
600 :
601 :
602 : #define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \
603 : gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
604 : BUILT_IN_ ## code ## L, name "l", \
605 : ATTR_CONST_NOTHROW_LEAF_LIST); \
606 : gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \
607 : BUILT_IN_ ## code, name, \
608 : ATTR_CONST_NOTHROW_LEAF_LIST); \
609 : gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \
610 : BUILT_IN_ ## code ## F, name "f", \
611 : ATTR_CONST_NOTHROW_LEAF_LIST);
612 :
613 : #define DEFINE_MATH_BUILTIN(code, name, argtype) \
614 : DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_)
615 :
616 : #define DEFINE_MATH_BUILTIN_C(code, name, argtype) \
617 : DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) \
618 : DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c)
619 :
620 :
621 : /* Create function types for builtin functions. */
622 :
623 : static void
624 190596 : build_builtin_fntypes (tree *fntype, tree type)
625 : {
626 : /* type (*) (type) */
627 190596 : fntype[0] = build_function_type_list (type, type, NULL_TREE);
628 : /* type (*) (type, type) */
629 190596 : fntype[1] = build_function_type_list (type, type, type, NULL_TREE);
630 : /* type (*) (type, int) */
631 190596 : fntype[2] = build_function_type_list (type,
632 : type, integer_type_node, NULL_TREE);
633 : /* type (*) (void) */
634 190596 : fntype[3] = build_function_type_list (type, NULL_TREE);
635 : /* type (*) (type, &int) */
636 190596 : fntype[4] = build_function_type_list (type, type,
637 : build_pointer_type (integer_type_node),
638 : NULL_TREE);
639 : /* type (*) (int, type) */
640 190596 : fntype[5] = build_function_type_list (type,
641 : integer_type_node, type, NULL_TREE);
642 190596 : }
643 :
644 :
645 : static tree
646 158830 : builtin_type_for_size (int size, bool unsignedp)
647 : {
648 158830 : tree type = gfc_type_for_size (size, unsignedp);
649 158830 : return type ? type : error_mark_node;
650 : }
651 :
652 : /* Initialization of builtin function nodes. */
653 :
654 : static void
655 31766 : gfc_init_builtin_functions (void)
656 : {
657 31766 : enum builtin_type
658 : {
659 : #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
660 : #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
661 : #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
662 : #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
663 : #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
664 : #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
665 : #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
666 : #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
667 : ARG6) NAME,
668 : #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
669 : ARG6, ARG7) NAME,
670 : #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
671 : ARG6, ARG7, ARG8) NAME,
672 : #define DEF_FUNCTION_TYPE_9(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
673 : ARG6, ARG7, ARG8, ARG9) NAME,
674 : #define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
675 : ARG6, ARG7, ARG8, ARG9, ARG10) NAME,
676 : #define DEF_FUNCTION_TYPE_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
677 : ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME,
678 : #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
679 : #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
680 : #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
681 : #define DEF_FUNCTION_TYPE_VAR_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
682 : ARG6) NAME,
683 : #define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
684 : ARG6, ARG7) NAME,
685 : #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
686 : #include "types.def"
687 : #undef DEF_PRIMITIVE_TYPE
688 : #undef DEF_FUNCTION_TYPE_0
689 : #undef DEF_FUNCTION_TYPE_1
690 : #undef DEF_FUNCTION_TYPE_2
691 : #undef DEF_FUNCTION_TYPE_3
692 : #undef DEF_FUNCTION_TYPE_4
693 : #undef DEF_FUNCTION_TYPE_5
694 : #undef DEF_FUNCTION_TYPE_6
695 : #undef DEF_FUNCTION_TYPE_7
696 : #undef DEF_FUNCTION_TYPE_8
697 : #undef DEF_FUNCTION_TYPE_9
698 : #undef DEF_FUNCTION_TYPE_10
699 : #undef DEF_FUNCTION_TYPE_11
700 : #undef DEF_FUNCTION_TYPE_VAR_0
701 : #undef DEF_FUNCTION_TYPE_VAR_1
702 : #undef DEF_FUNCTION_TYPE_VAR_2
703 : #undef DEF_FUNCTION_TYPE_VAR_6
704 : #undef DEF_FUNCTION_TYPE_VAR_7
705 : #undef DEF_POINTER_TYPE
706 : BT_LAST
707 : };
708 :
709 31766 : tree mfunc_float[6];
710 31766 : tree mfunc_double[6];
711 31766 : tree mfunc_longdouble[6];
712 31766 : tree mfunc_cfloat[6];
713 31766 : tree mfunc_cdouble[6];
714 31766 : tree mfunc_clongdouble[6];
715 31766 : tree func_cfloat_float, func_float_cfloat;
716 31766 : tree func_cdouble_double, func_double_cdouble;
717 31766 : tree func_clongdouble_longdouble, func_longdouble_clongdouble;
718 31766 : tree func_float_floatp_floatp;
719 31766 : tree func_double_doublep_doublep;
720 31766 : tree func_longdouble_longdoublep_longdoublep;
721 31766 : tree ftype, ptype;
722 31766 : tree builtin_types[(int) BT_LAST + 1];
723 :
724 31766 : int attr;
725 :
726 31766 : build_builtin_fntypes (mfunc_float, float_type_node);
727 31766 : build_builtin_fntypes (mfunc_double, double_type_node);
728 31766 : build_builtin_fntypes (mfunc_longdouble, long_double_type_node);
729 31766 : build_builtin_fntypes (mfunc_cfloat, complex_float_type_node);
730 31766 : build_builtin_fntypes (mfunc_cdouble, complex_double_type_node);
731 31766 : build_builtin_fntypes (mfunc_clongdouble, complex_long_double_type_node);
732 :
733 31766 : func_cfloat_float = build_function_type_list (float_type_node,
734 : complex_float_type_node,
735 : NULL_TREE);
736 :
737 31766 : func_float_cfloat = build_function_type_list (complex_float_type_node,
738 : float_type_node, NULL_TREE);
739 :
740 31766 : func_cdouble_double = build_function_type_list (double_type_node,
741 : complex_double_type_node,
742 : NULL_TREE);
743 :
744 31766 : func_double_cdouble = build_function_type_list (complex_double_type_node,
745 : double_type_node, NULL_TREE);
746 :
747 31766 : func_clongdouble_longdouble
748 31766 : = build_function_type_list (long_double_type_node,
749 : complex_long_double_type_node, NULL_TREE);
750 :
751 31766 : func_longdouble_clongdouble
752 31766 : = build_function_type_list (complex_long_double_type_node,
753 : long_double_type_node, NULL_TREE);
754 :
755 31766 : ptype = build_pointer_type (float_type_node);
756 31766 : func_float_floatp_floatp
757 31766 : = build_function_type_list (void_type_node, float_type_node, ptype, ptype,
758 : NULL_TREE);
759 :
760 31766 : ptype = build_pointer_type (double_type_node);
761 31766 : func_double_doublep_doublep
762 31766 : = build_function_type_list (void_type_node, double_type_node, ptype,
763 : ptype, NULL_TREE);
764 :
765 31766 : ptype = build_pointer_type (long_double_type_node);
766 31766 : func_longdouble_longdoublep_longdoublep
767 31766 : = build_function_type_list (void_type_node, long_double_type_node, ptype,
768 : ptype, NULL_TREE);
769 :
770 : /* Non-math builtins are defined manually, so they're not included here. */
771 : #define OTHER_BUILTIN(ID,NAME,TYPE,CONST)
772 :
773 : #include "mathbuiltins.def"
774 :
775 31766 : gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0],
776 : BUILT_IN_ROUNDL, "roundl", ATTR_CONST_NOTHROW_LEAF_LIST);
777 31766 : gfc_define_builtin ("__builtin_round", mfunc_double[0],
778 : BUILT_IN_ROUND, "round", ATTR_CONST_NOTHROW_LEAF_LIST);
779 31766 : gfc_define_builtin ("__builtin_roundf", mfunc_float[0],
780 : BUILT_IN_ROUNDF, "roundf", ATTR_CONST_NOTHROW_LEAF_LIST);
781 :
782 31766 : gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0],
783 : BUILT_IN_TRUNCL, "truncl", ATTR_CONST_NOTHROW_LEAF_LIST);
784 31766 : gfc_define_builtin ("__builtin_trunc", mfunc_double[0],
785 : BUILT_IN_TRUNC, "trunc", ATTR_CONST_NOTHROW_LEAF_LIST);
786 31766 : gfc_define_builtin ("__builtin_truncf", mfunc_float[0],
787 : BUILT_IN_TRUNCF, "truncf", ATTR_CONST_NOTHROW_LEAF_LIST);
788 :
789 31766 : gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble,
790 : BUILT_IN_CABSL, "cabsl", ATTR_CONST_NOTHROW_LEAF_LIST);
791 31766 : gfc_define_builtin ("__builtin_cabs", func_cdouble_double,
792 : BUILT_IN_CABS, "cabs", ATTR_CONST_NOTHROW_LEAF_LIST);
793 31766 : gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
794 : BUILT_IN_CABSF, "cabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
795 :
796 31766 : gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1],
797 : BUILT_IN_COPYSIGNL, "copysignl",
798 : ATTR_CONST_NOTHROW_LEAF_LIST);
799 31766 : gfc_define_builtin ("__builtin_copysign", mfunc_double[1],
800 : BUILT_IN_COPYSIGN, "copysign",
801 : ATTR_CONST_NOTHROW_LEAF_LIST);
802 31766 : gfc_define_builtin ("__builtin_copysignf", mfunc_float[1],
803 : BUILT_IN_COPYSIGNF, "copysignf",
804 : ATTR_CONST_NOTHROW_LEAF_LIST);
805 :
806 31766 : gfc_define_builtin ("__builtin_nextafterl", mfunc_longdouble[1],
807 : BUILT_IN_NEXTAFTERL, "nextafterl",
808 : ATTR_CONST_NOTHROW_LEAF_LIST);
809 31766 : gfc_define_builtin ("__builtin_nextafter", mfunc_double[1],
810 : BUILT_IN_NEXTAFTER, "nextafter",
811 : ATTR_CONST_NOTHROW_LEAF_LIST);
812 31766 : gfc_define_builtin ("__builtin_nextafterf", mfunc_float[1],
813 : BUILT_IN_NEXTAFTERF, "nextafterf",
814 : ATTR_CONST_NOTHROW_LEAF_LIST);
815 :
816 : /* Some built-ins depend on rounding mode. Depending on compilation options, they
817 : will be "pure" or "const". */
818 31766 : attr = flag_rounding_math ? ATTR_PURE_NOTHROW_LEAF_LIST : ATTR_CONST_NOTHROW_LEAF_LIST;
819 :
820 31766 : gfc_define_builtin ("__builtin_rintl", mfunc_longdouble[0],
821 : BUILT_IN_RINTL, "rintl", attr);
822 31766 : gfc_define_builtin ("__builtin_rint", mfunc_double[0],
823 : BUILT_IN_RINT, "rint", attr);
824 31766 : gfc_define_builtin ("__builtin_rintf", mfunc_float[0],
825 : BUILT_IN_RINTF, "rintf", attr);
826 :
827 31766 : gfc_define_builtin ("__builtin_remainderl", mfunc_longdouble[1],
828 : BUILT_IN_REMAINDERL, "remainderl", attr);
829 31766 : gfc_define_builtin ("__builtin_remainder", mfunc_double[1],
830 : BUILT_IN_REMAINDER, "remainder", attr);
831 31766 : gfc_define_builtin ("__builtin_remainderf", mfunc_float[1],
832 : BUILT_IN_REMAINDERF, "remainderf", attr);
833 :
834 31766 : gfc_define_builtin ("__builtin_logbl", mfunc_longdouble[0],
835 : BUILT_IN_LOGBL, "logbl", ATTR_CONST_NOTHROW_LEAF_LIST);
836 31766 : gfc_define_builtin ("__builtin_logb", mfunc_double[0],
837 : BUILT_IN_LOGB, "logb", ATTR_CONST_NOTHROW_LEAF_LIST);
838 31766 : gfc_define_builtin ("__builtin_logbf", mfunc_float[0],
839 : BUILT_IN_LOGBF, "logbf", ATTR_CONST_NOTHROW_LEAF_LIST);
840 :
841 :
842 31766 : gfc_define_builtin ("__builtin_frexpl", mfunc_longdouble[4],
843 : BUILT_IN_FREXPL, "frexpl", ATTR_NOTHROW_LEAF_LIST);
844 31766 : gfc_define_builtin ("__builtin_frexp", mfunc_double[4],
845 : BUILT_IN_FREXP, "frexp", ATTR_NOTHROW_LEAF_LIST);
846 31766 : gfc_define_builtin ("__builtin_frexpf", mfunc_float[4],
847 : BUILT_IN_FREXPF, "frexpf", ATTR_NOTHROW_LEAF_LIST);
848 :
849 31766 : gfc_define_builtin ("__builtin_fabsl", mfunc_longdouble[0],
850 : BUILT_IN_FABSL, "fabsl", ATTR_CONST_NOTHROW_LEAF_LIST);
851 31766 : gfc_define_builtin ("__builtin_fabs", mfunc_double[0],
852 : BUILT_IN_FABS, "fabs", ATTR_CONST_NOTHROW_LEAF_LIST);
853 31766 : gfc_define_builtin ("__builtin_fabsf", mfunc_float[0],
854 : BUILT_IN_FABSF, "fabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
855 :
856 31766 : gfc_define_builtin ("__builtin_scalbnl", mfunc_longdouble[2],
857 : BUILT_IN_SCALBNL, "scalbnl", ATTR_CONST_NOTHROW_LEAF_LIST);
858 31766 : gfc_define_builtin ("__builtin_scalbn", mfunc_double[2],
859 : BUILT_IN_SCALBN, "scalbn", ATTR_CONST_NOTHROW_LEAF_LIST);
860 31766 : gfc_define_builtin ("__builtin_scalbnf", mfunc_float[2],
861 : BUILT_IN_SCALBNF, "scalbnf", ATTR_CONST_NOTHROW_LEAF_LIST);
862 :
863 31766 : gfc_define_builtin ("__builtin_fmaxl", mfunc_longdouble[1],
864 : BUILT_IN_FMAXL, "fmaxl", ATTR_CONST_NOTHROW_LEAF_LIST);
865 31766 : gfc_define_builtin ("__builtin_fmax", mfunc_double[1],
866 : BUILT_IN_FMAX, "fmax", ATTR_CONST_NOTHROW_LEAF_LIST);
867 31766 : gfc_define_builtin ("__builtin_fmaxf", mfunc_float[1],
868 : BUILT_IN_FMAXF, "fmaxf", ATTR_CONST_NOTHROW_LEAF_LIST);
869 :
870 31766 : gfc_define_builtin ("__builtin_fminl", mfunc_longdouble[1],
871 : BUILT_IN_FMINL, "fminl", ATTR_CONST_NOTHROW_LEAF_LIST);
872 31766 : gfc_define_builtin ("__builtin_fmin", mfunc_double[1],
873 : BUILT_IN_FMIN, "fmin", ATTR_CONST_NOTHROW_LEAF_LIST);
874 31766 : gfc_define_builtin ("__builtin_fminf", mfunc_float[1],
875 : BUILT_IN_FMINF, "fminf", ATTR_CONST_NOTHROW_LEAF_LIST);
876 :
877 31766 : gfc_define_builtin ("__builtin_fmodl", mfunc_longdouble[1],
878 : BUILT_IN_FMODL, "fmodl", ATTR_CONST_NOTHROW_LEAF_LIST);
879 31766 : gfc_define_builtin ("__builtin_fmod", mfunc_double[1],
880 : BUILT_IN_FMOD, "fmod", ATTR_CONST_NOTHROW_LEAF_LIST);
881 31766 : gfc_define_builtin ("__builtin_fmodf", mfunc_float[1],
882 : BUILT_IN_FMODF, "fmodf", ATTR_CONST_NOTHROW_LEAF_LIST);
883 :
884 : /* iround{f,,l}, lround{f,,l} and llround{f,,l} */
885 31766 : ftype = build_function_type_list (integer_type_node,
886 : float_type_node, NULL_TREE);
887 31766 : gfc_define_builtin("__builtin_iroundf", ftype, BUILT_IN_IROUNDF,
888 : "iroundf", ATTR_CONST_NOTHROW_LEAF_LIST);
889 31766 : ftype = build_function_type_list (long_integer_type_node,
890 : float_type_node, NULL_TREE);
891 31766 : gfc_define_builtin ("__builtin_lroundf", ftype, BUILT_IN_LROUNDF,
892 : "lroundf", ATTR_CONST_NOTHROW_LEAF_LIST);
893 31766 : ftype = build_function_type_list (long_long_integer_type_node,
894 : float_type_node, NULL_TREE);
895 31766 : gfc_define_builtin ("__builtin_llroundf", ftype, BUILT_IN_LLROUNDF,
896 : "llroundf", ATTR_CONST_NOTHROW_LEAF_LIST);
897 :
898 31766 : ftype = build_function_type_list (integer_type_node,
899 : double_type_node, NULL_TREE);
900 31766 : gfc_define_builtin("__builtin_iround", ftype, BUILT_IN_IROUND,
901 : "iround", ATTR_CONST_NOTHROW_LEAF_LIST);
902 31766 : ftype = build_function_type_list (long_integer_type_node,
903 : double_type_node, NULL_TREE);
904 31766 : gfc_define_builtin ("__builtin_lround", ftype, BUILT_IN_LROUND,
905 : "lround", ATTR_CONST_NOTHROW_LEAF_LIST);
906 31766 : ftype = build_function_type_list (long_long_integer_type_node,
907 : double_type_node, NULL_TREE);
908 31766 : gfc_define_builtin ("__builtin_llround", ftype, BUILT_IN_LLROUND,
909 : "llround", ATTR_CONST_NOTHROW_LEAF_LIST);
910 :
911 31766 : ftype = build_function_type_list (integer_type_node,
912 : long_double_type_node, NULL_TREE);
913 31766 : gfc_define_builtin("__builtin_iroundl", ftype, BUILT_IN_IROUNDL,
914 : "iroundl", ATTR_CONST_NOTHROW_LEAF_LIST);
915 31766 : ftype = build_function_type_list (long_integer_type_node,
916 : long_double_type_node, NULL_TREE);
917 31766 : gfc_define_builtin ("__builtin_lroundl", ftype, BUILT_IN_LROUNDL,
918 : "lroundl", ATTR_CONST_NOTHROW_LEAF_LIST);
919 31766 : ftype = build_function_type_list (long_long_integer_type_node,
920 : long_double_type_node, NULL_TREE);
921 31766 : gfc_define_builtin ("__builtin_llroundl", ftype, BUILT_IN_LLROUNDL,
922 : "llroundl", ATTR_CONST_NOTHROW_LEAF_LIST);
923 :
924 : /* These are used to implement the ** operator. */
925 31766 : gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1],
926 : BUILT_IN_POWL, "powl", ATTR_CONST_NOTHROW_LEAF_LIST);
927 31766 : gfc_define_builtin ("__builtin_pow", mfunc_double[1],
928 : BUILT_IN_POW, "pow", ATTR_CONST_NOTHROW_LEAF_LIST);
929 31766 : gfc_define_builtin ("__builtin_powf", mfunc_float[1],
930 : BUILT_IN_POWF, "powf", ATTR_CONST_NOTHROW_LEAF_LIST);
931 31766 : gfc_define_builtin ("__builtin_cpowl", mfunc_clongdouble[1],
932 : BUILT_IN_CPOWL, "cpowl", ATTR_CONST_NOTHROW_LEAF_LIST);
933 31766 : gfc_define_builtin ("__builtin_cpow", mfunc_cdouble[1],
934 : BUILT_IN_CPOW, "cpow", ATTR_CONST_NOTHROW_LEAF_LIST);
935 31766 : gfc_define_builtin ("__builtin_cpowf", mfunc_cfloat[1],
936 : BUILT_IN_CPOWF, "cpowf", ATTR_CONST_NOTHROW_LEAF_LIST);
937 31766 : gfc_define_builtin ("__builtin_powil", mfunc_longdouble[2],
938 : BUILT_IN_POWIL, "powil", ATTR_CONST_NOTHROW_LEAF_LIST);
939 31766 : gfc_define_builtin ("__builtin_powi", mfunc_double[2],
940 : BUILT_IN_POWI, "powi", ATTR_CONST_NOTHROW_LEAF_LIST);
941 31766 : gfc_define_builtin ("__builtin_powif", mfunc_float[2],
942 : BUILT_IN_POWIF, "powif", ATTR_CONST_NOTHROW_LEAF_LIST);
943 :
944 :
945 31766 : if (targetm.libc_has_function (function_c99_math_complex, NULL_TREE))
946 : {
947 31766 : gfc_define_builtin ("__builtin_cbrtl", mfunc_longdouble[0],
948 : BUILT_IN_CBRTL, "cbrtl",
949 : ATTR_CONST_NOTHROW_LEAF_LIST);
950 31766 : gfc_define_builtin ("__builtin_cbrt", mfunc_double[0],
951 : BUILT_IN_CBRT, "cbrt",
952 : ATTR_CONST_NOTHROW_LEAF_LIST);
953 31766 : gfc_define_builtin ("__builtin_cbrtf", mfunc_float[0],
954 : BUILT_IN_CBRTF, "cbrtf",
955 : ATTR_CONST_NOTHROW_LEAF_LIST);
956 31766 : gfc_define_builtin ("__builtin_cexpil", func_longdouble_clongdouble,
957 : BUILT_IN_CEXPIL, "cexpil",
958 : ATTR_CONST_NOTHROW_LEAF_LIST);
959 31766 : gfc_define_builtin ("__builtin_cexpi", func_double_cdouble,
960 : BUILT_IN_CEXPI, "cexpi",
961 : ATTR_CONST_NOTHROW_LEAF_LIST);
962 31766 : gfc_define_builtin ("__builtin_cexpif", func_float_cfloat,
963 : BUILT_IN_CEXPIF, "cexpif",
964 : ATTR_CONST_NOTHROW_LEAF_LIST);
965 : }
966 :
967 31766 : if (targetm.libc_has_function (function_sincos, NULL_TREE))
968 : {
969 31766 : gfc_define_builtin ("__builtin_sincosl",
970 : func_longdouble_longdoublep_longdoublep,
971 : BUILT_IN_SINCOSL, "sincosl", ATTR_NOTHROW_LEAF_LIST);
972 31766 : gfc_define_builtin ("__builtin_sincos", func_double_doublep_doublep,
973 : BUILT_IN_SINCOS, "sincos", ATTR_NOTHROW_LEAF_LIST);
974 31766 : gfc_define_builtin ("__builtin_sincosf", func_float_floatp_floatp,
975 : BUILT_IN_SINCOSF, "sincosf", ATTR_NOTHROW_LEAF_LIST);
976 : }
977 :
978 : /* For LEADZ, TRAILZ, POPCNT and POPPAR. */
979 31766 : ftype = build_function_type_list (integer_type_node,
980 : unsigned_type_node, NULL_TREE);
981 31766 : gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
982 : "__builtin_clz", ATTR_CONST_NOTHROW_LEAF_LIST);
983 31766 : gfc_define_builtin ("__builtin_ctz", ftype, BUILT_IN_CTZ,
984 : "__builtin_ctz", ATTR_CONST_NOTHROW_LEAF_LIST);
985 31766 : gfc_define_builtin ("__builtin_parity", ftype, BUILT_IN_PARITY,
986 : "__builtin_parity", ATTR_CONST_NOTHROW_LEAF_LIST);
987 31766 : gfc_define_builtin ("__builtin_popcount", ftype, BUILT_IN_POPCOUNT,
988 : "__builtin_popcount", ATTR_CONST_NOTHROW_LEAF_LIST);
989 :
990 31766 : ftype = build_function_type_list (integer_type_node,
991 : long_unsigned_type_node, NULL_TREE);
992 31766 : gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
993 : "__builtin_clzl", ATTR_CONST_NOTHROW_LEAF_LIST);
994 31766 : gfc_define_builtin ("__builtin_ctzl", ftype, BUILT_IN_CTZL,
995 : "__builtin_ctzl", ATTR_CONST_NOTHROW_LEAF_LIST);
996 31766 : gfc_define_builtin ("__builtin_parityl", ftype, BUILT_IN_PARITYL,
997 : "__builtin_parityl", ATTR_CONST_NOTHROW_LEAF_LIST);
998 31766 : gfc_define_builtin ("__builtin_popcountl", ftype, BUILT_IN_POPCOUNTL,
999 : "__builtin_popcountl", ATTR_CONST_NOTHROW_LEAF_LIST);
1000 :
1001 31766 : ftype = build_function_type_list (integer_type_node,
1002 : long_long_unsigned_type_node, NULL_TREE);
1003 31766 : gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
1004 : "__builtin_clzll", ATTR_CONST_NOTHROW_LEAF_LIST);
1005 31766 : gfc_define_builtin ("__builtin_ctzll", ftype, BUILT_IN_CTZLL,
1006 : "__builtin_ctzll", ATTR_CONST_NOTHROW_LEAF_LIST);
1007 31766 : gfc_define_builtin ("__builtin_parityll", ftype, BUILT_IN_PARITYLL,
1008 : "__builtin_parityll", ATTR_CONST_NOTHROW_LEAF_LIST);
1009 31766 : gfc_define_builtin ("__builtin_popcountll", ftype, BUILT_IN_POPCOUNTLL,
1010 : "__builtin_popcountll", ATTR_CONST_NOTHROW_LEAF_LIST);
1011 :
1012 : /* Other builtin functions we use. */
1013 :
1014 31766 : ftype = build_function_type_list (long_integer_type_node,
1015 : long_integer_type_node,
1016 : long_integer_type_node, NULL_TREE);
1017 31766 : gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
1018 : "__builtin_expect", ATTR_CONST_NOTHROW_LEAF_LIST);
1019 :
1020 31766 : ftype = build_function_type_list (void_type_node,
1021 : pvoid_type_node, NULL_TREE);
1022 31766 : gfc_define_builtin ("__builtin_free", ftype, BUILT_IN_FREE,
1023 : "free", ATTR_NOTHROW_LEAF_LIST);
1024 :
1025 31766 : ftype = build_function_type_list (pvoid_type_node,
1026 : size_type_node, NULL_TREE);
1027 31766 : gfc_define_builtin ("__builtin_malloc", ftype, BUILT_IN_MALLOC,
1028 : "malloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);
1029 :
1030 31766 : ftype = build_function_type_list (pvoid_type_node, size_type_node,
1031 : size_type_node, NULL_TREE);
1032 31766 : gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC,
1033 : "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);
1034 31766 : DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1;
1035 :
1036 31766 : ftype = build_function_type_list (pvoid_type_node, pvoid_type_node,
1037 : size_type_node, NULL_TREE);
1038 31766 : gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
1039 : "realloc", ATTR_NOTHROW_LEAF_LIST);
1040 :
1041 31766 : ftype = build_function_type_list (size_type_node, pchar_type_node,
1042 : size_type_node, NULL_TREE);
1043 31766 : gfc_define_builtin ("__builtin_strnlen", ftype, BUILT_IN_STRNLEN,
1044 : "strnlen", ATTR_PURE_NOTHROW_LEAF_LIST);
1045 :
1046 : /* Type-generic floating-point classification built-ins. */
1047 :
1048 31766 : ftype = build_function_type (integer_type_node, NULL_TREE);
1049 31766 : gfc_define_builtin ("__builtin_isfinite", ftype, BUILT_IN_ISFINITE,
1050 : "__builtin_isfinite", ATTR_CONST_NOTHROW_LEAF_LIST);
1051 31766 : gfc_define_builtin ("__builtin_isinf", ftype, BUILT_IN_ISINF,
1052 : "__builtin_isinf", ATTR_CONST_NOTHROW_LEAF_LIST);
1053 31766 : gfc_define_builtin ("__builtin_isinf_sign", ftype, BUILT_IN_ISINF_SIGN,
1054 : "__builtin_isinf_sign", ATTR_CONST_NOTHROW_LEAF_LIST);
1055 31766 : gfc_define_builtin ("__builtin_isnan", ftype, BUILT_IN_ISNAN,
1056 : "__builtin_isnan", ATTR_CONST_NOTHROW_LEAF_LIST);
1057 31766 : gfc_define_builtin ("__builtin_isnormal", ftype, BUILT_IN_ISNORMAL,
1058 : "__builtin_isnormal", ATTR_CONST_NOTHROW_LEAF_LIST);
1059 31766 : gfc_define_builtin ("__builtin_issignaling", ftype, BUILT_IN_ISSIGNALING,
1060 : "__builtin_issignaling", ATTR_CONST_NOTHROW_LEAF_LIST);
1061 31766 : gfc_define_builtin ("__builtin_signbit", ftype, BUILT_IN_SIGNBIT,
1062 : "__builtin_signbit", ATTR_CONST_NOTHROW_LEAF_LIST);
1063 31766 : gfc_define_builtin ("__builtin_fpclassify", ftype, BUILT_IN_FPCLASSIFY,
1064 : "__builtin_fpclassify", ATTR_CONST_NOTHROW_LEAF_LIST);
1065 :
1066 31766 : gfc_define_builtin ("__builtin_isless", ftype, BUILT_IN_ISLESS,
1067 : "__builtin_isless", ATTR_CONST_NOTHROW_LEAF_LIST);
1068 31766 : gfc_define_builtin ("__builtin_islessequal", ftype, BUILT_IN_ISLESSEQUAL,
1069 : "__builtin_islessequal", ATTR_CONST_NOTHROW_LEAF_LIST);
1070 31766 : gfc_define_builtin ("__builtin_islessgreater", ftype, BUILT_IN_ISLESSGREATER,
1071 : "__builtin_islessgreater", ATTR_CONST_NOTHROW_LEAF_LIST);
1072 31766 : gfc_define_builtin ("__builtin_isgreater", ftype, BUILT_IN_ISGREATER,
1073 : "__builtin_isgreater", ATTR_CONST_NOTHROW_LEAF_LIST);
1074 31766 : gfc_define_builtin ("__builtin_isgreaterequal", ftype,
1075 : BUILT_IN_ISGREATEREQUAL, "__builtin_isgreaterequal",
1076 : ATTR_CONST_NOTHROW_LEAF_LIST);
1077 31766 : gfc_define_builtin ("__builtin_isunordered", ftype, BUILT_IN_ISUNORDERED,
1078 : "__builtin_isunordered", ATTR_CONST_NOTHROW_LEAF_LIST);
1079 31766 : gfc_define_builtin ("__builtin_iseqsig", ftype, BUILT_IN_ISEQSIG,
1080 : "__builtin_iseqsig", ATTR_CONST_NOTHROW_LEAF_LIST);
1081 :
1082 :
1083 : #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
1084 : builtin_types[(int) ENUM] = VALUE;
1085 : #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
1086 : builtin_types[(int) ENUM] \
1087 : = build_function_type_list (builtin_types[(int) RETURN], \
1088 : NULL_TREE);
1089 : #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
1090 : builtin_types[(int) ENUM] \
1091 : = build_function_type_list (builtin_types[(int) RETURN], \
1092 : builtin_types[(int) ARG1], \
1093 : NULL_TREE);
1094 : #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
1095 : builtin_types[(int) ENUM] \
1096 : = build_function_type_list (builtin_types[(int) RETURN], \
1097 : builtin_types[(int) ARG1], \
1098 : builtin_types[(int) ARG2], \
1099 : NULL_TREE);
1100 : #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
1101 : builtin_types[(int) ENUM] \
1102 : = build_function_type_list (builtin_types[(int) RETURN], \
1103 : builtin_types[(int) ARG1], \
1104 : builtin_types[(int) ARG2], \
1105 : builtin_types[(int) ARG3], \
1106 : NULL_TREE);
1107 : #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
1108 : builtin_types[(int) ENUM] \
1109 : = build_function_type_list (builtin_types[(int) RETURN], \
1110 : builtin_types[(int) ARG1], \
1111 : builtin_types[(int) ARG2], \
1112 : builtin_types[(int) ARG3], \
1113 : builtin_types[(int) ARG4], \
1114 : NULL_TREE);
1115 : #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
1116 : builtin_types[(int) ENUM] \
1117 : = build_function_type_list (builtin_types[(int) RETURN], \
1118 : builtin_types[(int) ARG1], \
1119 : builtin_types[(int) ARG2], \
1120 : builtin_types[(int) ARG3], \
1121 : builtin_types[(int) ARG4], \
1122 : builtin_types[(int) ARG5], \
1123 : NULL_TREE);
1124 : #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1125 : ARG6) \
1126 : builtin_types[(int) ENUM] \
1127 : = build_function_type_list (builtin_types[(int) RETURN], \
1128 : builtin_types[(int) ARG1], \
1129 : builtin_types[(int) ARG2], \
1130 : builtin_types[(int) ARG3], \
1131 : builtin_types[(int) ARG4], \
1132 : builtin_types[(int) ARG5], \
1133 : builtin_types[(int) ARG6], \
1134 : NULL_TREE);
1135 : #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1136 : ARG6, ARG7) \
1137 : builtin_types[(int) ENUM] \
1138 : = build_function_type_list (builtin_types[(int) RETURN], \
1139 : builtin_types[(int) ARG1], \
1140 : builtin_types[(int) ARG2], \
1141 : builtin_types[(int) ARG3], \
1142 : builtin_types[(int) ARG4], \
1143 : builtin_types[(int) ARG5], \
1144 : builtin_types[(int) ARG6], \
1145 : builtin_types[(int) ARG7], \
1146 : NULL_TREE);
1147 : #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1148 : ARG6, ARG7, ARG8) \
1149 : builtin_types[(int) ENUM] \
1150 : = build_function_type_list (builtin_types[(int) RETURN], \
1151 : builtin_types[(int) ARG1], \
1152 : builtin_types[(int) ARG2], \
1153 : builtin_types[(int) ARG3], \
1154 : builtin_types[(int) ARG4], \
1155 : builtin_types[(int) ARG5], \
1156 : builtin_types[(int) ARG6], \
1157 : builtin_types[(int) ARG7], \
1158 : builtin_types[(int) ARG8], \
1159 : NULL_TREE);
1160 : #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1161 : ARG6, ARG7, ARG8, ARG9) \
1162 : builtin_types[(int) ENUM] \
1163 : = build_function_type_list (builtin_types[(int) RETURN], \
1164 : builtin_types[(int) ARG1], \
1165 : builtin_types[(int) ARG2], \
1166 : builtin_types[(int) ARG3], \
1167 : builtin_types[(int) ARG4], \
1168 : builtin_types[(int) ARG5], \
1169 : builtin_types[(int) ARG6], \
1170 : builtin_types[(int) ARG7], \
1171 : builtin_types[(int) ARG8], \
1172 : builtin_types[(int) ARG9], \
1173 : NULL_TREE);
1174 : #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, \
1175 : ARG5, ARG6, ARG7, ARG8, ARG9, ARG10) \
1176 : builtin_types[(int) ENUM] \
1177 : = build_function_type_list (builtin_types[(int) RETURN], \
1178 : builtin_types[(int) ARG1], \
1179 : builtin_types[(int) ARG2], \
1180 : builtin_types[(int) ARG3], \
1181 : builtin_types[(int) ARG4], \
1182 : builtin_types[(int) ARG5], \
1183 : builtin_types[(int) ARG6], \
1184 : builtin_types[(int) ARG7], \
1185 : builtin_types[(int) ARG8], \
1186 : builtin_types[(int) ARG9], \
1187 : builtin_types[(int) ARG10], \
1188 : NULL_TREE);
1189 : #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, \
1190 : ARG5, ARG6, ARG7, ARG8, ARG9, ARG10, ARG11)\
1191 : builtin_types[(int) ENUM] \
1192 : = build_function_type_list (builtin_types[(int) RETURN], \
1193 : builtin_types[(int) ARG1], \
1194 : builtin_types[(int) ARG2], \
1195 : builtin_types[(int) ARG3], \
1196 : builtin_types[(int) ARG4], \
1197 : builtin_types[(int) ARG5], \
1198 : builtin_types[(int) ARG6], \
1199 : builtin_types[(int) ARG7], \
1200 : builtin_types[(int) ARG8], \
1201 : builtin_types[(int) ARG9], \
1202 : builtin_types[(int) ARG10], \
1203 : builtin_types[(int) ARG11], \
1204 : NULL_TREE);
1205 : #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
1206 : builtin_types[(int) ENUM] \
1207 : = build_varargs_function_type_list (builtin_types[(int) RETURN], \
1208 : NULL_TREE);
1209 : #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
1210 : builtin_types[(int) ENUM] \
1211 : = build_varargs_function_type_list (builtin_types[(int) RETURN], \
1212 : builtin_types[(int) ARG1], \
1213 : NULL_TREE);
1214 : #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
1215 : builtin_types[(int) ENUM] \
1216 : = build_varargs_function_type_list (builtin_types[(int) RETURN], \
1217 : builtin_types[(int) ARG1], \
1218 : builtin_types[(int) ARG2], \
1219 : NULL_TREE);
1220 : #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1221 : ARG6) \
1222 : builtin_types[(int) ENUM] \
1223 : = build_varargs_function_type_list (builtin_types[(int) RETURN], \
1224 : builtin_types[(int) ARG1], \
1225 : builtin_types[(int) ARG2], \
1226 : builtin_types[(int) ARG3], \
1227 : builtin_types[(int) ARG4], \
1228 : builtin_types[(int) ARG5], \
1229 : builtin_types[(int) ARG6], \
1230 : NULL_TREE);
1231 : #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
1232 : ARG6, ARG7) \
1233 : builtin_types[(int) ENUM] \
1234 : = build_varargs_function_type_list (builtin_types[(int) RETURN], \
1235 : builtin_types[(int) ARG1], \
1236 : builtin_types[(int) ARG2], \
1237 : builtin_types[(int) ARG3], \
1238 : builtin_types[(int) ARG4], \
1239 : builtin_types[(int) ARG5], \
1240 : builtin_types[(int) ARG6], \
1241 : builtin_types[(int) ARG7], \
1242 : NULL_TREE);
1243 : #define DEF_POINTER_TYPE(ENUM, TYPE) \
1244 : builtin_types[(int) ENUM] \
1245 : = build_pointer_type (builtin_types[(int) TYPE]);
1246 : #include "types.def"
1247 : #undef DEF_PRIMITIVE_TYPE
1248 : #undef DEF_FUNCTION_TYPE_0
1249 : #undef DEF_FUNCTION_TYPE_1
1250 : #undef DEF_FUNCTION_TYPE_2
1251 : #undef DEF_FUNCTION_TYPE_3
1252 : #undef DEF_FUNCTION_TYPE_4
1253 : #undef DEF_FUNCTION_TYPE_5
1254 : #undef DEF_FUNCTION_TYPE_6
1255 : #undef DEF_FUNCTION_TYPE_7
1256 : #undef DEF_FUNCTION_TYPE_8
1257 : #undef DEF_FUNCTION_TYPE_10
1258 : #undef DEF_FUNCTION_TYPE_VAR_0
1259 : #undef DEF_FUNCTION_TYPE_VAR_1
1260 : #undef DEF_FUNCTION_TYPE_VAR_2
1261 : #undef DEF_FUNCTION_TYPE_VAR_6
1262 : #undef DEF_FUNCTION_TYPE_VAR_7
1263 : #undef DEF_POINTER_TYPE
1264 31766 : builtin_types[(int) BT_LAST] = NULL_TREE;
1265 :
1266 : /* Initialize synchronization builtins. */
1267 : #undef DEF_SYNC_BUILTIN
1268 : #define DEF_SYNC_BUILTIN(code, name, type, attr) \
1269 : gfc_define_builtin (name, builtin_types[type], code, name, \
1270 : attr);
1271 : #include "../sync-builtins.def"
1272 : #undef DEF_SYNC_BUILTIN
1273 :
1274 31766 : if (flag_openacc)
1275 : {
1276 : #undef DEF_GOACC_BUILTIN
1277 : #define DEF_GOACC_BUILTIN(code, name, type, attr) \
1278 : gfc_define_builtin ("__builtin_" name, builtin_types[type], \
1279 : code, name, attr);
1280 : #undef DEF_GOACC_BUILTIN_COMPILER
1281 : #define DEF_GOACC_BUILTIN_COMPILER(code, name, type, attr) \
1282 : gfc_define_builtin (name, builtin_types[type], code, name, attr);
1283 : #undef DEF_GOACC_BUILTIN_ONLY
1284 : #define DEF_GOACC_BUILTIN_ONLY(code, name, type, attr) \
1285 : gfc_define_builtin ("__builtin_" name, builtin_types[type], code, NULL, \
1286 : attr);
1287 : #undef DEF_GOMP_BUILTIN
1288 : #define DEF_GOMP_BUILTIN(code, name, type, attr) /* ignore */
1289 : #undef DEF_GOMP_BUILTIN_COMPILER
1290 : #define DEF_GOMP_BUILTIN_COMPILER(code, name, type, attr) /* ignore */
1291 : #include "../omp-builtins.def"
1292 : #undef DEF_GOACC_BUILTIN
1293 : #undef DEF_GOACC_BUILTIN_COMPILER
1294 : #undef DEF_GOMP_BUILTIN
1295 : #undef DEF_GOMP_BUILTIN_COMPILER
1296 : }
1297 :
1298 31766 : if (flag_openmp || flag_openmp_simd || flag_tree_parallelize_loops)
1299 : {
1300 : #undef DEF_GOACC_BUILTIN
1301 : #define DEF_GOACC_BUILTIN(code, name, type, attr) /* ignore */
1302 : #undef DEF_GOACC_BUILTIN_COMPILER
1303 : #define DEF_GOACC_BUILTIN_COMPILER(code, name, type, attr) /* ignore */
1304 : #undef DEF_GOMP_BUILTIN
1305 : #define DEF_GOMP_BUILTIN(code, name, type, attr) \
1306 : gfc_define_builtin ("__builtin_" name, builtin_types[type], \
1307 : code, name, attr);
1308 : #undef DEF_GOMP_BUILTIN_COMPILER
1309 : #define DEF_GOMP_BUILTIN_COMPILER(code, name, type, attr) \
1310 : if (flag_openmp) \
1311 : gfc_define_builtin ("__builtin_" name, builtin_types[type], \
1312 : code, name, attr);
1313 : #include "../omp-builtins.def"
1314 : #undef DEF_GOACC_BUILTIN
1315 : #undef DEF_GOACC_BUILTIN_COMPILER
1316 : #undef DEF_GOMP_BUILTIN
1317 : #undef DEF_GOMP_BUILTIN_COMPILER
1318 31766 : tree gomp_alloc = builtin_decl_explicit (BUILT_IN_GOMP_ALLOC);
1319 31766 : tree two = build_int_cst (integer_type_node, 2);
1320 31766 : DECL_ATTRIBUTES (gomp_alloc)
1321 63532 : = tree_cons (get_identifier ("warn_unused_result"), NULL_TREE,
1322 : tree_cons (get_identifier ("alloc_size"),
1323 : build_tree_list (NULL_TREE, two),
1324 31766 : DECL_ATTRIBUTES (gomp_alloc)));
1325 : }
1326 :
1327 31766 : gfc_define_builtin ("__builtin_trap", builtin_types[BT_FN_VOID],
1328 : BUILT_IN_TRAP, NULL, ATTR_NOTHROW_LEAF_LIST);
1329 31766 : TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1;
1330 :
1331 31766 : ftype = build_varargs_function_type_list (ptr_type_node, const_ptr_type_node,
1332 : size_type_node, NULL_TREE);
1333 31766 : gfc_define_builtin ("__builtin_assume_aligned", ftype,
1334 : BUILT_IN_ASSUME_ALIGNED,
1335 : "__builtin_assume_aligned",
1336 : ATTR_CONST_NOTHROW_LEAF_LIST);
1337 :
1338 31766 : ftype = build_function_type_list (long_double_type_node, long_double_type_node,
1339 : long_double_type_node, long_double_type_node,
1340 : NULL_TREE);
1341 31766 : gfc_define_builtin ("__builtin_fmal", ftype, BUILT_IN_FMAL,
1342 : "fmal", ATTR_CONST_NOTHROW_LEAF_LIST);
1343 31766 : ftype = build_function_type_list (double_type_node, double_type_node,
1344 : double_type_node, double_type_node,
1345 : NULL_TREE);
1346 31766 : gfc_define_builtin ("__builtin_fma", ftype, BUILT_IN_FMA,
1347 : "fma", ATTR_CONST_NOTHROW_LEAF_LIST);
1348 31766 : ftype = build_function_type_list (float_type_node, float_type_node,
1349 : float_type_node, float_type_node,
1350 : NULL_TREE);
1351 31766 : gfc_define_builtin ("__builtin_fmaf", ftype, BUILT_IN_FMAF,
1352 : "fmaf", ATTR_CONST_NOTHROW_LEAF_LIST);
1353 :
1354 31766 : gfc_define_builtin ("__emutls_get_address",
1355 : builtin_types[BT_FN_PTR_PTR],
1356 : BUILT_IN_EMUTLS_GET_ADDRESS,
1357 : "__emutls_get_address", ATTR_CONST_NOTHROW_LEAF_LIST);
1358 31766 : gfc_define_builtin ("__emutls_register_common",
1359 : builtin_types[BT_FN_VOID_PTR_WORD_WORD_PTR],
1360 : BUILT_IN_EMUTLS_REGISTER_COMMON,
1361 : "__emutls_register_common", ATTR_NOTHROW_LEAF_LIST);
1362 :
1363 31766 : build_common_builtin_nodes ();
1364 31766 : targetm.init_builtins ();
1365 31766 : }
1366 :
1367 : #undef DEFINE_MATH_BUILTIN_C
1368 : #undef DEFINE_MATH_BUILTIN
1369 :
1370 : static void
1371 31784 : gfc_init_ts (void)
1372 : {
1373 31784 : tree_contains_struct[NAMESPACE_DECL][TS_DECL_NON_COMMON] = 1;
1374 31784 : tree_contains_struct[NAMESPACE_DECL][TS_DECL_WITH_VIS] = 1;
1375 31784 : tree_contains_struct[NAMESPACE_DECL][TS_DECL_WRTL] = 1;
1376 31784 : tree_contains_struct[NAMESPACE_DECL][TS_DECL_COMMON] = 1;
1377 31784 : tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
1378 31784 : }
1379 :
1380 : void
1381 19015 : gfc_maybe_initialize_eh (void)
1382 : {
1383 19015 : if (!flag_exceptions || gfc_eh_initialized_p)
1384 : return;
1385 :
1386 9 : gfc_eh_initialized_p = true;
1387 9 : using_eh_for_cleanups ();
1388 : }
1389 :
1390 :
1391 : #include "gt-fortran-f95-lang.h"
1392 : #include "gtype-fortran.h"
|