GCC Middle and Back End API Reference
reload.c File Reference

Data Structures

struct  replacement
struct  decomposition


static bool small_register_class_p ()
static int push_secondary_reload (int, rtx, int, int, enum reg_class, enum machine_mode, enum reload_type, enum insn_code *, secondary_reload_info *)
static enum reg_class find_valid_class (enum machine_mode, enum machine_mode, int, unsigned int)
static void push_replacement (rtx *, int, enum machine_mode)
static void dup_replacements (rtx *, rtx *)
static void combine_reloads (void)
static int find_reusable_reload (rtx *, rtx, enum reg_class, enum reload_type, int, int)
static rtx find_dummy_reload (rtx, rtx, rtx *, rtx *, enum machine_mode, enum machine_mode, reg_class_t, int, int)
static int hard_reg_set_here_p (unsigned int, unsigned int, rtx)
static struct decomposition decompose (rtx)
static int immune_p (rtx, rtx, struct decomposition)
static bool alternative_allows_const_pool_ref (rtx, const char *, int)
static rtx find_reloads_toplev (rtx, int, enum reload_type, int, int, rtx, int *)
static rtx make_memloc (rtx, int)
static int maybe_memory_address_addr_space_p (enum machine_mode, rtx, addr_space_t, rtx *)
static int find_reloads_address (enum machine_mode, rtx *, rtx, rtx *, int, enum reload_type, int, rtx)
static rtx subst_reg_equivs (rtx, rtx)
static rtx subst_indexed_address (rtx)
static void update_auto_inc_notes (rtx, int, int)
static int find_reloads_address_1 (enum machine_mode, addr_space_t, rtx, int, enum rtx_code, enum rtx_code, rtx *, int, enum reload_type, int, rtx)
static void find_reloads_address_part (rtx, rtx *, enum reg_class, enum machine_mode, int, enum reload_type, int)
static rtx find_reloads_subreg_address (rtx, int, enum reload_type, int, rtx, int *)
static void copy_replacements_1 (rtx *, rtx *, int)
static int find_inc_amount (rtx, rtx)
static int refers_to_mem_for_reload_p (rtx)
static int refers_to_regno_for_reload_p (unsigned int, unsigned int, rtx, rtx *)
static void push_reg_equiv_alt_mem ()
reg_class_t secondary_reload_class (bool in_p, reg_class_t rclass, enum machine_mode mode, rtx x)
enum reg_class scratch_reload_class ()
rtx get_secondary_mem (rtx x, enum machine_mode mode, int opnum, enum reload_type type)
void clear_secondary_mem ()
static enum reg_class find_valid_class_1 (enum machine_mode outer, enum machine_mode mode, enum reg_class dest_class)
static bool reload_inner_reg_of_subreg ()
static int can_reload_into ()
int push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc, enum reg_class rclass, enum machine_mode inmode, enum machine_mode outmode, int strict_low, int optional, int opnum, enum reload_type type)
static void push_replacement ()
static void dup_replacements ()
void transfer_replacements ()
int remove_address_replacements ()
int earlyclobber_operand_p ()
static int hard_reg_set_here_p ()
int strict_memory_address_addr_space_p (enum machine_mode mode, rtx addr, addr_space_t as)
int operands_match_p ()
static struct decomposition decompose ()
static int immune_p ()
int safe_from_earlyclobber ()
int find_reloads (rtx insn, int replace, int ind_levels, int live_known, short *reload_reg_p)
static rtx make_memloc ()
static rtx subst_reg_equivs ()
rtx form_sum ()
static rtx subst_indexed_address ()
void subst_reloads ()
void copy_replacements ()
static void copy_replacements_1 ()
void move_replacements ()
rtx find_replacement ()
int reg_overlap_mentioned_for_reload_p ()
static int refers_to_mem_for_reload_p ()
rtx find_equiv_reg (rtx goal, rtx insn, enum reg_class rclass, int other, short *reload_reg_p, int goalreg, enum machine_mode mode)
static int find_inc_amount ()
static int reg_inc_found_and_valid_p (unsigned int regno, unsigned int endregno, rtx insn)
int regno_clobbered_p (unsigned int regno, rtx insn, enum machine_mode mode, int sets)
rtx reload_adjust_reg_for_mode ()
DEBUG_FUNCTION void debug_reload_to_stream ()
DEBUG_FUNCTION void debug_reload ()


int n_reloads
struct reload rld [MAX_RELOADS]
int n_earlyclobbers
rtx reload_earlyclobbers [MAX_RECOG_OPERANDS]
int reload_n_operands
static int replace_reloads
static struct replacement replacements [MAX_RECOG_OPERANDS *((MAX_REGS_PER_ADDRESS *2)+1)]
static int n_replacements
static rtx secondary_memlocs [NUM_MACHINE_MODES]
static rtx secondary_memlocs_elim [NUM_MACHINE_MODES][MAX_RECOG_OPERANDS]
static int secondary_memlocs_elim_used = 0
static rtx this_insn
static int this_insn_is_asm
static int hard_regs_live_known
static short * static_reload_reg_p
static int subst_reg_equivs_changed
static int output_reloadnum
static const char *const reload_when_needed_name []

Function Documentation

