aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2007-02-28 14:21:20 -0500
committerSandra Loosemore <sandra@gcc.gnu.org>2007-02-28 14:21:20 -0500
commit94a0dd7b599e1d83b81f007258af2b16e7cbc4c5 (patch)
tree34dad42b40269284ec633fd80ce8a06342ba7ea3 /gcc/builtins.c
parent76bf4853ce24034b8489b3b5ba56d1de50203ea5 (diff)
downloadgcc-94a0dd7b599e1d83b81f007258af2b16e7cbc4c5.zip
gcc-94a0dd7b599e1d83b81f007258af2b16e7cbc4c5.tar.gz
gcc-94a0dd7b599e1d83b81f007258af2b16e7cbc4c5.tar.bz2
builtins.c (fold_builtin_call_list, [...]): Delete, and replace with...
2007-02-28 Sandra Loosemore <sandra@codesourcery.com> * gcc/builtins.c (fold_builtin_call_list, fold_builtin_call_valist): Delete, and replace with... (fold_builtin_call_array): This. Update callers to use it. * gcc/fold-const.c (fold_build_call_list): Delete, and replace with... (fold_build_call_array): This. (fold_build_call_list_initializer): Delete, and replace with... (fold_build_call_array_initializer): This. * gcc/tree.h: Update declarations to reflect above changes. * gcc/c-typeck.c (build_function_call): Store converted arguments in a stack-allocated array instead of building a list. (convert_arguments): Store arguments in the array passed in as an argument, and return the actual number of arguments. * gcc/c-format.c: (check_function_format): Pass arguments in an array instead of a list. * gcc/c-common.c (check_function_nonnull): Likewise. (check_function_sentinel): Likewise. (check_function_arguments): Likewise. * gcc/c-common.h: Update declarations to reflect above changes. * gcc/cp/typeck.c (build_function_call): Store converted arguments in a stack-allocated array instead of building a list. (convert_arguments): Store arguments in the array passed in as an argument, and return the actual number of arguments. * gcc/cp/call.c (build_call): Delete, and replace with... (build_call_n, build_call_a): New. (build_op_delete_call): Rewrite to avoid constructing argument lists. (build_over_call): Store converted arguments in a stack-allocated array instead of building a list. (build_cxx_call): Pass arguments in an array instead of as a list. (build_java_interface_fn_ref): Rewrite to avoid constructing argument lists. * gcc/cp/tree.h: Update declarations to reflect above changes. * gcc/cp/method.c (use_thunk): Use a stack-allocated array to hold the arguments instead of a list. * gcc/cp/rtti.c (throw_bad_cast): Update call to cxx_call. (throw_bad_typeid): Likewise. (build_dynamic_cast_1): Likewise. * gcc/cp/init.c (build_builtin_delete_call): Use build_call_n. * gcc/cp/decl.c (expand_static_init): Likewise. * gcc/cp/except.c (cp_protect_cleanup_actions): Likewise. * gcc/cp/cp-gimplify.c (genericize_eh_spec_block): Likewise. (gimplify_must_not_throw_expr): Likewise. (cxx_omp_apply_fn): Use build_call_a. From-SVN: r122411
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c98
1 files changed, 22 insertions, 76 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 3e1ab59..676b9ca 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -10124,56 +10124,13 @@ build_function_call_expr (tree fndecl, tree arglist)
{
tree fntype = TREE_TYPE (fndecl);
tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
- return fold_builtin_call_list (TREE_TYPE (fntype), fn, arglist);
-}
-
-/* Construct a CALL_EXPR with type TYPE with FN as the function expression.
- ARGLIST is a TREE_LIST of arguments. */
-
-tree
-fold_builtin_call_list (tree type, tree fn, tree arglist)
-{
- tree ret = NULL_TREE;
- if (TREE_CODE (fn) == ADDR_EXPR)
- {
- tree fndecl = TREE_OPERAND (fn, 0);
- if (TREE_CODE (fndecl) == FUNCTION_DECL
- && DECL_BUILT_IN (fndecl))
- {
- /* FIXME: Don't use a list in this interface. */
- if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
- {
- ret = targetm.fold_builtin (fndecl, arglist, false);
- if (ret)
- return ret;
- }
- else
- {
- tree tail = arglist;
- tree args[MAX_ARGS_TO_FOLD_BUILTIN];
- int nargs;
- tree exp;
-
- for (nargs = 0; nargs < MAX_ARGS_TO_FOLD_BUILTIN; nargs++)
- {
- if (!tail)
- break;
- args[nargs] = TREE_VALUE (tail);
- tail = TREE_CHAIN (tail);
- }
- if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN)
- {
- ret = fold_builtin_n (fndecl, args, nargs, false);
- if (ret)
- return ret;
- }
- exp = build_call_list (type, fn, arglist);
- ret = fold_builtin_varargs (fndecl, exp, false);
- return ret ? ret : exp;
- }
- }
- }
- return build_call_list (type, fn, arglist);
+ int n = list_length (arglist);
+ tree *argarray = (tree *) alloca (n * sizeof (tree));
+ int i;
+
+ for (i = 0; i < n; i++, arglist = TREE_CHAIN (arglist))
+ argarray[i] = TREE_VALUE (arglist);
+ return fold_builtin_call_array (TREE_TYPE (fntype), fn, n, argarray);
}
/* Conveniently construct a function call expression. FNDECL names the
@@ -10184,24 +10141,26 @@ tree
build_call_expr (tree fndecl, int n, ...)
{
va_list ap;
- tree ret;
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);
- ret = fold_builtin_call_valist (TREE_TYPE (fntype), fn, n, ap);
+ for (i = 0; i < n; i++)
+ argarray[i] = va_arg (ap, tree);
va_end (ap);
- return ret;
+ return fold_builtin_call_array (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 va_list AP. */
+ N arguments are passed in the array ARGARRAY. */
tree
-fold_builtin_call_valist (tree type,
- tree fn,
- int n,
- va_list ap)
+fold_builtin_call_array (tree type,
+ tree fn,
+ int n,
+ tree *argarray)
{
tree ret = NULL_TREE;
int i;
@@ -10216,15 +10175,8 @@ fold_builtin_call_valist (tree type,
if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
{
tree arglist = NULL_TREE;
- va_list ap0;
- va_copy (ap0, ap);
- for (i = 0; i < n; i++)
- {
- tree arg = va_arg (ap0, tree);
- arglist = tree_cons (NULL_TREE, arg, arglist);
- }
- va_end (ap0);
- arglist = nreverse (arglist);
+ 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;
@@ -10233,25 +10185,19 @@ fold_builtin_call_valist (tree type,
{
/* First try the transformations that don't require consing up
an exp. */
- tree args[MAX_ARGS_TO_FOLD_BUILTIN];
- va_list ap0;
- va_copy (ap0, ap);
- for (i = 0; i < n; i++)
- args[i] = va_arg (ap0, tree);
- va_end (ap0);
- ret = fold_builtin_n (fndecl, args, n, false);
+ ret = fold_builtin_n (fndecl, argarray, n, false);
if (ret)
return ret;
}
/* If we got this far, we need to build an exp. */
- exp = build_call_valist (type, fn, n, ap);
+ exp = build_call_array (type, fn, n, argarray);
ret = fold_builtin_varargs (fndecl, exp, false);
return ret ? ret : exp;
}
}
- return build_call_valist (type, fn, n, ap);
+ return build_call_array (type, fn, n, argarray);
}
/* Construct a new CALL_EXPR using the tail of the argument list of EXP