home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / local-alloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-01  |  37.1 KB  |  1,201 lines  |  [TEXT/KAHL]

  1. /* Allocate registers within a basic block, for GNU compiler.
  2.    Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* Allocation of hard register numbers to pseudo registers is done in
  22.    two passes.  In this pass we consider only regs that are born and
  23.    die once within one basic block.  We do this one basic block at a
  24.    time.  Then the next pass allocates the registers that remain.
  25.    Two passes are used because this pass uses methods that work only
  26.    on linear code, but that do a better job than the general methods
  27.    used in global_alloc, and more quickly too.
  28.  
  29.    The assignments made are recorded in the vector reg_renumber
  30.    whose space is allocated here.  The rtl code itself is not altered.
  31.  
  32.    We assign each instruction in the basic block a number
  33.    which is its order from the beginning of the block.
  34.    Then we can represent the lifetime of a pseudo register with
  35.    a pair of numbers, and check for conflicts easily.
  36.    We can record the availability of hard registers with a
  37.    HARD_REG_SET for each instruction.  The HARD_REG_SET
  38.    contains 0 or 1 for each hard reg.
  39.  
  40.    To avoid register shuffling, we tie registers together when one
  41.    dies by being copied into another, or dies in an instruction that
  42.    does arithmetic to produce another.  The tied registers are
  43.    allocated as one.  Registers with different reg class preferences
  44.    can never be tied unless the class preferred by one is a subclass
  45.    of the one preferred by the other.
  46.  
  47.    Tying is represented with "quantity numbers".
  48.    A non-tied register is given a new quantity number.
  49.    Tied registers have the same quantity number.
  50.    
  51.    We have provision to exempt registers, even when they are contained
  52.    within the block, that can be tied to others that are not contained in it.
  53.    This is so that global_alloc could process them both and tie them then.
  54.    But this is currently disabled since tying in global_alloc is not
  55.    yet implemented.  */
  56.  
  57. #include <stdio.h>
  58. #include "config.h"
  59. #include "rtl.h"
  60. #include "flags.h"
  61. #include "basic-block.h"
  62. #include "regs.h"
  63. #include "hard-reg-set.h"
  64. #include "insn-config.h"
  65. #include "recog.h"
  66.  
  67. #ifdef MPW
  68. #include <CursorCtl.h>
  69. #endif
  70.  
  71. /* What about hardware registers used and set within same insn?
  72.    Will that ever happen for a non-fixed register?
  73.    Our lifetime-tracking for hardware registers would lose.
  74.    [This caution is an old comment that may be obsolete;
  75.     I think there is no longer a problem, but I'm not sure.]  */
  76.  
  77. /* Next quantity number available for allocation.  */
  78.  
  79. static int next_qty;
  80.  
  81. /* In all the following vectors indexed by quantity number,
  82.    only elements at indices >= FIRST_PSEUDO_REGISTER are actually used.  */
  83.  
  84. /* Element Q is the hard reg number chosen for quantity Q,
  85.    or -1 if none was found.  */
  86.  
  87. static short *qty_phys_reg;
  88.  
  89. /* Element Q is the hard reg number suggested for quantity Q,
  90.    or -1 if no specific suggestion.  */
  91.  
  92. static short *qty_phys_sugg;
  93.  
  94. /* Element Q is the number of refs to quantity Q.  */
  95.  
  96. static short *qty_n_refs;
  97.  
  98. /* Element Q is a reg class contained in (smaller than) the
  99.    preferred classes of all the pseudo regs that are tied in quantity Q.
  100.    This is the preferred class for allocating that quantity.  */
  101.  
  102. static enum reg_class *qty_min_class;
  103.  
  104. /* Insn number (counting from head of basic block)
  105.    where quantity Q was born.  -1 if birth has not been recorded.  */
  106.  
  107. static int *qty_birth;
  108.  
  109. /* Insn number (counting from head of basic block)
  110.    where quantity Q died.  Due to the way tying is done,
  111.    and the fact that we consider in this pass only regs that die but once,
  112.    a quantity can die only once.  Each quantity's life span
  113.    is a set of consecutive insns.  -1 if death has not been recorded.  */
  114.  
  115. static int *qty_death;
  116.  
  117. /* Number of words needed to hold the data in quantity Q.
  118.    This depends on its machine mode.  It is used for these purposes:
  119.    1. If it is 0, the qty is not really in use and is not allocated.
  120.    2. It is used in computing the relative importances of qtys,
  121.       which determines the order in which we look for regs for them.
  122.    3. It is used in rules that prevent tying several registers of
  123.       different sizes in a way that is geometrically impossible
  124.       (see combine_regs).  */
  125.  
  126. static int *qty_size;
  127.  
  128. /* This holds the mode of the registers that are tied to qty Q,
  129.    or VOIDmode if registers with differing modes are tied together.  */
  130.  
  131. static enum machine_mode *qty_mode;
  132.  
  133. /* Number of times a reg tied to qty Q lives across a CALL_INSN.  */
  134.  
  135. static int *qty_n_calls_crossed;
  136.  
  137. /* Nonzero means don't allocate qty Q if we can't get its preferred class.  */
  138.  
  139. static char *qty_preferred_or_nothing;
  140.  
  141. /* reg_qty[N] (where N is a pseudo reg number)
  142.    is the qty number of that reg (which is >= FIRST_PSEUDO_REGISTER),
  143.    or -1 if (REG N) is not local to the current basic block,
  144.    or -2 if not known yet.
  145.  
  146.    If N is < FIRST_PSEUDO_REGISTER, reg_qty[N] is -1.  */
  147.  
  148. static int *reg_qty;
  149.  
  150. /* The offset (in words) of register N within its quantity.
  151.    This can be nonzero if register N is SImode, and has been tied
  152.    to a subreg of a DImode register.  */
  153.  
  154. static int *reg_offset;
  155.  
  156. /* Vector of substitutions of register numbers,
  157.    used to map pseudo regs into hardware regs.
  158.    This is set up as a result of register allocation.
  159.    Element N is the hard reg assigned to pseudo reg N,
  160.    or is -1 if no hard reg was assigned.
  161.    If N is a hard reg number, element N is N.  */
  162.  
  163. short *reg_renumber;
  164.  
  165. /* Set of hard registers live at the current point in the scan
  166.    of the instructions in a basic block.  */
  167.  
  168. static HARD_REG_SET regs_live;
  169.  
  170. /* Indexed by insn-number-within-basic-block,
  171.    a set or hard registers live *after* that insn.  */
  172.  
  173. static HARD_REG_SET *regs_live_at;
  174.  
  175. /* Nonzero if a CALL_INSN has been scanned
  176.    but we have not yet seen a reference to the value returned.  */
  177.  
  178. static int call_seen;
  179.  
  180. /* Communicate local vars `insn_number' and `insn'
  181.    from `block_alloc' to `reg_is_set' and `wipe_dead_reg'.  */
  182. static int this_insn_number;
  183. static rtx this_insn;
  184.  
  185. static void block_alloc ();
  186. static int combine_regs ();
  187. static void wipe_dead_reg ();
  188. static int find_free_reg ();
  189. static void reg_is_born ();
  190. static void reg_is_set ();
  191. static void mark_life ();
  192. static void post_mark_life ();
  193. static int qty_compare ();
  194. static int qty_compare_1 ();
  195. static int reg_meets_class_p ();
  196. static int reg_class_subset_p ();
  197. static void update_qty_class ();
  198.  
  199. /* Allocate a new quantity (new within current basic block)
  200.    for register number REGNO which is born in insn number INSN_NUMBER
  201.    within the block.  MODE and SIZE are info on reg REGNO.  */
  202.  
  203. static void
  204. alloc_qty (regno, mode, size, insn_number)
  205.      int regno;
  206.      enum machine_mode mode;
  207.      int size, insn_number;
  208. {
  209.   register int qty = next_qty++;
  210.   reg_qty[regno] = qty;
  211.   reg_offset[regno] = 0;
  212.   qty_size[qty] = size;
  213.   qty_mode[qty] = mode;
  214.   qty_birth[qty] = insn_number;
  215.   qty_n_calls_crossed[qty] = reg_n_calls_crossed[regno];
  216.   qty_min_class[qty] = reg_preferred_class (regno);
  217.   qty_preferred_or_nothing[qty] = reg_preferred_or_nothing (regno);
  218.   qty_n_refs[qty] = reg_n_refs[regno];
  219. }
  220.  
  221. /* Main entry point of this file.  */
  222.  
  223. void
  224. local_alloc ()
  225. {
  226.   register int b, i;
  227.  
  228.   /* Allocate vectors of temporary data.
  229.      See the declarations of these variables, above,
  230.      for what they mean.  */
  231.  
  232.   qty_phys_reg = (short *) alloca (max_regno * sizeof (short));
  233.   qty_phys_sugg = (short *) alloca (max_regno * sizeof (short));
  234.   qty_birth = (int *) alloca (max_regno * sizeof (int));
  235.   qty_death = (int *) alloca (max_regno * sizeof (int));
  236.   qty_size = (int *) alloca (max_regno * sizeof (int));
  237.   qty_mode = (enum machine_mode *) alloca (max_regno * sizeof (enum machine_mode));
  238.   qty_n_calls_crossed = (int *) alloca (max_regno * sizeof (int));
  239.   qty_min_class = (enum reg_class *) alloca (max_regno * sizeof (enum reg_class));
  240.   qty_preferred_or_nothing = (char *) alloca (max_regno);
  241.   qty_n_refs = (short *) alloca (max_regno * sizeof (short));
  242.  
  243.   reg_qty = (int *) alloca (max_regno * sizeof (int));
  244.   reg_offset = (int *) alloca (max_regno * sizeof (int));
  245.  
  246.   reg_renumber = (short *) oballoc (max_regno * sizeof (short));
  247.   for (i = 0; i < max_regno; i++)
  248.     reg_renumber[i] = -1;
  249.  
  250.   /* This controls only how many elts of the `qty_...' vectors
  251.      need to be zero for the first basic block.  */
  252.   next_qty = max_regno;
  253.  
  254.   /* Allocate each block's local registers, block by block.  */
  255.  
  256.   for (b = 0; b < n_basic_blocks; b++)
  257.     {
  258.  
  259. #ifdef MPW
  260.     SpinCursor(1);
  261. #endif
  262.  
  263.     for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  264.     {
  265.       reg_qty[i] = -1;
  266.     }
  267.     for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  268.     {
  269.       qty_phys_sugg[i] = -1;
  270.       qty_birth[i] = -1;
  271.       qty_death[i] = -1;
  272.       /* Set reg_qty to -2 for pseudos in this block, -1 for others.  */
  273.       if (reg_basic_block[i] == b && reg_n_deaths[i] == 1)
  274.         reg_qty[i] = -2;
  275.       else
  276.         reg_qty[i] = -1;
  277.     }
  278.  
  279.       bzero (reg_offset, max_regno * sizeof (int));
  280.  
  281.       /* NEXT_QTY indicates which elements of the `qty_...'
  282.      vectors might need to be initialized.  Initialize those,
  283.      with explicit loop if there are few, else with bzero.  */
  284.  
  285.       if (next_qty < FIRST_PSEUDO_REGISTER + 6)
  286.     {
  287.       for (i = FIRST_PSEUDO_REGISTER; i < next_qty; i++)
  288.         {
  289.           qty_size[i] = 0;
  290.           qty_mode[i] = VOIDmode;
  291.           qty_min_class[i] = NO_REGS;
  292.           qty_preferred_or_nothing[i] = 0;
  293.           qty_n_calls_crossed[i] = 0;
  294.           qty_n_refs[i] = 0;
  295.         }
  296.     }
  297.       else
  298.     {
  299.       int clear_length = next_qty - FIRST_PSEUDO_REGISTER;
  300.  
  301. #define CLEAR(vector)  \
  302.    bzero ((vector) + FIRST_PSEUDO_REGISTER,    \
  303.       (sizeof (*(vector))) * clear_length)
  304.  
  305.       CLEAR (qty_size);
  306.       CLEAR (qty_mode);
  307.       CLEAR (qty_min_class);
  308.       CLEAR (qty_preferred_or_nothing);
  309.       CLEAR (qty_n_calls_crossed);
  310.       CLEAR (qty_n_refs);
  311.     }
  312.  
  313.       next_qty = FIRST_PSEUDO_REGISTER;
  314.  
  315.       block_alloc (b);
  316. #ifdef USE_C_ALLOCA
  317.       alloca (0);
  318. #endif
  319.     }
  320. }
  321.  
  322. /* Allocate hard regs to the pseudo regs used only within block number B.
  323.    Only the pseudos that die but once can be handled.  */
  324.  
  325. static void
  326. block_alloc (b)
  327.      int b;
  328. {
  329.   register int i, q;
  330.   register rtx insn;
  331.   int insn_number = 0;
  332.   int insn_count = 0;
  333.   short *qty_order;
  334.  
  335.   call_seen = 0;
  336.  
  337.   /* Count the instructions in the basic block.  */
  338.  
  339.   insn = basic_block_end[b];
  340.   while (1)
  341.     {
  342.       if (GET_CODE (insn) != NOTE)
  343.     insn_count++;
  344.       if (insn == basic_block_head[b])
  345.     break;
  346.       insn = PREV_INSN (insn);
  347.     }
  348.  
  349.   /* +1 to leave room for a post_mark_life at the last insn.  */
  350.   regs_live_at = (HARD_REG_SET *) alloca ((insn_count + 1)
  351.                       * sizeof (HARD_REG_SET));
  352.   bzero (regs_live_at, (insn_count + 1) * sizeof (HARD_REG_SET));
  353.  
  354.   /* Initialize table of hardware registers currently live.  */
  355.  
  356. #ifdef HARD_REG_SET
  357.   regs_live = *basic_block_live_at_start[b];
  358. #else
  359.   COPY_HARD_REG_SET (regs_live, basic_block_live_at_start[b]);
  360. #endif
  361.  
  362.   /* This loop scans the instructions of the basic block
  363.      and assigns quantities to registers.
  364.      It computes which registers to tie.  */
  365.  
  366.   insn = basic_block_head[b];
  367.   while (1)
  368.     {
  369.       register rtx body = PATTERN (insn);
  370.  
  371. #ifdef MPW
  372.       SpinCursor(1);
  373. #endif
  374.  
  375.       if (GET_CODE (insn) != NOTE)
  376.     insn_number++;
  377.  
  378.       if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
  379.       || GET_CODE (insn) == CALL_INSN)
  380.     {
  381.       register rtx link;
  382.       register int win = 0;
  383.       register rtx r0, r1;
  384.       int combined_regno = -1;
  385.       int insn_code_number = recog_memoized (insn);
  386.       int commutative = 0;
  387.  
  388.       this_insn_number = insn_number;
  389.       this_insn = insn;
  390.  
  391.       /* Set COMMUTATIVE if operands 1 and 2 are commutative.  */
  392.       if (insn_code_number >= 0
  393.           && insn_n_operands[insn_code_number] > 2
  394.           && insn_operand_constraint[insn_code_number][1][0] == '%')
  395.         commutative = 1;
  396.  
  397.       /* Is this insn suitable for tying two registers?
  398.          If so, try doing that.
  399.          Suitable insns are (set reg0 reg1) and
  400.          (set reg0 (arithop reg1 ...)).
  401.          For a commutative operation, try (set reg0 (arithop ... reg1)).
  402.          Subregs in place of regs are also ok.
  403.          An insn with parallel sets is ok if the first set is suitable.
  404.  
  405.          If tying is done, WIN is set nonzero.  */
  406.  
  407.       if (GET_CODE (body) == SET
  408.           && (r0 = SET_DEST (body),
  409.           GET_CODE (r0) == REG || GET_CODE (r0) == SUBREG)
  410.           && (r1 = SET_SRC (body),
  411.           GET_CODE (r1) == REG || GET_CODE (r1) == SUBREG))
  412.         win = combine_regs (r1, r0, b, insn_number, insn);
  413.       else if (GET_CODE (body) == SET)
  414.         {
  415.           r0 = SET_DEST (body);
  416.           if (GET_CODE (r0) == REG || GET_CODE (r0) == SUBREG)
  417.         {
  418.           if (GET_RTX_FORMAT (GET_CODE (SET_SRC (body)))[0] == 'e'
  419.               && (r1 = XEXP (SET_SRC (body), 0),
  420.               GET_CODE (r1) == REG || GET_CODE (r1) == SUBREG))
  421.             win = combine_regs (r1, r0, b, insn_number, insn);
  422.           if (win == 0 && commutative
  423.               && GET_RTX_FORMAT (GET_CODE (SET_SRC (body)))[1] == 'e'
  424.               && (r1 = XEXP (SET_SRC (body), 1),
  425.               GET_CODE (r1) == REG || GET_CODE (r1) == SUBREG))
  426.             win = combine_regs (r1, r0, b, insn_number, insn);
  427.         }
  428.         }
  429.       else if (GET_CODE (body) == PARALLEL)
  430.         {
  431.           rtx set1 = XVECEXP (body, 0, 0);
  432.           if (GET_CODE (set1) == SET 
  433.           && (r0 = SET_DEST (set1),
  434.               GET_CODE (r0) == REG || GET_CODE (r0) == SUBREG)
  435.           && GET_RTX_FORMAT (GET_CODE (SET_SRC (set1)))[0] == 'e'
  436.           && (r1 = XEXP (SET_SRC (set1), 0),
  437.               GET_CODE (r1) == REG || GET_CODE (r1) == SUBREG))
  438.         win = combine_regs (r1, r0, b, insn_number, insn);
  439.           if (win == 0 && commutative && GET_CODE (set1) == SET 
  440.           && (r0 = SET_DEST (set1),
  441.               GET_CODE (r0) == REG || GET_CODE (r0) == SUBREG)
  442.           && GET_RTX_FORMAT (GET_CODE (SET_SRC (set1)))[1] == 'e'
  443.           && (r1 = XEXP (SET_SRC (set1), 1),
  444.               GET_CODE (r1) == REG || GET_CODE (r1) == SUBREG))
  445.         win = combine_regs (r1, r0, b, insn_number, insn);
  446.         }
  447.  
  448.       /* If registers were just tied, set COMBINED_REGNO
  449.          to the number of the register used in this insn
  450.          that was tied to the register set in this insn.
  451.          This register's qty should not be "killed".  */
  452.  
  453.       if (win)
  454.         {
  455.           while (GET_CODE (r1) == SUBREG)
  456.         r1 = SUBREG_REG (r1);
  457.           combined_regno = REGNO (r1);
  458.         }
  459.  
  460.       for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
  461.         {
  462.           /* Mark the death of everything that dies in this instruction,
  463.          except for anything that was just combined.  */
  464.           if (XEXP (link, 0)
  465.           && REG_NOTE_KIND (link) == REG_DEAD
  466.           && combined_regno != REGNO (XEXP (link, 0)))
  467.         {
  468. #if 0  /* The mechanism in reg_is_set that checks whether the qty dies here
  469.       ought to handle this case properly.  */
  470.           if (combined_regno >= 0 &&
  471.               reg_qty[combined_regno] == reg_qty[REGNO (XEXP (link, 0))])
  472.             /* Here for the death of the quotient in a divmod insn:
  473.                something that was born and dead in this insn
  474.                but combined with something else that also dies here.
  475.                Mark the qty as dying one instruction later.  */
  476.             wipe_dead_reg (XEXP (link, 0), insn_number,
  477.                    insn_number + 1);
  478.           else
  479. #endif
  480.             wipe_dead_reg (XEXP (link, 0), insn_number, insn_number);
  481.         }
  482.           /* Also, if this insn introduces a "constant" register,
  483.          that could just be replaced by the value it is given here
  484.          (which can legitimately be an immediate operand),
  485.          tell global-alloc not to allocate it
  486.          unless it is used at least twice more.  */
  487.  
  488.           else if (REG_NOTE_KIND (link) == REG_EQUIV
  489.                && GET_CODE (SET_DEST (body)) == REG
  490.                && general_operand (XEXP (link, 0), VOIDmode)
  491.                /* Don't inhibit allocation of a "constant" register
  492.               that we have already tied to something else!  */
  493.                && combined_regno < 0
  494.                /* Don't mess with things live during setjmp.  */
  495.                && reg_live_length[REGNO (SET_DEST (body))] >= 0)
  496.         {
  497.           i = REGNO (SET_DEST (body));
  498.           if (reg_n_sets[i] > 1)
  499.             {
  500.               /* Register is set in another place => not really constant.
  501.              cse or flow can cause this to happen.
  502.              Ok, forget we ever thought it was constant.  */
  503.               GET_MODE (link) = VOIDmode;
  504.             }
  505.           else if (reg_n_refs[i] <= 2)
  506.             {
  507.               /* For a parameter copy, do let global-alloc
  508.              allocate it; otherwise we would be forced to
  509.              have a frame pointer.  */
  510.               if (! frame_pointer_needed
  511.               && GET_CODE (SET_SRC (PATTERN (insn))) == MEM)
  512.             reg_live_length[i] = -2;
  513.               else
  514.             reg_live_length[i] = -1;
  515.  
  516.               /* If value is not constant, we have a parameter
  517.              or a static chain pointer.  Tell local-alloc
  518.              as well not to allocate it.  */
  519.               if (! CONSTANT_P (SET_SRC (PATTERN (insn))))
  520.             {
  521.               reg_basic_block[i] = REG_BLOCK_GLOBAL;
  522.               reg_qty[i] = -1;
  523.             }
  524.             }
  525.           else
  526.             /* In any case, lower its priority for global-alloc.  */
  527.             reg_live_length[i] *= 2;
  528.         }
  529.         }
  530.  
  531.       /* Allocate qty numbers for all registers local to this block
  532.          that are born (set) in this instruction.
  533.          A pseudo that already has a qty is not changed.  */
  534.  
  535.       note_stores (PATTERN (insn), reg_is_set);
  536.     }
  537.       if (GET_CODE (insn) == CALL_INSN)
  538.     call_seen = 1;
  539.       if (insn == basic_block_end[b])
  540.     break;
  541.       /* We don't need this for the block's first instruction
  542.      since no regs we care about are live before that instruction.
  543.      Also we do not allocate space in regs_live_at for that instruction. */
  544.       IOR_HARD_REG_SET (regs_live_at[insn_number], regs_live);
  545.       insn = NEXT_INSN (insn);
  546.     }
  547.  
  548.   /* Now every register that is local to this basic block
  549.      should have been given a quantity, or else -1 meaning ignore it.
  550.      Every quantity should have a known birth (verify this now).
  551.  
  552.      If a qty's death has not been established, it indicates a dead store.
  553.      That is ok if the insn is not entirely dead.
  554.      So set the qty'd death to just after its birth.  */
  555.  
  556.   for (i = FIRST_PSEUDO_REGISTER; i < next_qty; i++)
  557.     {
  558.       if (qty_birth[i] == -1)
  559.     abort ();
  560.       if (qty_death[i] == -1)
  561.     qty_death[i] = qty_birth[i] + 1;
  562.     }
  563.  
  564.   /* Now order the qtys so we assign them registers
  565.      in order of decreasing length of life.  */
  566.   qty_order = (short *) alloca (next_qty * sizeof (short));
  567.   for (i = FIRST_PSEUDO_REGISTER; i < next_qty; i++)
  568.     qty_order[i] = i;
  569.  
  570. #define EXCHANGE(I1, I2)  \
  571.   { i = qty_order[I1]; qty_order[I1] = qty_order[I2]; qty_order[I2] = i; }
  572.  
  573.   if (next_qty == 2 + FIRST_PSEUDO_REGISTER)
  574.     {
  575.       if (qty_compare (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1) > 0)
  576.     EXCHANGE (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1);
  577.     }
  578.   else if (next_qty == 3 + FIRST_PSEUDO_REGISTER)
  579.     {
  580.       if (qty_compare (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1) > 0)
  581.     EXCHANGE (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1);
  582.       if (qty_compare (FIRST_PSEUDO_REGISTER + 1, FIRST_PSEUDO_REGISTER + 2) > 0)
  583.     EXCHANGE (FIRST_PSEUDO_REGISTER + 2, FIRST_PSEUDO_REGISTER + 1);
  584.       if (qty_compare (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1) > 0)
  585.     EXCHANGE (FIRST_PSEUDO_REGISTER, FIRST_PSEUDO_REGISTER + 1);
  586.     }
  587.   else if (next_qty > 3 + FIRST_PSEUDO_REGISTER)
  588.     qsort (qty_order + FIRST_PSEUDO_REGISTER,
  589.        next_qty - FIRST_PSEUDO_REGISTER, sizeof (short), qty_compare_1);
  590.  
  591.   /* Now for each qty that is not a hardware register,
  592.      look for a hardware register to put it in.
  593.      First try the register class that is cheapest for this qty,
  594.      if there is more than one class.  */
  595.  
  596.   for (i = FIRST_PSEUDO_REGISTER; i < next_qty; i++)
  597.     {
  598.  
  599. #ifdef MPW
  600.      SpinCursor(1);
  601. #endif
  602.  
  603.       q = qty_order[i];
  604.       if (qty_size[q] >= 0)
  605.     {
  606.       if (N_REG_CLASSES > 1)
  607.         {
  608.           qty_phys_reg[q] = find_free_reg (qty_min_class[q], 
  609.                            qty_mode[q], q, 0,
  610.                            qty_birth[q], qty_death[q]);
  611.           if (qty_phys_reg[q] >= 0)
  612.         continue;
  613.         }
  614.  
  615.       if (!qty_preferred_or_nothing[q])
  616.         qty_phys_reg[q] = find_free_reg (GENERAL_REGS, 
  617.                          qty_mode[q], q, 0,
  618.                          qty_birth[q], qty_death[q]);
  619.     }
  620.     }
  621.  
  622.   /* Now propagate the register assignments
  623.      to the pseudo regs belonging to the qtys.  */
  624.  
  625.   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  626.     if (reg_qty[i] >= 0 && qty_phys_reg[reg_qty[i]] >= 0)
  627.       {
  628.     reg_renumber[i] = qty_phys_reg[reg_qty[i]] + reg_offset[i];
  629.       }
  630. }
  631.  
  632. /* Compare two quantities' priority for getting real registers.
  633.    We give quantities with hard-reg suggestions priority over all others.
  634.    We give longer-lived quantities higher priority
  635.    so that the shorter-lived ones will tend to be in the same places
  636.    which gives in general the maximum room for the regs to
  637.    be allocated by global-alloc.
  638.    Regs with more references are also preferred.  */
  639.  
  640. static int
  641. qty_compare (q1, q2)
  642.      int q1, q2;
  643. {
  644.   register int tem = (qty_phys_sugg[q2] >= 0) - (qty_phys_sugg[q1] >= 0);
  645.   if (tem != 0) return tem;
  646.   return -((qty_n_refs[q1] + qty_death[q1] - qty_birth[q1]) * qty_size[q2]
  647.        - (qty_n_refs[q2] + qty_death[q2] - qty_birth[q2]) * qty_size[q1]);
  648. }
  649.  
  650. static int
  651. qty_compare_1 (q1, q2)
  652.      short *q1, *q2;
  653. {
  654.   register int tem = (qty_phys_sugg[*q2] >= 0) - (qty_phys_sugg[*q1] >= 0);
  655.   if (tem != 0) return tem;
  656.   tem = -((qty_n_refs[*q1] + qty_death[*q1] - qty_birth[*q1]) * qty_size[*q2]
  657.       - (qty_n_refs[*q2] + qty_death[*q2] - qty_birth[*q2]) * qty_size[*q1]);
  658.   if (tem != 0) return tem;
  659.   /* If qtys are equally good, sort by qty number,
  660.      so that the results of qsort leave nothing to chance.  */
  661.   return *q1 - *q2;
  662. }
  663.  
  664. /* Attempt to combine the two registers (rtx's) USEDREG and SETREG.
  665.    Returns 1 if have done so, or 0 if cannot.
  666.  
  667.    Combining registers means marking them as having the same quantity
  668.    and adjusting the offsets within the quantity if either of
  669.    them is a SUBREG).
  670.  
  671.    We don't actually combine a hard reg with a pseudo; instead
  672.    we just record the hard reg as the suggestion for the pseudo's quantity.
  673.    If we really combined them, we could lose if the pseudo lives
  674.    across an insn that clobbers the hard reg (eg, movstr).
  675.  
  676.    There are elaborate checks for the validity of combining.  */
  677.  
  678.    
  679. static int
  680. combine_regs (usedreg, setreg, b, insn_number, insn)
  681.      rtx usedreg, setreg;
  682.      int b;
  683.      int insn_number;
  684.      rtx insn;
  685. {
  686.   register int ureg, sreg;
  687.   register int offset = 0;
  688.   int usize, ssize;
  689.   register int sqty;
  690.  
  691.   /* Determine the numbers and sizes of registers being used.  */
  692.  
  693.  
  694. #ifdef MPW
  695.   SpinCursor(1);
  696. #endif
  697.  
  698.   while (GET_CODE (usedreg) == SUBREG)
  699.     {
  700.       offset += SUBREG_WORD (usedreg);
  701.       usedreg = SUBREG_REG (usedreg);
  702.     }
  703.   if (GET_CODE (usedreg) != REG)
  704.     return 0;
  705.   ureg = REGNO (usedreg);
  706.   usize = REG_SIZE (usedreg);
  707.  
  708.   while (GET_CODE (setreg) == SUBREG)
  709.     {
  710.       offset -= SUBREG_WORD (setreg);
  711.       setreg = SUBREG_REG (setreg);
  712.     }
  713.   if (GET_CODE (setreg) != REG)
  714.     return 0;
  715.   sreg = REGNO (setreg);
  716.   ssize = REG_SIZE (setreg);
  717.  
  718.   /* Do not combine registers unless one fits within the other.  */
  719.   if (offset > 0 && usize + offset > ssize)
  720.     return 0;
  721.   if (offset < 0 && usize + offset < ssize)
  722.     return 0;
  723.   /* Do not combine with a smaller already-assigned object
  724.      if that smaller object is already combined with something bigger
  725.      or if that smaller object is a hard reg.
  726.      In the latter case, we would implicitly be using consecutive
  727.      hard regs, and there is no code to keep track of that.
  728.      (This is overcautious; we could check that ssize actually
  729.      requires more hard regs at this spot.)  */
  730.   if (ssize > usize && reg_qty[ureg] >= FIRST_PSEUDO_REGISTER
  731.       && usize < qty_size[reg_qty[ureg]])
  732.     return 0;
  733.  
  734.   /* Don't do anything with the non-allocatable registers.
  735.      Also, don't suggest a call-clobberable register
  736.      for something that must live across calls.
  737.      Also, don't suggest a hardware register for anything larger than it.  */
  738.   if (ureg < FIRST_PSEUDO_REGISTER)
  739.     {
  740.       if (fixed_regs[ureg])
  741.     return 0;
  742.       if (reg_n_calls_crossed[sreg] != 0 && call_used_regs[ureg])
  743.     return 0;
  744.       if (usize < ssize)
  745.     return 0;
  746.     }
  747.  
  748.   if (sreg < FIRST_PSEUDO_REGISTER)
  749.     {
  750.       if (fixed_regs[sreg])
  751.     return 0;
  752.       if (reg_n_calls_crossed[ureg] != 0 && call_used_regs[sreg])
  753.     return 0;
  754.       if (ssize < usize)
  755.     return 0;
  756.     }
  757.  
  758.   /* Don't tie something to itself.  In most cases it would make no
  759.      difference, but it would screw up if the reg being tied to itself
  760.      also dies in this insn.  */
  761.  
  762.   if (ureg == sreg)
  763.     return 0; 
  764.  
  765.   /* Don't try to connect two different hardware registers.  */
  766.  
  767.   if (ureg < FIRST_PSEUDO_REGISTER && sreg < FIRST_PSEUDO_REGISTER)
  768.     return 0;
  769.  
  770.   /* Don't connect two different machine modes if they have different
  771.      implications as to which registers may be used.  */
  772.  
  773.   if (!MODES_TIEABLE_P (GET_MODE (usedreg), GET_MODE (setreg)))
  774.     return 0;
  775.  
  776.   /* Now, if one of UREG and SREG is a hard reg and the other is
  777.      a pseudo, record the hard reg as the qty_phys_sugg for the pseudo
  778.      instead of tying them.  */
  779.   /* Return "failure" so that the lifespan of UREG is terminated here;
  780.      that way the two lifespans will be disjoint and nothing will prevent
  781.      the pseudo reg from being given this hard reg.  */
  782.  
  783.   if (ureg < FIRST_PSEUDO_REGISTER)
  784.     {
  785.       if (reg_qty[sreg] == -2)
  786.     reg_is_born (setreg, insn_number);
  787.       if (reg_qty[ureg] == -2)
  788.     reg_is_born (usedreg, insn_number);
  789.       if (reg_qty[sreg] >= 0)
  790.     qty_phys_sugg[reg_qty[sreg]] = ureg;
  791.       return 0;
  792.     }
  793.   if (sreg < FIRST_PSEUDO_REGISTER)
  794.     {
  795.       if (reg_qty[sreg] == -2)
  796.     reg_is_born (setreg, insn_number);
  797.       if (reg_qty[ureg] == -2)
  798.     reg_is_born (usedreg, insn_number);
  799.       /* If UREG already has a suggested hard reg, don't override it,
  800.      since the most likely case is on a risc machine
  801.      when a pseudo gets a subroutine result and is then returned by
  802.      this function.  In this case, the outgoing register window
  803.      is probably a better place to use.  */
  804.       if (reg_qty[ureg] >= 0
  805.       && (qty_phys_sugg[reg_qty[ureg]] < 0
  806.           /* If the old suggestion is no good, override it.  */
  807.           || (qty_n_calls_crossed[reg_qty[ureg]] != 0
  808.           && call_used_regs[qty_phys_sugg[reg_qty[ureg]]])))
  809.     qty_phys_sugg[reg_qty[ureg]] = sreg;
  810.       return 0;
  811.     }
  812.  
  813.   /* Do nothing if SREG is a pseudo that already has a quantity
  814.      or if it isn't local to this basic block or dies more than once.  */
  815.  
  816.   if (reg_qty[sreg] != -2)
  817.     return 0;
  818.  
  819.   /* Do nothing if UREG isn't local to this block or dies more than once.
  820.      We do this because global_alloc has no idea of tying,
  821.      so there is no use noting those local pseudos that could
  822.      profitably be delayed till global_alloc and get tied to global ones.  */
  823.  
  824.   if (reg_qty[ureg] == -1)
  825.     return 0;
  826.  
  827.   /* We don't already know about SREG, so tie it to UREG
  828.      if this is the last use of UREG, provided the classes they want
  829.      are compatible.  */
  830.  
  831.   if (find_regno_note (insn, REG_DEAD, ureg)
  832.       && (reg_qty[ureg] >= FIRST_PSEUDO_REGISTER
  833.       ? reg_meets_class_p (sreg, qty_min_class[reg_qty[ureg]])
  834.       : reg_meets_class_p (sreg, reg_preferred_class (ureg))))
  835.     {
  836.       if (reg_qty[ureg] == -2)
  837.     reg_is_born (usedreg, insn_number);
  838.       sqty = reg_qty[sreg] = reg_qty[ureg];
  839.       if (sqty < FIRST_PSEUDO_REGISTER) abort ();
  840.       /* If SREG's reg class is smaller, set qty_min_class[SQTY].  */
  841.       update_qty_class (sqty, sreg);
  842.       reg_offset[sreg] = reg_offset[ureg] + offset;
  843.       if (sqty >= 0)
  844.     {
  845.       qty_n_calls_crossed[sqty] += reg_n_calls_crossed[sreg];
  846.       qty_n_refs[sqty] += reg_n_refs[sreg];
  847.       if (! reg_preferred_or_nothing (sreg))
  848.         qty_preferred_or_nothing[sqty] = 0;
  849.       if (usize < ssize)
  850.         {
  851.           register int i;
  852.           for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  853.         if (reg_qty[i] == sqty)
  854.           reg_offset[i] -= offset;
  855.           qty_size[sqty] = ssize;
  856.           qty_mode[sqty] = GET_MODE (setreg);
  857.         }
  858.     }
  859.     }
  860.   else
  861.     return 0;
  862.  
  863.   return 1;
  864. }
  865.  
  866. /* Return 1 if the preferred class of REG allows it to be tied
  867.    to a quantity or register whose class is CLASS.
  868.    True if REG's reg class either contains or is contained in CLASS.  */
  869.  
  870. static int
  871. reg_meets_class_p (reg, class)
  872.      int reg;
  873.      enum reg_class class;
  874. {
  875.   register enum reg_class rclass = reg_preferred_class (reg);
  876.   return (reg_class_subset_p (rclass, class)
  877.       || reg_class_subset_p (class, rclass));
  878. }
  879.  
  880. /* Return nonzero if R2's preferred class is the same as or contains
  881.    R1's preferred class.  R1 and R2 are pseudo-register numbers.  */
  882.  
  883. static int
  884. reg_class_subset_p (c1, c2)
  885.      register enum reg_class c1;
  886.      register enum reg_class c2;
  887. {
  888.   if (c1 == c2) return 1;
  889.  
  890.   if (c2 == ALL_REGS)
  891.   win:
  892.     return 1;
  893.   GO_IF_HARD_REG_SUBSET (reg_class_contents[(int)c1],
  894.              reg_class_contents[(int)c2],
  895.              win);
  896.   return 0;
  897. }
  898.  
  899. /* Update the class of QTY assuming that REG is being tied to it.  */
  900.  
  901. static void
  902. update_qty_class (qty, reg)
  903.      int qty;
  904.      int reg;
  905. {
  906.   enum reg_class rclass = reg_preferred_class (reg);
  907.   if (reg_class_subset_p (rclass, qty_min_class[qty]))
  908.     qty_min_class[qty] = rclass;
  909. }
  910.  
  911. /* Handle something which alters the value of an rtx REG.
  912.    REG is whatever is set or clobbered.  (CLOBBER_FLAG says which.)
  913.    If it is not really a register, we do nothing.
  914.    The file-global variables `this_insn' and `this_insn_number'
  915.    carry info from `block_alloc'.  */
  916.  
  917. static void
  918. reg_is_set (reg, setter)
  919.      rtx reg;
  920.      rtx setter;
  921. {
  922.   register int regno;
  923.   int clobber_flag = GET_CODE (setter) == CLOBBER;
  924.  
  925.   if (reg == 0 || GET_CODE (reg) != REG)
  926.     return;
  927.  
  928.   regno = REGNO (reg);
  929.  
  930.   if (regno < FIRST_PSEUDO_REGISTER)
  931.     {
  932.       /* A hard reg is set or clobbered.
  933.      Mark it as live at the moment immediately following this insn
  934.      so that no pseudo can live here at that time.
  935.      For a CLOBBER, mark it as live before this insn,
  936.      to make sure it is free during the entire insn.  */
  937.  
  938.       register int lim = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
  939.       register int i;
  940.       for (i = regno; i < lim; i++)
  941.     {
  942.       SET_HARD_REG_BIT (regs_live_at[this_insn_number], i);
  943.       if (clobber_flag)
  944.         SET_HARD_REG_BIT (regs_live_at[this_insn_number - 1], i);
  945.     }
  946.  
  947.       /* If the hard reg is given a useful value
  948.      and it does not die in this insn,
  949.      mark it as live indefinitely afterward.  */
  950.       if (! clobber_flag
  951.       && ! find_regno_note (this_insn, REG_DEAD, regno))
  952.     reg_is_born (reg, this_insn_number);
  953.     }
  954.   else if (! clobber_flag)
  955.     {
  956.       /* A pseudo-reg is set (not just clobbered).  */
  957.  
  958.       reg_is_born (reg, this_insn_number);
  959.  
  960.       /* If a pseudo register dies in the same insn that sets it,
  961.      say it dies in the following insn instead,
  962.      because it will have to be live right after this insn.  */
  963.       if (qty_death[reg_qty[regno]] == this_insn_number)
  964.     {
  965.       /* Calls to post_mark_life and mark_life deleted here.
  966.          They only know how to handle hard regs.  */
  967.       qty_death[reg_qty[regno]]++;
  968.     }
  969.     }
  970.   else if (reg_qty[regno] >= 0 && qty_death[reg_qty[regno]] == this_insn_number
  971.        && qty_birth[reg_qty[regno]] == this_insn_number)
  972.     {
  973.       /* A psuedo-reg is clobbered by this insn and was born and dies here.
  974.      This is a temporary required for this insn and so will
  975.      conflict with any other live registers at this point.  We must
  976.      assume that this register is used before all the inputs of the
  977.      insn are dead.  So this register must not conflict with any of them.
  978.      Mark it as born at the previous insn.  */
  979.       qty_birth[reg_qty[regno]]--;
  980.       /* It should also conflict with this insn's outputs.  */
  981.       qty_death[reg_qty[regno]]++;
  982.     }
  983. }
  984.  
  985. /* Handle beginning of the life of register REG.
  986.    INSN_NUMBER is the insn at which this is happening.  */
  987.  
  988. static void
  989. reg_is_born (reg, insn_number)
  990.      rtx reg;
  991.      int insn_number;
  992. {
  993.   register int regno = REGNO (reg);
  994.      
  995.   if (regno < FIRST_PSEUDO_REGISTER)
  996.     mark_life (regno, GET_MODE (reg), 1);
  997.   else if (reg_qty[regno] == -2)
  998.     alloc_qty (regno, GET_MODE (reg), PSEUDO_REGNO_SIZE (regno), insn_number);
  999. }
  1000.  
  1001. /* Record the death in insn DEATH_INSN_NUMBER for the register REG.  */
  1002.  
  1003. static void
  1004. wipe_dead_reg (reg, this_insn_number, death_insn_number)
  1005.      register rtx reg;
  1006.      int this_insn_number;
  1007.      int death_insn_number;
  1008. {
  1009.   register int regno = REGNO (reg);
  1010.  
  1011.   if (regno < FIRST_PSEUDO_REGISTER)
  1012.     {
  1013.       mark_life (regno, GET_MODE (reg), 0);
  1014.       if (this_insn_number != death_insn_number)
  1015.     abort ();
  1016. #if 0                /* Should never get here */
  1017.     post_mark_life (regno, GET_MODE (reg), 1,
  1018.             this_insn_number, death_insn_number);
  1019. #endif
  1020.     }
  1021.   else
  1022.     {
  1023.       /* If a pseudo reg is referred to but was never set,
  1024.      we will find here that its qty is -2.
  1025.      Since these regs do not conflict with anything,
  1026.      mark them as born and dead in the same place.  */
  1027.       if (reg_qty[regno] == -2)
  1028.     {
  1029.       alloc_qty (regno, GET_MODE (reg), REG_SIZE (reg), this_insn_number);
  1030.       REG_NOTES (this_insn) = gen_rtx (EXPR_LIST, REG_UNSET, reg,
  1031.                        REG_NOTES (this_insn));
  1032.     }
  1033.  
  1034.       if (reg_qty[regno] >= 0)
  1035.     qty_death[reg_qty[regno]] = death_insn_number;
  1036.     }
  1037. }
  1038.  
  1039. /* Find a block of SIZE words of hard regs in reg_class CLASS
  1040.    that can hold something of machine-mode MODE
  1041.      (but actually we test only the first of the block for holding MODE)
  1042.    and still free between insn BORN_INSN and insn DEAD_INSN,
  1043.    and return the number of the first of them.
  1044.    Return -1 if such a block cannot be found. 
  1045.    If QTY crosses calls, insist on a register preserved by calls,
  1046.    unless ACCEPT_CALL_CLOBBERED is nonzero.  */
  1047.  
  1048. static int
  1049. find_free_reg (class, mode, qty, accept_call_clobbered, born_insn, dead_insn)
  1050.      enum reg_class class;
  1051.      enum machine_mode mode;
  1052.      int accept_call_clobbered;
  1053.      int qty;
  1054.      int born_insn, dead_insn;
  1055. {
  1056.   register int i, ins;
  1057. #ifdef HARD_REG_SET
  1058.   register        /* Declare it register if it's a scalar.  */
  1059. #endif
  1060.     HARD_REG_SET used;
  1061.  
  1062.   if (accept_call_clobbered)
  1063.     COPY_HARD_REG_SET (used, call_fixed_reg_set);
  1064.   else if (qty_n_calls_crossed[qty] == 0)
  1065.     COPY_HARD_REG_SET (used, fixed_reg_set);
  1066.   else
  1067.     COPY_HARD_REG_SET (used, call_used_reg_set);
  1068.  
  1069.   for (ins = born_insn; ins < dead_insn; ins++)
  1070.     IOR_HARD_REG_SET (used, regs_live_at[ins]);
  1071.  
  1072.   IOR_COMPL_HARD_REG_SET (used, reg_class_contents[(int) class]);
  1073.   /* Don't use the frame pointer reg in local-alloc even if
  1074.      we may omit the frame pointer, because if we do that and then we
  1075.      need a frame pointer, reload won't know how to move the pseudo
  1076.      to another hard reg.  It can move only regs made by global-alloc.  */
  1077.   SET_HARD_REG_BIT (used, FRAME_POINTER_REGNUM);
  1078.  
  1079.   /* If quantity QTY has a suggested physical register,
  1080.      try that one first.  */
  1081.  
  1082.   if (qty_phys_sugg[qty] >= 0)
  1083.     {
  1084.       i = qty_phys_sugg[qty];
  1085.       if (! TEST_HARD_REG_BIT (used, i)
  1086.       && HARD_REGNO_MODE_OK (i, mode))
  1087.     {
  1088.       register int j;
  1089.       register int size1 = HARD_REGNO_NREGS (i, mode);
  1090.       for (j = 1; j < size1 && ! TEST_HARD_REG_BIT (used, i + j); j++);
  1091.       if (j == size1)
  1092.         {
  1093.           post_mark_life (i, mode, 1, born_insn, dead_insn);
  1094.           return i;
  1095.         }
  1096.     }
  1097.     }
  1098.  
  1099.   /* If that doesn't find one, test each hard reg.  */
  1100.  
  1101.   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  1102.     {
  1103. #ifdef REG_ALLOC_ORDER
  1104.       int regno = reg_alloc_order[i];
  1105. #else
  1106.       int regno = i;
  1107. #endif
  1108.       if (! TEST_HARD_REG_BIT (used, regno)
  1109.       && HARD_REGNO_MODE_OK (regno, mode))
  1110.     {
  1111.       register int j;
  1112.       register int size1 = HARD_REGNO_NREGS (regno, mode);
  1113.       for (j = 1; j < size1 && ! TEST_HARD_REG_BIT (used, regno + j); j++);
  1114.       if (j == size1)
  1115.         {
  1116.           post_mark_life (regno, mode, 1, born_insn, dead_insn);
  1117.           return regno;
  1118.         }
  1119. #ifndef REG_ALLOC_ORDER
  1120.       i += j;        /* Skip starting points we know will lose */
  1121. #endif
  1122.     }
  1123.     }
  1124.  
  1125.   /* If it would be profitable to allocate a call-clobbered register
  1126.      and save and restore it around calls, do that.  */
  1127.  
  1128.   if (! accept_call_clobbered
  1129.       && flag_caller_saves
  1130.       && qty_n_calls_crossed[qty] != 0
  1131.       && CALLER_SAVE_PROFITABLE (qty_n_refs[qty], qty_n_calls_crossed[qty]))
  1132.     {
  1133.       i = find_free_reg (class, mode, qty, 1, born_insn, dead_insn);
  1134.       if (i >= 0)
  1135.     caller_save_needed = 1;
  1136.       return i;
  1137.     }
  1138.   return -1;
  1139. }
  1140.  
  1141. static void
  1142. mark_life (regno, mode, life)
  1143.      register int regno;
  1144.      enum machine_mode mode;
  1145.      int life;
  1146. {
  1147.   register int j = HARD_REGNO_NREGS (regno, mode);
  1148.   if (life)
  1149.     while (--j >= 0)
  1150.       SET_HARD_REG_BIT (regs_live, regno + j);
  1151.   else
  1152.     while (--j >= 0)
  1153.       CLEAR_HARD_REG_BIT (regs_live, regno + j);
  1154. }
  1155.  
  1156. static void
  1157. post_mark_life (regno, mode, life, birth, death)
  1158.      register int regno, life, birth;
  1159.      enum machine_mode mode;
  1160.      int death;
  1161. {
  1162.   register int j = HARD_REGNO_NREGS (regno, mode);
  1163. #ifdef HARD_REG_SET
  1164.   register        /* Declare it register if it's a scalar.  */
  1165. #endif
  1166.     HARD_REG_SET this_reg;
  1167.  
  1168.   CLEAR_HARD_REG_SET (this_reg);
  1169.   while (--j >= 0)
  1170.     SET_HARD_REG_BIT (this_reg, regno + j);
  1171.  
  1172.   /* If a reg is born and dies in one insn,
  1173.      consider it live after that insn.  */
  1174.  
  1175.   if (birth == death)
  1176.     death++;
  1177.  
  1178.   if (life)
  1179.     while (birth < death)
  1180.       {
  1181.     IOR_HARD_REG_SET (regs_live_at[birth], this_reg);
  1182.     birth++;
  1183.       }
  1184.   else
  1185.     while (birth < death)
  1186.       {
  1187.     AND_COMPL_HARD_REG_SET (regs_live_at[birth], this_reg);
  1188.     birth++;
  1189.       }
  1190. }
  1191.  
  1192. void
  1193. dump_local_alloc (file)
  1194.      FILE *file;
  1195. {
  1196.   register int i;
  1197.   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  1198.     if (reg_renumber[i] != -1)
  1199.       fprintf (file, ";; Register %d in %d.\n", i, reg_renumber[i]);
  1200. }
  1201.