1 |
12 |
jlechner |
/* gfortran backend interface
|
2 |
|
|
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
|
3 |
|
|
Inc.
|
4 |
|
|
Contributed by Paul Brook.
|
5 |
|
|
|
6 |
|
|
This file is part of GCC.
|
7 |
|
|
|
8 |
|
|
GCC is free software; you can redistribute it and/or modify it under
|
9 |
|
|
the terms of the GNU General Public License as published by the Free
|
10 |
|
|
Software Foundation; either version 2, or (at your option) any later
|
11 |
|
|
version.
|
12 |
|
|
|
13 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
14 |
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16 |
|
|
for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
20 |
|
|
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
21 |
|
|
02110-1301, USA. */
|
22 |
|
|
|
23 |
|
|
/* f95-lang.c-- GCC backend interface stuff */
|
24 |
|
|
|
25 |
|
|
/* declare required prototypes: */
|
26 |
|
|
|
27 |
|
|
#include "config.h"
|
28 |
|
|
#include "system.h"
|
29 |
|
|
#include "ansidecl.h"
|
30 |
|
|
#include "system.h"
|
31 |
|
|
#include "coretypes.h"
|
32 |
|
|
#include "tree.h"
|
33 |
|
|
#include "tree-gimple.h"
|
34 |
|
|
#include "flags.h"
|
35 |
|
|
#include "langhooks.h"
|
36 |
|
|
#include "langhooks-def.h"
|
37 |
|
|
#include "timevar.h"
|
38 |
|
|
#include "tm.h"
|
39 |
|
|
#include "function.h"
|
40 |
|
|
#include "ggc.h"
|
41 |
|
|
#include "toplev.h"
|
42 |
|
|
#include "target.h"
|
43 |
|
|
#include "debug.h"
|
44 |
|
|
#include "diagnostic.h"
|
45 |
|
|
#include "tree-dump.h"
|
46 |
|
|
#include "cgraph.h"
|
47 |
|
|
|
48 |
|
|
#include "gfortran.h"
|
49 |
|
|
#include "trans.h"
|
50 |
|
|
#include "trans-types.h"
|
51 |
|
|
#include "trans-const.h"
|
52 |
|
|
|
53 |
|
|
/* Language-dependent contents of an identifier. */
|
54 |
|
|
|
55 |
|
|
struct lang_identifier
|
56 |
|
|
GTY(())
|
57 |
|
|
{
|
58 |
|
|
struct tree_identifier common;
|
59 |
|
|
};
|
60 |
|
|
|
61 |
|
|
/* The resulting tree type. */
|
62 |
|
|
|
63 |
|
|
union lang_tree_node
|
64 |
|
|
GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
|
65 |
|
|
chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
|
66 |
|
|
{
|
67 |
|
|
union tree_node GTY((tag ("0"),
|
68 |
|
|
desc ("tree_node_structure (&%h)"))) generic;
|
69 |
|
|
struct lang_identifier GTY((tag ("1"))) identifier;
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
/* Save and restore the variables in this file and elsewhere
|
73 |
|
|
that keep track of the progress of compilation of the current function.
|
74 |
|
|
Used for nested functions. */
|
75 |
|
|
|
76 |
|
|
struct language_function
|
77 |
|
|
GTY(())
|
78 |
|
|
{
|
79 |
|
|
/* struct gfc_language_function base; */
|
80 |
|
|
struct binding_level *binding_level;
|
81 |
|
|
};
|
82 |
|
|
|
83 |
|
|
/* We don't have a lex/yacc lexer/parser, but toplev expects these to
|
84 |
|
|
exist anyway. */
|
85 |
|
|
void yyerror (const char *str);
|
86 |
|
|
int yylex (void);
|
87 |
|
|
|
88 |
|
|
static void gfc_init_decl_processing (void);
|
89 |
|
|
static void gfc_init_builtin_functions (void);
|
90 |
|
|
|
91 |
|
|
/* Each front end provides its own. */
|
92 |
|
|
static bool gfc_init (void);
|
93 |
|
|
static void gfc_finish (void);
|
94 |
|
|
static void gfc_print_identifier (FILE *, tree, int);
|
95 |
|
|
static bool gfc_mark_addressable (tree);
|
96 |
|
|
void do_function_end (void);
|
97 |
|
|
int global_bindings_p (void);
|
98 |
|
|
void insert_block (tree);
|
99 |
|
|
static void gfc_clear_binding_stack (void);
|
100 |
|
|
static void gfc_be_parse_file (int);
|
101 |
|
|
static void gfc_expand_function (tree);
|
102 |
|
|
static HOST_WIDE_INT gfc_get_alias_set (tree);
|
103 |
|
|
|
104 |
|
|
#undef LANG_HOOKS_NAME
|
105 |
|
|
#undef LANG_HOOKS_INIT
|
106 |
|
|
#undef LANG_HOOKS_FINISH
|
107 |
|
|
#undef LANG_HOOKS_INIT_OPTIONS
|
108 |
|
|
#undef LANG_HOOKS_HANDLE_OPTION
|
109 |
|
|
#undef LANG_HOOKS_POST_OPTIONS
|
110 |
|
|
#undef LANG_HOOKS_PRINT_IDENTIFIER
|
111 |
|
|
#undef LANG_HOOKS_PARSE_FILE
|
112 |
|
|
#undef LANG_HOOKS_MARK_ADDRESSABLE
|
113 |
|
|
#undef LANG_HOOKS_TYPE_FOR_MODE
|
114 |
|
|
#undef LANG_HOOKS_TYPE_FOR_SIZE
|
115 |
|
|
#undef LANG_HOOKS_UNSIGNED_TYPE
|
116 |
|
|
#undef LANG_HOOKS_SIGNED_TYPE
|
117 |
|
|
#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
|
118 |
|
|
#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
|
119 |
|
|
#undef LANG_HOOKS_CLEAR_BINDING_STACK
|
120 |
|
|
#undef LANG_HOOKS_GET_ALIAS_SET
|
121 |
|
|
|
122 |
|
|
/* Define lang hooks. */
|
123 |
|
|
#define LANG_HOOKS_NAME "GNU F95"
|
124 |
|
|
#define LANG_HOOKS_INIT gfc_init
|
125 |
|
|
#define LANG_HOOKS_FINISH gfc_finish
|
126 |
|
|
#define LANG_HOOKS_INIT_OPTIONS gfc_init_options
|
127 |
|
|
#define LANG_HOOKS_HANDLE_OPTION gfc_handle_option
|
128 |
|
|
#define LANG_HOOKS_POST_OPTIONS gfc_post_options
|
129 |
|
|
#define LANG_HOOKS_PRINT_IDENTIFIER gfc_print_identifier
|
130 |
|
|
#define LANG_HOOKS_PARSE_FILE gfc_be_parse_file
|
131 |
|
|
#define LANG_HOOKS_MARK_ADDRESSABLE gfc_mark_addressable
|
132 |
|
|
#define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode
|
133 |
|
|
#define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size
|
134 |
|
|
#define LANG_HOOKS_UNSIGNED_TYPE gfc_unsigned_type
|
135 |
|
|
#define LANG_HOOKS_SIGNED_TYPE gfc_signed_type
|
136 |
|
|
#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gfc_signed_or_unsigned_type
|
137 |
|
|
#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
|
138 |
|
|
#define LANG_HOOKS_CLEAR_BINDING_STACK gfc_clear_binding_stack
|
139 |
|
|
#define LANG_HOOKS_GET_ALIAS_SET gfc_get_alias_set
|
140 |
|
|
|
141 |
|
|
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
|
142 |
|
|
|
143 |
|
|
/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
|
144 |
|
|
that have names. Here so we can clear out their names' definitions
|
145 |
|
|
at the end of the function. */
|
146 |
|
|
|
147 |
|
|
/* Tree code classes. */
|
148 |
|
|
|
149 |
|
|
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
|
150 |
|
|
|
151 |
|
|
const enum tree_code_class tree_code_type[] = {
|
152 |
|
|
#include "tree.def"
|
153 |
|
|
};
|
154 |
|
|
#undef DEFTREECODE
|
155 |
|
|
|
156 |
|
|
/* Table indexed by tree code giving number of expression
|
157 |
|
|
operands beyond the fixed part of the node structure.
|
158 |
|
|
Not used for types or decls. */
|
159 |
|
|
|
160 |
|
|
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
|
161 |
|
|
|
162 |
|
|
const unsigned char tree_code_length[] = {
|
163 |
|
|
#include "tree.def"
|
164 |
|
|
};
|
165 |
|
|
#undef DEFTREECODE
|
166 |
|
|
|
167 |
|
|
/* Names of tree components.
|
168 |
|
|
Used for printing out the tree and error messages. */
|
169 |
|
|
#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
|
170 |
|
|
|
171 |
|
|
const char *const tree_code_name[] = {
|
172 |
|
|
#include "tree.def"
|
173 |
|
|
};
|
174 |
|
|
#undef DEFTREECODE
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
#define NULL_BINDING_LEVEL (struct binding_level *) NULL
|
178 |
|
|
|
179 |
|
|
/* A chain of binding_level structures awaiting reuse. */
|
180 |
|
|
|
181 |
|
|
static GTY(()) struct binding_level *free_binding_level;
|
182 |
|
|
|
183 |
|
|
/* The elements of `ridpointers' are identifier nodes
|
184 |
|
|
for the reserved type names and storage classes.
|
185 |
|
|
It is indexed by a RID_... value. */
|
186 |
|
|
tree *ridpointers = NULL;
|
187 |
|
|
|
188 |
|
|
/* language-specific flags. */
|
189 |
|
|
|
190 |
|
|
static void
|
191 |
|
|
gfc_expand_function (tree fndecl)
|
192 |
|
|
{
|
193 |
|
|
tree t;
|
194 |
|
|
|
195 |
|
|
if (DECL_INITIAL (fndecl)
|
196 |
|
|
&& BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl)))
|
197 |
|
|
{
|
198 |
|
|
/* Local static equivalenced variables are never seen by
|
199 |
|
|
check_global_declarations, so we need to output debug
|
200 |
|
|
info by hand. */
|
201 |
|
|
|
202 |
|
|
t = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl));
|
203 |
|
|
for (t = BLOCK_VARS (t); t; t = TREE_CHAIN (t))
|
204 |
|
|
if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)
|
205 |
|
|
&& TREE_STATIC (t))
|
206 |
|
|
{
|
207 |
|
|
tree expr = DECL_VALUE_EXPR (t);
|
208 |
|
|
|
209 |
|
|
if (TREE_CODE (expr) == COMPONENT_REF
|
210 |
|
|
&& TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
|
211 |
|
|
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
|
212 |
|
|
== UNION_TYPE
|
213 |
|
|
&& cgraph_varpool_node (TREE_OPERAND (expr, 0))->needed
|
214 |
|
|
&& errorcount == 0 && sorrycount == 0)
|
215 |
|
|
{
|
216 |
|
|
timevar_push (TV_SYMOUT);
|
217 |
|
|
(*debug_hooks->global_decl) (t);
|
218 |
|
|
timevar_pop (TV_SYMOUT);
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
tree_rest_of_compilation (fndecl);
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
|
228 |
|
|
or validate its data type for an `if' or `while' statement or ?..: exp.
|
229 |
|
|
|
230 |
|
|
This preparation consists of taking the ordinary
|
231 |
|
|
representation of an expression expr and producing a valid tree
|
232 |
|
|
boolean expression describing whether expr is nonzero. We could
|
233 |
|
|
simply always do build_binary_op (NE_EXPR, expr, boolean_false_node, 1),
|
234 |
|
|
but we optimize comparisons, &&, ||, and !.
|
235 |
|
|
|
236 |
|
|
The resulting type should always be `boolean_type_node'.
|
237 |
|
|
This is much simpler than the corresponding C version because we have a
|
238 |
|
|
distinct boolean type. */
|
239 |
|
|
|
240 |
|
|
tree
|
241 |
|
|
gfc_truthvalue_conversion (tree expr)
|
242 |
|
|
{
|
243 |
|
|
switch (TREE_CODE (TREE_TYPE (expr)))
|
244 |
|
|
{
|
245 |
|
|
case BOOLEAN_TYPE:
|
246 |
|
|
if (TREE_TYPE (expr) == boolean_type_node)
|
247 |
|
|
return expr;
|
248 |
|
|
else if (COMPARISON_CLASS_P (expr))
|
249 |
|
|
{
|
250 |
|
|
TREE_TYPE (expr) = boolean_type_node;
|
251 |
|
|
return expr;
|
252 |
|
|
}
|
253 |
|
|
else if (TREE_CODE (expr) == NOP_EXPR)
|
254 |
|
|
return build1 (NOP_EXPR, boolean_type_node,
|
255 |
|
|
TREE_OPERAND (expr, 0));
|
256 |
|
|
else
|
257 |
|
|
return build1 (NOP_EXPR, boolean_type_node, expr);
|
258 |
|
|
|
259 |
|
|
case INTEGER_TYPE:
|
260 |
|
|
if (TREE_CODE (expr) == INTEGER_CST)
|
261 |
|
|
return integer_zerop (expr) ? boolean_false_node : boolean_true_node;
|
262 |
|
|
else
|
263 |
|
|
return build2 (NE_EXPR, boolean_type_node, expr, integer_zero_node);
|
264 |
|
|
|
265 |
|
|
default:
|
266 |
|
|
internal_error ("Unexpected type in truthvalue_conversion");
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
static void
|
271 |
|
|
gfc_create_decls (void)
|
272 |
|
|
{
|
273 |
|
|
/* GCC builtins. */
|
274 |
|
|
gfc_init_builtin_functions ();
|
275 |
|
|
|
276 |
|
|
/* Runtime/IO library functions. */
|
277 |
|
|
gfc_build_builtin_function_decls ();
|
278 |
|
|
|
279 |
|
|
gfc_init_constants ();
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
static void
|
283 |
|
|
gfc_be_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
|
284 |
|
|
{
|
285 |
|
|
int errors;
|
286 |
|
|
int warnings;
|
287 |
|
|
|
288 |
|
|
gfc_create_decls ();
|
289 |
|
|
gfc_parse_file ();
|
290 |
|
|
gfc_generate_constructors ();
|
291 |
|
|
|
292 |
|
|
cgraph_finalize_compilation_unit ();
|
293 |
|
|
cgraph_optimize ();
|
294 |
|
|
|
295 |
|
|
/* Tell the frontent about any errors. */
|
296 |
|
|
gfc_get_errors (&warnings, &errors);
|
297 |
|
|
errorcount += errors;
|
298 |
|
|
warningcount += warnings;
|
299 |
|
|
}
|
300 |
|
|
|
301 |
|
|
/* Initialize everything. */
|
302 |
|
|
|
303 |
|
|
static bool
|
304 |
|
|
gfc_init (void)
|
305 |
|
|
{
|
306 |
|
|
#ifdef USE_MAPPED_LOCATION
|
307 |
|
|
linemap_add (&line_table, LC_ENTER, false, gfc_source_file, 1);
|
308 |
|
|
linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
|
309 |
|
|
#endif
|
310 |
|
|
|
311 |
|
|
/* First initialize the backend. */
|
312 |
|
|
gfc_init_decl_processing ();
|
313 |
|
|
gfc_static_ctors = NULL_TREE;
|
314 |
|
|
|
315 |
|
|
/* Then the frontend. */
|
316 |
|
|
gfc_init_1 ();
|
317 |
|
|
|
318 |
|
|
if (gfc_new_file () != SUCCESS)
|
319 |
|
|
fatal_error ("can't open input file: %s", gfc_source_file);
|
320 |
|
|
return true;
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
static void
|
325 |
|
|
gfc_finish (void)
|
326 |
|
|
{
|
327 |
|
|
gfc_done_1 ();
|
328 |
|
|
gfc_release_include_path ();
|
329 |
|
|
return;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
static void
|
333 |
|
|
gfc_print_identifier (FILE * file ATTRIBUTE_UNUSED,
|
334 |
|
|
tree node ATTRIBUTE_UNUSED,
|
335 |
|
|
int indent ATTRIBUTE_UNUSED)
|
336 |
|
|
{
|
337 |
|
|
return;
|
338 |
|
|
}
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
/* These functions and variables deal with binding contours. We only
|
342 |
|
|
need these functions for the list of PARM_DECLs, but we leave the
|
343 |
|
|
functions more general; these are a simplified version of the
|
344 |
|
|
functions from GNAT. */
|
345 |
|
|
|
346 |
|
|
/* For each binding contour we allocate a binding_level structure which records
|
347 |
|
|
the entities defined or declared in that contour. Contours include:
|
348 |
|
|
|
349 |
|
|
the global one
|
350 |
|
|
one for each subprogram definition
|
351 |
|
|
one for each compound statement (declare block)
|
352 |
|
|
|
353 |
|
|
Binding contours are used to create GCC tree BLOCK nodes. */
|
354 |
|
|
|
355 |
|
|
struct binding_level
|
356 |
|
|
GTY(())
|
357 |
|
|
{
|
358 |
|
|
/* A chain of ..._DECL nodes for all variables, constants, functions,
|
359 |
|
|
parameters and type declarations. These ..._DECL nodes are chained
|
360 |
|
|
through the TREE_CHAIN field. Note that these ..._DECL nodes are stored
|
361 |
|
|
in the reverse of the order supplied to be compatible with the
|
362 |
|
|
back-end. */
|
363 |
|
|
tree names;
|
364 |
|
|
/* For each level (except the global one), a chain of BLOCK nodes for all
|
365 |
|
|
the levels that were entered and exited one level down from this one. */
|
366 |
|
|
tree blocks;
|
367 |
|
|
/* The binding level containing this one (the enclosing binding level). */
|
368 |
|
|
struct binding_level *level_chain;
|
369 |
|
|
};
|
370 |
|
|
|
371 |
|
|
/* The binding level currently in effect. */
|
372 |
|
|
static GTY(()) struct binding_level *current_binding_level = NULL;
|
373 |
|
|
|
374 |
|
|
/* The outermost binding level. This binding level is created when the
|
375 |
|
|
compiler is started and it will exist through the entire compilation. */
|
376 |
|
|
static GTY(()) struct binding_level *global_binding_level;
|
377 |
|
|
|
378 |
|
|
/* Binding level structures are initialized by copying this one. */
|
379 |
|
|
static struct binding_level clear_binding_level = { NULL, NULL, NULL };
|
380 |
|
|
|
381 |
|
|
/* Return nonzero if we are currently in the global binding level. */
|
382 |
|
|
|
383 |
|
|
int
|
384 |
|
|
global_bindings_p (void)
|
385 |
|
|
{
|
386 |
|
|
return current_binding_level == global_binding_level ? -1 : 0;
|
387 |
|
|
}
|
388 |
|
|
|
389 |
|
|
tree
|
390 |
|
|
getdecls (void)
|
391 |
|
|
{
|
392 |
|
|
return current_binding_level->names;
|
393 |
|
|
}
|
394 |
|
|
|
395 |
|
|
/* Enter a new binding level. The input parameter is ignored, but has to be
|
396 |
|
|
specified for back-end compatibility. */
|
397 |
|
|
|
398 |
|
|
void
|
399 |
|
|
pushlevel (int ignore ATTRIBUTE_UNUSED)
|
400 |
|
|
{
|
401 |
|
|
struct binding_level *newlevel
|
402 |
|
|
= (struct binding_level *) ggc_alloc (sizeof (struct binding_level));
|
403 |
|
|
|
404 |
|
|
*newlevel = clear_binding_level;
|
405 |
|
|
|
406 |
|
|
/* Add this level to the front of the chain (stack) of levels that are
|
407 |
|
|
active. */
|
408 |
|
|
newlevel->level_chain = current_binding_level;
|
409 |
|
|
current_binding_level = newlevel;
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
/* Exit a binding level.
|
413 |
|
|
Pop the level off, and restore the state of the identifier-decl mappings
|
414 |
|
|
that were in effect when this level was entered.
|
415 |
|
|
|
416 |
|
|
If KEEP is nonzero, this level had explicit declarations, so
|
417 |
|
|
and create a "block" (a BLOCK node) for the level
|
418 |
|
|
to record its declarations and subblocks for symbol table output.
|
419 |
|
|
|
420 |
|
|
If FUNCTIONBODY is nonzero, this level is the body of a function,
|
421 |
|
|
so create a block as if KEEP were set and also clear out all
|
422 |
|
|
label names.
|
423 |
|
|
|
424 |
|
|
If REVERSE is nonzero, reverse the order of decls before putting
|
425 |
|
|
them into the BLOCK. */
|
426 |
|
|
|
427 |
|
|
tree
|
428 |
|
|
poplevel (int keep, int reverse, int functionbody)
|
429 |
|
|
{
|
430 |
|
|
/* Points to a BLOCK tree node. This is the BLOCK node constructed for the
|
431 |
|
|
binding level that we are about to exit and which is returned by this
|
432 |
|
|
routine. */
|
433 |
|
|
tree block_node = NULL_TREE;
|
434 |
|
|
tree decl_chain;
|
435 |
|
|
tree subblock_chain = current_binding_level->blocks;
|
436 |
|
|
tree subblock_node;
|
437 |
|
|
|
438 |
|
|
/* Reverse the list of XXXX_DECL nodes if desired. Note that the ..._DECL
|
439 |
|
|
nodes chained through the `names' field of current_binding_level are in
|
440 |
|
|
reverse order except for PARM_DECL node, which are explicitly stored in
|
441 |
|
|
the right order. */
|
442 |
|
|
decl_chain = (reverse) ? nreverse (current_binding_level->names)
|
443 |
|
|
: current_binding_level->names;
|
444 |
|
|
|
445 |
|
|
/* If there were any declarations in the current binding level, or if this
|
446 |
|
|
binding level is a function body, or if there are any nested blocks then
|
447 |
|
|
create a BLOCK node to record them for the life of this function. */
|
448 |
|
|
if (keep || functionbody)
|
449 |
|
|
block_node = build_block (keep ? decl_chain : 0, subblock_chain, 0, 0);
|
450 |
|
|
|
451 |
|
|
/* Record the BLOCK node just built as the subblock its enclosing scope. */
|
452 |
|
|
for (subblock_node = subblock_chain; subblock_node;
|
453 |
|
|
subblock_node = TREE_CHAIN (subblock_node))
|
454 |
|
|
BLOCK_SUPERCONTEXT (subblock_node) = block_node;
|
455 |
|
|
|
456 |
|
|
/* Clear out the meanings of the local variables of this level. */
|
457 |
|
|
|
458 |
|
|
for (subblock_node = decl_chain; subblock_node;
|
459 |
|
|
subblock_node = TREE_CHAIN (subblock_node))
|
460 |
|
|
if (DECL_NAME (subblock_node) != 0)
|
461 |
|
|
/* If the identifier was used or addressed via a local extern decl,
|
462 |
|
|
don't forget that fact. */
|
463 |
|
|
if (DECL_EXTERNAL (subblock_node))
|
464 |
|
|
{
|
465 |
|
|
if (TREE_USED (subblock_node))
|
466 |
|
|
TREE_USED (DECL_NAME (subblock_node)) = 1;
|
467 |
|
|
if (TREE_ADDRESSABLE (subblock_node))
|
468 |
|
|
TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (subblock_node)) = 1;
|
469 |
|
|
}
|
470 |
|
|
|
471 |
|
|
/* Pop the current level. */
|
472 |
|
|
current_binding_level = current_binding_level->level_chain;
|
473 |
|
|
|
474 |
|
|
if (functionbody)
|
475 |
|
|
{
|
476 |
|
|
/* This is the top level block of a function. The ..._DECL chain stored
|
477 |
|
|
in BLOCK_VARS are the function's parameters (PARM_DECL nodes). Don't
|
478 |
|
|
leave them in the BLOCK because they are found in the FUNCTION_DECL
|
479 |
|
|
instead. */
|
480 |
|
|
DECL_INITIAL (current_function_decl) = block_node;
|
481 |
|
|
BLOCK_VARS (block_node) = 0;
|
482 |
|
|
}
|
483 |
|
|
else if (block_node)
|
484 |
|
|
{
|
485 |
|
|
current_binding_level->blocks
|
486 |
|
|
= chainon (current_binding_level->blocks, block_node);
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
/* If we did not make a block for the level just exited, any blocks made for
|
490 |
|
|
inner levels (since they cannot be recorded as subblocks in that level)
|
491 |
|
|
must be carried forward so they will later become subblocks of something
|
492 |
|
|
else. */
|
493 |
|
|
else if (subblock_chain)
|
494 |
|
|
current_binding_level->blocks
|
495 |
|
|
= chainon (current_binding_level->blocks, subblock_chain);
|
496 |
|
|
if (block_node)
|
497 |
|
|
TREE_USED (block_node) = 1;
|
498 |
|
|
|
499 |
|
|
return block_node;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
/* Insert BLOCK at the end of the list of subblocks of the
|
503 |
|
|
current binding level. This is used when a BIND_EXPR is expanded,
|
504 |
|
|
to handle the BLOCK node inside the BIND_EXPR. */
|
505 |
|
|
|
506 |
|
|
void
|
507 |
|
|
insert_block (tree block)
|
508 |
|
|
{
|
509 |
|
|
TREE_USED (block) = 1;
|
510 |
|
|
current_binding_level->blocks
|
511 |
|
|
= chainon (current_binding_level->blocks, block);
|
512 |
|
|
}
|
513 |
|
|
|
514 |
|
|
/* Records a ..._DECL node DECL as belonging to the current lexical scope.
|
515 |
|
|
Returns the ..._DECL node. */
|
516 |
|
|
|
517 |
|
|
tree
|
518 |
|
|
pushdecl (tree decl)
|
519 |
|
|
{
|
520 |
|
|
/* External objects aren't nested, other objects may be. */
|
521 |
|
|
if ((DECL_EXTERNAL (decl)) || (decl == current_function_decl))
|
522 |
|
|
DECL_CONTEXT (decl) = 0;
|
523 |
|
|
else
|
524 |
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
525 |
|
|
|
526 |
|
|
/* Put the declaration on the list. The list of declarations is in reverse
|
527 |
|
|
order. The list will be reversed later if necessary. This needs to be
|
528 |
|
|
this way for compatibility with the back-end. */
|
529 |
|
|
|
530 |
|
|
TREE_CHAIN (decl) = current_binding_level->names;
|
531 |
|
|
current_binding_level->names = decl;
|
532 |
|
|
|
533 |
|
|
/* For the declaration of a type, set its name if it is not already set. */
|
534 |
|
|
|
535 |
|
|
if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0)
|
536 |
|
|
{
|
537 |
|
|
if (DECL_SOURCE_LINE (decl) == 0)
|
538 |
|
|
TYPE_NAME (TREE_TYPE (decl)) = decl;
|
539 |
|
|
else
|
540 |
|
|
TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl);
|
541 |
|
|
}
|
542 |
|
|
|
543 |
|
|
return decl;
|
544 |
|
|
}
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL. */
|
548 |
|
|
|
549 |
|
|
tree
|
550 |
|
|
pushdecl_top_level (tree x)
|
551 |
|
|
{
|
552 |
|
|
tree t;
|
553 |
|
|
struct binding_level *b = current_binding_level;
|
554 |
|
|
|
555 |
|
|
current_binding_level = global_binding_level;
|
556 |
|
|
t = pushdecl (x);
|
557 |
|
|
current_binding_level = b;
|
558 |
|
|
return t;
|
559 |
|
|
}
|
560 |
|
|
|
561 |
|
|
|
562 |
|
|
/* Clear the binding stack. */
|
563 |
|
|
static void
|
564 |
|
|
gfc_clear_binding_stack (void)
|
565 |
|
|
{
|
566 |
|
|
while (!global_bindings_p ())
|
567 |
|
|
poplevel (0, 0, 0);
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
|
571 |
|
|
#ifndef CHAR_TYPE_SIZE
|
572 |
|
|
#define CHAR_TYPE_SIZE BITS_PER_UNIT
|
573 |
|
|
#endif
|
574 |
|
|
|
575 |
|
|
#ifndef INT_TYPE_SIZE
|
576 |
|
|
#define INT_TYPE_SIZE BITS_PER_WORD
|
577 |
|
|
#endif
|
578 |
|
|
|
579 |
|
|
#undef SIZE_TYPE
|
580 |
|
|
#define SIZE_TYPE "long unsigned int"
|
581 |
|
|
|
582 |
|
|
/* Create tree nodes for the basic scalar types of Fortran 95,
|
583 |
|
|
and some nodes representing standard constants (0, 1, (void *) 0).
|
584 |
|
|
Initialize the global binding level.
|
585 |
|
|
Make definitions for built-in primitive functions. */
|
586 |
|
|
static void
|
587 |
|
|
gfc_init_decl_processing (void)
|
588 |
|
|
{
|
589 |
|
|
current_function_decl = NULL;
|
590 |
|
|
current_binding_level = NULL_BINDING_LEVEL;
|
591 |
|
|
free_binding_level = NULL_BINDING_LEVEL;
|
592 |
|
|
|
593 |
|
|
/* Make the binding_level structure for global names. We move all
|
594 |
|
|
variables that are in a COMMON block to this binding level. */
|
595 |
|
|
pushlevel (0);
|
596 |
|
|
global_binding_level = current_binding_level;
|
597 |
|
|
|
598 |
|
|
/* Build common tree nodes. char_type_node is unsigned because we
|
599 |
|
|
only use it for actual characters, not for INTEGER(1). Also, we
|
600 |
|
|
want double_type_node to actually have double precision. */
|
601 |
|
|
build_common_tree_nodes (false, false);
|
602 |
|
|
set_sizetype (long_unsigned_type_node);
|
603 |
|
|
build_common_tree_nodes_2 (0);
|
604 |
|
|
void_list_node = build_tree_list (NULL_TREE, void_type_node);
|
605 |
|
|
|
606 |
|
|
/* Set up F95 type nodes. */
|
607 |
|
|
gfc_init_kinds ();
|
608 |
|
|
gfc_init_types ();
|
609 |
|
|
}
|
610 |
|
|
|
611 |
|
|
/* Mark EXP saying that we need to be able to take the
|
612 |
|
|
address of it; it should not be allocated in a register.
|
613 |
|
|
In Fortran 95 this is only the case for variables with
|
614 |
|
|
the TARGET attribute, but we implement it here for a
|
615 |
|
|
likely future Cray pointer extension.
|
616 |
|
|
Value is 1 if successful. */
|
617 |
|
|
/* TODO: Check/fix mark_addressable. */
|
618 |
|
|
bool
|
619 |
|
|
gfc_mark_addressable (tree exp)
|
620 |
|
|
{
|
621 |
|
|
register tree x = exp;
|
622 |
|
|
while (1)
|
623 |
|
|
switch (TREE_CODE (x))
|
624 |
|
|
{
|
625 |
|
|
case COMPONENT_REF:
|
626 |
|
|
case ADDR_EXPR:
|
627 |
|
|
case ARRAY_REF:
|
628 |
|
|
case REALPART_EXPR:
|
629 |
|
|
case IMAGPART_EXPR:
|
630 |
|
|
x = TREE_OPERAND (x, 0);
|
631 |
|
|
break;
|
632 |
|
|
|
633 |
|
|
case CONSTRUCTOR:
|
634 |
|
|
TREE_ADDRESSABLE (x) = 1;
|
635 |
|
|
return true;
|
636 |
|
|
|
637 |
|
|
case VAR_DECL:
|
638 |
|
|
case CONST_DECL:
|
639 |
|
|
case PARM_DECL:
|
640 |
|
|
case RESULT_DECL:
|
641 |
|
|
if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x) && DECL_NONLOCAL (x))
|
642 |
|
|
{
|
643 |
|
|
if (TREE_PUBLIC (x))
|
644 |
|
|
{
|
645 |
|
|
error
|
646 |
|
|
("global register variable %qs used in nested function",
|
647 |
|
|
IDENTIFIER_POINTER (DECL_NAME (x)));
|
648 |
|
|
return false;
|
649 |
|
|
}
|
650 |
|
|
pedwarn ("register variable %qs used in nested function",
|
651 |
|
|
IDENTIFIER_POINTER (DECL_NAME (x)));
|
652 |
|
|
}
|
653 |
|
|
else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
|
654 |
|
|
{
|
655 |
|
|
if (TREE_PUBLIC (x))
|
656 |
|
|
{
|
657 |
|
|
error ("address of global register variable %qs requested",
|
658 |
|
|
IDENTIFIER_POINTER (DECL_NAME (x)));
|
659 |
|
|
return true;
|
660 |
|
|
}
|
661 |
|
|
|
662 |
|
|
#if 0
|
663 |
|
|
/* If we are making this addressable due to its having
|
664 |
|
|
volatile components, give a different error message. Also
|
665 |
|
|
handle the case of an unnamed parameter by not trying
|
666 |
|
|
to give the name. */
|
667 |
|
|
|
668 |
|
|
else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
|
669 |
|
|
{
|
670 |
|
|
error ("cannot put object with volatile field into register");
|
671 |
|
|
return false;
|
672 |
|
|
}
|
673 |
|
|
#endif
|
674 |
|
|
|
675 |
|
|
pedwarn ("address of register variable %qs requested",
|
676 |
|
|
IDENTIFIER_POINTER (DECL_NAME (x)));
|
677 |
|
|
}
|
678 |
|
|
|
679 |
|
|
/* drops in */
|
680 |
|
|
case FUNCTION_DECL:
|
681 |
|
|
TREE_ADDRESSABLE (x) = 1;
|
682 |
|
|
|
683 |
|
|
default:
|
684 |
|
|
return true;
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
|
688 |
|
|
/* Return the typed-based alias set for T, which may be an expression
|
689 |
|
|
or a type. Return -1 if we don't do anything special. */
|
690 |
|
|
|
691 |
|
|
static HOST_WIDE_INT
|
692 |
|
|
gfc_get_alias_set (tree t)
|
693 |
|
|
{
|
694 |
|
|
tree u;
|
695 |
|
|
|
696 |
|
|
/* Permit type-punning when accessing an EQUIVALENCEd variable or
|
697 |
|
|
mixed type entry master's return value. */
|
698 |
|
|
for (u = t; handled_component_p (u); u = TREE_OPERAND (u, 0))
|
699 |
|
|
if (TREE_CODE (u) == COMPONENT_REF
|
700 |
|
|
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
|
701 |
|
|
return 0;
|
702 |
|
|
|
703 |
|
|
return -1;
|
704 |
|
|
}
|
705 |
|
|
|
706 |
|
|
/* press the big red button - garbage (ggc) collection is on */
|
707 |
|
|
|
708 |
|
|
int ggc_p = 1;
|
709 |
|
|
|
710 |
|
|
/* Builtin function initialization. */
|
711 |
|
|
|
712 |
|
|
/* Return a definition for a builtin function named NAME and whose data type
|
713 |
|
|
is TYPE. TYPE should be a function type with argument types.
|
714 |
|
|
FUNCTION_CODE tells later passes how to compile calls to this function.
|
715 |
|
|
See tree.h for its possible values.
|
716 |
|
|
|
717 |
|
|
If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
|
718 |
|
|
the name to be called if we can't opencode the function. If
|
719 |
|
|
ATTRS is nonzero, use that for the function's attribute list. */
|
720 |
|
|
|
721 |
|
|
tree
|
722 |
|
|
builtin_function (const char *name,
|
723 |
|
|
tree type,
|
724 |
|
|
int function_code,
|
725 |
|
|
enum built_in_class class,
|
726 |
|
|
const char *library_name,
|
727 |
|
|
tree attrs)
|
728 |
|
|
{
|
729 |
|
|
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
|
730 |
|
|
DECL_EXTERNAL (decl) = 1;
|
731 |
|
|
TREE_PUBLIC (decl) = 1;
|
732 |
|
|
if (library_name)
|
733 |
|
|
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
|
734 |
|
|
make_decl_rtl (decl);
|
735 |
|
|
pushdecl (decl);
|
736 |
|
|
DECL_BUILT_IN_CLASS (decl) = class;
|
737 |
|
|
DECL_FUNCTION_CODE (decl) = function_code;
|
738 |
|
|
|
739 |
|
|
/* Possibly apply some default attributes to this built-in function. */
|
740 |
|
|
if (attrs)
|
741 |
|
|
{
|
742 |
|
|
/* FORNOW the only supported attribute is "const". If others need
|
743 |
|
|
to be supported then see the more general solution in procedure
|
744 |
|
|
builtin_function in c-decl.c */
|
745 |
|
|
if (lookup_attribute ( "const", attrs ))
|
746 |
|
|
TREE_READONLY (decl) = 1;
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
return decl;
|
750 |
|
|
}
|
751 |
|
|
|
752 |
|
|
|
753 |
|
|
static void
|
754 |
|
|
gfc_define_builtin (const char * name,
|
755 |
|
|
tree type,
|
756 |
|
|
int code,
|
757 |
|
|
const char * library_name,
|
758 |
|
|
bool const_p)
|
759 |
|
|
{
|
760 |
|
|
tree decl;
|
761 |
|
|
|
762 |
|
|
decl = builtin_function (name, type, code, BUILT_IN_NORMAL,
|
763 |
|
|
library_name, NULL_TREE);
|
764 |
|
|
if (const_p)
|
765 |
|
|
TREE_READONLY (decl) = 1;
|
766 |
|
|
|
767 |
|
|
built_in_decls[code] = decl;
|
768 |
|
|
implicit_built_in_decls[code] = decl;
|
769 |
|
|
}
|
770 |
|
|
|
771 |
|
|
|
772 |
|
|
#define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \
|
773 |
|
|
gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
|
774 |
|
|
BUILT_IN_ ## code ## L, name "l", true); \
|
775 |
|
|
gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \
|
776 |
|
|
BUILT_IN_ ## code, name, true); \
|
777 |
|
|
gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \
|
778 |
|
|
BUILT_IN_ ## code ## F, name "f", true);
|
779 |
|
|
|
780 |
|
|
#define DEFINE_MATH_BUILTIN(code, name, argtype) \
|
781 |
|
|
DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_)
|
782 |
|
|
|
783 |
|
|
#define DEFINE_MATH_BUILTIN_C(code, name, argtype) \
|
784 |
|
|
DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) \
|
785 |
|
|
DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c)
|
786 |
|
|
|
787 |
|
|
|
788 |
|
|
/* Create function types for builtin functions. */
|
789 |
|
|
|
790 |
|
|
static void
|
791 |
|
|
build_builtin_fntypes (tree * fntype, tree type)
|
792 |
|
|
{
|
793 |
|
|
tree tmp;
|
794 |
|
|
|
795 |
|
|
/* type (*) (type) */
|
796 |
|
|
tmp = tree_cons (NULL_TREE, float_type_node, void_list_node);
|
797 |
|
|
fntype[0] = build_function_type (type, tmp);
|
798 |
|
|
/* type (*) (type, type) */
|
799 |
|
|
tmp = tree_cons (NULL_TREE, float_type_node, tmp);
|
800 |
|
|
fntype[1] = build_function_type (type, tmp);
|
801 |
|
|
/* type (*) (int, type) */
|
802 |
|
|
tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
|
803 |
|
|
tmp = tree_cons (NULL_TREE, type, tmp);
|
804 |
|
|
fntype[2] = build_function_type (type, tmp);
|
805 |
|
|
}
|
806 |
|
|
|
807 |
|
|
|
808 |
|
|
/* Initialization of builtin function nodes. */
|
809 |
|
|
|
810 |
|
|
static void
|
811 |
|
|
gfc_init_builtin_functions (void)
|
812 |
|
|
{
|
813 |
|
|
tree mfunc_float[3];
|
814 |
|
|
tree mfunc_double[3];
|
815 |
|
|
tree mfunc_longdouble[3];
|
816 |
|
|
tree mfunc_cfloat[3];
|
817 |
|
|
tree mfunc_cdouble[3];
|
818 |
|
|
tree mfunc_clongdouble[3];
|
819 |
|
|
tree func_cfloat_float;
|
820 |
|
|
tree func_cdouble_double;
|
821 |
|
|
tree func_clongdouble_longdouble;
|
822 |
|
|
tree ftype;
|
823 |
|
|
tree tmp;
|
824 |
|
|
|
825 |
|
|
build_builtin_fntypes (mfunc_float, float_type_node);
|
826 |
|
|
build_builtin_fntypes (mfunc_double, double_type_node);
|
827 |
|
|
build_builtin_fntypes (mfunc_longdouble, long_double_type_node);
|
828 |
|
|
build_builtin_fntypes (mfunc_cfloat, complex_float_type_node);
|
829 |
|
|
build_builtin_fntypes (mfunc_cdouble, complex_double_type_node);
|
830 |
|
|
build_builtin_fntypes (mfunc_clongdouble, complex_long_double_type_node);
|
831 |
|
|
|
832 |
|
|
tmp = tree_cons (NULL_TREE, complex_float_type_node, void_list_node);
|
833 |
|
|
func_cfloat_float = build_function_type (float_type_node, tmp);
|
834 |
|
|
|
835 |
|
|
tmp = tree_cons (NULL_TREE, complex_double_type_node, void_list_node);
|
836 |
|
|
func_cdouble_double = build_function_type (double_type_node, tmp);
|
837 |
|
|
|
838 |
|
|
tmp = tree_cons (NULL_TREE, complex_long_double_type_node, void_list_node);
|
839 |
|
|
func_clongdouble_longdouble =
|
840 |
|
|
build_function_type (long_double_type_node, tmp);
|
841 |
|
|
|
842 |
|
|
#include "mathbuiltins.def"
|
843 |
|
|
|
844 |
|
|
/* We define these separately as the fortran versions have different
|
845 |
|
|
semantics (they return an integer type) */
|
846 |
|
|
gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0],
|
847 |
|
|
BUILT_IN_ROUNDL, "roundl", true);
|
848 |
|
|
gfc_define_builtin ("__builtin_round", mfunc_double[0],
|
849 |
|
|
BUILT_IN_ROUND, "round", true);
|
850 |
|
|
gfc_define_builtin ("__builtin_roundf", mfunc_float[0],
|
851 |
|
|
BUILT_IN_ROUNDF, "roundf", true);
|
852 |
|
|
|
853 |
|
|
gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0],
|
854 |
|
|
BUILT_IN_TRUNCL, "truncl", true);
|
855 |
|
|
gfc_define_builtin ("__builtin_trunc", mfunc_double[0],
|
856 |
|
|
BUILT_IN_TRUNC, "trunc", true);
|
857 |
|
|
gfc_define_builtin ("__builtin_truncf", mfunc_float[0],
|
858 |
|
|
BUILT_IN_TRUNCF, "truncf", true);
|
859 |
|
|
|
860 |
|
|
gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble,
|
861 |
|
|
BUILT_IN_CABSL, "cabsl", true);
|
862 |
|
|
gfc_define_builtin ("__builtin_cabs", func_cdouble_double,
|
863 |
|
|
BUILT_IN_CABS, "cabs", true);
|
864 |
|
|
gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
|
865 |
|
|
BUILT_IN_CABSF, "cabsf", true);
|
866 |
|
|
|
867 |
|
|
gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1],
|
868 |
|
|
BUILT_IN_COPYSIGNL, "copysignl", true);
|
869 |
|
|
gfc_define_builtin ("__builtin_copysign", mfunc_double[1],
|
870 |
|
|
BUILT_IN_COPYSIGN, "copysign", true);
|
871 |
|
|
gfc_define_builtin ("__builtin_copysignf", mfunc_float[1],
|
872 |
|
|
BUILT_IN_COPYSIGNF, "copysignf", true);
|
873 |
|
|
|
874 |
|
|
/* These are used to implement the ** operator. */
|
875 |
|
|
gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1],
|
876 |
|
|
BUILT_IN_POWL, "powl", true);
|
877 |
|
|
gfc_define_builtin ("__builtin_pow", mfunc_double[1],
|
878 |
|
|
BUILT_IN_POW, "pow", true);
|
879 |
|
|
gfc_define_builtin ("__builtin_powf", mfunc_float[1],
|
880 |
|
|
BUILT_IN_POWF, "powf", true);
|
881 |
|
|
|
882 |
|
|
/* Other builtin functions we use. */
|
883 |
|
|
|
884 |
|
|
tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
|
885 |
|
|
ftype = build_function_type (integer_type_node, tmp);
|
886 |
|
|
gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
|
887 |
|
|
"__builtin_clz", true);
|
888 |
|
|
|
889 |
|
|
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
|
890 |
|
|
ftype = build_function_type (integer_type_node, tmp);
|
891 |
|
|
gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
|
892 |
|
|
"__builtin_clzl", true);
|
893 |
|
|
|
894 |
|
|
tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
|
895 |
|
|
ftype = build_function_type (integer_type_node, tmp);
|
896 |
|
|
gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
|
897 |
|
|
"__builtin_clzll", true);
|
898 |
|
|
|
899 |
|
|
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
|
900 |
|
|
tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
|
901 |
|
|
ftype = build_function_type (long_integer_type_node, tmp);
|
902 |
|
|
gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
|
903 |
|
|
"__builtin_expect", true);
|
904 |
|
|
|
905 |
|
|
build_common_builtin_nodes ();
|
906 |
|
|
targetm.init_builtins ();
|
907 |
|
|
}
|
908 |
|
|
|
909 |
|
|
#undef DEFINE_MATH_BUILTIN_C
|
910 |
|
|
#undef DEFINE_MATH_BUILTIN
|
911 |
|
|
|
912 |
|
|
#include "gt-fortran-f95-lang.h"
|
913 |
|
|
#include "gtype-fortran.h"
|