Commit fc188d37 by Andreas Krebbel Committed by Ulrich Weigand

cse.c (struct change_cc_mode_args): New structure.

2004-11-16  Andreas Krebbel  <krebbel1@de.ibm.com>

	* gcc/cse.c (struct change_cc_mode_args): New structure.
	(cse_change_cc_mode_insn): New function.
	(cse_change_cc_mode): Use validate_change to perfom changes.
	(cse_change_cc_mode_insns, cse_condition_code_reg):
	Call cse_change_cc_mode_insn.

From-SVN: r90728
parent be06f47b
2004-11-16 Andreas Krebbel <krebbel1@de.ibm.com>
* gcc/cse.c (struct change_cc_mode_args): New structure.
(cse_change_cc_mode_insn): New function.
(cse_change_cc_mode): Use validate_change to perfom changes.
(cse_change_cc_mode_insns, cse_condition_code_reg):
Call cse_change_cc_mode_insn.
2004-11-16 Steven Bosscher <stevenb@suse.de> 2004-11-16 Steven Bosscher <stevenb@suse.de>
* stack.h: Remove. * stack.h: Remove.
......
...@@ -263,6 +263,14 @@ struct qty_table_elem ...@@ -263,6 +263,14 @@ struct qty_table_elem
/* The table of all qtys, indexed by qty number. */ /* The table of all qtys, indexed by qty number. */
static struct qty_table_elem *qty_table; static struct qty_table_elem *qty_table;
/* Structure used to pass arguments via for_each_rtx to function
cse_change_cc_mode. */
struct change_cc_mode_args
{
rtx insn;
rtx newreg;
};
#ifdef HAVE_cc0 #ifdef HAVE_cc0
/* For machines that have a CC0, we do not record its value in the hash /* For machines that have a CC0, we do not record its value in the hash
table since its use is guaranteed to be the insn immediately following table since its use is guaranteed to be the insn immediately following
...@@ -653,6 +661,7 @@ static bool insn_live_p (rtx, int *); ...@@ -653,6 +661,7 @@ static bool insn_live_p (rtx, int *);
static bool set_live_p (rtx, rtx, int *); static bool set_live_p (rtx, rtx, int *);
static bool dead_libcall_p (rtx, int *); static bool dead_libcall_p (rtx, int *);
static int cse_change_cc_mode (rtx *, void *); static int cse_change_cc_mode (rtx *, void *);
static void cse_change_cc_mode_insn (rtx, rtx);
static void cse_change_cc_mode_insns (rtx, rtx, rtx); static void cse_change_cc_mode_insns (rtx, rtx, rtx);
static enum machine_mode cse_cc_succs (basic_block, rtx, rtx, bool); static enum machine_mode cse_cc_succs (basic_block, rtx, rtx, bool);
...@@ -7303,20 +7312,47 @@ delete_trivially_dead_insns (rtx insns, int nreg) ...@@ -7303,20 +7312,47 @@ delete_trivially_dead_insns (rtx insns, int nreg)
static int static int
cse_change_cc_mode (rtx *loc, void *data) cse_change_cc_mode (rtx *loc, void *data)
{ {
rtx newreg = (rtx) data; struct change_cc_mode_args* args = (struct change_cc_mode_args*)data;
if (*loc if (*loc
&& REG_P (*loc) && REG_P (*loc)
&& REGNO (*loc) == REGNO (newreg) && REGNO (*loc) == REGNO (args->newreg)
&& GET_MODE (*loc) != GET_MODE (newreg)) && GET_MODE (*loc) != GET_MODE (args->newreg))
{ {
*loc = newreg; validate_change (args->insn, loc, args->newreg, 1);
return -1; return -1;
} }
return 0; return 0;
} }
/* Change the mode of any reference to the register REGNO (NEWREG) to /* Change the mode of any reference to the register REGNO (NEWREG) to
GET_MODE (NEWREG) in INSN. */
static void
cse_change_cc_mode_insn (rtx insn, rtx newreg)
{
struct change_cc_mode_args args;
int success;
if (!INSN_P (insn))
return;
args.insn = insn;
args.newreg = newreg;
for_each_rtx (&PATTERN (insn), cse_change_cc_mode, &args);
for_each_rtx (&REG_NOTES (insn), cse_change_cc_mode, &args);
/* If the following assertion was triggered, there is most probably
something wrong with the cc_modes_compatible back end function.
CC modes only can be considered compatible if the insn - with the mode
replaced by any of the compatible modes - can still be recognized. */
success = apply_change_group ();
gcc_assert (success);
}
/* Change the mode of any reference to the register REGNO (NEWREG) to
GET_MODE (NEWREG), starting at START. Stop before END. Stop at GET_MODE (NEWREG), starting at START. Stop before END. Stop at
any instruction which modifies NEWREG. */ any instruction which modifies NEWREG. */
...@@ -7333,8 +7369,7 @@ cse_change_cc_mode_insns (rtx start, rtx end, rtx newreg) ...@@ -7333,8 +7369,7 @@ cse_change_cc_mode_insns (rtx start, rtx end, rtx newreg)
if (reg_set_p (newreg, insn)) if (reg_set_p (newreg, insn))
return; return;
for_each_rtx (&PATTERN (insn), cse_change_cc_mode, newreg); cse_change_cc_mode_insn (insn, newreg);
for_each_rtx (&REG_NOTES (insn), cse_change_cc_mode, newreg);
} }
} }
...@@ -7443,6 +7478,8 @@ cse_cc_succs (basic_block bb, rtx cc_reg, rtx cc_src, bool can_change_mode) ...@@ -7443,6 +7478,8 @@ cse_cc_succs (basic_block bb, rtx cc_reg, rtx cc_src, bool can_change_mode)
{ {
gcc_assert (can_change_mode); gcc_assert (can_change_mode);
mode = comp_mode; mode = comp_mode;
/* The modified insn will be re-recognized later. */
PUT_MODE (cc_src, mode); PUT_MODE (cc_src, mode);
} }
} }
...@@ -7622,12 +7659,7 @@ cse_condition_code_reg (void) ...@@ -7622,12 +7659,7 @@ cse_condition_code_reg (void)
{ {
rtx newreg = gen_rtx_REG (mode, REGNO (cc_reg)); rtx newreg = gen_rtx_REG (mode, REGNO (cc_reg));
/* Change the mode of CC_REG in CC_SRC_INSN to cse_change_cc_mode_insn (cc_src_insn, newreg);
GET_MODE (NEWREG). */
for_each_rtx (&PATTERN (cc_src_insn), cse_change_cc_mode,
newreg);
for_each_rtx (&REG_NOTES (cc_src_insn), cse_change_cc_mode,
newreg);
/* Do the same in the following insns that use the /* Do the same in the following insns that use the
current value of CC_REG within BB. */ current value of CC_REG within BB. */
......
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