Commit bd3d34d4 by Richard Sandiford Committed by Richard Sandiford

lra-constraints.c (process_address): Describe the kinds of address that we might see.

gcc/
	* lra-constraints.c (process_address): Describe the kinds of address
	that we might see.

From-SVN: r192833
parent a202e609
2012-10-26 Richard Sandiford <rdsandiford@googlemail.com>
* lra-constraints.c (process_address): Describe the kinds of address
that we might see.
2012-10-25 Vladimir Makarov <vmakarov@redhat.com> 2012-10-25 Vladimir Makarov <vmakarov@redhat.com>
* lra-int.h (lra_assert): Redefine it gcc_checking_assert. * lra-int.h (lra_assert): Redefine it gcc_checking_assert.
...@@ -2494,8 +2494,23 @@ equiv_address_substitution (struct address *ad, rtx *addr_loc, ...@@ -2494,8 +2494,23 @@ equiv_address_substitution (struct address *ad, rtx *addr_loc,
return change_p; return change_p;
} }
/* Major function to make reloads for address in operand NOP. Add to /* Major function to make reloads for an address in operand NOP.
reloads to the list *BEFORE and *AFTER. We might need to add The supported cases are:
1) an address that existed before LRA started, at which point it must
have been valid. These addresses are subject to elimination and
may have become invalid due to the elimination offset being out
of range.
2) an address created by forcing a constant to memory (force_const_to_mem).
The initial form of these addresses might not be valid, and it is this
function's job to make them valid.
3) a frame address formed from a register and a (possibly zero)
constant offset. As above, these addresses might not be valid
and this function must make them so.
Add reloads to the lists *BEFORE and *AFTER. We might need to add
reloads to *AFTER because of inc/dec, {pre, post} modify in the reloads to *AFTER because of inc/dec, {pre, post} modify in the
address. Return true for any RTL change. */ address. Return true for any RTL change. */
static bool static bool
...@@ -2557,9 +2572,19 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2557,9 +2572,19 @@ process_address (int nop, rtx *before, rtx *after)
&& process_addr_reg (ad.index_reg_loc, before, NULL, INDEX_REG_CLASS)) && process_addr_reg (ad.index_reg_loc, before, NULL, INDEX_REG_CLASS))
change_p = true; change_p = true;
/* The address was valid before LRA. We only change its form if the /* There are three cases where the shape of *ADDR_LOC may now be invalid:
address has a displacement, so if it has no displacement it must
still be valid. */ 1) the original address was valid, but either elimination or
equiv_address_substitution applied a displacement that made
it invalid.
2) the address is an invalid symbolic address created by
force_const_to_mem.
3) the address is a frame address with an invalid offset.
All these cases involve a displacement, so there is no point
revalidating when there is no displacement. */
if (ad.disp_loc == NULL) if (ad.disp_loc == NULL)
return change_p; return change_p;
...@@ -2594,9 +2619,8 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2594,9 +2619,8 @@ process_address (int nop, rtx *before, rtx *after)
if (ok_p) if (ok_p)
return change_p; return change_p;
/* Addresses were legitimate before LRA. So if the address has /* Any index existed before LRA started, so we can assume that the
two registers than it can have two of them. We should also presence and shape of the index is valid. */
not worry about scale for the same reason. */
push_to_sequence (*before); push_to_sequence (*before);
if (ad.base_reg_loc == NULL) if (ad.base_reg_loc == NULL)
{ {
...@@ -2611,7 +2635,7 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2611,7 +2635,7 @@ process_address (int nop, rtx *before, rtx *after)
rtx insn; rtx insn;
rtx last = get_last_insn (); rtx last = get_last_insn ();
/* disp => lo_sum (new_base, disp) */ /* disp => lo_sum (new_base, disp), case (2) above. */
insn = emit_insn (gen_rtx_SET insn = emit_insn (gen_rtx_SET
(VOIDmode, new_reg, (VOIDmode, new_reg,
gen_rtx_HIGH (Pmode, copy_rtx (*ad.disp_loc)))); gen_rtx_HIGH (Pmode, copy_rtx (*ad.disp_loc))));
...@@ -2633,14 +2657,15 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2633,14 +2657,15 @@ process_address (int nop, rtx *before, rtx *after)
#endif #endif
if (code < 0) if (code < 0)
{ {
/* disp => new_base */ /* disp => new_base, case (2) above. */
lra_emit_move (new_reg, *ad.disp_loc); lra_emit_move (new_reg, *ad.disp_loc);
*ad.disp_loc = new_reg; *ad.disp_loc = new_reg;
} }
} }
else else
{ {
/* index * scale + disp => new base + index * scale */ /* index * scale + disp => new base + index * scale,
case (1) above. */
enum reg_class cl = base_reg_class (mode, as, SCRATCH, SCRATCH); enum reg_class cl = base_reg_class (mode, as, SCRATCH, SCRATCH);
lra_assert (INDEX_REG_CLASS != NO_REGS); lra_assert (INDEX_REG_CLASS != NO_REGS);
...@@ -2654,7 +2679,7 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2654,7 +2679,7 @@ process_address (int nop, rtx *before, rtx *after)
} }
else if (ad.index_reg_loc == NULL) else if (ad.index_reg_loc == NULL)
{ {
/* base + disp => new base */ /* base + disp => new base, cases (1) and (3) above. */
/* Another option would be to reload the displacement into an /* Another option would be to reload the displacement into an
index register. However, postreload has code to optimize index register. However, postreload has code to optimize
address reloads that have the same base and different address reloads that have the same base and different
...@@ -2665,7 +2690,8 @@ process_address (int nop, rtx *before, rtx *after) ...@@ -2665,7 +2690,8 @@ process_address (int nop, rtx *before, rtx *after)
} }
else else
{ {
/* base + scale * index + disp => new base + scale * index */ /* base + scale * index + disp => new base + scale * index,
case (1) above. */
new_reg = base_plus_disp_to_reg (mode, as, &ad); new_reg = base_plus_disp_to_reg (mode, as, &ad);
*addr_loc = gen_rtx_PLUS (Pmode, new_reg, *ad.index_loc); *addr_loc = gen_rtx_PLUS (Pmode, new_reg, *ad.index_loc);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment