diff options
author | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-25 21:21:19 +0000 |
---|---|---|
committer | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-25 21:21:19 +0000 |
commit | 43daa21e7c3b20f510ed5e16e2aef1b806d69d2b (patch) | |
tree | 22414e194e2c3d5262c72554997d72332edaa89c /gcc/tree-into-ssa.c | |
parent | dc5fda0ed00721c5c3c4d23e13ba4be8897c4c20 (diff) | |
download | gcc-43daa21e7c3b20f510ed5e16e2aef1b806d69d2b.tar.gz |
2004-08-25 Andrew MacLeod <amacleod@redhat.com>
* tree-ssa-operands.h (struct ssa_operand_iterator_d): New. SSA operand
iterator controlling structure.
(SSA_OP_USE, SSA_OP_DEF, SSA_OP_VUSE, SSA_OP_VMAYUSE, SSA_OP_VMAYDEF,
SSA_OP_VMUSTDEF, SSA_OP_VIRTUAL_USES, SSA_OP_VIRTUAL_DEFS,
SSA_OP_ALL_USES, SSA_OP_ALL_DEFS, SSA_OP_ALL_OPERANDS): New. Operand
iterator flags.
(FOR_EACH_SSA_TREE_OPERAND): New. Iterate over operands as trees.
(FOR_EACH_SSA_USE_OPERAND): New. Iterate over operands as uses.
(FOR_EACH_SSA_DEF_OPERAND): New. Iterate over operands as defs.
(FOR_EACH_SSA_MAYDEF_OPERAND): New. Iterate over V_MAY_DEFs.
* tree-ssa-operands.c (NULL_DEF_OPERAND_P, NULL_USE_OPERAND_P): New.
Empty operand pointers.
* tree-flow-inline.h (op_iter_done): New. Return true if finished.
(op_iter_next_use): New. Return next use_operand_p.
(op_iter_next_def): New. Return next def_operand_p.
(op_iter_next_tree): New. Return next operands as a tree.
(op_iter_init): New. Initialize an iterator structure.
(op_iter_init_use): New. Initialize structure and get the first use.
(op_iter_init_def): New. Initialize structure and get the first def.
(op_iter_init_tree): New. Initialize structure and get the first tree.
(op_iter_next_maydef): New. Return next V_MAY_DEF operands.
(op_iter_init_maydef): New. Initialize structure and get the first
V_MAY_DEF operands.
* tree-cfg.c (tree_duplicate_bb): Use new operand iterator.
* tree-dfa.c (compute_immediate_uses_for_stmt,
redirect_immediate_uses): Use new operand iterator.
(v_may_defs_disappeared_p, v_must_defs_disappeared_p): Delete.
(mark_new_vars_to_rename): Use new operand iterator. Count virtual
operands instead of using *_disappeared_p routines.
* tree-into-ssa.c (mark_def_sites, ssa_mark_def_sites, rewrite_stmt,
ssa_rewrite_stmt): Use new operand iterator.
* tree-outof-ssa.c (check_replaceable, find_replaceable_in_bb,
rewrite_trees): Use new operand iterator.
* tree-pretty-print.c (dump_vops): Use new operand iterator.
* tree-sra.c (mark_all_v_defs): Use new operand iterator.
* tree-ssa-alias.c (compute_points_to_and_addr_escape,
dump_points_to_info): Use new operand iterator.
* tree-ssa-ccp.c (cp_lattice_meet, visit_stmt, initialize,
replace_uses_in, replace_vuse_in, likely_value, set_rhs): Use new
operand iterator.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary,
propagate_necessity): Use new operand iterator.
* tree-ssa-dom.c (cprop_into_stmt, optimize_stmt): Use operand iterator.
(register_definitions_for_stmt): Use new operand iterator. Take stmt as
a parameter instead of a stmt_ann_t.
* tree-ssa-live.c (create_ssa_var_map, calculate_live_on_entry,
build_tree_conflict_graph): Use new operand iterator.
* tree-ssa-loop-im.c (determine_max_movement, single_reachable_address,
rewrite_mem_refs): Use new operand iterator.
* tree-ssa-loop-manip.c (find_uses_to_rename_stmt,
check_loop_closed_ssa_use): Use new operand iterator.
* tree-ssa.c (verify_ssa, replace_immediate_uses): Use operand iterator.
* tree-ssanames.c (release_defs): Use new operand iterator.
* tree-vectorizer.c (vect_create_data_ref): Use new operand iterator.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86583 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-into-ssa.c')
-rw-r--r-- | gcc/tree-into-ssa.c | 243 |
1 files changed, 26 insertions, 217 deletions
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index edeeab5f1bf..6387b7fadd5 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -342,71 +342,50 @@ mark_def_sites (struct dom_walk_data *walk_data, { struct mark_def_sites_global_data *gd = walk_data->global_data; sbitmap kills = gd->kills; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - vuse_optype vuses; - def_optype defs; - use_optype uses; - size_t i, uid; - tree stmt; - stmt_ann_t ann; + size_t uid; + tree stmt, def; + use_operand_p use_p; + def_operand_p def_p; + ssa_op_iter iter; /* Mark all the blocks that have definitions for each variable in the VARS_TO_RENAME bitmap. */ stmt = bsi_stmt (bsi); get_stmt_operands (stmt); - ann = stmt_ann (stmt); /* If a variable is used before being set, then the variable is live across a block boundary, so mark it live-on-entry to BB. */ - uses = USE_OPS (ann); - for (i = 0; i < NUM_USES (uses); i++) - { - use_operand_p use_p = USE_OP_PTR (uses, i); - if (prepare_use_operand_for_rename (use_p, &uid) - && !TEST_BIT (kills, uid)) - 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++) + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE | SSA_OP_VUSE) { - use_operand_p use_p = VUSE_OP_PTR (vuses, i); - if (prepare_use_operand_for_rename (use_p, &uid) && !TEST_BIT (kills, uid)) set_livein_block (USE_FROM_PTR (use_p), bb); } - + /* Note that virtual definitions are irrelevant for computing KILLS because a V_MAY_DEF does not constitute a killing definition of the variable. However, the operand of a virtual definitions is a use of the variable, so it may cause the variable to be considered live-on-entry. */ - v_may_defs = V_MAY_DEF_OPS (ann); - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) + + FOR_EACH_SSA_MAYDEF_OPERAND (def_p, use_p, stmt, iter) { - 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) - SET_V_MAY_DEF_RESULT (v_may_defs, i, USE_FROM_PTR (use_p)); + if (TREE_CODE (DEF_FROM_PTR (def_p)) != SSA_NAME) + SET_DEF (def_p, USE_FROM_PTR (use_p)); set_livein_block (USE_FROM_PTR (use_p), bb); - set_def_block (V_MAY_DEF_RESULT (v_may_defs, i), bb, false, false); + set_def_block (DEF_FROM_PTR (def_p), bb, false, false); } } /* Now process the virtual must-defs made by this statement. */ - v_must_defs = V_MUST_DEF_OPS (ann); - for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF | SSA_OP_VMUSTDEF) { - tree def = V_MUST_DEF_OP (v_must_defs, i); - if (prepare_def_operand_for_rename (def, &uid)) { set_def_block (def, bb, false, false); @@ -414,19 +393,6 @@ mark_def_sites (struct dom_walk_data *walk_data, } } - /* Now process the definition made by this statement. Mark the - variables in KILLS. */ - defs = DEF_OPS (ann); - for (i = 0; i < NUM_DEFS (defs); i++) - { - tree def = DEF_OP (defs, i); - - if (prepare_def_operand_for_rename (def, &uid)) - { - set_def_block (def, bb, false, false); - SET_BIT (kills, uid); - } - } } /* Ditto, but works over ssa names. */ @@ -438,27 +404,19 @@ ssa_mark_def_sites (struct dom_walk_data *walk_data, { struct mark_def_sites_global_data *gd = walk_data->global_data; sbitmap kills = gd->kills; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - vuse_optype vuses; - def_optype defs; - use_optype uses; - size_t i, uid, def_uid; + size_t uid, def_uid; tree stmt, use, def; - stmt_ann_t ann; + ssa_op_iter iter; /* Mark all the blocks that have definitions for each variable in the names_to_rename bitmap. */ stmt = bsi_stmt (bsi); get_stmt_operands (stmt); - ann = stmt_ann (stmt); /* If a variable is used before being set, then the variable is live across a block boundary, so mark it live-on-entry to BB. */ - uses = USE_OPS (ann); - for (i = 0; i < NUM_USES (uses); i++) + FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_ALL_USES) { - use = USE_OP (uses, i); uid = SSA_NAME_VERSION (use); if (TEST_BIT (gd->names_to_rename, uid) @@ -466,61 +424,10 @@ ssa_mark_def_sites (struct dom_walk_data *walk_data, set_livein_block (use, bb); } - /* Similarly for virtual uses. */ - vuses = VUSE_OPS (ann); - for (i = 0; i < NUM_VUSES (vuses); i++) - { - use = VUSE_OP (vuses, i); - uid = SSA_NAME_VERSION (use); - - if (TEST_BIT (gd->names_to_rename, uid) - && !TEST_BIT (kills, uid)) - set_livein_block (use, bb); - } - - v_may_defs = V_MAY_DEF_OPS (ann); - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - use = V_MAY_DEF_OP (v_may_defs, i); - uid = SSA_NAME_VERSION (use); - - if (TEST_BIT (gd->names_to_rename, uid) - && !TEST_BIT (kills, uid)) - set_livein_block (use, bb); - } - /* Now process the definition made by this statement. Mark the variables in KILLS. */ - defs = DEF_OPS (ann); - for (i = 0; i < NUM_DEFS (defs); i++) - { - def = DEF_OP (defs, i); - def_uid = SSA_NAME_VERSION (def); - - if (TEST_BIT (gd->names_to_rename, def_uid)) - { - set_def_block (def, bb, false, true); - SET_BIT (kills, def_uid); - } - } - - v_may_defs = V_MAY_DEF_OPS (ann); - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - def = V_MAY_DEF_RESULT (v_may_defs, i); - def_uid = SSA_NAME_VERSION (def); - - if (TEST_BIT (gd->names_to_rename, def_uid)) - { - set_def_block (def, bb, false, true); - SET_BIT (kills, def_uid); - } - } - - v_must_defs = V_MUST_DEF_OPS (ann); - for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) + FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS) { - def = V_MUST_DEF_OP (v_must_defs, i); def_uid = SSA_NAME_VERSION (def); if (TEST_BIT (gd->names_to_rename, def_uid)) @@ -1138,14 +1045,11 @@ rewrite_stmt (struct dom_walk_data *walk_data, basic_block bb ATTRIBUTE_UNUSED, block_stmt_iterator si) { - size_t i; stmt_ann_t ann; tree stmt; - vuse_optype vuses; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - def_optype defs; - use_optype uses; + use_operand_p use_p; + def_operand_p def_p; + ssa_op_iter iter; struct rewrite_block_data *bd; bd = VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack); @@ -1167,25 +1071,13 @@ rewrite_stmt (struct dom_walk_data *walk_data, abort (); #endif - defs = DEF_OPS (ann); - uses = USE_OPS (ann); - vuses = VUSE_OPS (ann); - v_may_defs = V_MAY_DEF_OPS (ann); - v_must_defs = V_MUST_DEF_OPS (ann); - /* Step 1. Rewrite USES and VUSES in the statement. */ - for (i = 0; i < NUM_USES (uses); i++) - rewrite_operand (USE_OP_PTR (uses, i)); - - /* Rewrite virtual uses in the statement. */ - for (i = 0; i < NUM_VUSES (vuses); i++) - rewrite_operand (VUSE_OP_PTR (vuses, i)); + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) + rewrite_operand (use_p); /* Step 2. Register the statement's DEF and VDEF operands. */ - for (i = 0; i < NUM_DEFS (defs); i++) + FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS) { - def_operand_p def_p = DEF_OP_PTR (defs, i); - if (TREE_CODE (DEF_FROM_PTR (def_p)) != SSA_NAME) SET_DEF (def_p, make_ssa_name (DEF_FROM_PTR (def_p), stmt)); @@ -1193,36 +1085,6 @@ rewrite_stmt (struct dom_walk_data *walk_data, doesn't need to be renamed. */ register_new_def (DEF_FROM_PTR (def_p), &bd->block_defs); } - - /* Register new virtual definitions made by the statement. */ - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - rewrite_operand (V_MAY_DEF_OP_PTR (v_may_defs, i)); - - if (TREE_CODE (V_MAY_DEF_RESULT (v_may_defs, i)) != SSA_NAME) - 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. */ - register_new_def (V_MAY_DEF_RESULT (v_may_defs, i), &bd->block_defs); - } - - /* Register new virtual mustdefs made by the statement. */ - for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) - { - def_operand_p v_must_def_p = V_MUST_DEF_OP_PTR (v_must_defs, i); - - 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 (DEF_FROM_PTR (v_must_def_p), &bd->block_defs); - } - } /* Ditto, for rewriting ssa names. */ @@ -1232,16 +1094,11 @@ ssa_rewrite_stmt (struct dom_walk_data *walk_data, basic_block bb ATTRIBUTE_UNUSED, block_stmt_iterator si) { - size_t i; stmt_ann_t ann; tree stmt, var; + ssa_op_iter iter; use_operand_p use_p; def_operand_p def_p; - vuse_optype vuses; - v_may_def_optype v_may_defs; - v_must_def_optype v_must_defs; - def_optype defs; - use_optype uses; struct rewrite_block_data *bd; sbitmap names_to_rename = walk_data->global_data; @@ -1264,64 +1121,16 @@ ssa_rewrite_stmt (struct dom_walk_data *walk_data, abort (); #endif - defs = DEF_OPS (ann); - uses = USE_OPS (ann); - vuses = VUSE_OPS (ann); - v_may_defs = V_MAY_DEF_OPS (ann); - v_must_defs = V_MUST_DEF_OPS (ann); - /* Step 1. Rewrite USES and VUSES in the statement. */ - for (i = 0; i < NUM_USES (uses); i++) + FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) { - use_p = USE_OP_PTR (uses, i); - if (TEST_BIT (names_to_rename, SSA_NAME_VERSION (USE_FROM_PTR (use_p)))) - SET_USE (use_p, get_reaching_def (USE_FROM_PTR (use_p))); - } - - /* Rewrite virtual uses in the statement. */ - for (i = 0; i < NUM_VUSES (vuses); i++) - { - use_p = VUSE_OP_PTR (vuses, i); - if (TEST_BIT (names_to_rename, SSA_NAME_VERSION (USE_FROM_PTR (use_p)))) - SET_USE (use_p, get_reaching_def (USE_FROM_PTR (use_p))); - } - - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - use_p = V_MAY_DEF_OP_PTR (v_may_defs, i); if (TEST_BIT (names_to_rename, SSA_NAME_VERSION (USE_FROM_PTR (use_p)))) SET_USE (use_p, get_reaching_def (USE_FROM_PTR (use_p))); } /* Step 2. Register the statement's DEF and VDEF operands. */ - for (i = 0; i < NUM_DEFS (defs); i++) - { - def_p = DEF_OP_PTR (defs, i); - var = DEF_FROM_PTR (def_p); - - if (!TEST_BIT (names_to_rename, SSA_NAME_VERSION (var))) - continue; - - SET_DEF (def_p, duplicate_ssa_name (var, stmt)); - ssa_register_new_def (var, DEF_FROM_PTR (def_p), &bd->block_defs); - } - - /* Register new virtual definitions made by the statement. */ - for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++) - { - def_p = V_MAY_DEF_RESULT_PTR (v_may_defs, i); - var = DEF_FROM_PTR (def_p); - - if (!TEST_BIT (names_to_rename, SSA_NAME_VERSION (var))) - continue; - - SET_DEF (def_p, duplicate_ssa_name (var, stmt)); - ssa_register_new_def (var, DEF_FROM_PTR (def_p), &bd->block_defs); - } - - for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++) + FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS) { - def_p = V_MUST_DEF_OP_PTR (v_must_defs, i); var = DEF_FROM_PTR (def_p); if (!TEST_BIT (names_to_rename, SSA_NAME_VERSION (var))) |