#include "flags.h"
#include "insn-attr.h"
#include "function.h"
+#include "tm_p.h"
/* Target register optimizations - these are performed after reload. */
btr_user uses;
/* If this def has a reaching use which is not a simple use
in a branch instruction, then has_ambiguous_use will be true,
- and we will not attempt to migrate this definition. */
+ and we will not attempt to migrate this definition. */
char has_ambiguous_use;
/* live_range is an approximation to the true live range for this
def/use web, because it records the set of blocks that contain
containing the def (before the def), or in a block containing
a use (after the use). If there are such other live ranges, then
other_btr_uses_before_def or other_btr_uses_after_use must be set true
- as appropriate. */
+ as appropriate. */
char other_btr_uses_before_def;
char other_btr_uses_after_use;
bitmap live_range;
return 0;
}
-/* Find and return a use of a target register within an instruction INSN. */
+/* Find and return a use of a target register within an instruction INSN. */
static rtx *
find_btr_use (rtx insn)
{
if (!this_group)
{
- this_group = (btr_def_group)
- obstack_alloc (&migrate_btrl_obstack,
- sizeof (struct btr_def_group_s));
+ this_group = obstack_alloc (&migrate_btrl_obstack,
+ sizeof (struct btr_def_group_s));
this_group->src = def_src;
this_group->members = NULL;
this_group->next = *all_btr_def_groups;
unsigned int dest_reg, int other_btr_uses_before_def,
btr_def_group *all_btr_def_groups)
{
- btr_def this = (btr_def)
- obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_def_s));
+ btr_def this
+ = obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_def_s));
this->bb = bb;
this->luid = insn_luid;
this->insn = insn;
usep = NULL;
}
use = usep ? *usep : NULL_RTX;
- user = (btr_user)
- obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_user_s));
+ user = obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_user_s));
user->bb = bb;
user->luid = insn_luid;
user->insn = insn;
return user;
}
-/* Write the contents of S to the dump file. */
+/* Write the contents of S to the dump file. */
static void
dump_hard_reg_set (HARD_REG_SET s)
{
fprintf (rtl_dump_file, " %d", reg);
}
-/* Write the set of target regs live in block BB to the dump file. */
+/* Write the set of target regs live in block BB to the dump file. */
static void
dump_btrs_live (int bb)
{
/* Called via note_stores or directly to register stores into /
clobbers of a branch target register DEST that are not recognized as
straightforward definitions. DATA points to information about the
- current basic block that needs updating. */
+ current basic block that needs updating. */
static void
note_btr_set (rtx dest, rtx set ATTRIBUTE_UNUSED, void *data)
{
int regno;
/* For each basic block, form the set BB_KILL - the set
- of definitions that the block kills. */
+ of definitions that the block kills. */
sbitmap_vector_zero (bb_kill, n_basic_blocks);
for (i = 0; i < n_basic_blocks; i++)
{
For each block,
BB_IN = union over predecessors of BB_OUT(pred)
BB_OUT = (BB_IN - BB_KILL) + BB_GEN
- Iterate until the bb_out sets stop growing. */
+ Iterate until the bb_out sets stop growing. */
int i;
int changed;
sbitmap bb_in = sbitmap_alloc (max_uid);
sbitmap reaching_defs = sbitmap_alloc (max_uid);
/* Link uses to the uses lists of all of their reaching defs.
- Count up the number of reaching defs of each use. */
+ Count up the number of reaching defs of each use. */
for (i = 0; i < n_basic_blocks; i++)
{
basic_block bb = BASIC_BLOCK (i);
if (def != NULL)
{
/* Remove all reaching defs of regno except
- for this one. */
+ for this one. */
sbitmap_difference (reaching_defs, reaching_defs,
btr_defset[def->btr - first_btr]);
SET_BIT(reaching_defs, insn_uid);
if (user != NULL)
{
- /* Find all the reaching defs for this use */
+ /* Find all the reaching defs for this use. */
sbitmap reaching_defs_of_reg = sbitmap_alloc(max_uid);
int uid;
{
btr_def def = def_array[uid];
- /* We now know that def reaches user */
+ /* We now know that def reaches user. */
if (rtl_dump_file)
fprintf (rtl_dump_file,
if (user->first_reaching_def != -1)
{ /* There is more than one reaching def. This is
a rare case, so just give up on this def/use
- web when it occurs. */
+ web when it occurs. */
def->has_ambiguous_use = 1;
def_array[user->first_reaching_def]
->has_ambiguous_use = 1;
sbitmap *btr_defset = sbitmap_vector_alloc (
(last_btr - first_btr) + 1, max_uid);
sbitmap *bb_gen = sbitmap_vector_alloc (n_basic_blocks, max_uid);
- HARD_REG_SET *btrs_written = (HARD_REG_SET *) xcalloc (
- n_basic_blocks, sizeof (HARD_REG_SET));
+ HARD_REG_SET *btrs_written = xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
sbitmap *bb_kill;
sbitmap *bb_out;
Blocks at the boundary of the live range may contain other live
ranges for the same target register, so we have to be careful
to remove the target register from the live set of these blocks
- only if they do not contain other live ranges for the same register. */
+ only if they do not contain other live ranges for the same register. */
static void
clear_btr_from_live_range (btr_def def)
{
{
basic_block *worklist, *tos;
- tos = worklist =
- (basic_block *) xmalloc (sizeof (basic_block) * (n_basic_blocks + 1));
+ tos = worklist = xmalloc (sizeof (basic_block) * (n_basic_blocks + 1));
if (dominated_by_p (dom, new_bb, head_bb))
*tos++ = new_bb;
&& dominated_by_p (dom, other_def->bb, def->bb))
{
/* def->bb dominates the other def, so def and other_def could
- be combined. */
+ be combined. */
/* Merge their live ranges, and get the set of
- target registers live over the merged range. */
+ target registers live over the merged range. */
int btr;
HARD_REG_SET combined_btrs_live;
bitmap combined_live_range = BITMAP_XMALLOC ();
btr = choose_btr (combined_btrs_live);
if (btr != -1)
{
- /* We can combine them */
+ /* We can combine them. */
if (rtl_dump_file)
fprintf (rtl_dump_file,
"Combining def in insn %d with def in insn %d\n",
some REG_DEAD notes may no longer be correct. We could
be more precise about this if we looked at the combined
live range, but here I just delete any REG_DEAD notes
- in case they are no longer correct. */
+ in case they are no longer correct. */
for (user = def->uses; user != NULL; user = user->next)
remove_note (user->insn,
find_regno_note (user->insn, REG_DEAD,
def->other_btr_uses_after_use = 1;
COPY_HARD_REG_SET (*btrs_live_in_range, combined_btrs_live);
- /* Delete the old target register initialization */
+ /* Delete the old target register initialization. */
delete_insn (other_def->insn);
}
Set a target register in block NEW_DEF_BB to the value
needed for this target register definition.
Replace all uses of the old target register definition by
- uses of the new definition. Delete the old definition. */
+ uses of the new definition. Delete the old definition. */
basic_block b = new_def_bb;
rtx insp = b->head;
rtx old_insn = def->insn;
new_insn = gen_move_insn (btr_rtx, src);
- /* Insert target register initialization at head of basic block. */
+ /* Insert target register initialization at head of basic block. */
def->insn = emit_insn_after (new_insn, insp);
regs_ever_live[btr] = 1;
fprintf (rtl_dump_file, "New pt is insn %d, inserted after insn %d\n",
INSN_UID (def->insn), INSN_UID (insp));
- /* Delete the old target register initialization */
+ /* Delete the old target register initialization. */
delete_insn (old_insn);
/* Replace each use of the old target register by a use of the new target
- register. */
+ register. */
for (user = def->uses; user != NULL; user = user->next)
{
/* Some extra work here to ensure consistent modes, because
it seems that a target register REG rtx can be given a different
mode depending on the context (surely that should not be
- the case?). */
+ the case?). */
rtx replacement_rtx;
if (GET_MODE (user->use) == GET_MODE (btr_rtx)
|| GET_MODE (user->use) == VOIDmode)
MIN_COST is the lower bound on the cost of the DEF after migration.
If we migrate DEF so that its cost falls below MIN_COST,
then we do not attempt to migrate further. The idea is that
- we migrate defintions in a priority order based on their cost,
+ we migrate definitions in a priority order based on their cost,
when the cost of this definition falls below MIN_COST, then
there is another definition with cost == MIN_COST which now
has a higher priority than this definition.
Return nonzero if there may be benefit from attempting to
migrate this DEF further (i.e. we have reduced the cost below
MIN_COST, but we may be able to reduce it further).
- Return zero if no further migration is possible. */
+ Return zero if no further migration is possible. */
static int
migrate_btr_def (btr_def def, int min_cost)
{
INSN_UID (def->insn), def->cost, min_cost);
if (!def->group || def->has_ambiguous_use)
- /* These defs are not migratable */
+ /* These defs are not migratable. */
{
if (rtl_dump_file)
fprintf (rtl_dump_file, "it's not migratable\n");
try = get_immediate_dominator (dom, try))
{
/* Try to move the instruction that sets the target register into
- basic block TRY. */
+ basic block TRY. */
int try_freq = basic_block_freq (try);
if (rtl_dump_file)
}
/* Attempt to move instructions that set target registers earlier
- in the flowgraph, away from their corresponding uses. */
+ in the flowgraph, away from their corresponding uses. */
static void
migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
{
first_btr = reg;
}
- btrs_live =
- (HARD_REG_SET *) xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
+ btrs_live = xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
build_btr_def_use_webs (all_btr_defs);
else
issue_rate = 1;
- /* Build the CFG for migrate_btr_defs. */
+ /* Build the CFG for migrate_btr_defs. */
#if 1
/* This may or may not be needed, depending on where we
- run this phase. */
+ run this phase. */
cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
#endif
life_analysis (insns, NULL, 0);
- /* Dominator info is also needed for migrate_btr_def. */
+ /* Dominator info is also needed for migrate_btr_def. */
dom = calculate_dominance_info (CDI_DOMINATORS);
migrate_btr_defs (class,
((*targetm.branch_target_register_callee_saved)