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