static bool alternative_allows_const_pool_ref ( rtx  mem,
const char *  constraint,
int  altnum 
   Return true if alternative number ALTNUM in constraint-string
   CONSTRAINT is guaranteed to accept a reloaded constant-pool reference.
   MEM gives the reference if it didn't need any reloads, otherwise it
   is null.  
     Skip alternatives before the one requested.  
     Scan the requested alternative for TARGET_MEM_CONSTRAINT or 'o'.
     If one of them is present, this alternative accepts the result of
     passing a constant-pool reference through find_reloads_toplev.

     The same is true of extra memory constraints if the address
     was reloaded into a register.  However, the target may elect
     to disallow the original constant address, forcing it to be
     reloaded into a register instead.  
static int can_reload_into ( )
   Return nonzero if IN can be reloaded into REGNO with mode MODE without
   requiring an extra reload register.  The caller has already found that
   IN contains some reference to REGNO, so check that we can produce the
   new value in a single step.  E.g. if we have
   (set (reg r13) (plus (reg r13) (const int 1))), and there is an
   instruction that adds one to a register, this should succeed.
   However, if we have something like
   (set (reg r13) (plus (reg r13) (const int 999))), and the constant 999
   needs to be loaded into a register first, we need a separate reload
   Such PLUS reloads are generated by find_reload_address_part.
   The out-of-range PLUS expressions are usually introduced in the instruction
   patterns by register elimination and substituting pseudos without a home
   by their function-invariant equivalences.  
     For matching constraints, we often get notional input reloads where
     we want to use the original register as the reload register.  I.e.
     technically this is a non-optional input-output reload, but IN is
     already a valid register, and has been chosen as the reload register.
     Speed this up, since it trivially works.  
     To test MEMs properly, we'd have to take into account all the reloads
     that are already scheduled, which can become quite complicated.
     And since we've already handled address reloads for this MEM, it
     should always succeed anyway.  
     If we can make a simple SET insn that does the job, everything should
     be fine.  

References reg_renumber, replace_equiv_address_nv(), and rtx_equal_p().

void clear_secondary_mem ( void  )
   Clear any secondary memory locations we've made.  
static void combine_reloads ( )
   If there is only one output reload, and it is not for an earlyclobber
   operand, try to combine it with a (logically unrelated) input reload
   to reduce the number of reload registers needed.

   This is safe if the input reload does not appear in
   the value being output-reloaded, because this implies
   it is not needed any more once the original insn completes.

   If that doesn't work, see we can use any of the registers that
   die in this insn as a reload register.  We can if it is of the right
   class and does not appear in the value being output-reloaded.  
     Find the output reload; return unless there is exactly one
     and that one is mandatory.  
     An input-output reload isn't combinable.  
     If this reload is for an earlyclobber operand, we can't do anything.  
     If there is a reload for part of the address of this operand, we would
     need to change it to RELOAD_FOR_OTHER_ADDRESS.  But that would extend
     its life to the point where doing this combine would not lower the
     number of spill registers needed.  
     Check each input reload; can we combine it?  
           Life span of this reload must not extend past main insn.  
           Don't combine two reloads with different secondary
           memory locations.  
               Args reversed because the first arg seems to be
               the one that we imagine being modified
               while the second is the one that might be affected.  
                   However, if the input is a register that appears inside
                   the output, then we also can't share.
                   Imagine (set (mem (reg 69)) (plus (reg 69) ...)).
                   If the same reload reg is used for both reg 69 and the
                   result to be stored in memory, then that result
                   will clobber the address of the memory ref.  
           We will allow making things slightly worse by combining an
           input and an output, but no worse than that.  
           We have found a reload to combine with!  
           Mark the old output reload as inoperative.  
           The combined reload is needed for the entire insn.  
           If the output reload had a secondary reload, copy it.  
           Copy any secondary MEM.  
           If required, minimize the register class.  
           Transfer all replacements from the old reload to the combined.  
     If this insn has only one operand that is modified or written (assumed
     to be the first),  it must be the one corresponding to this reload.  It
     is safe to use anything that dies in this insn for that output provided
     that it does not occur in the output (we already know it isn't an
     earlyclobber.  If this is an asm insn, give up.  
     See if some hard register that dies in this insn and is not used in
     the output is the right class.  Only works if the register we pick
     up can fully hold our output reload.  
           Ensure that a secondary or tertiary reload for this output
           won't want this register.  
           Check that a former pseudo is valid; see find_dummy_reload.  
void copy_replacements ( )
   Make a copy of any replacements being done into X and move those
   copies to locations in Y, a copy of X.  

Referenced by set_storage_via_setmem().

static void copy_replacements_1 ( rtx ,
rtx ,
static void copy_replacements_1 ( )
DEBUG_FUNCTION void debug_reload ( void  )
DEBUG_FUNCTION void debug_reload_to_stream ( )
   These functions are used to print the variables set by 'find_reloads' 
static struct decomposition decompose ( rtx  )

Referenced by operands_match_p().

static struct decomposition decompose ( )
   Describe the range of registers or memory referenced by X.
   If X is a register, set REG_FLAG and put the first register
   number into START and the last plus one into END.
   If X is a memory reference, put a base address into BASE
   and a range of integer offsets into START and END.
   If X is pushing on the stack, we can assume it causes no trouble,
   so we set the SAFE field.  
             A pseudo with no hard reg.  
           A hard reg.  
           This could be more precise, but it's good enough.  
           A hard reg.  
         This hasn't been assigned yet, so it can't conflict yet.  
static void dup_replacements ( rtx ,
static void dup_replacements ( )
   Duplicate any replacement we have recorded to apply at
   location ORIG_LOC to also be performed at DUP_LOC.
   This is used in insn patterns that use match_dup.  
int earlyclobber_operand_p ( )
   This page contains subroutines used mainly for determining
   whether the IN or an OUT of a reload can serve as the
   reload register.  
   Return 1 if X is an operand of an insn that is being earlyclobbered.  

Referenced by find_valid_class_1(), and reloads_unique_chain_p().

static rtx find_dummy_reload ( rtx  real_in,
rtx  real_out,
rtx inloc,
rtx outloc,
enum machine_mode  inmode,
enum machine_mode  outmode,
reg_class_t  rclass,
int  for_real,
int  earlyclobber 
   Try to find a reload register for an in-out reload (expressions IN and OUT).
   See if one of IN and OUT is a register that may be used;
   this is desirable since a spill-register won't be needed.
   If so, return the register rtx that proves acceptable.

   INLOC and OUTLOC are locations where IN and OUT appear in the insn.
   RCLASS is the register class required for the reload.

   If FOR_REAL is >= 0, it is the number of the reload,
   and in some cases when it can be discovered that OUT doesn't need
   to be computed, clear out rld[FOR_REAL].out.

   If FOR_REAL is -1, this should not be done, because this call
   is just to see if a register can be found, not to find and install it.

   EARLYCLOBBER is nonzero if OUT is an earlyclobber operand.  This
   puts an additional constraint on being able to use IN for OUT since
   IN must not appear elsewhere in the insn (it is assumed that IN itself
   is safe from the earlyclobber).  
     If operands exceed a word, we can't use either of them
     unless they have the same size.  
     Note that {in,out}_offset are needed only when 'in' or 'out'
     respectively refers to a hard register.  
     Find the inside of any subregs.  
     Narrow down the reg class, the same way push_reload will;
     otherwise we might find a dummy now, but push_reload won't.  
     See if OUT will do.  
         When we consider whether the insn uses OUT,
         ignore references within IN.  They don't prevent us
         from copying IN into OUT, because those refs would
         move into the insn that reloads IN.

         However, we only ignore IN in its role as this reload.
         If the insn uses IN elsewhere and it contains OUT,
         that counts.  We can't be sure it's the "same" operand
         so it might not go through this reload.  

         We also need to avoid using OUT if it, or part of it, is a
         fixed register.  Modifying such registers, even transiently,
         may have undefined effects on the machine, such as modifying
         the stack pointer.  
     Consider using IN if OUT was not acceptable
     or if OUT dies in this insn (like the quotient in a divmod insn).
     We can't use IN unless it is dies in this insn,
     which means we must know accurately which hard regs are live.
     Also, the result can't go in IN if IN is used within OUT,
     or if OUT is an earlyclobber and IN appears elsewhere in the insn.  
                                The only case where out and real_out might
                                have different modes is where real_out
                                is a subreg, and in that case, out
                                has a real mode.  
             However only do this if we can be sure that this input
             operand doesn't correspond with an uninitialized pseudo.
             global can assign some hardreg to it that is the same as
             the one assigned to a different, also live pseudo (as it
             can ignore the conflict).  We must never introduce writes
             to such hardregs, as they would clobber the other live
             pseudo.  See PR 20973.  
                 Similarly, only do this if we can be sure that the death
                 note is still valid.  global can assign some hardreg to
                 the pseudo referenced in the note and simultaneously a
                 subword of this hardreg to a different, also live pseudo,
                 because only another subword of the hardreg is actually
                 used in the insn.  This cannot happen if the pseudo has
                 been assigned exactly one hardreg.  See PR 33732.  
                 If we were going to use OUT as the reload reg
                 and changed our mind, it means OUT is a dummy that
                 dies here.  So don't bother copying value to it.  

References gen_rtx_REG().

rtx find_equiv_reg ( rtx  goal,
rtx  insn,
enum reg_class  rclass,
int  other,
short *  reload_reg_p,
int  goalreg,
enum machine_mode  mode 
   Check the insns before INSN to see if there is a suitable register
   containing the same value as GOAL.
   If OTHER is -1, look for a register in class RCLASS.
   Otherwise, just see if register number OTHER shares GOAL's value.

   Return an rtx for the register found, or zero if none is found.

   If RELOAD_REG_P is (short *)1,
   we reject any hard reg that appears in reload_reg_rtx
   because such a hard reg is also needed coming into this insn.

   If RELOAD_REG_P is any other nonzero value,
   it is a vector indexed by hard reg number
   and we reject any hard reg whose element in the vector is nonnegative
   as well as any that appears in reload_reg_rtx.

   If GOAL is zero, then GOALREG is a register number; we look
   for an equivalent for that register.

   MODE is the machine mode of the value we want an equivalence for.
   If GOAL is nonzero and not VOIDmode, then it must have mode MODE.

   This function is used by jump.c as well as in the reload pass.

   If GOAL is the sum of the stack pointer and a constant, we treat it
   as if it were a constant except that sp is required to be unchanging.  
         An address with side effects must be reexecuted.  
     Scan insns back from INSN, looking for one that copies
     a value into or out of GOAL.
     Stop and give up if we reach a label.  
         Don't reuse register contents from before a setjmp-type
         function call; on the second return (from the longjmp) it
         might have been clobbered by a later reuse.  It doesn't
         seem worthwhile to actually go and see if it is actually
         reused even if that information would be readily available;
         just don't reuse it across the setjmp call.  
             If we don't want spill regs ...  
                 ... then ignore insns introduced by reload; they aren't
                 useful and can cause results in reload_as_needed to be
                 different from what they were when calculating the need for
                 spills.  If we notice an input-reload insn here, we will
                 reject it below, but it might hide a usable equivalent.
                 That makes bad code.  It may even fail: perhaps no reg was
                 spilled for this insn because it was assumed we would find
                 that equivalent.  
             First check for something that sets some reg equal to GOAL.  
                      When looking for stack pointer + const,
                      make sure we don't use a stack adjust.  
                     If we are looking for a constant,
                     and something equivalent to that constant was copied
                     into a reg, we can use that reg.  
     We found a previous insn copying GOAL into a suitable other reg VALUE
     (or copying VALUE into GOAL, if GOAL is also a register).
     Now verify that VALUE is really valid.  
     VALUENO is the register number of VALUE; a hard register.  
     Don't try to re-use something that is killed in this insn.  We want
     to be able to trust REG_UNUSED notes.  
     If we propose to get the value from the stack pointer or if GOAL is
     a MEM based on the stack pointer, we need a stable SP.  
     Reject VALUE if the copy-insn moved the wrong sort of datum.  
     Reject VALUE if it was loaded from GOAL
     and is also a register that appears in the address of GOAL.  
     Reject registers that overlap GOAL.  
     Reject VALUE if it is one of the regs reserved for reloads.
     Reload1 knows how to reuse them anyway, and it would get
     confused if we allocated one without its knowledge.
     (Now that insns introduced by reload are ignored above,
     this case shouldn't happen, but I'm not positive.)  
     Reject VALUE if it is a register being used for an input reload
     even if it is not one of those reserved.  
       We must treat frame pointer as varying here,
       since it can vary--in a nonlocal goto as generated by expand_goto.  
     Now verify that the values of GOAL and VALUE remain unaltered
     until INSN is reached.  
         Don't trust the conversion past a function call
         if either of the two is in a call-clobbered register, or memory.  
             Watch out for unspec_volatile, and volatile asms.  
             If this insn P stores in either GOAL or VALUE, return 0.
             If GOAL is a memory ref and this insn writes memory, return 0.
             If GOAL is a memory ref and its address is not constant,
             and this insn P changes a register used in GOAL, return 0.  
             If this insn auto-increments or auto-decrements
             either regno or valueno, return 0 now.
             If GOAL is a memory ref and its address is not constant,
             and this insn P increments a register used in GOAL, return 0.  
static int find_inc_amount ( rtx  ,
static int find_inc_amount ( )
   Find a place where INCED appears in an increment or decrement operator
   within X, and return the amount INCED is incremented or decremented by.
   The value is always positive.  
int find_reloads ( rtx  insn,
int  replace,
int  ind_levels,
int  live_known,
short *  reload_reg_p 
   Main entry point of this file: search the body of INSN
   for values that need reloading and record them with push_reload.
   REPLACE nonzero means record also where the values occur
   so that subst_reloads can be used.

   IND_LEVELS says how many levels of indirection are supported by this
   machine; a value of zero means that a memory reference is not a valid
   memory address.

   LIVE_KNOWN says we have valid information about which hard
   regs are live at each point in the program; this is true when
   we are called from global_alloc but false when stupid register
   allocation has been done.

   RELOAD_REG_P if nonzero is a vector indexed by hard reg number
   which is nonnegative if the reg has been commandeered for reloading into.
   It is copied into STATIC_RELOAD_REG_P and referenced from there
   by various subroutines.

   Return TRUE if some operands need to be changed, because of swapping
   commutative operands, reg_equiv_address substitution, or whatever.  
     These start out as the constraints for the insn
     and they are chewed up as we consider alternatives.  
     These are the preferred classes for an operand, or NO_REGS if it isn't
     a register.  
     Nonzero for a MEM operand whose entire address needs a reload.
     May be -1 to indicate the entire address may or may not need a reload.  
     Nonzero for an address operand that needs to be completely reloaded.
     May be -1 to indicate the entire operand may or may not need a reload.  
     Value of enum reload_type to use for operand.  
     Value of enum reload_type to use within address of operand.  
     Save the usage of each operand.  
     JUMP_INSNs and CALL_INSNs are not allowed to have any output reloads;
     neither are insns that SET cc0.  Insns that use CC0 are not allowed
     to have any input reloads.  
     The eliminated forms of any secondary memory locations are per-insn, so
     clear them out here.  
     Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
     is cheap to move between them.  If it is not, there may not be an insn
     to do the copy, so we may need a reload.  
     Just return "no reloads" if insn has no operands with constraints.  
     If we will need to know, later, whether some pair of operands
     are the same, we must compare them now and save the result.
     Reloading the base and index registers will clobber them
     and afterward they will fail to match.  
         Scan this operand's constraint to see if it is an output operand,
         an in-out operand, is commutative, or should match another.  
                   The last operand should not be marked commutative.  
                   We currently only support one commutative pair of
                   operands.  Some existing asm code currently uses more
                   than one pair.  Previously, that would usually work,
                   but sometimes it would crash the compiler.  We
                   continue supporting that case as well as we can by
                   silently ignoring all but the first pair.  In the
                   future we may handle it correctly.  
               Use of ISDIGIT is tempting here, but it may get expensive because
               of locale support we don't want.  
                   An operand may not match itself.  
                   If C can be commuted with C+1, and C might need to match I,
                   then C+1 might also need to match I.  
                       Note that C is supposed to be less than I.
                       No need to consider altering both C and I because in
                       that case we would alter one into the other.  
     Examine each operand that is a memory reference or memory address
     and reload parts of the addresses into index registers.
     Also here any references to pseudo regs that didn't get hard regs
     but are equivalent to constants get replaced in the insn itself
     with those constants.  Nobody will ever see them again.

     Finally, set up the preferred classes of each operand.  
           Ignore things like match_operator operands.  
             If we now have a simple operand where we used to have a
             PLUS or MULT, re-recognize and try again.  
             Address operands are reloaded in their existing mode,
             no matter what is specified in the machine description.  
             If the address is a single CONST_INT pick address mode
             instead otherwise we will later not know in which mode
             the reload should be performed.  
             If we made a MEM to load (a part of) the stackslot of a pseudo
             that didn't get a hard register, emit a USE with a REG_EQUAL
             note in front so that we might inherit a previous, possibly
             wider reload.  
           We can get a PLUS as an "operand" as a result of register
           elimination.  See eliminate_regs and gen_reload.  We handle
           a unary operator by reloading the operand.  
             This is equivalent to calling find_reloads_toplev.
             The code is duplicated for speed.
             When we find a pseudo always equivalent to a constant,
             we replace it by the constant.  We must be sure, however,
             that we don't try to replace it in the insn in which it
             is being set.  
                 Record the existing mode so that the check if constants are
                 allowed will work when operand_mode isn't specified.  
               We need not give a valid is_set_dest argument since the case
               of a constant equivalence was checked above.  
         If the operand is still a register (we didn't replace it with an
         equivalent), get the preferred class to reload it into.  
     If this is simply a copy from operand 1 to operand 0, merge the
     preferred classes for the operands.  
     Now see what we need for pseudo-regs that didn't get hard regs
     or got the wrong kind of hard reg.  For this, we must consider
     all the operands together against the register constraints.  
     The constraints are made of several alternatives.
     Each operand's constraint looks like foo,bar,... with commas
     separating the alternatives.  The first alternatives for all
     operands go together, the second alternatives go together, etc.

     First loop over alternatives.  
         If insn is commutative (it's safe to exchange a certain pair
         of operands) then we need to try each alternative twice, the
         second time matching those two operands as if we had
         exchanged them.  To do this, really exchange them in
             Loop over operands for one constraint alternative.  
             LOSERS counts those that don't fit this alternative
             and would require loading.  
             BAD is set to 1 if it some operand can't fit this alternative
             even after reloading.  
             REJECT is a count of how undesirable this alternative says it is
             if any reloading is required.  If the alternative matches exactly
             then REJECT is ignored, but otherwise it gets this much
             counted against it in addition to the reloading needed.  Each
             ? counts three times here since we want the disparaging caused by
             a bad register class to only count 1/3 as much.  
                 Swap the duplicates too.  
                 0 => this operand can be reloaded somehow for this alternative.  
                 0 => this operand can be reloaded if the alternative allows regs.  
                 Nonzero means this is a MEM that must be reloaded into a reg
                 regardless of what the constraint says.  
                 Nonzero if a constant forced into memory would be OK for this
                 If the predicate accepts a unary operator, it means that
                 we need to reload the operand, but do not do this for
                 match_operator and friends.  
                 If the operand is a SUBREG, extract
                 the REG or MEM (or maybe even a constant) within.
                 (Constants can occur as a result of reg_equiv_constant.)  
                     Offset only matters when operand is a REG and
                     it is a hard reg.  This is because it is passed
                     to reg_fits_class_p if it is a REG and all pseudos
                     return 0 from that function.  
                     Force reload if this is a constant or PLUS or if there may
                     be a problem accessing OPERAND in the outer mode.  
                         We must force a reload of paradoxical SUBREGs
                         of a MEM because the alignment of the inner value
                         may not be enough to do the outer reference.  On
                         big-endian machines, it may also reference outside
                         the object.

                         On machines that extend byte operations and we have a
                         SUBREG where both the inner and outer modes are no wider
                         than a word and the inner mode is narrower, is integral,
                         and gets extended when loaded from memory, combine.c has
                         made assumptions about the behavior of the machine in such
                         register access.  If the data is, in fact, in memory we
                         must always load using the size assumed to be in the
                         register and let the insn do the different-sized

                         This is doubly true if WORD_REGISTER_OPERATIONS.  In
                         this case eliminate_regs has left non-paradoxical
                         subregs for push_reload to see.  Make sure it does
                         by forcing the reload.

                         ??? When is it right at this stage to have a subreg
                         of a mem that is _not_ to be handled specially?  IMO
                         those should have been reduced to just a mem.  
                 An empty constraint or empty alternative
                 allows anything which matched the pattern.  
                 Scan this alternative's specs for this operand;
                 set WIN if the operand fits any letter in this alternative.
                 Otherwise, clear BADOP if this operand could
                 fit some letter after reloads,
                 or set WINREG if this operand could fit after reloads
                 provided the constraint allows some registers.  
                       We only support one commutative marker, the first
                       one.  We already set commutative above.  
                       Ignore rest of this alternative as far as
                       reloading is concerned.  
                       We are supposed to match a previous operand.
                       If we do, we win if that one did.
                       If we do not, count both of the operands as losers.
                       (This is too conservative, since most of the time
                       only a single reload insn will be needed to make
                       the two operands win.  As a result, this alternative
                       may be rejected when it is actually desirable.)  
                           If we are matching as if two operands were swapped,
                           also pretend that operands_match had been computed
                           with swapped.
                           But if I is the second of those and C is the first,
                           don't exchange them, because operands_match is valid
                           only on one side of its diagonal.  
                           If we are matching a non-offsettable address where an
                           offsettable address was expected, then we must reject
                           this combination, because we can't reload it.  
                           Operands don't match.  
                           Retroactively mark the operand we had to match
                           as a loser, if it wasn't already.  
                           But count the pair only once in the total badness of
                           this alternative, if the pair can be a dummy reload.
                           The pointers in operand_loc are not swapped; swap
                           them by hand if necessary.  
                       This can be fixed with reloads if the operand
                       we are supposed to match can be fixed with reloads.  
                       If we have to reload this operand and some previous
                       operand also had to match the same thing as this
                       operand, we don't know how to do that.  So reject this
                       All necessary reloads for an address_operand
                       were handled in find_reloads_address.  
                       Memory operand whose address is not offsettable.  
                           Certain mem addresses will become offsettable
                           after they themselves are reloaded.  This is important;
                           we don't want our own handling of unoffsettables
                           to override the handling of reg_equiv_address.  
                       Memory operand whose address is offsettable.  
                            If IND_LEVELS, find_reloads_address won't reload a
                            pseudo that didn't get a hard reg, so we have to
                            reject that case.  
                                A reloaded address is offsettable because it is now
                                just a simple register indirect.  
                               If reg_equiv_address is nonzero, we will be
                               loading it into a register; hence it will be
                               offsettable, but we cannot say that reg_equiv_mem
                               is offsettable without checking.  
                       Output operand that is stored before the need for the
                       input operands (and their index registers) is over.  
                           A PLUS is never a valid operand, but reload can make
                           it from a register when eliminating registers.  
                           A SCRATCH is not a valid operand.  
                       Drop through into 'r' case.  
                               If the address was already reloaded,
                               we win as well.  
                               Likewise if the address will be reloaded because
                               reg_equiv_address is nonzero.  For reg_equiv_mem
                               we have to check.  
                               If we didn't already win, we can reload
                               constants via force_const_mem, and other
                               MEMs by reloading the address like for 'o'.  
                               If we didn't already win, we can reload
                               the address into a base register.  
                 If this operand could be handled with a reg,
                 and some reg is allowed, then this operand can be handled.  
                 Record which operands fit this alternative.  
                     Alternative loses if it has no regs for a reg operand.  
                     If this is a constant that is reloaded into the desired
                     class by copying it to memory first, count that as another
                     reload.  This is consistent with other code and is
                     required to avoid choosing another alternative when
                     the constant is moved into memory by this function on
                     an early reload pass.  Note that the test here is
                     precisely the same as in the code below that calls
                     Alternative loses if it requires a type of reload not
                     permitted for this insn.  We can always reload SCRATCH
                     and objects with a REG_UNUSED note.  
                     If we can't reload this value at all, reject this
                     alternative.  Note that we could also lose due to
                     LIMIT_RELOAD_CLASS, but we don't check that
                     We prefer to reload pseudos over reloading other things,
                     since such reloads may be able to be eliminated later.
                     If we are reloading a SCRATCH, we won't be generating any
                     insns, just using a register, so it is also preferred.
                     So bump REJECT in other cases.  Don't do this in the
                     case where we are forcing a constant into memory and
                     it will then win since we don't want to have a different
                     alternative match then.  
                     Input reloads can be inherited more often than output
                     reloads can be removed, so penalize output reloads.  
                 If this operand is a pseudo register that didn't get
                 a hard reg and this alternative accepts some
                 register, see if the class that we want is a subset
                 of the preferred class for this register.  If not,
                 but it intersects that class, use the preferred class
                 instead.  If it does not intersect the preferred
                 class, show that usage of this alternative should be
                 discouraged; it will be discouraged more still if the
                 register is `preferred or nothing'.  We do this
                 because it increases the chance of reusing our spill
                 register in a later insn and avoiding a pair of
                 memory stores and loads.

                 Don't bother with this if this alternative will
                 accept this operand.

                 Don't do this for a multiword operand, since it is
                 only a small win and has the risk of requiring more
                 spill registers, which could cause a large loss.

                 Don't do this if the preferred class has only one
                 register because we might otherwise exhaust the
                         Since we don't have a way of forming the intersection,
                         we just do something special if the preferred class
                         is a subset of the class we have; that's the most
                         common case anyway.  
             Now see if any output operands that are marked "earlyclobber"
             in this alternative conflict with any input operands
             or any memory addresses.  
                     Is this an input operand or a memory ref?  
                         Ignore things like match_operator operands.  
                         Don't count an input operand that is constrained to match
                         the early clobber operand.  
                         Is it altered by storing the earlyclobber operand?  
                         If the output is in a non-empty few-regs class,
                         it's costly to reload it, so reload the input instead.  
                   If an earlyclobber operand conflicts with something,
                   it must be reloaded, so request this and count the cost.  
             If one alternative accepts all the operands, no reload required,
             choose that alternative; don't consider the remaining ones.  
                 Unswap these so that they are never swapped at `finish'.  
             REJECT, set by the ! and ? constraint characters and when a register
             would be reloaded into a non-preferred class, discourages the use of
             this alternative for a reload goal.  REJECT is incremented by six
             for each ? and two for each non-preferred class.  
             If this alternative can be made to work by reloading,
             and it needs less reloading than the others checked so far,
             record it as the chosen goal for reloading.  
                 If the commutative operands have been swapped, swap
                 them back in order to check the next alternative.  
                 Unswap the duplicates too.  
                 Unswap the operand related information as well.  
     The operands don't meet the constraints.
     goal_alternative describes the alternative
     that we could reach by reloading the fewest operands.
     Reload so as to fit it.  
         No alternative works with reloads??  
         Avoid further trouble with this insn.  
     Jump to `finish' from above if all operands are valid already.
     In that case, goal_alternative_win is all 1.  
     Right now, for any pair of operands I and J that are required to match,
     with I < J,
     goal_alternative_matches[J] is I.
     Set up goal_alternative_matched as the inverse function:
     goal_alternative_matched[I] = J.  
     If the best alternative is with operands 1 and 2 swapped,
     consider them swapped before reporting the reloads.  Update the
     operand numbers of any reloads already pushed.  
         If this is an earlyclobber operand, we need to widen the scope.
         The reload must remain valid from the start of the insn being
         reloaded until after the operand is stored into its destination.
         We approximate this with RELOAD_OTHER even though we know that we
         do not conflict with RELOAD_FOR_INPUT_ADDRESS reloads.

         One special case that is worth checking is when we have an
         output that is earlyclobber but isn't used past the insn (typically
         a SCRATCH).  In this case, we only need have the reload live
         through the insn itself, but not for any of our input or output
         But we must not accidentally narrow the scope of an existing
         RELOAD_OTHER reload - leave these alone.

         In any case, anything needed to address this operand can remain
         however they were previously categorized.  
     Any constants that aren't allowed and can't be reloaded
     into registers are here changed into memory references.  
           Reloads of SUBREGs of CONSTANT RTXs are handled later in
           push_reload so we have to let them pass here.  
               If we stripped a SUBREG or a PLUS above add it back.  
               If the alternative accepts constant pool refs directly
               there will be no reload needed at all.  
     Record the values of the earlyclobber operands for the caller.  
     Now record reloads for all the operands that need them.  
           Operands that match previous ones have already been handled.  
           Handle an operand with a nonoffsettable address
           appearing where an offsettable address will do
           by reloading the address into a base register.

           ??? We can also do this when the operand is a register and
           reg_equiv_mem is not offsettable, but this is a bit tricky,
           so we don't bother with it.  It may not be worth doing.  
               If the address to be reloaded is a VOIDmode constant,
               use the default address mode as mode of the reload register,
               as would have been done by find_reloads_address.  
               If this operand is an output, we will have made any
               reloads for its address as RELOAD_FOR_OUTPUT_ADDRESS, but
               now we are treating part of the operand as an input, so
               we must change these to RELOAD_FOR_INPUT_ADDRESS.  
           In a matching pair of operands, one must be input only
           and the other must be output only.
           Pass the input operand as IN and the other as OUT.  
               Avoid further trouble with this insn.  
           For each non-matching operand that's a MEM or a pseudo-register
           that didn't get a hard register, make an optional reload.
           This may get done even if the insn needs no reloads otherwise.  
               If this is only for an output, the optional reload would not
               actually cause us to use a register now, just note that
               something is stored here.  
               An optional output reload might allow to delete INSN later.
               We mustn't make in-out reloads on insns that are not permitted
               output reloads.
               If this is an asm, we can't delete it; we must not even call
               push_reload for an optional output reload in this case,
               because we can't be sure that the constraint allows a register,
               and push_reload verifies the constraints for asms.  
           If a memory reference remains (either as a MEM or a pseudo that
           did not get a hard register), yet we can't make an optional
           reload, check if this is actually a pseudo register reference;
           we then need to emit a USE and/or a CLOBBER so that reload
           inheritance will do the right thing.  
                     We mark the USE with QImode so that we recognize
                     it as one that can be safely deleted at the end
                     of reload.  
           Similarly, make an optional reload for a pair of matching
           objects that are in MEM or a pseudo that didn't get a hard reg.  
     Perform whatever substitutions on the operands we are supposed
     to make due to commutativity or replacement of registers
     with equivalent constants or memory slots.  
         We only do this on the last pass through reload, because it is
         possible for some data (like reg_equiv_address) to be changed during
         later passes.  Moreover, we lose the opportunity to get a useful
         reload_{in,out}_reg when we do these replacements.  
             If we're replacing an operand with a LABEL_REF, we need to
             make sure that there's a REG_LABEL_OPERAND note attached to
             this instruction.  
                 For a JUMP_P, if it was a branch target it must have
                 already been recorded as such.  
     If this insn pattern contains any MATCH_DUP's, make sure that
     they will be substituted if the operands they match are substituted.
     Also do now any substitutions we already did on the operands.

     Don't do this if we aren't making replacements because we might be
     propagating things allocated by frame pointer elimination into places
     it doesn't expect.  
     This loses because reloading of prior insns can invalidate the equivalence
     (or at least find_equiv_reg isn't smart enough to find it any more),
     causing this insn to need more reload regs than it needed before.
     It may be too late to make the reload regs available.
     Now this optimization is done safely in choose_reload_regs.  
     For each reload of a reg into some other class of reg,
     search for an existing equivalent reg (same value now) in the right class.
     We can use it as long as we don't need to change its contents.  
           Prevent generation of insn to load the value
           because the one we found already has the value.  
     If we detected error and replaced asm instruction by USE, forget about the
     Perhaps an output reload can be combined with another
     to reduce needs by one.  
     If we have a pair of reloads for parts of an address, they are reloading
     the same object, the operands themselves were not reloaded, and they
     are for two operands that are supposed to match, merge the reloads and
     change the type of the surviving reload to RELOAD_FOR_OPERAND_ADDRESS.  
     Scan all the reloads and update their type.
     If a reload is for the address of an operand and we didn't reload
     that operand, change the type.  Similarly, change the operand number
     of a reload when two operands match.  If a reload is optional, treat it
     as though the operand isn't reloaded.

     ??? This latter case is somewhat odd because if we do the optional
     reload, it means the object is hanging around.  Thus we need only
     do the address reload if the optional reload was NOT done.

     Change secondary reloads to be the address type of their operand, not
     the normal type.

     If an operand's reload is now RELOAD_OTHER, change any
     RELOAD_FOR_INPUT_ADDRESS reloads of that operand to
             If we have a secondary reload to go along with this reload,
             change its type to RELOAD_FOR_OPADDR_ADDR.  
                 If there's a tertiary reload we have to change it also.  
                 If there's a tertiary reload we have to change it also.  
     Scan all the reloads, and check for RELOAD_FOR_OPERAND_ADDRESS reloads.
     If we have more than one, then convert all RELOAD_FOR_OPADDR_ADDR
     reloads to RELOAD_FOR_OPERAND_ADDRESS reloads.

     choose_reload_regs assumes that RELOAD_FOR_OPADDR_ADDR reloads never
     conflict with RELOAD_FOR_OPERAND_ADDRESS reloads.  This is true for a
     However, if there is more than one RELOAD_FOR_OPERAND_ADDRESS reload,
     then a RELOAD_FOR_OPADDR_ADDR reload conflicts with all
     RELOAD_FOR_OPERAND_ADDRESS reloads other than the one that uses it.
     This is complicated by the fact that a single operand can have more
     than one RELOAD_FOR_OPERAND_ADDRESS reload.  It is very difficult to fix
     choose_reload_regs without affecting code quality, and cases that
     actually fail are extremely rare, so it turns out to be better to fix
     the problem here by not generating cases that choose_reload_regs will
     fail for.  
     There is a similar problem with RELOAD_FOR_INPUT_ADDRESS /
     RELOAD_FOR_OUTPUT_ADDRESS when there is more than one of a kind for
     a single operand.
     We can reduce the register pressure by exploiting that a
     RELOAD_FOR_X_ADDR_ADDR that precedes all RELOAD_FOR_X_ADDRESS reloads
     does not conflict with any of them, if it is only used for the first of
     the RELOAD_FOR_X_ADDRESS reloads.  
       We use last_op_addr_reload and the contents of the above arrays
       first as flags - -2 means no instance encountered, -1 means exactly
       one instance encountered.
       If more than one instance has been encountered, we store the reload
       number of the first reload of the kind in question; reload numbers
       are known to be non-negative.  
                   Check if the only TYPE reload that uses reload I is
                   reload FIRST_NUM.  
     See if we have any reloads that are now allowed to be merged
     because we've changed when the reload is needed to
     check for the most common cases.  
     If we made any reloads for addresses, see if they violate a
     "no input reloads" requirement for this insn.  But loads that we
     do after the insn (such as for output addresses) are fine.  
     Compute reload_mode and reload_nregs.  
     Special case a simple move with an input reload and a
     destination of a hard reg, if the hard reg is ok, use it.  

References recog_data_d::operand, operands_match_p(), and recog_data.

Referenced by maybe_fix_stack_asms().

static int find_reloads_address ( enum machine_mode  mode,
rtx memrefloc,
rtx  ad,
rtx loc,
int  opnum,
enum reload_type  type,
int  ind_levels,
rtx  insn 
   Record all reloads needed for handling memory address AD
   which appears in *LOC in a memory reference to mode MODE
   which itself is found in location  *MEMREFLOC.
   Note that we take shortcuts assuming that no multi-reg machine mode
   occurs as part of an address.

   OPNUM and TYPE specify the purpose of this reload.

   IND_LEVELS says how many levels of indirect addressing this machine

   INSN, if nonzero, is the insn in which we do the reload.  It is used
   to determine if we may generate output reloads, and where to put USEs
   for pseudos that we have to replace with stack slots.

   Value is one if this address is reloaded or replaced as a whole; it is
   zero if the top level of this address was not reloaded or replaced, and
   it is -1 if it may or may not have been reloaded or replaced.

   Note that there is no verification that the address will be valid after
   this routine does its work.  Instead, we rely on the fact that the address
   was valid when reload started.  So we need only undo things that reload
   could have broken.  These are wrong register types, pseudos not allocated
   to a hard register, and frame pointer elimination.  
     If the address is a register, see if it is a legitimate address and
     reload if not.  We first handle the cases where we need not reload
     or where we must reload in a non-standard way.  
                 We can avoid a reload if the register's equivalent memory
                 expression is valid as an indirect memory address.
                 But not all addresses are valid in a mem used as an indirect
                 address: only reg or reg+constant.  
                     TEM is not the same as what we'll be replacing the
                     pseudo with after reload, put a USE in front of INSN
                     in the final reload pass.  
                         We mark the USE with QImode so that we
                         recognize it as one that can be safely
                         deleted at the end of reload.  
                         This doesn't really count as replacing the address
                         as a whole, since it is still a memory access.  
         The only remaining case where we can avoid a reload is if this is a
         hard register that is valid as a base register and which is not the
         subject of a CLOBBER in this insn.  
         If we do not have one of the cases above, we must do the reload.  
         The address appears valid, so reloads are not needed.
         But the address may contain an eliminable register.
         This can happen because a machine with indirect addressing
         may consider a pseudo register by itself a valid address even when
         it has failed to get a hard reg.
         So do a tree-walk to find and eliminate all such regs.  
         But first quickly dispose of a common case.  
         Check result for validity after substitution.  
     The address is not valid.  We have to figure out why.  First see if
     we have an outer AND and remove it if so.  Then analyze what's inside.  
     One possibility for why the address is invalid is that it is itself
     a MEM.  This can happen when the frame pointer is being eliminated, a
     pseudo is not allocated to a hard register, and the offset between the
     frame and stack pointers is not its initial value.  In that case the
     pseudo will have been replaced by a MEM referring to the
     stack pointer.  
         First ensure that the address in this MEM is valid.  Then, unless
         indirect addresses are valid, reload the MEM into a register.  
         If tem was changed, then we must create a new memory reference to
         hold it and store it back into memrefloc.  
         Check similar cases as for indirect addresses as above except
         that we can allow pseudos and a MEM since they should have been
         taken care of above.  
             Must use TEM here, not AD, since it is the one that will
             have any subexpressions reloaded, if needed.  
     If we have address of a stack slot but it's not valid because the
     displacement is too large, compute the sum in a register.
     Handle all base registers here, not just fp/ap/sp, because on some
     targets (namely SH) we can also get too large displacements from
     big-endian corrections.  
                  Similarly, if we were to reload the base register and the
                  mem+offset address is still invalid, then we want to reload
                  the whole address, not just the base register.  
         Unshare the MEM rtx so we can safely alter it.  
             Unshare the sum as well.  
             Reload the displacement into an index reg.
             We assume the frame pointer or arg pointer is a base reg.  
             If the sum of two regs is not necessarily valid,
             reload the sum into a base reg.
             That will at least work.  
     If we have an indexed stack slot, there are three possible reasons why
     it might be invalid: The index might need to be reloaded, the address
     might have been made by frame pointer elimination and hence have a
     constant out of range, or both reasons might apply.

     We can easily check for an index needing reload, but even if that is the
     case, we might also have an invalid constant.  To avoid making the
     conservative assumption and requiring two reloads, we see if this address
     is valid when not interpreted strictly.  If it is, the only problem is
     that the index needs a reload and find_reloads_address_1 will take care
     of it.

     Handle all base registers here, not just fp/ap/sp, because on some
     targets (namely SPARC) we can also get invalid addresses from preventive
     subreg big-endian corrections made by find_reloads_toplev.  We
     can also get expressions involving LO_SUM (rather than PLUS) from

     If we decide to do something, it must be that `double_reg_address_ok'
     is true.  We generate a reload of the base register + constant and
     rework the sum so that the reload register will be added to the index.
     This is safe because we know the address isn't shared.

     We check for the base register as both the first and second operand of
     the innermost PLUS and/or LO_SUM.  
             Form the adjusted address.  
     See if address becomes valid when an eliminable register
     in a sum is replaced.  
         Ok, we win that way.  Replace any additional eliminable
         Make sure that didn't make the address invalid again.  
     If constants aren't valid addresses, reload the constant address
     into a register.  
         If AD is an address in the constant pool, the MEM rtx may be shared.
         Unshare it so we can safely alter it.  
static int find_reloads_address_1 ( enum machine_mode  mode,
addr_space_t  as,
rtx  x,
int  context,
enum rtx_code  outer_code,
enum rtx_code  index_code,
rtx loc,
int  opnum,
enum reload_type  type,
int  ind_levels,
rtx  insn 
   Record the pseudo registers we must reload into hard registers in a
   subexpression of a would-be memory address, X referring to a value
   in mode MODE.  (This function is not called if the address we find
   is strictly valid.)

   CONTEXT = 1 means we are considering regs as index regs,
   = 0 means we are considering them as base regs.
   OUTER_CODE is the code of the enclosing RTX, typically a MEM, a PLUS,
   or an autoinc code.
   If CONTEXT == 0 and OUTER_CODE is a PLUS or LO_SUM, then INDEX_CODE
   is the code of the index part of the address.  Otherwise, pass SCRATCH
   for this argument.
   OPNUM and TYPE specify the purpose of any reloads made.

   IND_LEVELS says how many levels of indirect addressing are
   supported at this point in the address.

   INSN, if nonzero, is the insn in which we do the reload.  It is used
   to determine if we may generate output reloads.

   We return nonzero if X, as a whole, is reloaded or replaced.  
   Note that we take shortcuts assuming that no multi-reg machine mode
   occurs as part of an address.
   Also, this is not fully machine-customizable; it works for machines
   such as VAXen and 68000's and 32000's, but other possible machines
   could have addressing modes that this does not handle right.
   If you add push_reload calls here, you need to make sure gen_reload
   handles those cases gracefully.  
                 ??? Why is this given op1's mode and above for
                 ??? op0 SUBREGs we use word_mode?  
           Plus in the index register may be created only as a result of
           register rematerialization for expression like &localvar*4.  Reload it.
           It may be possible to combine the displacement on the outer level,
           but it is probably not worthwhile to do so.  
           Currently, we only support {PRE,POST}_MODIFY constructs
           where a base register is {inc,dec}remented by the contents
           of another register or by a constant value.  Thus, these
           operands must match.  
           Require index register (or constant).  Let's just handle the
           register case in the meantime... If the target allows
           auto-modify by a constant then we could try replacing a pseudo
           register with its equivalent constant where applicable.

           We also handle the case where the register was eliminated
           resulting in a PLUS subexpression.

           If we later decide to reload the whole PRE_MODIFY or
           POST_MODIFY, inc_for_reload might clobber the reload register
           before reading the index.  The index register might therefore
           need to live longer than a TYPE reload normally would, so be
           conservative and class it as RELOAD_OTHER.  
           A register that is incremented cannot be constant!  
           Handle a register that is equivalent to a memory location
            which cannot be addressed directly.  
                   First reload the memory location's address.
                    We can't use ADDR_TYPE (type) here, because we need to
                    write back the value after reading it, hence we actually
                    need two registers.  
                   Then reload the memory location into a base
           We require a base register here...  
             A register that is incremented cannot be constant!  
             Handle a register that is equivalent to a memory location
             which cannot be addressed directly.  
                     First reload the memory location's address.
                     We can't use ADDR_TYPE (type) here, because we need to
                     write back the value after reading it, hence we actually
                     need two registers.  
                     Put this inside a new increment-expression.  
                     Proceed to reload that, as if it contained a register.  
             If we have a hard register that is ok in this incdec context,
             don't make a reload.  If the register isn't nice enough for
             autoincdec, we can reload it.  But, if an autoincrement of a
             register that we here verified as playing nice, still outside
             isn't "valid", it must be that no autoincrement is "valid".
             If that is true and something made an autoincrement anyway,
             this must be a special context where one is allowed.
             (For example, a "push" instruction.)
             We can't improve this address, so leave it alone.  
             Otherwise, reload the autoincrement into a suitable hard reg
             and record how much to increment by.  
                 If we can output the register afterwards, do so, this
                 saves the extra update.
                 We can do so if we have an INSN - i.e. no JUMP_INSN nor
                 CALL_INSN - and it does not set CC0.
                 But don't do this if we cannot directly address the
                 memory location, since this will make it harder to
                 reuse address reloads, and increases register pressure.
                 Also don't do this if we can probably update x directly.  
                     We use the original pseudo for loc, so that
                     emit_reload_insns() knows which pseudo this
                     reload refers to and updates the pseudo rtx, not
                     its equivalent memory location, as well as the
                     corresponding entry in reg_last_reload_reg.  
         Look for parts to reload in the inner expression and reload them
         too, in addition to this operation.  Reloading all inner parts in
         addition to this one shouldn't be necessary, but at this point,
         we don't know if we can possibly omit any part that *can* be
         reloaded.  Targets that are better off reloading just either part
         (or perhaps even a different part of an outer expression), should
         This is probably the result of a substitution, by eliminate_regs, of
         an equivalent address for a pseudo that was not allocated to a hard
         register.  Verify that the specified address is valid and reload it
         into a register.

         Since we know we are going to reload this item, don't decrement for
         the indirection level.

         Note that this is actually conservative:  it would be slightly more
         efficient to use the value of SPILL_INDIRECT_LEVELS from
         reload1.c here.  
           If a register appearing in an address is the subject of a CLOBBER
           in this insn, reload it into some other register to be safe.
           The CLOBBER is supposed to make the register unavailable
           from before this insn to after it.  
             If this is a SUBREG of a hard register and the resulting register
             is of the wrong class, reload the whole SUBREG.  This avoids
             needless copies if SUBREG_REG is multi-word.  
             If this is a SUBREG of a pseudo-register, and the pseudo-register
             is larger than the class size, then reload the whole SUBREG.  
                     If the inner register will be replaced by a memory
                     reference, we can do this only if we can replace the
                     whole subreg by a (narrower) memory reference.  If
                     this is not possible, fall through and reload just
                     the inner register (including address reloads).  
             Pass SCRATCH for INDEX_CODE, since CODE can never be a PLUS once
             we get here.  

Referenced by maybe_memory_address_addr_space_p().

static void find_reloads_address_part ( rtx  x,
rtx loc,
enum reg_class  rclass,
enum machine_mode  mode,
int  opnum,
enum reload_type  type,
int  ind_levels 
   X, which is found at *LOC, is a part of an address that needs to be
   reloaded into a register of class RCLASS.  If X is a constant, or if
   X is a PLUS that contains a constant, check that the constant is a
   legitimate operand and that we are supposed to be able to load
   it into the register.

   If not, force the constant into memory and reload the MEM instead.

   MODE is the mode to use, in case X is an integer constant.

   OPNUM and TYPE describe the purpose of any reloads made.

   IND_LEVELS says how many levels of indirect addressing this machine

Referenced by maybe_memory_address_addr_space_p().

static rtx find_reloads_subreg_address ( rtx  x,
int  opnum,
enum reload_type  type,
int  ind_levels,
rtx  insn,
int *  address_reloaded 
   X, a subreg of a pseudo, is a part of an address that needs to be
   reloaded, and the pseusdo is equivalent to a memory location.

   Attempt to replace the whole subreg by a (possibly narrower or wider)
   memory reference.  If this is possible, return this new memory
   reference, and push all required address reloads.  Otherwise,
   return NULL.

   OPNUM and TYPE identify the purpose of the reload.

   IND_LEVELS says how many levels of indirect addressing are
   supported at this point in the address.

   INSN, if nonzero, is the insn in which we do the reload.  It is used
   to determine where to put USEs for pseudos that we have to replace with
   stack slots.  
     We cannot replace the subreg with a modified memory reference if:

     - we have a paradoxical subreg that implicitly acts as a zero or
       sign extension operation due to LOAD_EXTEND_OP;

     - we have a subreg that is implicitly supposed to act on the full
       register due to WORD_REGISTER_OPERATIONS (see also eliminate_regs);

     - the address of the equivalent memory location is mode-dependent;  or

     - we have a paradoxical subreg and the resulting memory is not
       sufficiently aligned to allow access in the wider mode.

    In addition, we choose not to perform the replacement for *any*
    paradoxical subreg, even if it were possible in principle.  This
    is to avoid generating wider memory references than necessary.

    This corresponds to how previous versions of reload used to handle
    paradoxical subregs where no address reload was required.  
     Since we don't attempt to handle paradoxical subregs, we can just
     call into simplify_subreg, which will handle all remaining checks
     for us.  
     Now push all required address reloads, if any.  
     ??? Do we need to handle nonzero offsets somehow?  
     For some processors an address may be valid in the original mode but
     not in a smaller mode.  For example, ARM accepts a scaled index register
     in SImode but not in HImode.  Note that this is only a problem if the
     address in reg_equiv_mem is already invalid in the new mode; other
     cases would be fixed by find_reloads_address as usual.

     ??? We attempt to handle such cases here by doing an additional reload
     of the full address after the usual processing by find_reloads_address.
     Note that this may not work in the general case, but it seems to cover
     the cases where this situation currently occurs.  A more general fix
     might be to reload the *value* instead of the address, but this would
     not be expected by the callers of this routine as-is.

     If find_reloads_address already completed replaced the address, there
     is nothing further to do.  
     If this is not a toplevel operand, find_reloads doesn't see this
     substitution.  We have to emit a USE of the pseudo so that
     delete_output_reload can see it.  
       We mark the USE with QImode so that we recognize it as one that
       can be safely deleted at the end of reload.  
static rtx find_reloads_toplev ( rtx  x,
int  opnum,
enum reload_type  type,
int  ind_levels,
int  is_set_dest,
rtx  insn,
int *  address_reloaded 
   Scan X for memory references and scan the addresses for reloading.
   Also checks for references to "constant" regs that we want to eliminate
   and replaces them with the values they stand for.
   We may alter X destructively if it contains a reference to such.
   If X is just a constant reg, we return the equivalent value
   instead of X.

   IND_LEVELS says how many levels of indirect addressing this machine

   OPNUM and TYPE identify the purpose of the reload.

   IS_SET_DEST is true if X is the destination of a SET, which is not
   appropriate to be replaced by a constant.

   INSN, if nonzero, is the insn in which we do the reload.  It is used
   to determine if we may generate output reloads, and where to put USEs
   for pseudos that we have to replace with stack slots.

   ADDRESS_RELOADED.  If nonzero, is a pointer to where we put the
   result of find_reloads_address.  
         This code is duplicated for speed in find_reloads.  
          This creates (subreg (mem...)) which would cause an unnecessary
          reload of the mem.  
                 If this is not a toplevel operand, find_reloads doesn't see
                 this substitution.  We have to emit a USE of the pseudo so
                 that delete_output_reload can see it.  
                   We mark the USE with QImode so that we recognize it
                   as one that can be safely deleted at the end of
         Check for SUBREG containing a REG that's equivalent to a
         constant.  If the constant has a known value, truncate it
         right now.  Similarly if we are extracting a single-word of a
         multi-word constant.  If the constant is symbolic, allow it
         to be substituted normally.  push_reload will strip the
         subreg later.  The constant must not be VOIDmode, because we
         will lose the mode of the register (this should never happen
         because one of the cases above should handle it).  
         If the subreg contains a reg that will be converted to a mem,
         attempt to convert the whole subreg to a (narrower or wider)
         memory reference instead.  If this succeeds, we're done --
         otherwise fall through to check whether the inner reg still
         needs address reloads anyway.  
             If we have replaced a reg with it's equivalent memory loc -
             that can still be handled here e.g. if it's in a paradoxical
             subreg - we must make the change in a copy, rather than using
             a destructive change.  This way, find_reloads can still elect
             not to do the change.  

References copy_rtx(), and move_replacements().

rtx find_replacement ( )
   If LOC was scheduled to be replaced by something, return the replacement.
   Otherwise, return *LOC.  
     If *LOC is a PLUS, MINUS, or MULT, see if a replacement is scheduled for
     what's inside and make a new rtl if so.  

References in_hard_reg_set_p().

Referenced by do_output_reload().

static int find_reusable_reload ( rtx p_in,
rtx  out,
enum reg_class  rclass,
enum reload_type  type,
int  opnum,
int  dont_share 
   Return the number of a previously made reload that can be combined with
   a new one, or n_reloads if none of the existing reloads can be used.
   OUT, RCLASS, TYPE and OPNUM are the same arguments as passed to
   push_reload, they determine the kind of the new reload that we try to
   combine.  P_IN points to the corresponding value of IN, which can be
   modified by this function.
   DONT_SHARE is nonzero if we can't share any input-only reload for IN.  
     We can't merge two reloads if the output of either one is
     We can use an existing reload if the class is right
     and at least one of IN and OUT is a match
     and the other is at worst neutral.
     (A zero compared against anything is neutral.)

     For targets with small register classes, don't use existing reloads
     unless they are for the same thing since that can cause us to need
     more reload registers than we otherwise would.  
           If the existing reload has a register, it must fit our class.  
     Reloading a plain reg for input can match a reload to postincrement
     that reg, since the postincrement's value is the right value.
     Likewise, it can match a preincrement reload, since we regard
     the preincrementation as happening before any ref in this insn
     to that register.  
           If the existing reload has a register, it must fit our
           Make sure reload_in ultimately has the increment,
           not the plain register.  

References rld, and targetm.

static enum reg_class find_valid_class ( enum machine_mode  outer,
enum machine_mode  inner,
int  n,
unsigned int  dest_regno 
   Find the largest class which has at least one register valid in
   mode INNER, and which for every such register, that register number
   plus N is also valid in OUTER (if in range) and is cheap to move
   into REGNO.  Such a class must exist.  

References in_hard_reg_set_p(), and register_move_cost().

static enum reg_class find_valid_class_1 ( enum machine_mode  outer,
enum machine_mode  mode,
enum reg_class  dest_class 
   We are trying to reload a subreg of something that is not a register.
   Find the largest class which contains only registers valid in
   mode MODE.  OUTER is the mode of the subreg, DEST_CLASS the class in
   which we would eventually like to obtain the object.  

References earlyclobber_operand_p(), n_reloads, reg_class_subset_p(), rld, small_register_class_p(), targetm, and true_regnum().

rtx form_sum ( )
   Compute the sum of X and Y, making canonicalizations assumed in an
   address, namely: sum constant integers, surround the sum of two
   constants with a CONST, put the constant as the second operand, and
   group the constant on the outermost sum.

   This routine assumes both inputs are already in canonical form.  
     Note that if the operands of Y are specified in the opposite
     order in the recursive calls below, infinite recursion will occur.  
     If both constant, encapsulate sum.  Otherwise, just form sum.  A
     constant will have been placed second.  
rtx get_secondary_mem ( rtx  x,
enum machine_mode  mode,
int  opnum,
enum reload_type  type 
   Return a memory location that will be used to copy X in mode MODE.
   If we haven't already made a location for this mode in this insn,
   call find_reloads_address on the location being returned.  
     By default, if MODE is narrower than a word, widen it to a word.
     This is required because most machines that require these memory
     locations do not support short load and stores from all registers
     (e.g., FP registers).  
     If we already have made a MEM for this operand in MODE, return it.  
     If this is the first time we've tried to get a MEM for this mode,
     allocate a new one.  `something_changed' in reload will get set
     by noticing that the frame size has changed.  
     Get a version of the address doing any eliminations needed.  If that
     didn't give us a new MEM, make a new one if it isn't valid.  
     The only time the call below will do anything is if the stack
     offset is too large.  In that case IND_LEVELS doesn't matter, so we
     can just pass a zero.  Adjust the type to be the address of the
     corresponding object.  If the address was valid, save the eliminated
     address.  If it wasn't valid, we need to make a reload each time, so
     don't save it.  

Referenced by inherit_piecemeal_p().

static int hard_reg_set_here_p ( unsigned  int,
unsigned  int,
static int hard_reg_set_here_p ( )
   Return 1 if expression X alters a hard reg in the range
   from BEG_REGNO (inclusive) to END_REGNO (exclusive),
   either explicitly or in the guise of a pseudo-reg allocated to REGNO.
   X should be the body of an instruction.  
             See if this reg overlaps range under consideration.  
static int immune_p ( rtx  ,
rtx  ,
struct decomposition   
static int immune_p ( )
   Return 1 if altering Y will not modify the value of X.
   Y is also described by YDATA, which should be decompose (Y).  
     If Y is memory and X is not, Y can't affect X.  
         If bases are distinct symbolic constants, there is no overlap.  
         Constants and stack slots never overlap.  
         If either base is variable, we don't know anything.  
static rtx make_memloc ( rtx  ,
static rtx make_memloc ( )
   Return a mem ref for the memory equivalent of reg REGNO.
   This mem ref is not shared with anything.  
     We must rerun eliminate_regs, in case the elimination
     offsets have changed.  
     If TEM might contain a pseudo, we must copy it to avoid
     modifying it when we do the substitution for the reload.  
     Copy the result if it's still the same as the equivalence, to avoid
     modifying it when we do the substitution for the reload.  

References regno_ok_for_base_p().

static int maybe_memory_address_addr_space_p ( enum machine_mode  mode,
rtx  ad,
addr_space_t  as,
rtx part 
   Returns true if AD could be turned into a valid memory reference
   to mode MODE in address space AS by reloading the part pointed to
   by PART into a register.  

References base_reg_class(), find_reloads_address_1(), find_reloads_address_part(), and plus_constant().

void move_replacements ( )
   Change any replacements being done to *X to be done to *Y.  

Referenced by find_reloads_toplev().

int operands_match_p ( )
   Like rtx_equal_p except that it allows a REG and a SUBREG to match
   if they are the same hard reg, and has special hacks for
   autoincrement and autodecrement.
   This is specifically intended for find_reloads to use
   in determining whether two operands match.
   X is the operand whose number is the lower of the two.

   The value is 2 if Y contains a pre-increment that matches
   a non-incrementing address in X.  
   ??? To be completely correct, we should arrange to pass
   for X the output operand and for Y the input operand.
   For now, we assume that the output operand has the lower number
   because that is natural in (SET output (... input ...)).  
         On a REG_WORDS_BIG_ENDIAN machine, point to the last register of a
         multiple hard register group of scalar integer registers, so that
         for example (reg:DI 0) and (reg:SI 1) will be considered the same
     If two operands must match, because they are really a single
     operand of an assembler insn, then two postincrements are invalid
     because the assembler insn would increment only once.
     On the other hand, a postincrement matches ordinary indexing
     if the postincrement is the output operand.  
     Two preincrements are invalid
     because the assembler insn would increment only once.
     On the other hand, a preincrement matches ordinary indexing
     if the preincrement is the input operand.
     In this case, return 2, since some callers need to do special
     things when this happens.  
     Now we have disposed of all the cases in which different rtx codes
     can match.  
     (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.  
     MEMs referring to different address space are not equivalent.  
     Compare the elements.  If any pair of corresponding elements
     fail to match, return 0 for the whole things.  
             If any subexpression returns 2,
             we should return 2 if we are successful.  
             It is believed that rtx's at this level will never
             contain anything but integers and other rtx's,
             except for within LABEL_REFs and SYMBOL_REFs.  

References decomposition::base, decompose(), decomposition::end, end_hard_regno(), memset(), offset, decomposition::reg_flag, decomposition::safe, decomposition::start, subreg_nregs(), and true_regnum().

static void push_reg_equiv_alt_mem ( )
   Add NEW to reg_equiv_alt_mem_list[REGNO] if it's not present in the
   list yet.  


int push_reload ( rtx  in,
rtx  out,
rtx inloc,
rtx outloc,
enum reg_class  rclass,
enum machine_mode  inmode,
enum machine_mode  outmode,
int  strict_low,
int  optional,
int  opnum,
enum reload_type  type 
   Record one reload that needs to be performed.
   IN is an rtx saying where the data are to be found before this instruction.
   OUT says where they must be stored after the instruction.
   (IN is zero for data not read, and OUT is zero for data not written.)
   INLOC and OUTLOC point to the places in the instructions where
   IN and OUT were found.
   If IN and OUT are both nonzero, it means the same register must be used
   to reload both IN and OUT.

   RCLASS is a register class required for the reloaded data.
   INMODE is the machine mode that the instruction requires
   for the reg that replaces IN and OUTMODE is likewise for OUT.

   If IN is zero, then OUT's location and mode should be passed as

   STRICT_LOW is the 1 if there is a containing STRICT_LOW_PART rtx.

   OPTIONAL nonzero means this reload does not need to be performed:
   it can be discarded if that is more convenient.

   OPNUM and TYPE say what the purpose of this reload is.

   The return value is the reload-number for this reload.

   If both IN and OUT are nonzero, in some rare cases we might
   want to make two separate reloads.  (Actually we never do this now.)
   Therefore, the reload-number for OUT is stored in
   output_reloadnum when we return; the return value applies to IN.
   Usually (presently always), when IN and OUT are nonzero,
   the two reload-numbers are equal, but the caller should be careful to
   distinguish them.  
     INMODE and/or OUTMODE could be VOIDmode if no mode
     has been specified for the operand.  In that case,
     use the operand's mode as the mode to reload.  
     If find_reloads and friends until now missed to replace a pseudo
     with a constant of reg_equiv_constant something went wrong
     Note that it can't simply be done here if we missed it earlier
     since the constant might need to be pushed into the literal pool
     and the resulting memref would probably need further
     reg_equiv_constant only contains constants which are obviously
     not appropriate as destination.  So if we would need to replace
     the destination pseudo with a constant we are in real
     If we have a read-write operand with an address side-effect,
     change either IN or OUT so the side-effect happens only once.  
     If we are reloading a (SUBREG constant ...), really reload just the
     inside expression in its own mode.  Similarly for (SUBREG (PLUS ...)).
     If we have (SUBREG:M1 (MEM:M2 ...) ...) (or an inner REG that is still
     a pseudo and hence will become a MEM) with M1 wider than M2 and the
     register is a pseudo, also reload the inside expression.
     For machines that extend byte loads, do this for any SUBREG of a pseudo
     where both M1 and M2 are a word or smaller, M1 is wider than M2, and
     M2 is an integral mode that gets extended when loaded.
     Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R
     where either M1 is not valid for R or M2 is wider than a word but we
     only need one register to store an M2-sized quantity in R.
     (However, if OUT is nonzero, we need to reload the reg *and*
     the subreg, so do nothing here, and let following statement handle it.)

     Note that the case of (SUBREG (CONST_INT...)...) is handled elsewhere;
     we can't handle it here because CONST_INT does not indicate a mode.

     Similarly, we must reload the inside expression if we have a
     STRICT_LOW_PART (presumably, in == out in this case).

     Also reload the inner expression if it does not require a secondary
     reload but the SUBREG does.

     Finally, reload the inner expression if it is a register that is in
     the class whose registers cannot be referenced in a different size
     and M1 is not the same size as M2.  If subreg_lowpart_p is false, we
     cannot reload just the inside since we might end up with the wrong
     register class.  But if it is inside a STRICT_LOW_PART, we have
     no choice, so we hope we do get the right register class there.  
                 The case where out is nonzero
                 is handled differently in the following statement.  
           This is supposed to happen only for paradoxical subregs made by
           combine.c.  (SUBREG (MEM)) isn't supposed to occur other ways.  
     Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R
     where M1 is not valid for R if it was not handled by the code above.

     Similar issue for (SUBREG constant ...) if it was not handled by the
     code above.  This can happen if SUBREG_BYTE != 0.

     However, we must reload the inner reg *as well as* the subreg in
     that case.  
         This relies on the fact that emit_reload_insns outputs the
         instructions for input reloads of type RELOAD_OTHER in the same
         order as the reloads.  Thus if the outer reload is also of type
         RELOAD_OTHER, we are guaranteed that this inner reload will be
         output before the outer reload.  
     Similarly for paradoxical and problematical SUBREGs on the output.
     Note that there is no reason we need worry about the previous value
     of SUBREG_REG (out); even if wider than out, storing in a subreg is
     entitled to clobber it all (except in the case of a word mode subreg
     or of a STRICT_LOW_PART, in that latter case the constraint should
     label it input-output.)  
                 The case of a word mode subreg
                 is handled differently in the following statement.  
     Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R
     where either M1 is not valid for R or M2 is wider than a word but we
     only need one register to store an M2-sized quantity in R.

     However, we must reload the inner reg *as well as* the subreg in
     that case and the inner reg is an in-out reload.  
         This relies on the fact that emit_reload_insns outputs the
         instructions for output reloads of type RELOAD_OTHER in reverse
         order of the reloads.  Thus if the outer reload is also of type
         RELOAD_OTHER, we are guaranteed that this inner reload will be
         output after the outer reload.  
     If IN appears in OUT, we can't share any input-only reload for IN.  
     If IN is a SUBREG of a hard register, make a new REG.  This
     simplifies some of the cases below.  
     Similarly for OUT.  
     Narrow down the class of register wanted if that is
     desirable on this machine for efficiency.  
       Output reloads may need analogous treatment, different in detail.  
       Discard what the target said if we cannot do it.  
     Make sure we use a class that can handle the actual pseudo
     inside any subreg.  For example, on the 386, QImode regs
     can appear within SImode subregs.  Although GENERAL_REGS
     can handle SImode, QImode needs a smaller class.  
     Verify that this class is at least possible for the mode that
     is specified.  
             Avoid further trouble with this insn.  
             We used to continue here setting class to ALL_REGS, but it triggers
             sanity check on i386 for:
             void foo(long double d)
               asm("" :: "a" (d));
             Returning zero here ought to be safe as we take care in
             find_reloads to not process the reloads when instruction was
             replaced by USE.  
     Optional output reloads are always OK even if we have no register class,
     since the function of these reloads is only to have spill_reg_store etc.
     set, so that the storing insn can be deleted later.  
         See if we need a secondary reload register to move between CLASS
         and IN or CLASS and OUT.  Get the icode and push any required reloads
         needed for each of them if so.  
         We found no existing reload suitable for re-use.
         So add an additional reload.  
         If a memory location is needed for the copy, make one.  
         We are reusing an existing reload,
         but we may have additional information for it.
         For example, we may now have both IN and OUT
         while the old one may have just one of them.  
         The modes can be different.  If they are, we want to reload in
         the larger mode, so that the value is valid for both modes.  
             If we merge reloads for two distinct rtl expressions that
             are identical in content, there might be duplicate address
             reloads.  Remove the extra set now, so that if we later find
             that we can inherit this reload, we can get rid of the
             address reloads altogether.

             Do not do this if both reloads are optional since the result
             would be an optional reload which could potentially leave
             unresolved address replacements.

             It is not sufficient to call transfer_replacements since
             choose_reload_regs will remove the replacements for address
             reloads of inherited reloads which results in the same
                 We must keep the address reload with the lower operand
                 number alive.  
             When emitting reloads we don't necessarily look at the in-
             and outmode, but also directly at the operands (in and out).
             So we can't simply overwrite them with whatever we have found
             for this (to-be-merged) reload, we have to "merge" that too.
             Reusing another reload already verified that we deal with the
             same operands, just possibly in different modes.  So we
             overwrite the operands only when the new mode is larger.
             See also PR33613.  
     If the ostensible rtx being reloaded differs from the rtx found
     in the location to substitute, this reload is not safe to combine
     because we cannot reliably tell whether it appears in the insn.  
     This was replaced by changes in find_reloads_address_1 and the new
     function inc_for_reload, which go with a new meaning of reload_inc.  
     If this is an IN/OUT reload in an insn that sets the CC,
     it must be for an autoincrement.  It doesn't work to store
     the incremented value after the insn because that would clobber the CC.
     So we must do the increment of the value reloaded from,
     increment it, store it back, then decrement again.  
         If we did not find a nonzero amount-to-increment-by,
         that contradicts the belief that IN is being incremented
         in an address in this insn.  
     If we will replace IN and OUT with the reload-reg,
     record where they are located so that substitution need
     not do a tree walk.  
     If this reload is just being introduced and it has both
     an incoming quantity and an outgoing quantity that are
     supposed to be made to match, see if either one of the two
     can serve as the place to reload into.

     If one of them is acceptable, set rld[i].reg_rtx
     to that one.  
         If the outgoing register already contains the same value
         as the incoming one, we can dispense with loading it.
         The easiest way to tell the caller that is to give a phony
         value for the incoming operand (same as outgoing one).  
     If this is an input reload and the operand contains a register that
     dies in this insn and is used nowhere else, see if it is the right class
     to be used for this reload.  Use it if so.  (This occurs most commonly
     in the case of paradoxical SUBREGs and in-out reloads).  We cannot do
     this if it is also an output reload that mentions the register unless
     the output is a SUBREG that clobbers an entire register.

     Note that the operand might be one of the spill regs, if it is a
     pseudo reg and we are in a block where spilling has not taken place.
     But if there is no spilling in this block, that is OK.
     An explicitly used hard reg cannot be a spill reg.  
               Check that a former pseudo is valid; see find_dummy_reload.  
               If this is also an output reload, IN cannot be used as
               the reload register if it is set in this insn unless IN
               is also OUT.  
               ??? Why is this code so different from the previous?
               Is there any simple coherent way to describe the two together?
               What's going on here.  
               Make sure the operand fits in the reg that dies.  

Referenced by update_auto_inc_notes().

static void push_replacement ( rtx ,
int  ,
enum  machine_mode 
static void push_replacement ( )
   Record an additional place we must replace a value
   for which we have already recorded a reload.
   RELOADNUM is the value returned by push_reload
   when the reload was recorded.
   This is used in insn patterns that use match_dup.  
static int push_secondary_reload ( int  in_p,
rtx  x,
int  opnum,
int  optional,
enum reg_class  reload_class,
enum machine_mode  reload_mode,
enum reload_type  type,
enum insn_code *  picode,
secondary_reload_info prev_sri 
   Determine if any secondary reloads are needed for loading (if IN_P is
   nonzero) or storing (if IN_P is zero) X to or from a reload register of
   register class RELOAD_CLASS in mode RELOAD_MODE.  If secondary reloads
   are needed, push them.

   Return the reload number of the secondary reload we made, or -1 if
   we didn't need one.  *PICODE is set to the insn_code to use if we do
   need a secondary reload.  
     If X is a paradoxical SUBREG, use the inner value to determine both the
     mode and object being reloaded.  
     If X is a pseudo-register that has an equivalent MEM (actually, if it
     is still a pseudo-register by now, it *must* have an equivalent MEM
     but we don't want to assume that), use that equivalent when seeing if
     a secondary reload is needed since whether or not a reload is needed
     might be sensitive to the form of the MEM.  
     If we don't need any secondary registers, done.  
     If we will be using an insn, the secondary reload is for a
     scratch register.  
         If IN_P is nonzero, the reload register will be the output in
         operand 0.  If IN_P is zero, the reload register will be the input
         in operand 1.  Outputs should have an initial "=", which we must
         ??? It would be useful to be able to handle only two, or more than
         three, operands, but for now we can only handle the case of having
         exactly three: output, input and one temp/scratch.  
         ??? We currently have no way to represent a reload that needs
         an icode to reload from an intermediate tertiary reload register.
         We should probably have a new field in struct reload to tag a
         chain of scratch operand reloads onto.   
     This case isn't valid, so fail.  Reload is allowed to use the same
     register for RELOAD_FOR_INPUT_ADDRESS and RELOAD_FOR_INPUT reloads, but
     in the case of a secondary register, we actually need two different
     registers for correct code.  We fail here to prevent the possibility of
     silently generating incorrect code later.

     The convention is that secondary input reloads are valid only if the
     secondary_class is different from class.  If you have such a case, you
     can not use secondary reloads, you must work around the problem some
     other way.

     Allow this when a reload_in/out pattern is being used.  I.e. assume
     that the generated code handles this case.  
     See if we can reuse an existing secondary reload.  
         If we need a memory location to copy between the two reload regs,
         set it up now.  Note that we do the input case before making
         the reload and the output case after.  This is due to the
         way reloads are output.  
             We may have just added new reloads.  Make sure we add
             the new reload at the end.  
         We need to make a new secondary reload for this register class.  
         Maybe we could combine these, but it seems too tricky.  
static int refers_to_mem_for_reload_p ( rtx  )
static int refers_to_mem_for_reload_p ( )
   Return nonzero if anything in X contains a MEM.  Look also for pseudo
static int refers_to_regno_for_reload_p ( unsigned int  regno,
unsigned int  endregno,
rtx  x,
rtx loc 
   Return nonzero if register in range [REGNO, ENDREGNO)
   appears either explicitly or implicitly in X
   other than being stored into (except for earlyclobber operands).

   References contained within the substructure at LOC do not count.
   LOC may be zero, meaning don't ignore anything.

   This is similar to refers_to_regno_p in rtlanal.c except that we
   look at equivalences for pseudos that didn't get hard registers.  
         If this is a pseudo, a hard register must not have been allocated.
         X must therefore either be a constant or be in memory.  
         If this is a SUBREG of a hard reg, we can see exactly which
         registers are being modified.  Otherwise, handle normally.  
             Note setting a SUBREG counts as referring to the REG it is in for
             a pseudo but not for hard registers since we can
             treat each word individually.  
                 If the output is an earlyclobber operand, this is
                 a conflict.  
     X does not match, so try its subexpressions.  
static int reg_inc_found_and_valid_p ( unsigned int  regno,
unsigned int  endregno,
rtx  insn 
   Return 1 if registers from REGNO to ENDREGNO are the subjects of a
   REG_INC note in insn INSN.  REGNO must refer to a hard register.  
int reg_overlap_mentioned_for_reload_p ( )
   Nonzero if modifying X will affect IN.  If X is a register or a SUBREG,
   we check if any register number in X conflicts with the relevant register
   numbers.  If X is a constant, return 0.  If X is a MEM, return 1 iff IN
   contains a MEM (we don't bother checking for memory addresses that can't
   conflict because we expect this to be a rare case.

   This function is similar to reg_overlap_mentioned_p in rtlanal.c except
   that we look at equivalences for pseudos that didn't get hard registers.  
     Overly conservative.  
     If either argument is a constant, then modifying X can not affect IN.  
         If this is a pseudo, it must not have been assigned a hard register.
         Therefore, it must either be in memory or be a constant.  
         We actually want to know if X is mentioned somewhere inside IN.
         We must not say that (plus (sp) (const_int 124)) is in
         (plus (sp) (const_int 64)), since that can lead to incorrect reload
         allocation when spuriously changing a RELOAD_FOR_OUTPUT_ADDRESS
         into a RELOAD_OTHER on behalf of another RELOAD_OTHER.  

Referenced by copy_replacements_1().

int regno_clobbered_p ( unsigned int  regno,
rtx  insn,
enum machine_mode  mode,
int  sets 
   Return 1 if register REGNO is the subject of a clobber in insn INSN.
   If SETS is 1, also consider SETs.  If SETS is 2, enable checking
   REG_INC.  REGNO must refer to a hard register.  
     regno must be a hard register.  
rtx reload_adjust_reg_for_mode ( )
   Find the low part, with mode MODE, of a hard regno RELOADREG.  
static bool reload_inner_reg_of_subreg ( )
   Return true if X is a SUBREG that will need reloading of its SUBREG_REG
   expression.  MODE is the mode that X will be used in.  OUTPUT is true if
   the function is invoked for the output part of an enclosing reload.  
     Only SUBREGs are problematical.  
     If INNER is a constant or PLUS, then INNER will need reloading.  
     If INNER is not a hard register, then INNER will not need reloading.  
     If INNER is not ok for MODE, then INNER will need reloading.  
     If this is for an output, and the outer part is a word or smaller,
     INNER is larger than a word and the number of registers in INNER is
     not the same as the number of words in INNER, then INNER will need
     reloading (with an in-out reload).  
int remove_address_replacements ( )
   IN_RTX is the value loaded by a reload that we now decided to inherit,
   or a subpart of it.  If we have any replacements registered for IN_RTX,
   cancel the reloads that were supposed to load them.
   Return nonzero if we canceled any reloads.  
     Note that the following store must be done before the recursive calls.  

References reload::opnum, reload::out, reload::out_reg, reload::outmode, reg_class_subset_p(), RELOAD_OTHER, rld, reload::secondary_out_icode, reload::secondary_out_reload, targetm, and reload::when_needed.

int safe_from_earlyclobber ( )
   Similar, but calls decompose.  
enum reg_class scratch_reload_class ( )
   ICODE is the insn_code of a reload pattern.  Check that it has exactly
   three operands, verify that operand 2 is an output operand, and return
   its register class.
   ??? We'd like to be able to handle any pattern with at least 2 operands,
   for zero or more scratch registers, but that needs more infrastructure.  
reg_class_t secondary_reload_class ( bool  in_p,
reg_class_t  rclass,
enum machine_mode  mode,
rtx  x 
   If a secondary reload is needed, return its class.  If both an intermediate
   register and a scratch register is needed, we return the class of the
   intermediate register.  
     If there are no secondary reloads at all, we return NO_REGS.
     If an intermediate register is needed, we return its class.  
     No intermediate register is needed, but we have a special reload
     pattern, which we assume for now needs a scratch register.  

Referenced by deallocate_reload_reg().

static bool small_register_class_p ( )
   True if C is a non-empty register class that has too few registers
   to be safely used as a reload target class.  

Referenced by find_valid_class_1().

int strict_memory_address_addr_space_p ( enum machine_mode  mode,
rtx  addr,
addr_space_t  as 
   Return 1 if ADDR is a valid memory address for mode MODE
   in address space AS, and check that each pseudo reg has the
   proper kind of hard reg.  

References operands_match_p().

Referenced by subreg_lowpart_offset().

static rtx subst_indexed_address ( rtx  )
static rtx subst_indexed_address ( )
   If ADDR is a sum containing a pseudo register that should be
   replaced with a constant (from reg_equiv_constant),
   return the result of doing so, and also apply the associative
   law so that the result is more likely to be a valid address.
   (But it is not guaranteed to be one.)

   Note that at most one register is replaced, even if more are
   replaceable.  Also, we try to put the result into a canonical form
   so it is more likely to be a valid address.

   In all other cases, return ADDR.  
         Try to find a register to replace.  
         Pick out up to three things to add.  
         Compute the sum.  
static rtx subst_reg_equivs ( rtx  ,
static rtx subst_reg_equivs ( )
   Find all pseudo regs appearing in AD
   that are eliminable in favor of equivalent values
   and do not have hard regs; replace them by their equivalents.
   INSN, if nonzero, is the insn in which we do the reload.  We put USEs in
   front of it for pseudos that we have to replace with stack slots.  
                   We mark the USE with QImode so that we recognize it
                   as one that can be safely deleted at the end of
         Quickly dispose of a common case.  
void subst_reloads ( )
   Substitute into the current INSN the registers into which we have reloaded
   the things that need reloading.  The array `replacements'
   contains the locations of all pointers that must be changed
   and says what to replace them with.

   Return the rtx that X translates into; usually X, but modified.  
             This checking takes a very long time on some platforms
             causing the gcc.c-torture/compile/limits-fnargs.c test
             to time out during testing.  See PR 31850.

             Internal consistency test.  Check that we don't modify
             anything in the equivalence arrays.  Whenever something from
             those arrays needs to be reloaded, it must be unshared before
             being substituted into; the equivalence must not be modified.
             Otherwise, if the equivalence is used after that, it will
             have been modified, and the thing substituted (probably a
             register) is likely overwritten and not a usable equivalence.  
             If we're replacing a LABEL_REF with a register, there must
             already be an indication (to e.g. flow) which label this
             register refers to.  
             Encapsulate RELOADREG so its machine mode matches what
             used to be there.  Note that gen_lowpart_common will
             do the wrong thing if RELOADREG is multi-word.  RELOADREG
             will always be a REG here.  
         If reload got no reg and isn't optional, something's wrong.  

References replacement::where.

void transfer_replacements ( )
   Transfer all replacements that used to be in reload FROM to be in
   reload TO.  

References targetm.

static void update_auto_inc_notes ( rtx  insn,
int  regno,
int  reloadnum 
   Update the REG_INC notes for an insn.  It updates all REG_INC
   notes for the instruction which refer to REGNO the to refer
   to the reload number.

   INSN is the insn for which any REG_INC notes need updating.

   REGNO is the register number which has been reloaded.

   RELOADNUM is the reload number.  

References push_reload(), and RELOAD_OTHER.

Variable Documentation

int hard_regs_live_known
   If hard_regs_live_known is nonzero,
   we can tell which hard regs are currently live,
   at least enough to succeed in choosing dummy reloads.  
int n_earlyclobbers
   All the "earlyclobber" operands of the current insn
   are recorded here.  
int n_reloads
   All reloads of the current insn are recorded here.  See reload.h for

Referenced by find_valid_class_1(), gen_reload_chain_without_interm_reg_p(), and maybe_fix_stack_asms().

int n_replacements
   Number of replacements currently recorded.  
int output_reloadnum
   On return from push_reload, holds the reload-number for the OUT
   operand, which can be different for that from the input operand.  
rtx reload_earlyclobbers[MAX_RECOG_OPERANDS]
int reload_n_operands
   Save the number of operands.  
const char* const reload_when_needed_name[]
Initial value:
int replace_reloads
   Replacing reloads.

   If `replace_reloads' is nonzero, then as each reload is recorded
   an entry is made for it in the table `replacements'.
   Then later `subst_reloads' can look through that table and
   perform all the replacements needed.  
   Nonzero means record the places to replace.  
struct replacement replacements[MAX_RECOG_OPERANDS *((MAX_REGS_PER_ADDRESS *2)+1)]
rtx secondary_memlocs[NUM_MACHINE_MODES]
   Save MEMs needed to copy from one class of registers to another.  One MEM
   is used per mode, but normally only one or two modes are ever used.

   We keep two versions, before and after register elimination.  The one
   after register elimination is record separately for each operand.  This
   is done in case the address is not valid to be sure that we separately
   reload each.  
rtx secondary_memlocs_elim[NUM_MACHINE_MODES][MAX_RECOG_OPERANDS]
int secondary_memlocs_elim_used = 0
short* static_reload_reg_p
   Indexed by hard reg number,
   element is nonnegative if hard reg has been spilled.
   This vector is passed to `find_reloads' as an argument
   and is not changed here.  
int subst_reg_equivs_changed
   Set to 1 in subst_reg_equivs if it changes anything.  
rtx this_insn
   The instruction we are doing reloads for;
   so we can test whether a register dies in it.  
int this_insn_is_asm
   Nonzero if this instruction is a user-specified asm with operands.