summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog22
-rw-r--r--gcc/builtins.c22
-rw-r--r--gcc/config/alpha/alpha.c21
-rw-r--r--gcc/config/sparc/sparc.c21
-rw-r--r--gcc/config/xtensa/xtensa.c9
-rw-r--r--gcc/doc/tm.texi10
-rw-r--r--gcc/hooks.c7
-rw-r--r--gcc/hooks.h2
-rw-r--r--gcc/target-def.h2
-rw-r--r--gcc/target.h2
10 files changed, 69 insertions, 49 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4167712f49b..d9a89d7950d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,25 @@
+2010-05-19 Nathan Froyd <froydnj@codesourcery.com>
+
+ * hooks.h (hook_tree_tree_tree_bool_null): Rename to...
+ (hook_tree_tree_int_treep_bool_null): ...this. Update signature.
+ * hooks.c: Likewise.
+ * target-def.h (TARGET_FOLD_BUILTIN): Define to
+ hook_tree_tree_int_treep_bool_null.
+ * target.h: (struct gcc_target): Update signature of fold_builtin
+ field.
+ * doc/tm.texi (TARGET_FOLD_BUILTIN): Update description and signature.
+ * builtins.c (fold_call_expr): Pass call_expr_nargs and CALL_EXPR_ARGP
+ instead of the call expression.
+ (fold_builtin_call_array): Pass n and argarray directly.
+ (fold_call_stmt): Pass nargs and gimple_call_arg_ptr instead of
+ consing a list.
+ * config/alpha/alpha.c (alpha_fold_builtin): Update signature. Lift
+ MAX_ARGS check out of the loop. Delete declaration of `arity', declare
+ `i' and use it in place of `arity'.
+ * config/sparc/sparc.c (sparc_fold_builtin): Update signature.
+ Dereference `args' directly.
+ * config/xtensa/xtensa (xtensa_fold_builtin): Likewise.
+
2010-05-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* doc/sourcebuild.texi (Effective-Target Keywords): Document
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8541b829801..6ad95adbc00 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -10702,7 +10702,8 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
return NULL_TREE;
if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
- return targetm.fold_builtin (fndecl, exp, ignore);
+ return targetm.fold_builtin (fndecl, call_expr_nargs (exp),
+ CALL_EXPR_ARGP (exp), ignore);
else
{
if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN)
@@ -10766,7 +10767,6 @@ fold_builtin_call_array (location_t loc, tree type,
tree *argarray)
{
tree ret = NULL_TREE;
- int i;
tree exp;
if (TREE_CODE (fn) == ADDR_EXPR)
@@ -10790,12 +10790,10 @@ fold_builtin_call_array (location_t loc, tree type,
return build_call_array_loc (loc, type, fn, n, argarray);
if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
{
- tree arglist = NULL_TREE;
- for (i = n - 1; i >= 0; i--)
- arglist = tree_cons (NULL_TREE, argarray[i], arglist);
- ret = targetm.fold_builtin (fndecl, arglist, false);
- if (ret)
- return ret;
+ ret = targetm.fold_builtin (fndecl, n, argarray, false);
+ if (ret)
+ return ret;
+
return build_call_array_loc (loc, type, fn, n, argarray);
}
else if (n <= MAX_ARGS_TO_FOLD_BUILTIN)
@@ -13698,14 +13696,10 @@ fold_call_stmt (gimple stmt, bool ignore)
if (avoid_folding_inline_builtin (fndecl))
return NULL_TREE;
- /* FIXME: Don't use a list in this interface. */
if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
{
- tree arglist = NULL_TREE;
- int i;
- for (i = nargs - 1; i >= 0; i--)
- arglist = tree_cons (NULL_TREE, gimple_call_arg (stmt, i), arglist);
- return targetm.fold_builtin (fndecl, arglist, ignore);
+ return targetm.fold_builtin (fndecl, nargs,
+ gimple_call_arg_ptr (stmt, 0), ignore);
}
else
{
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 764326728e7..2cc173f589a 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -7138,26 +7138,27 @@ alpha_fold_builtin_ctpop (unsigned HOST_WIDE_INT opint[], long op_const)
/* Fold one of our builtin functions. */
static tree
-alpha_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
+alpha_fold_builtin (tree fndecl, int n_args, tree *op,
+ bool ignore ATTRIBUTE_UNUSED)
{
- tree *op = CALL_EXPR_ARGP (call);
unsigned HOST_WIDE_INT opint[MAX_ARGS];
long op_const = 0;
- int arity;
+ int i;
- for (i = 0; i < call_expr_nargs (call); i++)
+ if (n_args >= MAX_ARGS)
+ return NULL;
+
+ for (i = 0; i < n_args; i++)
{
- tree arg = CALL_EXPR_ARG (call, i);
+ tree arg = op[i];
if (arg == error_mark_node)
return NULL;
- if (arity >= MAX_ARGS)
- return NULL;
- opint[arity] = 0;
+ opint[i] = 0;
if (TREE_CODE (arg) == INTEGER_CST)
{
- op_const |= 1L << arity;
- opint[arity] = int_cst_value (arg);
+ op_const |= 1L << i;
+ opint[i] = int_cst_value (arg);
}
}
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 856431285df..9f9e20beb10 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -386,7 +386,7 @@ static void sparc_init_libfuncs (void);
static void sparc_init_builtins (void);
static void sparc_vis_init_builtins (void);
static rtx sparc_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
-static tree sparc_fold_builtin (tree, tree, bool);
+static tree sparc_fold_builtin (tree, int, tree *, bool);
static int sparc_vis_mul8x16 (int, int);
static tree sparc_handle_vis_mul8x16 (int, tree, tree, tree);
static void sparc_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
@@ -8372,7 +8372,8 @@ sparc_handle_vis_mul8x16 (int fncode, tree inner_type, tree elts0, tree elts1)
function could not be folded. */
static tree
-sparc_fold_builtin (tree fndecl, tree call, bool ignore)
+sparc_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED,
+ tree *args, bool ignore)
{
tree arg0, arg1, arg2;
tree rtype = TREE_TYPE (TREE_TYPE (fndecl));
@@ -8386,7 +8387,7 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
switch (icode)
{
case CODE_FOR_fexpand_vis:
- arg0 = CALL_EXPR_ARG (call, 0);
+ arg0 = args[0];
STRIP_NOPS (arg0);
if (TREE_CODE (arg0) == VECTOR_CST)
@@ -8409,8 +8410,8 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
case CODE_FOR_fmul8x16_vis:
case CODE_FOR_fmul8x16au_vis:
case CODE_FOR_fmul8x16al_vis:
- arg0 = CALL_EXPR_ARG (call, 0);
- arg1 = CALL_EXPR_ARG (call, 1);
+ arg0 = args[0];
+ arg1 = args[1];
STRIP_NOPS (arg0);
STRIP_NOPS (arg1);
@@ -8427,8 +8428,8 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
break;
case CODE_FOR_fpmerge_vis:
- arg0 = CALL_EXPR_ARG (call, 0);
- arg1 = CALL_EXPR_ARG (call, 1);
+ arg0 = args[0];
+ arg1 = args[1];
STRIP_NOPS (arg0);
STRIP_NOPS (arg1);
@@ -8450,9 +8451,9 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
break;
case CODE_FOR_pdist_vis:
- arg0 = CALL_EXPR_ARG (call, 0);
- arg1 = CALL_EXPR_ARG (call, 1);
- arg2 = CALL_EXPR_ARG (call, 2);
+ arg0 = args[0];
+ arg1 = args[1];
+ arg2 = args[2];
STRIP_NOPS (arg0);
STRIP_NOPS (arg1);
STRIP_NOPS (arg2);
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index fac7e517ad2..97b941d5021 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -142,7 +142,7 @@ static tree xtensa_gimplify_va_arg_expr (tree, tree, gimple_seq *,
gimple_seq *);
static rtx xtensa_function_value (const_tree, const_tree, bool);
static void xtensa_init_builtins (void);
-static tree xtensa_fold_builtin (tree, tree, bool);
+static tree xtensa_fold_builtin (tree, int, tree *, bool);
static rtx xtensa_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
static void xtensa_va_start (tree, rtx);
static bool xtensa_frame_pointer_required (void);
@@ -3000,7 +3000,8 @@ xtensa_init_builtins (void)
static tree
-xtensa_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
+xtensa_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *args,
+ bool ignore ATTRIBUTE_UNUSED)
{
unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
tree arg0, arg1;
@@ -3008,8 +3009,8 @@ xtensa_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
switch (fcode)
{
case XTENSA_BUILTIN_UMULSIDI3:
- arg0 = CALL_EXPR_ARG (call, 0);
- arg1 = CALL_EXPR_ARG (call, 1);
+ arg0 = args[0];
+ arg1 = args[1];
if ((TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
|| TARGET_MUL32_HIGH)
return fold_build2 (MULT_EXPR, unsigned_intDI_type_node,
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8f9bbe7933a..80e28a34b90 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -10784,14 +10784,14 @@ another @code{CALL_EXPR}.
@var{arglist} really has type @samp{VEC(tree,gc)*}
@end deftypefn
-@deftypefn {Target Hook} tree TARGET_FOLD_BUILTIN (tree @var{fndecl}, tree @var{call}, bool @var{ignore})
+@deftypefn {Target Hook} tree TARGET_FOLD_BUILTIN (tree @var{fndecl}, int @var{n_args}, tree *@var{argp}, bool @var{ignore})
Fold a call to a machine specific built-in function that was set up by
@samp{TARGET_INIT_BUILTINS}. @var{fndecl} is the declaration of the
-built-in function. @var{call} is the @code{CALL_EXPR} representing
-the call. The result is another tree containing a
-simplified expression for the call's result. If @var{ignore} is true
-the value will be ignored.
+built-in function. @var{n_args} is the number of arguments passed to
+the function; the arguments themselves are pointed to by @var{argp}.
+The result is another tree containing a simplified expression for the
+call's result. If @var{ignore} is true the value will be ignored.
@end deftypefn
@deftypefn {Target Hook} {const char *} TARGET_INVALID_WITHIN_DOLOOP (const_rtx @var{insn})
diff --git a/gcc/hooks.c b/gcc/hooks.c
index aac44485898..97e10646088 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -299,9 +299,10 @@ hook_constcharptr_const_tree_null (const_tree t ATTRIBUTE_UNUSED)
}
tree
-hook_tree_tree_tree_bool_null (tree t0 ATTRIBUTE_UNUSED,
- tree t1 ATTRIBUTE_UNUSED,
- bool ignore ATTRIBUTE_UNUSED)
+hook_tree_tree_int_treep_bool_null (tree t0 ATTRIBUTE_UNUSED,
+ int i ATTRIBUTE_UNUSED,
+ tree *p ATTRIBUTE_UNUSED,
+ bool ignore ATTRIBUTE_UNUSED)
{
return NULL;
}
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 5fd8296c75a..50280628ab8 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -71,7 +71,7 @@ extern tree hook_tree_const_tree_null (const_tree);
extern tree hook_tree_tree_tree_null (tree, tree);
extern tree hook_tree_tree_tree_tree_null (tree, tree, tree);
extern tree hook_tree_tree_tree_tree_3rd_identity (tree, tree, tree);
-extern tree hook_tree_tree_tree_bool_null (tree, tree, bool);
+extern tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
extern unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **);
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 3ead3702047..09da722b8d9 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -456,7 +456,7 @@
#define TARGET_INIT_BUILTINS hook_void_void
#define TARGET_EXPAND_BUILTIN default_expand_builtin
#define TARGET_RESOLVE_OVERLOADED_BUILTIN NULL
-#define TARGET_FOLD_BUILTIN hook_tree_tree_tree_bool_null
+#define TARGET_FOLD_BUILTIN hook_tree_tree_int_treep_bool_null
#define TARGET_BUILTIN_DECL NULL
/* In tree-ssa-math-opts.c */
diff --git a/gcc/target.h b/gcc/target.h
index 29ec84f1a48..744790061a2 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -616,7 +616,7 @@ struct gcc_target
tree decl, void *params);
/* Fold a target-specific builtin. */
- tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore);
+ tree (* fold_builtin) (tree fndecl, int nargs, tree *argp, bool ignore);
/* Returns a code for a target-specific builtin that implements
reciprocal of the function, or NULL_TREE if not available. */