This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] PATCH: updates to use new CALL_EXPR interfaces
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 06 Jul 2006 22:05:00 -0400
- Subject: [lto] PATCH: updates to use new CALL_EXPR interfaces
Here's another batch of changes I've made to use the new CALL_EXPR interfaces.
No new functions or changes to the interfaces of existing ones here. In the
future, should I just go ahead and commit these kinds of changes as "obvious",
as Kazu has been doing with his?
Tested with native build on x86_64 Linux.
-Sandra
2006-07-06 Sandra Loosemore <sandra@codesourcery.com>
* gcc/cgraphunit.c (cgraph_create_edges, update_call_expr): Convert
to use new abstract CALL_EXPR accessors, iterators, and constructors.
* gcc/dojump.c (do_jump): Likewise.
* gcc/expr.c (emit_block_move_via_libcall): Likewise.
(clear_storage_via_libcall): Likewise.
(expand_expr_real_1): Likewise.
* gcc/c-pretty-print.c (pp_c_postfix_expression): Likewise.
* gcc/calls.c (alloca_call_p, call_expr_flags): Likewise.
* gcc/coverage.c (create_coverage): Likewise.
* gcc/c-omp.c (c_finish_omp_barrier, c_finish_omp_flush): Likewise.
* gcc/c-common.c (verify_tree): Likewise.
(check_function_arguments_recurse): Likewise.
* gcc/convert.c (convert_to_real, convert_to_integer): Likewise.
Index: gcc/cgraphunit.c
===================================================================
*** gcc/cgraphunit.c (revision 115245)
--- gcc/cgraphunit.c (working copy)
*************** cgraph_create_edges (struct cgraph_node
*** 569,579 ****
if (call && (decl = get_callee_fndecl (call)))
{
cgraph_create_edge (node, cgraph_node (decl), stmt,
bb->count,
bb->loop_depth);
! walk_tree (&TREE_OPERAND (call, 1),
! record_reference, node, visited_nodes);
if (TREE_CODE (stmt) == MODIFY_EXPR)
walk_tree (&TREE_OPERAND (stmt, 0),
record_reference, node, visited_nodes);
--- 569,583 ----
if (call && (decl = get_callee_fndecl (call)))
{
+ call_expr_arg_iterator iter;
+ tree arg;
+
cgraph_create_edge (node, cgraph_node (decl), stmt,
bb->count,
bb->loop_depth);
! for (arg = first_call_expr_arg (call, &iter); arg;
! arg = next_call_expr_arg (&iter))
! walk_tree (&arg, record_reference, node, visited_nodes);
if (TREE_CODE (stmt) == MODIFY_EXPR)
walk_tree (&TREE_OPERAND (stmt, 0),
record_reference, node, visited_nodes);
*************** update_call_expr (struct cgraph_node *ne
*** 1572,1578 ****
for (e = new_version->callers; e; e = e->next_caller)
/* Update the call expr on the edges
to call the new version. */
! TREE_OPERAND (TREE_OPERAND (get_call_expr_in (e->call_stmt), 0), 0) = new_version->decl;
}
--- 1576,1582 ----
for (e = new_version->callers; e; e = e->next_caller)
/* Update the call expr on the edges
to call the new version. */
! TREE_OPERAND (CALL_EXPR_FN (get_call_expr_in (e->call_stmt)), 0) = new_version->decl;
}
Index: gcc/dojump.c
===================================================================
*** gcc/dojump.c (revision 115245)
--- gcc/dojump.c (working copy)
*************** do_jump (tree exp, rtx if_false_label, r
*** 562,574 ****
/* Check for a built-in function. */
{
tree fndecl = get_callee_fndecl (exp);
- tree arglist = TREE_OPERAND (exp, 1);
if (fndecl
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
! && arglist != NULL_TREE
! && TREE_CHAIN (arglist) != NULL_TREE)
{
rtx seq = expand_builtin_expect_jump (exp, if_false_label,
if_true_label);
--- 562,572 ----
/* Check for a built-in function. */
{
tree fndecl = get_callee_fndecl (exp);
if (fndecl
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
! && call_expr_nargs (exp) >= 2)
{
rtx seq = expand_builtin_expect_jump (exp, if_false_label,
if_true_label);
Index: gcc/expr.c
===================================================================
*** gcc/expr.c (revision 115245)
--- gcc/expr.c (working copy)
*************** static rtx
*** 1340,1346 ****
emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall)
{
rtx dst_addr, src_addr;
! tree call_expr, arg_list, fn, src_tree, dst_tree, size_tree;
enum machine_mode size_mode;
rtx retval;
--- 1340,1346 ----
emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall)
{
rtx dst_addr, src_addr;
! tree call_expr, fn, src_tree, dst_tree, size_tree;
enum machine_mode size_mode;
rtx retval;
*************** emit_block_move_via_libcall (rtx dst, rt
*** 1371,1384 ****
size_tree = make_tree (sizetype, size);
fn = emit_block_move_libcall_fn (true);
! arg_list = tree_cons (NULL_TREE, size_tree, NULL_TREE);
! arg_list = tree_cons (NULL_TREE, src_tree, arg_list);
! arg_list = tree_cons (NULL_TREE, dst_tree, arg_list);
!
! /* Now we have to build up the CALL_EXPR itself. */
! call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
! call_expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
! call_expr, arg_list, NULL_TREE);
CALL_EXPR_TAILCALL (call_expr) = tailcall;
retval = expand_normal (call_expr);
--- 1371,1377 ----
size_tree = make_tree (sizetype, size);
fn = emit_block_move_libcall_fn (true);
! call_expr = build_call_expr (fn, 3, dst_tree, src_tree, size_tree);
CALL_EXPR_TAILCALL (call_expr) = tailcall;
retval = expand_normal (call_expr);
*************** clear_storage (rtx object, rtx size, enu
*** 2552,2558 ****
static rtx
clear_storage_via_libcall (rtx object, rtx size, bool tailcall)
{
! tree call_expr, arg_list, fn, object_tree, size_tree;
enum machine_mode size_mode;
rtx retval;
--- 2545,2551 ----
static rtx
clear_storage_via_libcall (rtx object, rtx size, bool tailcall)
{
! tree call_expr, fn, object_tree, size_tree;
enum machine_mode size_mode;
rtx retval;
*************** clear_storage_via_libcall (rtx object, r
*** 2575,2588 ****
size_tree = make_tree (sizetype, size);
fn = clear_storage_libcall_fn (true);
! arg_list = tree_cons (NULL_TREE, size_tree, NULL_TREE);
! arg_list = tree_cons (NULL_TREE, integer_zero_node, arg_list);
! arg_list = tree_cons (NULL_TREE, object_tree, arg_list);
!
! /* Now we have to build up the CALL_EXPR itself. */
! call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
! call_expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
! call_expr, arg_list, NULL_TREE);
CALL_EXPR_TAILCALL (call_expr) = tailcall;
retval = expand_normal (call_expr);
--- 2568,2575 ----
size_tree = make_tree (sizetype, size);
fn = clear_storage_libcall_fn (true);
! call_expr = build_call_expr (fn, 3,
! object_tree, integer_zero_node, size_tree);
CALL_EXPR_TAILCALL (call_expr) = tailcall;
retval = expand_normal (call_expr);
*************** expand_expr_real_1 (tree exp, rtx target
*** 7590,7601 ****
case CALL_EXPR:
/* Check for a built-in function. */
! if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
! && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
== FUNCTION_DECL)
! && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
{
! if (DECL_BUILT_IN_CLASS (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
== BUILT_IN_FRONTEND)
return lang_hooks.expand_expr (exp, original_target,
tmode, modifier,
--- 7577,7588 ----
case CALL_EXPR:
/* Check for a built-in function. */
! if (TREE_CODE (CALL_EXPR_FN (exp)) == ADDR_EXPR
! && (TREE_CODE (TREE_OPERAND (CALL_EXPR_FN (exp), 0))
== FUNCTION_DECL)
! && DECL_BUILT_IN (TREE_OPERAND (CALL_EXPR_FN (exp), 0)))
{
! if (DECL_BUILT_IN_CLASS (TREE_OPERAND (CALL_EXPR_FN (exp), 0))
== BUILT_IN_FRONTEND)
return lang_hooks.expand_expr (exp, original_target,
tmode, modifier,
Index: gcc/c-pretty-print.c
===================================================================
*** gcc/c-pretty-print.c (revision 115245)
--- gcc/c-pretty-print.c (working copy)
*************** pp_c_postfix_expression (c_pretty_printe
*** 1271,1279 ****
break;
case CALL_EXPR:
! pp_postfix_expression (pp, TREE_OPERAND (e, 0));
! pp_c_call_argument_list (pp, TREE_OPERAND (e, 1));
! break;
case UNORDERED_EXPR:
pp_c_identifier (pp, flag_isoc99
--- 1271,1291 ----
break;
case CALL_EXPR:
! {
! call_expr_arg_iterator iter;
! tree arg;
! pp_postfix_expression (pp, CALL_EXPR_FN (e));
! pp_c_left_paren (pp);
! for (arg = first_call_expr_arg (e, &iter); arg;
! arg = next_call_expr_arg (&iter))
! {
! pp_expression (pp, arg);
! if (more_call_expr_args_p (&iter))
! pp_separate_with (pp, ',');
! }
! pp_c_right_paren (pp);
! break;
! }
case UNORDERED_EXPR:
pp_c_identifier (pp, flag_isoc99
*************** pp_c_constructor_elts (c_pretty_printer
*** 1420,1426 ****
}
}
! /* Print out an expression-list in parens, as in a function call. */
void
pp_c_call_argument_list (c_pretty_printer *pp, tree t)
--- 1432,1439 ----
}
}
! /* Print out an expression-list in parens, as if it were the argument
! list to a function. */
void
pp_c_call_argument_list (c_pretty_printer *pp, tree t)
Index: gcc/calls.c
===================================================================
*** gcc/calls.c (revision 115245)
--- gcc/calls.c (working copy)
*************** bool
*** 553,563 ****
alloca_call_p (tree exp)
{
if (TREE_CODE (exp) == CALL_EXPR
! && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
! && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
! == FUNCTION_DECL)
! && (special_function_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
! 0) & ECF_MAY_BE_ALLOCA))
return true;
return false;
}
--- 553,562 ----
alloca_call_p (tree exp)
{
if (TREE_CODE (exp) == CALL_EXPR
! && TREE_CODE (CALL_EXPR_FN (exp)) == ADDR_EXPR
! && (TREE_CODE (TREE_OPERAND (CALL_EXPR_FN (exp), 0)) == FUNCTION_DECL)
! && (special_function_p (TREE_OPERAND (CALL_EXPR_FN (exp), 0), 0)
! & ECF_MAY_BE_ALLOCA))
return true;
return false;
}
*************** call_expr_flags (tree t)
*** 626,632 ****
flags = flags_from_decl_or_type (decl);
else
{
! t = TREE_TYPE (TREE_OPERAND (t, 0));
if (t && TREE_CODE (t) == POINTER_TYPE)
flags = flags_from_decl_or_type (TREE_TYPE (t));
else
--- 625,631 ----
flags = flags_from_decl_or_type (decl);
else
{
! t = TREE_TYPE (CALL_EXPR_FN (t));
if (t && TREE_CODE (t) == POINTER_TYPE)
flags = flags_from_decl_or_type (TREE_TYPE (t));
else
Index: gcc/coverage.c
===================================================================
*** gcc/coverage.c (revision 115245)
--- gcc/coverage.c (working copy)
*************** create_coverage (void)
*** 945,952 ****
/* Generate a call to __gcov_init(&gcov_info). */
body = NULL;
t = build_fold_addr_expr (gcov_info);
! t = tree_cons (NULL, t, NULL);
! t = build_function_call_expr (gcov_init, t);
append_to_statement_list (t, &body);
/* Generate a constructor to run it. */
--- 945,951 ----
/* Generate a call to __gcov_init(&gcov_info). */
body = NULL;
t = build_fold_addr_expr (gcov_info);
! t = build_call_expr (gcov_init, 1, t);
append_to_statement_list (t, &body);
/* Generate a constructor to run it. */
Index: gcc/c-omp.c
===================================================================
*** gcc/c-omp.c (revision 115245)
--- gcc/c-omp.c (working copy)
*************** c_finish_omp_barrier (void)
*** 76,82 ****
tree x;
x = built_in_decls[BUILT_IN_GOMP_BARRIER];
! x = build_function_call_expr (x, NULL);
add_stmt (x);
}
--- 76,82 ----
tree x;
x = built_in_decls[BUILT_IN_GOMP_BARRIER];
! x = build_call_expr (x, 0);
add_stmt (x);
}
*************** c_finish_omp_flush (void)
*** 138,144 ****
tree x;
x = built_in_decls[BUILT_IN_SYNCHRONIZE];
! x = build_function_call_expr (x, NULL);
add_stmt (x);
}
--- 138,144 ----
tree x;
x = built_in_decls[BUILT_IN_SYNCHRONIZE];
! x = build_call_expr (x, 0);
add_stmt (x);
}
Index: gcc/c-common.c
===================================================================
*** gcc/c-common.c (revision 115245)
--- gcc/c-common.c (working copy)
*************** verify_tree (tree x, struct tlist **pbef
*** 1416,1431 ****
/* We need to warn about conflicts among arguments and conflicts between
args and the function address. Side effects of the function address,
however, are not ordered by the sequence point of the call. */
! tmp_before = tmp_nosp = tmp_list2 = tmp_list3 = 0;
! verify_tree (TREE_OPERAND (x, 0), &tmp_before, &tmp_nosp, NULL_TREE);
! if (TREE_OPERAND (x, 1))
! verify_tree (TREE_OPERAND (x, 1), &tmp_list2, &tmp_list3, NULL_TREE);
! merge_tlist (&tmp_list3, tmp_list2, 0);
! add_tlist (&tmp_before, tmp_list3, NULL_TREE, 0);
! add_tlist (&tmp_before, tmp_nosp, NULL_TREE, 0);
! warn_for_collisions (tmp_before);
! add_tlist (pbefore_sp, tmp_before, NULL_TREE, 0);
! return;
case TREE_LIST:
/* Scan all the list, e.g. indices of multi dimensional array. */
--- 1416,1439 ----
/* We need to warn about conflicts among arguments and conflicts between
args and the function address. Side effects of the function address,
however, are not ordered by the sequence point of the call. */
! {
! call_expr_arg_iterator iter;
! tree arg;
! tmp_before = tmp_nosp = 0;
! verify_tree (CALL_EXPR_FN (x), &tmp_before, &tmp_nosp, NULL_TREE);
! for (arg = first_call_expr_arg (x, &iter); arg;
! arg = next_call_expr_arg (&iter))
! {
! tmp_list2 = tmp_list3 = 0;
! verify_tree (arg, &tmp_list2, &tmp_list3, NULL_TREE);
! merge_tlist (&tmp_list3, tmp_list2, 0);
! add_tlist (&tmp_before, tmp_list3, NULL_TREE, 0);
! }
! add_tlist (&tmp_before, tmp_nosp, NULL_TREE, 0);
! warn_for_collisions (tmp_before);
! add_tlist (pbefore_sp, tmp_before, NULL_TREE, 0);
! return;
! }
case TREE_LIST:
/* Scan all the list, e.g. indices of multi dimensional array. */
*************** check_function_arguments_recurse (void (
*** 5697,5703 ****
if (TREE_CODE (param) == CALL_EXPR)
{
! tree type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (param, 0)));
tree attrs;
bool found_format_arg = false;
--- 5705,5711 ----
if (TREE_CODE (param) == CALL_EXPR)
{
! tree type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (param)));
tree attrs;
bool found_format_arg = false;
*************** check_function_arguments_recurse (void (
*** 5710,5719 ****
attrs = TREE_CHAIN (attrs))
if (is_attribute_p ("format_arg", TREE_PURPOSE (attrs)))
{
! tree inner_args;
tree format_num_expr;
int format_num;
int i;
/* Extract the argument number, which was previously checked
to be valid. */
--- 5718,5728 ----
attrs = TREE_CHAIN (attrs))
if (is_attribute_p ("format_arg", TREE_PURPOSE (attrs)))
{
! tree inner_arg;
tree format_num_expr;
int format_num;
int i;
+ call_expr_arg_iterator iter;
/* Extract the argument number, which was previously checked
to be valid. */
*************** check_function_arguments_recurse (void (
*** 5724,5737 ****
format_num = TREE_INT_CST_LOW (format_num_expr);
! for (inner_args = TREE_OPERAND (param, 1), i = 1;
! inner_args != 0;
! inner_args = TREE_CHAIN (inner_args), i++)
if (i == format_num)
{
check_function_arguments_recurse (callback, ctx,
! TREE_VALUE (inner_args),
! param_num);
found_format_arg = true;
break;
}
--- 5733,5745 ----
format_num = TREE_INT_CST_LOW (format_num_expr);
! for (inner_arg = first_call_expr_arg (param, &iter), i = 1;
! inner_arg != 0;
! inner_arg = next_call_expr_arg (&iter), i++)
if (i == format_num)
{
check_function_arguments_recurse (callback, ctx,
! inner_arg, param_num);
found_format_arg = true;
break;
}
*************** c_warn_unused_result (tree *top_p)
*** 5948,5954 ****
ftype = TREE_TYPE (fdecl);
else
{
! ftype = TREE_TYPE (TREE_OPERAND (t, 0));
/* Look past pointer-to-function to the function type itself. */
ftype = TREE_TYPE (ftype);
}
--- 5956,5962 ----
ftype = TREE_TYPE (fdecl);
else
{
! ftype = TREE_TYPE (CALL_EXPR_FN (t));
/* Look past pointer-to-function to the function type itself. */
ftype = TREE_TYPE (ftype);
}
Index: gcc/convert.c
===================================================================
*** gcc/convert.c (revision 115245)
--- gcc/convert.c (working copy)
*************** convert_to_real (tree type, tree expr)
*** 177,183 ****
CASE_MATHFN (Y1)
#undef CASE_MATHFN
{
! tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
tree newtype = type;
/* We have (outertype)sqrt((innertype)x). Choose the wider mode from
--- 177,183 ----
CASE_MATHFN (Y1)
#undef CASE_MATHFN
{
! tree arg0 = strip_float_extensions (CALL_EXPR_ARG0 (expr));
tree newtype = type;
/* We have (outertype)sqrt((innertype)x). Choose the wider mode from
*************** convert_to_real (tree type, tree expr)
*** 192,204 ****
&& (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
|| TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
{
- tree arglist;
tree fn = mathfn_built_in (newtype, fcode);
if (fn)
{
! arglist = build_tree_list (NULL_TREE, fold (convert_to_real (newtype, arg0)));
! expr = build_function_call_expr (fn, arglist);
if (newtype == type)
return expr;
}
--- 192,203 ----
&& (TYPE_MODE (newtype) == TYPE_MODE (double_type_node)
|| TYPE_MODE (newtype) == TYPE_MODE (float_type_node)))
{
tree fn = mathfn_built_in (newtype, fcode);
if (fn)
{
! tree arg = fold (convert_to_real (newtype, arg0));
! expr = build_call_expr (fn, 1, arg);
if (newtype == type)
return expr;
}
*************** convert_to_real (tree type, tree expr)
*** 229,246 ****
if (fn)
{
! tree arg
! = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, 1)));
/* Make sure (type)arg0 is an extension, otherwise we could end up
changing (float)floor(double d) into floorf((float)d), which is
incorrect because (float)d uses round-to-nearest and can round
up to the next integer. */
if (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (arg)))
! return
! build_function_call_expr (fn,
! build_tree_list (NULL_TREE,
! fold (convert_to_real (type, arg))));
}
}
--- 228,241 ----
if (fn)
{
! tree arg = strip_float_extensions (CALL_EXPR_ARG0 (expr));
/* Make sure (type)arg0 is an extension, otherwise we could end up
changing (float)floor(double d) into floorf((float)d), which is
incorrect because (float)d uses round-to-nearest and can round
up to the next integer. */
if (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (arg)))
! return build_call_expr (fn, 1, fold (convert_to_real (type, arg)));
}
}
*************** convert_to_integer (tree type, tree expr
*** 420,429 ****
break;
CASE_FLT_FN (BUILT_IN_TRUNC):
! {
! tree arglist = TREE_OPERAND (s_expr, 1);
! return convert_to_integer (type, TREE_VALUE (arglist));
! }
default:
break;
--- 415,421 ----
break;
CASE_FLT_FN (BUILT_IN_TRUNC):
! return convert_to_integer (type, CALL_EXPR_ARG0 (s_expr));
default:
break;
*************** convert_to_integer (tree type, tree expr
*** 431,438 ****
if (fn)
{
! tree arglist = TREE_OPERAND (s_expr, 1);
! tree newexpr = build_function_call_expr (fn, arglist);
return convert_to_integer (type, newexpr);
}
}
--- 423,429 ----
if (fn)
{
! tree newexpr = build_call_expr (fn, 1, CALL_EXPR_ARG0 (s_expr));
return convert_to_integer (type, newexpr);
}
}