This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Get rid of some further varargs macros (PR bootstrap/44426)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 14 Jun 2010 17:33:01 +0200
- Subject: [PATCH] Get rid of some further varargs macros (PR bootstrap/44426)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This patch gets rid of the remaining #define xxx(...) macros
(after the sel_print* patch).
build_call_nofold has been used just 11 times, all in builtins.c and
generally it was easy to find out the right locus to use.
build_call_expr is used more than 3 times that often, so the patch
just duplicates the short function.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2010-06-14 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/44426
* tree.h (build_call_expr): Don't define as vararg macro, instead
add a prototype.
* builtins.c (build_call_nofold): Remove.
(expand_builtin_int_roundingfn, expand_builtin_pow,
expand_builtin_mempcpy_args, expand_builtin_stpcpy,
expand_builtin_memset_args, expand_builtin_strcmp,
expand_builtin_strncmp, expand_builtin_memory_chk): Use
build_call_nofold_loc instead of build_call_nofold.
(build_call_expr): New function.
--- gcc/tree.h.jj 2010-06-14 07:44:24.000000000 +0200
+++ gcc/tree.h 2010-06-14 13:32:36.000000000 +0200
@@ -5017,9 +5017,8 @@ extern bool fold_builtin_next_arg (tree,
extern enum built_in_function builtin_mathfn_code (const_tree);
extern tree build_function_call_expr (location_t, tree, tree);
extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
-#define build_call_expr(...)\
- build_call_expr_loc (UNKNOWN_LOCATION, __VA_ARGS__)
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 std_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *);
--- gcc/builtins.c.jj 2010-06-01 12:27:48.000000000 +0200
+++ gcc/builtins.c 2010-06-14 14:01:08.000000000 +0200
@@ -2521,8 +2521,6 @@ build_call_nofold_loc (location_t loc, t
SET_EXPR_LOCATION (fn, loc);
return fn;
}
-#define build_call_nofold(...) \
- build_call_nofold_loc (UNKNOWN_LOCATION, __VA_ARGS__)
/* Expand a call to one of the builtin rounding functions gcc defines
as an extension (lfloor and lceil). As these are gcc extensions we
@@ -2640,7 +2638,7 @@ expand_builtin_int_roundingfn (tree exp,
fallback_fndecl = build_fn_decl (name, fntype);
}
- exp = build_call_nofold (fallback_fndecl, 1, arg);
+ exp = build_call_nofold_loc (EXPR_LOCATION (exp), fallback_fndecl, 1, arg);
tmp = expand_normal (exp);
@@ -3085,7 +3083,8 @@ expand_builtin_pow (tree exp, rtx target
&& (optab_handler (sqrt_optab, mode)->insn_code
!= CODE_FOR_nothing))))
{
- tree call_expr = build_call_nofold (fn, 1, narg0);
+ tree call_expr = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 1,
+ narg0);
/* Use expand_expr in case the newly built call expression
was folded to a non-call. */
op = expand_expr (call_expr, subtarget, mode, EXPAND_NORMAL);
@@ -3137,7 +3136,8 @@ expand_builtin_pow (tree exp, rtx target
&& powi_cost (n/3) <= POWI_MAX_MULTS)
|| n == 1))
{
- tree call_expr = build_call_nofold (fn, 1,narg0);
+ tree call_expr = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 1,
+ narg0);
op = expand_builtin (call_expr, NULL_RTX, subtarget, mode, 0);
if (abs (n) % 3 == 2)
op = expand_simple_binop (mode, MULT, op, op, op,
@@ -3471,7 +3471,8 @@ expand_builtin_mempcpy_args (tree dest,
if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_MEMCPY])
{
tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
- tree result = build_call_nofold (fn, 3, dest, src, len);
+ tree result = build_call_nofold_loc (UNKNOWN_LOCATION, fn, 3,
+ dest, src, len);
return expand_expr (result, target, mode, EXPAND_NORMAL);
}
else
@@ -3652,7 +3653,7 @@ expand_builtin_stpcpy (tree exp, rtx tar
if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_STRCPY])
{
tree fn = implicit_built_in_decls[BUILT_IN_STRCPY];
- tree result = build_call_nofold (fn, 2, dst, src);
+ tree result = build_call_nofold_loc (loc, fn, 2, dst, src);
return expand_expr (result, target, mode, EXPAND_NORMAL);
}
else
@@ -3955,9 +3956,11 @@ expand_builtin_memset_args (tree dest, t
fndecl = get_callee_fndecl (orig_exp);
fcode = DECL_FUNCTION_CODE (fndecl);
if (fcode == BUILT_IN_MEMSET)
- fn = build_call_nofold (fndecl, 3, dest, val, len);
+ fn = build_call_nofold_loc (EXPR_LOCATION (orig_exp), fndecl, 3,
+ dest, val, len);
else if (fcode == BUILT_IN_BZERO)
- fn = build_call_nofold (fndecl, 2, dest, len);
+ fn = build_call_nofold_loc (EXPR_LOCATION (orig_exp), fndecl, 2,
+ dest, len);
else
gcc_unreachable ();
gcc_assert (TREE_CODE (fn) == CALL_EXPR);
@@ -4230,7 +4233,7 @@ expand_builtin_strcmp (tree exp, ATTRIBU
do_libcall:
#endif
fndecl = get_callee_fndecl (exp);
- fn = build_call_nofold (fndecl, 2, arg1, arg2);
+ fn = build_call_nofold_loc (EXPR_LOCATION (exp), fndecl, 2, arg1, arg2);
gcc_assert (TREE_CODE (fn) == CALL_EXPR);
CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp);
return expand_call (fn, target, target == const0_rtx);
@@ -4352,7 +4355,8 @@ expand_builtin_strncmp (tree exp, ATTRIB
/* Expand the library call ourselves using a stabilized argument
list to avoid re-evaluating the function's arguments twice. */
fndecl = get_callee_fndecl (exp);
- fn = build_call_nofold (fndecl, 3, arg1, arg2, len);
+ fn = build_call_nofold_loc (EXPR_LOCATION (exp), fndecl, 3,
+ arg1, arg2, len);
gcc_assert (TREE_CODE (fn) == CALL_EXPR);
CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp);
return expand_call (fn, target, target == const0_rtx);
@@ -10758,6 +10762,26 @@ build_call_expr_loc (location_t loc, tre
return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, 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 fntype = TREE_TYPE (fndecl);
+ tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ tree *argarray = (tree *) alloca (n * sizeof (tree));
+ int i;
+
+ va_start (ap, n);
+ for (i = 0; i < n; i++)
+ argarray[i] = va_arg (ap, tree);
+ va_end (ap);
+ return fold_builtin_call_array (UNKNOWN_LOCATION, TREE_TYPE (fntype),
+ fn, n, argarray);
+}
+
/* Construct a CALL_EXPR with type TYPE with FN as the function expression.
N arguments are passed in the array ARGARRAY. */
@@ -11848,7 +11872,7 @@ expand_builtin_memory_chk (tree exp, rtx
if (! fn)
return NULL_RTX;
- fn = build_call_nofold (fn, 3, dest, src, len);
+ fn = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 3, dest, src, len);
gcc_assert (TREE_CODE (fn) == CALL_EXPR);
CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp);
return expand_expr (fn, target, mode, EXPAND_NORMAL);
@@ -11896,7 +11920,8 @@ expand_builtin_memory_chk (tree exp, rtx
tree fn = built_in_decls[BUILT_IN_MEMCPY_CHK];
if (!fn)
return NULL_RTX;
- fn = build_call_nofold (fn, 4, dest, src, len, size);
+ fn = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 4,
+ dest, src, len, size);
gcc_assert (TREE_CODE (fn) == CALL_EXPR);
CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp);
return expand_expr (fn, target, mode, EXPAND_NORMAL);
Jakub