#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "rtl.h"
#include "expr.h"
the same hard register in the same machine mode are in the same
class. */
-/* If conservative_reg_partition is non-zero, use a conservative
+/* If conservative_reg_partition is nonzero, use a conservative
register partitioning algorithm (which leaves more regs after
emerging from SSA) instead of the coalescing one. This is being
left in for a limited time only, as a debugging tool until the
partition reg_partition;
};
+static rtx gen_sequence
+ PARAMS ((void));
static void ssa_rename_from_initialize
PARAMS ((void));
static rtx ssa_rename_from_lookup
static inline rtx * phi_alternative
PARAMS ((rtx, int));
static void compute_dominance_frontiers_1
- PARAMS ((sbitmap *frontiers, int *idom, int bb, sbitmap done));
+ PARAMS ((sbitmap *frontiers, dominance_info idom, int bb, sbitmap done));
static void find_evaluations_1
PARAMS ((rtx dest, rtx set, void *data));
static void find_evaluations
static int rename_insn_1
PARAMS ((rtx *ptr, void *data));
static void rename_block
- PARAMS ((int b, int *idom));
+ PARAMS ((int b, dominance_info dom));
static void rename_registers
- PARAMS ((int nregs, int *idom));
+ PARAMS ((int nregs, dominance_info idom));
static inline int ephi_add_node
PARAMS ((rtx reg, rtx *nodes, int *n_nodes));
}
/* Given the SET of a phi node, remove the alternative for predecessor
- block C. Return non-zero on success, or zero if no alternative is
+ block C. Return nonzero on success, or zero if no alternative is
found for C. */
int
static void
compute_dominance_frontiers_1 (frontiers, idom, bb, done)
sbitmap *frontiers;
- int *idom;
+ dominance_info idom;
int bb;
sbitmap done;
{
dominator tree (blocks dominated by this one) are children in the
CFG, so check all blocks. */
FOR_EACH_BB (c)
- if (idom[c->index] == bb && ! TEST_BIT (done, c->index))
+ if (get_immediate_dominator (idom, c)->index == bb
+ && ! TEST_BIT (done, c->index))
compute_dominance_frontiers_1 (frontiers, idom, c->index, done);
/* Find blocks conforming to rule (1) above. */
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
- if (idom[e->dest->index] != bb)
+ if (get_immediate_dominator (idom, e->dest)->index != bb)
SET_BIT (frontiers[bb], e->dest->index);
}
/* Find blocks conforming to rule (2). */
FOR_EACH_BB (c)
- if (idom[c->index] == bb)
+ if (get_immediate_dominator (idom, c)->index == bb)
{
int x;
EXECUTE_IF_SET_IN_SBITMAP (frontiers[c->index], 0, x,
{
- if (idom[x] != bb)
+ if (get_immediate_dominator (idom, BASIC_BLOCK (x))->index != bb)
SET_BIT (frontiers[bb], x);
});
}
void
compute_dominance_frontiers (frontiers, idom)
sbitmap *frontiers;
- int *idom;
+ dominance_info idom;
{
sbitmap done = sbitmap_alloc (last_basic_block);
sbitmap_zero (done);
/* Rename the registers to conform to SSA.
This is essentially the algorithm presented in Figure 7.8 of Morgan,
- with a few changes to reduce pattern search time in favour of a bit
+ with a few changes to reduce pattern search time in favor of a bit
more memory usage. */
/* One of these is created for each set. It will live in a list local
}
case REG:
- if (CONVERT_REGISTER_TO_SSA_P (REGNO (x)) &&
- REGNO (x) < ssa_max_reg_num)
+ if (CONVERT_REGISTER_TO_SSA_P (REGNO (x))
+ && REGNO (x) < ssa_max_reg_num)
{
rtx new_reg = ssa_rename_to_lookup (x);
- if (new_reg != NULL_RTX && new_reg != RENAME_NO_RTX)
+ if (new_reg != RENAME_NO_RTX && new_reg != NULL_RTX)
{
if (GET_MODE (x) != GET_MODE (new_reg))
abort ();
*ptr = new_reg;
}
- /* Else this is a use before a set. Warn? */
+ else
+ {
+ /* Undefined value used, rename it to a new pseudo register so
+ that it cannot conflict with an existing register. */
+ *ptr = gen_reg_rtx (GET_MODE (x));
+ }
}
return -1;
}
}
+static rtx
+gen_sequence ()
+{
+ rtx first_insn = get_insns ();
+ rtx result;
+ rtx tem;
+ int i;
+ int len;
+
+ /* Count the insns in the chain. */
+ len = 0;
+ for (tem = first_insn; tem; tem = NEXT_INSN (tem))
+ len++;
+
+ result = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (len));
+
+ for (i = 0, tem = first_insn; tem; tem = NEXT_INSN (tem), i++)
+ XVECEXP (result, 0, i) = tem;
+
+ return result;
+}
+
static void
rename_block (bb, idom)
int bb;
- int *idom;
+ dominance_info idom;
{
basic_block b = BASIC_BLOCK (bb);
edge e;
dominator order. */
FOR_EACH_BB (c)
- if (idom[c->index] == bb)
+ if (get_immediate_dominator (idom, c)->index == bb)
rename_block (c->index, idom);
/* Step Four: Update the sets to refer to their new register,
static void
rename_registers (nregs, idom)
int nregs;
- int *idom;
+ dominance_info idom;
{
VARRAY_RTX_INIT (ssa_definition, nregs * 3, "ssa_definition");
ssa_rename_from_initialize ();
sbitmap *idfs;
/* Element I is the immediate dominator of block I. */
- int *idom;
+ dominance_info idom;
int nregs;
dead code. We'll let the SSA optimizers do that. */
life_analysis (get_insns (), NULL, 0);
- idom = (int *) alloca (last_basic_block * sizeof (int));
- memset ((void *) idom, -1, (size_t) last_basic_block * sizeof (int));
- calculate_dominance_info (idom, NULL, CDI_DOMINATORS);
+ idom = calculate_dominance_info (CDI_DOMINATORS);
if (rtl_dump_file)
{
fputs (";; Immediate Dominators:\n", rtl_dump_file);
FOR_EACH_BB (bb)
- fprintf (rtl_dump_file, ";\t%3d = %3d\n", bb->index, idom[bb->index]);
+ fprintf (rtl_dump_file, ";\t%3d = %3d\n", bb->index,
+ get_immediate_dominator (idom, bb)->index);
fflush (rtl_dump_file);
}
in_ssa_form = 1;
reg_scan (get_insns (), max_reg_num (), 1);
+ free_dominance_info (idom);
}
/* REG is the representative temporary of its partition. Add it to the
ephi_create (i, visited, pred, succ, nodes);
}
- insn = gen_sequence ();
+ insn = get_insns ();
end_sequence ();
insert_insn_on_edge (insn, e);
if (rtl_dump_file)
and C is the ith predecessor of B,
then T0 and Ti must be equivalent.
- Return non-zero iff any such cases were found for which the two
+ Return nonzero iff any such cases were found for which the two
regs were not already in the same class. */
static int
/* Callback function for for_each_successor_phi. If the set
destination and the phi alternative regs do not conflict, place
- them in the same paritition class. DATA is a pointer to a
+ them in the same partition class. DATA is a pointer to a
phi_coalesce_context struct. */
static int
count_or_remove_death_notes (NULL, 1);
/* Deallocate the data structures. */
- VARRAY_FREE (ssa_definition);
+ ssa_definition = 0;
ssa_rename_from_free ();
}
destination, the regno of the phi argument corresponding to BB,
and DATA.
- If FN ever returns non-zero, stops immediately and returns this
+ If FN ever returns nonzero, stops immediately and returns this
value. Otherwise, returns zero. */
int