#include "flags.h"
#include "insn-config.h"
#include "recog.h"
-#include "basic-block.h"
+#include "predict.h"
+#include "vec.h"
+#include "hashtab.h"
+#include "hash-set.h"
+#include "machmode.h"
+#include "input.h"
#include "function.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfgrtl.h"
+#include "cfganal.h"
+#include "lcm.h"
+#include "cfgcleanup.h"
+#include "basic-block.h"
#include "expr.h"
#include "except.h"
#include "ggc.h"
#include "hash-table.h"
#include "df.h"
#include "dbgcnt.h"
+#include "rtl-iter.h"
/* This pass implements downward store motion.
As of May 1, 2009, the pass is not enabled by default on any target,
/* List of registers mentioned by the mem. */
rtx pattern_regs;
/* INSN list of stores that are locally anticipatable. */
- rtx antic_stores;
+ rtx_insn_list *antic_stores;
/* INSN list of stores that are locally available. */
- rtx avail_stores;
+ rtx_insn_list *avail_stores;
/* Next in the list. */
struct st_expr * next;
/* Store ID in the dataflow bitmaps. */
ptr->next = store_motion_mems;
ptr->pattern = x;
ptr->pattern_regs = NULL_RTX;
- ptr->antic_stores = NULL_RTX;
- ptr->avail_stores = NULL_RTX;
+ ptr->antic_stores = NULL;
+ ptr->avail_stores = NULL;
ptr->reaching_reg = NULL_RTX;
ptr->index = 0;
ptr->hash_index = hash;
return true;
}
-/* Helper for extract_mentioned_regs. */
-
-static int
-extract_mentioned_regs_1 (rtx *loc, void *data)
-{
- rtx *mentioned_regs_p = (rtx *) data;
-
- if (REG_P (*loc))
- *mentioned_regs_p = alloc_EXPR_LIST (0, *loc, *mentioned_regs_p);
-
- return 0;
-}
-
/* Returns a list of registers mentioned in X.
FIXME: A regset would be prettier and less expensive. */
extract_mentioned_regs (rtx x)
{
rtx mentioned_regs = NULL;
- for_each_rtx (&x, extract_mentioned_regs_1, &mentioned_regs);
+ subrtx_var_iterator::array_type array;
+ FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
+ {
+ rtx x = *iter;
+ if (REG_P (x))
+ mentioned_regs = alloc_EXPR_LIST (0, x, mentioned_regs);
+ }
return mentioned_regs;
}
find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after)
{
struct st_expr * ptr;
- rtx dest, set, tmp;
+ rtx dest, set;
int check_anticipatable, check_available;
basic_block bb = BLOCK_FOR_INSN (insn);
check_anticipatable = 1;
else
{
- tmp = XEXP (ptr->antic_stores, 0);
+ rtx_insn *tmp = ptr->antic_stores->insn ();
if (tmp != NULL_RTX
&& BLOCK_FOR_INSN (tmp) != bb)
check_anticipatable = 1;
}
if (check_anticipatable)
{
+ rtx_insn *tmp;
if (store_killed_before (dest, ptr->pattern_regs, insn, bb, regs_set_before))
- tmp = NULL_RTX;
+ tmp = NULL;
else
tmp = insn;
ptr->antic_stores = alloc_INSN_LIST (tmp, ptr->antic_stores);
check_available = 1;
else
{
- tmp = XEXP (ptr->avail_stores, 0);
+ rtx_insn *tmp = ptr->avail_stores->insn ();
if (BLOCK_FOR_INSN (tmp) != bb)
check_available = 1;
}
failed last time. */
if (LAST_AVAIL_CHECK_FAILURE (ptr))
{
+ rtx_insn *tmp;
for (tmp = BB_END (bb);
tmp != insn && tmp != LAST_AVAIL_CHECK_FAILURE (ptr);
tmp = PREV_INSN (tmp))
unsigned regno;
#endif
rtx_insn *insn;
- rtx tmp;
+ rtx_insn *tmp;
df_ref def;
int *last_set_in, *already_set;
struct st_expr * ptr, **prev_next_ptr_ptr;
{
LAST_AVAIL_CHECK_FAILURE (ptr) = NULL_RTX;
if (ptr->antic_stores
- && (tmp = XEXP (ptr->antic_stores, 0)) == NULL_RTX)
- ptr->antic_stores = XEXP (ptr->antic_stores, 1);
+ && (tmp = ptr->antic_stores->insn ()) == NULL_RTX)
+ ptr->antic_stores = ptr->antic_stores->next ();
}
}
/* This routine will replace a store with a SET to a specified register. */
static void
-replace_store_insn (rtx reg, rtx del, basic_block bb, struct st_expr *smexpr)
+replace_store_insn (rtx reg, rtx_insn *del, basic_block bb,
+ struct st_expr *smexpr)
{
rtx_insn *insn;
rtx mem, note, set, ptr;
static void
delete_store (struct st_expr * expr, basic_block bb)
{
- rtx reg, i, del;
+ rtx reg;
if (expr->reaching_reg == NULL_RTX)
expr->reaching_reg = gen_reg_rtx_and_attrs (expr->pattern);
reg = expr->reaching_reg;
- for (i = expr->avail_stores; i; i = XEXP (i, 1))
+ for (rtx_insn_list *i = expr->avail_stores; i; i = i->next ())
{
- del = XEXP (i, 0);
+ rtx_insn *del = i->insn ();
if (BLOCK_FOR_INSN (del) == bb)
{
/* We know there is only one since we deleted redundant
{
basic_block bb;
int *regs_set_in_block;
- rtx insn, st;
+ rtx_insn *insn;
+ rtx_insn_list *st;
struct st_expr * ptr;
unsigned int max_gcse_regno = max_reg_num ();
for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
{
- for (st = ptr->avail_stores; st != NULL; st = XEXP (st, 1))
+ for (st = ptr->avail_stores; st != NULL; st = st->next ())
{
- insn = XEXP (st, 0);
+ insn = st->insn ();
bb = BLOCK_FOR_INSN (insn);
/* If we've already seen an available expression in this block,
rtx r = gen_reg_rtx_and_attrs (ptr->pattern);
if (dump_file)
fprintf (dump_file, "Removing redundant store:\n");
- replace_store_insn (r, XEXP (st, 0), bb, ptr);
+ replace_store_insn (r, st->insn (), bb, ptr);
continue;
}
bitmap_set_bit (st_avloc[bb->index], ptr->index);
}
- for (st = ptr->antic_stores; st != NULL; st = XEXP (st, 1))
+ for (st = ptr->antic_stores; st != NULL; st = st->next ())
{
- insn = XEXP (st, 0);
+ insn = st->insn ();
bb = BLOCK_FOR_INSN (insn);
bitmap_set_bit (st_antloc[bb->index], ptr->index);
}