summaryrefslogtreecommitdiff
path: root/gcc/df-problems.c
diff options
context:
space:
mode:
authorzadeck <zadeck@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-31 16:25:36 +0000
committerzadeck <zadeck@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-31 16:25:36 +0000
commite51dfa029f0d49f5226acbd88e3ccfd80f1d62ec (patch)
tree06681fbc4aff4b3025bdc9beee338213d6803bd4 /gcc/df-problems.c
parente4b5271963eb88fd2003b0052865245c93f57294 (diff)
downloadgcc-e51dfa029f0d49f5226acbd88e3ccfd80f1d62ec.tar.gz
2007-07-31 Kenneth Zadeck <zadeck@naturalbridge.com>
* df.h (DF_RU, DF_RU_BB_INFO, df_ru_bb_info, df_ru, df_ru_add_problem, df_ru_get_bb_info): Removed. (DF_RD, DF_UREC, DF_CHAIN, DF_NOTE): Renumbered. * df-problems.c (df_ru_problem_data, df_ru_set_bb_info, df_ru_free_bb_info, df_ru_alloc, df_ru_bb_local_compute_process_def, df_ru_bb_local_compute_process_use, df_ru_bb_local_compute, df_ru_local_compute, df_ru_init_solution, df_ru_confluence_n, df_ru_transfer_function, df_ru_free, df_ru_start_dump, df_ru_top_dump, df_ru_bottom_dump, df_problem problem_RU, df_ru_add_problem): Removed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127099 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/df-problems.c')
-rw-r--r--gcc/df-problems.c530
1 files changed, 0 insertions, 530 deletions
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index b28fb16e177..f5ca47f785f 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -202,536 +202,6 @@ df_unset_seen (void)
/*----------------------------------------------------------------------------
- REACHING USES
-
- Find the locations in the function where each use site for a pseudo
- can reach backwards. In and out bitvectors are built for each basic
- block. The id field in the ref is used to index into these sets.
- See df.h for details.
-
-----------------------------------------------------------------------------*/
-
-/* This problem plays a large number of games for the sake of
- efficiency.
-
- 1) The order of the bits in the bitvectors. After the scanning
- phase, all of the uses are sorted. All of the uses for the reg 0
- are first, followed by all uses for reg 1 and so on.
-
- 2) There are two kill sets, one if the number of uses is less or
- equal to DF_SPARSE_THRESHOLD and another if it is greater.
-
- <= : Data is built directly in the kill set.
-
- > : One level of indirection is used to keep from generating long
- strings of 1 bits in the kill sets. Bitvectors that are indexed
- by the regnum are used to represent that there is a killing def
- for the register. The confluence and transfer functions use
- these along with the bitmap_clear_range call to remove ranges of
- bits without actually generating a knockout vector.
-
- The kill and sparse_kill and the dense_invalidated_by_call and
- sparse_invalidated_by_call both play this game. */
-
-/* Private data used to compute the solution for this problem. These
- data structures are not accessible outside of this module. */
-struct df_ru_problem_data
-{
- /* The set of defs to regs invalidated by call. */
- bitmap sparse_invalidated_by_call;
- /* The set of defs to regs invalidated by call for ru. */
- bitmap dense_invalidated_by_call;
- /* An obstack for the bitmaps we need for this problem. */
- bitmap_obstack ru_bitmaps;
-};
-
-/* Set basic block info. */
-
-static void
-df_ru_set_bb_info (unsigned int index, struct df_ru_bb_info *bb_info)
-{
- gcc_assert (df_ru);
- gcc_assert (index < df_ru->block_info_size);
- df_ru->block_info[index] = bb_info;
-}
-
-
-/* Free basic block info. */
-
-static void
-df_ru_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
- void *vbb_info)
-{
- struct df_ru_bb_info *bb_info = (struct df_ru_bb_info *) vbb_info;
- if (bb_info)
- {
- BITMAP_FREE (bb_info->kill);
- BITMAP_FREE (bb_info->sparse_kill);
- BITMAP_FREE (bb_info->gen);
- BITMAP_FREE (bb_info->in);
- BITMAP_FREE (bb_info->out);
- pool_free (df_ru->block_pool, bb_info);
- }
-}
-
-
-/* Allocate or reset bitmaps for DF_RU blocks. The solution bits are
- not touched unless the block is new. */
-
-static void
-df_ru_alloc (bitmap all_blocks)
-{
- unsigned int bb_index;
- bitmap_iterator bi;
- struct df_ru_problem_data *problem_data;
-
- if (!df_ru->block_pool)
- df_ru->block_pool = create_alloc_pool ("df_ru_block pool",
- sizeof (struct df_ru_bb_info), 50);
-
- if (df_ru->problem_data)
- {
- problem_data = (struct df_ru_problem_data *) df_ru->problem_data;
- bitmap_clear (problem_data->sparse_invalidated_by_call);
- bitmap_clear (problem_data->dense_invalidated_by_call);
- }
- else
- {
- problem_data = XNEW (struct df_ru_problem_data);
- df_ru->problem_data = problem_data;
-
- bitmap_obstack_initialize (&problem_data->ru_bitmaps);
- problem_data->sparse_invalidated_by_call
- = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- problem_data->dense_invalidated_by_call
- = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- }
-
- df_grow_bb_info (df_ru);
-
- /* Because of the clustering of all def sites for the same pseudo,
- we have to process all of the blocks before doing the
- analysis. */
-
- EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
- {
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb_index);
- if (bb_info)
- {
- bitmap_clear (bb_info->kill);
- bitmap_clear (bb_info->sparse_kill);
- bitmap_clear (bb_info->gen);
- }
- else
- {
- bb_info = (struct df_ru_bb_info *) pool_alloc (df_ru->block_pool);
- df_ru_set_bb_info (bb_index, bb_info);
- bb_info->kill = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- bb_info->sparse_kill = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- bb_info->gen = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- bb_info->in = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- bb_info->out = BITMAP_ALLOC (&problem_data->ru_bitmaps);
- }
- }
- df_ru->optional_p = true;
-}
-
-
-/* Process a list of DEFs for df_ru_bb_local_compute. */
-
-static void
-df_ru_bb_local_compute_process_def (struct df_ru_bb_info *bb_info,
- struct df_ref **def_rec,
- enum df_ref_flags top_flag)
-{
- while (*def_rec)
- {
- struct df_ref *def = *def_rec;
- if ((top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
- /* If the def is to only part of the reg, it is as if it did
- not happen, since some of the bits may get thru. */
- && (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))))
- {
- unsigned int regno = DF_REF_REGNO (def);
- unsigned int begin = DF_USES_BEGIN (regno);
- unsigned int n_uses = DF_USES_COUNT (regno);
-
- if (!bitmap_bit_p (seen_in_block, regno))
- {
- /* The first def for regno in the insn, causes the kill
- info to be generated. Do not modify the gen set
- because the only values in it are the uses from here
- to the top of the block and this def does not effect
- them. */
- if (!bitmap_bit_p (seen_in_insn, regno))
- {
- if (n_uses > DF_SPARSE_THRESHOLD)
- bitmap_set_bit (bb_info->sparse_kill, regno);
- else
- bitmap_set_range (bb_info->kill, begin, n_uses);
- }
- bitmap_set_bit (seen_in_insn, regno);
- }
- }
- def_rec++;
- }
-}
-
-
-/* Process a list of USEs for df_ru_bb_local_compute. */
-
-static void
-df_ru_bb_local_compute_process_use (struct df_ru_bb_info *bb_info,
- struct df_ref **use_rec,
- enum df_ref_flags top_flag)
-{
- while (*use_rec)
- {
- struct df_ref *use = *use_rec;
- if (top_flag == (DF_REF_FLAGS (use) & DF_REF_AT_TOP))
- {
- /* Add use to set of gens in this BB unless we have seen a
- def in a previous instruction. */
- unsigned int regno = DF_REF_REGNO (use);
- if (!bitmap_bit_p (seen_in_block, regno))
- bitmap_set_bit (bb_info->gen, DF_REF_ID (use));
- }
- use_rec++;
- }
-}
-
-/* Compute local reaching use (upward exposed use) info for basic
- block BB. USE_INFO->REGS[R] caches the set of uses for register R. */
-static void
-df_ru_bb_local_compute (unsigned int bb_index)
-{
- basic_block bb = BASIC_BLOCK (bb_index);
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb_index);
- rtx insn;
-
- /* Set when a def for regno is seen. */
- bitmap_clear (seen_in_block);
- bitmap_clear (seen_in_insn);
-
-#ifdef EH_USES
- /* Variables defined in the prolog that are used by the exception
- handler. */
- df_ru_bb_local_compute_process_use (bb_info,
- df_get_artificial_uses (bb_index),
- DF_REF_AT_TOP);
-#endif
- df_ru_bb_local_compute_process_def (bb_info,
- df_get_artificial_defs (bb_index),
- DF_REF_AT_TOP);
-
- FOR_BB_INSNS (bb, insn)
- {
- unsigned int uid = INSN_UID (insn);
- if (!INSN_P (insn))
- continue;
-
- df_ru_bb_local_compute_process_use (bb_info,
- DF_INSN_UID_USES (uid), 0);
-
- if (df->changeable_flags & DF_EQ_NOTES)
- df_ru_bb_local_compute_process_use (bb_info,
- DF_INSN_UID_EQ_USES (uid), 0);
-
- df_ru_bb_local_compute_process_def (bb_info,
- DF_INSN_UID_DEFS (uid), 0);
-
- bitmap_ior_into (seen_in_block, seen_in_insn);
- bitmap_clear (seen_in_insn);
- }
-
- /* Process the hardware registers that are always live. */
- df_ru_bb_local_compute_process_use (bb_info,
- df_get_artificial_uses (bb_index), 0);
-
- df_ru_bb_local_compute_process_def (bb_info,
- df_get_artificial_defs (bb_index), 0);
-}
-
-
-/* Compute local reaching use (upward exposed use) info for each basic
- block within BLOCKS. */
-static void
-df_ru_local_compute (bitmap all_blocks)
-{
- unsigned int bb_index;
- bitmap_iterator bi;
- unsigned int regno;
- struct df_ru_problem_data *problem_data
- = (struct df_ru_problem_data *) df_ru->problem_data;
- bitmap sparse_invalidated = problem_data->sparse_invalidated_by_call;
- bitmap dense_invalidated = problem_data->dense_invalidated_by_call;
-
- df_set_seen ();
-
- df_maybe_reorganize_use_refs (df->changeable_flags & DF_EQ_NOTES ?
- DF_REF_ORDER_BY_REG_WITH_NOTES : DF_REF_ORDER_BY_REG);
-
- EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
- {
- df_ru_bb_local_compute (bb_index);
- }
-
- /* Set up the knockout bit vectors to be applied across EH_EDGES. */
- EXECUTE_IF_SET_IN_BITMAP (df_invalidated_by_call, 0, regno, bi)
- {
- if (DF_USES_COUNT (regno) > DF_SPARSE_THRESHOLD)
- bitmap_set_bit (sparse_invalidated, regno);
- else
- bitmap_set_range (dense_invalidated,
- DF_USES_BEGIN (regno),
- DF_USES_COUNT (regno));
- }
-
- df_unset_seen ();
-}
-
-
-/* Initialize the solution bit vectors for problem. */
-
-static void
-df_ru_init_solution (bitmap all_blocks)
-{
- unsigned int bb_index;
- bitmap_iterator bi;
-
- EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
- {
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb_index);
- bitmap_copy (bb_info->in, bb_info->gen);
- bitmap_clear (bb_info->out);
- }
-}
-
-
-/* Out of target gets or of in of source. */
-
-static void
-df_ru_confluence_n (edge e)
-{
- bitmap op1 = df_ru_get_bb_info (e->src->index)->out;
- bitmap op2 = df_ru_get_bb_info (e->dest->index)->in;
-
- if (e->flags & EDGE_EH)
- {
- struct df_ru_problem_data *problem_data
- = (struct df_ru_problem_data *) df_ru->problem_data;
- bitmap sparse_invalidated = problem_data->sparse_invalidated_by_call;
- bitmap dense_invalidated = problem_data->dense_invalidated_by_call;
- bitmap_iterator bi;
- unsigned int regno;
- bitmap tmp = BITMAP_ALLOC (&df_bitmap_obstack);
-
- bitmap_copy (tmp, op2);
- bitmap_and_compl_into (tmp, dense_invalidated);
-
- EXECUTE_IF_SET_IN_BITMAP (sparse_invalidated, 0, regno, bi)
- {
- bitmap_clear_range (tmp,
- DF_USES_BEGIN (regno),
- DF_USES_COUNT (regno));
- }
- bitmap_ior_into (op1, tmp);
- BITMAP_FREE (tmp);
- }
- else
- bitmap_ior_into (op1, op2);
-}
-
-
-/* Transfer function. */
-
-static bool
-df_ru_transfer_function (int bb_index)
-{
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb_index);
- unsigned int regno;
- bitmap_iterator bi;
- bitmap in = bb_info->in;
- bitmap out = bb_info->out;
- bitmap gen = bb_info->gen;
- bitmap kill = bb_info->kill;
- bitmap sparse_kill = bb_info->sparse_kill;
-
- if (bitmap_empty_p (sparse_kill))
- return bitmap_ior_and_compl (in, gen, out, kill);
- else
- {
- struct df_ru_problem_data *problem_data;
- bitmap tmp;
- bool changed = false;
-
- /* Note that TMP is _not_ a temporary bitmap if we end up replacing
- IN with TMP. Therefore, allocate TMP in the RU bitmaps obstack. */
- problem_data = (struct df_ru_problem_data *) df_ru->problem_data;
- tmp = BITMAP_ALLOC (&problem_data->ru_bitmaps);
-
- bitmap_copy (tmp, out);
- EXECUTE_IF_SET_IN_BITMAP (sparse_kill, 0, regno, bi)
- {
- bitmap_clear_range (tmp,
- DF_USES_BEGIN (regno),
- DF_USES_COUNT (regno));
- }
- bitmap_and_compl_into (tmp, kill);
- bitmap_ior_into (tmp, gen);
- changed = !bitmap_equal_p (tmp, in);
- if (changed)
- {
- BITMAP_FREE (in);
- bb_info->in = tmp;
- }
- else
- BITMAP_FREE (tmp);
- return changed;
- }
-}
-
-
-/* Free all storage associated with the problem. */
-
-static void
-df_ru_free (void)
-{
- unsigned int i;
- struct df_ru_problem_data *problem_data
- = (struct df_ru_problem_data *) df_ru->problem_data;
-
- if (problem_data)
- {
- for (i = 0; i < df_ru->block_info_size; i++)
- {
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (i);
- if (bb_info)
- {
- BITMAP_FREE (bb_info->kill);
- BITMAP_FREE (bb_info->sparse_kill);
- BITMAP_FREE (bb_info->gen);
- BITMAP_FREE (bb_info->in);
- BITMAP_FREE (bb_info->out);
- }
- }
-
- free_alloc_pool (df_ru->block_pool);
- BITMAP_FREE (problem_data->sparse_invalidated_by_call);
- BITMAP_FREE (problem_data->dense_invalidated_by_call);
- bitmap_obstack_release (&problem_data->ru_bitmaps);
-
- df_ru->block_info_size = 0;
- free (df_ru->block_info);
- free (df_ru->problem_data);
- }
- free (df_ru);
-}
-
-
-/* Debugging info. */
-
-static void
-df_ru_start_dump (FILE *file)
-{
- struct df_ru_problem_data *problem_data
- = (struct df_ru_problem_data *) df_ru->problem_data;
- unsigned int m = DF_REG_SIZE(df);
- unsigned int regno;
-
- if (!df_ru->block_info)
- return;
-
- fprintf (file, ";; Reaching uses:\n");
-
- fprintf (file, ";; sparse invalidated \t");
- dump_bitmap (file, problem_data->sparse_invalidated_by_call);
- fprintf (file, " dense invalidated \t");
- dump_bitmap (file, problem_data->dense_invalidated_by_call);
-
- for (regno = 0; regno < m; regno++)
- if (DF_USES_COUNT (regno))
- fprintf (file, "%d[%d,%d] ", regno,
- DF_USES_BEGIN (regno),
- DF_USES_COUNT (regno));
- fprintf (file, "\n");
-}
-
-
-/* Debugging info at top of bb. */
-
-static void
-df_ru_top_dump (basic_block bb, FILE *file)
-{
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb->index);
- if (!bb_info || !bb_info->in)
- return;
-
- fprintf (file, ";; ru in \t(%d)\n", (int) bitmap_count_bits (bb_info->in));
- dump_bitmap (file, bb_info->in);
- fprintf (file, ";; ru gen \t(%d)\n", (int) bitmap_count_bits (bb_info->gen));
- dump_bitmap (file, bb_info->gen);
- fprintf (file, ";; ru kill\t(%d)\n", (int) bitmap_count_bits (bb_info->kill));
- dump_bitmap (file, bb_info->kill);
-}
-
-
-/* Debugging info at bottom of bb. */
-
-static void
-df_ru_bottom_dump (basic_block bb, FILE *file)
-{
- struct df_ru_bb_info *bb_info = df_ru_get_bb_info (bb->index);
- if (!bb_info || !bb_info->out)
- return;
-
- fprintf (file, ";; ru out \t(%d)\n", (int) bitmap_count_bits (bb_info->out));
- dump_bitmap (file, bb_info->out);
-}
-
-
-/* All of the information associated with every instance of the problem. */
-
-static struct df_problem problem_RU =
-{
- DF_RU, /* Problem id. */
- DF_BACKWARD, /* Direction. */
- df_ru_alloc, /* Allocate the problem specific data. */
- NULL, /* Reset global information. */
- df_ru_free_bb_info, /* Free basic block info. */
- df_ru_local_compute, /* Local compute function. */
- df_ru_init_solution, /* Init the solution specific data. */
- df_worklist_dataflow, /* Worklist solver. */
- NULL, /* Confluence operator 0. */
- df_ru_confluence_n, /* Confluence operator n. */
- df_ru_transfer_function, /* Transfer function. */
- NULL, /* Finalize function. */
- df_ru_free, /* Free all of the problem information. */
- df_ru_free, /* Remove this problem from the stack of dataflow problems. */
- df_ru_start_dump, /* Debugging. */
- df_ru_top_dump, /* Debugging start block. */
- df_ru_bottom_dump, /* Debugging end block. */
- NULL, /* Incremental solution verify start. */
- NULL, /* Incremental solution verify end. */
- NULL, /* Dependent problem. */
- TV_DF_RU, /* Timing variable. */
- true /* Reset blocks on dropping out of blocks_to_analyze. */
-};
-
-
-
-/* Create a new DATAFLOW instance and add it to an existing instance
- of DF. The returned structure is what is used to get at the
- solution. */
-
-void
-df_ru_add_problem (void)
-{
- df_add_problem (&problem_RU);
-}
-
-
-/*----------------------------------------------------------------------------
REACHING DEFINITIONS
Find the locations in the function where each definition site for a