home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / reload.c < prev    next >
C/C++ Source or Header  |  1992-06-19  |  140KB  |  4,245 lines

  1. /* Search an insn for pseudo regs that must be in hard regs and are not.
  2.    Copyright (C) 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This file contains subroutines used only from the file reload1.c.
  22.    It knows how to scan one insn for operands and values
  23.    that need to be copied into registers to make valid code.
  24.    It also finds other operands and values which are valid
  25.    but for which equivalent values in registers exist and
  26.    ought to be used instead.
  27.  
  28.    Before processing the first insn of the function, call `init_reload'.
  29.  
  30.    To scan an insn, call `find_reloads'.  This does two things:
  31.    1. sets up tables describing which values must be reloaded
  32.    for this insn, and what kind of hard regs they must be reloaded into;
  33.    2. optionally record the locations where those values appear in
  34.    the data, so they can be replaced properly later.
  35.    This is done only if the second arg to `find_reloads' is nonzero.
  36.  
  37.    The third arg to `find_reloads' specifies the number of levels
  38.    of indirect addressing supported by the machine.  If it is zero,
  39.    indirect addressing is not valid.  If it is one, (MEM (REG n))
  40.    is valid even if (REG n) did not get a hard register; if it is two,
  41.    (MEM (MEM (REG n))) is also valid even if (REG n) did not get a
  42.    hard register, and similarly for higher values.
  43.  
  44.    Then you must choose the hard regs to reload those pseudo regs into,
  45.    and generate appropriate load insns before this insn and perhaps
  46.    also store insns after this insn.  Set up the array `reload_reg_rtx'
  47.    to contain the REG rtx's for the registers you used.  In some
  48.    cases `find_reloads' will return a nonzero value in `reload_reg_rtx'
  49.    for certain reloads.  Then that tells you which register to use,
  50.    so you do not need to allocate one.  But you still do need to add extra
  51.    instructions to copy the value into and out of that register.
  52.  
  53.    Finally you must call `subst_reloads' to substitute the reload reg rtx's
  54.    into the locations already recorded.
  55.  
  56. NOTE SIDE EFFECTS:
  57.  
  58.    find_reloads can alter the operands of the instruction it is called on.
  59.  
  60.    1. Two operands of any sort may be interchanged, if they are in a
  61.    commutative instruction.
  62.    This happens only if find_reloads thinks the instruction will compile
  63.    better that way.
  64.  
  65.    2. Pseudo-registers that are equivalent to constants are replaced
  66.    with those constants if they are not in hard registers.
  67.  
  68. 1 happens every time find_reloads is called.
  69. 2 happens only when REPLACE is 1, which is only when
  70. actually doing the reloads, not when just counting them.
  71.  
  72.  
  73. Using a reload register for several reloads in one insn:
  74.  
  75. When an insn has reloads, it is considered as having three parts:
  76. the input reloads, the insn itself after reloading, and the output reloads.
  77. Reloads of values used in memory addresses are often needed for only one part.
  78.  
  79. When this is so, reload_when_needed records which part needs the reload.
  80. Two reloads for different parts of the insn can share the same reload
  81. register.
  82.  
  83. When a reload is used for addresses in multiple parts, or when it is
  84. an ordinary operand, it is classified as RELOAD_OTHER, and cannot share
  85. a register with any other reload.  */
  86.  
  87. #define REG_OK_STRICT
  88.  
  89. #include "config.h"
  90. #include "rtl.h"
  91. #include "insn-config.h"
  92. #include "recog.h"
  93. #include "reload.h"
  94. #include "regs.h"
  95. #include "hard-reg-set.h"
  96. #include "flags.h"
  97. #include "real.h"
  98.  
  99. #define min(x,y) ((x) < (y) ? (x) : (y))
  100.  
  101. #ifndef REGISTER_MOVE_COST
  102. #define REGISTER_MOVE_COST(x, y) 2
  103. #endif
  104.  
  105. /* The variables set up by `find_reloads' are:
  106.  
  107.    n_reloads          number of distinct reloads needed; max reload # + 1
  108.        tables indexed by reload number
  109.    reload_in          rtx for value to reload from
  110.    reload_out          rtx for where to store reload-reg afterward if nec
  111.                (often the same as reload_in)
  112.    reload_reg_class      enum reg_class, saying what regs to reload into
  113.    reload_inmode      enum machine_mode; mode this operand should have
  114.                when reloaded, on input.
  115.    reload_outmode      enum machine_mode; mode this operand should have
  116.                when reloaded, on output.
  117.    reload_strict_low      char; currently always zero; used to mean that this
  118.               reload is inside a STRICT_LOW_PART, but we don't
  119.               need to know this anymore.
  120.    reload_optional      char, nonzero for an optional reload.
  121.                Optional reloads are ignored unless the
  122.                value is already sitting in a register.
  123.    reload_inc          int, positive amount to increment or decrement by if
  124.                reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC.
  125.                Ignored otherwise (don't assume it is zero).
  126.    reload_in_reg      rtx.  A reg for which reload_in is the equivalent.
  127.                If reload_in is a symbol_ref which came from
  128.                reg_equiv_constant, then this is the pseudo
  129.                which has that symbol_ref as equivalent.
  130.    reload_reg_rtx      rtx.  This is the register to reload into.
  131.                If it is zero when `find_reloads' returns,
  132.                you must find a suitable register in the class
  133.                specified by reload_reg_class, and store here
  134.                an rtx for that register with mode from
  135.                reload_inmode or reload_outmode.
  136.    reload_nocombine      char, nonzero if this reload shouldn't be
  137.                combined with another reload.
  138.    reload_needed_for      rtx, operand this reload is needed for address of.
  139.                0 means it isn't needed for addressing.
  140.    reload_needed_for_multiple
  141.               int, 1 if this reload needed for more than one thing.
  142.    reload_when_needed     enum, classifies reload as needed either for
  143.                addressing an input reload, addressing an output,
  144.                for addressing a non-reloaded mem ref,
  145.                or for unspecified purposes (i.e., more than one
  146.                of the above).
  147.    reload_secondary_reload int, gives the reload number of a secondary
  148.                reload, when needed; otherwise -1
  149.    reload_secondary_p      int, 1 if this is a secondary register for one
  150.               or more reloads.  */
  151. int n_reloads;
  152.  
  153. rtx reload_in[MAX_RELOADS];
  154. rtx reload_out[MAX_RELOADS];
  155. enum reg_class reload_reg_class[MAX_RELOADS];
  156. enum machine_mode reload_inmode[MAX_RELOADS];
  157. enum machine_mode reload_outmode[MAX_RELOADS];
  158. char reload_strict_low[MAX_RELOADS];
  159. rtx reload_reg_rtx[MAX_RELOADS];
  160. char reload_optional[MAX_RELOADS];
  161. int reload_inc[MAX_RELOADS];
  162. rtx reload_in_reg[MAX_RELOADS];
  163. char reload_nocombine[MAX_RELOADS];
  164. int reload_needed_for_multiple[MAX_RELOADS];
  165. rtx reload_needed_for[MAX_RELOADS];
  166. enum reload_when_needed reload_when_needed[MAX_RELOADS];
  167. int reload_secondary_reload[MAX_RELOADS];
  168. int reload_secondary_p[MAX_RELOADS];
  169.  
  170. /* All the "earlyclobber" operands of the current insn
  171.    are recorded here.  */
  172. int n_earlyclobbers;
  173. rtx reload_earlyclobbers[MAX_RECOG_OPERANDS];
  174.  
  175. /* Replacing reloads.
  176.  
  177.    If `replace_reloads' is nonzero, then as each reload is recorded
  178.    an entry is made for it in the table `replacements'.
  179.    Then later `subst_reloads' can look through that table and
  180.    perform all the replacements needed.  */
  181.  
  182. /* Nonzero means record the places to replace.  */
  183. static int replace_reloads;
  184.  
  185. /* Each replacement is recorded with a structure like this.  */
  186. struct replacement
  187. {
  188.   rtx *where;            /* Location to store in */
  189.   rtx *subreg_loc;        /* Location of SUBREG if WHERE is inside
  190.                    a SUBREG; 0 otherwise.  */
  191.   int what;            /* which reload this is for */
  192.   enum machine_mode mode;    /* mode it must have */
  193. };
  194.  
  195. static struct replacement replacements[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)];
  196.  
  197. /* Number of replacements currently recorded.  */
  198. static int n_replacements;
  199.  
  200. /* MEM-rtx's created for pseudo-regs in stack slots not directly addressable;
  201.    (see reg_equiv_address).  */
  202. static rtx memlocs[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)];
  203. static int n_memlocs;
  204.  
  205. /* The instruction we are doing reloads for;
  206.    so we can test whether a register dies in it.  */
  207. static rtx this_insn;
  208.  
  209. /* Nonzero if this instruction is a user-specified asm with operands.  */
  210. static int this_insn_is_asm;
  211.  
  212. /* If hard_regs_live_known is nonzero,
  213.    we can tell which hard regs are currently live,
  214.    at least enough to succeed in choosing dummy reloads.  */
  215. static int hard_regs_live_known;
  216.  
  217. /* Indexed by hard reg number,
  218.    element is nonegative if hard reg has been spilled.
  219.    This vector is passed to `find_reloads' as an argument
  220.    and is not changed here.  */
  221. static short *static_reload_reg_p;
  222.  
  223. /* Set to 1 in subst_reg_equivs if it changes anything.  */
  224. static int subst_reg_equivs_changed;
  225.  
  226. /* On return from push_reload, holds the reload-number for the OUT
  227.    operand, which can be different for that from the input operand.  */
  228. static int output_reloadnum;
  229.  
  230. static int alternative_allows_memconst ();
  231. static rtx find_dummy_reload ();
  232. static rtx find_reloads_toplev ();
  233. static int find_reloads_address ();
  234. static int find_reloads_address_1 ();
  235. static int hard_reg_set_here_p ();
  236. /* static rtx forget_volatility (); */
  237. static rtx subst_reg_equivs ();
  238. static rtx subst_indexed_address ();
  239. rtx find_equiv_reg ();
  240. static int find_inc_amount ();
  241.  
  242. /* Record one (sometimes two) reload that needs to be performed.
  243.    IN is an rtx saying where the data are to be found before this instruction.
  244.    OUT says where they must be stored after the instruction.
  245.    (IN is zero for data not read, and OUT is zero for data not written.)
  246.    INLOC and OUTLOC point to the places in the instructions where
  247.    IN and OUT were found.
  248.    CLASS is a register class required for the reloaded data.
  249.    INMODE is the machine mode that the instruction requires
  250.    for the reg that replaces IN and OUTMODE is likewise for OUT.
  251.  
  252.    If IN is zero, then OUT's location and mode should be passed as
  253.    INLOC and INMODE.
  254.  
  255.    STRICT_LOW is the 1 if there is a containing STRICT_LOW_PART rtx.
  256.  
  257.    OPTIONAL nonzero means this reload does not need to be performed:
  258.    it can be discarded if that is more convenient.
  259.  
  260.    The return value is the reload-number for this reload.
  261.  
  262.    If both IN and OUT are nonzero, in some rare cases we might
  263.    want to make two separate reloads.  (Actually we never do this now.)
  264.    Therefore, the reload-number for OUT is stored in
  265.    output_reloadnum when we return; the return value applies to IN.
  266.    Usually (presently always), when IN and OUT are nonzero,
  267.    the two reload-numbers are equal, but the caller should be careful to
  268.    distinguish them.  */
  269.  
  270. static int
  271. push_reload (in, out, inloc, outloc, class,
  272.          inmode, outmode, strict_low, optional, needed_for)
  273.      register rtx in, out;
  274.      rtx *inloc, *outloc;
  275.      enum reg_class class;
  276.      enum machine_mode inmode, outmode;
  277.      int strict_low;
  278.      int optional;
  279.      rtx needed_for;
  280. {
  281.   register int i;
  282.   int dont_share = 0;
  283.   rtx *in_subreg_loc = 0, *out_subreg_loc = 0;
  284.   int secondary_reload = -1;
  285.  
  286.   /* Compare two RTX's.  */
  287. #define MATCHES(x, y) \
  288.  (x == y || (x != 0 && (GET_CODE (x) == REG                \
  289.             ? GET_CODE (y) == REG && REGNO (x) == REGNO (y)    \
  290.             : rtx_equal_p (x, y) && ! side_effects_p (x))))
  291.  
  292.   /* INMODE and/or OUTMODE could be VOIDmode if no mode
  293.      has been specified for the operand.  In that case,
  294.      use the operand's mode as the mode to reload.  */
  295.   if (inmode == VOIDmode && in != 0)
  296.     inmode = GET_MODE (in);
  297.   if (outmode == VOIDmode && out != 0)
  298.     outmode = GET_MODE (out);
  299.  
  300.   /* If IN is a pseudo register everywhere-equivalent to a constant, and 
  301.      it is not in a hard register, reload straight from the constant,
  302.      since we want to get rid of such pseudo registers.
  303.      Often this is done earlier, but not always in find_reloads_address.  */
  304.   if (in != 0 && GET_CODE (in) == REG)
  305.     {
  306.       register int regno = REGNO (in);
  307.  
  308.       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  309.       && reg_equiv_constant[regno] != 0)
  310.     in = reg_equiv_constant[regno];
  311.     }
  312.  
  313.   /* Likewise for OUT.  Of course, OUT will never be equivalent to
  314.      an actual constant, but it might be equivalent to a memory location
  315.      (in the case of a parameter).  */
  316.   if (out != 0 && GET_CODE (out) == REG)
  317.     {
  318.       register int regno = REGNO (out);
  319.  
  320.       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  321.       && reg_equiv_constant[regno] != 0)
  322.     out = reg_equiv_constant[regno];
  323.     }
  324.  
  325.   /* If we have a read-write operand with an address side-effect,
  326.      change either IN or OUT so the side-effect happens only once.  */
  327.   if (in != 0 && out != 0 && GET_CODE (in) == MEM && rtx_equal_p (in, out))
  328.     {
  329.       if (GET_CODE (XEXP (in, 0)) == POST_INC
  330.       || GET_CODE (XEXP (in, 0)) == POST_DEC)
  331.     in = gen_rtx (MEM, GET_MODE (in), XEXP (XEXP (in, 0), 0));
  332.       if (GET_CODE (XEXP (in, 0)) == PRE_INC
  333.       || GET_CODE (XEXP (in, 0)) == PRE_DEC)
  334.     out = gen_rtx (MEM, GET_MODE (out), XEXP (XEXP (out, 0), 0));
  335.     }
  336.  
  337.   /* If we are reloading a (SUBREG (MEM ...) ...) or (SUBREG constant ...),
  338.      really reload just the inside expression in its own mode.
  339.      If we have (SUBREG:M1 (REG:M2 ...) ...) with M1 wider than M2 and the
  340.      register is a pseudo, this will become the same as the above case.
  341.      Do the same for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where
  342.      either M1 is not valid for R or M2 is wider than a word but we only
  343.      need one word to store an M2-sized quantity in R.
  344.      Note that the case of (SUBREG (CONST_INT...)...) is handled elsewhere;
  345.      we can't handle it here because CONST_INT does not indicate a mode.
  346.  
  347.      Similarly, we must reload the inside expression if we have a
  348.      STRICT_LOW_PART (presumably, in == out in the cas).  */
  349.  
  350.   if (in != 0 && GET_CODE (in) == SUBREG
  351.       && (GET_CODE (SUBREG_REG (in)) != REG
  352.       || strict_low
  353.       || (GET_CODE (SUBREG_REG (in)) == REG
  354.           && REGNO (SUBREG_REG (in)) >= FIRST_PSEUDO_REGISTER
  355.           && (GET_MODE_SIZE (inmode)
  356.           > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))))
  357.       || (GET_CODE (SUBREG_REG (in)) == REG
  358.           && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
  359.           && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (in)), inmode)
  360.           || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
  361.               && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  362.               > UNITS_PER_WORD)
  363.               && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  364.                / UNITS_PER_WORD)
  365.               != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)),
  366.                            GET_MODE (SUBREG_REG (in)))))))))
  367.     {
  368.       in_subreg_loc = inloc;
  369.       inloc = &SUBREG_REG (in);
  370.       in = *inloc;
  371.       if (GET_CODE (in) == MEM)
  372.     /* This is supposed to happen only for paradoxical subregs made by
  373.        combine.c.  (SUBREG (MEM)) isn't supposed to occur other ways.  */
  374.     if (GET_MODE_SIZE (GET_MODE (in)) > GET_MODE_SIZE (inmode))
  375.       abort ();
  376.       inmode = GET_MODE (in);
  377.     }
  378.  
  379.   /* Similarly for paradoxical and problematical SUBREGs on the output.
  380.      Note that there is no reason we need worry about the previous value
  381.      of SUBREG_REG (out); even if wider than out,
  382.      storing in a subreg is entitled to clobber it all
  383.      (except in the case of STRICT_LOW_PART,
  384.      and in that case the constraint should label it input-output.)  */
  385.   if (out != 0 && GET_CODE (out) == SUBREG
  386.       && (GET_CODE (SUBREG_REG (out)) != REG
  387.       || strict_low
  388.       || (GET_CODE (SUBREG_REG (out)) == REG
  389.           && REGNO (SUBREG_REG (out)) >= FIRST_PSEUDO_REGISTER
  390.           && (GET_MODE_SIZE (outmode)
  391.           > GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))))
  392.       || (GET_CODE (SUBREG_REG (out)) == REG
  393.           && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
  394.           && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (out)), outmode)
  395.           || (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
  396.               && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
  397.               > UNITS_PER_WORD)
  398.               && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
  399.                / UNITS_PER_WORD)
  400.               != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)),
  401.                            GET_MODE (SUBREG_REG (out)))))))))
  402.     {
  403.       out_subreg_loc = outloc;
  404.       outloc = &SUBREG_REG (out);
  405.       out = *outloc;
  406.       if (GET_CODE (out) == MEM
  407.       && GET_MODE_SIZE (GET_MODE (out)) > GET_MODE_SIZE (outmode))
  408.     abort ();
  409.       outmode = GET_MODE (out);
  410.     }
  411.  
  412.   /* That's all we use STRICT_LOW for, so clear it.  At some point,
  413.      we may want to get rid of reload_strict_low.  */
  414.   strict_low = 0;
  415.  
  416.   /* If IN appears in OUT, we can't share any input-only reload for IN.  */
  417.   if (in != 0 && out != 0 && GET_CODE (out) == MEM
  418.       && (GET_CODE (in) == REG || GET_CODE (in) == MEM)
  419.       && reg_overlap_mentioned_p (in, XEXP (out, 0)))
  420.     dont_share = 1;
  421.  
  422.   /* Narrow down the class of register wanted if that is
  423.      desirable on this machine for efficiency.  */
  424.   if (in != 0)
  425.     class = PREFERRED_RELOAD_CLASS (in, class);
  426.  
  427.   /* Make sure we use a class that can handle the actual pseudo
  428.      inside any subreg.  For example, on the 386, QImode regs
  429.      can appear within SImode subregs.  Although GENERAL_REGS
  430.      can handle SImode, QImode needs a smaller class.  */
  431. #ifdef LIMIT_RELOAD_CLASS
  432.   if (in_subreg_loc)
  433.     class = LIMIT_RELOAD_CLASS (inmode, class);
  434.   else if (in != 0 && GET_CODE (in) == SUBREG)
  435.     class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (in)), class);
  436.  
  437.   if (out_subreg_loc)
  438.     class = LIMIT_RELOAD_CLASS (outmode, class);
  439.   if (out != 0 && GET_CODE (out) == SUBREG)
  440.     class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (out)), class);
  441. #endif
  442.  
  443.   if (class == NO_REGS)
  444.     abort ();
  445.  
  446.   /* Verify that this class is at least possible for the mode that
  447.      is specified.  */
  448.   if (this_insn_is_asm)
  449.     {
  450.       enum machine_mode mode;
  451.       if (GET_MODE_SIZE (inmode) > GET_MODE_SIZE (outmode))
  452.     mode = inmode;
  453.       else
  454.     mode = outmode;
  455.       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  456.     if (HARD_REGNO_MODE_OK (i, mode)
  457.         && TEST_HARD_REG_BIT (reg_class_contents[(int) class], i))
  458.       {
  459.         int nregs = HARD_REGNO_NREGS (i, mode);
  460.  
  461.         int j;
  462.         for (j = 1; j < nregs; j++)
  463.           if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class], i + j))
  464.         break;
  465.         if (j == nregs)
  466.           break;
  467.       }
  468.       if (i == FIRST_PSEUDO_REGISTER)
  469.     {
  470.       error_for_asm (this_insn, "impossible register constraint in `asm'");
  471.       class = ALL_REGS;
  472.     }
  473.     }
  474.     
  475.   /* We can use an existing reload if the class is right
  476.      and at least one of IN and OUT is a match
  477.      and the other is at worst neutral.
  478.      (A zero compared against anything is neutral.)  */
  479.   for (i = 0; i < n_reloads; i++)
  480.     if ((reg_class_subset_p (class, reload_reg_class[i])
  481.      || reg_class_subset_p (reload_reg_class[i], class))
  482.     && reload_strict_low[i] == strict_low
  483.     /* If the existing reload has a register, it must fit our class.  */
  484.     && (reload_reg_rtx[i] == 0
  485.         || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  486.                   true_regnum (reload_reg_rtx[i])))
  487.     && ((in != 0 && MATCHES (reload_in[i], in) && ! dont_share
  488.          && (out == 0 || reload_out[i] == 0 || MATCHES (reload_out[i], out)))
  489.         ||
  490.         (out != 0 && MATCHES (reload_out[i], out)
  491.          && (in == 0 || reload_in[i] == 0 || MATCHES (reload_in[i], in)))))
  492.       break;
  493.  
  494.   /* Reloading a plain reg for input can match a reload to postincrement
  495.      that reg, since the postincrement's value is the right value.
  496.      Likewise, it can match a preincrement reload, since we regard
  497.      the preincrementation as happening before any ref in this insn
  498.      to that register.  */
  499.   if (i == n_reloads)
  500.     for (i = 0; i < n_reloads; i++)
  501.       if ((reg_class_subset_p (class, reload_reg_class[i])
  502.        || reg_class_subset_p (reload_reg_class[i], class))
  503.       /* If the existing reload has a register, it must fit our class.  */
  504.       && (reload_reg_rtx[i] == 0
  505.           || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  506.                     true_regnum (reload_reg_rtx[i])))
  507.       && reload_strict_low[i] == strict_low
  508.       && out == 0 && reload_out[i] == 0 && reload_in[i] != 0
  509.       && ((GET_CODE (in) == REG
  510.            && (GET_CODE (reload_in[i]) == POST_INC
  511.            || GET_CODE (reload_in[i]) == POST_DEC
  512.            || GET_CODE (reload_in[i]) == PRE_INC
  513.            || GET_CODE (reload_in[i]) == PRE_DEC)
  514.            && MATCHES (XEXP (reload_in[i], 0), in))
  515.           ||
  516.           (GET_CODE (reload_in[i]) == REG
  517.            && (GET_CODE (in) == POST_INC
  518.            || GET_CODE (in) == POST_DEC
  519.            || GET_CODE (in) == PRE_INC
  520.            || GET_CODE (in) == PRE_DEC)
  521.            && MATCHES (XEXP (in, 0), reload_in[i]))))
  522.     {
  523.       /* Make sure reload_in ultimately has the increment,
  524.          not the plain register.  */
  525.       if (GET_CODE (in) == REG)
  526.         in = reload_in[i];
  527.       break;
  528.     }
  529.  
  530.   if (i == n_reloads)
  531.     {
  532. #ifdef SECONDARY_RELOAD_CLASS
  533.       enum reg_class secondary_class = NO_REGS;
  534.  
  535.       /* See if we need a secondary reload register to move between
  536.      CLASS and IN or OUT.  */
  537.  
  538.       if (in != 0)
  539.     secondary_class = SECONDARY_RELOAD_CLASS (class, inmode, in);
  540.  
  541.       if (out != 0 && GET_CODE (out) != SCRATCH)
  542.     {
  543.       enum reg_class out_secondary_class
  544.         = SECONDARY_RELOAD_CLASS (class, outmode, out);
  545.  
  546.       /* If both IN and OUT need a secondary register, find a class
  547.          that will work for both.  We only check to see if one is a subset
  548.          of the other.  If not, we make a separate reload for the output.
  549.          This case should be very rare.  We could compute the intersection
  550.          if it turns out to be useful.  */
  551.       if (out_secondary_class != NO_REGS
  552.           && out_secondary_class != secondary_class)
  553.         {
  554.           if (secondary_class == NO_REGS
  555.           || reg_class_subset_p (out_secondary_class, secondary_class))
  556.         secondary_class = out_secondary_class;
  557.           else if (reg_class_subset_p (secondary_class,
  558.                        out_secondary_class))
  559.         ;
  560.           else
  561.         {
  562.           push_reload (0, out, 0, outloc, class, VOIDmode, outmode,
  563.                    strict_low, optional, needed_for);
  564.           out = 0;
  565.           outloc = 0;
  566.           outmode = VOIDmode;
  567.         }
  568.         }
  569.     }
  570.  
  571.       if (secondary_class != NO_REGS)
  572.     {
  573.       /* See if we can reuse an existing secondary reload.  */
  574.       for (secondary_reload = 0; secondary_reload < n_reloads;
  575.            secondary_reload++)
  576.         if (reload_secondary_p[secondary_reload]
  577.         && (reg_class_subset_p (secondary_class,
  578.                     reload_reg_class[secondary_reload])
  579.             || reg_class_subset_p (reload_reg_class[secondary_reload],
  580.                        secondary_class))
  581.         && (reload_inmode[secondary_reload] == inmode
  582.             || reload_inmode[secondary_reload] == VOIDmode)
  583.         && (reload_outmode[secondary_reload] == outmode
  584.             || reload_outmode[secondary_reload] == VOIDmode))
  585.           {
  586.         if (inmode != VOIDmode)
  587.           reload_inmode[secondary_reload] = inmode;
  588.         if (outmode != VOIDmode)
  589.           reload_outmode[secondary_reload] = outmode;
  590.         if (reg_class_subset_p (secondary_class,
  591.                     reload_reg_class[secondary_reload]))
  592.           reload_reg_class[secondary_reload] = secondary_class;
  593.         if (reload_needed_for[secondary_reload] != needed_for)
  594.           reload_needed_for_multiple[secondary_reload] = 1;
  595.         reload_optional[secondary_reload] &= optional;
  596.           }
  597.  
  598.       if (secondary_reload == n_reloads)
  599.         {
  600.           /* We need to make a new secondary reload for this register
  601.          class.  */
  602.           reload_in[secondary_reload] = reload_out[secondary_reload] = 0;
  603.           reload_reg_class[secondary_reload] = secondary_class;
  604.           reload_inmode[secondary_reload] = inmode;
  605.           reload_outmode[secondary_reload] = outmode;
  606.           reload_reg_rtx[secondary_reload] = 0;
  607.           reload_optional[secondary_reload] = optional;
  608.           reload_inc[secondary_reload] = 0;
  609.           reload_strict_low[secondary_reload] = 0;
  610.           /* Maybe we could combine these, but it seems too tricky.  */
  611.           reload_nocombine[secondary_reload] = 1;
  612.           reload_in_reg[secondary_reload] = 0;
  613.           reload_needed_for[secondary_reload] = needed_for;
  614.           reload_needed_for_multiple[secondary_reload] = 0;
  615.           reload_secondary_reload[secondary_reload] = -1;
  616.           reload_secondary_p[secondary_reload] = 1;
  617.  
  618.           n_reloads++;
  619.           i = n_reloads;
  620.         }
  621.     }
  622. #endif
  623.  
  624.       /* We found no existing reload suitable for re-use.
  625.      So add an additional reload.  */
  626.  
  627.       reload_in[i] = in;
  628.       reload_out[i] = out;
  629.       reload_reg_class[i] = class;
  630.       reload_inmode[i] = inmode;
  631.       reload_outmode[i] = outmode;
  632.       reload_reg_rtx[i] = 0;
  633.       reload_optional[i] = optional;
  634.       reload_inc[i] = 0;
  635.       reload_strict_low[i] = strict_low;
  636.       reload_nocombine[i] = 0;
  637.       reload_in_reg[i] = inloc ? *inloc : 0;
  638.       reload_needed_for[i] = needed_for;
  639.       reload_needed_for_multiple[i] = 0;
  640.       reload_secondary_reload[i] = secondary_reload;
  641.       reload_secondary_p[i] = 0;
  642.  
  643.       n_reloads++;
  644.     }
  645.   else
  646.     {
  647.       /* We are reusing an existing reload,
  648.      but we may have additional information for it.
  649.      For example, we may now have both IN and OUT
  650.      while the old one may have just one of them.  */
  651.  
  652.       if (inmode != VOIDmode)
  653.     reload_inmode[i] = inmode;
  654.       if (outmode != VOIDmode)
  655.     reload_outmode[i] = outmode;
  656.       if (in != 0)
  657.     reload_in[i] = in;
  658.       if (out != 0)
  659.     reload_out[i] = out;
  660.       if (reg_class_subset_p (class, reload_reg_class[i]))
  661.     reload_reg_class[i] = class;
  662.       reload_optional[i] &= optional;
  663.       if (reload_needed_for[i] != needed_for)
  664.     reload_needed_for_multiple[i] = 1;
  665.     }
  666.  
  667.   /* If the ostensible rtx being reload differs from the rtx found
  668.      in the location to substitute, this reload is not safe to combine
  669.      because we cannot reliably tell whether it appears in the insn.  */
  670.  
  671.   if (in != 0 && in != *inloc)
  672.     reload_nocombine[i] = 1;
  673.  
  674. #if 0
  675.   /* This was replaced by changes in find_reloads_address_1 and the new
  676.      function inc_for_reload, which go with a new meaning of reload_inc.  */
  677.  
  678.   /* If this is an IN/OUT reload in an insn that sets the CC,
  679.      it must be for an autoincrement.  It doesn't work to store
  680.      the incremented value after the insn because that would clobber the CC.
  681.      So we must do the increment of the value reloaded from,
  682.      increment it, store it back, then decrement again.  */
  683.   if (out != 0 && sets_cc0_p (PATTERN (this_insn)))
  684.     {
  685.       out = 0;
  686.       reload_out[i] = 0;
  687.       reload_inc[i] = find_inc_amount (PATTERN (this_insn), in);
  688.       /* If we did not find a nonzero amount-to-increment-by,
  689.      that contradicts the belief that IN is being incremented
  690.      in an address in this insn.  */
  691.       if (reload_inc[i] == 0)
  692.     abort ();
  693.     }
  694. #endif
  695.  
  696.   /* If we will replace IN and OUT with the reload-reg,
  697.      record where they are located so that substitution need
  698.      not do a tree walk.  */
  699.  
  700.   if (replace_reloads)
  701.     {
  702.       if (inloc != 0)
  703.     {
  704.       register struct replacement *r = &replacements[n_replacements++];
  705.       r->what = i;
  706.       r->subreg_loc = in_subreg_loc;
  707.       r->where = inloc;
  708.       r->mode = inmode;
  709.     }
  710.       if (outloc != 0 && outloc != inloc)
  711.     {
  712.       register struct replacement *r = &replacements[n_replacements++];
  713.       r->what = i;
  714.       r->where = outloc;
  715.       r->subreg_loc = out_subreg_loc;
  716.       r->mode = outmode;
  717.     }
  718.     }
  719.  
  720.   /* If this reload is just being introduced and it has both
  721.      an incoming quantity and an outgoing quantity that are
  722.      supposed to be made to match, see if either one of the two
  723.      can serve as the place to reload into.
  724.  
  725.      If one of them is acceptable, set reload_reg_rtx[i]
  726.      to that one.  */
  727.  
  728.   if (in != 0 && out != 0 && in != out && reload_reg_rtx[i] == 0)
  729.     {
  730.       reload_reg_rtx[i] = find_dummy_reload (in, out, inloc, outloc,
  731.                          reload_reg_class[i], i);
  732.  
  733.       /* If the outgoing register already contains the same value
  734.      as the incoming one, we can dispense with loading it.
  735.      The easiest way to tell the caller that is to give a phony
  736.      value for the incoming operand (same as outgoing one).  */
  737.       if (reload_reg_rtx[i] == out
  738.       && (GET_CODE (in) == REG || CONSTANT_P (in))
  739.       && 0 != find_equiv_reg (in, this_insn, 0, REGNO (out),
  740.                   static_reload_reg_p, i, inmode))
  741.     reload_in[i] = out;
  742.     }
  743.  
  744.   /* If this is an input reload and the operand contains a register that
  745.      dies in this insn and is used nowhere else, see if it is the right class
  746.      to be used for this reload.  Use it if so.  (This occurs most commonly
  747.      in the case of paradoxical SUBREGs and in-out reloads).  We cannot do
  748.      this if it is also an output reload that mentions the register unless
  749.      the output is a SUBREG that clobbers an entire register.
  750.  
  751.      Note that the operand might be one of the spill regs, if it is a
  752.      pseudo reg and we are in a block where spilling has not taken place.
  753.      But if there is no spilling in this block, that is OK.
  754.      An explicitly used hard reg cannot be a spill reg.  */
  755.  
  756.   if (reload_reg_rtx[i] == 0 && in != 0)
  757.     {
  758.       rtx note;
  759.       int regno;
  760.  
  761.       for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1))
  762.     if (REG_NOTE_KIND (note) == REG_DEAD
  763.         && GET_CODE (XEXP (note, 0)) == REG
  764.         && (regno = REGNO (XEXP (note, 0))) < FIRST_PSEUDO_REGISTER
  765.         && reg_mentioned_p (XEXP (note, 0), in)
  766.         && ! refers_to_regno_p (regno,
  767.                     regno + HARD_REGNO_NREGS (regno, inmode),
  768.                     PATTERN (this_insn), inloc)
  769.         && (in != out
  770.         || (GET_CODE (in) == SUBREG
  771.             && (((GET_MODE_SIZE (GET_MODE (in)) + (UNITS_PER_WORD - 1))
  772.              / UNITS_PER_WORD)
  773.             == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
  774.                  + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD))))
  775.         /* Make sure the operand fits in the reg that dies.  */
  776.         && GET_MODE_SIZE (inmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
  777.         && HARD_REGNO_MODE_OK (regno, inmode)
  778.         && GET_MODE_SIZE (outmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
  779.         && HARD_REGNO_MODE_OK (regno, outmode)
  780.         && TEST_HARD_REG_BIT (reg_class_contents[(int) class], regno))
  781.       {
  782.         reload_reg_rtx[i] = gen_rtx (REG, inmode, regno);
  783.         break;
  784.       }
  785.     }
  786.  
  787.   if (out)
  788.     output_reloadnum = i;
  789.  
  790.   return i;
  791. }
  792.  
  793. /* Record an additional place we must replace a value
  794.    for which we have already recorded a reload.
  795.    RELOADNUM is the value returned by push_reload
  796.    when the reload was recorded.
  797.    This is used in insn patterns that use match_dup.  */
  798.  
  799. static void
  800. push_replacement (loc, reloadnum, mode)
  801.      rtx *loc;
  802.      int reloadnum;
  803.      enum machine_mode mode;
  804. {
  805.   if (replace_reloads)
  806.     {
  807.       register struct replacement *r = &replacements[n_replacements++];
  808.       r->what = reloadnum;
  809.       r->where = loc;
  810.       r->subreg_loc = 0;
  811.       r->mode = mode;
  812.     }
  813. }
  814.  
  815. /* If there is only one output reload, and it is not for an earlyclobber
  816.    operand, try to combine it with a (logically unrelated) input reload
  817.    to reduce the number of reload registers needed.
  818.  
  819.    This is safe if the input reload does not appear in
  820.    the value being output-reloaded, because this implies
  821.    it is not needed any more once the original insn completes.
  822.  
  823.    If that doesn't work, see we can use any of the registers that
  824.    die in this insn as a reload register.  We can if it is of the right
  825.    class and does not appear in the value being output-reloaded.  */
  826.  
  827. static void
  828. combine_reloads ()
  829. {
  830.   int i;
  831.   int output_reload = -1;
  832.   rtx note;
  833.  
  834.   /* Find the output reload; return unless there is exactly one
  835.      and that one is mandatory.  */
  836.  
  837.   for (i = 0; i < n_reloads; i++)
  838.     if (reload_out[i] != 0)
  839.       {
  840.     if (output_reload >= 0)
  841.       return;
  842.     output_reload = i;
  843.       }
  844.  
  845.   if (output_reload < 0 || reload_optional[output_reload])
  846.     return;
  847.  
  848.   /* An input-output reload isn't combinable.  */
  849.  
  850.   if (reload_in[output_reload] != 0)
  851.     return;
  852.  
  853.   /* If this reload is for an earlyclobber operand, we can't do anyting.  */
  854.  
  855.   for (i = 0; i < n_earlyclobbers; i++)
  856.     if (reload_out[output_reload] == reload_earlyclobbers[i])
  857.       return;
  858.  
  859.   /* Check each input reload; can we combine it?  */
  860.  
  861.   for (i = 0; i < n_reloads; i++)
  862.     if (reload_in[i] && ! reload_optional[i] && ! reload_nocombine[i]
  863.     /* Life span of this reload must not extend past main insn.  */
  864.     && reload_when_needed[i] != RELOAD_FOR_OUTPUT_RELOAD_ADDRESS
  865.     && reload_inmode[i] == reload_outmode[output_reload]
  866.     && reload_inc[i] == 0
  867.     && reload_reg_rtx[i] == 0
  868.     && reload_strict_low[i] == 0
  869.     && (reg_class_subset_p (reload_reg_class[i],
  870.                 reload_reg_class[output_reload])
  871.         || reg_class_subset_p (reload_reg_class[output_reload],
  872.                    reload_reg_class[i]))
  873.     && (MATCHES (reload_in[i], reload_out[output_reload])
  874.         /* Args reversed because the first arg seems to be
  875.            the one that we imagine being modified
  876.            while the second is the one that might be affected.  */
  877.         || (! reg_overlap_mentioned_p (reload_out[output_reload],
  878.                        reload_in[i])
  879.         /* However, if the input is a register that appears inside
  880.            the output, then we also can't share.
  881.            Imagine (set (mem (reg 69)) (plus (reg 69) ...)).
  882.            If the same reload reg is used for both reg 69 and the
  883.            result to be stored in memory, then that result
  884.            will clobber the address of the memory ref.  */
  885.         && ! (GET_CODE (reload_in[i]) == REG
  886.               && reg_overlap_mentioned_p (reload_in[i],
  887.                           reload_out[output_reload])))))
  888.       {
  889.     int j;
  890.  
  891.     /* We have found a reload to combine with!  */
  892.     reload_out[i] = reload_out[output_reload];
  893.     reload_outmode[i] = reload_outmode[output_reload];
  894.     /* Mark the old output reload as inoperative.  */
  895.     reload_out[output_reload] = 0;
  896.     /* The combined reload is needed for the entire insn.  */
  897.     reload_needed_for_multiple[i] = 1;
  898.     reload_when_needed[i] = RELOAD_OTHER;
  899.     /* If required, minimize the register class. */
  900.     if (reg_class_subset_p (reload_reg_class[output_reload],
  901.                 reload_reg_class[i]))
  902.       reload_reg_class[i] = reload_reg_class[output_reload];
  903.  
  904.     /* Transfer all replacements from the old reload to the combined.  */
  905.     for (j = 0; j < n_replacements; j++)
  906.       if (replacements[j].what == output_reload)
  907.         replacements[j].what = i;
  908.  
  909.     return;
  910.       }
  911.  
  912.   /* If this insn has only one operand that is modified or written (assumed
  913.      to be the first),  it must be the one corresponding to this reload.  It
  914.      is safe to use anything that dies in this insn for that output provided
  915.      that it does not occur in the output (we already know it isn't an
  916.      earlyclobber.  If this is an asm insn, give up.  */
  917.  
  918.   if (INSN_CODE (this_insn) == -1)
  919.     return;
  920.  
  921.   for (i = 1; i < insn_n_operands[INSN_CODE (this_insn)]; i++)
  922.     if (insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '='
  923.     || insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '+')
  924.       return;
  925.  
  926.   /* See if some hard register that dies in this insn and is not used in
  927.      the output is the right class.  Only works if the register we pick
  928.      up can fully hold our output reload.  */
  929.   for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1))
  930.     if (REG_NOTE_KIND (note) == REG_DEAD
  931.     && GET_CODE (XEXP (note, 0)) == REG
  932.     && ! reg_overlap_mentioned_p (XEXP (note, 0),
  933.                       reload_out[output_reload])
  934.     && REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER
  935.     && HARD_REGNO_MODE_OK (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
  936.     && TEST_HARD_REG_BIT (reg_class_contents[(int) reload_reg_class[output_reload]],
  937.                   REGNO (XEXP (note, 0)))
  938.     && (HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
  939.         <= HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), GET_MODE (XEXP (note, 0)))))
  940.       {
  941.     reload_reg_rtx[output_reload] = gen_rtx (REG,
  942.                          reload_outmode[output_reload],
  943.                          REGNO (XEXP (note, 0)));
  944.     return;
  945.       }
  946. }
  947.  
  948. /* Try to find a reload register for an in-out reload (expressions IN and OUT).
  949.    See if one of IN and OUT is a register that may be used;
  950.    this is desirable since a spill-register won't be needed.
  951.    If so, return the register rtx that proves acceptable.
  952.  
  953.    INLOC and OUTLOC are locations where IN and OUT appear in the insn.
  954.    CLASS is the register class required for the reload.
  955.  
  956.    If FOR_REAL is >= 0, it is the number of the reload,
  957.    and in some cases when it can be discovered that OUT doesn't need
  958.    to be computed, clear out reload_out[FOR_REAL].
  959.  
  960.    If FOR_REAL is -1, this should not be done, because this call
  961.    is just to see if a register can be found, not to find and install it.  */
  962.  
  963. static rtx
  964. find_dummy_reload (real_in, real_out, inloc, outloc, class, for_real)
  965.      rtx real_in, real_out;
  966.      rtx *inloc, *outloc;
  967.      enum reg_class class;
  968.      int for_real;
  969. {
  970.   rtx in = real_in;
  971.   rtx out = real_out;
  972.   int in_offset = 0;
  973.   int out_offset = 0;
  974.   rtx value = 0;
  975.  
  976.   /* If operands exceed a word, we can't use either of them
  977.      unless they have the same size.  */
  978.   if (GET_MODE_SIZE (GET_MODE (real_out)) != GET_MODE_SIZE (GET_MODE (real_in))
  979.       && (GET_MODE_SIZE (GET_MODE (real_out)) > UNITS_PER_WORD
  980.       || GET_MODE_SIZE (GET_MODE (real_in)) > UNITS_PER_WORD))
  981.     return 0;
  982.  
  983.   /* Find the inside of any subregs.  */
  984.   while (GET_CODE (out) == SUBREG)
  985.     {
  986.       out_offset = SUBREG_WORD (out);
  987.       out = SUBREG_REG (out);
  988.     }
  989.   while (GET_CODE (in) == SUBREG)
  990.     {
  991.       in_offset = SUBREG_WORD (in);
  992.       in = SUBREG_REG (in);
  993.     }
  994.  
  995.   /* Narrow down the reg class, the same way push_reload will;
  996.      otherwise we might find a dummy now, but push_reload won't.  */
  997.   class = PREFERRED_RELOAD_CLASS (in, class);
  998.  
  999.   /* See if OUT will do.  */
  1000.   if (GET_CODE (out) == REG
  1001.       && REGNO (out) < FIRST_PSEUDO_REGISTER)
  1002.     {
  1003.       register int regno = REGNO (out) + out_offset;
  1004.       int nwords = HARD_REGNO_NREGS (regno, GET_MODE (real_out));
  1005.  
  1006.       /* When we consider whether the insn uses OUT,
  1007.      ignore references within IN.  They don't prevent us
  1008.      from copying IN into OUT, because those refs would
  1009.      move into the insn that reloads IN.
  1010.  
  1011.      However, we only ignore IN in its role as this reload.
  1012.      If the insn uses IN elsewhere and it contains OUT,
  1013.      that counts.  We can't be sure it's the "same" operand
  1014.      so it might not go through this reload.  */
  1015.       *inloc = const0_rtx;
  1016.  
  1017.       if (regno < FIRST_PSEUDO_REGISTER
  1018.       /* A fixed reg that can overlap other regs better not be used
  1019.          for reloading in any way.  */
  1020. #ifdef OVERLAPPING_REGNO_P
  1021.       && ! (fixed_regs[regno] && OVERLAPPING_REGNO_P (regno))
  1022. #endif
  1023.       && ! refers_to_regno_p (regno, regno + nwords,
  1024.                   PATTERN (this_insn), outloc))
  1025.     {
  1026.       int i;
  1027.       for (i = 0; i < nwords; i++)
  1028.         if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1029.                      regno + i))
  1030.           break;
  1031.  
  1032.       if (i == nwords)
  1033.         {
  1034.           if (GET_CODE (real_out) == REG)
  1035.         value = real_out;
  1036.           else
  1037.         value = gen_rtx (REG, GET_MODE (real_out), regno);
  1038.         }
  1039.     }
  1040.  
  1041.       *inloc = real_in;
  1042.     }
  1043.  
  1044.   /* Consider using IN if OUT was not acceptable
  1045.      or if OUT dies in this insn (like the quotient in a divmod insn).
  1046.      We can't use IN unless it is dies in this insn,
  1047.      which means we must know accurately which hard regs are live.
  1048.      Also, the result can't go in IN if IN is used within OUT.  */
  1049.   if (hard_regs_live_known
  1050.       && GET_CODE (in) == REG
  1051.       && REGNO (in) < FIRST_PSEUDO_REGISTER
  1052.       && (value == 0
  1053.       || find_reg_note (this_insn, REG_UNUSED, real_out))
  1054.       && find_reg_note (this_insn, REG_DEAD, real_in)
  1055.       && HARD_REGNO_MODE_OK (REGNO (in), GET_MODE (out)))
  1056.     {
  1057.       register int regno = REGNO (in) + in_offset;
  1058.       int nwords = HARD_REGNO_NREGS (regno, GET_MODE (real_in));
  1059.  
  1060.       if (! refers_to_regno_p (regno, regno + nwords, out, 0)
  1061.       && ! hard_reg_set_here_p (regno, regno + nwords,
  1062.                     PATTERN (this_insn)))
  1063.     {
  1064.       int i;
  1065.       for (i = 0; i < nwords; i++)
  1066.         if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  1067.                      regno + i))
  1068.           break;
  1069.  
  1070.       if (i == nwords)
  1071.         {
  1072.           /* If we were going to use OUT as the reload reg
  1073.          and changed our mind, it means OUT is a dummy that
  1074.          dies here.  So don't bother copying value to it.  */
  1075.           if (for_real >= 0 && value == real_out)
  1076.         reload_out[for_real] = 0;
  1077.           if (GET_CODE (real_in) == REG)
  1078.         value = real_in;
  1079.           else
  1080.         value = gen_rtx (REG, GET_MODE (real_in), regno);
  1081.         }
  1082.     }
  1083.     }
  1084.  
  1085.   return value;
  1086. }
  1087.  
  1088. /* This page contains subroutines used mainly for determining
  1089.    whether the IN or an OUT of a reload can serve as the
  1090.    reload register.  */
  1091.  
  1092. /* Return 1 if expression X alters a hard reg in the range
  1093.    from BEG_REGNO (inclusive) to END_REGNO (exclusive),
  1094.    either explicitly or in the guise of a pseudo-reg allocated to REGNO.
  1095.    X should be the body of an instruction.  */
  1096.  
  1097. static int
  1098. hard_reg_set_here_p (beg_regno, end_regno, x)
  1099.      register int beg_regno, end_regno;
  1100.      rtx x;
  1101. {
  1102.   if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
  1103.     {
  1104.       register rtx op0 = SET_DEST (x);
  1105.       while (GET_CODE (op0) == SUBREG)
  1106.     op0 = SUBREG_REG (op0);
  1107.       if (GET_CODE (op0) == REG)
  1108.     {
  1109.       register int r = REGNO (op0);
  1110.       /* See if this reg overlaps range under consideration.  */
  1111.       if (r < end_regno
  1112.           && r + HARD_REGNO_NREGS (r, GET_MODE (op0)) > beg_regno)
  1113.         return 1;
  1114.     }
  1115.     }
  1116.   else if (GET_CODE (x) == PARALLEL)
  1117.     {
  1118.       register int i = XVECLEN (x, 0) - 1;
  1119.       for (; i >= 0; i--)
  1120.     if (hard_reg_set_here_p (beg_regno, end_regno, XVECEXP (x, 0, i)))
  1121.       return 1;
  1122.     }
  1123.  
  1124.   return 0;
  1125. }
  1126.  
  1127. /* Return 1 if ADDR is a valid memory address for mode MODE,
  1128.    and check that each pseudo reg has the proper kind of
  1129.    hard reg.  */
  1130.  
  1131. int
  1132. strict_memory_address_p (mode, addr)
  1133.      enum machine_mode mode;
  1134.      register rtx addr;
  1135. {
  1136.   GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
  1137.   return 0;
  1138.  
  1139.  win:
  1140.   return 1;
  1141. }
  1142.  
  1143.  
  1144. /* Like rtx_equal_p except that it allows a REG and a SUBREG to match
  1145.    if they are the same hard reg, and has special hacks for
  1146.    autoincrement and autodecrement.
  1147.    This is specifically intended for find_reloads to use
  1148.    in determining whether two operands match.
  1149.    X is the operand whose number is the lower of the two.
  1150.  
  1151.    The value is 2 if Y contains a pre-increment that matches
  1152.    a non-incrementing address in X.  */
  1153.  
  1154. /* ??? To be completely correct, we should arrange to pass
  1155.    for X the output operand and for Y the input operand.
  1156.    For now, we assume that the output operand has the lower number
  1157.    because that is natural in (SET output (... input ...)).  */
  1158.  
  1159. int
  1160. operands_match_p (x, y)
  1161.      register rtx x, y;
  1162. {
  1163.   register int i;
  1164.   register RTX_CODE code = GET_CODE (x);
  1165.   register char *fmt;
  1166.   int success_2;
  1167.       
  1168.   if (x == y)
  1169.     return 1;
  1170.   if ((code == REG || (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG))
  1171.       && (GET_CODE (y) == REG || (GET_CODE (y) == SUBREG
  1172.                   && GET_CODE (SUBREG_REG (y)) == REG)))
  1173.     {
  1174.       register int j;
  1175.  
  1176.       if (code == SUBREG)
  1177.     {
  1178.       i = REGNO (SUBREG_REG (x));
  1179.       if (i >= FIRST_PSEUDO_REGISTER)
  1180.         goto slow;
  1181.       i += SUBREG_WORD (x);
  1182.     }
  1183.       else
  1184.     i = REGNO (x);
  1185.  
  1186.       if (GET_CODE (y) == SUBREG)
  1187.     {
  1188.       j = REGNO (SUBREG_REG (y));
  1189.       if (j >= FIRST_PSEUDO_REGISTER)
  1190.         goto slow;
  1191.       j += SUBREG_WORD (y);
  1192.     }
  1193.       else
  1194.     j = REGNO (y);
  1195.  
  1196.       return i == j;
  1197.     }
  1198.   /* If two operands must match, because they are really a single
  1199.      operand of an assembler insn, then two postincrements are invalid
  1200.      because the assembler insn would increment only once.
  1201.      On the other hand, an postincrement matches ordinary indexing
  1202.      if the postincrement is the output operand.  */
  1203.   if (code == POST_DEC || code == POST_INC)
  1204.     return operands_match_p (XEXP (x, 0), y);
  1205.   /* Two preincrements are invalid
  1206.      because the assembler insn would increment only once.
  1207.      On the other hand, an preincrement matches ordinary indexing
  1208.      if the preincrement is the input operand.
  1209.      In this case, return 2, since some callers need to do special
  1210.      things when this happens.  */
  1211.   if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC)
  1212.     return operands_match_p (x, XEXP (y, 0)) ? 2 : 0;
  1213.  
  1214.  slow:
  1215.  
  1216.   /* Now we have disposed of all the cases 
  1217.      in which different rtx codes can match.  */
  1218.   if (code != GET_CODE (y))
  1219.     return 0;
  1220.   if (code == LABEL_REF)
  1221.     return XEXP (x, 0) == XEXP (y, 0);
  1222.   if (code == SYMBOL_REF)
  1223.     return XSTR (x, 0) == XSTR (y, 0);
  1224.  
  1225.   /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.  */
  1226.  
  1227.   if (GET_MODE (x) != GET_MODE (y))
  1228.     return 0;
  1229.  
  1230.   /* Compare the elements.  If any pair of corresponding elements
  1231.      fail to match, return 0 for the whole things.  */
  1232.  
  1233.   success_2 = 0;
  1234.   fmt = GET_RTX_FORMAT (code);
  1235.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1236.     {
  1237.       int val;
  1238.       switch (fmt[i])
  1239.     {
  1240.     case 'i':
  1241.       if (XINT (x, i) != XINT (y, i))
  1242.         return 0;
  1243.       break;
  1244.  
  1245.     case 'e':
  1246.       val = operands_match_p (XEXP (x, i), XEXP (y, i));
  1247.       if (val == 0)
  1248.         return 0;
  1249.       /* If any subexpression returns 2,
  1250.          we should return 2 if we are successful.  */
  1251.       if (val == 2)
  1252.         success_2 = 1;
  1253.       break;
  1254.  
  1255.     case '0':
  1256.       break;
  1257.  
  1258.       /* It is believed that rtx's at this level will never
  1259.          contain anything but integers and other rtx's,
  1260.          except for within LABEL_REFs and SYMBOL_REFs.  */
  1261.     default:
  1262.       abort ();
  1263.     }
  1264.     }
  1265.   return 1 + success_2;
  1266. }
  1267.  
  1268. /* Return the number of times character C occurs in string S.  */
  1269.  
  1270. static int
  1271. n_occurrences (c, s)
  1272.      char c;
  1273.      char *s;
  1274. {
  1275.   int n = 0;
  1276.   while (*s)
  1277.     n += (*s++ == c);
  1278.   return n;
  1279. }
  1280.  
  1281. struct decomposition
  1282. {
  1283.   int reg_flag;
  1284.   int safe;
  1285.   rtx base;
  1286.   int start;
  1287.   int end;
  1288. };
  1289.  
  1290. /* Describe the range of registers or memory referenced by X.
  1291.    If X is a register, set REG_FLAG and put the first register 
  1292.    number into START and the last plus one into END.
  1293.    If X is a memory reference, put a base address into BASE 
  1294.    and a range of integer offsets into START and END.
  1295.    If X is pushing on the stack, we can assume it causes no trouble, 
  1296.    so we set the SAFE field.  */
  1297.  
  1298. static struct decomposition
  1299. decompose (x)
  1300.      rtx x;
  1301. {
  1302.   struct decomposition val;
  1303.   int all_const = 0;
  1304.  
  1305.   val.reg_flag = 0;
  1306.   val.safe = 0;
  1307.   if (GET_CODE (x) == MEM)
  1308.     {
  1309.       rtx base, offset = 0;
  1310.       rtx addr = XEXP (x, 0);
  1311.  
  1312.       if (GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == PRE_INC
  1313.       || GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC)
  1314.     {
  1315.       val.base = XEXP (addr, 0);
  1316.       val.start = - GET_MODE_SIZE (GET_MODE (x));
  1317.       val.end = GET_MODE_SIZE (GET_MODE (x));
  1318.       val.safe = REGNO (val.base) == STACK_POINTER_REGNUM;
  1319.       return val;
  1320.     }
  1321.  
  1322.       if (GET_CODE (addr) == CONST)
  1323.     {
  1324.       addr = XEXP (addr, 0);
  1325.       all_const = 1;
  1326.     }
  1327.       if (GET_CODE (addr) == PLUS)
  1328.     {
  1329.       if (CONSTANT_P (XEXP (addr, 0)))
  1330.         {
  1331.           base = XEXP (addr, 1);
  1332.           offset = XEXP (addr, 0);
  1333.         }
  1334.       else if (CONSTANT_P (XEXP (addr, 1)))
  1335.         {
  1336.           base = XEXP (addr, 0);
  1337.           offset = XEXP (addr, 1);
  1338.         }
  1339.     }
  1340.  
  1341.       if (offset == 0)
  1342.     {
  1343.       base = addr;
  1344.       offset = const0_rtx;
  1345.     } 
  1346.       if (GET_CODE (offset) == CONST)
  1347.     offset = XEXP (offset, 0);
  1348.       if (GET_CODE (offset) == PLUS)
  1349.     {
  1350.       if (GET_CODE (XEXP (offset, 0)) == CONST_INT)
  1351.         {
  1352.           base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 1));
  1353.           offset = XEXP (offset, 0);
  1354.         }
  1355.       else if (GET_CODE (XEXP (offset, 1)) == CONST_INT)
  1356.         {
  1357.           base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 0));
  1358.           offset = XEXP (offset, 1);
  1359.         }
  1360.       else
  1361.         {
  1362.           base = gen_rtx (PLUS, GET_MODE (base), base, offset);
  1363.           offset = const0_rtx;
  1364.         }
  1365.     }
  1366.       else if (GET_CODE (offset) != CONST_INT)
  1367.     {
  1368.       base = gen_rtx (PLUS, GET_MODE (base), base, offset);
  1369.       offset = const0_rtx;
  1370.     }
  1371.  
  1372.       if (all_const && GET_CODE (base) == PLUS)
  1373.     base = gen_rtx (CONST, GET_MODE (base), base);
  1374.  
  1375.       if (GET_CODE (offset) != CONST_INT)
  1376.     abort ();
  1377.  
  1378.       val.start = INTVAL (offset);
  1379.       val.end = val.start + GET_MODE_SIZE (GET_MODE (x));
  1380.       val.base = base;
  1381.       return val;
  1382.     }
  1383.   else if (GET_CODE (x) == REG)
  1384.     {
  1385.       val.reg_flag = 1;
  1386.       val.start = true_regnum (x); 
  1387.       if (val.start < 0)
  1388.     {
  1389.       /* A pseudo with no hard reg.  */
  1390.       val.start = REGNO (x);
  1391.       val.end = val.start + 1;
  1392.     }
  1393.       else
  1394.     /* A hard reg.  */
  1395.     val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x));
  1396.     }
  1397.   else if (GET_CODE (x) == SUBREG)
  1398.     {
  1399.       if (GET_CODE (SUBREG_REG (x)) != REG)
  1400.     /* This could be more precise, but it's good enough.  */
  1401.     return decompose (SUBREG_REG (x));
  1402.       val.reg_flag = 1;
  1403.       val.start = true_regnum (x); 
  1404.       if (val.start < 0)
  1405.     return decompose (SUBREG_REG (x));
  1406.       else
  1407.     /* A hard reg.  */
  1408.     val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x));
  1409.     }
  1410.   else if (GET_CODE (x) == SCRATCH)
  1411.     /* This hasn't been assigned yet, so it can't conflict yet.  */
  1412.     val.safe = 1;
  1413.   else
  1414.     abort ();
  1415.   return val;
  1416. }
  1417.  
  1418. /* Return 1 if altering Y will not modify the value of X.
  1419.    Y is also described by YDATA, which should be decompose (Y).  */
  1420.  
  1421. static int
  1422. immune_p (x, y, ydata)
  1423.      rtx x, y;
  1424.      struct decomposition ydata;
  1425. {
  1426.   struct decomposition xdata;
  1427.  
  1428.   if (ydata.reg_flag)
  1429.     return !refers_to_regno_p (ydata.start, ydata.end, x, 0);
  1430.   if (ydata.safe)
  1431.     return 1;
  1432.  
  1433.   if (GET_CODE (y) != MEM)
  1434.     abort ();
  1435.   /* If Y is memory and X is not, Y can't affect X.  */
  1436.   if (GET_CODE (x) != MEM)
  1437.     return 1;
  1438.  
  1439.   xdata =  decompose (x);
  1440.  
  1441.   if (! rtx_equal_p (xdata.base, ydata.base))
  1442.     {
  1443.       /* If bases are distinct symbolic constants, there is no overlap.  */
  1444.       if (CONSTANT_P (xdata.base) && CONSTANT_P (ydata.base))
  1445.     return 1;
  1446.       /* Constants and stack slots never overlap.  */
  1447.       if (CONSTANT_P (xdata.base)
  1448.       && (ydata.base == frame_pointer_rtx
  1449.           || ydata.base == stack_pointer_rtx))
  1450.     return 1;
  1451.       if (CONSTANT_P (ydata.base)
  1452.       && (xdata.base == frame_pointer_rtx
  1453.           || xdata.base == stack_pointer_rtx))
  1454.     return 1;
  1455.       /* If either base is variable, we don't know anything.  */
  1456.       return 0;
  1457.     }
  1458.  
  1459.  
  1460.   return (xdata.start >= ydata.end || ydata.start >= xdata.end);
  1461. }
  1462.  
  1463. /* Main entry point of this file: search the body of INSN
  1464.    for values that need reloading and record them with push_reload.
  1465.    REPLACE nonzero means record also where the values occur
  1466.    so that subst_reloads can be used.
  1467.  
  1468.    IND_LEVELS says how many levels of indirection are supported by this
  1469.    machine; a value of zero means that a memory reference is not a valid
  1470.    memory address.
  1471.  
  1472.    LIVE_KNOWN says we have valid information about which hard
  1473.    regs are live at each point in the program; this is true when
  1474.    we are called from global_alloc but false when stupid register
  1475.    allocation has been done.
  1476.  
  1477.    RELOAD_REG_P if nonzero is a vector indexed by hard reg number
  1478.    which is nonnegative if the reg has been commandeered for reloading into.
  1479.    It is copied into STATIC_RELOAD_REG_P and referenced from there
  1480.    by various subroutines.  */
  1481.  
  1482. void
  1483. find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
  1484.      rtx insn;
  1485.      int replace, ind_levels;
  1486.      int live_known;
  1487.      short *reload_reg_p;
  1488. {
  1489.   rtx non_reloaded_operands[MAX_RECOG_OPERANDS];
  1490.   int n_non_reloaded_operands = 0;
  1491. #ifdef REGISTER_CONSTRAINTS
  1492.  
  1493.   enum reload_modified { RELOAD_NOTHING, RELOAD_READ, RELOAD_READ_WRITE, RELOAD_WRITE };
  1494.  
  1495.   register int insn_code_number;
  1496.   register int i;
  1497.   int noperands;
  1498.   /* These are the constraints for the insn.  We don't change them.  */
  1499.   char *constraints1[MAX_RECOG_OPERANDS];
  1500.   /* These start out as the constraints for the insn
  1501.      and they are chewed up as we consider alternatives.  */
  1502.   char *constraints[MAX_RECOG_OPERANDS];
  1503.   /* These are the preferred classes for an operand, or NO_REGS if it isn't
  1504.      a register.  */
  1505.   enum reg_class preferred_class[MAX_RECOG_OPERANDS];
  1506.   char pref_or_nothing[MAX_RECOG_OPERANDS];
  1507.   /* Nonzero for a MEM operand whose entire address needs a reload.  */
  1508.   int address_reloaded[MAX_RECOG_OPERANDS];
  1509.   int no_input_reloads = 0, no_output_reloads = 0;
  1510.   int n_alternatives;
  1511.   int this_alternative[MAX_RECOG_OPERANDS];
  1512.   char this_alternative_win[MAX_RECOG_OPERANDS];
  1513.   char this_alternative_offmemok[MAX_RECOG_OPERANDS];
  1514.   char this_alternative_earlyclobber[MAX_RECOG_OPERANDS];
  1515.   int this_alternative_matches[MAX_RECOG_OPERANDS];
  1516.   int swapped;
  1517.   int goal_alternative[MAX_RECOG_OPERANDS];
  1518.   int this_alternative_number;
  1519.   int goal_alternative_number;
  1520.   int operand_reloadnum[MAX_RECOG_OPERANDS];
  1521.   int goal_alternative_matches[MAX_RECOG_OPERANDS];
  1522.   int goal_alternative_matched[MAX_RECOG_OPERANDS];
  1523.   char goal_alternative_win[MAX_RECOG_OPERANDS];
  1524.   char goal_alternative_offmemok[MAX_RECOG_OPERANDS];
  1525.   char goal_alternative_earlyclobber[MAX_RECOG_OPERANDS];
  1526.   int goal_alternative_swapped;
  1527.   enum reload_modified modified[MAX_RECOG_OPERANDS];
  1528.   int best;
  1529.   int commutative;
  1530.   char operands_match[MAX_RECOG_OPERANDS][MAX_RECOG_OPERANDS];
  1531.   rtx substed_operand[MAX_RECOG_OPERANDS];
  1532.   rtx body = PATTERN (insn);
  1533.   rtx set = single_set (insn);
  1534.   int goal_earlyclobber, this_earlyclobber;
  1535.   enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
  1536.  
  1537.   this_insn = insn;
  1538.   this_insn_is_asm = 0;        /* Tentative.  */
  1539.   n_reloads = 0;
  1540.   n_replacements = 0;
  1541.   n_memlocs = 0;
  1542.   n_earlyclobbers = 0;
  1543.   replace_reloads = replace;
  1544.   hard_regs_live_known = live_known;
  1545.   static_reload_reg_p = reload_reg_p;
  1546.  
  1547.   /* JUMP_INSNs are not allowed to have any output reloads; neither are
  1548.      insns that SET cc0.  Insns that use CC0 are not allowed to have any
  1549.      input reloads.  */
  1550.   if (GET_CODE (insn) == JUMP_INSN)
  1551.     no_output_reloads = 1;
  1552.  
  1553. #ifdef HAVE_cc0
  1554.   if (reg_referenced_p (cc0_rtx, PATTERN (insn)))
  1555.     no_input_reloads = 1;
  1556.   if (reg_set_p (cc0_rtx, PATTERN (insn)))
  1557.     no_output_reloads = 1;
  1558. #endif
  1559.      
  1560.   /* Find what kind of insn this is.  NOPERANDS gets number of operands.
  1561.      Make OPERANDS point to a vector of operand values.
  1562.      Make OPERAND_LOCS point to a vector of pointers to
  1563.      where the operands were found.
  1564.      Fill CONSTRAINTS and CONSTRAINTS1 with pointers to the
  1565.      constraint-strings for this insn.
  1566.      Return if the insn needs no reload processing.  */
  1567.  
  1568.   switch (GET_CODE (body))
  1569.     {
  1570.     case USE:
  1571.     case CLOBBER:
  1572.     case ASM_INPUT:
  1573.     case ADDR_VEC:
  1574.     case ADDR_DIFF_VEC:
  1575.       return;
  1576.  
  1577.     case SET:
  1578.       /* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
  1579.      is cheap to move between them.  If it is not, there may not be an insn
  1580.      to do the copy, so we may need a reload.  */
  1581.       if (GET_CODE (SET_DEST (body)) == REG
  1582.       && REGNO (SET_DEST (body)) < FIRST_PSEUDO_REGISTER
  1583.       && GET_CODE (SET_SRC (body)) == REG
  1584.       && REGNO (SET_SRC (body)) < FIRST_PSEUDO_REGISTER
  1585.       && REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (SET_SRC (body))),
  1586.                  REGNO_REG_CLASS (REGNO (SET_DEST (body)))) == 2)
  1587.     return;
  1588.     case PARALLEL:
  1589.     case ASM_OPERANDS:
  1590.       noperands = asm_noperands (body);
  1591.       if (noperands >= 0)
  1592.     {
  1593.       /* This insn is an `asm' with operands.  */
  1594.  
  1595.       insn_code_number = -1;
  1596.       this_insn_is_asm = 1;
  1597.  
  1598.       /* expand_asm_operands makes sure there aren't too many operands.  */
  1599.       if (noperands > MAX_RECOG_OPERANDS)
  1600.         abort ();
  1601.  
  1602.       /* Now get the operand values and constraints out of the insn.  */
  1603.  
  1604.       decode_asm_operands (body, recog_operand, recog_operand_loc,
  1605.                    constraints, operand_mode);
  1606.       if (noperands > 0)
  1607.         {
  1608.           bcopy (constraints, constraints1, noperands * sizeof (char *));
  1609.           n_alternatives = n_occurrences (',', constraints[0]) + 1;
  1610.           for (i = 1; i < noperands; i++)
  1611.         if (n_alternatives != n_occurrences (',', constraints[0]) + 1)
  1612.           {
  1613.             error_for_asm (insn, "operand constraints differ in number of alternatives");
  1614.             /* Avoid further trouble with this insn.  */
  1615.             PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  1616.             n_reloads = 0;
  1617.             return;
  1618.           }
  1619.         }
  1620.       break;
  1621.     }
  1622.  
  1623.     default:
  1624.       /* Ordinary insn: recognize it, get the operands via insn_extract
  1625.      and get the constraints.  */
  1626.  
  1627.       insn_code_number = recog_memoized (insn);
  1628.       noperands = insn_n_operands[insn_code_number];
  1629.       n_alternatives = insn_n_alternatives[insn_code_number];
  1630.       /* Just return "no reloads" if insn has no operands with constraints.  */
  1631.       if (n_alternatives == 0)
  1632.     return;
  1633.       insn_extract (insn);
  1634.       for (i = 0; i < noperands; i++)
  1635.     {
  1636.       constraints[i] = constraints1[i]
  1637.         = insn_operand_constraint[insn_code_number][i];
  1638.       operand_mode[i] = insn_operand_mode[insn_code_number][i];
  1639.     }
  1640.     }
  1641.  
  1642.   if (noperands == 0)
  1643.     return;
  1644.  
  1645.   commutative = -1;
  1646.  
  1647.   /* If we will need to know, later, whether some pair of operands
  1648.      are the same, we must compare them now and save the result.
  1649.      Reloading the base and index registers will clobber them
  1650.      and afterward they will fail to match.  */
  1651.  
  1652.   for (i = 0; i < noperands; i++)
  1653.     {
  1654.       register char *p;
  1655.       register int c;
  1656.  
  1657.       substed_operand[i] = recog_operand[i];
  1658.       p = constraints[i];
  1659.  
  1660.       /* Scan this operand's constraint to see if it should match another.  */
  1661.  
  1662.       while (c = *p++)
  1663.     if (c == '%')
  1664.       {
  1665.         /* The last operand should not be marked commutative.  This
  1666.            problem is hard to detect, so make it obvious by calling
  1667.            abort here.  */
  1668.         if (i == noperands - 1)
  1669.           abort ();
  1670.  
  1671.         commutative = i;
  1672.       }
  1673.     else if (c >= '0' && c <= '9')
  1674.       {
  1675.         c -= '0';
  1676.         operands_match[c][i]
  1677.           = operands_match_p (recog_operand[c], recog_operand[i]);
  1678.         /* If C can be commuted with C+1, and C might need to match I,
  1679.            then C+1 might also need to match I.  */
  1680.         if (commutative >= 0)
  1681.           {
  1682.         if (c == commutative || c == commutative + 1)
  1683.           {
  1684.             int other = c + (c == commutative ? 1 : -1);
  1685.             operands_match[other][i]
  1686.               = operands_match_p (recog_operand[other], recog_operand[i]);
  1687.           }
  1688.         if (i == commutative || i == commutative + 1)
  1689.           {
  1690.             int other = i + (i == commutative ? 1 : -1);
  1691.             operands_match[c][other]
  1692.               = operands_match_p (recog_operand[c], recog_operand[other]);
  1693.           }
  1694.         /* Note that C is supposed to be less than I.
  1695.            No need to consider altering both C and I
  1696.            because in that case we would alter one into the other.  */
  1697.           }
  1698.       }
  1699.     }
  1700.  
  1701.   /* Examine each operand that is a memory reference or memory address
  1702.      and reload parts of the addresses into index registers.
  1703.      While we are at it, initialize the array `modified'.
  1704.      Also here any references to pseudo regs that didn't get hard regs
  1705.      but are equivalent to constants get replaced in the insn itself
  1706.      with those constants.  Nobody will ever see them again. 
  1707.  
  1708.      Finally, set up the preferred classes of each operand.  */
  1709.  
  1710.   for (i = 0; i < noperands; i++)
  1711.     {
  1712.       register RTX_CODE code = GET_CODE (recog_operand[i]);
  1713.       modified[i] = RELOAD_READ;
  1714.       address_reloaded[i] = 0;
  1715. #ifndef NeXT
  1716.       preferred_class[i]
  1717.     = ((code == REG && REGNO (recog_operand[i]) > FIRST_PSEUDO_REGISTER)
  1718.        ? reg_preferred_class (REGNO (recog_operand[i])) : NO_REGS);
  1719.       pref_or_nothing[i]
  1720.     = (code == REG && REGNO (recog_operand[i]) > FIRST_PSEUDO_REGISTER
  1721.        && reg_preferred_or_nothing (REGNO (recog_operand[i])));
  1722. #endif /* not NeXT */
  1723.  
  1724.       if (constraints[i][0] == 'p')
  1725.     {
  1726.       find_reloads_address (VOIDmode, 0,
  1727.                 recog_operand[i], recog_operand_loc[i],
  1728.                 recog_operand[i], ind_levels);
  1729.       substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  1730.     }
  1731.       else if (code == MEM)
  1732.     {
  1733.       if (find_reloads_address (GET_MODE (recog_operand[i]),
  1734.                     recog_operand_loc[i],
  1735.                     XEXP (recog_operand[i], 0),
  1736.                     &XEXP (recog_operand[i], 0),
  1737.                     recog_operand[i], ind_levels))
  1738.         address_reloaded[i] = 1;
  1739.       substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  1740.     }
  1741.       else if (code == SUBREG)
  1742.     substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]
  1743.       = find_reloads_toplev (recog_operand[i], ind_levels);
  1744.       else if (code == REG)
  1745.     {
  1746.       /* This is equivalent to calling find_reloads_toplev.
  1747.          The code is duplicated for speed.  */
  1748.       register int regno = REGNO (recog_operand[i]);
  1749.       if (reg_equiv_constant[regno] != 0)
  1750.         substed_operand[i] = recog_operand[i]
  1751.           = reg_equiv_constant[regno];
  1752. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  1753.      that feeds this insn.  */
  1754.       if (reg_equiv_mem[regno] != 0)
  1755.         substed_operand[i] = recog_operand[i]
  1756.           = reg_equiv_mem[regno];
  1757. #endif
  1758.       if (reg_equiv_address[regno] != 0)
  1759.         {
  1760.           /* If reg_equiv_address is not a constant address, copy it,
  1761.          since it may be shared.  */
  1762.           rtx address = reg_equiv_address[regno];
  1763.  
  1764.           if (rtx_varies_p (address))
  1765.         address = copy_rtx (address);
  1766.  
  1767.           /* If this is an output operand, we must output a CLOBBER
  1768.          after INSN so find_equiv_reg knows REGNO is being written. */
  1769.           if (constraints[i][0] == '='
  1770.           || constraints[i][0] == '+')
  1771.         emit_insn_after (gen_rtx (CLOBBER, VOIDmode, recog_operand[i]),
  1772.                  insn);
  1773.  
  1774.           *recog_operand_loc[i] = recog_operand[i]
  1775.         = gen_rtx (MEM, GET_MODE (recog_operand[i]), address);
  1776.           RTX_UNCHANGING_P (recog_operand[i])
  1777.         = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  1778.           find_reloads_address (GET_MODE (recog_operand[i]),
  1779.                     recog_operand_loc[i],
  1780.                     XEXP (recog_operand[i], 0),
  1781.                     &XEXP (recog_operand[i], 0),
  1782.                     recog_operand[i], ind_levels);
  1783.           substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
  1784.         }
  1785.     }
  1786. #ifdef NeXT
  1787.       /* If the operand is still a register (we didn't replace it with an
  1788.      equivalent), get the preferred class to reload it into.  */
  1789.       code = GET_CODE (recog_operand[i]);
  1790.       preferred_class[i]
  1791.     = ((code == REG && REGNO (recog_operand[i]) > FIRST_PSEUDO_REGISTER)
  1792.        ? reg_preferred_class (REGNO (recog_operand[i])) : NO_REGS);
  1793.       pref_or_nothing[i]
  1794.     = (code == REG && REGNO (recog_operand[i]) > FIRST_PSEUDO_REGISTER
  1795.        && reg_preferred_or_nothing (REGNO (recog_operand[i])));
  1796. #endif /* NeXT */
  1797.     }
  1798.  
  1799.   /* If this is simply a copy from operand 1 to operand 0, merge the
  1800.      preferred classes for the operands.  */
  1801.   if (set != 0 && noperands >= 2 && recog_operand[0] == SET_DEST (set)
  1802.       && recog_operand[1] == SET_SRC (set))
  1803.     {
  1804.       preferred_class[0] = preferred_class[1]
  1805.     = reg_class_subunion[(int) preferred_class[0]][(int) preferred_class[1]];
  1806.       pref_or_nothing[0] |= pref_or_nothing[1];
  1807.       pref_or_nothing[1] |= pref_or_nothing[0];
  1808.     }
  1809.  
  1810.   /* Now see what we need for pseudo-regs that didn't get hard regs
  1811.      or got the wrong kind of hard reg.  For this, we must consider
  1812.      all the operands together against the register constraints.  */
  1813.  
  1814.   best = MAX_RECOG_OPERANDS + 300;
  1815.  
  1816.   swapped = 0;
  1817.   goal_alternative_swapped = 0;
  1818.  try_swapped:
  1819.  
  1820.   /* The constraints are made of several alternatives.
  1821.      Each operand's constraint looks like foo,bar,... with commas
  1822.      separating the alternatives.  The first alternatives for all
  1823.      operands go together, the second alternatives go together, etc.
  1824.  
  1825.      First loop over alternatives.  */
  1826.  
  1827.   for (this_alternative_number = 0;
  1828.        this_alternative_number < n_alternatives;
  1829.        this_alternative_number++)
  1830.     {
  1831.       /* Loop over operands for one constraint alternative.  */
  1832.       /* LOSERS counts those that don't fit this alternative
  1833.      and would require loading.  */
  1834.       int losers = 0;
  1835.       /* BAD is set to 1 if it some operand can't fit this alternative
  1836.      even after reloading.  */
  1837.       int bad = 0;
  1838.       /* REJECT is a count of how undesirable this alternative says it is
  1839.      if any reloading is required.  If the alternative matches exactly
  1840.      then REJECT is ignored, but otherwise it gets this much
  1841.      counted against it in addition to the reloading needed.  Each 
  1842.      ? counts three times here since we want the disparaging caused by
  1843.      a bad register class to only count 1/3 as much.  */
  1844.       int reject = 0;
  1845.  
  1846.       this_earlyclobber = 0;
  1847.  
  1848.       for (i = 0; i < noperands; i++)
  1849.     {
  1850.       register char *p = constraints[i];
  1851.       register int win = 0;
  1852.       /* 0 => this operand can be reloaded somehow for this alternative */
  1853.       int badop = 1;
  1854.       /* 0 => this operand can be reloaded if the alternative allows regs.  */
  1855.       int winreg = 0;
  1856.       int c;
  1857.       register rtx operand = recog_operand[i];
  1858.       int offset = 0;
  1859.       /* Nonzero means this is a MEM that must be reloaded into a reg
  1860.          regardless of what the constraint says.  */
  1861.       int force_reload = 0;
  1862.       int offmemok = 0;
  1863.       int earlyclobber = 0;
  1864.  
  1865.       /* If the operand is a SUBREG, extract
  1866.          the REG or MEM (or maybe even a constant) within.
  1867.          (Constants can occur as a result of reg_equiv_constant.)  */
  1868.  
  1869.       while (GET_CODE (operand) == SUBREG)
  1870.         {
  1871.           offset += SUBREG_WORD (operand);
  1872.           operand = SUBREG_REG (operand);
  1873.           /* Force reload if this is not a register or if there may may
  1874.          be a problem accessing the register in the outer mode.  */
  1875.           if (GET_CODE (operand) != REG
  1876.           || (REGNO (operand) < FIRST_PSEUDO_REGISTER
  1877.               && (! HARD_REGNO_MODE_OK (REGNO (operand),
  1878.                         operand_mode[i])
  1879.               || (GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
  1880.                   && (GET_MODE_SIZE (GET_MODE (operand))
  1881.                   > UNITS_PER_WORD)
  1882.                   && ((GET_MODE_SIZE (GET_MODE (operand))
  1883.                    / UNITS_PER_WORD)
  1884.                   != HARD_REGNO_NREGS (REGNO (operand),
  1885.                                GET_MODE (operand)))))))
  1886.         force_reload = 1;
  1887.         }
  1888.  
  1889.       this_alternative[i] = (int) NO_REGS;
  1890.       this_alternative_win[i] = 0;
  1891.       this_alternative_offmemok[i] = 0;
  1892.       this_alternative_earlyclobber[i] = 0;
  1893.       this_alternative_matches[i] = -1;
  1894.  
  1895.       /* An empty constraint or empty alternative
  1896.          allows anything which matched the pattern.  */
  1897.       if (*p == 0 || *p == ',')
  1898.         win = 1, badop = 0;
  1899.  
  1900.       /* Scan this alternative's specs for this operand;
  1901.          set WIN if the operand fits any letter in this alternative.
  1902.          Otherwise, clear BADOP if this operand could
  1903.          fit some letter after reloads,
  1904.          or set WINREG if this operand could fit after reloads
  1905.          provided the constraint allows some registers.  */
  1906.  
  1907.       while (*p && (c = *p++) != ',')
  1908.         switch (c)
  1909.           {
  1910.           case '=':
  1911.         modified[i] = RELOAD_WRITE;
  1912.         break;
  1913.  
  1914.           case '+':
  1915.         modified[i] = RELOAD_READ_WRITE;
  1916.         break;
  1917.  
  1918.           case '*':
  1919.         break;
  1920.  
  1921.           case '%':
  1922.         commutative = i;
  1923.         break;
  1924.  
  1925.           case '?':
  1926.         reject += 3;
  1927.         break;
  1928.  
  1929.           case '!':
  1930.         reject = 300;
  1931.         break;
  1932.  
  1933.           case '#':
  1934.         /* Ignore rest of this alternative as far as
  1935.            reloading is concerned.  */
  1936.         while (*p && *p != ',') p++;
  1937.         break;
  1938.  
  1939.           case '0':
  1940.           case '1':
  1941.           case '2':
  1942.           case '3':
  1943.           case '4':
  1944.         c -= '0';
  1945.         this_alternative_matches[i] = c;
  1946.         /* We are supposed to match a previous operand.
  1947.            If we do, we win if that one did.
  1948.            If we do not, count both of the operands as losers.
  1949.            (This is too conservative, since most of the time
  1950.            only a single reload insn will be needed to make
  1951.            the two operands win.  As a result, this alternative
  1952.            may be rejected when it is actually desirable.)  */
  1953.         if ((swapped && (c != commutative || i != commutative + 1))
  1954.             /* If we are matching as if two operands were swapped,
  1955.                also pretend that operands_match had been computed
  1956.                with swapped.
  1957.                But if I is the second of those and C is the first,
  1958.                don't exchange them, because operands_match is valid
  1959.                only on one side of its diagonal.  */
  1960.             ? (operands_match
  1961.                 [(c == commutative || c == commutative + 1)
  1962.              ? 2*commutative + 1 - c : c]
  1963.                 [(i == commutative || i == commutative + 1)
  1964.              ? 2*commutative + 1 - i : i])
  1965.             : operands_match[c][i])
  1966.           win = this_alternative_win[c];
  1967.         else
  1968.           {
  1969.             /* Operands don't match.  */
  1970.             rtx value;
  1971.             /* Retroactively mark the operand we had to match
  1972.                as a loser, if it wasn't already.  */
  1973.             if (this_alternative_win[c])
  1974.               losers++;
  1975.             this_alternative_win[c] = 0;
  1976.             if (this_alternative[c] == (int) NO_REGS)
  1977.               bad = 1;
  1978.             /* But count the pair only once in the total badness of
  1979.                this alternative, if the pair can be a dummy reload.  */
  1980.             value
  1981.               = find_dummy_reload (recog_operand[i], recog_operand[c],
  1982.                        recog_operand_loc[i], recog_operand_loc[c],
  1983.                        this_alternative[c], -1);
  1984.  
  1985.             if (value != 0)
  1986.               losers--;
  1987.           }
  1988.         /* This can be fixed with reloads if the operand
  1989.            we are supposed to match can be fixed with reloads.  */
  1990.         badop = 0;
  1991.         this_alternative[i] = this_alternative[c];
  1992.         break;
  1993.  
  1994.           case 'p':
  1995.         /* All necessary reloads for an address_operand
  1996.            were handled in find_reloads_address.  */
  1997.         this_alternative[i] = (int) ALL_REGS;
  1998.         win = 1;
  1999.         break;
  2000.  
  2001.           case 'm':
  2002.         if (force_reload)
  2003.           break;
  2004.         if (GET_CODE (operand) == MEM
  2005.             || (GET_CODE (operand) == REG
  2006.             && REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2007.             && reg_renumber[REGNO (operand)] < 0))
  2008.           win = 1;
  2009.         if (CONSTANT_P (operand))
  2010.           badop = 0;
  2011.         break;
  2012.  
  2013.           case '<':
  2014.         if (GET_CODE (operand) == MEM
  2015.             && ! address_reloaded[i]
  2016.             && (GET_CODE (XEXP (operand, 0)) == PRE_DEC
  2017.             || GET_CODE (XEXP (operand, 0)) == POST_DEC))
  2018.           win = 1;
  2019.         break;
  2020.  
  2021.           case '>':
  2022.         if (GET_CODE (operand) == MEM
  2023.             && ! address_reloaded[i]
  2024.             && (GET_CODE (XEXP (operand, 0)) == PRE_INC
  2025.             || GET_CODE (XEXP (operand, 0)) == POST_INC))
  2026.           win = 1;
  2027.         break;
  2028.  
  2029.         /* Memory operand whose address is not offsettable.  */
  2030.           case 'V':
  2031.         if (force_reload)
  2032.           break;
  2033.         if (GET_CODE (operand) == MEM
  2034.             && ! (ind_levels ? offsettable_memref_p (operand)
  2035.               : offsettable_nonstrict_memref_p (operand))
  2036.             /* Certain mem addresses will become offsettable
  2037.                after they themselves are reloaded.  This is important;
  2038.                we don't want our own handling of unoffsettables
  2039.                to override the handling of reg_equiv_address.  */
  2040.             && !(GET_CODE (XEXP (operand, 0)) == REG
  2041.              && (ind_levels == 0
  2042.                  || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0)))
  2043.           win = 1;
  2044.         break;
  2045.  
  2046.         /* Memory operand whose address is offsettable.  */
  2047.           case 'o':
  2048.         if (force_reload)
  2049.           break;
  2050.         if ((GET_CODE (operand) == MEM
  2051.              /* If IND_LEVELS, find_reloads_address won't reload a
  2052.             pseudo that didn't get a hard reg, so we have to
  2053.             reject that case.  */
  2054.              && (ind_levels ? offsettable_memref_p (operand)
  2055.              : offsettable_nonstrict_memref_p (operand)))
  2056.             /* Certain mem addresses will become offsettable
  2057.                after they themselves are reloaded.  This is important;
  2058.                we don't want our own handling of unoffsettables
  2059.                to override the handling of reg_equiv_address.  */
  2060.             || (GET_CODE (operand) == MEM
  2061.             && GET_CODE (XEXP (operand, 0)) == REG
  2062.             && (ind_levels == 0
  2063.                 || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0))
  2064.             || (GET_CODE (operand) == REG
  2065.             && REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2066.             && reg_renumber[REGNO (operand)] < 0))
  2067.           win = 1;
  2068.         if (CONSTANT_P (operand) || GET_CODE (operand) == MEM)
  2069.           badop = 0;
  2070.         offmemok = 1;
  2071.         break;
  2072.  
  2073.           case '&':
  2074.         /* Output operand that is stored before the need for the
  2075.            input operands (and their index registers) is over.  */
  2076.         earlyclobber = 1, this_earlyclobber = 1;
  2077.         break;
  2078.  
  2079.           case 'E':
  2080.         /* Match any floating double constant, but only if
  2081.            we can examine the bits of it reliably.  */
  2082.         if ((HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  2083.              || HOST_BITS_PER_INT != BITS_PER_WORD)
  2084.             && GET_MODE (operand) != VOIDmode && ! flag_pretend_float)
  2085.           break;
  2086.         if (GET_CODE (operand) == CONST_DOUBLE)
  2087.           win = 1;
  2088.         break;
  2089.  
  2090.           case 'F':
  2091.         if (GET_CODE (operand) == CONST_DOUBLE)
  2092.           win = 1;
  2093.         break;
  2094.  
  2095.           case 'G':
  2096.           case 'H':
  2097.         if (GET_CODE (operand) == CONST_DOUBLE
  2098.             && CONST_DOUBLE_OK_FOR_LETTER_P (operand, c))
  2099.           win = 1;
  2100.         break;
  2101.  
  2102.           case 's':
  2103.         if (GET_CODE (operand) == CONST_INT
  2104.             || (GET_CODE (operand) == CONST_DOUBLE
  2105.             && GET_MODE (operand) == VOIDmode))
  2106.           break;
  2107.           case 'i':
  2108.         if (CONSTANT_P (operand))
  2109.           win = 1;
  2110.         break;
  2111.  
  2112.           case 'n':
  2113.         if (GET_CODE (operand) == CONST_INT
  2114.             || (GET_CODE (operand) == CONST_DOUBLE
  2115.             && GET_MODE (operand) == VOIDmode))
  2116.           win = 1;
  2117.         break;
  2118.  
  2119.           case 'I':
  2120.           case 'J':
  2121.           case 'K':
  2122.           case 'L':
  2123.           case 'M':
  2124.           case 'N':
  2125.           case 'O':
  2126.           case 'P':
  2127.         if (GET_CODE (operand) == CONST_INT
  2128.             && CONST_OK_FOR_LETTER_P (INTVAL (operand), c))
  2129.           win = 1;
  2130.         break;
  2131.  
  2132.           case 'X':
  2133.         win = 1;
  2134.         break;
  2135.  
  2136.           case 'g':
  2137.         if (! force_reload
  2138.             /* A PLUS is never a valid operand, but reload can make
  2139.                it from a register when eliminating registers.  */
  2140.             && GET_CODE (operand) != PLUS
  2141.             /* A SCRATCH is not a valid operand.  */
  2142.             && GET_CODE (operand) != SCRATCH
  2143.             && (GENERAL_REGS == ALL_REGS
  2144.             || GET_CODE (operand) != REG
  2145.             || (REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2146.                 && reg_renumber[REGNO (operand)] < 0)))
  2147.           win = 1;
  2148.         /* Drop through into 'r' case */
  2149.  
  2150.           case 'r':
  2151.         this_alternative[i]
  2152.           = (int) reg_class_subunion[this_alternative[i]][(int) GENERAL_REGS];
  2153.         goto reg;
  2154.  
  2155. #ifdef EXTRA_CONSTRAINT
  2156.               case 'Q':
  2157.               case 'R':
  2158.               case 'S':
  2159.               case 'T':
  2160.               case 'U':
  2161.         if (EXTRA_CONSTRAINT (operand, c))
  2162.           win = 1;
  2163.         break;
  2164. #endif
  2165.   
  2166.           default:
  2167.         this_alternative[i]
  2168.           = (int) reg_class_subunion[this_alternative[i]][(int) REG_CLASS_FROM_LETTER (c)];
  2169.         
  2170.           reg:
  2171.         if (GET_MODE (operand) == BLKmode)
  2172.           break;
  2173.         winreg = 1;
  2174.         if (GET_CODE (operand) == REG
  2175.             && reg_fits_class_p (operand, this_alternative[i],
  2176.                      offset, GET_MODE (recog_operand[i])))
  2177.           win = 1;
  2178.         break;
  2179.           }
  2180.  
  2181.       constraints[i] = p;
  2182.  
  2183.       /* If this operand could be handled with a reg,
  2184.          and some reg is allowed, then this operand can be handled.  */
  2185.       if (winreg && this_alternative[i] != (int) NO_REGS)
  2186.         badop = 0;
  2187.  
  2188.       /* Record which operands fit this alternative.  */
  2189.       this_alternative_earlyclobber[i] = earlyclobber;
  2190.       if (win && ! force_reload)
  2191.         this_alternative_win[i] = 1;
  2192.       else
  2193.         {
  2194.           this_alternative_offmemok[i] = offmemok;
  2195.           losers++;
  2196.           if (badop)
  2197.         bad = 1;
  2198.           /* Alternative loses if it has no regs for a reg operand.  */
  2199.           if (GET_CODE (operand) == REG
  2200.           && this_alternative[i] == (int) NO_REGS
  2201.           && this_alternative_matches[i] < 0)
  2202.         bad = 1;
  2203.  
  2204.           /* Alternative loses if it requires a type of reload not
  2205.          permitted for this insn.  We can always reload SCRATCH
  2206.          and objects with a REG_UNUSED note.  */
  2207.           if (GET_CODE (operand) != SCRATCH && modified[i] != RELOAD_READ
  2208.           && no_output_reloads
  2209.           && ! find_reg_note (insn, REG_UNUSED, operand))
  2210.         bad = 1;
  2211.           else if (modified[i] != RELOAD_WRITE && no_input_reloads)
  2212.         bad = 1;
  2213.  
  2214.           /* We prefer to reload pseudos over reloading other things,
  2215.          since such reloads may be able to be eliminated later.
  2216.          So bump REJECT in other cases.  */
  2217.           if (GET_CODE (operand) != REG)
  2218.         reject++;
  2219.         }
  2220.  
  2221.       /* If this operand is a pseudo register that didn't get a hard 
  2222.          reg and this alternative accepts some register, see if the
  2223.          class that we want is a subset of the preferred class for this
  2224.          register.  If not, but it intersects that class, use the
  2225.          preferred class instead.  If it does not intersect the preferred
  2226.          class, show that usage of this alternative should be discouraged;
  2227.          it will be discouraged more still if the register is `preferred
  2228.          or nothing'.  We do this because it increases the chance of
  2229.          reusing our spill register in a later insn and avoiding a pair
  2230.          of memory stores and loads.
  2231.  
  2232.          Don't bother with this if this alternative will accept this
  2233.          operand.  */
  2234.  
  2235.       if (! win && this_alternative[i] != (int) NO_REGS
  2236.           && preferred_class[i] != (int) NO_REGS)
  2237.         {
  2238.           if (! reg_class_subset_p (this_alternative[i],
  2239.                     preferred_class[i]))
  2240.         {
  2241.           /* Since we don't have a way of forming the intersection,
  2242.              we just do something special if the preferred class
  2243.              is a subset of the class we have; that's the most 
  2244.              common case anyway.  */
  2245.           if (reg_class_subset_p (preferred_class[i],
  2246.                       this_alternative[i]))
  2247.             this_alternative[i] = (int) preferred_class[i];
  2248.           else
  2249.             reject += (1 + pref_or_nothing[i]);
  2250.         }
  2251.         }
  2252.     }
  2253.  
  2254.       /* Now see if any output operands that are marked "earlyclobber"
  2255.      in this alternative conflict with any input operands
  2256.      or any memory addresses.  */
  2257.  
  2258.       for (i = 0; i < noperands; i++)
  2259.     if (this_alternative_earlyclobber[i]
  2260.         && this_alternative_win[i])
  2261.       {
  2262.         struct decomposition early_data; 
  2263.         int j;
  2264.  
  2265.         early_data = decompose (recog_operand[i]);
  2266.  
  2267.         for (j = 0; j < noperands; j++)
  2268.           /* Is this an input operand or a memory ref?  */
  2269.           if ((GET_CODE (recog_operand[j]) == MEM
  2270.            || modified[j] != RELOAD_WRITE)
  2271.           && j != i
  2272.           /* Ignore things like match_operator operands.  */
  2273.           && *constraints1[j] != 0
  2274.           /* Don't count an input operand that is constrained to match
  2275.              the early clobber operand.  */
  2276.           && ! (this_alternative_matches[j] == i
  2277.             && rtx_equal_p (recog_operand[i], recog_operand[j]))
  2278.           /* Is it altered by storing the earlyclobber operand?  */
  2279.           && !immune_p (recog_operand[j], recog_operand[i], early_data))
  2280.         {
  2281.           /* If the output is in a single-reg class,
  2282.              it's costly to reload it, so reload the input instead.  */
  2283.           if (reg_class_size[this_alternative[i]] == 1
  2284.               && (GET_CODE (recog_operand[j]) == REG
  2285.               || GET_CODE (recog_operand[j]) == SUBREG))
  2286.             {
  2287.               losers++;
  2288.               this_alternative_win[j] = 0;
  2289.             }
  2290.           else
  2291.             break;
  2292.         }
  2293.         /* If an earlyclobber operand conflicts with something,
  2294.            it must be reloaded, so request this and count the cost.  */
  2295.         if (j != noperands)
  2296.           {
  2297.         losers++;
  2298.         this_alternative_win[i] = 0;
  2299.         for (j = 0; j < noperands; j++)
  2300.           if (this_alternative_matches[j] == i
  2301.               && this_alternative_win[j])
  2302.             {
  2303.               this_alternative_win[j] = 0;
  2304.               losers++;
  2305.             }
  2306.           }
  2307.       }
  2308.  
  2309.       /* If one alternative accepts all the operands, no reload required,
  2310.      choose that alternative; don't consider the remaining ones.  */
  2311.       if (losers == 0)
  2312.     {
  2313.       /* Unswap these so that they are never swapped at `finish'.  */
  2314.       if (commutative >= 0)
  2315.         {
  2316.           recog_operand[commutative] = substed_operand[commutative];
  2317.           recog_operand[commutative + 1]
  2318.         = substed_operand[commutative + 1];
  2319.         }
  2320.       for (i = 0; i < noperands; i++)
  2321.         {
  2322.           goal_alternative_win[i] = 1;
  2323.           goal_alternative[i] = this_alternative[i];
  2324.           goal_alternative_offmemok[i] = this_alternative_offmemok[i];
  2325.           goal_alternative_matches[i] = this_alternative_matches[i];
  2326.           goal_alternative_earlyclobber[i]
  2327.         = this_alternative_earlyclobber[i];
  2328.         }
  2329.       goal_alternative_number = this_alternative_number;
  2330.       goal_alternative_swapped = swapped;
  2331.       goal_earlyclobber = this_earlyclobber;
  2332.       goto finish;
  2333.     }
  2334.  
  2335.       /* REJECT, set by the ! and ? constraint characters and when a register
  2336.      would be reloaded into a non-preferred class, discourages the use of
  2337.      this alternative for a reload goal.  REJECT is incremented by three
  2338.      for each ? and one for each non-preferred class.  */
  2339.       losers = losers * 3 + reject;
  2340.  
  2341.       /* If this alternative can be made to work by reloading,
  2342.      and it needs less reloading than the others checked so far,
  2343.      record it as the chosen goal for reloading.  */
  2344.       if (! bad && best > losers)
  2345.     {
  2346.       for (i = 0; i < noperands; i++)
  2347.         {
  2348.           goal_alternative[i] = this_alternative[i];
  2349.           goal_alternative_win[i] = this_alternative_win[i];
  2350.           goal_alternative_offmemok[i] = this_alternative_offmemok[i];
  2351.           goal_alternative_matches[i] = this_alternative_matches[i];
  2352.           goal_alternative_earlyclobber[i]
  2353.         = this_alternative_earlyclobber[i];
  2354.         }
  2355.       goal_alternative_swapped = swapped;
  2356.       best = losers;
  2357.       goal_alternative_number = this_alternative_number;
  2358.       goal_earlyclobber = this_earlyclobber;
  2359.     }
  2360.     }
  2361.  
  2362.   /* If insn is commutative (it's safe to exchange a certain pair of operands)
  2363.      then we need to try each alternative twice,
  2364.      the second time matching those two operands
  2365.      as if we had exchanged them.
  2366.      To do this, really exchange them in operands.
  2367.  
  2368.      If we have just tried the alternatives the second time,
  2369.      return operands to normal and drop through.  */
  2370.  
  2371.   if (commutative >= 0)
  2372.     {
  2373.       swapped = !swapped;
  2374.       if (swapped)
  2375.     {
  2376.       register enum reg_class tclass;
  2377.       register int t;
  2378.  
  2379.       recog_operand[commutative] = substed_operand[commutative + 1];
  2380.       recog_operand[commutative + 1] = substed_operand[commutative];
  2381.  
  2382.       tclass = preferred_class[commutative];
  2383.       preferred_class[commutative] = preferred_class[commutative + 1];
  2384.       preferred_class[commutative + 1] = tclass;
  2385.  
  2386.       t = pref_or_nothing[commutative];
  2387.       pref_or_nothing[commutative] = pref_or_nothing[commutative + 1];
  2388.       pref_or_nothing[commutative + 1] = t;
  2389.  
  2390.       bcopy (constraints1, constraints, noperands * sizeof (char *));
  2391.       goto try_swapped;
  2392.     }
  2393.       else
  2394.     {
  2395.       recog_operand[commutative] = substed_operand[commutative];
  2396.       recog_operand[commutative + 1] = substed_operand[commutative + 1];
  2397.     }
  2398.     }
  2399.  
  2400.   /* The operands don't meet the constraints.
  2401.      goal_alternative describes the alternative
  2402.      that we could reach by reloading the fewest operands.
  2403.      Reload so as to fit it.  */
  2404.  
  2405.   if (best == MAX_RECOG_OPERANDS + 300)
  2406.     {
  2407.       /* No alternative works with reloads??  */
  2408.       if (insn_code_number >= 0)
  2409.     abort ();
  2410.       error_for_asm (insn, "inconsistent operand constraints in an `asm'");
  2411.       /* Avoid further trouble with this insn.  */
  2412.       PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  2413.       n_reloads = 0;
  2414.       return;
  2415.     }
  2416.  
  2417.   /* Jump to `finish' from above if all operands are valid already.
  2418.      In that case, goal_alternative_win is all 1.  */
  2419.  finish:
  2420.  
  2421.   /* Right now, for any pair of operands I and J that are required to match,
  2422.      with I < J,
  2423.      goal_alternative_matches[J] is I.
  2424.      Set up goal_alternative_matched as the inverse function:
  2425.      goal_alternative_matched[I] = J.  */
  2426.  
  2427.   for (i = 0; i < noperands; i++)
  2428.     goal_alternative_matched[i] = -1;
  2429.  
  2430.   for (i = 0; i < noperands; i++)
  2431.     if (! goal_alternative_win[i]
  2432.     && goal_alternative_matches[i] >= 0)
  2433.       goal_alternative_matched[goal_alternative_matches[i]] = i;
  2434.  
  2435.   /* If the best alternative is with operands 1 and 2 swapped,
  2436.      consider them swapped before reporting the reloads.  */
  2437.  
  2438.   if (goal_alternative_swapped)
  2439.     {
  2440.       register rtx tem;
  2441.  
  2442.       tem = substed_operand[commutative];
  2443.       substed_operand[commutative] = substed_operand[commutative + 1];
  2444.       substed_operand[commutative + 1] = tem;
  2445.       tem = recog_operand[commutative];
  2446.       recog_operand[commutative] = recog_operand[commutative + 1];
  2447.       recog_operand[commutative + 1] = tem;
  2448.     }
  2449.  
  2450.   /* Perform whatever substitutions on the operands we are supposed
  2451.      to make due to commutativity or replacement of registers
  2452.      with equivalent constants or memory slots.  */
  2453.  
  2454.   for (i = 0; i < noperands; i++)
  2455.     {
  2456.       *recog_operand_loc[i] = substed_operand[i];
  2457.       /* While we are looping on operands, initialize this.  */
  2458.       operand_reloadnum[i] = -1;
  2459.     }
  2460.  
  2461.   /* Any constants that aren't allowed and can't be reloaded
  2462.      into registers are here changed into memory references.  */
  2463.   for (i = 0; i < noperands; i++)
  2464.     if (! goal_alternative_win[i]
  2465.     && CONSTANT_P (recog_operand[i])
  2466.     && (PREFERRED_RELOAD_CLASS (recog_operand[i],
  2467.                     (enum reg_class) goal_alternative[i])
  2468.         == NO_REGS)
  2469.     && operand_mode[i] != VOIDmode)
  2470.       {
  2471.     *recog_operand_loc[i] = recog_operand[i]
  2472.       = find_reloads_toplev (force_const_mem (operand_mode[i],
  2473.                           recog_operand[i]),
  2474.                  ind_levels);
  2475.     if (alternative_allows_memconst (constraints1[i],
  2476.                      goal_alternative_number))
  2477.       goal_alternative_win[i] = 1;
  2478.       }
  2479.  
  2480.   /* Now record reloads for all the operands that need them.  */
  2481.   for (i = 0; i < noperands; i++)
  2482.     if (! goal_alternative_win[i])
  2483.       {
  2484.     /* Operands that match previous ones have already been handled.  */
  2485.     if (goal_alternative_matches[i] >= 0)
  2486.       ;
  2487.     /* Handle an operand with a nonoffsettable address
  2488.        appearing where an offsettable address will do
  2489.        by reloading the address into a base register.  */
  2490.     else if (goal_alternative_matched[i] == -1
  2491.          && goal_alternative_offmemok[i]
  2492.          && GET_CODE (recog_operand[i]) == MEM)
  2493.       {
  2494.         operand_reloadnum[i]
  2495.           = push_reload (XEXP (recog_operand[i], 0), 0,
  2496.                  &XEXP (recog_operand[i], 0), 0,
  2497.                  BASE_REG_CLASS, GET_MODE (XEXP (recog_operand[i], 0)),
  2498.                  VOIDmode, 0, 0, 0);
  2499.         reload_inc[operand_reloadnum[i]]
  2500.           = GET_MODE_SIZE (GET_MODE (recog_operand[i]));
  2501.       }
  2502.     else if (goal_alternative_matched[i] == -1)
  2503.       operand_reloadnum[i] =
  2504.         push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
  2505.              modified[i] != RELOAD_READ ? recog_operand[i] : 0,
  2506.              modified[i] != RELOAD_WRITE ? recog_operand_loc[i] : 0,
  2507.              modified[i] != RELOAD_READ ? recog_operand_loc[i] : 0,
  2508.              (enum reg_class) goal_alternative[i],
  2509.              (modified[i] == RELOAD_WRITE ? VOIDmode : operand_mode[i]),
  2510.              (modified[i] == RELOAD_READ ? VOIDmode : operand_mode[i]),
  2511.              (insn_code_number < 0 ? 0
  2512.               : insn_operand_strict_low[insn_code_number][i]),
  2513.              0, 0);
  2514.     /* In a matching pair of operands, one must be input only
  2515.        and the other must be output only.
  2516.        Pass the input operand as IN and the other as OUT.  */
  2517.     else if (modified[i] == RELOAD_READ
  2518.          && modified[goal_alternative_matched[i]] == RELOAD_WRITE)
  2519.       {
  2520.         operand_reloadnum[i]
  2521.           = push_reload (recog_operand[i],
  2522.                  recog_operand[goal_alternative_matched[i]],
  2523.                  recog_operand_loc[i],
  2524.                  recog_operand_loc[goal_alternative_matched[i]],
  2525.                  (enum reg_class) goal_alternative[i],
  2526.                  operand_mode[i],
  2527.                  operand_mode[goal_alternative_matched[i]],
  2528.                  0, 0, 0);
  2529.         operand_reloadnum[goal_alternative_matched[i]] = output_reloadnum;
  2530.       }
  2531.     else if (modified[i] == RELOAD_WRITE
  2532.          && modified[goal_alternative_matched[i]] == RELOAD_READ)
  2533.       {
  2534.         operand_reloadnum[goal_alternative_matched[i]]
  2535.           = push_reload (recog_operand[goal_alternative_matched[i]],
  2536.                  recog_operand[i],
  2537.                  recog_operand_loc[goal_alternative_matched[i]],
  2538.                  recog_operand_loc[i],
  2539.                  (enum reg_class) goal_alternative[i],
  2540.                  operand_mode[goal_alternative_matched[i]],
  2541.                  operand_mode[i],
  2542.                  0, 0, 0);
  2543.         operand_reloadnum[i] = output_reloadnum;
  2544.       }
  2545.     else if (insn_code_number >= 0)
  2546.       abort ();
  2547.     else
  2548.       {
  2549.         error_for_asm (insn, "inconsistent operand constraints in an `asm'");
  2550.         /* Avoid further trouble with this insn.  */
  2551.         PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx);
  2552.         n_reloads = 0;
  2553.         return;
  2554.       }
  2555.       }
  2556.     else if (goal_alternative_matched[i] < 0
  2557.          && goal_alternative_matches[i] < 0
  2558.          && optimize)
  2559.       {
  2560.     rtx operand = recog_operand[i];
  2561.     /* For each non-matching operand that's a pseudo-register 
  2562.        that didn't get a hard register, make an optional reload.
  2563.        This may get done even if the insn needs no reloads otherwise.  */
  2564.     /* (It would be safe to make an optional reload for a matching pair
  2565.        of operands, but we don't bother yet.)  */
  2566.     while (GET_CODE (operand) == SUBREG)
  2567.       operand = XEXP (operand, 0);
  2568.     if (GET_CODE (operand) == REG
  2569.         && REGNO (operand) >= FIRST_PSEUDO_REGISTER
  2570.         && reg_renumber[REGNO (operand)] < 0
  2571.         && (enum reg_class) goal_alternative[i] != NO_REGS
  2572.         /* Don't make optional output reloads for jump insns
  2573.            (such as aobjeq on the vax).  */
  2574.         && (modified[i] == RELOAD_READ
  2575.         || GET_CODE (insn) != JUMP_INSN))
  2576.       operand_reloadnum[i]
  2577.         = push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
  2578.                modified[i] != RELOAD_READ ? recog_operand[i] : 0,
  2579.                modified[i] != RELOAD_WRITE ? recog_operand_loc[i] : 0,
  2580.                modified[i] != RELOAD_READ ? recog_operand_loc[i] : 0,
  2581.                (enum reg_class) goal_alternative[i],
  2582.                (modified[i] == RELOAD_WRITE ? VOIDmode : operand_mode[i]),
  2583.                (modified[i] == RELOAD_READ ? VOIDmode : operand_mode[i]),
  2584.                (insn_code_number < 0 ? 0
  2585.                 : insn_operand_strict_low[insn_code_number][i]),
  2586.                1, 0);
  2587.     /* Make an optional reload for an explicit mem ref.  */
  2588.     else if (GET_CODE (operand) == MEM
  2589.          && (enum reg_class) goal_alternative[i] != NO_REGS
  2590.          /* Don't make optional output reloads for jump insns
  2591.             (such as aobjeq on the vax).  */
  2592.          && (modified[i] == RELOAD_READ
  2593.              || GET_CODE (insn) != JUMP_INSN))
  2594.       operand_reloadnum[i]
  2595.         = push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
  2596.                modified[i] != RELOAD_READ ? recog_operand[i] : 0,
  2597.                modified[i] != RELOAD_WRITE ? recog_operand_loc[i] : 0,
  2598.                modified[i] != RELOAD_READ ? recog_operand_loc[i] : 0,
  2599.                (enum reg_class) goal_alternative[i],
  2600.                (modified[i] == RELOAD_WRITE ? VOIDmode : operand_mode[i]),
  2601.                (modified[i] == RELOAD_READ ? VOIDmode : operand_mode[i]),
  2602.                (insn_code_number < 0 ? 0
  2603.                 : insn_operand_strict_low[insn_code_number][i]),
  2604.                1, 0);
  2605.     else
  2606.       non_reloaded_operands[n_non_reloaded_operands++] = recog_operand[i];
  2607.       }
  2608.  
  2609.   /* Record the values of the earlyclobber operands for the caller.  */
  2610.   if (goal_earlyclobber)
  2611.     for (i = 0; i < noperands; i++)
  2612.       if (goal_alternative_earlyclobber[i])
  2613.     reload_earlyclobbers[n_earlyclobbers++] = recog_operand[i];
  2614.  
  2615.   /* If this insn pattern contains any MATCH_DUP's, make sure that
  2616.      they will be substituted if the operands they match are substituted.
  2617.      Also do now any substitutions we already did on the operands.  */
  2618.   if (insn_code_number >= 0)
  2619.     for (i = insn_n_dups[insn_code_number] - 1; i >= 0; i--)
  2620.       {
  2621.     int opno = recog_dup_num[i];
  2622.     *recog_dup_loc[i] = *recog_operand_loc[opno];
  2623.     if (operand_reloadnum[opno] >= 0)
  2624.       push_replacement (recog_dup_loc[i], operand_reloadnum[opno],
  2625.                 insn_operand_mode[insn_code_number][opno]);
  2626.       }
  2627.  
  2628. #if 0
  2629.   /* This loses because reloading of prior insns can invalidate the equivalence
  2630.      (or at least find_equiv_reg isn't smart enough to find it any more),
  2631.      causing this insn to need more reload regs than it needed before.
  2632.      It may be too late to make the reload regs available.
  2633.      Now this optimization is done safely in choose_reload_regs.  */
  2634.  
  2635.   /* For each reload of a reg into some other class of reg,
  2636.      search for an existing equivalent reg (same value now) in the right class.
  2637.      We can use it as long as we don't need to change its contents.  */
  2638.   for (i = 0; i < n_reloads; i++)
  2639.     if (reload_reg_rtx[i] == 0
  2640.     && reload_in[i] != 0
  2641.     && GET_CODE (reload_in[i]) == REG
  2642.     && reload_out[i] == 0)
  2643.       {
  2644.     reload_reg_rtx[i]
  2645.       = find_equiv_reg (reload_in[i], insn, reload_reg_class[i], -1,
  2646.                 static_reload_reg_p, 0, reload_inmode[i]);
  2647.     /* Prevent generation of insn to load the value
  2648.        because the one we found already has the value.  */
  2649.     if (reload_reg_rtx[i])
  2650.       reload_in[i] = reload_reg_rtx[i];
  2651.       }
  2652. #endif
  2653.  
  2654. #else /* no REGISTER_CONSTRAINTS */
  2655.   int noperands;
  2656.   int insn_code_number;
  2657.   int goal_earlyclobber = 0; /* Always 0, to make combine_reloads happen.  */
  2658.   register int i;
  2659.   rtx body = PATTERN (insn);
  2660.  
  2661.   n_reloads = 0;
  2662.   n_replacements = 0;
  2663.   n_earlyclobbers = 0;
  2664.   replace_reloads = replace;
  2665.   this_insn = insn;
  2666.  
  2667.   /* Find what kind of insn this is.  NOPERANDS gets number of operands.
  2668.      Store the operand values in RECOG_OPERAND and the locations
  2669.      of the words in the insn that point to them in RECOG_OPERAND_LOC.
  2670.      Return if the insn needs no reload processing.  */
  2671.  
  2672.   switch (GET_CODE (body))
  2673.     {
  2674.     case USE:
  2675.     case CLOBBER:
  2676.     case ASM_INPUT:
  2677.     case ADDR_VEC:
  2678.     case ADDR_DIFF_VEC:
  2679.       return;
  2680.  
  2681.     case PARALLEL:
  2682.     case SET:
  2683.       noperands = asm_noperands (body);
  2684.       if (noperands >= 0)
  2685.     {
  2686.       /* This insn is an `asm' with operands.
  2687.          First, find out how many operands, and allocate space.  */
  2688.  
  2689.       insn_code_number = -1;
  2690.       /* ??? This is a bug! ???
  2691.          Give up and delete this insn if it has too many operands.  */
  2692.       if (noperands > MAX_RECOG_OPERANDS)
  2693.         abort ();
  2694.  
  2695.       /* Now get the operand values out of the insn.  */
  2696.  
  2697.       decode_asm_operands (body, recog_operand, recog_operand_loc, 0, 0);
  2698.       break;
  2699.     }
  2700.  
  2701.     default:
  2702.       /* Ordinary insn: recognize it, allocate space for operands and
  2703.      constraints, and get them out via insn_extract.  */
  2704.  
  2705.       insn_code_number = recog_memoized (insn);
  2706.       noperands = insn_n_operands[insn_code_number];
  2707.       insn_extract (insn);
  2708.     }
  2709.  
  2710.   if (noperands == 0)
  2711.     return;
  2712.  
  2713.   for (i = 0; i < noperands; i++)
  2714.     {
  2715.       register RTX_CODE code = GET_CODE (recog_operand[i]);
  2716.  
  2717.       if (insn_code_number >= 0)
  2718.     if (insn_operand_address_p[insn_code_number][i])
  2719.       find_reloads_address (VOIDmode, 0,
  2720.                 recog_operand[i], recog_operand_loc[i],
  2721.                 recog_operand[i], ind_levels);
  2722.       if (code == MEM)
  2723.     find_reloads_address (GET_MODE (recog_operand[i]),
  2724.                   recog_operand_loc[i],
  2725.                   XEXP (recog_operand[i], 0),
  2726.                   &XEXP (recog_operand[i], 0),
  2727.                   recog_operand[i], ind_levels);
  2728.       if (code == SUBREG)
  2729.     recog_operand[i] = *recog_operand_loc[i]
  2730.       = find_reloads_toplev (recog_operand[i], ind_levels);
  2731.       if (code == REG)
  2732.     {
  2733.       register int regno = REGNO (recog_operand[i]);
  2734.       if (reg_equiv_constant[regno] != 0)
  2735.         recog_operand[i] = *recog_operand_loc[i]
  2736.           = reg_equiv_constant[regno];
  2737. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  2738.      that feeds this insn.  */
  2739.       if (reg_equiv_mem[regno] != 0)
  2740.         recog_operand[i] = *recog_operand_loc[i]
  2741.           = reg_equiv_mem[regno];
  2742. #endif
  2743.     }
  2744.       /* All operands are non-reloaded.  */
  2745.       non_reloaded_operands[n_non_reloaded_operands++] = recog_operand[i];
  2746.     }
  2747. #endif /* no REGISTER_CONSTRAINTS */
  2748.  
  2749.   /* Determine which part of the insn each reload is needed for,
  2750.      based on which operand the reload is needed for.
  2751.      Reloads of entire operands are classified as RELOAD_OTHER.
  2752.      So are reloads for which a unique purpose is not known.  */
  2753.  
  2754.   for (i = 0; i < n_reloads; i++)
  2755.     {
  2756.       reload_when_needed[i] = RELOAD_OTHER;
  2757.  
  2758.       if (reload_needed_for[i] != 0 && ! reload_needed_for_multiple[i])
  2759.     {
  2760.       int j;
  2761.       int output_address = 0;
  2762.       int input_address = 0;
  2763.       int operand_address = 0;
  2764.  
  2765.       /* This reload is needed only for the address of something.
  2766.          Determine whether it is needed for addressing an operand
  2767.          being reloaded for input, whether it is needed for an
  2768.          operand being reloaded for output, and whether it is needed
  2769.          for addressing an operand that won't really be reloaded.
  2770.  
  2771.          Note that we know that this reload is needed in only one address,
  2772.          but we have not yet checked for the case where that same address
  2773.          is used in both input and output reloads.
  2774.          The following code detects this case.  */
  2775.  
  2776.       for (j = 0; j < n_reloads; j++)
  2777.         if (reload_needed_for[i] == reload_in[j]
  2778.         || reload_needed_for[i] == reload_out[j])
  2779.           {
  2780.         if (reload_optional[j])
  2781.           operand_address = 1;
  2782.         else
  2783.           {
  2784.             if (reload_needed_for[i] == reload_in[j])
  2785.               input_address = 1;
  2786.             if (reload_needed_for[i] == reload_out[j])
  2787.               output_address = 1;
  2788.           }
  2789.           }
  2790.       /* Don't ignore memrefs without optional reloads.  */
  2791.       for (j = 0; j < n_non_reloaded_operands; j++)
  2792.         if (reload_needed_for[i] == non_reloaded_operands[j])
  2793.           operand_address = 1;
  2794.  
  2795.       /* If it is needed for only one of those, record which one.  */
  2796.  
  2797.       if (input_address && ! output_address && ! operand_address)
  2798.         reload_when_needed[i] = RELOAD_FOR_INPUT_RELOAD_ADDRESS;
  2799.       if (output_address && ! input_address && ! operand_address)
  2800.         reload_when_needed[i] = RELOAD_FOR_OUTPUT_RELOAD_ADDRESS;
  2801.       if (operand_address && ! input_address && ! output_address)
  2802.         reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS;
  2803.  
  2804.       /* Indicate those RELOAD_OTHER reloads which, though they have
  2805.          0 for reload_output, still cannot overlap an output reload.  */
  2806.  
  2807.       if (output_address && reload_when_needed[i] == RELOAD_OTHER)
  2808.         reload_needed_for_multiple[i] = 1;
  2809.     }
  2810.     }
  2811.  
  2812.   /* Perhaps an output reload can be combined with another
  2813.      to reduce needs by one.  */
  2814.   if (!goal_earlyclobber)
  2815.     combine_reloads ();
  2816. }
  2817.  
  2818. /* Return 1 if alternative number ALTNUM in constraint-string CONSTRAINT
  2819.    accepts a memory operand with constant address.  */
  2820.  
  2821. static int
  2822. alternative_allows_memconst (constraint, altnum)
  2823.      char *constraint;
  2824.      int altnum;
  2825. {
  2826.   register int c;
  2827.   /* Skip alternatives before the one requested.  */
  2828.   while (altnum > 0)
  2829.     {
  2830.       while (*constraint++ != ',');
  2831.       altnum--;
  2832.     }
  2833.   /* Scan the requested alternative for 'm' or 'o'.
  2834.      If one of them is present, this alternative accepts memory constants.  */
  2835.   while ((c = *constraint++) && c != ',' && c != '#')
  2836.     if (c == 'm' || c == 'o')
  2837.       return 1;
  2838.   return 0;
  2839. }
  2840.  
  2841. /* Scan X for memory references and scan the addresses for reloading.
  2842.    Also checks for references to "constant" regs that we want to eliminate
  2843.    and replaces them with the values they stand for.
  2844.    We may alter X descructively if it contains a reference to such.
  2845.    If X is just a constant reg, we return the equivalent value
  2846.    instead of X.
  2847.  
  2848.    IND_LEVELS says how many levels of indirect addressing this machine
  2849.    supports.  */
  2850.  
  2851. static rtx
  2852. find_reloads_toplev (x, ind_levels)
  2853.      rtx x;
  2854.      int ind_levels;
  2855. {
  2856.   register RTX_CODE code = GET_CODE (x);
  2857.  
  2858.   register char *fmt = GET_RTX_FORMAT (code);
  2859.   register int i;
  2860.  
  2861.   if (code == REG)
  2862.     {
  2863.       /* This code is duplicated for speed in find_reloads.  */
  2864.       register int regno = REGNO (x);
  2865.       if (reg_equiv_constant[regno] != 0)
  2866.     x = reg_equiv_constant[regno];
  2867. #if 0
  2868. /*  This creates (subreg (mem...)) which would cause an unnecessary
  2869.     reload of the mem.  */
  2870.       else if (reg_equiv_mem[regno] != 0)
  2871.     x = reg_equiv_mem[regno];
  2872. #endif
  2873.       else if (reg_equiv_address[regno] != 0)
  2874.     {
  2875.       /* If reg_equiv_address varies, it may be shared, so copy it.  */
  2876.       rtx addr = reg_equiv_address[regno];
  2877.  
  2878.       if (rtx_varies_p (addr))
  2879.         addr = copy_rtx (addr);
  2880.  
  2881.       x = gen_rtx (MEM, GET_MODE (x), addr);
  2882.       RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  2883.       find_reloads_address (GET_MODE (x), 0,
  2884.                 XEXP (x, 0),
  2885.                 &XEXP (x, 0), x, ind_levels);
  2886.     }
  2887.       return x;
  2888.     }
  2889.   if (code == MEM)
  2890.     {
  2891.       rtx tem = x;
  2892.       find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
  2893.                 x, ind_levels);
  2894.       return tem;
  2895.     }
  2896.  
  2897.   if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG)
  2898.     {
  2899.       /* Check for SUBREG containing a REG that's equivalent to a constant. 
  2900.      If the constant has a known value, truncate it right now.
  2901.      If the constant is symbolic, allow it to be substituted normally.
  2902.      push_reload will strip the subreg later.  */
  2903.  
  2904.       register int regno = REGNO (SUBREG_REG (x));
  2905.       rtx tem;
  2906.  
  2907.       if (subreg_lowpart_p (x)
  2908.       && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  2909.       && reg_equiv_constant[regno] != 0
  2910.       && (tem = gen_lowpart_common (GET_MODE (x),
  2911.                     reg_equiv_constant[regno])) != 0)
  2912.     return tem;
  2913.  
  2914.       /* If the subreg contains a reg that will be converted to a mem,
  2915.      convert the subreg to a narrower memref now.
  2916.      Otherwise, we would get (subreg (mem ...) ...),
  2917.      which would force reload of the mem.
  2918.  
  2919.      We also need to do this if there is an equivalent MEM that is
  2920.      not offsettable.  In that case, alter_subreg would produce an
  2921.      invalid address on big-endian machines.  */
  2922.  
  2923.       else if (regno >= FIRST_PSEUDO_REGISTER
  2924.            && (reg_equiv_address[regno] != 0
  2925.            || (reg_equiv_mem[regno] != 0
  2926.                && ! offsettable_memref_p (reg_equiv_mem[regno]))))
  2927.     {
  2928.       int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
  2929.       rtx addr = (reg_equiv_address[regno] ? reg_equiv_address[regno]
  2930.               : XEXP (reg_equiv_mem[regno], 0));
  2931. #if BYTES_BIG_ENDIAN
  2932.       int size;
  2933.       size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
  2934.       offset += min (size, UNITS_PER_WORD);
  2935.       size = GET_MODE_SIZE (GET_MODE (x));
  2936.       offset -= min (size, UNITS_PER_WORD);
  2937. #endif
  2938.       addr = plus_constant (addr, offset);
  2939.       x = gen_rtx (MEM, GET_MODE (x), addr);
  2940.       RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  2941.       find_reloads_address (GET_MODE (x), 0,
  2942.                 XEXP (x, 0),
  2943.                 &XEXP (x, 0), x, ind_levels);
  2944.     }
  2945.  
  2946.     }
  2947.  
  2948.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  2949.     {
  2950.       if (fmt[i] == 'e')
  2951.     XEXP (x, i) = find_reloads_toplev (XEXP (x, i), ind_levels);
  2952.     }
  2953.   return x;
  2954. }
  2955.  
  2956. static rtx
  2957. make_memloc (ad, regno)
  2958.      rtx ad;
  2959.      int regno;
  2960. {
  2961.   register int i;
  2962.   rtx tem = reg_equiv_address[regno];
  2963.   for (i = 0; i < n_memlocs; i++)
  2964.     if (rtx_equal_p (tem, XEXP (memlocs[i], 0)))
  2965.       return memlocs[i];
  2966.  
  2967.   /* If TEM might contain a pseudo, we must copy it to avoid
  2968.      modifying it when we do the substitution for the reload.  */
  2969.   if (rtx_varies_p (tem))
  2970.     tem = copy_rtx (tem);
  2971.  
  2972.   tem = gen_rtx (MEM, GET_MODE (ad), tem);
  2973.   RTX_UNCHANGING_P (tem) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
  2974.   memlocs[n_memlocs++] = tem;
  2975.   return tem;
  2976. }
  2977.  
  2978. /* Record all reloads needed for handling memory address AD
  2979.    which appears in *LOC in a memory reference to mode MODE
  2980.    which itself is found in location  *MEMREFLOC.
  2981.    Note that we take shortcuts assuming that no multi-reg machine mode
  2982.    occurs as part of an address.
  2983.  
  2984.    OPERAND is the operand of the insn within which this address appears.
  2985.  
  2986.    IND_LEVELS says how many levels of indirect addressing this machine
  2987.    supports.
  2988.  
  2989.    Value is nonzero if this address is reloaded or replaced as a whole.
  2990.    This is interesting to the caller if the address is an autoincrement.
  2991.  
  2992.    Note that there is no verification that the address will be valid after
  2993.    this routine does its work.  Instead, we rely on the fact that the address
  2994.    was valid when reload started.  So we need only undo things that reload
  2995.    could have broken.  These are wrong register types, pseudos not allocated
  2996.    to a hard register, and frame pointer elimination.  */
  2997.  
  2998. static int
  2999. find_reloads_address (mode, memrefloc, ad, loc, operand, ind_levels)
  3000.      enum machine_mode mode;
  3001.      rtx *memrefloc;
  3002.      rtx ad;
  3003.      rtx *loc;
  3004.      rtx operand;
  3005.      int ind_levels;
  3006. {
  3007.   register int regno;
  3008.   rtx tem;
  3009.  
  3010.   if (GET_CODE (ad) == REG)
  3011.     {
  3012.       regno = REGNO (ad);
  3013.  
  3014.       if (reg_equiv_constant[regno] != 0)
  3015.     {
  3016.       if (strict_memory_address_p (mode, reg_equiv_constant[regno]))
  3017.         {
  3018.           *loc = ad = reg_equiv_constant[regno];
  3019.           return 1;
  3020.         }
  3021.     }
  3022. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  3023.      that feeds this insn.  */
  3024.       if (reg_equiv_mem[regno] != 0)
  3025.     {
  3026.       if (strict_memory_address_p (mode, reg_equiv_mem[regno]))
  3027.         {
  3028.           *loc = ad = reg_equiv_mem[regno];
  3029.           return 1;
  3030.         }
  3031.     }
  3032. #endif
  3033.       if (reg_equiv_address[regno] != 0)
  3034.     {
  3035.       rtx tem = make_memloc (ad, regno);
  3036.       find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0),
  3037.                 &XEXP (tem, 0), operand, ind_levels);
  3038.       push_reload (tem, 0, loc, 0, BASE_REG_CLASS,
  3039.                GET_MODE (ad), VOIDmode, 0, 0,
  3040.                operand);
  3041.       return 1;
  3042.     }
  3043.       if (! (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
  3044.          ? ind_levels > 0
  3045.          : REGNO_OK_FOR_BASE_P (regno)))
  3046.     {
  3047.       push_reload (ad, 0, loc, 0, BASE_REG_CLASS,
  3048.                GET_MODE (ad), VOIDmode, 0, 0, operand);
  3049.       return 1;
  3050.     }
  3051.       /* If a register appearing in an address is the subject of a CLOBBER
  3052.      in this insn, reload it into some other register to be safe.  */
  3053.       if (regno_clobbered_p (regno, this_insn))
  3054.     {
  3055.       push_reload (ad, 0, loc, 0, BASE_REG_CLASS,
  3056.                GET_MODE (ad), VOIDmode, 0, 0, operand);
  3057.       return 1;
  3058.     }
  3059.       return 0;
  3060.     }
  3061.  
  3062.   if (strict_memory_address_p (mode, ad))
  3063.     {
  3064.       /* The address appears valid, so reloads are not needed.
  3065.      But the address may contain an eliminable register.
  3066.      This can happen because a machine with indirect addressing
  3067.      may consider a pseudo register by itself a valid address even when
  3068.      it has failed to get a hard reg.
  3069.      So do a tree-walk to find and eliminate all such regs.  */
  3070.  
  3071.       /* But first quickly dispose of a common case.  */
  3072.       if (GET_CODE (ad) == PLUS
  3073.       && GET_CODE (XEXP (ad, 1)) == CONST_INT
  3074.       && GET_CODE (XEXP (ad, 0)) == REG
  3075.       && reg_equiv_constant[REGNO (XEXP (ad, 0))] == 0)
  3076.     return 0;
  3077.  
  3078.       subst_reg_equivs_changed = 0;
  3079.       *loc = subst_reg_equivs (ad);
  3080.  
  3081.       if (! subst_reg_equivs_changed)
  3082.     return 0;
  3083.  
  3084.       /* Check result for validity after substitution.  */
  3085.       if (strict_memory_address_p (mode, ad))
  3086.     return 0;
  3087.     }
  3088.  
  3089.   /* The address is not valid.  We have to figure out why.  One possibility
  3090.      is that it is itself a MEM.  This can happen when the frame pointer is
  3091.      being eliminated, a pseudo is not allocated to a hard register, and the
  3092.      offset between the frame and stack pointers is not its initial value.
  3093.      In that case the psuedo will have been replaced by a MEM referring to
  3094.      the stack pointer.  */
  3095.   if (GET_CODE (ad) == MEM)
  3096.     {
  3097.       /* First ensure that the address in this MEM is valid.  Then, unless
  3098.      indirect addresses are valid, reload the MEM into a register.  */
  3099.       rtx tem = ad;
  3100.       find_reloads_address (GET_MODE (ad), &tem, XEXP (ad, 0), &XEXP (ad, 0),
  3101.                 operand, ind_levels == 0 ? 0 : ind_levels - 1);
  3102.       if (ind_levels == 0)
  3103.     {
  3104.       /* Must use TEM here, not AD, since it is the one that will
  3105.          have any subexpressions reloaded, if needed.  */
  3106.       push_reload (tem, 0, loc, 0,
  3107.                BASE_REG_CLASS, GET_MODE (tem), VOIDmode, 0,
  3108.                0, operand);
  3109.       return 1;
  3110.     }
  3111.       else
  3112.     return 0;
  3113.     }
  3114.  
  3115.   /* If we have address of a stack slot but it's not valid
  3116.      (displacement is too large), compute the sum in a register.  */
  3117.   else if (GET_CODE (ad) == PLUS
  3118.        && (XEXP (ad, 0) == frame_pointer_rtx
  3119. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  3120.            || XEXP (ad, 0) == arg_pointer_rtx
  3121. #endif
  3122.            || XEXP (ad, 0) == stack_pointer_rtx)
  3123.        && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  3124.     {
  3125.       /* Unshare the MEM rtx so we can safely alter it.  */
  3126.       if (memrefloc)
  3127.     {
  3128.       rtx oldref = *memrefloc;
  3129.       *memrefloc = copy_rtx (*memrefloc);
  3130.       loc = &XEXP (*memrefloc, 0);
  3131.       if (operand == oldref)
  3132.         operand = *memrefloc;
  3133.     }
  3134.       if (double_reg_address_ok)
  3135.     {
  3136.       /* Unshare the sum as well.  */
  3137.       *loc = ad = copy_rtx (ad);
  3138.       /* Reload the displacement into an index reg.
  3139.          We assume the frame pointer or arg pointer is a base reg.  */
  3140.       push_reload (XEXP (ad, 1), 0, &XEXP (ad, 1), 0, INDEX_REG_CLASS, 
  3141.                GET_MODE (ad), VOIDmode, 0, 0, operand);
  3142.     }
  3143.       else
  3144.     {
  3145.       /* If the sum of two regs is not necessarily valid,
  3146.          reload the sum into a base reg.
  3147.          That will at least work.  */
  3148.       push_reload (ad, 0, loc, 0, BASE_REG_CLASS,
  3149.                GET_MODE (ad), VOIDmode, 0, 0, operand);
  3150.     }
  3151.       return 1;
  3152.     }
  3153.  
  3154.   /* If we have an indexed stack slot, there are three possible reasons why
  3155.      it might be invalid: The index might need to be reloaded, the address
  3156.      might have been made by frame pointer elimination and hence have a
  3157.      constant out of range, or both reasons might apply.  
  3158.  
  3159.      We can easily check for an index needing reload, but even if that is the
  3160.      case, we might also have an invalid constant.  To avoid making the
  3161.      conservative assumption and requiring two reloads, we see if this address
  3162.      is valid when not interpreted strictly.  If it is, the only problem is
  3163.      that the index needs a reload and find_reloads_address_1 will take care
  3164.      of it.
  3165.  
  3166.      There is still a case when we might generate an extra reload,
  3167.      however.  In certain cases eliminate_regs will return a MEM for a REG
  3168.      (see the code there for details).  In those cases, memory_address_p
  3169.      applied to our address will return 0 so we will think that our offset
  3170.      must be too large.  But it might indeed be valid and the only problem
  3171.      is that a MEM is present where a REG should be.  This case should be
  3172.      very rare and there doesn't seem to be any way to avoid it.
  3173.  
  3174.      If we decide to do something here, it must be that
  3175.      `double_reg_address_ok' is true and that this address rtl was made by
  3176.      eliminate_regs.  We generate a reload of the fp/sp/ap + constant and
  3177.      rework the sum so that the reload register will be added to the index.
  3178.      This is safe because we know the address isn't shared.
  3179.  
  3180.      We check for fp/ap/sp as both the first and second operand of the
  3181.      innermost PLUS.  */
  3182.  
  3183.   else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
  3184.        && GET_CODE (XEXP (ad, 0)) == PLUS
  3185.        && (XEXP (XEXP (ad, 0), 0) == frame_pointer_rtx
  3186. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  3187.            || XEXP (XEXP (ad, 0), 0) == arg_pointer_rtx
  3188. #endif
  3189.            || XEXP (XEXP (ad, 0), 0) == stack_pointer_rtx)
  3190.        && ! memory_address_p (mode, ad))
  3191.     {
  3192.       *loc = ad = gen_rtx (PLUS, GET_MODE (ad),
  3193.                plus_constant (XEXP (XEXP (ad, 0), 0),
  3194.                       INTVAL (XEXP (ad, 1))),
  3195.                XEXP (XEXP (ad, 0), 1));
  3196.       push_reload (XEXP (ad, 0), 0, &XEXP (ad, 0), 0, BASE_REG_CLASS,
  3197.            GET_MODE (ad), VOIDmode, 0, 0, operand);
  3198.       find_reloads_address_1 (XEXP (ad, 1), 1, &XEXP (ad, 1), operand, 0);
  3199.  
  3200.       return 1;
  3201.     }
  3202.                
  3203.   else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
  3204.        && GET_CODE (XEXP (ad, 0)) == PLUS
  3205.        && (XEXP (XEXP (ad, 0), 1) == frame_pointer_rtx
  3206. #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
  3207.            || XEXP (XEXP (ad, 0), 1) == arg_pointer_rtx
  3208. #endif
  3209.            || XEXP (XEXP (ad, 0), 1) == stack_pointer_rtx)
  3210.        && ! memory_address_p (mode, ad))
  3211.     {
  3212.       *loc = ad = gen_rtx (PLUS, GET_MODE (ad),
  3213.                plus_constant (XEXP (XEXP (ad, 0), 1),
  3214.                       INTVAL (XEXP (ad, 1))),
  3215.                XEXP (XEXP (ad, 0), 0));
  3216.       push_reload (XEXP (ad, 0), 0, &XEXP (ad, 0), 0, BASE_REG_CLASS,
  3217.            GET_MODE (ad), VOIDmode, 0, 0, operand);
  3218.       find_reloads_address_1 (XEXP (ad, 1), 1, &XEXP (ad, 1), operand, 0);
  3219.  
  3220.       return 1;
  3221.     }
  3222.                
  3223.   /* See if address becomes valid when an eliminable register
  3224.      in a sum is replaced.  */
  3225.  
  3226.   tem = ad;
  3227.   if (GET_CODE (ad) == PLUS)
  3228.     tem = subst_indexed_address (ad);
  3229.   if (tem != ad && strict_memory_address_p (mode, tem))
  3230.     {
  3231.       /* Ok, we win that way.  Replace any additional eliminable
  3232.      registers.  */
  3233.  
  3234.       subst_reg_equivs_changed = 0;
  3235.       tem = subst_reg_equivs (tem);
  3236.  
  3237.       /* Make sure that didn't make the address invalid again.  */
  3238.  
  3239.       if (! subst_reg_equivs_changed || strict_memory_address_p (mode, tem))
  3240.     {
  3241.       *loc = tem;
  3242.       return 0;
  3243.     }
  3244.     }
  3245.  
  3246.   /* If constants aren't valid addresses, reload the constant address
  3247.      into a register.  */
  3248.   if (CONSTANT_ADDRESS_P (ad) && ! strict_memory_address_p (mode, ad))
  3249.     {
  3250.       /* If AD is in address in the constant pool, the MEM rtx may be shared.
  3251.      Unshare it so we can safely alter it.  */
  3252.       if (memrefloc && GET_CODE (ad) == SYMBOL_REF
  3253.       && CONSTANT_POOL_ADDRESS_P (ad))
  3254.     {
  3255.       rtx oldref = *memrefloc;
  3256.       *memrefloc = copy_rtx (*memrefloc);
  3257.       loc = &XEXP (*memrefloc, 0);
  3258.       if (operand == oldref)
  3259.         operand = *memrefloc;
  3260.     }
  3261.  
  3262.       push_reload (ad, 0, loc, 0,
  3263.            BASE_REG_CLASS,
  3264.            Pmode, VOIDmode, 0, 0, operand);
  3265.       return 1;
  3266.     }
  3267.  
  3268.   return find_reloads_address_1 (ad, 0, loc, operand, ind_levels);
  3269. }
  3270.  
  3271. /* Find all pseudo regs appearing in AD
  3272.    that are eliminable in favor of equivalent values
  3273.    and do not have hard regs; replace them by their equivalents.  */
  3274.  
  3275. static rtx
  3276. subst_reg_equivs (ad)
  3277.      rtx ad;
  3278. {
  3279.   register RTX_CODE code = GET_CODE (ad);
  3280.   register int i;
  3281.   register char *fmt;
  3282.  
  3283.   switch (code)
  3284.     {
  3285.     case HIGH:
  3286.     case CONST_INT:
  3287.     case CONST:
  3288.     case CONST_DOUBLE:
  3289.     case SYMBOL_REF:
  3290.     case LABEL_REF:
  3291.     case PC:
  3292.     case CC0:
  3293.       return ad;
  3294.  
  3295.     case REG:
  3296.       {
  3297.     register int regno = REGNO (ad);
  3298.  
  3299.     if (reg_equiv_constant[regno] != 0)
  3300.       {
  3301.         subst_reg_equivs_changed = 1;
  3302.         return reg_equiv_constant[regno];
  3303.       }
  3304.       }
  3305.       return ad;
  3306.  
  3307.     case PLUS:
  3308.       /* Quickly dispose of a common case.  */
  3309.       if (XEXP (ad, 0) == frame_pointer_rtx
  3310.       && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  3311.     return ad;
  3312.     }
  3313.  
  3314.   fmt = GET_RTX_FORMAT (code);
  3315.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3316.     if (fmt[i] == 'e')
  3317.       XEXP (ad, i) = subst_reg_equivs (XEXP (ad, i));
  3318.   return ad;
  3319. }
  3320.  
  3321. /* Compute the sum of X and Y, making canonicalizations assumed in an
  3322.    address, namely: sum constant integers, surround the sum of two
  3323.    constants with a CONST, put the constant as the second operand, and
  3324.    group the constant on the outermost sum.
  3325.  
  3326.    This routine assumes both inputs are already in canonical form.  */
  3327.  
  3328. rtx
  3329. form_sum (x, y)
  3330.      rtx x, y;
  3331. {
  3332.   rtx tem;
  3333.  
  3334.   if (GET_CODE (x) == CONST_INT)
  3335.     return plus_constant (y, INTVAL (x));
  3336.   else if (GET_CODE (y) == CONST_INT)
  3337.     return plus_constant (x, INTVAL (y));
  3338.   else if (CONSTANT_P (x))
  3339.     tem = x, x = y, y = tem;
  3340.  
  3341.   if (GET_CODE (x) == PLUS && CONSTANT_P (XEXP (x, 1)))
  3342.     return form_sum (XEXP (x, 0), form_sum (XEXP (x, 1), y));
  3343.  
  3344.   /* Note that if the operands of Y are specified in the opposite
  3345.      order in the recursive calls below, infinite recursion will occur.  */
  3346.   if (GET_CODE (y) == PLUS && CONSTANT_P (XEXP (y, 1)))
  3347.     return form_sum (form_sum (x, XEXP (y, 0)), XEXP (y, 1));
  3348.  
  3349.   /* If both constant, encapsulate sum.  Otherwise, just form sum.  A
  3350.      constant will have been placed second.  */
  3351.   if (CONSTANT_P (x) && CONSTANT_P (y))
  3352.     {
  3353.       if (GET_CODE (x) == CONST)
  3354.     x = XEXP (x, 0);
  3355.       if (GET_CODE (y) == CONST)
  3356.     y = XEXP (y, 0);
  3357.  
  3358.       return gen_rtx (CONST, VOIDmode, gen_rtx (PLUS, Pmode, x, y));
  3359.     }
  3360.  
  3361.   return gen_rtx (PLUS, Pmode, x, y);
  3362. }
  3363.  
  3364. /* If ADDR is a sum containing a pseudo register that should be
  3365.    replaced with a constant (from reg_equiv_constant),
  3366.    return the result of doing so, and also apply the associative
  3367.    law so that the result is more likely to be a valid address.
  3368.    (But it is not guaranteed to be one.)
  3369.  
  3370.    Note that at most one register is replaced, even if more are
  3371.    replaceable.  Also, we try to put the result into a canonical form
  3372.    so it is more likely to be a valid address.
  3373.  
  3374.    In all other cases, return ADDR.  */
  3375.  
  3376. static rtx
  3377. subst_indexed_address (addr)
  3378.      rtx addr;
  3379. {
  3380.   rtx op0 = 0, op1 = 0, op2 = 0;
  3381.   rtx tem;
  3382.   int regno;
  3383.  
  3384.   if (GET_CODE (addr) == PLUS)
  3385.     {
  3386.       /* Try to find a register to replace.  */
  3387.       op0 = XEXP (addr, 0), op1 = XEXP (addr, 1), op2 = 0;
  3388.       if (GET_CODE (op0) == REG
  3389.       && (regno = REGNO (op0)) >= FIRST_PSEUDO_REGISTER
  3390.       && reg_renumber[regno] < 0
  3391.       && reg_equiv_constant[regno] != 0)
  3392.     op0 = reg_equiv_constant[regno];
  3393.       else if (GET_CODE (op1) == REG
  3394.       && (regno = REGNO (op1)) >= FIRST_PSEUDO_REGISTER
  3395.       && reg_renumber[regno] < 0
  3396.       && reg_equiv_constant[regno] != 0)
  3397.     op1 = reg_equiv_constant[regno];
  3398.       else if (GET_CODE (op0) == PLUS
  3399.            && (tem = subst_indexed_address (op0)) != op0)
  3400.     op0 = tem;
  3401.       else if (GET_CODE (op1) == PLUS
  3402.            && (tem = subst_indexed_address (op1)) != op1)
  3403.     op1 = tem;
  3404.       else
  3405.     return addr;
  3406.  
  3407.       /* Pick out up to three things to add.  */
  3408.       if (GET_CODE (op1) == PLUS)
  3409.     op2 = XEXP (op1, 1), op1 = XEXP (op1, 0);
  3410.       else if (GET_CODE (op0) == PLUS)
  3411.     op2 = op1, op1 = XEXP (op0, 1), op0 = XEXP (op0, 0);
  3412.  
  3413.       /* Compute the sum.  */
  3414.       if (op2 != 0)
  3415.     op1 = form_sum (op1, op2);
  3416.       if (op1 != 0)
  3417.     op0 = form_sum (op0, op1);
  3418.  
  3419.       return op0;
  3420.     }
  3421.   return addr;
  3422. }
  3423.  
  3424. /* Record the pseudo registers we must reload into hard registers
  3425.    in a subexpression of a would-be memory address, X.
  3426.    (This function is not called if the address we find is strictly valid.)
  3427.    CONTEXT = 1 means we are considering regs as index regs,
  3428.    = 0 means we are considering them as base regs.
  3429.  
  3430.    OPERAND is the operand of the insn within which this address appears.
  3431.  
  3432.    IND_LEVELS says how many levels of indirect addressing are
  3433.    supported at this point in the address.
  3434.  
  3435.    We return nonzero if X, as a whole, is reloaded or replaced.  */
  3436.  
  3437. /* Note that we take shortcuts assuming that no multi-reg machine mode
  3438.    occurs as part of an address.
  3439.    Also, this is not fully machine-customizable; it works for machines
  3440.    such as vaxes and 68000's and 32000's, but other possible machines
  3441.    could have addressing modes that this does not handle right.  */
  3442.  
  3443. static int
  3444. find_reloads_address_1 (x, context, loc, operand, ind_levels)
  3445.      rtx x;
  3446.      int context;
  3447.      rtx *loc;
  3448.      rtx operand;
  3449.      int ind_levels;
  3450. {
  3451.   register RTX_CODE code = GET_CODE (x);
  3452.  
  3453.   if (code == PLUS)
  3454.     {
  3455.       register rtx op0 = XEXP (x, 0);
  3456.       register rtx op1 = XEXP (x, 1);
  3457.       register RTX_CODE code0 = GET_CODE (op0);
  3458.       register RTX_CODE code1 = GET_CODE (op1);
  3459.       if (code0 == MULT || code0 == SIGN_EXTEND || code1 == MEM)
  3460.     {
  3461.       find_reloads_address_1 (op0, 1, &XEXP (x, 0), operand, ind_levels);
  3462.       find_reloads_address_1 (op1, 0, &XEXP (x, 1), operand, ind_levels);
  3463.     }
  3464.       else if (code1 == MULT || code1 == SIGN_EXTEND || code0 == MEM)
  3465.     {
  3466.       find_reloads_address_1 (op0, 0, &XEXP (x, 0), operand, ind_levels);
  3467.       find_reloads_address_1 (op1, 1, &XEXP (x, 1), operand, ind_levels);
  3468.     }
  3469.       else if (code0 == CONST_INT || code0 == CONST
  3470.            || code0 == SYMBOL_REF || code0 == LABEL_REF)
  3471.     {
  3472.       find_reloads_address_1 (op1, 0, &XEXP (x, 1), operand, ind_levels);
  3473.     }
  3474.       else if (code1 == CONST_INT || code1 == CONST
  3475.            || code1 == SYMBOL_REF || code1 == LABEL_REF)
  3476.     {
  3477.       find_reloads_address_1 (op0, 0, &XEXP (x, 0), operand, ind_levels);
  3478.     }
  3479.       else if (code0 == REG && code1 == REG)
  3480.     {
  3481.       if (REG_OK_FOR_INDEX_P (op0)
  3482.           && REG_OK_FOR_BASE_P (op1))
  3483.         return 0;
  3484.       else if (REG_OK_FOR_INDEX_P (op1)
  3485.           && REG_OK_FOR_BASE_P (op0))
  3486.         return 0;
  3487.       else if (REG_OK_FOR_BASE_P (op1))
  3488.         find_reloads_address_1 (op0, 1, &XEXP (x, 0), operand, ind_levels);
  3489.       else if (REG_OK_FOR_BASE_P (op0))
  3490.         find_reloads_address_1 (op1, 1, &XEXP (x, 1), operand, ind_levels);
  3491.       else if (REG_OK_FOR_INDEX_P (op1))
  3492.         find_reloads_address_1 (op0, 0, &XEXP (x, 0), operand, ind_levels);
  3493.       else if (REG_OK_FOR_INDEX_P (op0))
  3494.         find_reloads_address_1 (op1, 0, &XEXP (x, 1), operand, ind_levels);
  3495.       else
  3496.         {
  3497.           find_reloads_address_1 (op0, 1, &XEXP (x, 0), operand,
  3498.                       ind_levels);
  3499.           find_reloads_address_1 (op1, 0, &XEXP (x, 1), operand,
  3500.                       ind_levels);
  3501.         }
  3502.     }
  3503.       else if (code0 == REG)
  3504.     {
  3505.       find_reloads_address_1 (op0, 1, &XEXP (x, 0), operand, ind_levels);
  3506.       find_reloads_address_1 (op1, 0, &XEXP (x, 1), operand, ind_levels);
  3507.     }
  3508.       else if (code1 == REG)
  3509.     {
  3510.       find_reloads_address_1 (op1, 1, &XEXP (x, 1), operand, ind_levels);
  3511.       find_reloads_address_1 (op0, 0, &XEXP (x, 0), operand, ind_levels);
  3512.     }
  3513.     }
  3514.   else if (code == POST_INC || code == POST_DEC
  3515.        || code == PRE_INC || code == PRE_DEC)
  3516.     {
  3517.       if (GET_CODE (XEXP (x, 0)) == REG)
  3518.     {
  3519.       register int regno = REGNO (XEXP (x, 0));
  3520.       int value = 0;
  3521.       rtx x_orig = x;
  3522.  
  3523.       /* A register that is incremented cannot be constant!  */
  3524.       if (regno >= FIRST_PSEUDO_REGISTER
  3525.           && reg_equiv_constant[regno] != 0)
  3526.         abort ();
  3527.  
  3528.       /* Handle a register that is equivalent to a memory location
  3529.          which cannot be addressed directly.  */
  3530.       if (reg_equiv_address[regno] != 0)
  3531.         {
  3532.           rtx tem = make_memloc (XEXP (x, 0), regno);
  3533.           /* First reload the memory location's address.  */
  3534.           find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0),
  3535.                     &XEXP (tem, 0), operand, ind_levels);
  3536.           /* Put this inside a new increment-expression.  */
  3537.           x = gen_rtx (GET_CODE (x), GET_MODE (x), tem);
  3538.           /* Proceed to reload that, as if it contained a register.  */
  3539.         }
  3540.  
  3541.       /* If we have a hard register that is ok as an index,
  3542.          don't make a reload.  If an autoincrement of a nice register
  3543.          isn't "valid", it must be that no autoincrement is "valid".
  3544.          If that is true and something made an autoincrement anyway,
  3545.          this must be a special context where one is allowed.
  3546.          (For example, a "push" instruction.)
  3547.          We can't improve this address, so leave it alone.  */
  3548.  
  3549.       /* Otherwise, reload the autoincrement into a suitable hard reg
  3550.          and record how much to increment by.  */
  3551.  
  3552.       if (reg_renumber[regno] >= 0)
  3553.         regno = reg_renumber[regno];
  3554.       if ((regno >= FIRST_PSEUDO_REGISTER
  3555.            || !(context ? REGNO_OK_FOR_INDEX_P (regno)
  3556.             : REGNO_OK_FOR_BASE_P (regno))))
  3557.         {
  3558.           register rtx link;
  3559.  
  3560.           int reloadnum
  3561.         = push_reload (x, 0, loc, 0,
  3562.                    context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3563.                    GET_MODE (x), GET_MODE (x), VOIDmode, 0, operand);
  3564.           reload_inc[reloadnum]
  3565.         = find_inc_amount (PATTERN (this_insn), XEXP (x_orig, 0));
  3566.  
  3567.           value = 1;
  3568.  
  3569. #ifdef AUTO_INC_DEC
  3570.           /* Update the REG_INC notes.  */
  3571.  
  3572.           for (link = REG_NOTES (this_insn);
  3573.            link; link = XEXP (link, 1))
  3574.         if (REG_NOTE_KIND (link) == REG_INC
  3575.             && REGNO (XEXP (link, 0)) == REGNO (XEXP (x_orig, 0)))
  3576.           push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
  3577. #endif
  3578.         }
  3579.       return value;
  3580.     }
  3581.       else if (GET_CODE (XEXP (x, 0)) == MEM)
  3582.     {
  3583.       /* This is probably the result of a substitution, by eliminate_regs,
  3584.          of an equivalent address for a pseudo that was not allocated to a
  3585.          hard register.  Verify that the specified address is valid and
  3586.          reload it into a register.  */
  3587.       rtx tem = XEXP (x, 0);
  3588.       register rtx link;
  3589.       int reloadnum;
  3590.  
  3591.       /* Since we know we are going to reload this item, don't decrement
  3592.          for the indirection level.
  3593.  
  3594.          Note that this is actually conservative:  it would be slightly
  3595.          more efficient to use the value of SPILL_INDIRECT_LEVELS from
  3596.          reload1.c here.  */
  3597.       find_reloads_address (GET_MODE (x), &XEXP (x, 0),
  3598.                 XEXP (XEXP (x, 0), 0), &XEXP (XEXP (x, 0), 0),
  3599.                 operand, ind_levels);
  3600.  
  3601.       reloadnum = push_reload (x, 0, loc, 0,
  3602.                    context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3603.                    GET_MODE (x), VOIDmode, 0, 0, operand);
  3604.       reload_inc[reloadnum]
  3605.         = find_inc_amount (PATTERN (this_insn), XEXP (x, 0));
  3606.  
  3607.       link = FIND_REG_INC_NOTE (this_insn, tem);
  3608.       if (link != 0)
  3609.         push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
  3610.  
  3611.       return 1;
  3612.     }
  3613.     }
  3614.   else if (code == MEM)
  3615.     {
  3616.       /* This is probably the result of a substitution, by eliminate_regs,
  3617.      of an equivalent address for a pseudo that was not allocated to a
  3618.      hard register.  Verify that the specified address is valid and reload
  3619.      it into a register.
  3620.  
  3621.      Since we know we are going to reload this item, don't decrement
  3622.      for the indirection level.
  3623.  
  3624.      Note that this is actually conservative:  it would be slightly more
  3625.      efficient to use the value of SPILL_INDIRECT_LEVELS from
  3626.      reload1.c here.  */
  3627.  
  3628.       find_reloads_address (GET_MODE (x), loc, XEXP (x, 0), &XEXP (x, 0),
  3629.                 operand, ind_levels);
  3630.  
  3631.       push_reload (*loc, 0, loc, 0,
  3632.            context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3633.            GET_MODE (x), VOIDmode, 0, 0, operand);
  3634.       return 1;
  3635.     }
  3636.   else if (code == REG)
  3637.     {
  3638.       register int regno = REGNO (x);
  3639.  
  3640.       if (reg_equiv_constant[regno] != 0)
  3641.     {
  3642.       push_reload (reg_equiv_constant[regno], 0, loc, 0,
  3643.                context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3644.                GET_MODE (x), VOIDmode, 0, 0, operand);
  3645.       return 1;
  3646.     }
  3647.  
  3648. #if 0 /* This might screw code in reload1.c to delete prior output-reload
  3649.      that feeds this insn.  */
  3650.       if (reg_equiv_mem[regno] != 0)
  3651.     {
  3652.       push_reload (reg_equiv_mem[regno], 0, loc, 0,
  3653.                context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3654.                GET_MODE (x), VOIDmode, 0, 0, operand);
  3655.       return 1;
  3656.     }
  3657. #endif
  3658.       if (reg_equiv_address[regno] != 0)
  3659.     {
  3660.       x = make_memloc (x, regno);
  3661.       find_reloads_address (GET_MODE (x), 0, XEXP (x, 0), &XEXP (x, 0),
  3662.                 operand, ind_levels);
  3663.     }
  3664.  
  3665.       if (reg_renumber[regno] >= 0)
  3666.     regno = reg_renumber[regno];
  3667.       if ((regno >= FIRST_PSEUDO_REGISTER
  3668.        || !(context ? REGNO_OK_FOR_INDEX_P (regno)
  3669.         : REGNO_OK_FOR_BASE_P (regno))))
  3670.     {
  3671.       push_reload (x, 0, loc, 0,
  3672.                context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3673.                GET_MODE (x), VOIDmode, 0, 0, operand);
  3674.       return 1;
  3675.     }
  3676.  
  3677.       /* If a register appearing in an address is the subject of a CLOBBER
  3678.      in this insn, reload it into some other register to be safe.
  3679.      The CLOBBER is supposed to make the register unavailable
  3680.      from before this insn to after it.  */
  3681.       if (regno_clobbered_p (regno, this_insn))
  3682.     {
  3683.       push_reload (x, 0, loc, 0,
  3684.                context ? INDEX_REG_CLASS : BASE_REG_CLASS,
  3685.                GET_MODE (x), VOIDmode, 0, 0, operand);
  3686.       return 1;
  3687.     }
  3688.     }
  3689.   else
  3690.     {
  3691.       register char *fmt = GET_RTX_FORMAT (code);
  3692.       register int i;
  3693.       for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3694.     {
  3695.       if (fmt[i] == 'e')
  3696.         find_reloads_address_1 (XEXP (x, i), context, &XEXP (x, i),
  3697.                     operand, ind_levels);
  3698.     }
  3699.     }
  3700.  
  3701.   return 0;
  3702. }
  3703.  
  3704. /* Substitute into X the registers into which we have reloaded
  3705.    the things that need reloading.  The array `replacements'
  3706.    says contains the locations of all pointers that must be changed
  3707.    and says what to replace them with.
  3708.  
  3709.    Return the rtx that X translates into; usually X, but modified.  */
  3710.  
  3711. void
  3712. subst_reloads ()
  3713. {
  3714.   register int i;
  3715.  
  3716.   for (i = 0; i < n_replacements; i++)
  3717.     {
  3718.       register struct replacement *r = &replacements[i];
  3719.       register rtx reloadreg = reload_reg_rtx[r->what];
  3720.       if (reloadreg)
  3721.     {
  3722.       /* Encapsulate RELOADREG so its machine mode matches what
  3723.          used to be there.  */
  3724.       if (GET_MODE (reloadreg) != r->mode && r->mode != VOIDmode)
  3725.         reloadreg = gen_rtx (REG, r->mode, REGNO (reloadreg));
  3726.  
  3727. #if 0
  3728.       /* If we are putting this into a SUBREG and RELOADREG is a
  3729.          SUBREG, we would be making nested SUBREGs, so we have to fix
  3730.          this up.  Note that r->where == &SUBREG_REG (*r->subreg_loc).  */
  3731.  
  3732.       if (r->subreg_loc != 0 && GET_CODE (reloadreg) == SUBREG)
  3733.         {
  3734.           if (GET_MODE (*r->subreg_loc)
  3735.           == GET_MODE (SUBREG_REG (reloadreg)))
  3736.         *r->subreg_loc = SUBREG_REG (reloadreg);
  3737.           else
  3738.         {
  3739.           *r->where = SUBREG_REG (reloadreg);
  3740.           SUBREG_WORD (*r->subreg_loc) += SUBREG_WORD (reloadreg);
  3741.         }
  3742.         }
  3743.       else
  3744. #endif
  3745.         *r->where = reloadreg;
  3746.     }
  3747.       /* If reload got no reg and isn't optional, something's wrong.  */
  3748.       else if (! reload_optional[r->what])
  3749.     abort ();
  3750.     }
  3751. }
  3752.  
  3753. #if 0
  3754.  
  3755. /* [[This function is currently obsolete, now that volatility
  3756.    is represented by a special bit `volatil' so VOLATILE is never used;
  3757.    and UNCHANGING has never been brought into use.]]
  3758.  
  3759.    Alter X by eliminating all VOLATILE and UNCHANGING expressions.
  3760.    Each of them is replaced by its operand.
  3761.    Thus, (PLUS (VOLATILE (MEM (REG 5))) (CONST_INT 4))
  3762.    becomes (PLUS (MEM (REG 5)) (CONST_INT 4)).
  3763.  
  3764.    If X is itself a VOLATILE expression,
  3765.    we return the expression that should replace it
  3766.    but we do not modify X.  */
  3767.  
  3768. static rtx
  3769. forget_volatility (x)
  3770.      register rtx x;
  3771. {
  3772.   enum rtx_code code = GET_CODE (x);
  3773.   register char *fmt;
  3774.   register int i;
  3775.   register rtx value = 0;
  3776.  
  3777.   switch (code)
  3778.     {
  3779.     case LABEL_REF:
  3780.     case SYMBOL_REF:
  3781.     case CONST_INT:
  3782.     case CONST_DOUBLE:
  3783.     case CONST:
  3784.     case REG:
  3785.     case CC0:
  3786.     case PC:
  3787.       return x;
  3788.  
  3789.     case VOLATILE:
  3790.     case UNCHANGING:
  3791.       return XEXP (x, 0);
  3792.     }
  3793.  
  3794.   fmt = GET_RTX_FORMAT (code);
  3795.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3796.     {
  3797.       if (fmt[i] == 'e')
  3798.     XEXP (x, i) = forget_volatility (XEXP (x, i));
  3799.       if (fmt[i] == 'E')
  3800.     {
  3801.       register int j;
  3802.       for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  3803.         XVECEXP (x, i, j) = forget_volatility (XVECEXP (x, i, j));
  3804.     }
  3805.     }
  3806.  
  3807.   return x;
  3808. }
  3809.  
  3810. #endif
  3811.  
  3812. /* Check the insns before INSN to see if there is a suitable register
  3813.    containing the same value as GOAL.
  3814.    If OTHER is -1, look for a register in class CLASS.
  3815.    Otherwise, just see if register number OTHER shares GOAL's value.
  3816.  
  3817.    Return an rtx for the register found, or zero if none is found.
  3818.  
  3819.    If RELOAD_REG_P is (short *)1,
  3820.    we reject any hard reg that appears in reload_reg_rtx
  3821.    because such a hard reg is also needed coming into this insn.
  3822.  
  3823.    If RELOAD_REG_P is any other nonzero value,
  3824.    it is a vector indexed by hard reg number
  3825.    and we reject any hard reg whose element in the vector is nonnegative
  3826.    as well as any that appears in reload_reg_rtx.
  3827.  
  3828.    If GOAL is zero, then GOALREG is a register number; we look
  3829.    for an equivalent for that register.
  3830.  
  3831.    MODE is the machine mode of the value we want an equivalence for.
  3832.    If GOAL is nonzero and not VOIDmode, then it must have mode MODE.
  3833.  
  3834.    This function is used by jump.c as well as in the reload pass.
  3835.  
  3836.    If GOAL is the sum of the stack pointer and a constant, we treat it
  3837.    as if it were a constant except that sp is required to be unchanging.  */
  3838.  
  3839. rtx
  3840. find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
  3841.      register rtx goal;
  3842.      rtx insn;
  3843.      enum reg_class class;
  3844.      register int other;
  3845.      short *reload_reg_p;
  3846.      int goalreg;
  3847.      enum machine_mode mode;
  3848. {
  3849.   register rtx p = insn;
  3850.   rtx valtry, value, where;
  3851.   register rtx pat;
  3852.   register int regno = -1;
  3853.   int valueno;
  3854.   int goal_mem = 0;
  3855.   int goal_const = 0;
  3856.   int goal_mem_addr_varies = 0;
  3857.   int need_stable_sp = 0;
  3858.   int nregs;
  3859.   int valuenregs;
  3860.  
  3861.   if (goal == 0)
  3862.     regno = goalreg;
  3863.   else if (GET_CODE (goal) == REG)
  3864.     regno = REGNO (goal);
  3865.   else if (GET_CODE (goal) == MEM)
  3866.     {
  3867.       enum rtx_code code = GET_CODE (XEXP (goal, 0));
  3868.       if (MEM_VOLATILE_P (goal))
  3869.     return 0;
  3870.       if (flag_float_store
  3871.       && (GET_MODE (goal) == DFmode || GET_MODE (goal) == SFmode))
  3872.     return 0;
  3873.       /* An address with side effects must be reexecuted.  */
  3874.       switch (code)
  3875.     {
  3876.     case POST_INC:
  3877.     case PRE_INC:
  3878.     case POST_DEC:
  3879.     case PRE_DEC:
  3880.       return 0;
  3881.     }
  3882.       goal_mem = 1;
  3883.     }
  3884.   else if (CONSTANT_P (goal))
  3885.     goal_const = 1;
  3886.   else if (GET_CODE (goal) == PLUS
  3887.        && XEXP (goal, 0) == stack_pointer_rtx
  3888.        && CONSTANT_P (XEXP (goal, 1)))
  3889.     goal_const = need_stable_sp = 1;
  3890.   else
  3891.     return 0;
  3892.  
  3893.   /* On some machines, certain regs must always be rejected
  3894.      because they don't behave the way ordinary registers do.  */
  3895.   
  3896. #ifdef OVERLAPPING_REGNO_P
  3897.    if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  3898.        && OVERLAPPING_REGNO_P (regno))
  3899.      return 0;
  3900. #endif      
  3901.  
  3902.   /* Scan insns back from INSN, looking for one that copies
  3903.      a value into or out of GOAL.
  3904.      Stop and give up if we reach a label.  */
  3905.  
  3906.   while (1)
  3907.     {
  3908.       p = PREV_INSN (p);
  3909.       if (p == 0 || GET_CODE (p) == CODE_LABEL)
  3910.     return 0;
  3911.       if (GET_CODE (p) == INSN
  3912.       /* If we don't want spill regs ... */
  3913.       && (! (reload_reg_p != 0 && reload_reg_p != (short *)1)
  3914.       /* ... then ignore insns introduced by reload; they aren't useful
  3915.          and can cause results in reload_as_needed to be different
  3916.          from what they were when calculating the need for spills.
  3917.          If we notice an input-reload insn here, we will reject it below,
  3918.          but it might hide a usable equivalent.  That makes bad code.
  3919.          It may even abort: perhaps no reg was spilled for this insn
  3920.          because it was assumed we would find that equivalent.  */
  3921.           || INSN_UID (p) < reload_first_uid))
  3922.     {
  3923.       pat = PATTERN (p);
  3924.       /* First check for something that sets some reg equal to GOAL.  */
  3925.       if (GET_CODE (pat) == SET
  3926.           && ((regno >= 0
  3927.            && true_regnum (SET_SRC (pat)) == regno
  3928.            && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
  3929.           ||
  3930.           (regno >= 0
  3931.            && true_regnum (SET_DEST (pat)) == regno
  3932.            && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0)
  3933.           ||
  3934.           (goal_const && rtx_equal_p (SET_SRC (pat), goal)
  3935.            && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
  3936.           || (goal_mem
  3937.               && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0
  3938.               && rtx_renumbered_equal_p (goal, SET_SRC (pat)))
  3939.           || (goal_mem
  3940.               && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0
  3941.               && rtx_renumbered_equal_p (goal, SET_DEST (pat)))))
  3942.         if (other >= 0
  3943.         ? valueno == other
  3944.         : ((unsigned) valueno < FIRST_PSEUDO_REGISTER
  3945.            && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
  3946.                      valueno)))
  3947.           {
  3948.         value = valtry;
  3949.         where = p;
  3950.         break;
  3951.           }
  3952.     }
  3953.     }
  3954.  
  3955.   /* We found a previous insn copying GOAL into a suitable other reg VALUE
  3956.      (or copying VALUE into GOAL, if GOAL is also a register).
  3957.      Now verify that VALUE is really valid.  */
  3958.  
  3959.   /* VALUENO is the register number of VALUE; a hard register.  */
  3960.  
  3961.   /* Don't try to re-use something that is killed in this insn.  We want
  3962.      to be able to trust REG_UNUSED notes.  */
  3963.   if (find_reg_note (where, REG_UNUSED, value))
  3964.     return 0;
  3965.  
  3966.   /* If we propose to get the value from the stack pointer or if GOAL is
  3967.      a MEM based on the stack pointer, we need a stable SP.  */
  3968.   if (valueno == STACK_POINTER_REGNUM
  3969.       || (goal_mem && reg_overlap_mentioned_p (stack_pointer_rtx, goal)))
  3970.     need_stable_sp = 1;
  3971.  
  3972.   /* Reject VALUE if the copy-insn moved the wrong sort of datum.  */
  3973.   if (GET_MODE (value) != mode)
  3974.     return 0;
  3975.  
  3976.   /* Reject VALUE if it was loaded from GOAL
  3977.      and is also a register that appears in the address of GOAL.  */
  3978.  
  3979.   if (goal_mem && value == SET_DEST (PATTERN (where))
  3980.       && refers_to_regno_p (valueno,
  3981.                 valueno + HARD_REGNO_NREGS (valueno, mode),
  3982.                 goal, 0))
  3983.     return 0;
  3984.  
  3985.   /* Reject registers that overlap GOAL.  */
  3986.  
  3987.   if (!goal_mem && !goal_const
  3988.       && regno + HARD_REGNO_NREGS (regno, mode) > valueno
  3989.       && regno < valueno + HARD_REGNO_NREGS (valueno, mode))
  3990.     return 0;
  3991.  
  3992.   /* Reject VALUE if it is one of the regs reserved for reloads.
  3993.      Reload1 knows how to reuse them anyway, and it would get
  3994.      confused if we allocated one without its knowledge.
  3995.      (Now that insns introduced by reload are ignored above,
  3996.      this case shouldn't happen, but I'm not positive.)  */
  3997.  
  3998.   if (reload_reg_p != 0 && reload_reg_p != (short *)1
  3999.       && reload_reg_p[valueno] >= 0)
  4000.     return 0;
  4001.  
  4002.   /* On some machines, certain regs must always be rejected
  4003.      because they don't behave the way ordinary registers do.  */
  4004.   
  4005. #ifdef OVERLAPPING_REGNO_P
  4006.   if (OVERLAPPING_REGNO_P (valueno))
  4007.     return 0;
  4008. #endif      
  4009.  
  4010.   nregs = HARD_REGNO_NREGS (regno, mode);
  4011.   valuenregs = HARD_REGNO_NREGS (valueno, mode);
  4012.  
  4013.   /* Reject VALUE if it is a register being used for an input reload
  4014.      even if it is not one of those reserved.  */
  4015.  
  4016.   if (reload_reg_p != 0)
  4017.     {
  4018.       int i;
  4019.       for (i = 0; i < n_reloads; i++)
  4020.     if (reload_reg_rtx[i] != 0 && reload_in[i])
  4021.       {
  4022.         int regno1 = REGNO (reload_reg_rtx[i]);
  4023.         int nregs1 = HARD_REGNO_NREGS (regno1,
  4024.                        GET_MODE (reload_reg_rtx[i]));
  4025.         if (regno1 < valueno + valuenregs
  4026.         && regno1 + nregs1 > valueno)
  4027.           return 0;
  4028.       }
  4029.     }
  4030.  
  4031.   if (goal_mem)
  4032.     goal_mem_addr_varies = rtx_addr_varies_p (goal);
  4033.  
  4034.   /* Now verify that the values of GOAL and VALUE remain unaltered
  4035.      until INSN is reached.  */
  4036.  
  4037.   p = insn;
  4038.   while (1)
  4039.     {
  4040.       p = PREV_INSN (p);
  4041.       if (p == where)
  4042.     return value;
  4043.  
  4044.       /* Don't trust the conversion past a function call
  4045.      if either of the two is in a call-clobbered register, or memory.  */
  4046.       if (GET_CODE (p) == CALL_INSN
  4047.       && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  4048.            && call_used_regs[regno])
  4049.           ||
  4050.           (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
  4051.            && call_used_regs[valueno])
  4052.           ||
  4053.           goal_mem
  4054.           || need_stable_sp))
  4055.     return 0;
  4056.  
  4057. #ifdef INSN_CLOBBERS_REGNO_P
  4058.       if ((valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
  4059.       && INSN_CLOBBERS_REGNO_P (p, valueno))
  4060.       || (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
  4061.       && INSN_CLOBBERS_REGNO_P (p, regno)))
  4062.     return 0;
  4063. #endif
  4064.  
  4065.       if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
  4066.       || GET_CODE (p) == CALL_INSN)
  4067.     {
  4068.       /* If this insn P stores in either GOAL or VALUE, return 0.
  4069.          If GOAL is a memory ref and this insn writes memory, return 0.
  4070.          If GOAL is a memory ref and its address is not constant,
  4071.          and this insn P changes a register, return 0.
  4072.          That is in lieue of checking whether GOAL uses this register.  */
  4073.  
  4074.       pat = PATTERN (p);
  4075.       if (GET_CODE (pat) == SET || GET_CODE (pat) == CLOBBER)
  4076.         {
  4077.           register rtx dest = SET_DEST (pat);
  4078.           while (GET_CODE (dest) == SUBREG
  4079.              || GET_CODE (dest) == ZERO_EXTRACT
  4080.              || GET_CODE (dest) == SIGN_EXTRACT
  4081.              || GET_CODE (dest) == STRICT_LOW_PART)
  4082.         dest = XEXP (dest, 0);
  4083.           if (GET_CODE (dest) == REG)
  4084.         {
  4085.           register int xregno = REGNO (dest);
  4086.           int xnregs;
  4087.           if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
  4088.             xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
  4089.           else
  4090.             xnregs = 1;
  4091.           if (xregno < regno + nregs && xregno + xnregs > regno)
  4092.             return 0;
  4093.           if (xregno < valueno + valuenregs
  4094.               && xregno + xnregs > valueno)
  4095.             return 0;
  4096.           if (goal_mem_addr_varies)
  4097.             return 0;
  4098.         }
  4099.           else if (goal_mem && GET_CODE (dest) == MEM
  4100.                && ! push_operand (dest, GET_MODE (dest)))
  4101.         return 0;
  4102.           else if (need_stable_sp && push_operand (dest, GET_MODE (dest)))
  4103.         return 0;
  4104.         }
  4105.       else if (GET_CODE (pat) == PARALLEL)
  4106.         {
  4107.           register int i;
  4108.           for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)
  4109.         {
  4110.           register rtx v1 = XVECEXP (pat, 0, i);
  4111.           if (GET_CODE (v1) == SET || GET_CODE (v1) == CLOBBER)
  4112.             {
  4113.               register rtx dest = SET_DEST (v1);
  4114.               while (GET_CODE (dest) == SUBREG
  4115.                  || GET_CODE (dest) == ZERO_EXTRACT
  4116.                  || GET_CODE (dest) == SIGN_EXTRACT
  4117.                  || GET_CODE (dest) == STRICT_LOW_PART)
  4118.             dest = XEXP (dest, 0);
  4119.               if (GET_CODE (dest) == REG)
  4120.             {
  4121.               register int xregno = REGNO (dest);
  4122.               int xnregs;
  4123.               if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
  4124.                 xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
  4125.               else
  4126.                 xnregs = 1;
  4127.               if (xregno < regno + nregs
  4128.                   && xregno + xnregs > regno)
  4129.                 return 0;
  4130.               if (xregno < valueno + valuenregs
  4131.                   && xregno + xnregs > valueno)
  4132.                 return 0;
  4133.               if (goal_mem_addr_varies)
  4134.                 return 0;
  4135.             }
  4136.               else if (goal_mem && GET_CODE (dest) == MEM
  4137.                    && ! push_operand (dest, GET_MODE (dest)))
  4138.             return 0;
  4139.               else if (need_stable_sp
  4140.                    && push_operand (dest, GET_MODE (dest)))
  4141.             return 0;
  4142.             }
  4143.         }
  4144.         }
  4145.  
  4146. #ifdef AUTO_INC_DEC
  4147.       /* If this insn auto-increments or auto-decrements
  4148.          either regno or valueno, return 0 now.
  4149.          If GOAL is a memory ref and its address is not constant,
  4150.          and this insn P increments a register, return 0.
  4151.          That is in lieue of checking whether GOAL uses this register.  */
  4152.       {
  4153.         register rtx link;
  4154.  
  4155.         for (link = REG_NOTES (p); link; link = XEXP (link, 1))
  4156.           if (REG_NOTE_KIND (link) == REG_INC)
  4157.         {
  4158.           register int incno = REGNO (XEXP (link, 0));
  4159.           if (incno < regno + nregs && incno >= regno)
  4160.             return 0;
  4161.           if (incno < valueno + valuenregs && incno >= valueno)
  4162.             return 0;
  4163.           if (goal_mem_addr_varies)
  4164.             return 0;
  4165.         }
  4166.       }
  4167. #endif
  4168.     }
  4169.     }
  4170. }
  4171.  
  4172. /* Find a place where INCED appears in an increment or decrement operator
  4173.    within X, and return the amount INCED is incremented or decremented by.
  4174.    The value is always positive.  */
  4175.  
  4176. static int
  4177. find_inc_amount (x, inced)
  4178.      rtx x, inced;
  4179. {
  4180.   register enum rtx_code code = GET_CODE (x);
  4181.   register char *fmt;
  4182.   register int i;
  4183.  
  4184.   if (code == MEM)
  4185.     {
  4186.       register rtx addr = XEXP (x, 0);
  4187.       if ((GET_CODE (addr) == PRE_DEC
  4188.        || GET_CODE (addr) == POST_DEC
  4189.        || GET_CODE (addr) == PRE_INC
  4190.        || GET_CODE (addr) == POST_INC)
  4191.       && XEXP (addr, 0) == inced)
  4192.     return GET_MODE_SIZE (GET_MODE (x));
  4193.     }
  4194.  
  4195.   fmt = GET_RTX_FORMAT (code);
  4196.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  4197.     {
  4198.       if (fmt[i] == 'e')
  4199.     {
  4200.       register int tem = find_inc_amount (XEXP (x, i), inced);
  4201.       if (tem != 0)
  4202.         return tem;
  4203.     }
  4204.       if (fmt[i] == 'E')
  4205.     {
  4206.       register int j;
  4207.       for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  4208.         {
  4209.           register int tem = find_inc_amount (XVECEXP (x, i, j), inced);
  4210.           if (tem != 0)
  4211.         return tem;
  4212.         }
  4213.     }
  4214.     }
  4215.  
  4216.   return 0;
  4217. }
  4218.  
  4219. /* Return 1 if register REGNO is the subject of a clobber in insn INSN.  */
  4220.  
  4221. int
  4222. regno_clobbered_p (regno, insn)
  4223.      int regno;
  4224.      rtx insn;
  4225. {
  4226.   if (GET_CODE (PATTERN (insn)) == CLOBBER
  4227.       && GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
  4228.     return REGNO (XEXP (PATTERN (insn), 0)) == regno;
  4229.  
  4230.   if (GET_CODE (PATTERN (insn)) == PARALLEL)
  4231.     {
  4232.       int i = XVECLEN (PATTERN (insn), 0) - 1;
  4233.  
  4234.       for (; i >= 0; i--)
  4235.     {
  4236.       rtx elt = XVECEXP (PATTERN (insn), 0, i);
  4237.       if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG
  4238.           && REGNO (XEXP (elt, 0)) == regno)
  4239.         return 1;
  4240.     }
  4241.     }
  4242.  
  4243.   return 0;
  4244. }
  4245.