1 /* gfortran backend interface
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
4 Contributed by Paul Brook.
6 This file is part of GCC.
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
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
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
23 /* f95-lang.c-- GCC backend interface stuff */
25 /* declare required prototypes: */
31 #include "coretypes.h"
33 #include "tree-gimple.h"
35 #include "langhooks.h"
36 #include "langhooks-def.h"
44 #include "diagnostic.h"
45 #include "tree-dump.h"
50 #include "trans-types.h"
51 #include "trans-const.h"
53 /* Language-dependent contents of an identifier. */
55 struct lang_identifier
58 struct tree_identifier common;
61 /* The resulting tree type. */
64 GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
65 chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
67 union tree_node GTY((tag ("0"),
68 desc ("tree_node_structure (&%h)"))) generic;
69 struct lang_identifier GTY((tag ("1"))) identifier;
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. */
76 struct language_function
79 /* struct gfc_language_function base; */
80 struct binding_level *binding_level;
83 /* We don't have a lex/yacc lexer/parser, but toplev expects these to
85 void yyerror (const char *str);
88 static void gfc_init_decl_processing (void);
89 static void gfc_init_builtin_functions (void);
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);
103 #undef LANG_HOOKS_NAME
104 #undef LANG_HOOKS_INIT
105 #undef LANG_HOOKS_FINISH
106 #undef LANG_HOOKS_INIT_OPTIONS
107 #undef LANG_HOOKS_HANDLE_OPTION
108 #undef LANG_HOOKS_POST_OPTIONS
109 #undef LANG_HOOKS_PRINT_IDENTIFIER
110 #undef LANG_HOOKS_PARSE_FILE
111 #undef LANG_HOOKS_MARK_ADDRESSABLE
112 #undef LANG_HOOKS_TYPE_FOR_MODE
113 #undef LANG_HOOKS_TYPE_FOR_SIZE
114 #undef LANG_HOOKS_UNSIGNED_TYPE
115 #undef LANG_HOOKS_SIGNED_TYPE
116 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
117 #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
118 #undef LANG_HOOKS_CLEAR_BINDING_STACK
120 /* Define lang hooks. */
121 #define LANG_HOOKS_NAME "GNU F95"
122 #define LANG_HOOKS_INIT gfc_init
123 #define LANG_HOOKS_FINISH gfc_finish
124 #define LANG_HOOKS_INIT_OPTIONS gfc_init_options
125 #define LANG_HOOKS_HANDLE_OPTION gfc_handle_option
126 #define LANG_HOOKS_POST_OPTIONS gfc_post_options
127 #define LANG_HOOKS_PRINT_IDENTIFIER gfc_print_identifier
128 #define LANG_HOOKS_PARSE_FILE gfc_be_parse_file
129 #define LANG_HOOKS_MARK_ADDRESSABLE gfc_mark_addressable
130 #define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode
131 #define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size
132 #define LANG_HOOKS_UNSIGNED_TYPE gfc_unsigned_type
133 #define LANG_HOOKS_SIGNED_TYPE gfc_signed_type
134 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gfc_signed_or_unsigned_type
135 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
136 #define LANG_HOOKS_CLEAR_BINDING_STACK gfc_clear_binding_stack
138 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
140 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
141 that have names. Here so we can clear out their names' definitions
142 at the end of the function. */
144 /* Tree code classes. */
146 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
148 const enum tree_code_class tree_code_type[] = {
153 /* Table indexed by tree code giving number of expression
154 operands beyond the fixed part of the node structure.
155 Not used for types or decls. */
157 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
159 const unsigned char tree_code_length[] = {
164 /* Names of tree components.
165 Used for printing out the tree and error messages. */
166 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
168 const char *const tree_code_name[] = {
174 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
176 /* A chain of binding_level structures awaiting reuse. */
178 static GTY(()) struct binding_level *free_binding_level;
180 /* The elements of `ridpointers' are identifier nodes
181 for the reserved type names and storage classes.
182 It is indexed by a RID_... value. */
183 tree *ridpointers = NULL;
185 /* language-specific flags. */
188 gfc_expand_function (tree fndecl)
192 if (DECL_INITIAL (fndecl)
193 && BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl)))
195 /* Local static equivalenced variables are never seen by
196 check_global_declarations, so we need to output debug
199 t = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl));
200 for (t = BLOCK_VARS (t); t; t = TREE_CHAIN (t))
201 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)
204 tree expr = DECL_VALUE_EXPR (t);
206 if (TREE_CODE (expr) == COMPONENT_REF
207 && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
208 && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
210 && cgraph_varpool_node (TREE_OPERAND (expr, 0))->needed
211 && errorcount == 0 && sorrycount == 0)
213 timevar_push (TV_SYMOUT);
214 (*debug_hooks->global_decl) (t);
215 timevar_pop (TV_SYMOUT);
220 tree_rest_of_compilation (fndecl);
224 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
225 or validate its data type for an `if' or `while' statement or ?..: exp.
227 This preparation consists of taking the ordinary
228 representation of an expression expr and producing a valid tree
229 boolean expression describing whether expr is nonzero. We could
230 simply always do build_binary_op (NE_EXPR, expr, boolean_false_node, 1),
231 but we optimize comparisons, &&, ||, and !.
233 The resulting type should always be `boolean_type_node'.
234 This is much simpler than the corresponding C version because we have a
235 distinct boolean type. */
238 gfc_truthvalue_conversion (tree expr)
240 switch (TREE_CODE (TREE_TYPE (expr)))
243 if (TREE_TYPE (expr) == boolean_type_node)
245 else if (COMPARISON_CLASS_P (expr))
247 TREE_TYPE (expr) = boolean_type_node;
250 else if (TREE_CODE (expr) == NOP_EXPR)
251 return build1 (NOP_EXPR, boolean_type_node,
252 TREE_OPERAND (expr, 0));
254 return build1 (NOP_EXPR, boolean_type_node, expr);
257 if (TREE_CODE (expr) == INTEGER_CST)
258 return integer_zerop (expr) ? boolean_false_node : boolean_true_node;
260 return build2 (NE_EXPR, boolean_type_node, expr, integer_zero_node);
263 internal_error ("Unexpected type in truthvalue_conversion");
268 gfc_create_decls (void)
271 gfc_init_builtin_functions ();
273 /* Runtime/IO library functions. */
274 gfc_build_builtin_function_decls ();
276 gfc_init_constants ();
280 gfc_be_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
287 gfc_generate_constructors ();
289 cgraph_finalize_compilation_unit ();
292 /* Tell the frontent about any errors. */
293 gfc_get_errors (&warnings, &errors);
294 errorcount += errors;
295 warningcount += warnings;
298 /* Initialize everything. */
303 #ifdef USE_MAPPED_LOCATION
304 linemap_add (&line_table, LC_ENTER, false, gfc_source_file, 1);
305 linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
308 /* First initialize the backend. */
309 gfc_init_decl_processing ();
310 gfc_static_ctors = NULL_TREE;
312 /* Then the frontend. */
315 if (gfc_new_file () != SUCCESS)
316 fatal_error ("can't open input file: %s", gfc_source_file);
325 gfc_release_include_path ();
330 gfc_print_identifier (FILE * file ATTRIBUTE_UNUSED,
331 tree node ATTRIBUTE_UNUSED,
332 int indent ATTRIBUTE_UNUSED)
338 /* These functions and variables deal with binding contours. We only
339 need these functions for the list of PARM_DECLs, but we leave the
340 functions more general; these are a simplified version of the
341 functions from GNAT. */
343 /* For each binding contour we allocate a binding_level structure which records
344 the entities defined or declared in that contour. Contours include:
347 one for each subprogram definition
348 one for each compound statement (declare block)
350 Binding contours are used to create GCC tree BLOCK nodes. */
355 /* A chain of ..._DECL nodes for all variables, constants, functions,
356 parameters and type declarations. These ..._DECL nodes are chained
357 through the TREE_CHAIN field. Note that these ..._DECL nodes are stored
358 in the reverse of the order supplied to be compatible with the
361 /* For each level (except the global one), a chain of BLOCK nodes for all
362 the levels that were entered and exited one level down from this one. */
364 /* The binding level containing this one (the enclosing binding level). */
365 struct binding_level *level_chain;
368 /* The binding level currently in effect. */
369 static GTY(()) struct binding_level *current_binding_level = NULL;
371 /* The outermost binding level. This binding level is created when the
372 compiler is started and it will exist through the entire compilation. */
373 static GTY(()) struct binding_level *global_binding_level;
375 /* Binding level structures are initialized by copying this one. */
376 static struct binding_level clear_binding_level = { NULL, NULL, NULL };
378 /* Return nonzero if we are currently in the global binding level. */
381 global_bindings_p (void)
383 return current_binding_level == global_binding_level ? -1 : 0;
389 return current_binding_level->names;
392 /* Enter a new binding level. The input parameter is ignored, but has to be
393 specified for back-end compatibility. */
396 pushlevel (int ignore ATTRIBUTE_UNUSED)
398 struct binding_level *newlevel
399 = (struct binding_level *) ggc_alloc (sizeof (struct binding_level));
401 *newlevel = clear_binding_level;
403 /* Add this level to the front of the chain (stack) of levels that are
405 newlevel->level_chain = current_binding_level;
406 current_binding_level = newlevel;
409 /* Exit a binding level.
410 Pop the level off, and restore the state of the identifier-decl mappings
411 that were in effect when this level was entered.
413 If KEEP is nonzero, this level had explicit declarations, so
414 and create a "block" (a BLOCK node) for the level
415 to record its declarations and subblocks for symbol table output.
417 If FUNCTIONBODY is nonzero, this level is the body of a function,
418 so create a block as if KEEP were set and also clear out all
421 If REVERSE is nonzero, reverse the order of decls before putting
422 them into the BLOCK. */
425 poplevel (int keep, int reverse, int functionbody)
427 /* Points to a BLOCK tree node. This is the BLOCK node constructed for the
428 binding level that we are about to exit and which is returned by this
430 tree block_node = NULL_TREE;
432 tree subblock_chain = current_binding_level->blocks;
435 /* Reverse the list of XXXX_DECL nodes if desired. Note that the ..._DECL
436 nodes chained through the `names' field of current_binding_level are in
437 reverse order except for PARM_DECL node, which are explicitly stored in
439 decl_chain = (reverse) ? nreverse (current_binding_level->names)
440 : current_binding_level->names;
442 /* If there were any declarations in the current binding level, or if this
443 binding level is a function body, or if there are any nested blocks then
444 create a BLOCK node to record them for the life of this function. */
445 if (keep || functionbody)
446 block_node = build_block (keep ? decl_chain : 0, subblock_chain, 0, 0);
448 /* Record the BLOCK node just built as the subblock its enclosing scope. */
449 for (subblock_node = subblock_chain; subblock_node;
450 subblock_node = TREE_CHAIN (subblock_node))
451 BLOCK_SUPERCONTEXT (subblock_node) = block_node;
453 /* Clear out the meanings of the local variables of this level. */
455 for (subblock_node = decl_chain; subblock_node;
456 subblock_node = TREE_CHAIN (subblock_node))
457 if (DECL_NAME (subblock_node) != 0)
458 /* If the identifier was used or addressed via a local extern decl,
459 don't forget that fact. */
460 if (DECL_EXTERNAL (subblock_node))
462 if (TREE_USED (subblock_node))
463 TREE_USED (DECL_NAME (subblock_node)) = 1;
464 if (TREE_ADDRESSABLE (subblock_node))
465 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (subblock_node)) = 1;
468 /* Pop the current level. */
469 current_binding_level = current_binding_level->level_chain;
473 /* This is the top level block of a function. The ..._DECL chain stored
474 in BLOCK_VARS are the function's parameters (PARM_DECL nodes). Don't
475 leave them in the BLOCK because they are found in the FUNCTION_DECL
477 DECL_INITIAL (current_function_decl) = block_node;
478 BLOCK_VARS (block_node) = 0;
482 current_binding_level->blocks
483 = chainon (current_binding_level->blocks, block_node);
486 /* If we did not make a block for the level just exited, any blocks made for
487 inner levels (since they cannot be recorded as subblocks in that level)
488 must be carried forward so they will later become subblocks of something
490 else if (subblock_chain)
491 current_binding_level->blocks
492 = chainon (current_binding_level->blocks, subblock_chain);
494 TREE_USED (block_node) = 1;
499 /* Insert BLOCK at the end of the list of subblocks of the
500 current binding level. This is used when a BIND_EXPR is expanded,
501 to handle the BLOCK node inside the BIND_EXPR. */
504 insert_block (tree block)
506 TREE_USED (block) = 1;
507 current_binding_level->blocks
508 = chainon (current_binding_level->blocks, block);
511 /* Records a ..._DECL node DECL as belonging to the current lexical scope.
512 Returns the ..._DECL node. */
517 /* External objects aren't nested, other objects may be. */
518 if ((DECL_EXTERNAL (decl)) || (decl == current_function_decl))
519 DECL_CONTEXT (decl) = 0;
521 DECL_CONTEXT (decl) = current_function_decl;
523 /* Put the declaration on the list. The list of declarations is in reverse
524 order. The list will be reversed later if necessary. This needs to be
525 this way for compatibility with the back-end. */
527 TREE_CHAIN (decl) = current_binding_level->names;
528 current_binding_level->names = decl;
530 /* For the declaration of a type, set its name if it is not already set. */
532 if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0)
534 if (DECL_SOURCE_LINE (decl) == 0)
535 TYPE_NAME (TREE_TYPE (decl)) = decl;
537 TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl);
544 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL. */
547 pushdecl_top_level (tree x)
550 struct binding_level *b = current_binding_level;
552 current_binding_level = global_binding_level;
554 current_binding_level = b;
559 /* Clear the binding stack. */
561 gfc_clear_binding_stack (void)
563 while (!global_bindings_p ())
568 #ifndef CHAR_TYPE_SIZE
569 #define CHAR_TYPE_SIZE BITS_PER_UNIT
572 #ifndef INT_TYPE_SIZE
573 #define INT_TYPE_SIZE BITS_PER_WORD
577 #define SIZE_TYPE "long unsigned int"
579 /* Create tree nodes for the basic scalar types of Fortran 95,
580 and some nodes representing standard constants (0, 1, (void *) 0).
581 Initialize the global binding level.
582 Make definitions for built-in primitive functions. */
584 gfc_init_decl_processing (void)
586 current_function_decl = NULL;
587 current_binding_level = NULL_BINDING_LEVEL;
588 free_binding_level = NULL_BINDING_LEVEL;
590 /* Make the binding_level structure for global names. We move all
591 variables that are in a COMMON block to this binding level. */
593 global_binding_level = current_binding_level;
595 /* Build common tree nodes. char_type_node is unsigned because we
596 only use it for actual characters, not for INTEGER(1). Also, we
597 want double_type_node to actually have double precision. */
598 build_common_tree_nodes (false, false);
599 set_sizetype (long_unsigned_type_node);
600 build_common_tree_nodes_2 (0);
601 void_list_node = build_tree_list (NULL_TREE, void_type_node);
603 /* Set up F95 type nodes. */
608 /* Mark EXP saying that we need to be able to take the
609 address of it; it should not be allocated in a register.
610 In Fortran 95 this is only the case for variables with
611 the TARGET attribute, but we implement it here for a
612 likely future Cray pointer extension.
613 Value is 1 if successful. */
614 /* TODO: Check/fix mark_addressable. */
616 gfc_mark_addressable (tree exp)
618 register tree x = exp;
620 switch (TREE_CODE (x))
627 x = TREE_OPERAND (x, 0);
631 TREE_ADDRESSABLE (x) = 1;
638 if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x) && DECL_NONLOCAL (x))
643 ("global register variable %qs used in nested function",
644 IDENTIFIER_POINTER (DECL_NAME (x)));
647 pedwarn ("register variable %qs used in nested function",
648 IDENTIFIER_POINTER (DECL_NAME (x)));
650 else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
654 error ("address of global register variable %qs requested",
655 IDENTIFIER_POINTER (DECL_NAME (x)));
660 /* If we are making this addressable due to its having
661 volatile components, give a different error message. Also
662 handle the case of an unnamed parameter by not trying
665 else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
667 error ("cannot put object with volatile field into register");
672 pedwarn ("address of register variable %qs requested",
673 IDENTIFIER_POINTER (DECL_NAME (x)));
678 TREE_ADDRESSABLE (x) = 1;
685 /* press the big red button - garbage (ggc) collection is on */
689 /* Builtin function initialization. */
691 /* Return a definition for a builtin function named NAME and whose data type
692 is TYPE. TYPE should be a function type with argument types.
693 FUNCTION_CODE tells later passes how to compile calls to this function.
694 See tree.h for its possible values.
696 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
697 the name to be called if we can't opencode the function. If
698 ATTRS is nonzero, use that for the function's attribute list. */
701 builtin_function (const char *name,
704 enum built_in_class class,
705 const char *library_name,
708 tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
709 DECL_EXTERNAL (decl) = 1;
710 TREE_PUBLIC (decl) = 1;
712 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
713 make_decl_rtl (decl);
715 DECL_BUILT_IN_CLASS (decl) = class;
716 DECL_FUNCTION_CODE (decl) = function_code;
718 /* Possibly apply some default attributes to this built-in function. */
721 /* FORNOW the only supported attribute is "const". If others need
722 to be supported then see the more general solution in procedure
723 builtin_function in c-decl.c */
724 if (lookup_attribute ( "const", attrs ))
725 TREE_READONLY (decl) = 1;
733 gfc_define_builtin (const char * name,
736 const char * library_name,
741 decl = builtin_function (name, type, code, BUILT_IN_NORMAL,
742 library_name, NULL_TREE);
744 TREE_READONLY (decl) = 1;
746 built_in_decls[code] = decl;
747 implicit_built_in_decls[code] = decl;
751 #define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \
752 gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
753 BUILT_IN_ ## code ## L, name "l", true); \
754 gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \
755 BUILT_IN_ ## code, name, true); \
756 gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \
757 BUILT_IN_ ## code ## F, name "f", true);
759 #define DEFINE_MATH_BUILTIN(code, name, argtype) \
760 DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_)
762 #define DEFINE_MATH_BUILTIN_C(code, name, argtype) \
763 DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) \
764 DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c)
767 /* Create function types for builtin functions. */
770 build_builtin_fntypes (tree * fntype, tree type)
774 /* type (*) (type) */
775 tmp = tree_cons (NULL_TREE, float_type_node, void_list_node);
776 fntype[0] = build_function_type (type, tmp);
777 /* type (*) (type, type) */
778 tmp = tree_cons (NULL_TREE, float_type_node, tmp);
779 fntype[1] = build_function_type (type, tmp);
780 /* type (*) (int, type) */
781 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
782 tmp = tree_cons (NULL_TREE, type, tmp);
783 fntype[2] = build_function_type (type, tmp);
787 /* Initialization of builtin function nodes. */
790 gfc_init_builtin_functions (void)
793 tree mfunc_double[3];
794 tree mfunc_longdouble[3];
795 tree mfunc_cfloat[3];
796 tree mfunc_cdouble[3];
797 tree mfunc_clongdouble[3];
798 tree func_cfloat_float;
799 tree func_cdouble_double;
800 tree func_clongdouble_longdouble;
804 build_builtin_fntypes (mfunc_float, float_type_node);
805 build_builtin_fntypes (mfunc_double, double_type_node);
806 build_builtin_fntypes (mfunc_longdouble, long_double_type_node);
807 build_builtin_fntypes (mfunc_cfloat, complex_float_type_node);
808 build_builtin_fntypes (mfunc_cdouble, complex_double_type_node);
809 build_builtin_fntypes (mfunc_clongdouble, complex_long_double_type_node);
811 tmp = tree_cons (NULL_TREE, complex_float_type_node, void_list_node);
812 func_cfloat_float = build_function_type (float_type_node, tmp);
814 tmp = tree_cons (NULL_TREE, complex_double_type_node, void_list_node);
815 func_cdouble_double = build_function_type (double_type_node, tmp);
817 tmp = tree_cons (NULL_TREE, complex_long_double_type_node, void_list_node);
818 func_clongdouble_longdouble =
819 build_function_type (long_double_type_node, tmp);
821 #include "mathbuiltins.def"
823 /* We define these separately as the fortran versions have different
824 semantics (they return an integer type) */
825 gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0],
826 BUILT_IN_ROUNDL, "roundl", true);
827 gfc_define_builtin ("__builtin_round", mfunc_double[0],
828 BUILT_IN_ROUND, "round", true);
829 gfc_define_builtin ("__builtin_roundf", mfunc_float[0],
830 BUILT_IN_ROUNDF, "roundf", true);
832 gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0],
833 BUILT_IN_TRUNCL, "truncl", true);
834 gfc_define_builtin ("__builtin_trunc", mfunc_double[0],
835 BUILT_IN_TRUNC, "trunc", true);
836 gfc_define_builtin ("__builtin_truncf", mfunc_float[0],
837 BUILT_IN_TRUNCF, "truncf", true);
839 gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble,
840 BUILT_IN_CABSL, "cabsl", true);
841 gfc_define_builtin ("__builtin_cabs", func_cdouble_double,
842 BUILT_IN_CABS, "cabs", true);
843 gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
844 BUILT_IN_CABSF, "cabsf", true);
846 gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1],
847 BUILT_IN_COPYSIGNL, "copysignl", true);
848 gfc_define_builtin ("__builtin_copysign", mfunc_double[1],
849 BUILT_IN_COPYSIGN, "copysign", true);
850 gfc_define_builtin ("__builtin_copysignf", mfunc_float[1],
851 BUILT_IN_COPYSIGNF, "copysignf", true);
853 /* These are used to implement the ** operator. */
854 gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1],
855 BUILT_IN_POWL, "powl", true);
856 gfc_define_builtin ("__builtin_pow", mfunc_double[1],
857 BUILT_IN_POW, "pow", true);
858 gfc_define_builtin ("__builtin_powf", mfunc_float[1],
859 BUILT_IN_POWF, "powf", true);
861 /* Other builtin functions we use. */
863 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
864 ftype = build_function_type (integer_type_node, tmp);
865 gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
866 "__builtin_clz", true);
868 tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
869 ftype = build_function_type (integer_type_node, tmp);
870 gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
871 "__builtin_clzl", true);
873 tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
874 ftype = build_function_type (integer_type_node, tmp);
875 gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
876 "__builtin_clzll", true);
878 tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
879 tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
880 ftype = build_function_type (long_integer_type_node, tmp);
881 gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
882 "__builtin_expect", true);
884 build_common_builtin_nodes ();
885 targetm.init_builtins ();
888 #undef DEFINE_MATH_BUILTIN_C
889 #undef DEFINE_MATH_BUILTIN
891 #include "gt-fortran-f95-lang.h"
892 #include "gtype-fortran.h"