]>
Commit | Line | Data |
---|---|---|
f36327db | 1 | /* gfortran backend interface |
5624e564 | 2 | Copyright (C) 2000-2015 Free Software Foundation, Inc. |
6de9cd9a DN |
3 | Contributed by Paul Brook. |
4 | ||
9fc4d79b | 5 | This file is part of GCC. |
6de9cd9a | 6 | |
9fc4d79b TS |
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 | |
d234d788 | 9 | Software Foundation; either version 3, or (at your option) any later |
9fc4d79b | 10 | version. |
6de9cd9a | 11 | |
9fc4d79b TS |
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. | |
6de9cd9a DN |
16 | |
17 | You should have received a copy of the GNU General Public License | |
d234d788 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
6de9cd9a DN |
20 | |
21 | /* f95-lang.c-- GCC backend interface stuff */ | |
22 | ||
23 | /* declare required prototypes: */ | |
24 | ||
25 | #include "config.h" | |
d22e4895 | 26 | #include "system.h" |
6de9cd9a DN |
27 | #include "ansidecl.h" |
28 | #include "system.h" | |
29 | #include "coretypes.h" | |
8e54f6d3 | 30 | #include "gfortran.h" |
40e23961 MC |
31 | #include "hash-set.h" |
32 | #include "machmode.h" | |
33 | #include "vec.h" | |
34 | #include "double-int.h" | |
35 | #include "input.h" | |
36 | #include "alias.h" | |
37 | #include "symtab.h" | |
38 | #include "options.h" | |
39 | #include "wide-int.h" | |
40 | #include "inchash.h" | |
6de9cd9a | 41 | #include "tree.h" |
6de9cd9a DN |
42 | #include "flags.h" |
43 | #include "langhooks.h" | |
44 | #include "langhooks-def.h" | |
45 | #include "timevar.h" | |
46 | #include "tm.h" | |
83685514 AM |
47 | #include "hard-reg-set.h" |
48 | #include "input.h" | |
6de9cd9a DN |
49 | #include "function.h" |
50 | #include "ggc.h" | |
51 | #include "toplev.h" | |
52 | #include "target.h" | |
53 | #include "debug.h" | |
8e54f6d3 | 54 | #include "diagnostic.h" /* For errorcount/warningcount */ |
7ee2468b | 55 | #include "dumpfile.h" |
c582198b AM |
56 | #include "hash-map.h" |
57 | #include "is-a.h" | |
58 | #include "plugin-api.h" | |
59 | #include "ipa-ref.h" | |
6de9cd9a | 60 | #include "cgraph.h" |
670637ee | 61 | #include "cpp.h" |
6de9cd9a DN |
62 | #include "trans.h" |
63 | #include "trans-types.h" | |
64 | #include "trans-const.h" | |
65 | ||
6de9cd9a DN |
66 | /* Language-dependent contents of an identifier. */ |
67 | ||
d1b38208 TG |
68 | struct GTY(()) |
69 | lang_identifier { | |
6de9cd9a DN |
70 | struct tree_identifier common; |
71 | }; | |
72 | ||
73 | /* The resulting tree type. */ | |
74 | ||
d1b38208 | 75 | union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), |
81f653d6 | 76 | chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) |
d1b38208 | 77 | lang_tree_node { |
6de9cd9a DN |
78 | union tree_node GTY((tag ("0"), |
79 | desc ("tree_node_structure (&%h)"))) generic; | |
80 | struct lang_identifier GTY((tag ("1"))) identifier; | |
81 | }; | |
82 | ||
83 | /* Save and restore the variables in this file and elsewhere | |
84 | that keep track of the progress of compilation of the current function. | |
85 | Used for nested functions. */ | |
86 | ||
d1b38208 TG |
87 | struct GTY(()) |
88 | language_function { | |
6de9cd9a | 89 | /* struct gfc_language_function base; */ |
6de9cd9a DN |
90 | struct binding_level *binding_level; |
91 | }; | |
92 | ||
6de9cd9a DN |
93 | static void gfc_init_decl_processing (void); |
94 | static void gfc_init_builtin_functions (void); | |
87a60f68 | 95 | static bool global_bindings_p (void); |
6de9cd9a DN |
96 | |
97 | /* Each front end provides its own. */ | |
98 | static bool gfc_init (void); | |
99 | static void gfc_finish (void); | |
8b84c596 | 100 | static void gfc_write_global_declarations (void); |
b37421c6 | 101 | static void gfc_be_parse_file (void); |
4862826d | 102 | static alias_set_type gfc_get_alias_set (tree); |
a64f5186 | 103 | static void gfc_init_ts (void); |
87a60f68 | 104 | static tree gfc_builtin_function (tree); |
6de9cd9a | 105 | |
f014c653 JJ |
106 | /* Handle an "omp declare target" attribute; arguments as in |
107 | struct attribute_spec.handler. */ | |
108 | static tree | |
109 | gfc_handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *) | |
110 | { | |
111 | return NULL_TREE; | |
112 | } | |
113 | ||
114 | /* Table of valid Fortran attributes. */ | |
115 | static const struct attribute_spec gfc_attribute_table[] = | |
116 | { | |
117 | /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler, | |
118 | affects_type_identity } */ | |
119 | { "omp declare target", 0, 0, true, false, false, | |
120 | gfc_handle_omp_declare_target_attribute, false }, | |
121 | { NULL, 0, 0, false, false, false, NULL, false } | |
122 | }; | |
123 | ||
6de9cd9a DN |
124 | #undef LANG_HOOKS_NAME |
125 | #undef LANG_HOOKS_INIT | |
126 | #undef LANG_HOOKS_FINISH | |
8b84c596 | 127 | #undef LANG_HOOKS_WRITE_GLOBALS |
7a9bf9a4 | 128 | #undef LANG_HOOKS_OPTION_LANG_MASK |
a75bfaa6 | 129 | #undef LANG_HOOKS_INIT_OPTIONS_STRUCT |
6de9cd9a DN |
130 | #undef LANG_HOOKS_INIT_OPTIONS |
131 | #undef LANG_HOOKS_HANDLE_OPTION | |
132 | #undef LANG_HOOKS_POST_OPTIONS | |
6de9cd9a | 133 | #undef LANG_HOOKS_PARSE_FILE |
6de9cd9a DN |
134 | #undef LANG_HOOKS_MARK_ADDRESSABLE |
135 | #undef LANG_HOOKS_TYPE_FOR_MODE | |
136 | #undef LANG_HOOKS_TYPE_FOR_SIZE | |
7b9c708f | 137 | #undef LANG_HOOKS_GET_ALIAS_SET |
a64f5186 | 138 | #undef LANG_HOOKS_INIT_TS |
6c7a4dfd JJ |
139 | #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE |
140 | #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING | |
79943d19 | 141 | #undef LANG_HOOKS_OMP_REPORT_DECL |
cd75853e | 142 | #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR |
a68ab351 JJ |
143 | #undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR |
144 | #undef LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP | |
da6f124d | 145 | #undef LANG_HOOKS_OMP_CLAUSE_LINEAR_CTOR |
a68ab351 | 146 | #undef LANG_HOOKS_OMP_CLAUSE_DTOR |
f014c653 | 147 | #undef LANG_HOOKS_OMP_FINISH_CLAUSE |
6c7a4dfd JJ |
148 | #undef LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR |
149 | #undef LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE | |
a68ab351 | 150 | #undef LANG_HOOKS_OMP_PRIVATE_OUTER_REF |
6c7a4dfd | 151 | #undef LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES |
c79efc4d | 152 | #undef LANG_HOOKS_BUILTIN_FUNCTION |
87a60f68 | 153 | #undef LANG_HOOKS_BUILTIN_FUNCTION |
fad0afd7 | 154 | #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO |
f014c653 | 155 | #undef LANG_HOOKS_ATTRIBUTE_TABLE |
6de9cd9a DN |
156 | |
157 | /* Define lang hooks. */ | |
3135ce84 | 158 | #define LANG_HOOKS_NAME "GNU Fortran" |
6de9cd9a DN |
159 | #define LANG_HOOKS_INIT gfc_init |
160 | #define LANG_HOOKS_FINISH gfc_finish | |
8b84c596 | 161 | #define LANG_HOOKS_WRITE_GLOBALS gfc_write_global_declarations |
7a9bf9a4 | 162 | #define LANG_HOOKS_OPTION_LANG_MASK gfc_option_lang_mask |
a75bfaa6 | 163 | #define LANG_HOOKS_INIT_OPTIONS_STRUCT gfc_init_options_struct |
6de9cd9a DN |
164 | #define LANG_HOOKS_INIT_OPTIONS gfc_init_options |
165 | #define LANG_HOOKS_HANDLE_OPTION gfc_handle_option | |
166 | #define LANG_HOOKS_POST_OPTIONS gfc_post_options | |
6de9cd9a | 167 | #define LANG_HOOKS_PARSE_FILE gfc_be_parse_file |
a64f5186 JJ |
168 | #define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode |
169 | #define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size | |
170 | #define LANG_HOOKS_GET_ALIAS_SET gfc_get_alias_set | |
171 | #define LANG_HOOKS_INIT_TS gfc_init_ts | |
6c7a4dfd JJ |
172 | #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference |
173 | #define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing | |
79943d19 | 174 | #define LANG_HOOKS_OMP_REPORT_DECL gfc_omp_report_decl |
cd75853e | 175 | #define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR gfc_omp_clause_default_ctor |
a68ab351 JJ |
176 | #define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR gfc_omp_clause_copy_ctor |
177 | #define LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP gfc_omp_clause_assign_op | |
da6f124d | 178 | #define LANG_HOOKS_OMP_CLAUSE_LINEAR_CTOR gfc_omp_clause_linear_ctor |
a68ab351 | 179 | #define LANG_HOOKS_OMP_CLAUSE_DTOR gfc_omp_clause_dtor |
f014c653 | 180 | #define LANG_HOOKS_OMP_FINISH_CLAUSE gfc_omp_finish_clause |
6c7a4dfd JJ |
181 | #define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR gfc_omp_disregard_value_expr |
182 | #define LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE gfc_omp_private_debug_clause | |
a68ab351 | 183 | #define LANG_HOOKS_OMP_PRIVATE_OUTER_REF gfc_omp_private_outer_ref |
6c7a4dfd JJ |
184 | #define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \ |
185 | gfc_omp_firstprivatize_type_sizes | |
f014c653 JJ |
186 | #define LANG_HOOKS_BUILTIN_FUNCTION gfc_builtin_function |
187 | #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gfc_get_array_descr_info | |
188 | #define LANG_HOOKS_ATTRIBUTE_TABLE gfc_attribute_table | |
6de9cd9a | 189 | |
4537ec0c | 190 | struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; |
6de9cd9a | 191 | |
6de9cd9a DN |
192 | #define NULL_BINDING_LEVEL (struct binding_level *) NULL |
193 | ||
194 | /* A chain of binding_level structures awaiting reuse. */ | |
195 | ||
196 | static GTY(()) struct binding_level *free_binding_level; | |
197 | ||
602b8523 | 198 | /* True means we've initialized exception handling. */ |
87a60f68 | 199 | static bool gfc_eh_initialized_p; |
602b8523 | 200 | |
e5b16755 RG |
201 | /* The current translation unit. */ |
202 | static GTY(()) tree current_translation_unit; | |
203 | ||
602b8523 | 204 | |
6de9cd9a DN |
205 | static void |
206 | gfc_create_decls (void) | |
207 | { | |
208 | /* GCC builtins. */ | |
209 | gfc_init_builtin_functions (); | |
210 | ||
211 | /* Runtime/IO library functions. */ | |
212 | gfc_build_builtin_function_decls (); | |
213 | ||
214 | gfc_init_constants (); | |
e5b16755 RG |
215 | |
216 | /* Build our translation-unit decl. */ | |
217 | current_translation_unit = build_translation_unit_decl (NULL_TREE); | |
6de9cd9a DN |
218 | } |
219 | ||
b251af97 | 220 | |
6de9cd9a | 221 | static void |
b37421c6 | 222 | gfc_be_parse_file (void) |
6de9cd9a DN |
223 | { |
224 | int errors; | |
225 | int warnings; | |
226 | ||
227 | gfc_create_decls (); | |
228 | gfc_parse_file (); | |
229 | gfc_generate_constructors (); | |
230 | ||
df2fba9e | 231 | /* Tell the frontend about any errors. */ |
6de9cd9a DN |
232 | gfc_get_errors (&warnings, &errors); |
233 | errorcount += errors; | |
234 | warningcount += warnings; | |
30e257e5 | 235 | |
87a60f68 SB |
236 | /* Clear the binding level stack. */ |
237 | while (!global_bindings_p ()) | |
238 | poplevel (0, 0); | |
3aa34c1d MLI |
239 | |
240 | /* Switch to the default tree diagnostics here, because there may be | |
241 | diagnostics before gfc_finish(). */ | |
242 | gfc_diagnostics_finish (); | |
6de9cd9a | 243 | } |
b251af97 SK |
244 | |
245 | ||
6de9cd9a DN |
246 | /* Initialize everything. */ |
247 | ||
248 | static bool | |
249 | gfc_init (void) | |
250 | { | |
670637ee DF |
251 | if (!gfc_cpp_enabled ()) |
252 | { | |
253 | linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1); | |
254 | linemap_add (line_table, LC_RENAME, false, "<built-in>", 0); | |
255 | } | |
256 | else | |
257 | gfc_cpp_init_0 (); | |
c8cc8542 | 258 | |
6de9cd9a DN |
259 | gfc_init_decl_processing (); |
260 | gfc_static_ctors = NULL_TREE; | |
261 | ||
670637ee DF |
262 | if (gfc_cpp_enabled ()) |
263 | gfc_cpp_init (); | |
264 | ||
6de9cd9a DN |
265 | gfc_init_1 (); |
266 | ||
524af0d6 | 267 | if (!gfc_new_file ()) |
e0bcf78c | 268 | fatal_error ("can't open input file: %s", gfc_source_file); |
670637ee | 269 | |
566916e6 TB |
270 | if (flag_preprocess_only) |
271 | return false; | |
272 | ||
6de9cd9a DN |
273 | return true; |
274 | } | |
275 | ||
276 | ||
277 | static void | |
278 | gfc_finish (void) | |
279 | { | |
670637ee | 280 | gfc_cpp_done (); |
6de9cd9a DN |
281 | gfc_done_1 (); |
282 | gfc_release_include_path (); | |
283 | return; | |
284 | } | |
285 | ||
8b84c596 RH |
286 | /* ??? This is something of a hack. |
287 | ||
288 | Emulated tls lowering needs to see all TLS variables before we call | |
65d630d4 | 289 | finalize_compilation_unit. The C/C++ front ends manage this |
8b84c596 RH |
290 | by calling decl_rest_of_compilation on each global and static variable |
291 | as they are seen. The Fortran front end waits until this hook. | |
292 | ||
65d630d4 | 293 | A Correct solution is for finalize_compilation_unit not to be |
8b84c596 RH |
294 | called during the WRITE_GLOBALS langhook, and have that hook only do what |
295 | its name suggests and write out globals. But the C++ and Java front ends | |
296 | have (unspecified) problems with aliases that gets in the way. It has | |
297 | been suggested that these problems would be solved by completing the | |
298 | conversion to cgraph-based aliases. */ | |
299 | ||
300 | static void | |
301 | gfc_write_global_declarations (void) | |
302 | { | |
303 | tree decl; | |
304 | ||
305 | /* Finalize all of the globals. */ | |
306 | for (decl = getdecls(); decl ; decl = DECL_CHAIN (decl)) | |
307 | rest_of_decl_compilation (decl, true, true); | |
308 | ||
309 | write_global_declarations (); | |
310 | } | |
311 | ||
6de9cd9a DN |
312 | /* These functions and variables deal with binding contours. We only |
313 | need these functions for the list of PARM_DECLs, but we leave the | |
314 | functions more general; these are a simplified version of the | |
315 | functions from GNAT. */ | |
316 | ||
b251af97 SK |
317 | /* For each binding contour we allocate a binding_level structure which |
318 | records the entities defined or declared in that contour. Contours | |
319 | include: | |
6de9cd9a DN |
320 | |
321 | the global one | |
322 | one for each subprogram definition | |
323 | one for each compound statement (declare block) | |
324 | ||
325 | Binding contours are used to create GCC tree BLOCK nodes. */ | |
326 | ||
d1b38208 TG |
327 | struct GTY(()) |
328 | binding_level { | |
6de9cd9a DN |
329 | /* A chain of ..._DECL nodes for all variables, constants, functions, |
330 | parameters and type declarations. These ..._DECL nodes are chained | |
87a60f68 | 331 | through the DECL_CHAIN field. */ |
6de9cd9a DN |
332 | tree names; |
333 | /* For each level (except the global one), a chain of BLOCK nodes for all | |
334 | the levels that were entered and exited one level down from this one. */ | |
335 | tree blocks; | |
f7b529fa | 336 | /* The binding level containing this one (the enclosing binding level). */ |
6de9cd9a DN |
337 | struct binding_level *level_chain; |
338 | }; | |
339 | ||
340 | /* The binding level currently in effect. */ | |
341 | static GTY(()) struct binding_level *current_binding_level = NULL; | |
342 | ||
343 | /* The outermost binding level. This binding level is created when the | |
344 | compiler is started and it will exist through the entire compilation. */ | |
345 | static GTY(()) struct binding_level *global_binding_level; | |
346 | ||
347 | /* Binding level structures are initialized by copying this one. */ | |
9dcf6e73 | 348 | static struct binding_level clear_binding_level = { NULL, NULL, NULL }; |
b251af97 SK |
349 | |
350 | ||
c99c0026 | 351 | /* Return true if we are in the global binding level. */ |
6de9cd9a | 352 | |
c99c0026 | 353 | bool |
6de9cd9a DN |
354 | global_bindings_p (void) |
355 | { | |
c99c0026 | 356 | return current_binding_level == global_binding_level; |
6de9cd9a DN |
357 | } |
358 | ||
359 | tree | |
360 | getdecls (void) | |
361 | { | |
362 | return current_binding_level->names; | |
363 | } | |
364 | ||
1cc0e193 | 365 | /* Enter a new binding level. */ |
6de9cd9a DN |
366 | |
367 | void | |
87a60f68 | 368 | pushlevel (void) |
6de9cd9a | 369 | { |
766090c2 | 370 | struct binding_level *newlevel = ggc_alloc<binding_level> (); |
6de9cd9a DN |
371 | |
372 | *newlevel = clear_binding_level; | |
373 | ||
374 | /* Add this level to the front of the chain (stack) of levels that are | |
375 | active. */ | |
376 | newlevel->level_chain = current_binding_level; | |
377 | current_binding_level = newlevel; | |
378 | } | |
379 | ||
380 | /* Exit a binding level. | |
381 | Pop the level off, and restore the state of the identifier-decl mappings | |
382 | that were in effect when this level was entered. | |
383 | ||
384 | If KEEP is nonzero, this level had explicit declarations, so | |
385 | and create a "block" (a BLOCK node) for the level | |
386 | to record its declarations and subblocks for symbol table output. | |
387 | ||
388 | If FUNCTIONBODY is nonzero, this level is the body of a function, | |
389 | so create a block as if KEEP were set and also clear out all | |
87a60f68 | 390 | label names. */ |
6de9cd9a DN |
391 | |
392 | tree | |
87a60f68 | 393 | poplevel (int keep, int functionbody) |
6de9cd9a | 394 | { |
1f2959f0 | 395 | /* Points to a BLOCK tree node. This is the BLOCK node constructed for the |
6de9cd9a DN |
396 | binding level that we are about to exit and which is returned by this |
397 | routine. */ | |
398 | tree block_node = NULL_TREE; | |
87a60f68 | 399 | tree decl_chain = current_binding_level->names; |
6de9cd9a DN |
400 | tree subblock_chain = current_binding_level->blocks; |
401 | tree subblock_node; | |
6de9cd9a | 402 | |
6de9cd9a DN |
403 | /* If there were any declarations in the current binding level, or if this |
404 | binding level is a function body, or if there are any nested blocks then | |
405 | create a BLOCK node to record them for the life of this function. */ | |
9dcf6e73 | 406 | if (keep || functionbody) |
22e8617b | 407 | block_node = build_block (keep ? decl_chain : 0, subblock_chain, 0, 0); |
6de9cd9a DN |
408 | |
409 | /* Record the BLOCK node just built as the subblock its enclosing scope. */ | |
410 | for (subblock_node = subblock_chain; subblock_node; | |
61e46a7d | 411 | subblock_node = BLOCK_CHAIN (subblock_node)) |
6de9cd9a DN |
412 | BLOCK_SUPERCONTEXT (subblock_node) = block_node; |
413 | ||
414 | /* Clear out the meanings of the local variables of this level. */ | |
415 | ||
416 | for (subblock_node = decl_chain; subblock_node; | |
910ad8de | 417 | subblock_node = DECL_CHAIN (subblock_node)) |
6de9cd9a DN |
418 | if (DECL_NAME (subblock_node) != 0) |
419 | /* If the identifier was used or addressed via a local extern decl, | |
f7b529fa | 420 | don't forget that fact. */ |
6de9cd9a DN |
421 | if (DECL_EXTERNAL (subblock_node)) |
422 | { | |
423 | if (TREE_USED (subblock_node)) | |
424 | TREE_USED (DECL_NAME (subblock_node)) = 1; | |
425 | if (TREE_ADDRESSABLE (subblock_node)) | |
426 | TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (subblock_node)) = 1; | |
427 | } | |
428 | ||
429 | /* Pop the current level. */ | |
430 | current_binding_level = current_binding_level->level_chain; | |
431 | ||
432 | if (functionbody) | |
1cc0e193 | 433 | /* This is the top level block of a function. */ |
c7c79a09 | 434 | DECL_INITIAL (current_function_decl) = block_node; |
77092cda JJ |
435 | else if (current_binding_level == global_binding_level) |
436 | /* When using gfc_start_block/gfc_finish_block from middle-end hooks, | |
df2fba9e | 437 | don't add newly created BLOCKs as subblocks of global_binding_level. */ |
77092cda | 438 | ; |
6de9cd9a DN |
439 | else if (block_node) |
440 | { | |
9dcf6e73 | 441 | current_binding_level->blocks |
61e46a7d | 442 | = block_chainon (current_binding_level->blocks, block_node); |
6de9cd9a DN |
443 | } |
444 | ||
445 | /* If we did not make a block for the level just exited, any blocks made for | |
446 | inner levels (since they cannot be recorded as subblocks in that level) | |
447 | must be carried forward so they will later become subblocks of something | |
448 | else. */ | |
449 | else if (subblock_chain) | |
450 | current_binding_level->blocks | |
61e46a7d | 451 | = block_chainon (current_binding_level->blocks, subblock_chain); |
6de9cd9a DN |
452 | if (block_node) |
453 | TREE_USED (block_node) = 1; | |
454 | ||
455 | return block_node; | |
456 | } | |
b251af97 SK |
457 | |
458 | ||
6de9cd9a | 459 | /* Records a ..._DECL node DECL as belonging to the current lexical scope. |
f7b529fa | 460 | Returns the ..._DECL node. */ |
6de9cd9a DN |
461 | |
462 | tree | |
463 | pushdecl (tree decl) | |
464 | { | |
5b1cce91 | 465 | if (global_bindings_p ()) |
e5b16755 | 466 | DECL_CONTEXT (decl) = current_translation_unit; |
6de9cd9a | 467 | else |
5b1cce91 RG |
468 | { |
469 | /* External objects aren't nested. For debug info insert a copy | |
470 | of the decl into the binding level. */ | |
471 | if (DECL_EXTERNAL (decl)) | |
472 | { | |
473 | tree orig = decl; | |
474 | decl = copy_node (decl); | |
475 | DECL_CONTEXT (orig) = NULL_TREE; | |
476 | } | |
477 | DECL_CONTEXT (decl) = current_function_decl; | |
478 | } | |
6de9cd9a | 479 | |
87a60f68 | 480 | /* Put the declaration on the list. */ |
910ad8de | 481 | DECL_CHAIN (decl) = current_binding_level->names; |
6de9cd9a DN |
482 | current_binding_level->names = decl; |
483 | ||
69de3b83 | 484 | /* For the declaration of a type, set its name if it is not already set. */ |
6de9cd9a DN |
485 | |
486 | if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0) | |
487 | { | |
488 | if (DECL_SOURCE_LINE (decl) == 0) | |
489 | TYPE_NAME (TREE_TYPE (decl)) = decl; | |
490 | else | |
491 | TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl); | |
492 | } | |
493 | ||
494 | return decl; | |
495 | } | |
496 | ||
497 | ||
498 | /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL. */ | |
499 | ||
500 | tree | |
501 | pushdecl_top_level (tree x) | |
502 | { | |
503 | tree t; | |
504 | struct binding_level *b = current_binding_level; | |
505 | ||
506 | current_binding_level = global_binding_level; | |
507 | t = pushdecl (x); | |
508 | current_binding_level = b; | |
509 | return t; | |
510 | } | |
511 | ||
6de9cd9a DN |
512 | #ifndef CHAR_TYPE_SIZE |
513 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
514 | #endif | |
515 | ||
516 | #ifndef INT_TYPE_SIZE | |
517 | #define INT_TYPE_SIZE BITS_PER_WORD | |
518 | #endif | |
519 | ||
520 | #undef SIZE_TYPE | |
521 | #define SIZE_TYPE "long unsigned int" | |
522 | ||
523 | /* Create tree nodes for the basic scalar types of Fortran 95, | |
524 | and some nodes representing standard constants (0, 1, (void *) 0). | |
525 | Initialize the global binding level. | |
526 | Make definitions for built-in primitive functions. */ | |
527 | static void | |
528 | gfc_init_decl_processing (void) | |
529 | { | |
530 | current_function_decl = NULL; | |
6de9cd9a DN |
531 | current_binding_level = NULL_BINDING_LEVEL; |
532 | free_binding_level = NULL_BINDING_LEVEL; | |
533 | ||
534 | /* Make the binding_level structure for global names. We move all | |
535 | variables that are in a COMMON block to this binding level. */ | |
87a60f68 | 536 | pushlevel (); |
6de9cd9a DN |
537 | global_binding_level = current_binding_level; |
538 | ||
539 | /* Build common tree nodes. char_type_node is unsigned because we | |
540 | only use it for actual characters, not for INTEGER(1). Also, we | |
f7b529fa | 541 | want double_type_node to actually have double precision. */ |
1a072294 | 542 | build_common_tree_nodes (false, false); |
c1775967 | 543 | |
24cc1193 | 544 | void_list_node = build_tree_list (NULL_TREE, void_type_node); |
6de9cd9a DN |
545 | |
546 | /* Set up F95 type nodes. */ | |
5e8e542f | 547 | gfc_init_kinds (); |
6de9cd9a | 548 | gfc_init_types (); |
28d0b595 | 549 | gfc_init_c_interop_kinds (); |
6de9cd9a DN |
550 | } |
551 | ||
b251af97 | 552 | |
7b9c708f JJ |
553 | /* Return the typed-based alias set for T, which may be an expression |
554 | or a type. Return -1 if we don't do anything special. */ | |
555 | ||
4862826d | 556 | static alias_set_type |
7b9c708f JJ |
557 | gfc_get_alias_set (tree t) |
558 | { | |
559 | tree u; | |
560 | ||
561 | /* Permit type-punning when accessing an EQUIVALENCEd variable or | |
562 | mixed type entry master's return value. */ | |
563 | for (u = t; handled_component_p (u); u = TREE_OPERAND (u, 0)) | |
564 | if (TREE_CODE (u) == COMPONENT_REF | |
565 | && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE) | |
566 | return 0; | |
567 | ||
568 | return -1; | |
569 | } | |
570 | ||
1f2959f0 | 571 | /* Builtin function initialization. */ |
6de9cd9a | 572 | |
87a60f68 | 573 | static tree |
c79efc4d | 574 | gfc_builtin_function (tree decl) |
6de9cd9a | 575 | { |
6de9cd9a | 576 | pushdecl (decl); |
6de9cd9a DN |
577 | return decl; |
578 | } | |
579 | ||
5325296e | 580 | /* So far we need just these 7 attribute types. */ |
acf0174b | 581 | #define ATTR_NULL 0 |
5325296e | 582 | #define ATTR_LEAF_LIST (ECF_LEAF) |
d724c876 | 583 | #define ATTR_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF) |
46de9f5e | 584 | #define ATTR_NOTHROW_LEAF_MALLOC_LIST (ECF_NOTHROW | ECF_LEAF | ECF_MALLOC) |
d724c876 | 585 | #define ATTR_CONST_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_CONST) |
3b7ea188 | 586 | #define ATTR_PURE_NOTHROW_LEAF_LIST (ECF_NOTHROW | ECF_LEAF | ECF_PURE) |
d724c876 JJ |
587 | #define ATTR_NOTHROW_LIST (ECF_NOTHROW) |
588 | #define ATTR_CONST_NOTHROW_LIST (ECF_NOTHROW | ECF_CONST) | |
6de9cd9a DN |
589 | |
590 | static void | |
e79983f4 | 591 | gfc_define_builtin (const char *name, tree type, enum built_in_function code, |
d724c876 | 592 | const char *library_name, int attr) |
6de9cd9a DN |
593 | { |
594 | tree decl; | |
595 | ||
c79efc4d RÁE |
596 | decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL, |
597 | library_name, NULL_TREE); | |
46de9f5e | 598 | set_call_expr_flags (decl, attr); |
6de9cd9a | 599 | |
e79983f4 | 600 | set_builtin_decl (code, decl, true); |
6de9cd9a DN |
601 | } |
602 | ||
603 | ||
e8525382 | 604 | #define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \ |
644cb69f | 605 | gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \ |
d724c876 JJ |
606 | BUILT_IN_ ## code ## L, name "l", \ |
607 | ATTR_CONST_NOTHROW_LEAF_LIST); \ | |
e8525382 | 608 | gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \ |
d724c876 JJ |
609 | BUILT_IN_ ## code, name, \ |
610 | ATTR_CONST_NOTHROW_LEAF_LIST); \ | |
e8525382 | 611 | gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \ |
d724c876 JJ |
612 | BUILT_IN_ ## code ## F, name "f", \ |
613 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
6de9cd9a | 614 | |
e8525382 SK |
615 | #define DEFINE_MATH_BUILTIN(code, name, argtype) \ |
616 | DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) | |
617 | ||
e8525382 | 618 | #define DEFINE_MATH_BUILTIN_C(code, name, argtype) \ |
644cb69f FXC |
619 | DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) \ |
620 | DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c) | |
e8525382 SK |
621 | |
622 | ||
623 | /* Create function types for builtin functions. */ | |
624 | ||
625 | static void | |
b251af97 | 626 | build_builtin_fntypes (tree *fntype, tree type) |
e8525382 | 627 | { |
e8525382 | 628 | /* type (*) (type) */ |
b64fca63 | 629 | fntype[0] = build_function_type_list (type, type, NULL_TREE); |
e8525382 | 630 | /* type (*) (type, type) */ |
b64fca63 | 631 | fntype[1] = build_function_type_list (type, type, type, NULL_TREE); |
b5a4419c | 632 | /* type (*) (type, int) */ |
b64fca63 NF |
633 | fntype[2] = build_function_type_list (type, |
634 | type, integer_type_node, NULL_TREE); | |
635 | /* type (*) (void) */ | |
636 | fntype[3] = build_function_type_list (type, NULL_TREE); | |
db7f455b DS |
637 | /* type (*) (type, &int) */ |
638 | fntype[4] = build_function_type_list (type, type, | |
b64fca63 | 639 | build_pointer_type (integer_type_node), |
b64fca63 NF |
640 | NULL_TREE); |
641 | /* type (*) (int, type) */ | |
642 | fntype[5] = build_function_type_list (type, | |
643 | integer_type_node, type, NULL_TREE); | |
e8525382 SK |
644 | } |
645 | ||
b251af97 | 646 | |
6c7a4dfd JJ |
647 | static tree |
648 | builtin_type_for_size (int size, bool unsignedp) | |
649 | { | |
21fa2faf | 650 | tree type = gfc_type_for_size (size, unsignedp); |
6c7a4dfd JJ |
651 | return type ? type : error_mark_node; |
652 | } | |
e8525382 | 653 | |
1f2959f0 | 654 | /* Initialization of builtin function nodes. */ |
e8525382 | 655 | |
6de9cd9a DN |
656 | static void |
657 | gfc_init_builtin_functions (void) | |
658 | { | |
6c7a4dfd JJ |
659 | 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, | |
f6a7cffc TS |
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, | |
6c7a4dfd JJ |
674 | #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, |
675 | #define DEF_POINTER_TYPE(NAME, TYPE) NAME, | |
676 | #include "types.def" | |
677 | #undef DEF_PRIMITIVE_TYPE | |
678 | #undef DEF_FUNCTION_TYPE_0 | |
679 | #undef DEF_FUNCTION_TYPE_1 | |
680 | #undef DEF_FUNCTION_TYPE_2 | |
681 | #undef DEF_FUNCTION_TYPE_3 | |
682 | #undef DEF_FUNCTION_TYPE_4 | |
683 | #undef DEF_FUNCTION_TYPE_5 | |
684 | #undef DEF_FUNCTION_TYPE_6 | |
685 | #undef DEF_FUNCTION_TYPE_7 | |
acf0174b | 686 | #undef DEF_FUNCTION_TYPE_8 |
6c7a4dfd JJ |
687 | #undef DEF_FUNCTION_TYPE_VAR_0 |
688 | #undef DEF_POINTER_TYPE | |
689 | BT_LAST | |
690 | }; | |
6c7a4dfd | 691 | |
b5a4419c FXC |
692 | tree mfunc_float[6]; |
693 | tree mfunc_double[6]; | |
694 | tree mfunc_longdouble[6]; | |
695 | tree mfunc_cfloat[6]; | |
696 | tree mfunc_cdouble[6]; | |
697 | tree mfunc_clongdouble[6]; | |
3a53e165 RG |
698 | tree func_cfloat_float, func_float_cfloat; |
699 | tree func_cdouble_double, func_double_cdouble; | |
700 | tree func_clongdouble_longdouble, func_longdouble_clongdouble; | |
701 | tree func_float_floatp_floatp; | |
702 | tree func_double_doublep_doublep; | |
703 | tree func_longdouble_longdoublep_longdoublep; | |
704 | tree ftype, ptype; | |
6c7a4dfd | 705 | tree builtin_types[(int) BT_LAST + 1]; |
6de9cd9a | 706 | |
3b7ea188 FXC |
707 | int attr; |
708 | ||
e8525382 SK |
709 | build_builtin_fntypes (mfunc_float, float_type_node); |
710 | build_builtin_fntypes (mfunc_double, double_type_node); | |
644cb69f | 711 | build_builtin_fntypes (mfunc_longdouble, long_double_type_node); |
e8525382 SK |
712 | build_builtin_fntypes (mfunc_cfloat, complex_float_type_node); |
713 | build_builtin_fntypes (mfunc_cdouble, complex_double_type_node); | |
644cb69f | 714 | build_builtin_fntypes (mfunc_clongdouble, complex_long_double_type_node); |
e8525382 | 715 | |
b64fca63 NF |
716 | func_cfloat_float = build_function_type_list (float_type_node, |
717 | complex_float_type_node, | |
718 | NULL_TREE); | |
6de9cd9a | 719 | |
b64fca63 NF |
720 | func_float_cfloat = build_function_type_list (complex_float_type_node, |
721 | float_type_node, NULL_TREE); | |
3a53e165 | 722 | |
b64fca63 NF |
723 | func_cdouble_double = build_function_type_list (double_type_node, |
724 | complex_double_type_node, | |
725 | NULL_TREE); | |
6de9cd9a | 726 | |
b64fca63 NF |
727 | func_double_cdouble = build_function_type_list (complex_double_type_node, |
728 | double_type_node, NULL_TREE); | |
3a53e165 | 729 | |
644cb69f | 730 | func_clongdouble_longdouble = |
b64fca63 NF |
731 | build_function_type_list (long_double_type_node, |
732 | complex_long_double_type_node, NULL_TREE); | |
644cb69f | 733 | |
3a53e165 | 734 | func_longdouble_clongdouble = |
b64fca63 NF |
735 | build_function_type_list (complex_long_double_type_node, |
736 | long_double_type_node, NULL_TREE); | |
3a53e165 RG |
737 | |
738 | ptype = build_pointer_type (float_type_node); | |
3a53e165 | 739 | func_float_floatp_floatp = |
b64fca63 | 740 | build_function_type_list (void_type_node, ptype, ptype, NULL_TREE); |
3a53e165 RG |
741 | |
742 | ptype = build_pointer_type (double_type_node); | |
3a53e165 | 743 | func_double_doublep_doublep = |
b64fca63 | 744 | build_function_type_list (void_type_node, ptype, ptype, NULL_TREE); |
3a53e165 RG |
745 | |
746 | ptype = build_pointer_type (long_double_type_node); | |
3a53e165 | 747 | func_longdouble_longdoublep_longdoublep = |
b64fca63 | 748 | build_function_type_list (void_type_node, ptype, ptype, NULL_TREE); |
3a53e165 | 749 | |
2921157d | 750 | /* Non-math builtins are defined manually, so they're not included here. */ |
a3c85b74 | 751 | #define OTHER_BUILTIN(ID,NAME,TYPE,CONST) |
2921157d | 752 | |
6de9cd9a DN |
753 | #include "mathbuiltins.def" |
754 | ||
644cb69f | 755 | gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0], |
d724c876 | 756 | BUILT_IN_ROUNDL, "roundl", ATTR_CONST_NOTHROW_LEAF_LIST); |
6de9cd9a | 757 | gfc_define_builtin ("__builtin_round", mfunc_double[0], |
d724c876 | 758 | BUILT_IN_ROUND, "round", ATTR_CONST_NOTHROW_LEAF_LIST); |
6de9cd9a | 759 | gfc_define_builtin ("__builtin_roundf", mfunc_float[0], |
d724c876 | 760 | BUILT_IN_ROUNDF, "roundf", ATTR_CONST_NOTHROW_LEAF_LIST); |
644cb69f FXC |
761 | |
762 | gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0], | |
d724c876 | 763 | BUILT_IN_TRUNCL, "truncl", ATTR_CONST_NOTHROW_LEAF_LIST); |
e743d142 | 764 | gfc_define_builtin ("__builtin_trunc", mfunc_double[0], |
d724c876 | 765 | BUILT_IN_TRUNC, "trunc", ATTR_CONST_NOTHROW_LEAF_LIST); |
e743d142 | 766 | gfc_define_builtin ("__builtin_truncf", mfunc_float[0], |
d724c876 | 767 | BUILT_IN_TRUNCF, "truncf", ATTR_CONST_NOTHROW_LEAF_LIST); |
e743d142 | 768 | |
644cb69f | 769 | gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble, |
d724c876 | 770 | BUILT_IN_CABSL, "cabsl", ATTR_CONST_NOTHROW_LEAF_LIST); |
ead6d15f | 771 | gfc_define_builtin ("__builtin_cabs", func_cdouble_double, |
d724c876 | 772 | BUILT_IN_CABS, "cabs", ATTR_CONST_NOTHROW_LEAF_LIST); |
ead6d15f | 773 | gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, |
d724c876 | 774 | BUILT_IN_CABSF, "cabsf", ATTR_CONST_NOTHROW_LEAF_LIST); |
c6a912da | 775 | |
644cb69f | 776 | gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1], |
d724c876 JJ |
777 | BUILT_IN_COPYSIGNL, "copysignl", |
778 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
ead6d15f | 779 | gfc_define_builtin ("__builtin_copysign", mfunc_double[1], |
d724c876 JJ |
780 | BUILT_IN_COPYSIGN, "copysign", |
781 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
ead6d15f | 782 | gfc_define_builtin ("__builtin_copysignf", mfunc_float[1], |
d724c876 JJ |
783 | BUILT_IN_COPYSIGNF, "copysignf", |
784 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
58b6e047 | 785 | |
b5a4419c | 786 | gfc_define_builtin ("__builtin_nextafterl", mfunc_longdouble[1], |
d724c876 JJ |
787 | BUILT_IN_NEXTAFTERL, "nextafterl", |
788 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
b5a4419c | 789 | gfc_define_builtin ("__builtin_nextafter", mfunc_double[1], |
d724c876 JJ |
790 | BUILT_IN_NEXTAFTER, "nextafter", |
791 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
b5a4419c | 792 | gfc_define_builtin ("__builtin_nextafterf", mfunc_float[1], |
d724c876 JJ |
793 | BUILT_IN_NEXTAFTERF, "nextafterf", |
794 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
b5a4419c | 795 | |
3b7ea188 FXC |
796 | /* Some built-ins depend on rounding mode. Depending on compilation options, they |
797 | will be "pure" or "const". */ | |
798 | attr = flag_rounding_math ? ATTR_PURE_NOTHROW_LEAF_LIST : ATTR_CONST_NOTHROW_LEAF_LIST; | |
799 | ||
800 | gfc_define_builtin ("__builtin_rintl", mfunc_longdouble[0], | |
801 | BUILT_IN_RINTL, "rintl", attr); | |
802 | gfc_define_builtin ("__builtin_rint", mfunc_double[0], | |
803 | BUILT_IN_RINT, "rint", attr); | |
804 | gfc_define_builtin ("__builtin_rintf", mfunc_float[0], | |
805 | BUILT_IN_RINTF, "rintf", attr); | |
806 | ||
807 | gfc_define_builtin ("__builtin_remainderl", mfunc_longdouble[1], | |
808 | BUILT_IN_REMAINDERL, "remainderl", attr); | |
809 | gfc_define_builtin ("__builtin_remainder", mfunc_double[1], | |
810 | BUILT_IN_REMAINDER, "remainder", attr); | |
811 | gfc_define_builtin ("__builtin_remainderf", mfunc_float[1], | |
812 | BUILT_IN_REMAINDERF, "remainderf", attr); | |
813 | ||
814 | gfc_define_builtin ("__builtin_logbl", mfunc_longdouble[0], | |
815 | BUILT_IN_LOGBL, "logbl", ATTR_CONST_NOTHROW_LEAF_LIST); | |
816 | gfc_define_builtin ("__builtin_logb", mfunc_double[0], | |
817 | BUILT_IN_LOGB, "logb", ATTR_CONST_NOTHROW_LEAF_LIST); | |
818 | gfc_define_builtin ("__builtin_logbf", mfunc_float[0], | |
819 | BUILT_IN_LOGBF, "logbf", ATTR_CONST_NOTHROW_LEAF_LIST); | |
820 | ||
821 | ||
b5a4419c | 822 | gfc_define_builtin ("__builtin_frexpl", mfunc_longdouble[4], |
d724c876 | 823 | BUILT_IN_FREXPL, "frexpl", ATTR_NOTHROW_LEAF_LIST); |
b5a4419c | 824 | gfc_define_builtin ("__builtin_frexp", mfunc_double[4], |
d724c876 | 825 | BUILT_IN_FREXP, "frexp", ATTR_NOTHROW_LEAF_LIST); |
b5a4419c | 826 | gfc_define_builtin ("__builtin_frexpf", mfunc_float[4], |
d724c876 | 827 | BUILT_IN_FREXPF, "frexpf", ATTR_NOTHROW_LEAF_LIST); |
b5a4419c FXC |
828 | |
829 | gfc_define_builtin ("__builtin_fabsl", mfunc_longdouble[0], | |
d724c876 | 830 | BUILT_IN_FABSL, "fabsl", ATTR_CONST_NOTHROW_LEAF_LIST); |
b5a4419c | 831 | gfc_define_builtin ("__builtin_fabs", mfunc_double[0], |
d724c876 | 832 | BUILT_IN_FABS, "fabs", ATTR_CONST_NOTHROW_LEAF_LIST); |
b5a4419c | 833 | gfc_define_builtin ("__builtin_fabsf", mfunc_float[0], |
d724c876 | 834 | BUILT_IN_FABSF, "fabsf", ATTR_CONST_NOTHROW_LEAF_LIST); |
b5a4419c | 835 | |
5cfd56a7 | 836 | gfc_define_builtin ("__builtin_scalbnl", mfunc_longdouble[2], |
d724c876 | 837 | BUILT_IN_SCALBNL, "scalbnl", ATTR_CONST_NOTHROW_LEAF_LIST); |
5cfd56a7 | 838 | gfc_define_builtin ("__builtin_scalbn", mfunc_double[2], |
d724c876 | 839 | BUILT_IN_SCALBN, "scalbn", ATTR_CONST_NOTHROW_LEAF_LIST); |
5cfd56a7 | 840 | gfc_define_builtin ("__builtin_scalbnf", mfunc_float[2], |
d724c876 | 841 | BUILT_IN_SCALBNF, "scalbnf", ATTR_CONST_NOTHROW_LEAF_LIST); |
b5a4419c | 842 | |
58b6e047 | 843 | gfc_define_builtin ("__builtin_fmodl", mfunc_longdouble[1], |
d724c876 | 844 | BUILT_IN_FMODL, "fmodl", ATTR_CONST_NOTHROW_LEAF_LIST); |
58b6e047 | 845 | gfc_define_builtin ("__builtin_fmod", mfunc_double[1], |
d724c876 | 846 | BUILT_IN_FMOD, "fmod", ATTR_CONST_NOTHROW_LEAF_LIST); |
58b6e047 | 847 | gfc_define_builtin ("__builtin_fmodf", mfunc_float[1], |
d724c876 | 848 | BUILT_IN_FMODF, "fmodf", ATTR_CONST_NOTHROW_LEAF_LIST); |
6de9cd9a | 849 | |
6715d47b JB |
850 | /* iround{f,,l}, lround{f,,l} and llround{f,,l} */ |
851 | ftype = build_function_type_list (integer_type_node, | |
852 | float_type_node, NULL_TREE); | |
853 | gfc_define_builtin("__builtin_iroundf", ftype, BUILT_IN_IROUNDF, | |
854 | "iroundf", ATTR_CONST_NOTHROW_LEAF_LIST); | |
b64fca63 NF |
855 | ftype = build_function_type_list (long_integer_type_node, |
856 | float_type_node, NULL_TREE); | |
857 | gfc_define_builtin ("__builtin_lroundf", ftype, BUILT_IN_LROUNDF, | |
d724c876 | 858 | "lroundf", ATTR_CONST_NOTHROW_LEAF_LIST); |
b64fca63 NF |
859 | ftype = build_function_type_list (long_long_integer_type_node, |
860 | float_type_node, NULL_TREE); | |
861 | gfc_define_builtin ("__builtin_llroundf", ftype, BUILT_IN_LLROUNDF, | |
d724c876 | 862 | "llroundf", ATTR_CONST_NOTHROW_LEAF_LIST); |
94f548c2 | 863 | |
6715d47b JB |
864 | ftype = build_function_type_list (integer_type_node, |
865 | double_type_node, NULL_TREE); | |
866 | gfc_define_builtin("__builtin_iround", ftype, BUILT_IN_IROUND, | |
867 | "iround", ATTR_CONST_NOTHROW_LEAF_LIST); | |
b64fca63 NF |
868 | ftype = build_function_type_list (long_integer_type_node, |
869 | double_type_node, NULL_TREE); | |
870 | gfc_define_builtin ("__builtin_lround", ftype, BUILT_IN_LROUND, | |
d724c876 | 871 | "lround", ATTR_CONST_NOTHROW_LEAF_LIST); |
b64fca63 NF |
872 | ftype = build_function_type_list (long_long_integer_type_node, |
873 | double_type_node, NULL_TREE); | |
874 | gfc_define_builtin ("__builtin_llround", ftype, BUILT_IN_LLROUND, | |
d724c876 | 875 | "llround", ATTR_CONST_NOTHROW_LEAF_LIST); |
94f548c2 | 876 | |
6715d47b JB |
877 | ftype = build_function_type_list (integer_type_node, |
878 | long_double_type_node, NULL_TREE); | |
879 | gfc_define_builtin("__builtin_iroundl", ftype, BUILT_IN_IROUNDL, | |
880 | "iroundl", ATTR_CONST_NOTHROW_LEAF_LIST); | |
b64fca63 NF |
881 | ftype = build_function_type_list (long_integer_type_node, |
882 | long_double_type_node, NULL_TREE); | |
883 | gfc_define_builtin ("__builtin_lroundl", ftype, BUILT_IN_LROUNDL, | |
d724c876 | 884 | "lroundl", ATTR_CONST_NOTHROW_LEAF_LIST); |
b64fca63 NF |
885 | ftype = build_function_type_list (long_long_integer_type_node, |
886 | long_double_type_node, NULL_TREE); | |
887 | gfc_define_builtin ("__builtin_llroundl", ftype, BUILT_IN_LLROUNDL, | |
d724c876 | 888 | "llroundl", ATTR_CONST_NOTHROW_LEAF_LIST); |
94f548c2 | 889 | |
5b200ac2 | 890 | /* These are used to implement the ** operator. */ |
644cb69f | 891 | gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1], |
d724c876 | 892 | BUILT_IN_POWL, "powl", ATTR_CONST_NOTHROW_LEAF_LIST); |
c7d78bbe | 893 | gfc_define_builtin ("__builtin_pow", mfunc_double[1], |
d724c876 | 894 | BUILT_IN_POW, "pow", ATTR_CONST_NOTHROW_LEAF_LIST); |
c7d78bbe | 895 | gfc_define_builtin ("__builtin_powf", mfunc_float[1], |
d724c876 | 896 | BUILT_IN_POWF, "powf", ATTR_CONST_NOTHROW_LEAF_LIST); |
fb220235 | 897 | gfc_define_builtin ("__builtin_cpowl", mfunc_clongdouble[1], |
d724c876 | 898 | BUILT_IN_CPOWL, "cpowl", ATTR_CONST_NOTHROW_LEAF_LIST); |
fb220235 | 899 | gfc_define_builtin ("__builtin_cpow", mfunc_cdouble[1], |
d724c876 | 900 | BUILT_IN_CPOW, "cpow", ATTR_CONST_NOTHROW_LEAF_LIST); |
fb220235 | 901 | gfc_define_builtin ("__builtin_cpowf", mfunc_cfloat[1], |
d724c876 | 902 | BUILT_IN_CPOWF, "cpowf", ATTR_CONST_NOTHROW_LEAF_LIST); |
5cfd56a7 | 903 | gfc_define_builtin ("__builtin_powil", mfunc_longdouble[2], |
d724c876 | 904 | BUILT_IN_POWIL, "powil", ATTR_CONST_NOTHROW_LEAF_LIST); |
5cfd56a7 | 905 | gfc_define_builtin ("__builtin_powi", mfunc_double[2], |
d724c876 | 906 | BUILT_IN_POWI, "powi", ATTR_CONST_NOTHROW_LEAF_LIST); |
5cfd56a7 | 907 | gfc_define_builtin ("__builtin_powif", mfunc_float[2], |
d724c876 | 908 | BUILT_IN_POWIF, "powif", ATTR_CONST_NOTHROW_LEAF_LIST); |
31c97dfe | 909 | |
5b200ac2 | 910 | |
d33d9e47 | 911 | if (targetm.libc_has_function (function_c99_math_complex)) |
3a53e165 RG |
912 | { |
913 | gfc_define_builtin ("__builtin_cbrtl", mfunc_longdouble[0], | |
d724c876 JJ |
914 | BUILT_IN_CBRTL, "cbrtl", |
915 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 | 916 | gfc_define_builtin ("__builtin_cbrt", mfunc_double[0], |
d724c876 JJ |
917 | BUILT_IN_CBRT, "cbrt", |
918 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 | 919 | gfc_define_builtin ("__builtin_cbrtf", mfunc_float[0], |
d724c876 JJ |
920 | BUILT_IN_CBRTF, "cbrtf", |
921 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 | 922 | gfc_define_builtin ("__builtin_cexpil", func_longdouble_clongdouble, |
d724c876 JJ |
923 | BUILT_IN_CEXPIL, "cexpil", |
924 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 | 925 | gfc_define_builtin ("__builtin_cexpi", func_double_cdouble, |
d724c876 JJ |
926 | BUILT_IN_CEXPI, "cexpi", |
927 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 | 928 | gfc_define_builtin ("__builtin_cexpif", func_float_cfloat, |
d724c876 JJ |
929 | BUILT_IN_CEXPIF, "cexpif", |
930 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
3a53e165 RG |
931 | } |
932 | ||
d33d9e47 | 933 | if (targetm.libc_has_function (function_sincos)) |
3a53e165 RG |
934 | { |
935 | gfc_define_builtin ("__builtin_sincosl", | |
936 | func_longdouble_longdoublep_longdoublep, | |
d724c876 | 937 | BUILT_IN_SINCOSL, "sincosl", ATTR_NOTHROW_LEAF_LIST); |
3a53e165 | 938 | gfc_define_builtin ("__builtin_sincos", func_double_doublep_doublep, |
d724c876 | 939 | BUILT_IN_SINCOS, "sincos", ATTR_NOTHROW_LEAF_LIST); |
3a53e165 | 940 | gfc_define_builtin ("__builtin_sincosf", func_float_floatp_floatp, |
d724c876 | 941 | BUILT_IN_SINCOSF, "sincosf", ATTR_NOTHROW_LEAF_LIST); |
3a53e165 RG |
942 | } |
943 | ||
451238b7 | 944 | /* For LEADZ, TRAILZ, POPCNT and POPPAR. */ |
b64fca63 NF |
945 | ftype = build_function_type_list (integer_type_node, |
946 | unsigned_type_node, NULL_TREE); | |
414f00e9 | 947 | gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ, |
d724c876 | 948 | "__builtin_clz", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 949 | gfc_define_builtin ("__builtin_ctz", ftype, BUILT_IN_CTZ, |
d724c876 | 950 | "__builtin_ctz", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 951 | gfc_define_builtin ("__builtin_parity", ftype, BUILT_IN_PARITY, |
d724c876 | 952 | "__builtin_parity", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 953 | gfc_define_builtin ("__builtin_popcount", ftype, BUILT_IN_POPCOUNT, |
d724c876 | 954 | "__builtin_popcount", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 955 | |
b64fca63 NF |
956 | ftype = build_function_type_list (integer_type_node, |
957 | long_unsigned_type_node, NULL_TREE); | |
958 | gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL, | |
d724c876 | 959 | "__builtin_clzl", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 960 | gfc_define_builtin ("__builtin_ctzl", ftype, BUILT_IN_CTZL, |
d724c876 | 961 | "__builtin_ctzl", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 962 | gfc_define_builtin ("__builtin_parityl", ftype, BUILT_IN_PARITYL, |
d724c876 | 963 | "__builtin_parityl", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 964 | gfc_define_builtin ("__builtin_popcountl", ftype, BUILT_IN_POPCOUNTL, |
d724c876 | 965 | "__builtin_popcountl", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 966 | |
b64fca63 NF |
967 | ftype = build_function_type_list (integer_type_node, |
968 | long_long_unsigned_type_node, NULL_TREE); | |
969 | gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL, | |
d724c876 | 970 | "__builtin_clzll", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 971 | gfc_define_builtin ("__builtin_ctzll", ftype, BUILT_IN_CTZLL, |
d724c876 | 972 | "__builtin_ctzll", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 973 | gfc_define_builtin ("__builtin_parityll", ftype, BUILT_IN_PARITYLL, |
d724c876 | 974 | "__builtin_parityll", ATTR_CONST_NOTHROW_LEAF_LIST); |
ad5f4de2 | 975 | gfc_define_builtin ("__builtin_popcountll", ftype, BUILT_IN_POPCOUNTLL, |
d724c876 | 976 | "__builtin_popcountll", ATTR_CONST_NOTHROW_LEAF_LIST); |
414f00e9 | 977 | |
6de9cd9a DN |
978 | /* Other builtin functions we use. */ |
979 | ||
b64fca63 NF |
980 | ftype = build_function_type_list (long_integer_type_node, |
981 | long_integer_type_node, | |
982 | long_integer_type_node, NULL_TREE); | |
c6a912da | 983 | gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT, |
d724c876 | 984 | "__builtin_expect", ATTR_CONST_NOTHROW_LEAF_LIST); |
ef9312c1 | 985 | |
b64fca63 NF |
986 | ftype = build_function_type_list (void_type_node, |
987 | pvoid_type_node, NULL_TREE); | |
1529b8d9 | 988 | gfc_define_builtin ("__builtin_free", ftype, BUILT_IN_FREE, |
d724c876 | 989 | "free", ATTR_NOTHROW_LEAF_LIST); |
1529b8d9 | 990 | |
b64fca63 NF |
991 | ftype = build_function_type_list (pvoid_type_node, |
992 | size_type_node, NULL_TREE); | |
1529b8d9 | 993 | gfc_define_builtin ("__builtin_malloc", ftype, BUILT_IN_MALLOC, |
46de9f5e | 994 | "malloc", ATTR_NOTHROW_LEAF_MALLOC_LIST); |
1529b8d9 | 995 | |
4df0f7da TB |
996 | ftype = build_function_type_list (pvoid_type_node, size_type_node, |
997 | size_type_node, NULL_TREE); | |
998 | gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC, | |
46de9f5e | 999 | "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST); |
4df0f7da TB |
1000 | DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1; |
1001 | ||
b64fca63 NF |
1002 | ftype = build_function_type_list (pvoid_type_node, |
1003 | size_type_node, pvoid_type_node, | |
1004 | NULL_TREE); | |
4376b7cf | 1005 | gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC, |
d724c876 | 1006 | "realloc", ATTR_NOTHROW_LEAF_LIST); |
4376b7cf | 1007 | |
b64fca63 NF |
1008 | ftype = build_function_type_list (integer_type_node, |
1009 | void_type_node, NULL_TREE); | |
5fcb93f1 | 1010 | gfc_define_builtin ("__builtin_isnan", ftype, BUILT_IN_ISNAN, |
d724c876 | 1011 | "__builtin_isnan", ATTR_CONST_NOTHROW_LEAF_LIST); |
3b7ea188 FXC |
1012 | gfc_define_builtin ("__builtin_isfinite", ftype, BUILT_IN_ISFINITE, |
1013 | "__builtin_isfinite", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1014 | gfc_define_builtin ("__builtin_isnormal", ftype, BUILT_IN_ISNORMAL, | |
1015 | "__builtin_isnormal", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1016 | ||
1017 | ftype = build_function_type_list (integer_type_node, void_type_node, | |
1018 | void_type_node, NULL_TREE); | |
1019 | gfc_define_builtin ("__builtin_isunordered", ftype, BUILT_IN_ISUNORDERED, | |
1020 | "__builtin_isunordered", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1021 | gfc_define_builtin ("__builtin_islessequal", ftype, BUILT_IN_ISLESSEQUAL, | |
1022 | "__builtin_islessequal", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1023 | gfc_define_builtin ("__builtin_isgreaterequal", ftype, | |
1024 | BUILT_IN_ISGREATEREQUAL, "__builtin_isgreaterequal", | |
1025 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
1026 | ||
1027 | ftype = build_function_type_list (integer_type_node, | |
1028 | float_type_node, NULL_TREE); | |
1029 | gfc_define_builtin("__builtin_signbitf", ftype, BUILT_IN_SIGNBITF, | |
1030 | "signbitf", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1031 | ftype = build_function_type_list (integer_type_node, | |
1032 | double_type_node, NULL_TREE); | |
1033 | gfc_define_builtin("__builtin_signbit", ftype, BUILT_IN_SIGNBIT, | |
1034 | "signbit", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1035 | ftype = build_function_type_list (integer_type_node, | |
1036 | long_double_type_node, NULL_TREE); | |
1037 | gfc_define_builtin("__builtin_signbitl", ftype, BUILT_IN_SIGNBITL, | |
1038 | "signbitl", ATTR_CONST_NOTHROW_LEAF_LIST); | |
1039 | ||
5fcb93f1 | 1040 | |
6c7a4dfd JJ |
1041 | #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ |
1042 | builtin_types[(int) ENUM] = VALUE; | |
b64fca63 NF |
1043 | #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ |
1044 | builtin_types[(int) ENUM] \ | |
1045 | = build_function_type_list (builtin_types[(int) RETURN], \ | |
1046 | NULL_TREE); | |
6c7a4dfd JJ |
1047 | #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ |
1048 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1049 | = build_function_type_list (builtin_types[(int) RETURN], \ |
1050 | builtin_types[(int) ARG1], \ | |
1051 | NULL_TREE); | |
1052 | #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ | |
1053 | builtin_types[(int) ENUM] \ | |
1054 | = build_function_type_list (builtin_types[(int) RETURN], \ | |
1055 | builtin_types[(int) ARG1], \ | |
1056 | builtin_types[(int) ARG2], \ | |
1057 | NULL_TREE); | |
1058 | #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ | |
1059 | builtin_types[(int) ENUM] \ | |
1060 | = build_function_type_list (builtin_types[(int) RETURN], \ | |
1061 | builtin_types[(int) ARG1], \ | |
1062 | builtin_types[(int) ARG2], \ | |
1063 | builtin_types[(int) ARG3], \ | |
1064 | NULL_TREE); | |
6c7a4dfd JJ |
1065 | #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ |
1066 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1067 | = build_function_type_list (builtin_types[(int) RETURN], \ |
1068 | builtin_types[(int) ARG1], \ | |
1069 | builtin_types[(int) ARG2], \ | |
1070 | builtin_types[(int) ARG3], \ | |
1071 | builtin_types[(int) ARG4], \ | |
1072 | NULL_TREE); | |
6c7a4dfd JJ |
1073 | #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \ |
1074 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1075 | = build_function_type_list (builtin_types[(int) RETURN], \ |
1076 | builtin_types[(int) ARG1], \ | |
1077 | builtin_types[(int) ARG2], \ | |
1078 | builtin_types[(int) ARG3], \ | |
1079 | builtin_types[(int) ARG4], \ | |
1080 | builtin_types[(int) ARG5], \ | |
1081 | NULL_TREE); | |
6c7a4dfd JJ |
1082 | #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
1083 | ARG6) \ | |
1084 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1085 | = build_function_type_list (builtin_types[(int) RETURN], \ |
1086 | builtin_types[(int) ARG1], \ | |
1087 | builtin_types[(int) ARG2], \ | |
1088 | builtin_types[(int) ARG3], \ | |
1089 | builtin_types[(int) ARG4], \ | |
1090 | builtin_types[(int) ARG5], \ | |
1091 | builtin_types[(int) ARG6], \ | |
1092 | NULL_TREE); | |
6c7a4dfd JJ |
1093 | #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
1094 | ARG6, ARG7) \ | |
1095 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1096 | = build_function_type_list (builtin_types[(int) RETURN], \ |
1097 | builtin_types[(int) ARG1], \ | |
1098 | builtin_types[(int) ARG2], \ | |
1099 | builtin_types[(int) ARG3], \ | |
1100 | builtin_types[(int) ARG4], \ | |
1101 | builtin_types[(int) ARG5], \ | |
1102 | builtin_types[(int) ARG6], \ | |
1103 | builtin_types[(int) ARG7], \ | |
1104 | NULL_TREE); | |
acf0174b JJ |
1105 | #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
1106 | ARG6, ARG7, ARG8) \ | |
1107 | builtin_types[(int) ENUM] \ | |
1108 | = build_function_type_list (builtin_types[(int) RETURN], \ | |
1109 | builtin_types[(int) ARG1], \ | |
1110 | builtin_types[(int) ARG2], \ | |
1111 | builtin_types[(int) ARG3], \ | |
1112 | builtin_types[(int) ARG4], \ | |
1113 | builtin_types[(int) ARG5], \ | |
1114 | builtin_types[(int) ARG6], \ | |
1115 | builtin_types[(int) ARG7], \ | |
1116 | builtin_types[(int) ARG8], \ | |
1117 | NULL_TREE); | |
6c7a4dfd JJ |
1118 | #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ |
1119 | builtin_types[(int) ENUM] \ | |
b64fca63 NF |
1120 | = build_varargs_function_type_list (builtin_types[(int) RETURN], \ |
1121 | NULL_TREE); | |
6c7a4dfd JJ |
1122 | #define DEF_POINTER_TYPE(ENUM, TYPE) \ |
1123 | builtin_types[(int) ENUM] \ | |
1124 | = build_pointer_type (builtin_types[(int) TYPE]); | |
1125 | #include "types.def" | |
1126 | #undef DEF_PRIMITIVE_TYPE | |
f6a7cffc | 1127 | #undef DEF_FUNCTION_TYPE_0 |
6c7a4dfd JJ |
1128 | #undef DEF_FUNCTION_TYPE_1 |
1129 | #undef DEF_FUNCTION_TYPE_2 | |
1130 | #undef DEF_FUNCTION_TYPE_3 | |
1131 | #undef DEF_FUNCTION_TYPE_4 | |
1132 | #undef DEF_FUNCTION_TYPE_5 | |
1133 | #undef DEF_FUNCTION_TYPE_6 | |
f6a7cffc TS |
1134 | #undef DEF_FUNCTION_TYPE_7 |
1135 | #undef DEF_FUNCTION_TYPE_8 | |
6c7a4dfd JJ |
1136 | #undef DEF_FUNCTION_TYPE_VAR_0 |
1137 | #undef DEF_POINTER_TYPE | |
1138 | builtin_types[(int) BT_LAST] = NULL_TREE; | |
1139 | ||
1140 | /* Initialize synchronization builtins. */ | |
1141 | #undef DEF_SYNC_BUILTIN | |
1142 | #define DEF_SYNC_BUILTIN(code, name, type, attr) \ | |
1143 | gfc_define_builtin (name, builtin_types[type], code, name, \ | |
d724c876 | 1144 | attr); |
6c7a4dfd JJ |
1145 | #include "../sync-builtins.def" |
1146 | #undef DEF_SYNC_BUILTIN | |
1147 | ||
c61819ff | 1148 | if (flag_openmp || flag_openmp_simd || flag_tree_parallelize_loops) |
6c7a4dfd JJ |
1149 | { |
1150 | #undef DEF_GOMP_BUILTIN | |
1151 | #define DEF_GOMP_BUILTIN(code, name, type, attr) \ | |
1152 | gfc_define_builtin ("__builtin_" name, builtin_types[type], \ | |
d724c876 | 1153 | code, name, attr); |
6c7a4dfd JJ |
1154 | #include "../omp-builtins.def" |
1155 | #undef DEF_GOMP_BUILTIN | |
1156 | } | |
1157 | ||
1158 | gfc_define_builtin ("__builtin_trap", builtin_types[BT_FN_VOID], | |
d724c876 | 1159 | BUILT_IN_TRAP, NULL, ATTR_NOTHROW_LEAF_LIST); |
e79983f4 | 1160 | TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1; |
6c7a4dfd | 1161 | |
b46ebd6c JJ |
1162 | ftype = build_varargs_function_type_list (ptr_type_node, const_ptr_type_node, |
1163 | size_type_node, NULL_TREE); | |
1164 | gfc_define_builtin ("__builtin_assume_aligned", ftype, | |
1165 | BUILT_IN_ASSUME_ALIGNED, | |
1166 | "__builtin_assume_aligned", | |
1167 | ATTR_CONST_NOTHROW_LEAF_LIST); | |
1168 | ||
8893239d | 1169 | gfc_define_builtin ("__emutls_get_address", |
d724c876 JJ |
1170 | builtin_types[BT_FN_PTR_PTR], |
1171 | BUILT_IN_EMUTLS_GET_ADDRESS, | |
1172 | "__emutls_get_address", ATTR_CONST_NOTHROW_LEAF_LIST); | |
8893239d RH |
1173 | gfc_define_builtin ("__emutls_register_common", |
1174 | builtin_types[BT_FN_VOID_PTR_WORD_WORD_PTR], | |
1175 | BUILT_IN_EMUTLS_REGISTER_COMMON, | |
d724c876 | 1176 | "__emutls_register_common", ATTR_NOTHROW_LEAF_LIST); |
8893239d | 1177 | |
384c400a | 1178 | build_common_builtin_nodes (); |
ef9312c1 | 1179 | targetm.init_builtins (); |
6de9cd9a DN |
1180 | } |
1181 | ||
e8525382 | 1182 | #undef DEFINE_MATH_BUILTIN_C |
6de9cd9a DN |
1183 | #undef DEFINE_MATH_BUILTIN |
1184 | ||
a64f5186 JJ |
1185 | static void |
1186 | gfc_init_ts (void) | |
1187 | { | |
1188 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_NON_COMMON] = 1; | |
1189 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_WITH_VIS] = 1; | |
1190 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_WRTL] = 1; | |
1191 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_COMMON] = 1; | |
1192 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1; | |
1193 | } | |
1194 | ||
602b8523 TB |
1195 | void |
1196 | gfc_maybe_initialize_eh (void) | |
1197 | { | |
1198 | if (!flag_exceptions || gfc_eh_initialized_p) | |
1199 | return; | |
1200 | ||
1201 | gfc_eh_initialized_p = true; | |
602b8523 TB |
1202 | using_eh_for_cleanups (); |
1203 | } | |
1204 | ||
1205 | ||
6de9cd9a DN |
1206 | #include "gt-fortran-f95-lang.h" |
1207 | #include "gtype-fortran.h" |