summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-21 14:35:08 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-21 14:35:08 +0000
commit4a4d48d5d8e969366d5109f5508b3bb53f0693a9 (patch)
treec303459a3f6f0861fbf059f297c852a327157fb1
parent8666c3913a18243341907aa05523d93f97d5610f (diff)
downloadgcc-4a4d48d5d8e969366d5109f5508b3bb53f0693a9.tar.gz
* builtins.c (fold_builtin): Take decomposed arguments of
CALL_EXPR. * fold-const.c (fold_ternary): Update a call to fold_builtin. * gimplify.c (gimplify_call_expr): Likewise. * tree-ssa-ccp.c (ccp_fold, ccp_fold_builtin): Likewise. * tree.h: Update the prototype of fold_builtin. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96800 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/builtins.c7
-rw-r--r--gcc/fold-const.c4
-rw-r--r--gcc/gimplify.c10
-rw-r--r--gcc/tree-ssa-ccp.c11
-rw-r--r--gcc/tree.h2
6 files changed, 28 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0d36343d2fe..7adad7cbcf3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2005-03-21 Kazu Hirata <kazu@cs.umass.edu>
+
+ * builtins.c (fold_builtin): Take decomposed arguments of
+ CALL_EXPR.
+ * fold-const.c (fold_ternary): Update a call to fold_builtin.
+ * gimplify.c (gimplify_call_expr): Likewise.
+ * tree-ssa-ccp.c (ccp_fold, ccp_fold_builtin): Likewise.
+ * tree.h: Update the prototype of fold_builtin.
+
2005-03-21 Paolo Bonzini <bonzini@gnu.org>
* rtl.h (struct rtx_hooks): Add gen_lowpart_no_emit.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index e326c15376b..94fa62755f5 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8296,12 +8296,9 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore)
call node earlier than the warning is generated. */
tree
-fold_builtin (tree exp, bool ignore)
+fold_builtin (tree fndecl, tree arglist, bool ignore)
{
- tree fndecl = get_callee_fndecl (exp);
- tree arglist = TREE_OPERAND (exp, 1);
-
- exp = fold_builtin_1 (fndecl, arglist, ignore);
+ tree exp = fold_builtin_1 (fndecl, arglist, ignore);
if (exp)
{
/* ??? Don't clobber shared nodes such as integer_zero_node. */
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 848b167e9b7..2c4404b7676 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9909,7 +9909,9 @@ fold_ternary (tree expr)
&& TREE_CODE (TREE_OPERAND (op0, 0)) == FUNCTION_DECL
&& DECL_BUILT_IN (TREE_OPERAND (op0, 0)))
{
- tree tmp = fold_builtin (t, false);
+ tree fndecl = get_callee_fndecl (t);
+ tree arglist = TREE_OPERAND (t, 1);
+ tree tmp = fold_builtin (fndecl, arglist, false);
if (tmp)
return tmp;
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f16ff201694..b902ce1c97f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1744,7 +1744,9 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
decl = get_callee_fndecl (*expr_p);
if (decl && DECL_BUILT_IN (decl))
{
- tree new = fold_builtin (*expr_p, !want_value);
+ tree fndecl = get_callee_fndecl (*expr_p);
+ tree arglist = TREE_OPERAND (*expr_p, 1);
+ tree new = fold_builtin (fndecl, arglist, !want_value);
if (new && new != *expr_p)
{
@@ -1758,8 +1760,6 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_START)
{
- tree arglist = TREE_OPERAND (*expr_p, 1);
-
if (!arglist || !TREE_CHAIN (arglist))
{
error ("too few arguments to function %<va_start%>");
@@ -1802,7 +1802,9 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool want_value)
/* Try this again in case gimplification exposed something. */
if (ret != GS_ERROR && decl && DECL_BUILT_IN (decl))
{
- tree new = fold_builtin (*expr_p, !want_value);
+ tree fndecl = get_callee_fndecl (*expr_p);
+ tree arglist = TREE_OPERAND (*expr_p, 1);
+ tree new = fold_builtin (fndecl, arglist, !want_value);
if (new && new != *expr_p)
{
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index a14cf7f3664..9bae835d7cd 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -938,6 +938,7 @@ ccp_fold (tree stmt)
if (NUM_USES (uses) != 0)
{
tree *orig;
+ tree fndecl, arglist;
size_t i;
/* Preserve the original values of every operand. */
@@ -947,7 +948,9 @@ ccp_fold (tree stmt)
/* Substitute operands with their values and try to fold. */
replace_uses_in (stmt, NULL);
- retval = fold_builtin (rhs, false);
+ fndecl = get_callee_fndecl (rhs);
+ arglist = TREE_OPERAND (rhs, 1);
+ retval = fold_builtin (fndecl, arglist, false);
/* Restore operands to their original form. */
for (i = 0; i < NUM_USES (uses); i++)
@@ -1929,7 +1932,9 @@ ccp_fold_builtin (tree stmt, tree fn)
/* First try the generic builtin folder. If that succeeds, return the
result directly. */
- result = fold_builtin (fn, ignore);
+ callee = get_callee_fndecl (fn);
+ arglist = TREE_OPERAND (fn, 1);
+ result = fold_builtin (callee, arglist, ignore);
if (result)
{
if (ignore)
@@ -1938,13 +1943,11 @@ ccp_fold_builtin (tree stmt, tree fn)
}
/* Ignore MD builtins. */
- callee = get_callee_fndecl (fn);
if (DECL_BUILT_IN_CLASS (callee) == BUILT_IN_MD)
return NULL_TREE;
/* If the builtin could not be folded, and it has no argument list,
we're done. */
- arglist = TREE_OPERAND (fn, 1);
if (!arglist)
return NULL_TREE;
diff --git a/gcc/tree.h b/gcc/tree.h
index 3ad2a5142b8..96d04056031 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3563,7 +3563,7 @@ extern enum tree_code swap_tree_comparison (enum tree_code);
extern bool ptr_difference_const (tree, tree, HOST_WIDE_INT *);
/* In builtins.c */
-extern tree fold_builtin (tree, bool);
+extern tree fold_builtin (tree, tree, bool);
extern tree fold_builtin_fputs (tree, bool, bool, tree);
extern tree fold_builtin_strcpy (tree, tree, tree);
extern tree fold_builtin_strncpy (tree, tree, tree);