aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2005-03-18 16:50:29 +0000
committerDiego Novillo <dnovillo@redhat.com>2005-03-18 16:50:29 +0000
commit542958cd12aa4d4c597c444eee2990633f36f550 (patch)
tree4f46a68468772601bf09c07f6fa032cd798383db
parentdad778e1dd21c6a9413667c762afb2501ec4d60c (diff)
* tree-into-ssa.c (ssa_rewrite_finalize_block): Remove.
(ssa_register_new_def): Remove. (ssa_rewrite_stmt): Remove. (ssa_rewrite_phi_arguments): Remove. (ssa_rewrite_initialize_block): Remove. (ssa_mark_def_sites): Remove. (ssa_mark_def_sites_initialize_block): Remove. (ssa_mark_phi_uses): Remove. (rewrite_ssa_into_ssa): Remove. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tree-cleanup-branch@96688 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.tcb12
-rw-r--r--gcc/tree-into-ssa.c453
2 files changed, 12 insertions, 453 deletions
diff --git a/gcc/ChangeLog.tcb b/gcc/ChangeLog.tcb
index 20201b9b84b..f725d4d241a 100644
--- a/gcc/ChangeLog.tcb
+++ b/gcc/ChangeLog.tcb
@@ -1,5 +1,17 @@
2005-03-18 Diego Novillo <dnovillo@redhat.com>
+ * tree-into-ssa.c (ssa_rewrite_finalize_block): Remove.
+ (ssa_register_new_def): Remove.
+ (ssa_rewrite_stmt): Remove.
+ (ssa_rewrite_phi_arguments): Remove.
+ (ssa_rewrite_initialize_block): Remove.
+ (ssa_mark_def_sites): Remove.
+ (ssa_mark_def_sites_initialize_block): Remove.
+ (ssa_mark_phi_uses): Remove.
+ (rewrite_ssa_into_ssa): Remove.
+
+2005-03-18 Diego Novillo <dnovillo@redhat.com>
+
* Makefile.in (tree-into-ssa.o): Remove dependency on pointer-set.h.
(tree-cfg.o): Add dependency on vec.h.
* lambda-code.c (perfect_nestify): Mark for SSA updating any
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index cd0e8f4143f..0d1e799d086 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2836,456 +2836,3 @@ update_ssa (bool insert_phi_p)
timevar_pop (TV_TREE_SSA_INCREMENTAL);
}
-
-
-#if 0
-/*---------------------------------------------------------------------------
- Functions to fix a program in invalid SSA form into valid SSA
- form. The main entry point here is rewrite_ssa_into_ssa.
----------------------------------------------------------------------------*/
-
-/* Called after visiting basic block BB. Restore CURRDEFS to its
- original value. */
-
-static void
-ssa_rewrite_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
- basic_block bb ATTRIBUTE_UNUSED)
-{
-
- /* Step 5. Restore the current reaching definition for each variable
- referenced in the block (in reverse order). */
- while (VEC_length (tree_on_heap, block_defs_stack) > 0)
- {
- tree var = VEC_pop (tree_on_heap, block_defs_stack);
- tree saved_def;
-
- if (var == NULL)
- break;
-
- saved_def = VEC_pop (tree_on_heap, block_defs_stack);
- set_current_def (var, saved_def);
- }
-}
-
-
-/* Register DEF (an SSA_NAME) to be a new definition for the original
- ssa name VAR and push VAR's current reaching definition
- into the stack pointed by BLOCK_DEFS_P. */
-
-static void
-ssa_register_new_def (tree var, tree def)
-{
- tree currdef;
-
- /* If this variable is set in a single basic block and all uses are
- dominated by the set(s) in that single basic block, then there is
- nothing to do. TODO we should not be called at all, and just
- keep the original name. */
- if (get_phi_state (var) == NEED_PHI_STATE_NO)
- {
- set_current_def (var, def);
- return;
- }
-
- currdef = get_current_def (var);
-
- /* Push the current reaching definition into *BLOCK_DEFS_P. This stack is
- later used by the dominator tree callbacks to restore the reaching
- definitions for all the variables defined in the block after a recursive
- visit to all its immediately dominated blocks. */
- VEC_safe_push (tree_on_heap, block_defs_stack, currdef);
- VEC_safe_push (tree_on_heap, block_defs_stack, var);
-
- /* Set the current reaching definition for VAR to be DEF. */
- set_current_def (var, def);
-}
-
-
-/* Same as rewrite_stmt, for rewriting ssa names. */
-
-static void
-ssa_rewrite_stmt (struct dom_walk_data *walk_data,
- basic_block bb ATTRIBUTE_UNUSED,
- block_stmt_iterator si)
-{
- stmt_ann_t ann;
- tree stmt, var;
- ssa_op_iter iter;
- use_operand_p use_p;
- def_operand_p def_p;
- sbitmap names_to_rename = walk_data->global_data;
-
- stmt = bsi_stmt (si);
- ann = stmt_ann (stmt);
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Renaming statement ");
- print_generic_stmt (dump_file, stmt, TDF_SLIM);
- fprintf (dump_file, "\n");
- }
-
- /* We have just scanned the code for operands. No statement should
- be modified. */
- gcc_assert (!ann->modified);
-
- /* Step 1. Rewrite USES and VUSES in the statement. */
- FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES | SSA_OP_ALL_KILLS)
- {
- 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_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS)
- {
- 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));
- }
-}
-
-
-/* Ditto, for ssa name rewriting. */
-
-static void
-ssa_rewrite_phi_arguments (struct dom_walk_data *walk_data, basic_block bb)
-{
- edge e;
- sbitmap names_to_rename = walk_data->global_data;
- use_operand_p op;
- edge_iterator ei;
-
- FOR_EACH_EDGE (e, ei, bb->succs)
- {
- tree phi;
-
- if (e->dest == EXIT_BLOCK_PTR)
- continue;
-
- for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
- {
- op = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e);
- if (TREE_CODE (USE_FROM_PTR (op)) != SSA_NAME)
- continue;
-
- if (!TEST_BIT (names_to_rename, SSA_NAME_VERSION (USE_FROM_PTR (op))))
- continue;
-
- SET_USE (op, get_reaching_def (USE_FROM_PTR (op)));
- if (e->flags & EDGE_ABNORMAL)
- SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (op)) = 1;
- }
- }
-}
-
-/* Ditto, for rewriting ssa names. */
-
-static void
-ssa_rewrite_initialize_block (struct dom_walk_data *walk_data, basic_block bb)
-{
- tree phi, new_name;
- sbitmap names_to_rename = walk_data->global_data;
- edge e;
- bool abnormal_phi;
- edge_iterator ei;
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index);
-
- /* Mark the unwind point for this block. */
- VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
-
- FOR_EACH_EDGE (e, ei, bb->preds)
- if (e->flags & EDGE_ABNORMAL)
- break;
- abnormal_phi = (e != NULL);
-
- /* Step 1. Register new definitions for every PHI node in the block.
- Conceptually, all the PHI nodes are executed in parallel and each PHI
- node introduces a new version for the associated variable. */
- for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
- {
- tree result = PHI_RESULT (phi);
-
- if (TEST_BIT (names_to_rename, SSA_NAME_VERSION (result)))
- {
- new_name = duplicate_ssa_name (result, phi);
- SET_PHI_RESULT (phi, new_name);
-
- if (abnormal_phi)
- SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name) = 1;
- ssa_register_new_def (result, new_name);
- }
- }
-}
-
-
-/* Same as mark_def_sites, but works over SSA names. */
-
-static void
-ssa_mark_def_sites (struct dom_walk_data *walk_data,
- basic_block bb,
- block_stmt_iterator bsi)
-{
- struct mark_def_sites_global_data *gd = walk_data->global_data;
- bitmap kills = gd->kills;
- size_t uid, def_uid;
- tree stmt, use, def;
- 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);
-
- /* 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. */
- FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_ALL_USES | SSA_OP_ALL_KILLS)
- {
- uid = SSA_NAME_VERSION (use);
-
- if (TEST_BIT (gd->names_to_rename, uid)
- && !bitmap_bit_p (kills, uid))
- set_livein_block (use, bb);
- }
-
- /* Now process the definition made by this statement. Mark the
- variables in KILLS. */
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
- {
- def_uid = SSA_NAME_VERSION (def);
-
- if (TEST_BIT (gd->names_to_rename, def_uid))
- {
- set_def_block (def, bb, false, true);
- bitmap_set_bit (kills, def_uid);
- }
- }
-}
-
-
-/* Block initialization routine for mark_def_sites. Clear the
- KILLS bitmap at the start of each block. */
-
-static void
-ssa_mark_def_sites_initialize_block (struct dom_walk_data *walk_data,
- basic_block bb)
-{
- struct mark_def_sites_global_data *gd = walk_data->global_data;
- bitmap kills = gd->kills;
- tree phi, def;
- unsigned def_uid;
-
- bitmap_clear (kills);
-
- for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
- {
- def = PHI_RESULT (phi);
- def_uid = SSA_NAME_VERSION (def);
-
- if (!TEST_BIT (gd->names_to_rename, def_uid))
- continue;
-
- set_def_block (def, bb, true, true);
- bitmap_set_bit (kills, def_uid);
- }
-}
-
-/* Marks ssa names used as arguments of phis at the end of BB. */
-
-static void
-ssa_mark_phi_uses (struct dom_walk_data *walk_data, basic_block bb)
-{
- struct mark_def_sites_global_data *gd = walk_data->global_data;
- bitmap kills = gd->kills;
- edge e;
- tree phi, use;
- unsigned uid;
- edge_iterator ei;
-
- FOR_EACH_EDGE (e, ei, bb->succs)
- {
- if (e->dest == EXIT_BLOCK_PTR)
- continue;
-
- for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
- {
- use = PHI_ARG_DEF_FROM_EDGE (phi, e);
- if (TREE_CODE (use) != SSA_NAME)
- continue;
-
- uid = SSA_NAME_VERSION (use);
-
- if (TEST_BIT (gd->names_to_rename, uid)
- && !bitmap_bit_p (kills, uid))
- set_livein_block (use, bb);
- }
- }
-}
-
-
-/* The marked ssa names may have more than one definition;
- add PHI nodes and rewrite them to fix this. */
-
-void
-rewrite_ssa_into_ssa (void)
-{
- bitmap *dfs;
- basic_block bb;
- struct dom_walk_data walk_data;
- struct mark_def_sites_global_data mark_def_sites_global_data;
- unsigned i;
- sbitmap snames_to_rename;
- bitmap to_rename;
- bitmap_iterator bi;
-
- if (!any_marked_for_rewrite_p ())
- return;
- to_rename = marked_ssa_names ();
-
- timevar_push (TV_TREE_SSA_OTHER);
-
- /* Allocate memory for the DEF_BLOCKS hash table. */
- def_blocks = htab_create (num_ssa_names,
- def_blocks_hash, def_blocks_eq, def_blocks_free);
-
- /* Initialize dominance frontier and immediate dominator bitmaps.
- Also count the number of predecessors for each block. Doing so
- can save significant time during PHI insertion for large graphs. */
- dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap *));
- FOR_EACH_BB (bb)
- dfs[bb->index] = BITMAP_ALLOC (NULL);
-
- /* Ensure that the dominance information is OK. */
- calculate_dominance_info (CDI_DOMINATORS);
-
- /* Compute dominance frontiers. */
- compute_dominance_frontiers (dfs);
-
- /* Setup callbacks for the generic dominator tree walker to find and
- mark definition sites. */
- walk_data.walk_stmts_backward = false;
- walk_data.dom_direction = CDI_DOMINATORS;
- walk_data.initialize_block_local_data = NULL;
- walk_data.before_dom_children_before_stmts
- = ssa_mark_def_sites_initialize_block;
- walk_data.before_dom_children_walk_stmts = ssa_mark_def_sites;
- walk_data.before_dom_children_after_stmts = ssa_mark_phi_uses;
- walk_data.after_dom_children_before_stmts = NULL;
- walk_data.after_dom_children_walk_stmts = NULL;
- walk_data.after_dom_children_after_stmts = NULL;
- walk_data.interesting_blocks = NULL;
-
- snames_to_rename = sbitmap_alloc (num_ssa_names);
- sbitmap_zero (snames_to_rename);
- EXECUTE_IF_SET_IN_BITMAP (to_rename, 0, i, bi)
- {
- SET_BIT (snames_to_rename, i);
- set_current_def (ssa_name (i), NULL_TREE);
- }
-
- mark_def_sites_global_data.kills = BITMAP_ALLOC (NULL);
- mark_def_sites_global_data.names_to_rename = snames_to_rename;
- mark_def_sites_global_data.interesting_blocks = NULL;
- walk_data.global_data = &mark_def_sites_global_data;
-
- block_defs_stack = VEC_alloc (tree_on_heap, 10);
-
- /* We do not have any local data. */
- walk_data.block_local_data_size = 0;
-
- /* Initialize the dominator walker. */
- init_walk_dominator_tree (&walk_data);
-
- /* Recursively walk the dominator tree. */
- walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
-
- /* Finalize the dominator walker. */
- fini_walk_dominator_tree (&walk_data);
-
- /* We no longer need this bitmap, clear and free it. */
- BITMAP_FREE (mark_def_sites_global_data.kills);
-
- /* Insert PHI nodes at dominance frontiers of definition blocks. */
- insert_phi_nodes (dfs, to_rename);
-
- /* Rewrite all the basic blocks in the program. */
- timevar_push (TV_TREE_SSA_REWRITE_BLOCKS);
-
- /* Setup callbacks for the generic dominator tree walker. */
- walk_data.walk_stmts_backward = false;
- walk_data.dom_direction = CDI_DOMINATORS;
- walk_data.initialize_block_local_data = NULL;
- walk_data.before_dom_children_before_stmts = ssa_rewrite_initialize_block;
- walk_data.before_dom_children_walk_stmts = ssa_rewrite_stmt;
- walk_data.before_dom_children_after_stmts = ssa_rewrite_phi_arguments;
- walk_data.after_dom_children_before_stmts = NULL;
- walk_data.after_dom_children_walk_stmts = NULL;
- walk_data.after_dom_children_after_stmts = ssa_rewrite_finalize_block;
- walk_data.global_data = snames_to_rename;
- walk_data.block_local_data_size = 0;
- walk_data.interesting_blocks = NULL;
-
- /* Initialize the dominator walker. */
- init_walk_dominator_tree (&walk_data);
-
- /* Recursively walk the dominator tree rewriting each statement in
- each basic block. */
- walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
-
- /* Finalize the dominator walker. */
- fini_walk_dominator_tree (&walk_data);
-
- unmark_all_for_rewrite ();
-
- EXECUTE_IF_SET_IN_BITMAP (to_rename, 0, i, bi)
- {
- /* Free SSA_NAME_AUX. We don't have to zero it because
- release_ssa_name will. */
- if (SSA_NAME_AUX (ssa_name (i)))
- free (SSA_NAME_AUX (ssa_name (i)));
-
- release_ssa_name (ssa_name (i));
- }
-
- sbitmap_free (snames_to_rename);
-
- timevar_pop (TV_TREE_SSA_REWRITE_BLOCKS);
-
- /* Debugging dumps. */
- if (dump_file && (dump_flags & TDF_STATS))
- {
- dump_dfa_stats (dump_file);
- dump_tree_ssa_stats (dump_file);
- }
-
- /* Free allocated memory. */
- FOR_EACH_BB (bb)
- BITMAP_FREE (dfs[bb->index]);
- free (dfs);
-
- htab_delete (def_blocks);
-
-#ifdef ENABLE_CHECKING
- for (i = 1; i < num_ssa_names; i++)
- {
- tree name = ssa_name (i);
- if (!name)
- continue;
-
- gcc_assert (SSA_NAME_AUX (name) == NULL);
- }
-#endif
-
- BITMAP_FREE (to_rename);
-
- VEC_free (tree_on_heap, block_defs_stack);
- block_defs_stack = NULL;
- timevar_pop (TV_TREE_SSA_OTHER);
-}
-#endif