aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-outof-ssa.c
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2004-06-17 18:13:20 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2004-06-17 18:13:20 +0000
commitd00ad49ba1c217ec55751ed6461890e8911bb001 (patch)
tree48e225e2383797232dc02a86ef7fbfa79ca1a610 /gcc/tree-outof-ssa.c
parentd7621d3c741403a604eab08b66658d71f3452e8d (diff)
downloadgcc-d00ad49ba1c217ec55751ed6461890e8911bb001.zip
gcc-d00ad49ba1c217ec55751ed6461890e8911bb001.tar.gz
gcc-d00ad49ba1c217ec55751ed6461890e8911bb001.tar.bz2
tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT.
2004-06-16 Andrew MacLeod <amacleod@redhat.com> * tree-cfg.c (tree_make_forwarder_block): Use SET_PHI_RESULT. * tree-flow-inline.h (get_use_op_ptr): Return a use_operand_p. (get_use_from_ptr, get_def_from_ptr): New. Return operand pointers. (get_def_op_ptr): Return a def_operand_p instead of a 'tree *'. (get_v_may_def_result_ptr): Return a def_operand_p. (get_v_may_def_op_ptr, get_vuse_op_ptr): Return a use_operand_p. (get_v_must_def_op_ptr): Return a def_operand_p. (get_phi_result_ptr): New. Return a pointer to the result of a PHI. (get_phi_arg_def_ptr): New. Return a pointer to an argument of a PHI. (phi_element_for_edge): Remove. * tree-flow.h (propagate_value, replace_exp): Change prototype. (propagate_tree_value): Add new prototype. (phi_element_for_edge): Remove prototype. * tree-into-ssa.c (mark_def_sites): Use new operand types. (prepare_operand_for_rename): Split into two functions. (prepare_use_operand_for_rename): Prepare use operands. (prepare_def_operand_for_rename): Prepare def operands. (rewrite_stmt): Use new operand types. (rewrite_operand): Use new operand types, change parameter type. * tree-outof-ssa.c (replace_variable): Split into two functions. (replace_use_variable): Rewrite uses. (replace_def_variable): Rewrite defs. (rewrite_trees, rewrite_vars_out_of_ssa): Use new operand types. * tree-phinodes.c (make_phi_node, resize_phi_node): Use new types. (add_phi_arg, remove_phi_arg_num): Use new operand types. * tree-ssa-ccp.c (substitute_and_fold): Use new operand types. (ccp_fold, replace_uses_in): Use new operand types. * tree-ssa-copy.c (replace_ssa_names): Rename to replace_ssa_names_ann and no longer set the value, change parameter type. (replace_exp_1): Use new operand types. (propagate_value): Change parameter type, use new operand types. (propagate_tree_value): Propagate_value without SSA operands. (replace_exp, cprop_operand, cprop_into_stmt): Use new operand types. (cprop_into_successor_phis): Use new operand types. * tree-ssa-dom.c (thread_across_edge): Use new operand types. (eliminate_redundant_computations): Use new operand types. * tree-ssa-dse.c (fix_phi_uses): Use new operand_types. (fix_stmt_v_may_defs): Use new operand_types. * tree-ssa-live.c (create_ssa_var_map): Use new operand_types. (build_tree_conflict_graph): Use new operand_types. * tree-ssa-loop.c (duplicate_blocks): Use PHI_ARG_DEF_FROM_EDGE. * tree-ssa-operands.c (struct freelist_d): Remove. (check_optype_freelist, add_optype_freelist): Remove. (allocate_def_optype, allocate_use_optype, allocate_v_may_def_optype, allocate_vuse_optype, allocate_v_must_def_optype): Call ggc_alloc. (free_uses, free_defs, free_vuses, free_v_may_defs, free_v_must_defs): Call ggc_free instead of add_optype_freelist. (init_ssa_operands, fini_ssa_operands): Remove free list code. (finalize_ssa_defs, finalize_ssa_uses): Set new use/def operands. * tree-ssa-operands.h (struct def_optype_d): Change underlying type. (struct use_optype_d): Change underlying type. (def_operand_p, use_operand_p): New types for pointers to operands. (USE_OP, DEF_OP, V_MAY_DEF_RESULT, V_MAY_DEF_OP, VUSE_OP, V_MUST_DEF_OP): Use new pointer type instead of dereferencing directly. (USE_FROM_PTR, DEF_FROM_PTR): New macros to "dereference" operand pointer types. (SET_USE, SET_DEF): New macros to set operands from their pointer. (SET_USE_OP, SET_DEF_OP, SET_V_MAY_DEF_RESULT, SET_V_MAY_DEF_OP, SET_VUSE_OP, SET_V_MUST_DEF_OP): New SET routines for operands. (PHI_RESULT_PTR, PHI_RESULT, SET_PHI_RESULT): Macros to manage the PHI result as an operand. (PHI_ARG_DEF_PTR, PHI_ARG_DEF, SET_PHI_ARG_DEF, PHI_ARG_DEF_FROM_EDGE, PHI_ARG_DEF_PTR_FROM_EDGE): Macros to manage the PHI arguments. * tree-ssa-pre.c (eliminate): Call propagate_tree_value. * tree-tailcall.c (independent_of_stmt_p, propagate_through_phis): Use PHI_ARG_DEF_FROM_EDGE. * tree.h (PHI_RESULT): Renamed to PHI_RESULT_TREE. (PHI_ARG_DEF): Renamed to PHI_ARG_DEF_TREE. From-SVN: r83298
Diffstat (limited to 'gcc/tree-outof-ssa.c')
-rw-r--r--gcc/tree-outof-ssa.c69
1 files changed, 52 insertions, 17 deletions
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index ec52f69..28c8023 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -116,7 +116,8 @@ static void elim_create (elim_graph, int);
static void eliminate_phi (edge, int, elim_graph);
static tree_live_info_p coalesce_ssa_name (var_map, int);
static void assign_vars (var_map);
-static bool replace_variable (var_map, tree *, tree *);
+static bool replace_use_variable (var_map, use_operand_p, tree *);
+static bool replace_def_variable (var_map, def_operand_p, tree *);
static void eliminate_virtual_phis (void);
static void coalesce_abnormal_edges (var_map, conflict_graph, root_var_p);
static void print_exprs (FILE *, const char *, tree, const char *, tree,
@@ -922,25 +923,25 @@ assign_vars (var_map map)
}
-/* Replace *P with whatever variable it has been rewritten to based on the
- partitions in MAP. EXPR is an optional expression vector over SSA versions
- which is used to replace *P with an expression instead of a variable.
+/* Replace use operand P with whatever variable it has been rewritten to based
+ on the partitions in MAP. EXPR is an optional expression vector over SSA
+ versions which is used to replace P with an expression instead of a variable.
If the stmt is changed, return true. */
static inline bool
-replace_variable (var_map map, tree *p, tree *expr)
+replace_use_variable (var_map map, use_operand_p p, tree *expr)
{
tree new_var;
- tree var = *p;
+ tree var = USE_FROM_PTR (p);
/* Check if we are replacing this variable with an expression. */
if (expr)
{
- int version = SSA_NAME_VERSION (*p);
+ int version = SSA_NAME_VERSION (var);
if (expr[version])
{
tree new_expr = TREE_OPERAND (expr[version], 1);
- *p = new_expr;
+ SET_USE (p, new_expr);
/* Clear the stmt's RHS, or GC might bite us. */
TREE_OPERAND (expr[version], 1) = NULL_TREE;
return true;
@@ -950,7 +951,43 @@ replace_variable (var_map map, tree *p, tree *expr)
new_var = var_to_partition_to_var (map, var);
if (new_var)
{
- *p = new_var;
+ SET_USE (p, new_var);
+ set_is_used (new_var);
+ return true;
+ }
+ return false;
+}
+
+
+/* Replace def operand DEF_P with whatever variable it has been rewritten to
+ based on the partitions in MAP. EXPR is an optional expression vector over
+ SSA versions which is used to replace DEF_P with an expression instead of a
+ variable. If the stmt is changed, return true. */
+
+static inline bool
+replace_def_variable (var_map map, def_operand_p def_p, tree *expr)
+{
+ tree new_var;
+ tree var = DEF_FROM_PTR (def_p);
+
+ /* Check if we are replacing this variable with an expression. */
+ if (expr)
+ {
+ int version = SSA_NAME_VERSION (var);
+ if (expr[version])
+ {
+ tree new_expr = TREE_OPERAND (expr[version], 1);
+ SET_DEF (def_p, new_expr);
+ /* Clear the stmt's RHS, or GC might bite us. */
+ TREE_OPERAND (expr[version], 1) = NULL_TREE;
+ return true;
+ }
+ }
+
+ new_var = var_to_partition_to_var (map, var);
+ if (new_var)
+ {
+ SET_DEF (def_p, new_var);
set_is_used (new_var);
return true;
}
@@ -1832,7 +1869,7 @@ rewrite_trees (var_map map, tree *values)
use_optype uses;
def_optype defs;
tree stmt = bsi_stmt (si);
- tree *use_p = NULL;
+ use_operand_p use_p;
int remove = 0, is_copy = 0;
stmt_ann_t ann;
@@ -1850,7 +1887,7 @@ rewrite_trees (var_map map, tree *values)
for (i = 0; i < num_uses; i++)
{
use_p = USE_OP_PTR (uses, i);
- if (replace_variable (map, use_p, values))
+ if (replace_use_variable (map, use_p, values))
changed = true;
}
@@ -1871,18 +1908,16 @@ rewrite_trees (var_map map, tree *values)
{
for (i = 0; i < num_defs; i++)
{
- tree *def_p = DEF_OP_PTR (defs, i);
+ def_operand_p def_p = DEF_OP_PTR (defs, i);
- if (replace_variable (map, def_p, NULL))
+ if (replace_def_variable (map, def_p, NULL))
changed = true;
/* If both SSA_NAMEs coalesce to the same variable,
mark the now redundant copy for removal. */
if (is_copy
&& num_uses == 1
- && use_p
- && def_p
- && (*def_p == *use_p))
+ && (DEF_FROM_PTR (def_p) == USE_OP (uses, 0)))
remove = 1;
}
if (changed)
@@ -2074,7 +2109,7 @@ rewrite_vars_out_of_ssa (bitmap vars)
SSA_NAME_DEF_STMT (new_name) = copy;
/* Now make the argument reference our new SSA_NAME. */
- PHI_ARG_DEF (phi, i) = new_name;
+ SET_PHI_ARG_DEF (phi, i, new_name);
/* Queue the statement for insertion. */
bsi_insert_on_edge (PHI_ARG_EDGE (phi, i), copy);