Commit d3e80850 by Bernd Schmidt Committed by Bernd Schmidt

regrename.c (struct du_head): Remove member terminated.

	* regrename.c (struct du_head): Remove member terminated.
	(create_new_chain): Don't initialize it.
	(scan_rtx_reg): Don't set or test it, test the open_chains_set
	bitmap instead.
	(tick, this_tick): New global variables, moved out of
	regrename_optimize.
	(current_id, open_chains, closed_chains, open_chains_set,
	live_in_chains, live_hard_regs): Reorder declarations.
	(dump_def_use_chain): Move function earlier in the file.
	(rename_chains): New static function, broken out of
	regrename_optimize.
	(regrename_optimize): Use it.  Remove #if 0'ed code.

From-SVN: r178057
parent 39b75e51
2011-08-25 Bernd Schmidt <bernds@codesourcery.com>
* regrename.c (struct du_head): Remove member terminated.
(create_new_chain): Don't initialize it.
(scan_rtx_reg): Don't set or test it, test the open_chains_set
bitmap instead.
(tick, this_tick): New global variables, moved out of
regrename_optimize.
(current_id, open_chains, closed_chains, open_chains_set,
live_in_chains, live_hard_regs): Reorder declarations.
(dump_def_use_chain): Move function earlier in the file.
(rename_chains): New static function, broken out of
regrename_optimize.
(regrename_optimize): Use it. Remove #if 0'ed code.
2011-08-25 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
* varasm.c: (default_binds_local_p_1): Commentary typo fix.
......
......@@ -85,8 +85,6 @@ struct du_head
/* Conflicts with untracked hard registers. */
HARD_REG_SET hard_conflicts;
/* Nonzero if the chain is finished; zero if it is still open. */
unsigned int terminated:1;
/* Nonzero if the chain crosses a call. */
unsigned int need_caller_save_reg:1;
/* Nonzero if the register is used in a way that prevents renaming,
......@@ -132,6 +130,11 @@ static const char * const scan_actions_name[] =
"mark_access"
};
/* TICK and THIS_TICK are used to record the last time we saw each
register. */
static int tick[FIRST_PSEUDO_REGISTER];
static int this_tick = 0;
static struct obstack rename_obstack;
static void do_replace (struct du_head *, int);
......@@ -147,8 +150,49 @@ static void dump_def_use_chain (struct du_head *);
typedef struct du_head *du_head_p;
DEF_VEC_P (du_head_p);
DEF_VEC_ALLOC_P (du_head_p, heap);
/* The id to be given to the next opened chain. */
static unsigned current_id;
/* A mapping of unique id numbers to chains. */
static VEC(du_head_p, heap) *id_to_chain;
/* List of currently open chains, and closed chains that can be renamed. */
static struct du_head *open_chains;
static struct du_head *closed_chains;
/* Bitmap of open chains. The bits set always match the list found in
open_chains. */
static bitmap_head open_chains_set;
/* Record the registers being tracked in open_chains. */
static HARD_REG_SET live_in_chains;
/* Record the registers that are live but not tracked. The intersection
between this and live_in_chains is empty. */
static HARD_REG_SET live_hard_regs;
/* Dump all def/use chains in CHAINS to DUMP_FILE. */
static void
dump_def_use_chain (struct du_head *head)
{
while (head)
{
struct du_chain *this_du = head->first;
fprintf (dump_file, "Register %s (%d):",
reg_names[head->regno], head->nregs);
while (this_du)
{
fprintf (dump_file, " %d [%s]", INSN_UID (this_du->insn),
reg_class_names[this_du->cl]);
this_du = this_du->next_use;
}
fprintf (dump_file, "\n");
head = head->next_chain;
}
}
static void
free_chain_data (void)
{
......@@ -225,46 +269,12 @@ check_new_reg_p (int reg ATTRIBUTE_UNUSED, int new_reg,
return true;
}
/* Perform register renaming on the current function. */
static unsigned int
regrename_optimize (void)
/* Process the closed chains starting with ALL_CHAINS and rename
registers if possible. */
static void
rename_chains (du_head_p all_chains)
{
int tick[FIRST_PSEUDO_REGISTER];
int this_tick = 0;
basic_block bb;
char *first_obj;
df_set_flags (DF_LR_RUN_DCE);
df_note_add_problem ();
df_analyze ();
df_set_flags (DF_DEFER_INSN_RESCAN);
memset (tick, 0, sizeof tick);
gcc_obstack_init (&rename_obstack);
first_obj = XOBNEWVAR (&rename_obstack, char, 0);
FOR_EACH_BB (bb)
{
struct du_head *all_chains = 0;
HARD_REG_SET unavailable;
#if 0
HARD_REG_SET regs_seen;
CLEAR_HARD_REG_SET (regs_seen);
#endif
id_to_chain = VEC_alloc (du_head_p, heap, 0);
CLEAR_HARD_REG_SET (unavailable);
if (dump_file)
fprintf (dump_file, "\nBasic block %d:\n", bb->index);
all_chains = build_def_use (bb);
if (dump_file)
dump_def_use_chain (all_chains);
CLEAR_HARD_REG_SET (unavailable);
/* Don't clobber traceback for noreturn functions. */
......@@ -297,15 +307,6 @@ regrename_optimize (void)
best_new_reg = reg;
best_nregs = this_head->nregs;
#if 0 /* This just disables optimization opportunities. */
/* Only rename once we've seen the reg more than once. */
if (! TEST_HARD_REG_BIT (regs_seen, reg))
{
SET_HARD_REG_BIT (regs_seen, reg);
continue;
}
#endif
if (fixed_regs[reg] || global_regs[reg]
#if !HARD_FRAME_POINTER_IS_FRAME_POINTER
|| (frame_pointer_needed && reg == HARD_FRAME_POINTER_REGNUM)
......@@ -363,9 +364,8 @@ regrename_optimize (void)
for (new_reg = 0; new_reg < FIRST_PSEUDO_REGISTER; new_reg++)
{
if (has_preferred_class
&& (pass == 0)
!= TEST_HARD_REG_BIT
(reg_class_contents[preferred_class], new_reg))
&& ((pass == 0) != TEST_HARD_REG_BIT
(reg_class_contents[preferred_class], new_reg)))
continue;
/* In the first pass, we force the renaming of registers that
......@@ -374,9 +374,9 @@ regrename_optimize (void)
if (check_new_reg_p (reg, new_reg, this_head,
this_unavailable)
&& ((pass == 0
&& !TEST_HARD_REG_BIT
&& (!TEST_HARD_REG_BIT
(reg_class_contents[preferred_class],
best_new_reg))
best_new_reg)))
|| tick[best_new_reg] > tick[new_reg]))
{
enum machine_mode mode
......@@ -414,6 +414,41 @@ regrename_optimize (void)
tick[best_new_reg] = ++this_tick;
df_set_regs_ever_live (best_new_reg, true);
}
}
/* Perform register renaming on the current function. */
static unsigned int
regrename_optimize (void)
{
basic_block bb;
char *first_obj;
df_set_flags (DF_LR_RUN_DCE);
df_note_add_problem ();
df_analyze ();
df_set_flags (DF_DEFER_INSN_RESCAN);
memset (tick, 0, sizeof tick);
gcc_obstack_init (&rename_obstack);
first_obj = XOBNEWVAR (&rename_obstack, char, 0);
FOR_EACH_BB (bb)
{
struct du_head *all_chains = 0;
id_to_chain = VEC_alloc (du_head_p, heap, 0);
if (dump_file)
fprintf (dump_file, "\nBasic block %d:\n", bb->index);
all_chains = build_def_use (bb);
if (dump_file)
dump_def_use_chain (all_chains);
rename_chains (all_chains);
free_chain_data ();
obstack_free (&rename_obstack, first_obj);
......@@ -475,24 +510,6 @@ mark_conflict (struct du_head *chains, unsigned id)
without renaming. */
static bool fail_current_block;
/* The id to be given to the next opened chain. */
static unsigned current_id;
/* List of currently open chains, and closed chains that can be renamed. */
static struct du_head *open_chains;
static struct du_head *closed_chains;
/* Bitmap of open chains. The bits set always match the list found in
open_chains. */
static bitmap_head open_chains_set;
/* Record the registers being tracked in open_chains. */
static HARD_REG_SET live_in_chains;
/* Record the registers that are live but not tracked. The intersection
between this and live_in_chains is empty. */
static HARD_REG_SET live_hard_regs;
/* Return true if OP is a reg for which all bits are set in PSET, false
if all bits are clear.
In other cases, set fail_current_block and return false. */
......@@ -571,7 +588,6 @@ create_new_chain (unsigned this_regno, unsigned this_nregs, rtx *loc,
head->nregs = this_nregs;
head->need_caller_save_reg = 0;
head->cannot_rename = 0;
head->terminated = 0;
VEC_safe_push (du_head_p, heap, id_to_chain, head);
head->id = current_id++;
......@@ -650,7 +666,7 @@ scan_rtx_reg (rtx insn, rtx *loc, enum reg_class cl, enum scan_actions action,
int subset = (this_regno >= head->regno
&& this_regno + this_nregs <= head->regno + head->nregs);
if (head->terminated
if (!bitmap_bit_p (&open_chains_set, head->id)
|| head->regno + head->nregs <= this_regno
|| this_regno + this_nregs <= head->regno)
{
......@@ -725,7 +741,6 @@ scan_rtx_reg (rtx insn, rtx *loc, enum reg_class cl, enum scan_actions action,
{
unsigned nregs;
head->terminated = 1;
if (subset && !superset)
head->cannot_rename = 1;
head->next_chain = closed_chains;
......@@ -1385,29 +1400,6 @@ build_def_use (basic_block bb)
return closed_chains;
}
/* Dump all def/use chains in CHAINS to DUMP_FILE. They are
printed in reverse order as that's how we build them. */
static void
dump_def_use_chain (struct du_head *head)
{
while (head)
{
struct du_chain *this_du = head->first;
fprintf (dump_file, "Register %s (%d):",
reg_names[head->regno], head->nregs);
while (this_du)
{
fprintf (dump_file, " %d [%s]", INSN_UID (this_du->insn),
reg_class_names[this_du->cl]);
this_du = this_du->next_use;
}
fprintf (dump_file, "\n");
head = head->next_chain;
}
}
static bool
gate_handle_regrename (void)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment