#include "addresses.h"
#include "hard-reg-set.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 "tree-pass.h"
#include "df.h"
#include "rtl-iter.h"
+#include "emit-rtl.h"
/* The following code does forward propagation of hard register copies.
The object is to eliminate as many dependencies as possible, so that
rtx_insn *insn;
rtx *loc;
rtx new_rtx;
+
+ /* Pool allocation new operator. */
+ inline void *operator new (size_t)
+ {
+ return pool.allocate ();
+ }
+
+ /* Delete operator utilizing pool allocation. */
+ inline void operator delete (void *ptr)
+ {
+ pool.remove ((queued_debug_insn_change *) ptr);
+ }
+
+ /* Memory allocation pool. */
+ static pool_allocator<queued_debug_insn_change> pool;
};
/* For each register, we have a list of registers that contain the same
unsigned int n_debug_insn_changes;
};
-static alloc_pool debug_insn_changes_pool;
+pool_allocator<queued_debug_insn_change> queued_debug_insn_change::pool
+ ("debug insn changes pool", 256);
+
static bool skip_debug_insn_p;
static void kill_value_one_regno (unsigned, struct value_data *);
{
next = cur->next;
--vd->n_debug_insn_changes;
- pool_free (debug_insn_changes_pool, cur);
+ delete cur;
}
vd->e[regno].debug_insn_changes = NULL;
}
x = tmp ? tmp : SUBREG_REG (x);
}
if (REG_P (x))
- {
- unsigned int regno = REGNO (x);
- unsigned int n = hard_regno_nregs[regno][GET_MODE (x)];
-
- kill_value_regno (regno, n, vd);
- }
+ kill_value_regno (REGNO (x), REG_NREGS (x), vd);
}
/* Remember that REGNO is valid in MODE. */
and install that register as the root of its own value list. */
static void
-kill_autoinc_value (rtx insn, struct value_data *vd)
+kill_autoinc_value (rtx_insn *insn, struct value_data *vd)
{
subrtx_iterator::array_type array;
FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
return;
/* If SRC and DEST overlap, don't record anything. */
- dn = hard_regno_nregs[dr][GET_MODE (dest)];
- sn = hard_regno_nregs[sr][GET_MODE (dest)];
+ dn = REG_NREGS (dest);
+ sn = REG_NREGS (src);
if ((dr > sr && dr < sr + sn)
|| (sr > dr && sr < dr + dn))
return;
return NULL_RTX;
if (orig_mode == new_mode)
- return gen_rtx_raw_REG (new_mode, regno);
+ return gen_raw_REG (new_mode, regno);
else if (mode_change_ok (orig_mode, new_mode, regno))
{
int copy_nregs = hard_regno_nregs[copy_regno][copy_mode];
+ (BYTES_BIG_ENDIAN ? byteoffset : 0));
regno += subreg_regno_offset (regno, orig_mode, offset, new_mode);
if (HARD_REGNO_MODE_OK (regno, new_mode))
- return gen_rtx_raw_REG (new_mode, regno);
+ return gen_raw_REG (new_mode, regno);
}
return NULL_RTX;
}
fprintf (dump_file, "debug_insn %u: queued replacing reg %u with %u\n",
INSN_UID (insn), REGNO (*loc), REGNO (new_rtx));
- change = (struct queued_debug_insn_change *)
- pool_alloc (debug_insn_changes_pool);
+ change = new queued_debug_insn_change;
change->next = vd->e[REGNO (new_rtx)].debug_insn_changes;
change->insn = insn;
change->loc = loc;
}
}
+/* Apply clobbers of INSN in PATTERN and C_I_F_U to value_data VD. */
+
+static void
+kill_clobbered_values (rtx_insn *insn, struct value_data *vd)
+{
+ note_stores (PATTERN (insn), kill_clobbered_value, vd);
+
+ if (CALL_P (insn))
+ {
+ rtx exp;
+
+ for (exp = CALL_INSN_FUNCTION_USAGE (insn); exp; exp = XEXP (exp, 1))
+ {
+ rtx x = XEXP (exp, 0);
+ if (GET_CODE (x) == CLOBBER)
+ kill_value (SET_DEST (x), vd);
+ }
+ }
+}
+
/* Perform the forward copy propagation on basic block BB. */
static bool
/* Within asms, a clobber cannot overlap inputs or outputs.
I wouldn't think this were true for regular insns, but
scan_rtx treats them like that... */
- note_stores (PATTERN (insn), kill_clobbered_value, vd);
+ kill_clobbered_values (insn, vd);
/* Kill all auto-incremented values. */
/* ??? REG_INC is useless, since stack pushes aren't done that way. */
copy_value (dest, SET_SRC (x), vd);
ksvd.ignore_set_reg = dest;
set_regno = REGNO (dest);
- set_nregs
- = hard_regno_nregs[set_regno][GET_MODE (dest)];
+ set_nregs = REG_NREGS (dest);
break;
}
}
but instead among CLOBBERs on the CALL_INSN, we could wrongly
assume the value in it is still live. */
if (ksvd.ignore_set_reg)
- {
- note_stores (PATTERN (insn), kill_clobbered_value, vd);
- for (exp = CALL_INSN_FUNCTION_USAGE (insn);
- exp;
- exp = XEXP (exp, 1))
- {
- rtx x = XEXP (exp, 0);
- if (GET_CODE (x) == CLOBBER)
- kill_value (SET_DEST (x), vd);
- }
- }
+ kill_clobbered_values (insn, vd);
}
bool copy_p = (set
visited = sbitmap_alloc (last_basic_block_for_fn (fun));
bitmap_clear (visited);
- if (MAY_HAVE_DEBUG_INSNS)
- debug_insn_changes_pool
- = create_alloc_pool ("debug insn changes pool",
- sizeof (struct queued_debug_insn_change), 256);
-
FOR_EACH_BB_FN (bb, fun)
{
bitmap_set_bit (visited, bb->index);
}
}
- free_alloc_pool (debug_insn_changes_pool);
+ queued_debug_insn_change::pool.release ();
}
sbitmap_free (visited);