/* Search an insn for pseudo regs that must be in hard regs and are not.
- Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU CC.
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-
/* This file contains subroutines used only from the file reload1.c.
It knows how to scan one insn for operands and values
that need to be copied into registers to make valid code.
2 happens only when REPLACE is 1, which is only when
actually doing the reloads, not when just counting them.
-
Using a reload register for several reloads in one insn:
When an insn has reloads, it is considered as having three parts:
: (type)))
#ifdef HAVE_SECONDARY_RELOADS
-static int push_secondary_reload PROTO((int, rtx, int, int, enum reg_class,
+static int push_secondary_reload PARAMS ((int, rtx, int, int, enum reg_class,
enum machine_mode, enum reload_type,
enum insn_code *));
#endif
-static enum reg_class find_valid_class PROTO((enum machine_mode, int));
-static int push_reload PROTO((rtx, rtx, rtx *, rtx *, enum reg_class,
+static enum reg_class find_valid_class PARAMS ((enum machine_mode, int));
+static int reload_inner_reg_of_subreg PARAMS ((rtx, enum machine_mode));
+static int push_reload PARAMS ((rtx, rtx, rtx *, rtx *, enum reg_class,
enum machine_mode, enum machine_mode,
int, int, int, enum reload_type));
-static void push_replacement PROTO((rtx *, int, enum machine_mode));
-static void combine_reloads PROTO((void));
-static int find_reusable_reload PROTO((rtx *, rtx, enum reg_class,
+static void push_replacement PARAMS ((rtx *, int, enum machine_mode));
+static void combine_reloads PARAMS ((void));
+static int find_reusable_reload PARAMS ((rtx *, rtx, enum reg_class,
enum reload_type, int, int));
-static rtx find_dummy_reload PROTO((rtx, rtx, rtx *, rtx *,
+static rtx find_dummy_reload PARAMS ((rtx, rtx, rtx *, rtx *,
enum machine_mode, enum machine_mode,
enum reg_class, int, int));
-static int earlyclobber_operand_p PROTO((rtx));
-static int hard_reg_set_here_p PROTO((int, int, rtx));
-static struct decomposition decompose PROTO((rtx));
-static int immune_p PROTO((rtx, rtx, struct decomposition));
-static int alternative_allows_memconst PROTO((const char *, int));
-static rtx find_reloads_toplev PROTO((rtx, int, enum reload_type, int, int, rtx));
-static rtx make_memloc PROTO((rtx, int));
-static int find_reloads_address PROTO((enum machine_mode, rtx *, rtx, rtx *,
+static int hard_reg_set_here_p PARAMS ((unsigned int, unsigned int, rtx));
+static struct decomposition decompose PARAMS ((rtx));
+static int immune_p PARAMS ((rtx, rtx, struct decomposition));
+static int alternative_allows_memconst PARAMS ((const char *, int));
+static rtx find_reloads_toplev PARAMS ((rtx, int, enum reload_type, int,
+ int, rtx, int *));
+static rtx make_memloc PARAMS ((rtx, int));
+static int find_reloads_address PARAMS ((enum machine_mode, rtx *, rtx, rtx *,
int, enum reload_type, int, rtx));
-static rtx subst_reg_equivs PROTO((rtx, rtx));
-static rtx subst_indexed_address PROTO((rtx));
-static int find_reloads_address_1 PROTO((enum machine_mode, rtx, int, rtx *,
+static rtx subst_reg_equivs PARAMS ((rtx, rtx));
+static rtx subst_indexed_address PARAMS ((rtx));
+static int find_reloads_address_1 PARAMS ((enum machine_mode, rtx, int, rtx *,
int, enum reload_type,int, rtx));
-static void find_reloads_address_part PROTO((rtx, rtx *, enum reg_class,
+static void find_reloads_address_part PARAMS ((rtx, rtx *, enum reg_class,
enum machine_mode, int,
enum reload_type, int));
-static rtx find_reloads_subreg_address PROTO((rtx, int, int, enum reload_type,
+static rtx find_reloads_subreg_address PARAMS ((rtx, int, int, enum reload_type,
int, rtx));
-static int find_inc_amount PROTO((rtx, rtx));
-static int loc_mentioned_in_p PROTO((rtx *, rtx));
-extern void debug_reload_to_stream PROTO((FILE *));
-extern void debug_reload PROTO((void));
+static int find_inc_amount PARAMS ((rtx, rtx));
\f
#ifdef HAVE_SECONDARY_RELOADS
can not use secondary reloads, you must work around the problem some
other way.
- Allow this when MODE is not reload_mode and assume that the generated
- code handles this case (it does on the Alpha, which is the only place
- this currently happens). */
+ Allow this when a reload_in/out pattern is being used. I.e. assume
+ that the generated code handles this case. */
- if (in_p && class == reload_class && mode == reload_mode)
+ if (in_p && class == reload_class && icode == CODE_FOR_nothing
+ && t_icode == CODE_FOR_nothing)
abort ();
/* If we need a tertiary reload, see if we have one we can reuse or else
rld[t_reload].outmode = ! in_p ? t_mode : VOIDmode;
rld[t_reload].reg_rtx = 0;
rld[t_reload].optional = optional;
- rld[t_reload].nongroup = 0;
rld[t_reload].inc = 0;
/* Maybe we could combine these, but it seems too tricky. */
rld[t_reload].nocombine = 1;
if (in_p && icode == CODE_FOR_nothing
&& SECONDARY_MEMORY_NEEDED (class, reload_class, mode))
- get_secondary_mem (x, reload_mode, opnum, type);
+ {
+ get_secondary_mem (x, reload_mode, opnum, type);
+
+ /* We may have just added new reloads. Make sure we add
+ the new reload at the end. */
+ s_reload = n_reloads;
+ }
#endif
/* We need to make a new secondary reload for this register class. */
rld[s_reload].outmode = ! in_p ? mode : VOIDmode;
rld[s_reload].reg_rtx = 0;
rld[s_reload].optional = optional;
- rld[s_reload].nongroup = 0;
rld[s_reload].inc = 0;
/* Maybe we could combine these, but it seems too tricky. */
rld[s_reload].nocombine = 1;
#ifdef SECONDARY_MEMORY_NEEDED_MODE
mode = SECONDARY_MEMORY_NEEDED_MODE (mode);
#else
- if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
+ if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD && INTEGRAL_MODE_P (mode))
mode = mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0);
#endif
void
clear_secondary_mem ()
{
- bzero ((char *) secondary_memlocs, sizeof secondary_memlocs);
+ memset ((char *) secondary_memlocs, 0, sizeof secondary_memlocs);
}
#endif /* SECONDARY_MEMORY_NEEDED */
\f
static enum reg_class
find_valid_class (m1, n)
- enum machine_mode m1;
+ enum machine_mode m1 ATTRIBUTE_UNUSED;
int n;
{
int class;
int regno;
enum reg_class best_class = NO_REGS;
- int best_size = 0;
+ unsigned int best_size = 0;
for (class = 1; class < N_REG_CLASSES; class++)
{
true_regnum (rld[i].reg_rtx)))
&& out == 0 && rld[i].out == 0 && rld[i].in != 0
&& ((GET_CODE (in) == REG
- && (GET_CODE (rld[i].in) == POST_INC
- || GET_CODE (rld[i].in) == POST_DEC
- || GET_CODE (rld[i].in) == PRE_INC
- || GET_CODE (rld[i].in) == PRE_DEC)
+ && GET_RTX_CLASS (GET_CODE (rld[i].in)) == 'a'
&& MATCHES (XEXP (rld[i].in, 0), in))
- ||
- (GET_CODE (rld[i].in) == REG
- && (GET_CODE (in) == POST_INC
- || GET_CODE (in) == POST_DEC
- || GET_CODE (in) == PRE_INC
- || GET_CODE (in) == PRE_DEC)
- && MATCHES (XEXP (in, 0), rld[i].in)))
+ || (GET_CODE (rld[i].in) == REG
+ && GET_RTX_CLASS (GET_CODE (in)) == 'a'
+ && MATCHES (XEXP (in, 0), rld[i].in)))
&& (rld[i].out == 0 || ! earlyclobber_operand_p (rld[i].out))
&& (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
&& MERGABLE_RELOADS (type, rld[i].when_needed,
return n_reloads;
}
+/* Return nonzero if X is a SUBREG which will require reloading of its
+ SUBREG_REG expression. */
+
+static int
+reload_inner_reg_of_subreg (x, mode)
+ rtx x;
+ enum machine_mode mode;
+{
+ rtx inner;
+
+ /* Only SUBREGs are problematical. */
+ if (GET_CODE (x) != SUBREG)
+ return 0;
+
+ inner = SUBREG_REG (x);
+
+ /* If INNER is a constant, then INNER must be reloaded. */
+ if (CONSTANT_P (inner))
+ return 1;
+
+ /* If INNER is not a hard register, then INNER will not need to
+ be reloaded. */
+ if (GET_CODE (inner) != REG
+ || REGNO (inner) >= FIRST_PSEUDO_REGISTER)
+ return 0;
+
+ /* If INNER is not ok for MODE, then INNER will need reloading. */
+ if (! HARD_REGNO_MODE_OK (REGNO (inner) + SUBREG_WORD (x), mode))
+ return 1;
+
+ /* If the outer part is a word or smaller, INNER larger than a
+ word and the number of regs for INNER is not the same as the
+ number of words in INNER, then INNER will need reloading. */
+ return (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
+ && GET_MODE_SIZE (GET_MODE (inner)) > UNITS_PER_WORD
+ && ((GET_MODE_SIZE (GET_MODE (inner)) / UNITS_PER_WORD)
+ != HARD_REGNO_NREGS (REGNO (inner), GET_MODE (inner))));
+}
+
/* Record one reload that needs to be performed.
IN is an rtx saying where the data are to be found before this instruction.
OUT says where they must be stored after the instruction.
if (in != 0 && out != 0 && GET_CODE (in) == MEM && rtx_equal_p (in, out))
{
if (GET_CODE (XEXP (in, 0)) == POST_INC
- || GET_CODE (XEXP (in, 0)) == POST_DEC)
- in = gen_rtx_MEM (GET_MODE (in), XEXP (XEXP (in, 0), 0));
+ || GET_CODE (XEXP (in, 0)) == POST_DEC
+ || GET_CODE (XEXP (in, 0)) == POST_MODIFY)
+ {
+ rtx new = gen_rtx_MEM (GET_MODE (in), XEXP (XEXP (in, 0), 0));
+
+ MEM_COPY_ATTRIBUTES (new, in);
+ in = new;
+ }
if (GET_CODE (XEXP (in, 0)) == PRE_INC
- || GET_CODE (XEXP (in, 0)) == PRE_DEC)
- out = gen_rtx_MEM (GET_MODE (out), XEXP (XEXP (out, 0), 0));
+ || GET_CODE (XEXP (in, 0)) == PRE_DEC
+ || GET_CODE (XEXP (in, 0)) == PRE_MODIFY)
+ {
+ rtx new = gen_rtx_MEM (GET_MODE (out), XEXP (XEXP (out, 0), 0));
+
+ MEM_COPY_ATTRIBUTES (new, out);
+ out = new;
+ }
}
/* If we are reloading a (SUBREG constant ...), really reload just the
if (in != 0 && GET_CODE (in) == SUBREG
&& (SUBREG_WORD (in) == 0 || strict_low)
-#ifdef CLASS_CANNOT_CHANGE_SIZE
- && class != CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
+ && (class != CLASS_CANNOT_CHANGE_MODE
+ || ! CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (in)), inmode))
#endif
&& (CONSTANT_P (SUBREG_REG (in))
|| GET_CODE (SUBREG_REG (in)) == PLUS
SUBREG_REG (in))
== NO_REGS))
#endif
-#ifdef CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
|| (GET_CODE (SUBREG_REG (in)) == REG
&& REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
&& (TEST_HARD_REG_BIT
- (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
+ (reg_class_contents[(int) CLASS_CANNOT_CHANGE_MODE],
REGNO (SUBREG_REG (in))))
- && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
- != GET_MODE_SIZE (inmode)))
+ && CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (in)),
+ inmode))
#endif
))
{
/* Similar issue for (SUBREG constant ...) if it was not handled by the
code above. This can happen if SUBREG_WORD != 0. */
- if (in != 0 && GET_CODE (in) == SUBREG
- && (CONSTANT_P (SUBREG_REG (in))
- || (GET_CODE (SUBREG_REG (in)) == REG
- && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
- && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (in))
- + SUBREG_WORD (in),
- inmode)
- || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
- && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
- > UNITS_PER_WORD)
- && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
- / UNITS_PER_WORD)
- != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)),
- GET_MODE (SUBREG_REG (in)))))))))
+ if (in != 0 && reload_inner_reg_of_subreg (in, inmode))
{
/* This relies on the fact that emit_reload_insns outputs the
instructions for input reloads of type RELOAD_OTHER in the same
and in that case the constraint should label it input-output.) */
if (out != 0 && GET_CODE (out) == SUBREG
&& (SUBREG_WORD (out) == 0 || strict_low)
-#ifdef CLASS_CANNOT_CHANGE_SIZE
- && class != CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
+ && (class != CLASS_CANNOT_CHANGE_MODE
+ || ! CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (out)),
+ outmode))
#endif
&& (CONSTANT_P (SUBREG_REG (out))
|| strict_low
SUBREG_REG (out))
== NO_REGS))
#endif
-#ifdef CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
|| (GET_CODE (SUBREG_REG (out)) == REG
&& REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
&& (TEST_HARD_REG_BIT
- (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
+ (reg_class_contents[(int) CLASS_CANNOT_CHANGE_MODE],
REGNO (SUBREG_REG (out))))
- && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
- != GET_MODE_SIZE (outmode)))
+ && CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (out)),
+ outmode))
#endif
))
{
However, we must reload the inner reg *as well as* the subreg in
that case. In this case, the inner reg is an in-out reload. */
- if (out != 0 && GET_CODE (out) == SUBREG
- && GET_CODE (SUBREG_REG (out)) == REG
- && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
- && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (out)) + SUBREG_WORD (out),
- outmode)
- || (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
- && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
- > UNITS_PER_WORD)
- && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
- / UNITS_PER_WORD)
- != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)),
- GET_MODE (SUBREG_REG (out)))))))
+ if (out != 0 && reload_inner_reg_of_subreg (out, outmode))
{
/* This relies on the fact that emit_reload_insns outputs the
instructions for output reloads of type RELOAD_OTHER in reverse
rld[i].outmode = outmode;
rld[i].reg_rtx = 0;
rld[i].optional = optional;
- rld[i].nongroup = 0;
rld[i].inc = 0;
rld[i].nocombine = 0;
rld[i].in_reg = inloc ? *inloc : 0;
&& GET_MODE_SIZE (inmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
&& HARD_REGNO_MODE_OK (regno, inmode)
&& GET_MODE_SIZE (outmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
- && HARD_REGNO_MODE_OK (regno, outmode)
- && TEST_HARD_REG_BIT (reg_class_contents[(int) class], regno)
- && !fixed_regs[regno])
+ && HARD_REGNO_MODE_OK (regno, outmode))
{
- rld[i].reg_rtx = gen_rtx_REG (inmode, regno);
- break;
+ unsigned int offs;
+ unsigned int nregs = MAX (HARD_REGNO_NREGS (regno, inmode),
+ HARD_REGNO_NREGS (regno, outmode));
+
+ for (offs = 0; offs < nregs; offs++)
+ if (fixed_regs[regno + offs]
+ || ! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+ regno + offs))
+ break;
+
+ if (offs == nregs)
+ {
+ rld[i].reg_rtx = gen_rtx_REG (inmode, regno);
+ break;
+ }
}
}
char reload_flags[MAX_RELOADS];
int something_changed = 0;
- bzero (reload_flags, sizeof reload_flags);
+ memset (reload_flags, 0, sizeof reload_flags);
for (i = 0, j = 0; i < n_replacements; i++)
{
if (loc_mentioned_in_p (replacements[i].where, in_rtx))
}
return something_changed;
}
-
-/* Return non-zero if IN contains a piece of rtl that has the address LOC */
-static int
-loc_mentioned_in_p (loc, in)
- rtx *loc, in;
-{
- enum rtx_code code = GET_CODE (in);
- const char *fmt = GET_RTX_FORMAT (code);
- int i, j;
-
- for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
- {
- if (loc == &in->fld[i].rtx)
- return 1;
- if (fmt[i] == 'e')
- {
- if (loc_mentioned_in_p (loc, XEXP (in, i)))
- return 1;
- }
- else if (fmt[i] == 'E')
- for (j = XVECLEN (in, i) - 1; i >= 0; i--)
- if (loc_mentioned_in_p (loc, XVECEXP (in, i, j)))
- return 1;
- }
- return 0;
-}
\f
/* If there is only one output reload, and it is not for an earlyclobber
operand, try to combine it with a (logically unrelated) input reload
&& ! (GET_CODE (rld[i].in) == REG
&& reg_overlap_mentioned_for_reload_p (rld[i].in,
rld[output_reload].out))))
+ && ! reload_inner_reg_of_subreg (rld[i].in, rld[i].inmode)
&& (reg_class_size[(int) rld[i].class]
|| SMALL_REGISTER_CLASSES)
/* We will allow making things slightly worse by combining an
if (GET_CODE (out) == REG
&& REGNO (out) < FIRST_PSEUDO_REGISTER)
{
- register int regno = REGNO (out) + out_offset;
- int nwords = HARD_REGNO_NREGS (regno, outmode);
+ unsigned int regno = REGNO (out) + out_offset;
+ unsigned int nwords = HARD_REGNO_NREGS (regno, outmode);
rtx saved_rtx;
/* When we consider whether the insn uses OUT,
*inloc = const0_rtx;
if (regno < FIRST_PSEUDO_REGISTER
- /* A fixed reg that can overlap other regs better not be used
- for reloading in any way. */
-#ifdef OVERLAPPING_REGNO_P
- && ! (fixed_regs[regno] && OVERLAPPING_REGNO_P (regno))
-#endif
&& ! refers_to_regno_for_reload_p (regno, regno + nwords,
PATTERN (this_insn), outloc))
{
- int i;
+ unsigned int i;
+
for (i = 0; i < nwords; i++)
if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
regno + i))
(GET_MODE (out) != VOIDmode
? GET_MODE (out) : outmode)))
{
- register int regno = REGNO (in) + in_offset;
- int nwords = HARD_REGNO_NREGS (regno, inmode);
+ unsigned int regno = REGNO (in) + in_offset;
+ unsigned int nwords = HARD_REGNO_NREGS (regno, inmode);
if (! refers_to_regno_for_reload_p (regno, regno + nwords, out, NULL_PTR)
&& ! hard_reg_set_here_p (regno, regno + nwords,
|| ! refers_to_regno_for_reload_p (regno, regno + nwords,
PATTERN (this_insn), inloc)))
{
- int i;
+ unsigned int i;
+
for (i = 0; i < nwords; i++)
if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
regno + i))
/* Return 1 if X is an operand of an insn that is being earlyclobbered. */
-static int
+int
earlyclobber_operand_p (x)
rtx x;
{
static int
hard_reg_set_here_p (beg_regno, end_regno, x)
- register int beg_regno, end_regno;
+ unsigned int beg_regno, end_regno;
rtx x;
{
if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
{
register rtx op0 = SET_DEST (x);
+
while (GET_CODE (op0) == SUBREG)
op0 = SUBREG_REG (op0);
if (GET_CODE (op0) == REG)
{
- register int r = REGNO (op0);
+ unsigned int r = REGNO (op0);
+
/* See if this reg overlaps range under consideration. */
if (r < end_regno
&& r + HARD_REGNO_NREGS (r, GET_MODE (op0)) > beg_regno)
else if (GET_CODE (x) == PARALLEL)
{
register int i = XVECLEN (x, 0) - 1;
+
for (; i >= 0; i--)
if (hard_reg_set_here_p (beg_regno, end_regno, XVECEXP (x, 0, i)))
return 1;
int
strict_memory_address_p (mode, addr)
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
register rtx addr;
{
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
because the assembler insn would increment only once.
On the other hand, an postincrement matches ordinary indexing
if the postincrement is the output operand. */
- if (code == POST_DEC || code == POST_INC)
+ if (code == POST_DEC || code == POST_INC || code == POST_MODIFY)
return operands_match_p (XEXP (x, 0), y);
/* Two preincrements are invalid
because the assembler insn would increment only once.
if the preincrement is the input operand.
In this case, return 2, since some callers need to do special
things when this happens. */
- if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC)
+ if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC
+ || GET_CODE (y) == PRE_MODIFY)
return operands_match_p (x, XEXP (y, 0)) ? 2 : 0;
slow:
|| GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC)
{
val.base = XEXP (addr, 0);
- val.start = - GET_MODE_SIZE (GET_MODE (x));
+ val.start = -GET_MODE_SIZE (GET_MODE (x));
val.end = GET_MODE_SIZE (GET_MODE (x));
val.safe = REGNO (val.base) == STACK_POINTER_REGNUM;
return val;
}
+ if (GET_CODE (addr) == PRE_MODIFY || GET_CODE (addr) == POST_MODIFY)
+ {
+ if (GET_CODE (XEXP (addr, 1)) == PLUS
+ && XEXP (addr, 0) == XEXP (XEXP (addr, 1), 0)
+ && CONSTANT_P (XEXP (XEXP (addr, 1), 1)))
+ {
+ val.base = XEXP (addr, 0);
+ val.start = -INTVAL (XEXP (XEXP (addr, 1), 1));
+ val.end = INTVAL (XEXP (XEXP (addr, 1), 1));
+ val.safe = REGNO (val.base) == STACK_POINTER_REGNUM;
+ return val;
+ }
+ }
+
if (GET_CODE (addr) == CONST)
{
addr = XEXP (addr, 0);
if (GET_CODE (x) != MEM)
return 1;
- xdata = decompose (x);
+ xdata = decompose (x);
if (! rtx_equal_p (xdata.base, ydata.base))
{
return 0;
}
-
return (xdata.start >= ydata.end || ydata.start >= xdata.end);
}
int no_input_reloads = 0, no_output_reloads = 0;
int n_alternatives;
int this_alternative[MAX_RECOG_OPERANDS];
+ char this_alternative_match_win[MAX_RECOG_OPERANDS];
char this_alternative_win[MAX_RECOG_OPERANDS];
char this_alternative_offmemok[MAX_RECOG_OPERANDS];
char this_alternative_earlyclobber[MAX_RECOG_OPERANDS];
int swapped;
int goal_alternative[MAX_RECOG_OPERANDS];
int this_alternative_number;
- int goal_alternative_number;
+ int goal_alternative_number = 0;
int operand_reloadnum[MAX_RECOG_OPERANDS];
int goal_alternative_matches[MAX_RECOG_OPERANDS];
int goal_alternative_matched[MAX_RECOG_OPERANDS];
+ char goal_alternative_match_win[MAX_RECOG_OPERANDS];
char goal_alternative_win[MAX_RECOG_OPERANDS];
char goal_alternative_offmemok[MAX_RECOG_OPERANDS];
char goal_alternative_earlyclobber[MAX_RECOG_OPERANDS];
int goal_alternative_swapped;
int best;
int commutative;
- int changed;
char operands_match[MAX_RECOG_OPERANDS][MAX_RECOG_OPERANDS];
rtx substed_operand[MAX_RECOG_OPERANDS];
rtx body = PATTERN (insn);
rtx set = single_set (insn);
- int goal_earlyclobber, this_earlyclobber;
+ int goal_earlyclobber = 0, this_earlyclobber;
enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
int retval = 0;
/* The eliminated forms of any secondary memory locations are per-insn, so
clear them out here. */
- bzero ((char *) secondary_memlocs_elim, sizeof secondary_memlocs_elim);
+ memset ((char *) secondary_memlocs_elim, 0, sizeof secondary_memlocs_elim);
#endif
/* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
ind_levels,
set != 0
&& &SET_DEST (set) == recog_data.operand_loc[i],
- insn);
+ insn,
+ &address_reloaded[i]);
/* If we made a MEM to load (a part of) the stackslot of a pseudo
that didn't get a hard register, emit a USE with a REG_EQUAL
a unary operator by reloading the operand. */
substed_operand[i] = recog_data.operand[i]
= find_reloads_toplev (recog_data.operand[i], i, address_type[i],
- ind_levels, 0, insn);
+ ind_levels, 0, insn,
+ &address_reloaded[i]);
else if (code == REG)
{
/* This is equivalent to calling find_reloads_toplev.
of a constant equivalence was checked above. */
substed_operand[i] = recog_data.operand[i]
= find_reloads_toplev (recog_data.operand[i], i, address_type[i],
- ind_levels, 0, insn);
+ ind_levels, 0, insn,
+ &address_reloaded[i]);
}
/* If the operand is still a register (we didn't replace it with an
equivalent), get the preferred class to reload it into. */
&& reg_alternate_class (REGNO (recog_data.operand[i])) == NO_REGS);
}
-#ifdef HAVE_cc0
- /* If we made any reloads for addresses, see if they violate a
- "no input reloads" requirement for this insn. */
- if (no_input_reloads)
- for (i = 0; i < n_reloads; i++)
- if (rld[i].in != 0)
- abort ();
-#endif
-
/* If this is simply a copy from operand 1 to operand 0, merge the
preferred classes for the operands. */
if (set != 0 && noperands >= 2 && recog_data.operand[0] == SET_DEST (set)
{
register char *p = constraints[i];
register int win = 0;
+ int did_match = 0;
/* 0 => this operand can be reloaded somehow for this alternative */
int badop = 1;
/* 0 => this operand can be reloaded if the alternative allows regs. */
this_alternative[i] = (int) NO_REGS;
this_alternative_win[i] = 0;
+ this_alternative_match_win[i] = 0;
this_alternative_offmemok[i] = 0;
this_alternative_earlyclobber[i] = 0;
this_alternative_matches[i] = -1;
case '#':
/* Ignore rest of this alternative as far as
reloading is concerned. */
- while (*p && *p != ',') p++;
+ while (*p && *p != ',')
+ p++;
break;
case '0': case '1': case '2': case '3': case '4':
only on one side of its diagonal. */
? (operands_match
[(c == commutative || c == commutative + 1)
- ? 2*commutative + 1 - c : c]
+ ? 2 * commutative + 1 - c : c]
[(i == commutative || i == commutative + 1)
- ? 2*commutative + 1 - i : i])
+ ? 2 * commutative + 1 - i : i])
: operands_match[c][i])
{
/* If we are matching a non-offsettable address where an
&& ! this_alternative_win[c])
bad = 1;
- win = this_alternative_win[c];
+ did_match = this_alternative_win[c];
}
else
{
operand also had to match the same thing as this
operand, we don't know how to do that. So reject this
alternative. */
- if (! win || force_reload)
+ if (! did_match || force_reload)
for (j = 0; j < i; j++)
if (this_alternative_matches[j]
== this_alternative_matches[i])
badop = 1;
-
break;
case 'p':
= (int) reg_class_subunion[this_alternative[i]][(int) GENERAL_REGS];
goto reg;
+ default:
+ if (REG_CLASS_FROM_LETTER (c) == NO_REGS)
+ {
#ifdef EXTRA_CONSTRAINT
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- if (EXTRA_CONSTRAINT (operand, c))
- win = 1;
- break;
+ if (EXTRA_CONSTRAINT (operand, c))
+ win = 1;
#endif
+ break;
+ }
- default:
this_alternative[i]
= (int) reg_class_subunion[this_alternative[i]][(int) REG_CLASS_FROM_LETTER (c)];
-
reg:
if (GET_MODE (operand) == BLKmode)
break;
this_alternative_earlyclobber[i] = earlyclobber;
if (win && ! force_reload)
this_alternative_win[i] = 1;
+ else if (did_match && ! force_reload)
+ this_alternative_match_win[i] = 1;
else
{
int const_to_mem = 0;
&& ! const_to_mem)
bad = 1;
-
/* We prefer to reload pseudos over reloading other things,
since such reloads may be able to be eliminated later.
If we are reloading a SCRATCH, we won't be generating any
Don't do this if the preferred class has only one register
because we might otherwise exhaust the class. */
-
- if (! win && this_alternative[i] != (int) NO_REGS
+ if (! win && ! did_match
+ && this_alternative[i] != (int) NO_REGS
&& GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
&& reg_class_size[(int) preferred_class[i]] > 1)
{
for (i = 0; i < noperands; i++)
if (this_alternative_earlyclobber[i]
- && this_alternative_win[i])
+ && (this_alternative_win[i] || this_alternative_match_win[i]))
{
struct decomposition early_data;
{
losers++;
this_alternative_win[j] = 0;
+ this_alternative_match_win[j] = 0;
}
else
break;
{
losers++;
this_alternative_win[i] = 0;
+ this_alternative_match_win[j] = 0;
for (j = 0; j < noperands; j++)
if (this_alternative_matches[j] == i
- && this_alternative_win[j])
+ && this_alternative_match_win[j])
{
this_alternative_win[j] = 0;
+ this_alternative_match_win[j] = 0;
losers++;
}
}
}
for (i = 0; i < noperands; i++)
{
- goal_alternative_win[i] = 1;
+ goal_alternative_win[i] = this_alternative_win[i];
+ goal_alternative_match_win[i] = this_alternative_match_win[i];
goal_alternative[i] = this_alternative[i];
goal_alternative_offmemok[i] = this_alternative_offmemok[i];
goal_alternative_matches[i] = this_alternative_matches[i];
{
goal_alternative[i] = this_alternative[i];
goal_alternative_win[i] = this_alternative_win[i];
+ goal_alternative_match_win[i] = this_alternative_match_win[i];
goal_alternative_offmemok[i] = this_alternative_offmemok[i];
goal_alternative_matches[i] = this_alternative_matches[i];
goal_alternative_earlyclobber[i]
for (i = 0; i < noperands; i++)
goal_alternative_matched[i] = -1;
-
+
for (i = 0; i < noperands; i++)
if (! goal_alternative_win[i]
&& goal_alternative_matches[i] >= 0)
goal_alternative_matched[goal_alternative_matches[i]] = i;
+ for (i = 0; i < noperands; i++)
+ goal_alternative_win[i] |= goal_alternative_match_win[i];
+
/* If the best alternative is with operands 1 and 2 swapped,
consider them swapped before reporting the reloads. Update the
operand numbers of any reloads already pushed. */
tem = *recog_data.operand_loc[commutative];
*recog_data.operand_loc[commutative]
= *recog_data.operand_loc[commutative + 1];
- *recog_data.operand_loc[commutative+1] = tem;
+ *recog_data.operand_loc[commutative + 1] = tem;
for (i = 0; i < n_reloads; i++)
{
substed_operand[i] = recog_data.operand[i]
= find_reloads_toplev (force_const_mem (operand_mode[i],
recog_data.operand[i]),
- i, address_type[i], ind_levels, 0, insn);
+ i, address_type[i], ind_levels, 0, insn,
+ NULL);
if (alternative_allows_memconst (recog_data.constraints[i],
goal_alternative_number))
goal_alternative_win[i] = 1;
{
int secondary_in_reload = rld[i].secondary_in_reload;
- rld[secondary_in_reload].when_needed
- = RELOAD_FOR_OPADDR_ADDR;
+ rld[secondary_in_reload].when_needed = RELOAD_FOR_OPADDR_ADDR;
/* If there's a tertiary reload we have to change it also. */
if (secondary_in_reload > 0
{
int secondary_out_reload = rld[i].secondary_out_reload;
- rld[secondary_out_reload].when_needed
- = RELOAD_FOR_OPADDR_ADDR;
+ rld[secondary_out_reload].when_needed = RELOAD_FOR_OPADDR_ADDR;
/* If there's a tertiary reload we have to change it also. */
if (secondary_out_reload
int first_op_addr_num = -2;
int first_inpaddr_num[MAX_RECOG_OPERANDS];
int first_outpaddr_num[MAX_RECOG_OPERANDS];
- int need_change= 0;
+ int need_change = 0;
/* We use last_op_addr_reload and the contents of the above arrays
first as flags - -2 means no instance encountered, -1 means exactly
one instance encountered.
{
for (i = 0; i < n_reloads; i++)
{
- int first_num, type;
+ int first_num;
+ enum reload_type type;
switch (rld[i].when_needed)
{
rld[j].in = 0;
}
- /* Set which reloads must use registers not used in any group. Start
- with those that conflict with a group and then include ones that
- conflict with ones that are already known to conflict with a group. */
-
- changed = 0;
- for (i = 0; i < n_reloads; i++)
- {
- enum machine_mode mode = rld[i].inmode;
- enum reg_class class = rld[i].class;
- int size;
-
- if (GET_MODE_SIZE (rld[i].outmode) > GET_MODE_SIZE (mode))
- mode = rld[i].outmode;
- size = CLASS_MAX_NREGS (class, mode);
-
- if (size == 1)
- for (j = 0; j < n_reloads; j++)
- if ((CLASS_MAX_NREGS (rld[j].class,
- (GET_MODE_SIZE (rld[j].outmode)
- > GET_MODE_SIZE (rld[j].inmode))
- ? rld[j].outmode : rld[j].inmode)
- > 1)
- && !rld[j].optional
- && (rld[j].in != 0 || rld[j].out != 0
- || rld[j].secondary_p)
- && reloads_conflict (i, j)
- && reg_classes_intersect_p (class, rld[j].class))
- {
- rld[i].nongroup = 1;
- changed = 1;
- break;
- }
- }
-
- while (changed)
- {
- changed = 0;
-
- for (i = 0; i < n_reloads; i++)
- {
- enum machine_mode mode = rld[i].inmode;
- enum reg_class class = rld[i].class;
- int size;
-
- if (GET_MODE_SIZE (rld[i].outmode) > GET_MODE_SIZE (mode))
- mode = rld[i].outmode;
- size = CLASS_MAX_NREGS (class, mode);
-
- if (! rld[i].nongroup && size == 1)
- for (j = 0; j < n_reloads; j++)
- if (rld[j].nongroup
- && reloads_conflict (i, j)
- && reg_classes_intersect_p (class, rld[j].class))
- {
- rld[i].nongroup = 1;
- changed = 1;
- break;
- }
- }
- }
+#ifdef HAVE_cc0
+ /* If we made any reloads for addresses, see if they violate a
+ "no input reloads" requirement for this insn. But loads that we
+ do after the insn (such as for output addresses) are fine. */
+ if (no_input_reloads)
+ for (i = 0; i < n_reloads; i++)
+ if (rld[i].in != 0
+ && rld[i].when_needed != RELOAD_FOR_OUTADDR_ADDRESS
+ && rld[i].when_needed != RELOAD_FOR_OUTPUT_ADDRESS)
+ abort ();
+#endif
/* Compute reload_mode and reload_nregs. */
for (i = 0; i < n_reloads; i++)
INSN, if nonzero, is the insn in which we do the reload. It is used
to determine if we may generate output reloads, and where to put USEs
- for pseudos that we have to replace with stack slots. */
+ for pseudos that we have to replace with stack slots.
+
+ ADDRESS_RELOADED. If nonzero, is a pointer to where we put the
+ result of find_reloads_address. */
static rtx
-find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
+find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn,
+ address_reloaded)
rtx x;
int opnum;
enum reload_type type;
int ind_levels;
int is_set_dest;
rtx insn;
+ int *address_reloaded;
{
register RTX_CODE code = GET_CODE (x);
if (replace_reloads && recog_data.operand[opnum] != x)
emit_insn_before (gen_rtx_USE (VOIDmode, x), insn);
x = mem;
- find_reloads_address (GET_MODE (x), &x, XEXP (x, 0), &XEXP (x, 0),
- opnum, type, ind_levels, insn);
+ i = find_reloads_address (GET_MODE (x), &x, XEXP (x, 0), &XEXP (x, 0),
+ opnum, type, ind_levels, insn);
+ if (address_reloaded)
+ *address_reloaded = i;
}
}
return x;
if (code == MEM)
{
rtx tem = x;
- find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
- opnum, type, ind_levels, insn);
+
+ i = find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
+ opnum, type, ind_levels, insn);
+ if (address_reloaded)
+ *address_reloaded = i;
+
return tem;
}
x = find_reloads_subreg_address (x, 1, opnum, type, ind_levels,
insn);
}
+ else if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM
+ && (GET_MODE_SIZE (GET_MODE (x))
+ > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
+ && mode_dependent_address_p (XEXP (SUBREG_REG (x), 0)))
+ {
+ /* A paradoxical subreg will simply have the mode of the access
+ changed, so we need to reload such a memory operand to stabilize
+ the meaning of the memory access. */
+ enum machine_mode subreg_mode = GET_MODE (SUBREG_REG (x));
+
+ if (is_set_dest)
+ push_reload (NULL_RTX, SUBREG_REG (x), NULL_PTR, &SUBREG_REG (x),
+ find_valid_class (subreg_mode, SUBREG_WORD (x)),
+ VOIDmode, subreg_mode, 0, 0, opnum, type);
+ else
+ push_reload (SUBREG_REG (x), NULL_RTX, &SUBREG_REG (x), NULL_PTR,
+ find_valid_class (subreg_mode, SUBREG_WORD (x)),
+ subreg_mode, VOIDmode, 0, 0, opnum, type);
+ }
for (copied = 0, i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
{
rtx new_part = find_reloads_toplev (XEXP (x, i), opnum, type,
- ind_levels, is_set_dest, insn);
+ ind_levels, is_set_dest, insn,
+ address_reloaded);
/* If we have replaced a reg with it's equivalent memory loc -
that can still be handled here e.g. if it's in a paradoxical
subreg - we must make the change in a copy, rather than using
tem = copy_rtx (tem);
tem = gen_rtx_MEM (GET_MODE (ad), tem);
- RTX_UNCHANGING_P (tem) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
+ MEM_COPY_ATTRIBUTES (tem, reg_equiv_memory_loc[regno]);
return tem;
}
else if (regno < FIRST_PSEUDO_REGISTER
&& REGNO_MODE_OK_FOR_BASE_P (regno, mode)
- && ! regno_clobbered_p (regno, this_insn))
+ && ! regno_clobbered_p (regno, this_insn, mode, 0))
return 0;
/* If we do not have one of the cases above, we must do the reload. */
that the index needs a reload and find_reloads_address_1 will take care
of it.
- There is still a case when we might generate an extra reload,
- however. In certain cases eliminate_regs will return a MEM for a REG
- (see the code there for details). In those cases, memory_address_p
- applied to our address will return 0 so we will think that our offset
- must be too large. But it might indeed be valid and the only problem
- is that a MEM is present where a REG should be. This case should be
- very rare and there doesn't seem to be any way to avoid it.
-
If we decide to do something here, it must be that
`double_reg_address_ok' is true and that this address rtl was made by
eliminate_regs. We generate a reload of the fp/sp/ap + constant and
return 0;
+ case POST_MODIFY:
+ case PRE_MODIFY:
+ {
+ rtx op0 = XEXP (x, 0);
+ rtx op1 = XEXP (x, 1);
+
+ if (GET_CODE (op1) != PLUS && GET_CODE (op1) != MINUS)
+ return 0;
+
+ /* Currently, we only support {PRE,POST}_MODIFY constructs
+ where a base register is {inc,dec}remented by the contents
+ of another register or by a constant value. Thus, these
+ operands must match. */
+ if (op0 != XEXP (op1, 0))
+ abort ();
+
+ /* Require index register (or constant). Let's just handle the
+ register case in the meantime... If the target allows
+ auto-modify by a constant then we could try replacing a pseudo
+ register with its equivalent constant where applicable. */
+ if (REG_P (XEXP (op1, 1)))
+ if (!REGNO_OK_FOR_INDEX_P (REGNO (XEXP (op1, 1))))
+ find_reloads_address_1 (mode, XEXP (op1, 1), 1, &XEXP (op1, 1),
+ opnum, type, ind_levels, insn);
+
+ if (REG_P (XEXP (op1, 0)))
+ {
+ rtx link;
+ int regno = REGNO (XEXP (op1, 0));
+ int reloadnum;
+
+ /* A register that is incremented cannot be constant! */
+ if (regno >= FIRST_PSEUDO_REGISTER
+ && reg_equiv_constant[regno] != 0)
+ abort ();
+
+ /* Handle a register that is equivalent to a memory location
+ which cannot be addressed directly. */
+ if (reg_equiv_memory_loc[regno] != 0
+ && (reg_equiv_address[regno] != 0
+ || num_not_at_initial_offset))
+ {
+ rtx tem = make_memloc (XEXP (x, 0), regno);
+
+ if (reg_equiv_address[regno]
+ || ! rtx_equal_p (tem, reg_equiv_mem[regno]))
+ {
+ /* First reload the memory location's address.
+ We can't use ADDR_TYPE (type) here, because we need to
+ write back the value after reading it, hence we actually
+ need two registers. */
+ find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0),
+ &XEXP (tem, 0), opnum,
+ RELOAD_OTHER,
+ ind_levels, insn);
+
+ /* Then reload the memory location into a base
+ register. */
+ reloadnum = push_reload (tem, tem, &XEXP (x, 0),
+ &XEXP (op1, 0), BASE_REG_CLASS,
+ GET_MODE (x), GET_MODE (x), 0,
+ 0, opnum, RELOAD_OTHER);
+ goto reg_inc;
+ }
+ }
+
+ if (reg_renumber[regno] >= 0)
+ regno = reg_renumber[regno];
+
+ /* We require a base register here... */
+ if (!REGNO_MODE_OK_FOR_BASE_P (regno, GET_MODE (x)))
+ {
+ reloadnum = push_reload (XEXP (op1, 0), XEXP (x, 0),
+ &XEXP (op1, 0), &XEXP (x, 0),
+ BASE_REG_CLASS,
+ GET_MODE (x), GET_MODE (x), 0, 0,
+ opnum, RELOAD_OTHER);
+ }
+
+ /* Update the REG_INC notes. */
+ reg_inc:
+ for (link = REG_NOTES (this_insn); link; link = XEXP (link, 1))
+ if (REG_NOTE_KIND (link) == REG_INC
+ && REGNO (XEXP (link, 0)) == regno)
+ push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
+ }
+ else
+ abort ();
+ }
+ return 0;
+
case POST_INC:
case POST_DEC:
case PRE_INC:
&& ((*insn_data[icode].operand[1].predicate)
(equiv, Pmode))))
{
- loc = &XEXP (x, 0);
+ /* We use the original pseudo for loc, so that
+ emit_reload_insns() knows which pseudo this
+ reload refers to and updates the pseudo rtx, not
+ its equivalent memory location, as well as the
+ corresponding entry in reg_last_reload_reg. */
+ loc = &XEXP (x_orig, 0);
x = XEXP (x, 0);
reloadnum
= push_reload (x, x, loc, loc,
(context ? INDEX_REG_CLASS : BASE_REG_CLASS),
GET_MODE (x), GET_MODE (x), 0, 0,
opnum, RELOAD_OTHER);
-
- /* If we created a new MEM based on reg_equiv_mem[REGNO], then
- LOC above is part of the new MEM, not the MEM in INSN.
-
- We must also replace the address of the MEM in INSN. */
- if (&XEXP (x_orig, 0) != loc)
- push_replacement (&XEXP (x_orig, 0), reloadnum, VOIDmode);
-
}
else
{
in this insn, reload it into some other register to be safe.
The CLOBBER is supposed to make the register unavailable
from before this insn to after it. */
- if (regno_clobbered_p (regno, this_insn))
+ if (regno_clobbered_p (regno, this_insn, GET_MODE (x), 0))
{
push_reload (x, NULL_RTX, loc, NULL_PTR,
(context ? INDEX_REG_CLASS : BASE_REG_CLASS),
{
rtx tem;
- /* If this is a CONST_INT, it could have been created by a
- plus_constant call in eliminate_regs, which means it may be
- on the reload_obstack. reload_obstack will be freed later, so
- we can't allow such RTL to be put in the constant pool. There
- is code in force_const_mem to check for this case, but it doesn't
- work because we have already popped off the reload_obstack, so
- rtl_obstack == saveable_obstack is true at this point. */
- if (GET_CODE (x) == CONST_INT)
- tem = x = force_const_mem (mode, GEN_INT (INTVAL (x)));
- else
- tem = x = force_const_mem (mode, x);
-
+ tem = x = force_const_mem (mode, x);
find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
opnum, type, ind_levels, 0);
}
{
rtx tem;
- /* See comment above. */
- if (GET_CODE (XEXP (x, 1)) == CONST_INT)
- tem = force_const_mem (GET_MODE (x), GEN_INT (INTVAL (XEXP (x, 1))));
- else
- tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
-
+ tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
x = gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0), tem);
find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
opnum, type, ind_levels, 0);
\f
/* Substitute into the current INSN the registers into which we have reloaded
the things that need reloading. The array `replacements'
- says contains the locations of all pointers that must be changed
+ contains the locations of all pointers that must be changed
and says what to replace them with.
Return the rtx that X translates into; usually X, but modified. */
int
refers_to_regno_for_reload_p (regno, endregno, x, loc)
- int regno, endregno;
+ unsigned int regno, endregno;
rtx x;
rtx *loc;
{
- register int i;
- register RTX_CODE code;
- register const char *fmt;
+ int i;
+ unsigned int r;
+ RTX_CODE code;
+ const char *fmt;
if (x == 0)
return 0;
switch (code)
{
case REG:
- i = REGNO (x);
+ r = REGNO (x);
/* If this is a pseudo, a hard register must not have been allocated.
X must therefore either be a constant or be in memory. */
- if (i >= FIRST_PSEUDO_REGISTER)
+ if (r >= FIRST_PSEUDO_REGISTER)
{
- if (reg_equiv_memory_loc[i])
+ if (reg_equiv_memory_loc[r])
return refers_to_regno_for_reload_p (regno, endregno,
- reg_equiv_memory_loc[i],
+ reg_equiv_memory_loc[r],
NULL_PTR);
- if (reg_equiv_constant[i])
+ if (reg_equiv_constant[r])
return 0;
abort ();
}
- return (endregno > i
- && regno < i + (i < FIRST_PSEUDO_REGISTER
- ? HARD_REGNO_NREGS (i, GET_MODE (x))
+ return (endregno > r
+ && regno < r + (r < FIRST_PSEUDO_REGISTER
+ ? HARD_REGNO_NREGS (r, GET_MODE (x))
: 1));
case SUBREG:
if (GET_CODE (SUBREG_REG (x)) == REG
&& REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
{
- int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
- int inner_endregno
+ unsigned int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
+ unsigned int inner_endregno
= inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
else if (fmt[i] == 'E')
{
register int j;
- for (j = XVECLEN (x, i) - 1; j >=0; j--)
+ for (j = XVECLEN (x, i) - 1; j >= 0; j--)
if (loc != &XVECEXP (x, i, j)
&& refers_to_regno_for_reload_p (regno, endregno,
XVECEXP (x, i, j), loc))
case PRE_INC:
case POST_DEC:
case PRE_DEC:
+ case POST_MODIFY:
+ case PRE_MODIFY:
return 0;
default:
break;
else
return 0;
- /* On some machines, certain regs must always be rejected
- because they don't behave the way ordinary registers do. */
-
-#ifdef OVERLAPPING_REGNO_P
- if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
- && OVERLAPPING_REGNO_P (regno))
- return 0;
-#endif
-
/* Scan insns back from INSN, looking for one that copies
a value into or out of GOAL.
Stop and give up if we reach a label. */
p = PREV_INSN (p);
if (p == 0 || GET_CODE (p) == CODE_LABEL)
return 0;
+
if (GET_CODE (p) == INSN
/* If we don't want spill regs ... */
&& (! (reload_reg_p != 0
&& reload_reg_p != (short *) (HOST_WIDE_INT) 1)
- /* ... then ignore insns introduced by reload; they aren't useful
- and can cause results in reload_as_needed to be different
- from what they were when calculating the need for spills.
- If we notice an input-reload insn here, we will reject it below,
- but it might hide a usable equivalent. That makes bad code.
- It may even abort: perhaps no reg was spilled for this insn
- because it was assumed we would find that equivalent. */
+ /* ... then ignore insns introduced by reload; they aren't
+ useful and can cause results in reload_as_needed to be
+ different from what they were when calculating the need for
+ spills. If we notice an input-reload insn here, we will
+ reject it below, but it might hide a usable equivalent.
+ That makes bad code. It may even abort: perhaps no reg was
+ spilled for this insn because it was assumed we would find
+ that equivalent. */
|| INSN_UID (p) < reload_first_uid))
{
rtx tem;
pat = single_set (p);
+
/* First check for something that sets some reg equal to GOAL. */
if (pat != 0
&& ((regno >= 0
/* If we are looking for a constant,
and something equivalent to that constant was copied
into a reg, we can use that reg. */
- || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
- NULL_RTX))
- && rtx_equal_p (XEXP (tem, 0), goal)
- && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
- || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
- NULL_RTX))
- && GET_CODE (SET_DEST (pat)) == REG
- && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
- && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
- && GET_CODE (goal) == CONST_INT
- && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0,
+ || (goal_const && REG_NOTES (p) != 0
+ && (tem = find_reg_note (p, REG_EQUIV, NULL_RTX))
+ && ((rtx_equal_p (XEXP (tem, 0), goal)
+ && (valueno
+ = true_regnum (valtry = SET_DEST (pat))) >= 0)
+ || (GET_CODE (SET_DEST (pat)) == REG
+ && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
+ && (GET_MODE_CLASS (GET_MODE (XEXP (tem, 0)))
+ == MODE_FLOAT)
+ && GET_CODE (goal) == CONST_INT
+ && 0 != (goaltry
+ = operand_subword (XEXP (tem, 0), 0, 0,
VOIDmode))
- && rtx_equal_p (goal, goaltry)
- && (valtry = operand_subword (SET_DEST (pat), 0, 0,
- VOIDmode))
- && (valueno = true_regnum (valtry)) >= 0)
+ && rtx_equal_p (goal, goaltry)
+ && (valtry
+ = operand_subword (SET_DEST (pat), 0, 0,
+ VOIDmode))
+ && (valueno = true_regnum (valtry)) >= 0)))
|| (goal_const && (tem = find_reg_note (p, REG_EQUIV,
NULL_RTX))
&& GET_CODE (SET_DEST (pat)) == REG
&& GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
- && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
+ && (GET_MODE_CLASS (GET_MODE (XEXP (tem, 0)))
+ == MODE_FLOAT)
&& GET_CODE (goal) == CONST_INT
&& 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0,
VOIDmode))
&& (valtry
= operand_subword (SET_DEST (pat), 1, 0, VOIDmode))
&& (valueno = true_regnum (valtry)) >= 0)))
- if (other >= 0
- ? valueno == other
- : ((unsigned) valueno < FIRST_PSEUDO_REGISTER
- && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
- valueno)))
- {
- value = valtry;
- where = p;
- break;
- }
+ {
+ if (other >= 0)
+ {
+ if (valueno != other)
+ continue;
+ }
+ else if ((unsigned) valueno >= FIRST_PSEUDO_REGISTER)
+ continue;
+ else
+ {
+ int i;
+
+ for (i = HARD_REGNO_NREGS (valueno, mode) - 1; i >= 0; i--)
+ if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+ valueno + i))
+ break;
+ if (i >= 0)
+ continue;
+ }
+ value = valtry;
+ where = p;
+ break;
+ }
}
}
/* Don't try to re-use something that is killed in this insn. We want
to be able to trust REG_UNUSED notes. */
- if (find_reg_note (where, REG_UNUSED, value))
+ if (REG_NOTES (where) != 0 && find_reg_note (where, REG_UNUSED, value))
return 0;
/* If we propose to get the value from the stack pointer or if GOAL is
/* Reject registers that overlap GOAL. */
if (!goal_mem && !goal_const
- && regno + HARD_REGNO_NREGS (regno, mode) > valueno
- && regno < valueno + HARD_REGNO_NREGS (valueno, mode))
+ && regno + (int) HARD_REGNO_NREGS (regno, mode) > valueno
+ && regno < valueno + (int) HARD_REGNO_NREGS (valueno, mode))
return 0;
+ nregs = HARD_REGNO_NREGS (regno, mode);
+ valuenregs = HARD_REGNO_NREGS (valueno, mode);
+
/* Reject VALUE if it is one of the regs reserved for reloads.
Reload1 knows how to reuse them anyway, and it would get
confused if we allocated one without its knowledge.
(Now that insns introduced by reload are ignored above,
this case shouldn't happen, but I'm not positive.) */
- if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1
- && reload_reg_p[valueno] >= 0)
- return 0;
-
- /* On some machines, certain regs must always be rejected
- because they don't behave the way ordinary registers do. */
-
-#ifdef OVERLAPPING_REGNO_P
- if (OVERLAPPING_REGNO_P (valueno))
- return 0;
-#endif
-
- nregs = HARD_REGNO_NREGS (regno, mode);
- valuenregs = HARD_REGNO_NREGS (valueno, mode);
+ if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1)
+ {
+ int i;
+ for (i = 0; i < valuenregs; ++i)
+ if (reload_reg_p[valueno + i] >= 0)
+ return 0;
+ }
/* Reject VALUE if it is a register being used for an input reload
even if it is not one of those reserved. */
/* Don't trust the conversion past a function call
if either of the two is in a call-clobbered register, or memory. */
- if (GET_CODE (p) == CALL_INSN
- && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER
- && call_used_regs[regno])
- ||
- (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
- && call_used_regs[valueno])
- ||
- goal_mem
- || need_stable_sp))
- return 0;
+ if (GET_CODE (p) == CALL_INSN)
+ {
+ int i;
+
+ if (goal_mem || need_stable_sp)
+ return 0;
+
+ if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER)
+ for (i = 0; i < nregs; ++i)
+ if (call_used_regs[regno + i])
+ return 0;
+
+ if (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER)
+ for (i = 0; i < valuenregs; ++i)
+ if (call_used_regs[valueno + i])
+ return 0;
+ }
#ifdef NON_SAVING_SETJMP
if (NON_SAVING_SETJMP && GET_CODE (p) == NOTE
return 0;
#endif
-#ifdef INSN_CLOBBERS_REGNO_P
- if ((valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
- && INSN_CLOBBERS_REGNO_P (p, valueno))
- || (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
- && INSN_CLOBBERS_REGNO_P (p, regno)))
- return 0;
-#endif
-
- if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
+ if (INSN_P (p))
{
pat = PATTERN (p);
If GOAL is a memory ref and its address is not constant,
and this insn P changes a register used in GOAL, return 0. */
+ if (GET_CODE (pat) == COND_EXEC)
+ pat = COND_EXEC_CODE (pat);
if (GET_CODE (pat) == SET || GET_CODE (pat) == CLOBBER)
{
register rtx dest = SET_DEST (pat);
for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)
{
register rtx v1 = XVECEXP (pat, 0, i);
+ if (GET_CODE (v1) == COND_EXEC)
+ v1 = COND_EXEC_CODE (v1);
if (GET_CODE (v1) == SET || GET_CODE (v1) == CLOBBER)
{
register rtx dest = SET_DEST (v1);
if (GET_CODE (pat) == CLOBBER)
{
register rtx dest = SET_DEST (pat);
- while (GET_CODE (dest) == SUBREG
- || GET_CODE (dest) == ZERO_EXTRACT
- || GET_CODE (dest) == SIGN_EXTRACT
- || GET_CODE (dest) == STRICT_LOW_PART)
- dest = XEXP (dest, 0);
+
if (GET_CODE (dest) == REG)
{
register int xregno = REGNO (dest);
- int xnregs;
- if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
- xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
- else
- xnregs = 1;
+ int xnregs
+ = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
+
if (xregno < regno + nregs
&& xregno + xnregs > regno)
return 0;
- if (xregno < valueno + valuenregs
- && xregno + xnregs > valueno)
+ else if (xregno < valueno + valuenregs
+ && xregno + xnregs > valueno)
return 0;
- if (goal_mem_addr_varies
- && reg_overlap_mentioned_for_reload_p (dest,
+ else if (goal_mem_addr_varies
+ && reg_overlap_mentioned_for_reload_p (dest,
goal))
return 0;
}
+
else if (goal_mem && GET_CODE (dest) == MEM
&& ! push_operand (dest, GET_MODE (dest)))
return 0;
|| GET_CODE (addr) == POST_INC)
&& XEXP (addr, 0) == inced)
return GET_MODE_SIZE (GET_MODE (x));
+ else if ((GET_CODE (addr) == PRE_MODIFY
+ || GET_CODE (addr) == POST_MODIFY)
+ && GET_CODE (XEXP (addr, 1)) == PLUS
+ && XEXP (addr, 0) == XEXP (XEXP (addr, 1), 0)
+ && XEXP (addr, 0) == inced
+ && GET_CODE (XEXP (XEXP (addr, 1), 1)) == CONST_INT)
+ {
+ i = INTVAL (XEXP (XEXP (addr, 1), 1));
+ return i < 0 ? -i : i;
+ }
}
fmt = GET_RTX_FORMAT (code);
return 0;
}
\f
-/* Return 1 if register REGNO is the subject of a clobber in insn INSN. */
+/* Return 1 if register REGNO is the subject of a clobber in insn INSN.
+ If SETS is nonzero, also consider SETs. */
int
-regno_clobbered_p (regno, insn)
- int regno;
+regno_clobbered_p (regno, insn, mode, sets)
+ unsigned int regno;
rtx insn;
+ enum machine_mode mode;
+ int sets;
{
- if (GET_CODE (PATTERN (insn)) == CLOBBER
+ int nregs = HARD_REGNO_NREGS (regno, mode);
+ int endregno = regno + nregs;
+
+ if ((GET_CODE (PATTERN (insn)) == CLOBBER
+ || (sets && GET_CODE (PATTERN (insn)) == SET))
&& GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
- return REGNO (XEXP (PATTERN (insn), 0)) == regno;
+ {
+ int test = REGNO (XEXP (PATTERN (insn), 0));
+
+ return test >= regno && test < endregno;
+ }
if (GET_CODE (PATTERN (insn)) == PARALLEL)
{
for (; i >= 0; i--)
{
rtx elt = XVECEXP (PATTERN (insn), 0, i);
- if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG
- && REGNO (XEXP (elt, 0)) == regno)
- return 1;
+ if ((GET_CODE (elt) == CLOBBER
+ || (sets && GET_CODE (PATTERN (insn)) == SET))
+ && GET_CODE (XEXP (elt, 0)) == REG)
+ {
+ int test = REGNO (XEXP (elt, 0));
+
+ if (test >= regno && test < endregno)
+ return 1;
+ }
}
}
fprintf (f, ", optional");
if (rld[r].nongroup)
- fprintf (stderr, ", nongroup");
+ fprintf (f, ", nongroup");
if (rld[r].inc != 0)
fprintf (f, ", inc by %d", rld[r].inc);
prefix = "\n\t";
if (rld[r].secondary_in_icode != CODE_FOR_nothing)
{
- fprintf (stderr, "%ssecondary_in_icode = %s", prefix,
+ fprintf (f, "%ssecondary_in_icode = %s", prefix,
insn_data[rld[r].secondary_in_icode].name);
prefix = ", ";
}
if (rld[r].secondary_out_icode != CODE_FOR_nothing)
- fprintf (stderr, "%ssecondary_out_icode = %s", prefix,
+ fprintf (f, "%ssecondary_out_icode = %s", prefix,
insn_data[rld[r].secondary_out_icode].name);
fprintf (f, "\n");