Furthering the include file restructuring, this patch fixes the header
files for builtins.h. The prototypes were spread between tree.h, expr.h
and fold-const.h.
* There were 5 build_* routines in builtins.c that really should be in
tree.c. They are used all over the place. The prototypes were already
in tree.h.
* There were 3 routines in builtins.c that belonged in targhooks.c.
The prototypes were already in targhooks.h
* fold-const.c uses do_mpc_arg2() which is defined in builtins.c, so the
prototype should be in builtins.h. The prototype utilizes type
mpc_srcptr from <mpc.h> which means that every file which includes
builtins.h would also require #include <mpc.h>. That is likely the
reason the prototype was placed into realmpfr.h. I added #include
<mpc.h> to builtins.h. Normally we're trying not to do that until we
can rebuild a decent module structure, but I think that rule only makes
sense for include files within gcc's source base...
* Finally, fortran/trans.c was calling fold_builtin_call_array directly.
That means it would have needed builtins.h which caused issues since
builtins.h defines struct target_builtins and uses
FIRST_PSEUDO_REGISTER... which is defined within the target config
file... something I dont think we really want to expose to the fortran
front end :-P. Anyway, looking aorund, it turns out
fold-const.c::fold_build_call_array_loc is really a wrapper for a call
to fold_builtin_call_array, with some extra checking code before and
after the call protected by ENABLE_FOLD_CHECKING. I'd think that should
be OK since its what other front ends call...
Bootstraps on x86_64-unknown-linux-gnu with no regressions. I also ran
it through a full set of target builds for compilation, with no new
failures there.
The second set of patches are the updated #includes required for
compilation.
OK for trunk?
Andrew
* expr.h: Remove prototypes of functions defined in builtins.c.
* tree.h: (build_call_expr_*, build_string_literal): Add prototypes.
Remove prototypes of functions defined in builtins.c.
* builtins.h: Update prototype list to include all exported functions.
* builtins.c: (default_libc_has_function, gnu_libc_has_function,
no_c99_libc_has_function): Move to targhooks.c
(build_string_literal, build_call_expr_loc_array,
build_call_expr_loc_vec, build_call_expr_loc, build_call_expr): Move
to tree.c.
(expand_builtin_object_size, fold_builtin_object_size): Make static.
* targhooks.c (default_libc_has_function, gnu_libc_has_function,
no_c99_libc_has_function): Relocate from builtins.c.
* tree.c: Include builtins.h.
(build_call_expr_loc_array, build_call_expr_loc_vec,
build_call_expr_loc, build_call_expr, build_string_literal): Relocate
from builtins.c.
* fold-const.h (fold_fma): Move prototype to builtins.h.
* realmpfr.h (do_mpc_arg2): Move prototype to builtins.h.
* fortran/trans.c (trans_runtime_error_vararg): Call
fold_build_call_array_loc instead of fold_builtin_call_array.
Index: expr.h
===================================================================
*** expr.h (revision 211131)
--- expr.h (working copy)
*************** extern unsigned HOST_WIDE_INT choose_mul
*** 252,271 ****
int, unsigned HOST_WIDE_INT *,
int *, int *);
- /* Functions from builtins.c: */
- extern rtx expand_builtin (tree, rtx, rtx, enum machine_mode, int);
- extern tree std_build_builtin_va_list (void);
- extern tree std_fn_abi_va_list (tree);
- extern tree std_canonical_va_list_type (tree);
-
- extern void std_expand_builtin_va_start (tree, rtx);
- extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
- extern void expand_builtin_setjmp_setup (rtx, rtx);
- extern void expand_builtin_setjmp_receiver (rtx);
- extern rtx expand_builtin_saveregs (void);
- extern void expand_builtin_trap (void);
- extern rtx builtin_strncpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
-
/* Functions from expr.c: */
/* This is run during target initialization to set up which modes can be
--- 252,257 ----
Index: tree.h
===================================================================
*** tree.h (revision 211131)
--- tree.h (working copy)
*************** extern tree build_call_valist (tree, tre
*** 3624,3629 ****
--- 3624,3634 ----
build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T3)
extern tree build_call_array_loc (location_t, tree, tree, int, const tree *);
extern tree build_call_vec (tree, tree, vec<tree, va_gc> *);
+ extern tree build_call_expr_loc_array (location_t, tree, int, tree *);
+ extern tree build_call_expr_loc_vec (location_t, tree, vec<tree, va_gc> *);
+ extern tree build_call_expr_loc (location_t, tree, int, ...);
+ extern tree build_call_expr (tree, int, ...);
+ extern tree build_string_literal (int, const char *);
/* Construct various nodes representing data types. */
*************** extern tree get_inner_reference (tree, H
*** 4745,4790 ****
EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
extern tree array_ref_low_bound (tree);
- /* In builtins.c. */
-
- /* Non-zero if __builtin_constant_p should be folded right away. */
- extern bool force_folding_builtin_constant_p;
-
- extern bool avoid_folding_inline_builtin (tree);
- extern tree fold_call_expr (location_t, tree, bool);
- extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree);
- extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree);
- extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree);
- extern tree fold_builtin_strcat (location_t, tree, tree, tree);
- extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree, tree, bool,
- enum built_in_function);
- extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, bool,
- enum built_in_function);
- extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree, bool,
- enum built_in_function);
- extern tree fold_builtin_expect (location_t, tree, tree, tree);
- extern bool fold_builtin_next_arg (tree, bool);
- extern enum built_in_function builtin_mathfn_code (const_tree);
- extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
- extern tree build_call_expr_loc_array (location_t, tree, int, tree *);
- extern tree build_call_expr_loc_vec (location_t, tree, vec<tree, va_gc> *);
- extern tree build_call_expr_loc (location_t, tree, int, ...);
- extern tree build_call_expr (tree, int, ...);
- extern tree mathfn_built_in (tree, enum built_in_function fn);
- extern tree c_strlen (tree, int);
- extern tree build_string_literal (int, const char *);
- extern rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
- extern bool is_builtin_fn (tree);
- extern bool get_object_alignment_1 (tree, unsigned int *,
- unsigned HOST_WIDE_INT *);
- extern unsigned int get_object_alignment (tree);
- extern bool get_pointer_alignment_1 (tree, unsigned int *,
- unsigned HOST_WIDE_INT *);
- extern unsigned int get_pointer_alignment (tree);
- extern tree fold_call_stmt (gimple, bool);
- extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum built_in_function);
- extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
- extern bool is_simple_builtin (tree);
- extern bool is_inexpensive_builtin (tree);
-
#endif /* GCC_TREE_H */
--- 4750,4753 ----
Index: builtins.h
===================================================================
*** builtins.h (revision 211131)
--- builtins.h (working copy)
*************** along with GCC; see the file COPYING3.
*** 20,25 ****
--- 20,27 ----
#ifndef GCC_BUILTINS_H
#define GCC_BUILTINS_H
+ #include <mpc.h>
+
/* Target-dependent globals. */
struct target_builtins {
/* For each register that may be used for calling a function, this
*************** extern struct target_builtins *this_targ
*** 44,49 ****
--- 46,99 ----
#define this_target_builtins (&default_target_builtins)
#endif
+ /* Non-zero if __builtin_constant_p should be folded right away. */
+ extern bool force_folding_builtin_constant_p;
+
+ extern bool is_builtin_fn (tree);
+ extern bool get_object_alignment_1 (tree, unsigned int *,
+ unsigned HOST_WIDE_INT *);
+ extern unsigned int get_object_alignment (tree);
+ extern bool get_pointer_alignment_1 (tree, unsigned int *,
+ unsigned HOST_WIDE_INT *);
+ extern unsigned int get_pointer_alignment (tree);
+ extern tree c_strlen (tree, int);
+ extern void expand_builtin_setjmp_setup (rtx, rtx);
+ extern void expand_builtin_setjmp_receiver (rtx);
+ extern tree mathfn_built_in (tree, enum built_in_function fn);
+ extern rtx builtin_strncpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
+ extern rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
+ extern rtx expand_builtin_saveregs (void);
+ extern tree std_build_builtin_va_list (void);
+ extern tree std_fn_abi_va_list (tree);
+ extern tree std_canonical_va_list_type (tree);
+ extern void std_expand_builtin_va_start (tree, rtx);
+ extern void expand_builtin_trap (void);
+ extern rtx expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+ extern enum built_in_function builtin_mathfn_code (const_tree);
+ extern tree fold_builtin_expect (location_t, tree, tree, tree);
+ extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree);
+ extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree);
+ extern tree fold_fma (location_t, tree, tree, tree, tree);
+ extern bool avoid_folding_inline_builtin (tree);
+ extern tree fold_call_expr (location_t, tree, bool);
+ extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
extern bool validate_gimple_arglist (const_gimple, ...);
+ extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+ extern tree fold_builtin_strcat (location_t, tree, tree, tree);
+ extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree);
+ extern bool fold_builtin_next_arg (tree, bool);
+ extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree,
+ tree, bool, enum built_in_function);
+ extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree,
+ bool, enum built_in_function);
+ extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree,
+ bool, enum built_in_function);
+ extern tree gimple_fold_builtin_snprintf_chk (gimple, tree,
+ enum built_in_function);
+ extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
+ extern tree fold_call_stmt (gimple, bool);
+ extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
+ extern bool is_simple_builtin (tree);
+ extern bool is_inexpensive_builtin (tree);
#endif
Index: builtins.c
===================================================================
*** builtins.c (revision 211131)
--- builtins.c (working copy)
*************** is_builtin_fn (tree decl)
*** 259,289 ****
return TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl);
}
- /* By default we assume that c99 functions are present at the runtime,
- but sincos is not. */
- bool
- default_libc_has_function (enum function_class fn_class)
- {
- if (fn_class == function_c94
- || fn_class == function_c99_misc
- || fn_class == function_c99_math_complex)
- return true;
-
- return false;
- }
-
- bool
- gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
- {
- return true;
- }
-
- bool
- no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
- {
- return false;
- }
-
/* Return true if NODE should be considered for inline expansion regardless
of the optimization level. This means whenever a function is invoked with
its "internal" name, which normally contains the prefix "__builtin". */
--- 259,264 ----
*************** expand_builtin_copysign (tree exp, rtx t
*** 4690,4718 ****
return expand_copysign (op0, op1, target);
}
- /* Create a new constant string literal and return a char* pointer to it.
- The STRING_CST value is the LEN characters at STR. */
- tree
- build_string_literal (int len, const char *str)
- {
- tree t, elem, index, type;
-
- t = build_string (len, str);
- elem = build_type_variant (char_type_node, 1, 0);
- index = build_index_type (size_int (len - 1));
- type = build_array_type (elem, index);
- TREE_TYPE (t) = type;
- TREE_CONSTANT (t) = 1;
- TREE_READONLY (t) = 1;
- TREE_STATIC (t) = 1;
-
- type = build_pointer_type (elem);
- t = build1 (ADDR_EXPR, type,
- build4 (ARRAY_REF, elem,
- t, integer_zero_node, NULL_TREE, NULL_TREE));
- return t;
- }
-
/* Expand a call to __builtin___clear_cache. */
static rtx
--- 4665,4670 ----
*************** fold_call_expr (location_t loc, tree exp
*** 11159,11224 ****
return NULL_TREE;
}
- /* Conveniently construct a function call expression. FNDECL names the
- function to be called and N arguments are passed in the array
- ARGARRAY. */
-
- tree
- build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
- {
- tree fntype = TREE_TYPE (fndecl);
- tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
-
- return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
- }
-
- /* Conveniently construct a function call expression. FNDECL names the
- function to be called and the arguments are passed in the vector
- VEC. */
-
- tree
- build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
- {
- return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
- vec_safe_address (vec));
- }
-
-
- /* Conveniently construct a function call expression. FNDECL names the
- function to be called, N is the number of arguments, and the "..."
- parameters are the argument expressions. */
-
- tree
- build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
- {
- va_list ap;
- tree *argarray = XALLOCAVEC (tree, n);
- int i;
-
- va_start (ap, n);
- for (i = 0; i < n; i++)
- argarray[i] = va_arg (ap, tree);
- va_end (ap);
- return build_call_expr_loc_array (loc, fndecl, n, argarray);
- }
-
- /* Like build_call_expr_loc (UNKNOWN_LOCATION, ...). Duplicated because
- varargs macros aren't supported by all bootstrap compilers. */
-
- tree
- build_call_expr (tree fndecl, int n, ...)
- {
- va_list ap;
- tree *argarray = XALLOCAVEC (tree, n);
- int i;
-
- va_start (ap, n);
- for (i = 0; i < n; i++)
- argarray[i] = va_arg (ap, tree);
- va_end (ap);
- return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
- }
-
/* Construct a CALL_EXPR with type TYPE with FN as the function expression.
N arguments are passed in the array ARGARRAY. */
--- 11111,11116 ----
*************** fold_builtin_snprintf (location_t loc, t
*** 12281,12287 ****
/* Expand a call EXP to __builtin_object_size. */
! rtx
expand_builtin_object_size (tree exp)
{
tree ost;
--- 12173,12179 ----
/* Expand a call EXP to __builtin_object_size. */
! static rtx
expand_builtin_object_size (tree exp)
{
tree ost;
*************** maybe_emit_free_warning (tree exp)
*** 12586,12592 ****
/* Fold a call to __builtin_object_size with arguments PTR and OST,
if possible. */
! tree
fold_builtin_object_size (tree ptr, tree ost)
{
unsigned HOST_WIDE_INT bytes;
--- 12478,12484 ----
/* Fold a call to __builtin_object_size with arguments PTR and OST,
if possible. */
! static tree
fold_builtin_object_size (tree ptr, tree ost)
{
unsigned HOST_WIDE_INT bytes;
Index: targhooks.c
===================================================================
*** targhooks.c (revision 211131)
--- targhooks.c (working copy)
*************** default_have_conditional_execution (void
*** 1322,1327 ****
--- 1322,1352 ----
#endif
}
+ /* By default we assume that c99 functions are present at the runtime,
+ but sincos is not. */
+ bool
+ default_libc_has_function (enum function_class fn_class)
+ {
+ if (fn_class == function_c94
+ || fn_class == function_c99_misc
+ || fn_class == function_c99_math_complex)
+ return true;
+
+ return false;
+ }
+
+ bool
+ gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+ {
+ return true;
+ }
+
+ bool
+ no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+ {
+ return false;
+ }
+
tree
default_builtin_tm_load_store (tree ARG_UNUSED (type))
{
Index: tree.c
===================================================================
*** tree.c (revision 211131)
--- tree.c (working copy)
*************** along with GCC; see the file COPYING3.
*** 76,81 ****
--- 76,82 ----
#include "debug.h"
#include "intl.h"
#include "wide-int.h"
+ #include "builtins.h"
/* Tree code classes. */
*************** build_call_vec (tree return_type, tree f
*** 10467,10472 ****
--- 10468,10558 ----
return ret;
}
+ /* Conveniently construct a function call expression. FNDECL names the
+ function to be called and N arguments are passed in the array
+ ARGARRAY. */
+
+ tree
+ build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
+ {
+ tree fntype = TREE_TYPE (fndecl);
+ tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+
+ return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
+ }
+
+ /* Conveniently construct a function call expression. FNDECL names the
+ function to be called and the arguments are passed in the vector
+ VEC. */
+
+ tree
+ build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
+ {
+ return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
+ vec_safe_address (vec));
+ }
+
+
+ /* Conveniently construct a function call expression. FNDECL names the
+ function to be called, N is the number of arguments, and the "..."
+ parameters are the argument expressions. */
+
+ tree
+ build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
+ {
+ va_list ap;
+ tree *argarray = XALLOCAVEC (tree, n);
+ int i;
+
+ va_start (ap, n);
+ for (i = 0; i < n; i++)
+ argarray[i] = va_arg (ap, tree);
+ va_end (ap);
+ return build_call_expr_loc_array (loc, fndecl, n, argarray);
+ }
+
+ /* Like build_call_expr_loc (UNKNOWN_LOCATION, ...). Duplicated because
+ varargs macros aren't supported by all bootstrap compilers. */
+
+ tree
+ build_call_expr (tree fndecl, int n, ...)
+ {
+ va_list ap;
+ tree *argarray = XALLOCAVEC (tree, n);
+ int i;
+
+ va_start (ap, n);
+ for (i = 0; i < n; i++)
+ argarray[i] = va_arg (ap, tree);
+ va_end (ap);
+ return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
+ }
+
+ /* Create a new constant string literal and return a char* pointer to it.
+ The STRING_CST value is the LEN characters at STR. */
+ tree
+ build_string_literal (int len, const char *str)
+ {
+ tree t, elem, index, type;
+
+ t = build_string (len, str);
+ elem = build_type_variant (char_type_node, 1, 0);
+ index = build_index_type (size_int (len - 1));
+ type = build_array_type (elem, index);
+ TREE_TYPE (t) = type;
+ TREE_CONSTANT (t) = 1;
+ TREE_READONLY (t) = 1;
+ TREE_STATIC (t) = 1;
+
+ type = build_pointer_type (elem);
+ t = build1 (ADDR_EXPR, type,
+ build4 (ARRAY_REF, elem,
+ t, integer_zero_node, NULL_TREE, NULL_TREE));
+ return t;
+ }
+
+
+
/* Return true if T (assumed to be a DECL) must be assigned a memory
location. */
Index: fold-const.h
===================================================================
*** fold-const.h (revision 211131)
--- fold-const.h (working copy)
*************** extern void fold_defer_overflow_warnings
*** 85,91 ****
extern void fold_undefer_overflow_warnings (bool, const_gimple, int);
extern void fold_undefer_and_ignore_overflow_warnings (void);
extern bool fold_deferring_overflow_warnings_p (void);
- extern tree fold_fma (location_t, tree, tree, tree, tree);
extern int operand_equal_p (const_tree, const_tree, unsigned int);
extern int multiple_of_p (tree, const_tree, const_tree);
#define omit_one_operand(T1,T2,T3)\
--- 85,90 ----
Index: realmpfr.h
===================================================================
*** realmpfr.h (revision 211131)
--- realmpfr.h (working copy)
***************
*** 25,33 ****
#include <mpc.h>
#include "real.h"
- /* In builtins.c. */
- extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
-
/* Convert between MPFR and REAL_VALUE_TYPE. The caller is
responsible for initializing and clearing the MPFR parameter. */
--- 25,30 ----
Index: fortran/trans.c
===================================================================
*** fortran/trans.c (revision 211131)
--- fortran/trans.c (working copy)
*************** trans_runtime_error_vararg (bool error,
*** 450,462 ****
fntype = TREE_TYPE (gfor_fndecl_runtime_warning_at);
loc = where ? where->lb->location : input_location;
! tmp = fold_builtin_call_array (loc, TREE_TYPE (fntype),
! fold_build1_loc (loc, ADDR_EXPR,
build_pointer_type (fntype),
error
? gfor_fndecl_runtime_error_at
: gfor_fndecl_runtime_warning_at),
! nargs + 2, argarray);
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
--- 450,462 ----
fntype = TREE_TYPE (gfor_fndecl_runtime_warning_at);
loc = where ? where->lb->location : input_location;
! tmp = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
! fold_build1_loc (loc, ADDR_EXPR,
build_pointer_type (fntype),
error
? gfor_fndecl_runtime_error_at
: gfor_fndecl_runtime_warning_at),
! nargs + 2, argarray);
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);