diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2004-06-17 18:13:20 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2004-06-17 18:13:20 +0000 |
commit | d00ad49ba1c217ec55751ed6461890e8911bb001 (patch) | |
tree | 48e225e2383797232dc02a86ef7fbfa79ca1a610 /gcc/tree-into-ssa.c | |
parent | d7621d3c741403a604eab08b66658d71f3452e8d (diff) | |
download | gcc-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-into-ssa.c')
-rw-r--r-- | gcc/tree-into-ssa.c | 106 |
1 files changed, 60 insertions, 46 deletions
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 0f92686..0a20d2d 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -109,11 +109,12 @@ static void mark_def_sites_initialize_block (struct dom_walk_data *walk_data, static void compute_global_livein (bitmap, bitmap); static void set_def_block (tree, basic_block); static void set_livein_block (tree, basic_block); -static bool prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool); +static bool prepare_use_operand_for_rename (use_operand_p op_p, size_t *uid_p); +static bool prepare_def_operand_for_rename (tree def, size_t *uid_p); static void insert_phi_nodes (bitmap *); static void rewrite_stmt (struct dom_walk_data *, basic_block, block_stmt_iterator); -static inline void rewrite_operand (tree *); +static inline void rewrite_operand (use_operand_p); static void insert_phi_nodes_for (tree, bitmap *, varray_type *); static tree get_reaching_def (tree); static hashval_t def_blocks_hash (const void *); @@ -231,21 +232,21 @@ mark_def_sites (struct dom_walk_data *walk_data, uses = USE_OPS (ann); for (i = 0; i < NUM_USES (uses); i++) { - tree *use_p = USE_OP_PTR (uses, i); + use_operand_p use_p = USE_OP_PTR (uses, i); - if (prepare_operand_for_rename (use_p, &uid, true) + if (prepare_use_operand_for_rename (use_p, &uid) && !TEST_BIT (kills, uid)) - set_livein_block (*use_p, bb); + set_livein_block (USE_FROM_PTR (use_p), bb); } /* Similarly for virtual uses. */ vuses = VUSE_OPS (ann); for (i = 0; i < NUM_VUSES (vuses); i++) { - tree *use_p = VUSE_OP_PTR (vuses, i); + use_operand_p use_p = VUSE_OP_PTR (vuses, i); - if (prepare_operand_for_rename (use_p, &uid, true)) - set_livein_block (*use_p, bb); + if (prepare_use_operand_for_rename (use_p, &uid)) + set_livein_block (USE_FROM_PTR (use_p), bb); } /* Note that virtual definitions are irrelevant for computing KILLS @@ -256,15 +257,15 @@ mark_def_sites (struct dom_walk_data *walk_data, v_may_defs = V_MAY_DEF_OPS (ann); for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) { - if (prepare_operand_for_rename (V_MAY_DEF_OP_PTR (v_may_defs, i), - &uid, true)) + use_operand_p use_p = V_MAY_DEF_OP_PTR (v_may_defs, i); + if (prepare_use_operand_for_rename (use_p, &uid)) { /* If we do not already have an SSA_NAME for our destination, then set the destination to the source. */ if (TREE_CODE (V_MAY_DEF_RESULT (v_may_defs, i)) != SSA_NAME) - V_MAY_DEF_RESULT (v_may_defs, i) = V_MAY_DEF_OP (v_may_defs, i); + SET_V_MAY_DEF_RESULT (v_may_defs, i, USE_FROM_PTR (use_p)); - set_livein_block (V_MAY_DEF_OP (v_may_defs, i), bb); + set_livein_block (USE_FROM_PTR (use_p), bb); set_def_block (V_MAY_DEF_RESULT (v_may_defs, i), bb); } } @@ -273,11 +274,11 @@ mark_def_sites (struct dom_walk_data *walk_data, v_must_defs = V_MUST_DEF_OPS (ann); for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) { - tree *def_p = V_MUST_DEF_OP_PTR (v_must_defs, i); + tree def = V_MUST_DEF_OP (v_must_defs, i); - if (prepare_operand_for_rename (def_p, &uid, false)) + if (prepare_def_operand_for_rename (def, &uid)) { - set_def_block (*def_p, bb); + set_def_block (def, bb); SET_BIT (kills, uid); } } @@ -287,11 +288,11 @@ mark_def_sites (struct dom_walk_data *walk_data, defs = DEF_OPS (ann); for (i = 0; i < NUM_DEFS (defs); i++) { - tree *def_p = DEF_OP_PTR (defs, i); + tree def = DEF_OP (defs, i); - if (prepare_operand_for_rename (def_p, &uid, false)) + if (prepare_def_operand_for_rename (def, &uid)) { - set_def_block (*def_p, bb); + set_def_block (def, bb); SET_BIT (kills, uid); } } @@ -367,21 +368,16 @@ set_livein_block (tree var, basic_block bb) } -/* If the operand pointed to by OP_P needs to be renamed, then - - 1. If OP_P is used (rather than set), then strip away any SSA_NAME - wrapping the operand. - - 2. Set *UID_P to the underlying variable's uid. - - 3. Return true. - - Otherwise return false. */ +/* If the use operand pointed to by OP_P needs to be renamed, then strip away + any SSA_NAME wrapping the operand, set *UID_P to the underlying variable's + uid, and return true. Otherwise return false. If the operand was an + SSA_NAME, change it to the stipped name. */ static bool -prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool is_use) +prepare_use_operand_for_rename (use_operand_p op_p, size_t *uid_p) { - tree var = (TREE_CODE (*op_p) != SSA_NAME) ? *op_p : SSA_NAME_VAR (*op_p); + tree use = USE_FROM_PTR (op_p); + tree var = (TREE_CODE (use) != SSA_NAME) ? use : SSA_NAME_VAR (use); *uid_p = var_ann (var)->uid; /* Ignore variables that don't need to be renamed. */ @@ -394,12 +390,28 @@ prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool is_use) By not throwing away SSA_NAMEs on assignments, we avoid a lot of useless churn of SSA_NAMEs without having to overly complicate the renamer. */ - if (TREE_CODE (*op_p) == SSA_NAME && is_use) - *op_p = var; + if (TREE_CODE (use) == SSA_NAME) + SET_USE (op_p, var); return true; } +/* If the def variable DEF needs to be renamed, then strip away any SSA_NAME + wrapping the operand, set *UID_P to the underlying variable's uid and return + true. Otherwise return false. */ + +static bool +prepare_def_operand_for_rename (tree def, size_t *uid_p) +{ + tree var = (TREE_CODE (def) != SSA_NAME) ? def : SSA_NAME_VAR (def); + *uid_p = var_ann (var)->uid; + + /* Ignore variables that don't need to be renamed. */ + if (vars_to_rename && !bitmap_bit_p (vars_to_rename, *uid_p)) + return false; + + return true; +} /* Helper for insert_phi_nodes. If VAR needs PHI nodes, insert them at the dominance frontier (DFS) of blocks defining VAR. */ @@ -774,14 +786,14 @@ rewrite_stmt (struct dom_walk_data *walk_data, /* Step 2. Register the statement's DEF and VDEF operands. */ for (i = 0; i < NUM_DEFS (defs); i++) { - tree *def_p = DEF_OP_PTR (defs, i); + def_operand_p def_p = DEF_OP_PTR (defs, i); - if (TREE_CODE (*def_p) != SSA_NAME) - *def_p = make_ssa_name (*def_p, stmt); + if (TREE_CODE (DEF_FROM_PTR (def_p)) != SSA_NAME) + SET_DEF (def_p, make_ssa_name (DEF_FROM_PTR (def_p), stmt)); /* FIXME: We shouldn't be registering new defs if the variable doesn't need to be renamed. */ - register_new_def (*def_p, &bd->block_defs); + register_new_def (DEF_FROM_PTR (def_p), &bd->block_defs); } /* Register new virtual definitions made by the statement. */ @@ -790,8 +802,9 @@ rewrite_stmt (struct dom_walk_data *walk_data, rewrite_operand (V_MAY_DEF_OP_PTR (v_may_defs, i)); if (TREE_CODE (V_MAY_DEF_RESULT (v_may_defs, i)) != SSA_NAME) - *V_MAY_DEF_RESULT_PTR (v_may_defs, i) - = make_ssa_name (V_MAY_DEF_RESULT (v_may_defs, i), stmt); + SET_V_MAY_DEF_RESULT (v_may_defs, i, + make_ssa_name (V_MAY_DEF_RESULT (v_may_defs, i), + stmt)); /* FIXME: We shouldn't be registering new defs if the variable doesn't need to be renamed. */ @@ -801,27 +814,28 @@ rewrite_stmt (struct dom_walk_data *walk_data, /* Register new virtual mustdefs made by the statement. */ for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) { - tree *v_must_def_p = V_MUST_DEF_OP_PTR (v_must_defs, i); + def_operand_p v_must_def_p = V_MUST_DEF_OP_PTR (v_must_defs, i); - if (TREE_CODE (*v_must_def_p) != SSA_NAME) - *v_must_def_p = make_ssa_name (*v_must_def_p, stmt); + if (TREE_CODE (DEF_FROM_PTR (v_must_def_p)) != SSA_NAME) + SET_DEF (v_must_def_p, + make_ssa_name (DEF_FROM_PTR (v_must_def_p), stmt)); /* FIXME: We shouldn't be registering new mustdefs if the variable doesn't need to be renamed. */ - register_new_def (*v_must_def_p, &bd->block_defs); + register_new_def (DEF_FROM_PTR (v_must_def_p), &bd->block_defs); } } -/* Replace the operand pointed by OP_P with its immediate reaching +/* Replace the use operand pointed by OP_P with its immediate reaching definition. */ static inline void -rewrite_operand (tree *op_p) +rewrite_operand (use_operand_p op_p) { - if (TREE_CODE (*op_p) != SSA_NAME) - *op_p = get_reaching_def (*op_p); + if (TREE_CODE (USE_FROM_PTR (op_p)) != SSA_NAME) + SET_USE (op_p, get_reaching_def (USE_FROM_PTR (op_p))); } |