aboutsummaryrefslogtreecommitdiff
path: root/gcc/df-problems.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/df-problems.c')
-rw-r--r--gcc/df-problems.c325
1 files changed, 130 insertions, 195 deletions
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index 77f8c99..d2fb13b 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -268,12 +268,10 @@ void
df_rd_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
bitmap local_rd)
{
- unsigned uid = INSN_UID (insn);
- df_ref *def_rec;
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+ FOR_EACH_INSN_DEF (def, insn)
{
- df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
if ((!(df->changeable_flags & DF_NO_HARD_REGS))
|| (dregno >= FIRST_PSEUDO_REGISTER))
@@ -838,6 +836,7 @@ df_lr_bb_local_compute (unsigned int bb_index)
rtx insn;
df_ref *def_rec;
df_ref *use_rec;
+ df_ref def, use;
/* Process the registers set in an exception handler. */
for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
@@ -862,30 +861,23 @@ df_lr_bb_local_compute (unsigned int bb_index)
FOR_BB_INSNS_REVERSE (bb, insn)
{
- unsigned int uid = INSN_UID (insn);
-
if (!NONDEBUG_INSN_P (insn))
continue;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- /* If the def is to only part of the reg, it does
- not kill the other defs that reach here. */
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
- {
- unsigned int dregno = DF_REF_REGNO (def);
- bitmap_set_bit (&bb_info->def, dregno);
- bitmap_clear_bit (&bb_info->use, dregno);
- }
- }
+ df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
+ /* If the def is to only part of the reg, it does
+ not kill the other defs that reach here. */
+ if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+ {
+ unsigned int dregno = DF_REF_REGNO (def);
+ bitmap_set_bit (&bb_info->def, dregno);
+ bitmap_clear_bit (&bb_info->use, dregno);
+ }
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- {
- df_ref use = *use_rec;
- /* Add use to set of uses in this BB. */
- bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
- }
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
+ /* Add use to set of uses in this BB. */
+ bitmap_set_bit (&bb_info->use, DF_REF_REGNO (use));
}
/* Process the registers set in an exception handler or the hard
@@ -1463,7 +1455,7 @@ df_live_bb_local_compute (unsigned int bb_index)
basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
struct df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
rtx insn;
- df_ref *def_rec;
+ df_ref def, *def_rec;
int luid = 0;
FOR_BB_INSNS (bb, insn)
@@ -1484,9 +1476,8 @@ df_live_bb_local_compute (unsigned int bb_index)
continue;
luid++;
- for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++)
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
{
- df_ref def = *def_rec;
unsigned int regno = DF_REF_REGNO (def);
if (DF_REF_FLAGS_IS_SET (def,
@@ -1985,6 +1976,7 @@ df_chain_remove_problem (void)
rtx insn;
df_ref *def_rec;
df_ref *use_rec;
+ df_ref def, use;
basic_block bb = BASIC_BLOCK_FOR_FN (cfun, bb_index);
if (df_chain_problem_p (DF_DU_CHAIN))
@@ -1995,23 +1987,20 @@ df_chain_remove_problem (void)
DF_REF_CHAIN (*use_rec) = NULL;
FOR_BB_INSNS (bb, insn)
- {
- unsigned int uid = INSN_UID (insn);
-
- if (INSN_P (insn))
- {
- if (df_chain_problem_p (DF_DU_CHAIN))
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- DF_REF_CHAIN (*def_rec) = NULL;
- if (df_chain_problem_p (DF_UD_CHAIN))
- {
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- DF_REF_CHAIN (*use_rec) = NULL;
- for (use_rec = DF_INSN_UID_EQ_USES (uid); *use_rec; use_rec++)
- DF_REF_CHAIN (*use_rec) = NULL;
- }
- }
- }
+ if (INSN_P (insn))
+ {
+ df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
+ if (df_chain_problem_p (DF_DU_CHAIN))
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
+ DF_REF_CHAIN (def) = NULL;
+ if (df_chain_problem_p (DF_UD_CHAIN))
+ {
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
+ DF_REF_CHAIN (use) = NULL;
+ FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
+ DF_REF_CHAIN (use) = NULL;
+ }
+ }
}
bitmap_clear (df_chain->out_of_date_transfer_functions);
@@ -2254,39 +2243,28 @@ df_chain_insn_top_dump (const_rtx insn, FILE *file)
if (df_chain_problem_p (DF_UD_CHAIN) && INSN_P (insn))
{
struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
- df_ref *use_rec = DF_INSN_INFO_USES (insn_info);
- df_ref *eq_use_rec = DF_INSN_INFO_EQ_USES (insn_info);
+ df_ref use;
+
fprintf (file, ";; UD chains for insn luid %d uid %d\n",
DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
- if (*use_rec || *eq_use_rec)
- {
- while (*use_rec)
- {
- df_ref use = *use_rec;
- if (! HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
- || !(df->changeable_flags & DF_NO_HARD_REGS))
- {
- fprintf (file, ";; reg %d ", DF_REF_REGNO (use));
- if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
- fprintf (file, "read/write ");
- df_chain_dump (DF_REF_CHAIN (use), file);
- fprintf (file, "\n");
- }
- use_rec++;
- }
- while (*eq_use_rec)
- {
- df_ref use = *eq_use_rec;
- if (! HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
- || !(df->changeable_flags & DF_NO_HARD_REGS))
- {
- fprintf (file, ";; eq_note reg %d ", DF_REF_REGNO (use));
- df_chain_dump (DF_REF_CHAIN (use), file);
- fprintf (file, "\n");
- }
- eq_use_rec++;
- }
- }
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
+ if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
+ || !(df->changeable_flags & DF_NO_HARD_REGS))
+ {
+ fprintf (file, ";; reg %d ", DF_REF_REGNO (use));
+ if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
+ fprintf (file, "read/write ");
+ df_chain_dump (DF_REF_CHAIN (use), file);
+ fprintf (file, "\n");
+ }
+ FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
+ if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (use))
+ || !(df->changeable_flags & DF_NO_HARD_REGS))
+ {
+ fprintf (file, ";; eq_note reg %d ", DF_REF_REGNO (use));
+ df_chain_dump (DF_REF_CHAIN (use), file);
+ fprintf (file, "\n");
+ }
}
}
@@ -2296,26 +2274,19 @@ df_chain_insn_bottom_dump (const_rtx insn, FILE *file)
if (df_chain_problem_p (DF_DU_CHAIN) && INSN_P (insn))
{
struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
- df_ref *def_rec = DF_INSN_INFO_DEFS (insn_info);
+ df_ref def;
fprintf (file, ";; DU chains for insn luid %d uid %d\n",
DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
- if (*def_rec)
- {
- while (*def_rec)
- {
- df_ref def = *def_rec;
- if (! HARD_REGISTER_NUM_P (DF_REF_REGNO (def))
- || !(df->changeable_flags & DF_NO_HARD_REGS))
- {
- fprintf (file, ";; reg %d ", DF_REF_REGNO (def));
- if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE)
- fprintf (file, "read/write ");
- df_chain_dump (DF_REF_CHAIN (def), file);
- fprintf (file, "\n");
- }
- def_rec++;
- }
- }
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
+ if (!HARD_REGISTER_NUM_P (DF_REF_REGNO (def))
+ || !(df->changeable_flags & DF_NO_HARD_REGS))
+ {
+ fprintf (file, ";; reg %d ", DF_REF_REGNO (def));
+ if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE)
+ fprintf (file, "read/write ");
+ df_chain_dump (DF_REF_CHAIN (def), file);
+ fprintf (file, "\n");
+ }
fprintf (file, "\n");
}
}
@@ -2534,6 +2505,7 @@ df_word_lr_bb_local_compute (unsigned int bb_index)
rtx insn;
df_ref *def_rec;
df_ref *use_rec;
+ df_ref def, use;
/* Ensure that artificial refs don't contain references to pseudos. */
for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
@@ -2550,26 +2522,20 @@ df_word_lr_bb_local_compute (unsigned int bb_index)
FOR_BB_INSNS_REVERSE (bb, insn)
{
- unsigned int uid = INSN_UID (insn);
-
if (!NONDEBUG_INSN_P (insn))
continue;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- /* If the def is to only part of the reg, it does
- not kill the other defs that reach here. */
- if (!(DF_REF_FLAGS (def) & (DF_REF_CONDITIONAL)))
- {
- df_word_lr_mark_ref (def, true, &bb_info->def);
- df_word_lr_mark_ref (def, false, &bb_info->use);
- }
- }
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- {
- df_ref use = *use_rec;
- df_word_lr_mark_ref (use, true, &bb_info->use);
- }
+
+ df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
+ /* If the def is to only part of the reg, it does
+ not kill the other defs that reach here. */
+ if (!(DF_REF_FLAGS (def) & (DF_REF_CONDITIONAL)))
+ {
+ df_word_lr_mark_ref (def, true, &bb_info->def);
+ df_word_lr_mark_ref (def, false, &bb_info->use);
+ }
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
+ df_word_lr_mark_ref (use, true, &bb_info->use);
}
}
@@ -2753,17 +2719,13 @@ bool
df_word_lr_simulate_defs (rtx insn, bitmap live)
{
bool changed = false;
- df_ref *def_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- if (DF_REF_FLAGS (def) & DF_REF_CONDITIONAL)
- changed = true;
- else
- changed |= df_word_lr_mark_ref (*def_rec, false, live);
- }
+ FOR_EACH_INSN_DEF (def, insn)
+ if (DF_REF_FLAGS (def) & DF_REF_CONDITIONAL)
+ changed = true;
+ else
+ changed |= df_word_lr_mark_ref (def, false, live);
return changed;
}
@@ -2773,11 +2735,10 @@ df_word_lr_simulate_defs (rtx insn, bitmap live)
void
df_word_lr_simulate_uses (rtx insn, bitmap live)
{
- df_ref *use_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref use;
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- df_word_lr_mark_ref (*use_rec, true, live);
+ FOR_EACH_INSN_USE (use, insn)
+ df_word_lr_mark_ref (use, true, live);
}
/*----------------------------------------------------------------------------
@@ -2899,22 +2860,19 @@ df_remove_dead_eq_notes (rtx insn, bitmap live)
one REG_EQUAL/EQUIV note, all of EQ_USES will refer to this note
so we need to purge the complete EQ_USES vector when removing
the note using df_notes_rescan. */
- df_ref *use_rec;
+ df_ref use;
bool deleted = false;
- for (use_rec = DF_INSN_EQ_USES (insn); *use_rec; use_rec++)
- {
- df_ref use = *use_rec;
- if (DF_REF_REGNO (use) > FIRST_PSEUDO_REGISTER
- && DF_REF_LOC (use)
- && (DF_REF_FLAGS (use) & DF_REF_IN_NOTE)
- && ! bitmap_bit_p (live, DF_REF_REGNO (use))
- && loc_mentioned_in_p (DF_REF_LOC (use), XEXP (link, 0)))
- {
- deleted = true;
- break;
- }
- }
+ FOR_EACH_INSN_EQ_USE (use, insn)
+ if (DF_REF_REGNO (use) > FIRST_PSEUDO_REGISTER
+ && DF_REF_LOC (use)
+ && (DF_REF_FLAGS (use) & DF_REF_IN_NOTE)
+ && !bitmap_bit_p (live, DF_REF_REGNO (use))
+ && loc_mentioned_in_p (DF_REF_LOC (use), XEXP (link, 0)))
+ {
+ deleted = true;
+ break;
+ }
if (deleted)
{
rtx next;
@@ -3156,6 +3114,7 @@ df_note_bb_compute (unsigned int bb_index,
rtx insn;
df_ref *def_rec;
df_ref *use_rec;
+ df_ref def, use;
struct dead_debug_local debug;
dead_debug_local_init (&debug, NULL, NULL);
@@ -3204,7 +3163,7 @@ df_note_bb_compute (unsigned int bb_index,
FOR_BB_INSNS_REVERSE (bb, insn)
{
- unsigned int uid = INSN_UID (insn);
+ df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
struct df_mw_hardreg **mws_rec;
int debug_insn;
@@ -3221,13 +3180,14 @@ df_note_bb_compute (unsigned int bb_index,
{
if (REG_DEAD_DEBUGGING && dump_file)
{
- fprintf (dump_file, "processing call %d\n live =", INSN_UID (insn));
+ fprintf (dump_file, "processing call %d\n live =",
+ INSN_UID (insn));
df_print_regset (dump_file, live);
}
/* We only care about real sets for calls. Clobbers cannot
be depended on to really die. */
- mws_rec = DF_INSN_UID_MWS (uid);
+ mws_rec = DF_INSN_INFO_MWS (insn_info);
while (*mws_rec)
{
struct df_mw_hardreg *mws = *mws_rec;
@@ -3241,9 +3201,8 @@ df_note_bb_compute (unsigned int bb_index,
/* All of the defs except the return value are some sort of
clobber. This code is for the return. */
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
{
- df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
{
@@ -3259,7 +3218,7 @@ df_note_bb_compute (unsigned int bb_index,
else
{
/* Regular insn. */
- mws_rec = DF_INSN_UID_MWS (uid);
+ mws_rec = DF_INSN_INFO_MWS (insn_info);
while (*mws_rec)
{
struct df_mw_hardreg *mws = *mws_rec;
@@ -3270,9 +3229,8 @@ df_note_bb_compute (unsigned int bb_index,
mws_rec++;
}
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
{
- df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
df_create_unused_note (insn,
def, live, artificial_uses, &debug);
@@ -3286,7 +3244,7 @@ df_note_bb_compute (unsigned int bb_index,
}
/* Process the uses. */
- mws_rec = DF_INSN_UID_MWS (uid);
+ mws_rec = DF_INSN_INFO_MWS (insn_info);
while (*mws_rec)
{
struct df_mw_hardreg *mws = *mws_rec;
@@ -3306,9 +3264,8 @@ df_note_bb_compute (unsigned int bb_index,
mws_rec++;
}
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
{
- df_ref use = *use_rec;
unsigned int uregno = DF_REF_REGNO (use);
if (REG_DEAD_DEBUGGING && dump_file && !debug_insn)
@@ -3475,14 +3432,10 @@ df_note_add_problem (void)
void
df_simulate_find_defs (rtx insn, bitmap defs)
{
- df_ref *def_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- bitmap_set_bit (defs, DF_REF_REGNO (def));
- }
+ FOR_EACH_INSN_DEF (def, insn)
+ bitmap_set_bit (defs, DF_REF_REGNO (def));
}
/* Find the set of uses for INSN. This includes partial defs. */
@@ -3490,20 +3443,14 @@ df_simulate_find_defs (rtx insn, bitmap defs)
static void
df_simulate_find_uses (rtx insn, bitmap uses)
{
- df_ref *rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref def, use;
+ struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
- for (rec = DF_INSN_UID_DEFS (uid); *rec; rec++)
- {
- df_ref def = *rec;
- if (DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))
- bitmap_set_bit (uses, DF_REF_REGNO (def));
- }
- for (rec = DF_INSN_UID_USES (uid); *rec; rec++)
- {
- df_ref use = *rec;
- bitmap_set_bit (uses, DF_REF_REGNO (use));
- }
+ FOR_EACH_INSN_INFO_DEF (def, insn_info)
+ if (DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))
+ bitmap_set_bit (uses, DF_REF_REGNO (def));
+ FOR_EACH_INSN_INFO_USE (use, insn_info)
+ bitmap_set_bit (uses, DF_REF_REGNO (use));
}
/* Find the set of real DEFs, which are not clobbers, for INSN. */
@@ -3511,15 +3458,11 @@ df_simulate_find_uses (rtx insn, bitmap uses)
void
df_simulate_find_noclobber_defs (rtx insn, bitmap defs)
{
- df_ref *def_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
- {
- df_ref def = *def_rec;
- if (!(DF_REF_FLAGS (def) & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
- bitmap_set_bit (defs, DF_REF_REGNO (def));
- }
+ FOR_EACH_INSN_DEF (def, insn)
+ if (!(DF_REF_FLAGS (def) & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
+ bitmap_set_bit (defs, DF_REF_REGNO (def));
}
@@ -3528,12 +3471,10 @@ df_simulate_find_noclobber_defs (rtx insn, bitmap defs)
void
df_simulate_defs (rtx insn, bitmap live)
{
- df_ref *def_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+ FOR_EACH_INSN_DEF (def, insn)
{
- df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
/* If the def is to only part of the reg, it does
@@ -3549,18 +3490,14 @@ df_simulate_defs (rtx insn, bitmap live)
void
df_simulate_uses (rtx insn, bitmap live)
{
- df_ref *use_rec;
- unsigned int uid = INSN_UID (insn);
+ df_ref use;
if (DEBUG_INSN_P (insn))
return;
- for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
- {
- df_ref use = *use_rec;
- /* Add use to set of uses in this BB. */
- bitmap_set_bit (live, DF_REF_REGNO (use));
- }
+ FOR_EACH_INSN_USE (use, insn)
+ /* Add use to set of uses in this BB. */
+ bitmap_set_bit (live, DF_REF_REGNO (use));
}
@@ -4206,14 +4143,12 @@ df_md_simulate_artificial_defs_at_top (basic_block bb, bitmap local_md)
void
df_md_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
- bitmap local_md)
+ bitmap local_md)
{
- unsigned uid = INSN_UID (insn);
- df_ref *def_rec;
+ df_ref def;
- for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+ FOR_EACH_INSN_DEF (def, insn)
{
- df_ref def = *def_rec;
unsigned int dregno = DF_REF_REGNO (def);
if ((!(df->changeable_flags & DF_NO_HARD_REGS))
|| (dregno >= FIRST_PSEUDO_REGISTER))