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