annotate gcc/fortran/f95-lang.c @ 158:494b0b89df80 default tip

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