/* Allocation for dataflow support routines.
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
- Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008 Free Software Foundation, Inc.
Originally contributed by Michael P. Hayes
(m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-*/
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
/*
OVERVIEW:
There are three variations of the live variable problem that are
available whenever dataflow is available. The LR problem finds the
areas that can reach a use of a variable, the UR problems finds the
-areas tha can be reached from a definition of a variable. The LIVE
+areas that can be reached from a definition of a variable. The LIVE
problem finds the intersection of these two areas.
There are several optional problems. These can be enabled when they
section.
In the middle layer, basic blocks are scanned to produce transfer
-functions which describe the effects of that block on the a global
+functions which describe the effects of that block on the global
dataflow solution. The transfer functions are only rebuilt if the
some instruction within the block has changed.
The top layer is the dataflow solution itself. The dataflow solution
-is computed by using an efficient iterative solver and the trasfer
+is computed by using an efficient iterative solver and the transfer
functions. The dataflow solution must be recomputed whenever the
control changes or if one of the transfer function changes.
Here is an example of using the dataflow routines.
- df_[ru,rd,urec,ri,chain]_add_problem (flags);
+ df_[chain,live,note,rd]_add_problem (flags);
df_set_blocks (blocks);
df_dump (stderr);
- df_finish_pass ();
+ df_finish_pass (false);
-DF_[ru,rd,urec,ri,chain]_ADD_PROBLEM adds a problem, defined by an
+DF_[chain,live,note,rd]_ADD_PROBLEM adds a problem, defined by an
instance to struct df_problem, to the set of problems solved in this
instance of df. All calls to add a problem for a given instance of df
must occur before the first call to DF_ANALYZE.
DF_ANALYZE causes all of the defined problems to be (re)solved. When
DF_ANALYZE is completes, the IN and OUT sets for each basic block
contain the computer information. The DF_*_BB_INFO macros can be used
-to access these bitvectors. All defered rescannings are down before
-the transfer functions are recompited.
+to access these bitvectors. All deferred rescannings are down before
+the transfer functions are recomputed.
DF_DUMP can then be called to dump the information produce to some
file. This calls DF_DUMP_START, to print the information that is not
DF_FINISH_PASS causes df_remove_problem to be called on all of the
optional problems. It also causes any insns whose scanning has been
-defered to be rescanned as well as clears all of the changeable flags.
+deferred to be rescanned as well as clears all of the changeable flags.
Setting the pass manager TODO_df_finish flag causes this function to
be run. However, the pass manager will call df_finish_pass AFTER the
pass dumping has been done, so if you want to see the results of the
For most modern rtl passes, this is certainly the easiest way to
manage rescanning the insns. This technique also has the advantage
that the scanning information is always correct and can be relied
- apon even after changes have been made to the instructions. This
+ upon even after changes have been made to the instructions. This
technique is contra indicated in several cases:
a) If def-use chains OR use-def chains (but not both) are built,
rescanned may be impractical. Cse and regrename fall into this
category.
-2) Defered rescanning - Calls to df_insn_rescan, df_notes_rescan, and
+2) Deferred rescanning - Calls to df_insn_rescan, df_notes_rescan, and
df_insn_delete do not immediately change the insn but instead make
a note that the insn needs to be rescanned. The next call to
df_analyze, df_finish_pass, or df_process_deferred_rescans will
To enable this mode, call df_set_flags (DF_DEFER_INSN_RESCAN).
(This mode can be cleared by calling df_clear_flags
- (DF_DEFER_INSN_RESCAN) but this does not cause the defered insns to
+ (DF_DEFER_INSN_RESCAN) but this does not cause the deferred insns to
be rescanned.
3) Total rescanning - In this mode the rescanning is disabled.
insns when only a small number of them have really changed.
4) Do it yourself - In this mechanism, the pass updates the insns
- itself using the low level df primatives. Currently no pass does
+ itself using the low level df primitives. Currently no pass does
this, but it has the advantage that it is quite efficient given
that the pass generally has exact knowledge of what it is changing.
ACCESSING INSNS:
-1) The df insn information is kept in the insns array. This array is
- indexed by insn uid.
-
-2) Each insn has three sets of refs: They are linked into one of three
- lists: the insn's defs list (accessed by the DF_INSN_DEFS or
- DF_INSN_UID_DEFS macros), the insn's uses list (accessed by the
- DF_INSN_USES or DF_INSN_UID_USES macros) or the insn's eq_uses list
- (accessed by the DF_INSN_EQ_USES or DF_INSN_UID_EQ_USES macros).
- The latter list are the list of references in REG_EQUAL or
- REG_EQUIV notes. These macros produce a ref (or NULL), the rest of
- the list can be obtained by traversal of the NEXT_REF field
- (accessed by the DF_REF_NEXT_REF macro.) There is no significance
- to the ordering of the uses or refs in an instruction.
-
-3) Each insn has a logical uid field (LUID). When properly set, this
- is an integer that numbers each insn in the basic block, in order from
- the start of the block. The numbers are only correct after a call to
- df_analyse. They will rot after insns are added deleted or moved
- around.
+1) The df insn information is kept in an array of DF_INSN_INFO objects.
+ The array is indexed by insn uid, and every DF_REF points to the
+ DF_INSN_INFO object of the insn that contains the reference.
+
+2) Each insn has three sets of refs, which are linked into one of three
+ lists: The insn's defs list (accessed by the DF_INSN_INFO_DEFS,
+ DF_INSN_DEFS, or DF_INSN_UID_DEFS macros), the insn's uses list
+ (accessed by the DF_INSN_INFO_USES, DF_INSN_USES, or
+ DF_INSN_UID_USES macros) or the insn's eq_uses list (accessed by the
+ DF_INSN_INFO_EQ_USES, DF_INSN_EQ_USES or DF_INSN_UID_EQ_USES macros).
+ The latter list are the list of references in REG_EQUAL or REG_EQUIV
+ notes. These macros produce a ref (or NULL), the rest of the list
+ can be obtained by traversal of the NEXT_REF field (accessed by the
+ DF_REF_NEXT_REF macro.) There is no significance to the ordering of
+ the uses or refs in an instruction.
+
+3) Each insn has a logical uid field (LUID) which is stored in the
+ DF_INSN_INFO object for the insn. The LUID field is accessed by
+ the DF_INSN_INFO_LUID, DF_INSN_LUID, and DF_INSN_UID_LUID macros.
+ When properly set, the LUID is an integer that numbers each insn in
+ the basic block, in order from the start of the block.
+ The numbers are only correct after a call to df_analyze. They will
+ rot after insns are added deleted or moved round.
ACCESSING REFS:
chains.
4) An array of all of the uses (and an array of all of the defs) can
-
be built. These arrays are indexed by the value in the id
structure. These arrays are only lazily kept up to date, and that
process can be expensive. To have these arrays built, call
A set to a REG inside a ZERO_EXTRACT, or a set to a non-paradoxical SUBREG
for which the number of word_mode units covered by the outer mode is
-smaller than that covered by the inner mode, invokes a read-modify-write.
+smaller than that covered by the inner mode, invokes a read-modify-write
operation. We generate both a use and a def and again mark them
read/write.
#include "timevar.h"
#include "df.h"
#include "tree-pass.h"
+#include "params.h"
static void *df_get_bb_info (struct dataflow *, unsigned int);
static void df_set_bb_info (struct dataflow *, unsigned int, void *);
bitmap_print (dump_file, blocks, "setting blocks to analyze ", "\n");
if (df->blocks_to_analyze)
{
+ /* This block is called to change the focus from one subset
+ to another. */
int p;
bitmap diff = BITMAP_ALLOC (&df_bitmap_obstack);
bitmap_and_compl (diff, df->blocks_to_analyze, blocks);
- for (p = df->num_problems_defined - 1; p >= DF_FIRST_OPTIONAL_PROBLEM ;p--)
+ for (p = 0; p < df->num_problems_defined; p++)
{
struct dataflow *dflow = df->problems_in_order[p];
- if (dflow->problem->reset_fun)
+ if (dflow->optional_p && dflow->problem->reset_fun)
dflow->problem->reset_fun (df->blocks_to_analyze);
- else if (dflow->problem->free_bb_fun)
+ else if (dflow->problem->free_blocks_on_set_blocks)
{
bitmap_iterator bi;
unsigned int bb_index;
}
else
{
- /* If we have not actually run scanning before, do not try
- to clear anything. */
- if (df_scan->problem_data)
+ /* This block of code is executed to change the focus from
+ the entire function to a subset. */
+ bitmap blocks_to_reset = NULL;
+ int p;
+ for (p = 0; p < df->num_problems_defined; p++)
{
- bitmap blocks_to_reset = NULL;
- int p;
- for (p = df->num_problems_defined - 1; p >= DF_FIRST_OPTIONAL_PROBLEM ;p--)
+ struct dataflow *dflow = df->problems_in_order[p];
+ if (dflow->optional_p && dflow->problem->reset_fun)
{
- struct dataflow *dflow = df->problems_in_order[p];
- if (dflow->problem->reset_fun)
+ if (!blocks_to_reset)
{
- if (!blocks_to_reset)
+ basic_block bb;
+ blocks_to_reset =
+ BITMAP_ALLOC (&df_bitmap_obstack);
+ FOR_ALL_BB(bb)
{
- basic_block bb;
- blocks_to_reset =
- BITMAP_ALLOC (&df_bitmap_obstack);
- FOR_ALL_BB(bb)
- {
- bitmap_set_bit (blocks_to_reset, bb->index);
- }
+ bitmap_set_bit (blocks_to_reset, bb->index);
}
- dflow->problem->reset_fun (blocks_to_reset);
}
+ dflow->problem->reset_fun (blocks_to_reset);
}
- if (blocks_to_reset)
- BITMAP_FREE (blocks_to_reset);
}
+ if (blocks_to_reset)
+ BITMAP_FREE (blocks_to_reset);
+
df->blocks_to_analyze = BITMAP_ALLOC (&df_bitmap_obstack);
}
bitmap_copy (df->blocks_to_analyze, blocks);
}
else
{
+ /* This block is executed to reset the focus to the entire
+ function. */
if (dump_file)
- fprintf (dump_file, "clearing blocks to analyze\n");
+ fprintf (dump_file, "clearing blocks_to_analyze\n");
if (df->blocks_to_analyze)
{
BITMAP_FREE (df->blocks_to_analyze);
{
struct df_problem *problem;
int i;
- int start = 0;
if (!dflow)
return;
problem = dflow->problem;
gcc_assert (problem->remove_problem_fun);
- /* Normally only optional problems are removed, but during global,
- we remove ur and live and replace it with urec. */
- if (problem->id >= DF_FIRST_OPTIONAL_PROBLEM)
- start = DF_FIRST_OPTIONAL_PROBLEM;
-
/* Delete any problems that depended on this problem first. */
- for (i = start; i < df->num_problems_defined; i++)
+ for (i = 0; i < df->num_problems_defined; i++)
if (df->problems_in_order[i]->problem->dependent_problem == problem)
df_remove_problem (df->problems_in_order[i]);
/* Now remove this problem. */
- for (i = start; i < df->num_problems_defined; i++)
+ for (i = 0; i < df->num_problems_defined; i++)
if (df->problems_in_order[i] == dflow)
{
int j;
for (j = i + 1; j < df->num_problems_defined; j++)
df->problems_in_order[j-1] = df->problems_in_order[j];
- df->problems_in_order[j] = NULL;
+ df->problems_in_order[j-1] = NULL;
df->num_problems_defined--;
break;
}
}
-/* Remove all of the problems that are not permanent. Scanning, lr,
- ur and live are permanent, the rest are removeable. Also clear all
- of the changeable_flags. */
+/* Remove all of the problems that are not permanent. Scanning, LR
+ and (at -O2 or higher) LIVE are permanent, the rest are removable.
+ Also clear all of the changeable_flags. */
void
-df_finish_pass (void)
+df_finish_pass (bool verify ATTRIBUTE_UNUSED)
{
int i;
int removed = 0;
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
enum df_changeable_flags saved_flags;
#endif
df_maybe_reorganize_def_refs (DF_REF_ORDER_NO_TABLE);
df_maybe_reorganize_use_refs (DF_REF_ORDER_NO_TABLE);
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
saved_flags = df->changeable_flags;
#endif
- for (i = DF_FIRST_OPTIONAL_PROBLEM; i < df->num_problems_defined; i++)
+ for (i = 0; i < df->num_problems_defined; i++)
{
struct dataflow *dflow = df->problems_in_order[i];
struct df_problem *problem = dflow->problem;
- gcc_assert (problem->remove_problem_fun);
- (problem->remove_problem_fun) ();
- df->problems_in_order[i] = NULL;
- df->problems_by_index[problem->id] = NULL;
- removed++;
+ if (dflow->optional_p)
+ {
+ gcc_assert (problem->remove_problem_fun);
+ (problem->remove_problem_fun) ();
+ df->problems_in_order[i] = NULL;
+ df->problems_by_index[problem->id] = NULL;
+ removed++;
+ }
}
df->num_problems_defined -= removed;
df->analyze_subset = false;
}
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
/* Verification will fail in DF_NO_INSN_RESCAN. */
if (!(saved_flags & DF_NO_INSN_RESCAN))
{
df_set_clean_cfg ();
#endif
#endif
+
+#ifdef ENABLE_CHECKING
+ if (verify)
+ df->changeable_flags |= DF_VERIFY_SCHEDULED;
+#endif
}
/* These three problems are permanent. */
df_lr_add_problem ();
- if (optimize)
+ if (optimize > 1)
df_live_add_problem ();
df->postorder = XNEWVEC (int, last_basic_block);
}
-struct tree_opt_pass pass_df_initialize_opt =
+struct rtl_opt_pass pass_df_initialize_opt =
{
+ {
+ RTL_PASS,
"dfinit", /* name */
gate_opt, /* gate */
rest_of_handle_df_initialize, /* execute */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- 0, /* todo_flags_finish */
- 'z' /* letter */
+ 0 /* todo_flags_finish */
+ }
};
}
-struct tree_opt_pass pass_df_initialize_no_opt =
+struct rtl_opt_pass pass_df_initialize_no_opt =
{
+ {
+ RTL_PASS,
"dfinit", /* name */
gate_no_opt, /* gate */
rest_of_handle_df_initialize, /* execute */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- 0, /* todo_flags_finish */
- 'z' /* letter */
+ 0 /* todo_flags_finish */
+ }
};
}
-struct tree_opt_pass pass_df_finish =
+struct rtl_opt_pass pass_df_finish =
{
+ {
+ RTL_PASS,
"dfinish", /* name */
NULL, /* gate */
rest_of_handle_df_finish, /* execute */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- 0, /* todo_flags_finish */
- 'z' /* letter */
+ 0 /* todo_flags_finish */
+ }
};
}
+
+/* This will free "pending". */
+
+static void
+df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
+ bitmap pending,
+ sbitmap considered,
+ int *blocks_in_postorder,
+ unsigned *bbindex_to_postorder)
+{
+ enum df_flow_dir dir = dataflow->problem->dir;
+ int dcount = 0;
+ bitmap worklist = BITMAP_ALLOC (&df_bitmap_obstack);
+
+ /* Double-queueing. Worklist is for the current iteration,
+ and pending is for the next. */
+ while (!bitmap_empty_p (pending))
+ {
+ /* Swap pending and worklist. */
+ bitmap temp = worklist;
+ worklist = pending;
+ pending = temp;
+
+ do
+ {
+ int index;
+ unsigned bb_index;
+ dcount++;
+
+ index = bitmap_first_set_bit (worklist);
+ bitmap_clear_bit (worklist, index);
+
+ bb_index = blocks_in_postorder[index];
+
+ if (dir == DF_FORWARD)
+ df_worklist_propagate_forward (dataflow, bb_index,
+ bbindex_to_postorder,
+ pending, considered);
+ else
+ df_worklist_propagate_backward (dataflow, bb_index,
+ bbindex_to_postorder,
+ pending, considered);
+ }
+ while (!bitmap_empty_p (worklist));
+ }
+
+ BITMAP_FREE (worklist);
+ BITMAP_FREE (pending);
+
+ /* Dump statistics. */
+ if (dump_file)
+ fprintf (dump_file, "df_worklist_dataflow_doublequeue:"
+ "n_basic_blocks %d n_edges %d"
+ " count %d (%5.2g)\n",
+ n_basic_blocks, n_edges,
+ dcount, dcount / (float)n_basic_blocks);
+}
+
/* Worklist-based dataflow solver. It uses sbitmap as a worklist,
with "n"-th bit representing the n-th block in the reverse-postorder order.
- This is so-called over-eager algorithm where it propagates
- changes on demand. This algorithm may visit blocks more than
- iterative method if there are deeply nested loops.
- Worklist algorithm works better than iterative algorithm
- for CFGs with no nested loops.
- In practice, the measurement shows worklist algorithm beats
- iterative algorithm by some margin overall.
- Note that this is slightly different from the traditional textbook worklist solver,
- in that the worklist is effectively sorted by the reverse postorder.
- For CFGs with no nested loops, this is optimal. */
+ The solver is a double-queue algorithm similar to the "double stack" solver
+ from Cooper, Harvey and Kennedy, "Iterative data-flow analysis, Revisited".
+ The only significant difference is that the worklist in this implementation
+ is always sorted in RPO of the CFG visiting direction. */
void
df_worklist_dataflow (struct dataflow *dataflow,
bitmap_set_bit (pending, i);
}
+ /* Initialize the problem. */
if (dataflow->problem->init_fun)
dataflow->problem->init_fun (blocks_to_consider);
- while (!bitmap_empty_p (pending))
- {
- unsigned bb_index;
-
- index = bitmap_first_set_bit (pending);
- bitmap_clear_bit (pending, index);
+ /* Solve it. */
+ df_worklist_dataflow_doublequeue (dataflow, pending, considered,
+ blocks_in_postorder,
+ bbindex_to_postorder);
- bb_index = blocks_in_postorder[index];
-
- if (dir == DF_FORWARD)
- df_worklist_propagate_forward (dataflow, bb_index,
- bbindex_to_postorder,
- pending, considered);
- else
- df_worklist_propagate_backward (dataflow, bb_index,
- bbindex_to_postorder,
- pending, considered);
- }
-
- BITMAP_FREE (pending);
sbitmap_free (considered);
free (bbindex_to_postorder);
}
{
timevar_push (dflow->problem->tv_id);
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
if (dflow->problem->verify_start_fun)
dflow->problem->verify_start_fun ();
#endif
if (dflow->problem->finalize_fun)
dflow->problem->finalize_fun (blocks_to_consider);
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
if (dflow->problem->verify_end_fun)
dflow->problem->verify_end_fun ();
#endif
df_compute_regs_ever_live (false);
df_process_deferred_rescans ();
-#ifdef ENABLE_CHECKING
if (dump_file)
fprintf (dump_file, "df_analyze called\n");
- df_verify ();
-#endif
+
+#ifndef ENABLE_DF_CHECKING
+ if (df->changeable_flags & DF_VERIFY_SCHEDULED)
+#endif
+ df_verify ();
for (i = 0; i < df->n_blocks; i++)
bitmap_set_bit (current_all_blocks, df->postorder[i]);
void **problem_temps;
int size = last_basic_block * sizeof (void *);
bitmap tmp = BITMAP_ALLOC (&df_bitmap_obstack);
- problem_temps = xmalloc (size);
+ problem_temps = XNEWVAR (void *, size);
for (p = 0; p < df->num_problems_defined; p++)
{
/* Verify that there is a place for everything and everything is in
its place. This is too expensive to run after every pass in the
mainline. However this is an excellent debugging tool if the
- dataflow infomation is not being updated properly. You can just
+ dataflow information is not being updated properly. You can just
sprinkle calls in until you find the place that is changing an
underlying structure without calling the proper updating
- rountine. */
+ routine. */
void
df_verify (void)
{
df_scan_verify ();
+#ifdef ENABLE_DF_CHECKING
df_lr_verify_transfer_functions ();
if (df_live)
df_live_verify_transfer_functions ();
+#endif
}
#ifdef DF_DEBUG_CFG
----------------------------------------------------------------------------*/
-/* Return last use of REGNO within BB. */
-
-struct df_ref *
-df_bb_regno_last_use_find (basic_block bb, unsigned int regno)
-{
- rtx insn;
- struct df_ref **use_rec;
- unsigned int uid;
-
- FOR_BB_INSNS_REVERSE (bb, insn)
- {
- if (!INSN_P (insn))
- continue;
-
- uid = INSN_UID (insn);
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- {
- struct df_ref *use = *use_rec;
- if (DF_REF_REGNO (use) == regno)
- return use;
- }
-
- if (df->changeable_flags & DF_EQ_NOTES)
- for (use_rec = DF_INSN_UID_EQ_USES (uid); *use_rec; use_rec++)
- {
- struct df_ref *use = *use_rec;
- if (DF_REF_REGNO (use) == regno)
- return use;
- }
- }
- return NULL;
-}
-
-
/* Return first def of REGNO within BB. */
-struct df_ref *
+df_ref
df_bb_regno_first_def_find (basic_block bb, unsigned int regno)
{
rtx insn;
- struct df_ref **def_rec;
+ df_ref *def_rec;
unsigned int uid;
FOR_BB_INSNS (bb, insn)
uid = INSN_UID (insn);
for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
{
- struct df_ref *def = *def_rec;
+ df_ref def = *def_rec;
if (DF_REF_REGNO (def) == regno)
return def;
}
/* Return last def of REGNO within BB. */
-struct df_ref *
+df_ref
df_bb_regno_last_def_find (basic_block bb, unsigned int regno)
{
rtx insn;
- struct df_ref **def_rec;
+ df_ref *def_rec;
unsigned int uid;
FOR_BB_INSNS_REVERSE (bb, insn)
uid = INSN_UID (insn);
for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
{
- struct df_ref *def = *def_rec;
+ df_ref def = *def_rec;
if (DF_REF_REGNO (def) == regno)
return def;
}
return NULL;
}
-/* Return true if INSN defines REGNO. */
-
-bool
-df_insn_regno_def_p (rtx insn, unsigned int regno)
-{
- unsigned int uid;
- struct df_ref **def_rec;
-
- uid = INSN_UID (insn);
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- struct df_ref *def = *def_rec;
- if (DF_REF_REGNO (def) == regno)
- return true;
- }
-
- return false;
-}
-
-
/* Finds the reference corresponding to the definition of REG in INSN.
DF is the dataflow object. */
-struct df_ref *
+df_ref
df_find_def (rtx insn, rtx reg)
{
unsigned int uid;
- struct df_ref **def_rec;
+ df_ref *def_rec;
if (GET_CODE (reg) == SUBREG)
reg = SUBREG_REG (reg);
uid = INSN_UID (insn);
for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
{
- struct df_ref *def = *def_rec;
+ df_ref def = *def_rec;
if (rtx_equal_p (DF_REF_REAL_REG (def), reg))
return def;
}
/* Finds the reference corresponding to the use of REG in INSN.
DF is the dataflow object. */
-struct df_ref *
+df_ref
df_find_use (rtx insn, rtx reg)
{
unsigned int uid;
- struct df_ref **use_rec;
+ df_ref *use_rec;
if (GET_CODE (reg) == SUBREG)
reg = SUBREG_REG (reg);
uid = INSN_UID (insn);
for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
{
- struct df_ref *use = *use_rec;
+ df_ref use = *use_rec;
if (rtx_equal_p (DF_REF_REAL_REG (use), reg))
return use;
}
if (df->changeable_flags & DF_EQ_NOTES)
for (use_rec = DF_INSN_UID_EQ_USES (uid); *use_rec; use_rec++)
{
- struct df_ref *use = *use_rec;
+ df_ref use = *use_rec;
if (rtx_equal_p (DF_REF_REAL_REG (use), reg))
return use;
}
}
+/* Write information about registers and basic blocks into FILE. The
+ bitmap is in the form used by df_byte_lr. This is part of making a
+ debugging dump. */
+
+void
+df_print_byte_regset (FILE *file, bitmap r)
+{
+ unsigned int max_reg = max_reg_num ();
+ bitmap_iterator bi;
+
+ if (r == NULL)
+ fputs (" (nil)", file);
+ else
+ {
+ unsigned int i;
+ for (i = 0; i < max_reg; i++)
+ {
+ unsigned int first = df_byte_lr_get_regno_start (i);
+ unsigned int len = df_byte_lr_get_regno_len (i);
+
+ if (len > 1)
+ {
+ bool found = false;
+ unsigned int j;
+
+ EXECUTE_IF_SET_IN_BITMAP (r, first, j, bi)
+ {
+ found = j < first + len;
+ break;
+ }
+ if (found)
+ {
+ const char * sep = "";
+ fprintf (file, " %d", i);
+ if (i < FIRST_PSEUDO_REGISTER)
+ fprintf (file, " [%s]", reg_names[i]);
+ fprintf (file, "(");
+ EXECUTE_IF_SET_IN_BITMAP (r, first, j, bi)
+ {
+ if (j > first + len - 1)
+ break;
+ fprintf (file, "%s%d", sep, j-first);
+ sep = ", ";
+ }
+ fprintf (file, ")");
+ }
+ }
+ else
+ {
+ if (bitmap_bit_p (r, first))
+ {
+ fprintf (file, " %d", i);
+ if (i < FIRST_PSEUDO_REGISTER)
+ fprintf (file, " [%s]", reg_names[i]);
+ }
+ }
+
+ }
+ }
+ fprintf (file, "\n");
+}
+
+
/* Dump dataflow info. */
+
void
df_dump (FILE *file)
{
}
+/* Dump dataflow info for df->blocks_to_analyze. */
+
+void
+df_dump_region (FILE *file)
+{
+ if (df->blocks_to_analyze)
+ {
+ bitmap_iterator bi;
+ unsigned int bb_index;
+
+ fprintf (file, "\n\nstarting region dump\n");
+ df_dump_start (file);
+
+ EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
+ {
+ basic_block bb = BASIC_BLOCK (bb_index);
+
+ df_print_bb_index (bb, file);
+ df_dump_top (bb, file);
+ df_dump_bottom (bb, file);
+ }
+ fprintf (file, "\n");
+ }
+ else
+ df_dump (file);
+}
+
+
/* Dump the introductory information for each problem defined. */
void
void
-df_refs_chain_dump (struct df_ref **ref_rec, bool follow_chain, FILE *file)
+df_refs_chain_dump (df_ref *ref_rec, bool follow_chain, FILE *file)
{
fprintf (file, "{ ");
while (*ref_rec)
{
- struct df_ref *ref = *ref_rec;
+ df_ref ref = *ref_rec;
fprintf (file, "%c%d(%d)",
DF_REF_REG_DEF_P (ref) ? 'd' : (DF_REF_FLAGS (ref) & DF_REF_IN_NOTE) ? 'e' : 'u',
DF_REF_ID (ref),
/* Dump either a ref-def or reg-use chain. */
void
-df_regs_chain_dump (struct df_ref *ref, FILE *file)
+df_regs_chain_dump (df_ref ref, FILE *file)
{
fprintf (file, "{ ");
while (ref)
DF_REF_REG_DEF_P (ref) ? 'd' : 'u',
DF_REF_ID (ref),
DF_REF_REGNO (ref));
- ref = ref->next_reg;
+ ref = DF_REF_NEXT_REG (ref);
}
fprintf (file, "}");
}
while (*mws)
{
fprintf (file, "mw %c r[%d..%d]\n",
- ((*mws)->type == DF_REF_REG_DEF) ? 'd' : 'u',
+ (DF_MWS_REG_DEF_P (*mws)) ? 'd' : 'u',
(*mws)->start_regno, (*mws)->end_regno);
mws++;
}
void
df_insn_debug_regno (rtx insn, FILE *file)
{
- unsigned int uid = INSN_UID(insn);
+ struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
fprintf (file, "insn %d bb %d luid %d defs ",
- uid, BLOCK_FOR_INSN (insn)->index, DF_INSN_LUID (insn));
- df_refs_chain_dump (DF_INSN_UID_DEFS (uid), false, file);
+ INSN_UID (insn), BLOCK_FOR_INSN (insn)->index,
+ DF_INSN_INFO_LUID (insn_info));
+ df_refs_chain_dump (DF_INSN_INFO_DEFS (insn_info), false, file);
fprintf (file, " uses ");
- df_refs_chain_dump (DF_INSN_UID_USES (uid), false, file);
+ df_refs_chain_dump (DF_INSN_INFO_USES (insn_info), false, file);
fprintf (file, " eq_uses ");
- df_refs_chain_dump (DF_INSN_UID_EQ_USES (uid), false, file);
+ df_refs_chain_dump (DF_INSN_INFO_EQ_USES (insn_info), false, file);
fprintf (file, "\n");
}
void
-df_ref_debug (struct df_ref *ref, FILE *file)
+df_ref_debug (df_ref ref, FILE *file)
{
fprintf (file, "%c%d ",
DF_REF_REG_DEF_P (ref) ? 'd' : 'u',
fprintf (file, "reg %d bb %d insn %d flag 0x%x type 0x%x ",
DF_REF_REGNO (ref),
DF_REF_BBNO (ref),
- DF_REF_INSN (ref) ? INSN_UID (DF_REF_INSN (ref)) : -1,
+ DF_REF_IS_ARTIFICIAL (ref) ? -1 : DF_REF_INSN_UID (ref),
DF_REF_FLAGS (ref),
DF_REF_TYPE (ref));
if (DF_REF_LOC (ref))
void
-debug_df_ref (struct df_ref *ref)
+debug_df_ref (df_ref ref)
{
df_ref_debug (ref, stderr);
}