OSDN Git Service

Reorg reg-stack to use the standard CFG.
[pf3gnuchains/gcc-fork.git] / gcc / global.c
1 /* Allocate registers for pseudo-registers that span basic blocks.
2    Copyright (C) 1987, 88, 91, 94, 96-98, 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21
22 #include "config.h"
23 #include "system.h"
24
25 #include "machmode.h"
26 #include "hard-reg-set.h"
27 #include "rtl.h"
28 #include "tm_p.h"
29 #include "flags.h"
30 #include "basic-block.h"
31 #include "regs.h"
32 #include "function.h"
33 #include "insn-config.h"
34 #include "reload.h"
35 #include "output.h"
36 #include "toplev.h"
37
38 /* This pass of the compiler performs global register allocation.
39    It assigns hard register numbers to all the pseudo registers
40    that were not handled in local_alloc.  Assignments are recorded
41    in the vector reg_renumber, not by changing the rtl code.
42    (Such changes are made by final).  The entry point is
43    the function global_alloc.
44
45    After allocation is complete, the reload pass is run as a subroutine
46    of this pass, so that when a pseudo reg loses its hard reg due to
47    spilling it is possible to make a second attempt to find a hard
48    reg for it.  The reload pass is independent in other respects
49    and it is run even when stupid register allocation is in use.
50
51    1. Assign allocation-numbers (allocnos) to the pseudo-registers
52    still needing allocations and to the pseudo-registers currently
53    allocated by local-alloc which may be spilled by reload.
54    Set up tables reg_allocno and allocno_reg to map 
55    reg numbers to allocnos and vice versa.
56    max_allocno gets the number of allocnos in use.
57
58    2. Allocate a max_allocno by max_allocno conflict bit matrix and clear it.
59    Allocate a max_allocno by FIRST_PSEUDO_REGISTER conflict matrix
60    for conflicts between allocnos and explicit hard register use
61    (which includes use of pseudo-registers allocated by local_alloc).
62
63    3. For each basic block
64     walk forward through the block, recording which
65     pseudo-registers and which hardware registers are live.
66     Build the conflict matrix between the pseudo-registers
67     and another of pseudo-registers versus hardware registers.
68     Also record the preferred hardware registers
69     for each pseudo-register.
70
71    4. Sort a table of the allocnos into order of
72    desirability of the variables.
73
74    5. Allocate the variables in that order; each if possible into
75    a preferred register, else into another register.  */
76 \f
77 /* Number of pseudo-registers which are candidates for allocation. */
78
79 static int max_allocno;
80
81 /* Indexed by (pseudo) reg number, gives the allocno, or -1
82    for pseudo registers which are not to be allocated.  */
83
84 static int *reg_allocno;
85
86 /* Indexed by allocno, gives the reg number.  */
87
88 static int *allocno_reg;
89
90 /* A vector of the integers from 0 to max_allocno-1,
91    sorted in the order of first-to-be-allocated first.  */
92
93 static int *allocno_order;
94
95 /* Indexed by an allocno, gives the number of consecutive
96    hard registers needed by that pseudo reg.  */
97
98 static int *allocno_size;
99
100 /* Indexed by (pseudo) reg number, gives the number of another
101    lower-numbered pseudo reg which can share a hard reg with this pseudo
102    *even if the two pseudos would otherwise appear to conflict*.  */
103
104 static int *reg_may_share;
105
106 /* Define the number of bits in each element of `conflicts' and what
107    type that element has.  We use the largest integer format on the
108    host machine.  */
109
110 #define INT_BITS HOST_BITS_PER_WIDE_INT
111 #define INT_TYPE HOST_WIDE_INT
112
113 /* max_allocno by max_allocno array of bits,
114    recording whether two allocno's conflict (can't go in the same
115    hardware register).
116
117    `conflicts' is not symmetric; a conflict between allocno's i and j
118    is recorded either in element i,j or in element j,i.  */
119
120 static INT_TYPE *conflicts;
121
122 /* Number of ints require to hold max_allocno bits.
123    This is the length of a row in `conflicts'.  */
124
125 static int allocno_row_words;
126
127 /* Two macros to test or store 1 in an element of `conflicts'.  */
128
129 #define CONFLICTP(I, J) \
130  (conflicts[(I) * allocno_row_words + (J) / INT_BITS]   \
131   & ((INT_TYPE) 1 << ((J) % INT_BITS)))
132
133 #define SET_CONFLICT(I, J) \
134  (conflicts[(I) * allocno_row_words + (J) / INT_BITS]   \
135   |= ((INT_TYPE) 1 << ((J) % INT_BITS)))
136
137 /* Set of hard regs currently live (during scan of all insns).  */
138
139 static HARD_REG_SET hard_regs_live;
140
141 /* Indexed by N, set of hard regs conflicting with allocno N.  */
142
143 static HARD_REG_SET *hard_reg_conflicts;
144
145 /* Indexed by N, set of hard regs preferred by allocno N.
146    This is used to make allocnos go into regs that are copied to or from them,
147    when possible, to reduce register shuffling.  */
148
149 static HARD_REG_SET *hard_reg_preferences;
150
151 /* Similar, but just counts register preferences made in simple copy
152    operations, rather than arithmetic.  These are given priority because
153    we can always eliminate an insn by using these, but using a register
154    in the above list won't always eliminate an insn.  */
155
156 static HARD_REG_SET *hard_reg_copy_preferences;
157
158 /* Similar to hard_reg_preferences, but includes bits for subsequent
159    registers when an allocno is multi-word.  The above variable is used for
160    allocation while this is used to build reg_someone_prefers, below.  */
161
162 static HARD_REG_SET *hard_reg_full_preferences;
163
164 /* Indexed by N, set of hard registers that some later allocno has a
165    preference for.  */
166
167 static HARD_REG_SET *regs_someone_prefers;
168
169 /* Set of registers that global-alloc isn't supposed to use.  */
170
171 static HARD_REG_SET no_global_alloc_regs;
172
173 /* Set of registers used so far.  */
174
175 static HARD_REG_SET regs_used_so_far;
176
177 /* Number of calls crossed by each allocno.  */
178
179 static int *allocno_calls_crossed;
180
181 /* Number of refs (weighted) to each allocno.  */
182
183 static int *allocno_n_refs;
184
185 /* Guess at live length of each allocno.
186    This is actually the max of the live lengths of the regs.  */
187
188 static int *allocno_live_length;
189
190 /* Number of refs (weighted) to each hard reg, as used by local alloc.
191    It is zero for a reg that contains global pseudos or is explicitly used.  */
192
193 static int local_reg_n_refs[FIRST_PSEUDO_REGISTER];
194
195 /* Guess at live length of each hard reg, as used by local alloc.
196    This is actually the sum of the live lengths of the specific regs.  */
197
198 static int local_reg_live_length[FIRST_PSEUDO_REGISTER];
199
200 /* Test a bit in TABLE, a vector of HARD_REG_SETs,
201    for vector element I, and hard register number J.  */
202
203 #define REGBITP(TABLE, I, J)     TEST_HARD_REG_BIT (TABLE[I], J)
204
205 /* Set to 1 a bit in a vector of HARD_REG_SETs.  Works like REGBITP.  */
206
207 #define SET_REGBIT(TABLE, I, J)  SET_HARD_REG_BIT (TABLE[I], J)
208
209 /* Bit mask for allocnos live at current point in the scan.  */
210
211 static INT_TYPE *allocnos_live;
212
213 /* Test, set or clear bit number I in allocnos_live,
214    a bit vector indexed by allocno.  */
215
216 #define ALLOCNO_LIVE_P(I) \
217   (allocnos_live[(I) / INT_BITS] & ((INT_TYPE) 1 << ((I) % INT_BITS)))
218
219 #define SET_ALLOCNO_LIVE(I) \
220   (allocnos_live[(I) / INT_BITS] |= ((INT_TYPE) 1 << ((I) % INT_BITS)))
221
222 #define CLEAR_ALLOCNO_LIVE(I) \
223   (allocnos_live[(I) / INT_BITS] &= ~((INT_TYPE) 1 << ((I) % INT_BITS)))
224
225 /* This is turned off because it doesn't work right for DImode.
226    (And it is only used for DImode, so the other cases are worthless.)
227    The problem is that it isn't true that there is NO possibility of conflict;
228    only that there is no conflict if the two pseudos get the exact same regs.
229    If they were allocated with a partial overlap, there would be a conflict.
230    We can't safely turn off the conflict unless we have another way to
231    prevent the partial overlap.
232
233    Idea: change hard_reg_conflicts so that instead of recording which
234    hard regs the allocno may not overlap, it records where the allocno
235    may not start.  Change both where it is used and where it is updated.
236    Then there is a way to record that (reg:DI 108) may start at 10
237    but not at 9 or 11.  There is still the question of how to record
238    this semi-conflict between two pseudos.  */
239 #if 0
240 /* Reg pairs for which conflict after the current insn
241    is inhibited by a REG_NO_CONFLICT note.
242    If the table gets full, we ignore any other notes--that is conservative.  */
243 #define NUM_NO_CONFLICT_PAIRS 4
244 /* Number of pairs in use in this insn.  */
245 int n_no_conflict_pairs;
246 static struct { int allocno1, allocno2;}
247   no_conflict_pairs[NUM_NO_CONFLICT_PAIRS];
248 #endif /* 0 */
249
250 /* Record all regs that are set in any one insn.
251    Communication from mark_reg_{store,clobber} and global_conflicts.  */
252
253 static rtx *regs_set;
254 static int n_regs_set;
255
256 /* All registers that can be eliminated.  */
257
258 static HARD_REG_SET eliminable_regset;
259
260 static int allocno_compare      PROTO((const PTR, const PTR));
261 static void global_conflicts    PROTO((void));
262 static void expand_preferences  PROTO((void));
263 static void prune_preferences   PROTO((void));
264 static void find_reg            PROTO((int, HARD_REG_SET, int, int, int));
265 static void record_one_conflict PROTO((int));
266 static void record_conflicts    PROTO((int *, int));
267 static void mark_reg_store      PROTO((rtx, rtx));
268 static void mark_reg_clobber    PROTO((rtx, rtx));
269 static void mark_reg_conflicts  PROTO((rtx));
270 static void mark_reg_death      PROTO((rtx));
271 static void mark_reg_live_nc    PROTO((int, enum machine_mode));
272 static void set_preference      PROTO((rtx, rtx));
273 static void dump_conflicts      PROTO((FILE *));
274 static void reg_becomes_live    PROTO((rtx, rtx));
275 static void reg_dies            PROTO((int, enum machine_mode));
276 static void build_insn_chain    PROTO((rtx));
277 \f
278 /* Perform allocation of pseudo-registers not allocated by local_alloc.
279    FILE is a file to output debugging information on,
280    or zero if such output is not desired.
281
282    Return value is nonzero if reload failed
283    and we must not do any more for this function.  */
284
285 int
286 global_alloc (file)
287      FILE *file;
288 {
289   int retval;
290 #ifdef ELIMINABLE_REGS
291   static struct {int from, to; } eliminables[] = ELIMINABLE_REGS;
292 #endif
293   int need_fp
294     = (! flag_omit_frame_pointer
295 #ifdef EXIT_IGNORE_STACK
296        || (current_function_calls_alloca && EXIT_IGNORE_STACK)
297 #endif
298        || FRAME_POINTER_REQUIRED);
299
300   register size_t i;
301   rtx x;
302
303   max_allocno = 0;
304
305   /* A machine may have certain hard registers that
306      are safe to use only within a basic block.  */
307
308   CLEAR_HARD_REG_SET (no_global_alloc_regs);
309 #ifdef OVERLAPPING_REGNO_P
310   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
311     if (OVERLAPPING_REGNO_P (i))
312       SET_HARD_REG_BIT (no_global_alloc_regs, i);
313 #endif
314
315   /* Build the regset of all eliminable registers and show we can't use those
316      that we already know won't be eliminated.  */
317 #ifdef ELIMINABLE_REGS
318   for (i = 0; i < sizeof eliminables / sizeof eliminables[0]; i++)
319     {
320       SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from);
321
322       if (! CAN_ELIMINATE (eliminables[i].from, eliminables[i].to)
323           || (eliminables[i].to == STACK_POINTER_REGNUM && need_fp))
324         SET_HARD_REG_BIT (no_global_alloc_regs, eliminables[i].from);
325     }
326 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
327   SET_HARD_REG_BIT (eliminable_regset, HARD_FRAME_POINTER_REGNUM);
328   if (need_fp)
329     SET_HARD_REG_BIT (no_global_alloc_regs, HARD_FRAME_POINTER_REGNUM);
330 #endif
331
332 #else
333   SET_HARD_REG_BIT (eliminable_regset, FRAME_POINTER_REGNUM);
334   if (need_fp)
335     SET_HARD_REG_BIT (no_global_alloc_regs, FRAME_POINTER_REGNUM);
336 #endif
337
338   /* Track which registers have already been used.  Start with registers
339      explicitly in the rtl, then registers allocated by local register
340      allocation.  */
341
342   CLEAR_HARD_REG_SET (regs_used_so_far);
343 #ifdef LEAF_REGISTERS
344   /* If we are doing the leaf function optimization, and this is a leaf
345      function, it means that the registers that take work to save are those
346      that need a register window.  So prefer the ones that can be used in
347      a leaf function.  */
348   {
349     char *cheap_regs;
350     static char leaf_regs[] = LEAF_REGISTERS;
351
352     if (only_leaf_regs_used () && leaf_function_p ())
353       cheap_regs = leaf_regs;
354     else
355       cheap_regs = call_used_regs;
356     for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
357       if (regs_ever_live[i] || cheap_regs[i])
358         SET_HARD_REG_BIT (regs_used_so_far, i);
359   }
360 #else
361   /* We consider registers that do not have to be saved over calls as if
362      they were already used since there is no cost in using them.  */
363   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
364     if (regs_ever_live[i] || call_used_regs[i])
365       SET_HARD_REG_BIT (regs_used_so_far, i);
366 #endif
367
368   for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
369     if (reg_renumber[i] >= 0)
370       SET_HARD_REG_BIT (regs_used_so_far, reg_renumber[i]);
371
372   /* Establish mappings from register number to allocation number
373      and vice versa.  In the process, count the allocnos.  */
374
375   reg_allocno = (int *) alloca (max_regno * sizeof (int));
376
377   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
378     reg_allocno[i] = -1;
379
380   /* Initialize the shared-hard-reg mapping
381      from the list of pairs that may share.  */
382   reg_may_share = (int *) alloca (max_regno * sizeof (int));
383   bzero ((char *) reg_may_share, max_regno * sizeof (int));
384   for (x = regs_may_share; x; x = XEXP (XEXP (x, 1), 1))
385     {
386       int r1 = REGNO (XEXP (x, 0));
387       int r2 = REGNO (XEXP (XEXP (x, 1), 0));
388       if (r1 > r2)
389         reg_may_share[r1] = r2;
390       else
391         reg_may_share[r2] = r1;
392     }
393
394   for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
395     /* Note that reg_live_length[i] < 0 indicates a "constant" reg
396        that we are supposed to refrain from putting in a hard reg.
397        -2 means do make an allocno but don't allocate it.  */
398     if (REG_N_REFS (i) != 0 && REG_LIVE_LENGTH (i) != -1
399         /* Don't allocate pseudos that cross calls,
400            if this function receives a nonlocal goto.  */
401         && (! current_function_has_nonlocal_label
402             || REG_N_CALLS_CROSSED (i) == 0))
403       {
404         if (reg_renumber[i] < 0 && reg_may_share[i] && reg_allocno[reg_may_share[i]] >= 0)
405           reg_allocno[i] = reg_allocno[reg_may_share[i]];
406         else
407           reg_allocno[i] = max_allocno++;
408         if (REG_LIVE_LENGTH (i) == 0)
409           abort ();
410       }
411     else
412       reg_allocno[i] = -1;
413
414   allocno_reg = (int *) alloca (max_allocno * sizeof (int));
415   allocno_size = (int *) alloca (max_allocno * sizeof (int));
416   allocno_calls_crossed = (int *) alloca (max_allocno * sizeof (int));
417   allocno_n_refs = (int *) alloca (max_allocno * sizeof (int));
418   allocno_live_length = (int *) alloca (max_allocno * sizeof (int));
419   bzero ((char *) allocno_size, max_allocno * sizeof (int));
420   bzero ((char *) allocno_calls_crossed, max_allocno * sizeof (int));
421   bzero ((char *) allocno_n_refs, max_allocno * sizeof (int));
422   bzero ((char *) allocno_live_length, max_allocno * sizeof (int));
423
424   for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
425     if (reg_allocno[i] >= 0)
426       {
427         int allocno = reg_allocno[i];
428         allocno_reg[allocno] = i;
429         allocno_size[allocno] = PSEUDO_REGNO_SIZE (i);
430         allocno_calls_crossed[allocno] += REG_N_CALLS_CROSSED (i);
431         allocno_n_refs[allocno] += REG_N_REFS (i);
432         if (allocno_live_length[allocno] < REG_LIVE_LENGTH (i))
433           allocno_live_length[allocno] = REG_LIVE_LENGTH (i);
434       }
435
436   /* Calculate amount of usage of each hard reg by pseudos
437      allocated by local-alloc.  This is to see if we want to
438      override it.  */
439   bzero ((char *) local_reg_live_length, sizeof local_reg_live_length);
440   bzero ((char *) local_reg_n_refs, sizeof local_reg_n_refs);
441   for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
442     if (reg_renumber[i] >= 0)
443       {
444         int regno = reg_renumber[i];
445         int endregno = regno + HARD_REGNO_NREGS (regno, PSEUDO_REGNO_MODE (i));
446         int j;
447
448         for (j = regno; j < endregno; j++)
449           {
450             local_reg_n_refs[j] += REG_N_REFS (i);
451             local_reg_live_length[j] += REG_LIVE_LENGTH (i);
452           }
453       }
454
455   /* We can't override local-alloc for a reg used not just by local-alloc.  */
456   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
457     if (regs_ever_live[i])
458       local_reg_n_refs[i] = 0;
459         
460   /* Allocate the space for the conflict and preference tables and
461      initialize them.  */
462
463   hard_reg_conflicts
464     = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
465   bzero ((char *) hard_reg_conflicts, max_allocno * sizeof (HARD_REG_SET));
466
467   hard_reg_preferences
468     = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
469   bzero ((char *) hard_reg_preferences, max_allocno * sizeof (HARD_REG_SET));
470   
471   hard_reg_copy_preferences
472     = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
473   bzero ((char *) hard_reg_copy_preferences,
474          max_allocno * sizeof (HARD_REG_SET));
475   
476   hard_reg_full_preferences
477     = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
478   bzero ((char *) hard_reg_full_preferences,
479          max_allocno * sizeof (HARD_REG_SET));
480   
481   regs_someone_prefers
482     = (HARD_REG_SET *) alloca (max_allocno * sizeof (HARD_REG_SET));
483   bzero ((char *) regs_someone_prefers, max_allocno * sizeof (HARD_REG_SET));
484
485   allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS;
486
487   /* We used to use alloca here, but the size of what it would try to
488      allocate would occasionally cause it to exceed the stack limit and
489      cause unpredictable core dumps.  Some examples were > 2Mb in size.  */
490   conflicts = (INT_TYPE *) xcalloc (max_allocno * allocno_row_words,
491                                     sizeof (INT_TYPE));
492
493   allocnos_live = (INT_TYPE *) alloca (allocno_row_words * sizeof (INT_TYPE));
494
495   /* If there is work to be done (at least one reg to allocate),
496      perform global conflict analysis and allocate the regs.  */
497
498   if (max_allocno > 0)
499     {
500       /* Scan all the insns and compute the conflicts among allocnos
501          and between allocnos and hard regs.  */
502
503       global_conflicts ();
504
505       /* Eliminate conflicts between pseudos and eliminable registers.  If
506          the register is not eliminated, the pseudo won't really be able to
507          live in the eliminable register, so the conflict doesn't matter.
508          If we do eliminate the register, the conflict will no longer exist.
509          So in either case, we can ignore the conflict.  Likewise for
510          preferences.  */
511
512       for (i = 0; i < (size_t) max_allocno; i++)
513         {
514           AND_COMPL_HARD_REG_SET (hard_reg_conflicts[i], eliminable_regset);
515           AND_COMPL_HARD_REG_SET (hard_reg_copy_preferences[i],
516                                   eliminable_regset);
517           AND_COMPL_HARD_REG_SET (hard_reg_preferences[i], eliminable_regset);
518         }
519
520       /* Try to expand the preferences by merging them between allocnos.  */
521
522       expand_preferences ();
523
524       /* Determine the order to allocate the remaining pseudo registers.  */
525
526       allocno_order = (int *) alloca (max_allocno * sizeof (int));
527       for (i = 0; i < (size_t) max_allocno; i++)
528         allocno_order[i] = i;
529
530       /* Default the size to 1, since allocno_compare uses it to divide by.
531          Also convert allocno_live_length of zero to -1.  A length of zero
532          can occur when all the registers for that allocno have reg_live_length
533          equal to -2.  In this case, we want to make an allocno, but not
534          allocate it.  So avoid the divide-by-zero and set it to a low
535          priority.  */
536
537       for (i = 0; i < (size_t) max_allocno; i++)
538         {
539           if (allocno_size[i] == 0)
540             allocno_size[i] = 1;
541           if (allocno_live_length[i] == 0)
542             allocno_live_length[i] = -1;
543         }
544
545       qsort (allocno_order, max_allocno, sizeof (int), allocno_compare);
546       
547       prune_preferences ();
548
549       if (file)
550         dump_conflicts (file);
551
552       /* Try allocating them, one by one, in that order,
553          except for parameters marked with reg_live_length[regno] == -2.  */
554
555       for (i = 0; i < (size_t) max_allocno; i++)
556         if (reg_renumber[allocno_reg[allocno_order[i]]] < 0
557             && REG_LIVE_LENGTH (allocno_reg[allocno_order[i]]) >= 0)
558           {
559             /* If we have more than one register class,
560                first try allocating in the class that is cheapest
561                for this pseudo-reg.  If that fails, try any reg.  */
562             if (N_REG_CLASSES > 1)
563               {
564                 find_reg (allocno_order[i], 0, 0, 0, 0);
565                 if (reg_renumber[allocno_reg[allocno_order[i]]] >= 0)
566                   continue;
567               }
568             if (reg_alternate_class (allocno_reg[allocno_order[i]]) != NO_REGS)
569               find_reg (allocno_order[i], 0, 1, 0, 0);
570           }
571     }
572
573   /* Do the reloads now while the allocno data still exist, so that we can
574      try to assign new hard regs to any pseudo regs that are spilled.  */
575
576 #if 0 /* We need to eliminate regs even if there is no rtl code,
577          for the sake of debugging information.  */
578   if (n_basic_blocks > 0)
579 #endif
580     {
581       build_insn_chain (get_insns ());
582       retval = reload (get_insns (), 1, file);
583     }
584
585   free (conflicts);
586   return retval;
587 }
588
589 /* Sort predicate for ordering the allocnos.
590    Returns -1 (1) if *v1 should be allocated before (after) *v2.  */
591
592 static int
593 allocno_compare (v1p, v2p)
594      const PTR v1p;
595      const PTR v2p;
596 {
597   int v1 = *(const int *)v1p, v2 = *(const int *)v2p;
598   /* Note that the quotient will never be bigger than
599      the value of floor_log2 times the maximum number of
600      times a register can occur in one insn (surely less than 100).
601      Multiplying this by 10000 can't overflow.  */
602   register int pri1
603     = (((double) (floor_log2 (allocno_n_refs[v1]) * allocno_n_refs[v1])
604         / allocno_live_length[v1])
605        * 10000 * allocno_size[v1]);
606   register int pri2
607     = (((double) (floor_log2 (allocno_n_refs[v2]) * allocno_n_refs[v2])
608         / allocno_live_length[v2])
609        * 10000 * allocno_size[v2]);
610   if (pri2 - pri1)
611     return pri2 - pri1;
612
613   /* If regs are equally good, sort by allocno,
614      so that the results of qsort leave nothing to chance.  */
615   return v1 - v2;
616 }
617 \f
618 /* Scan the rtl code and record all conflicts and register preferences in the
619    conflict matrices and preference tables.  */
620
621 static void
622 global_conflicts ()
623 {
624   register int b, i;
625   register rtx insn;
626   int *block_start_allocnos;
627
628   /* Make a vector that mark_reg_{store,clobber} will store in.  */
629   regs_set = (rtx *) alloca (max_parallel * sizeof (rtx) * 2);
630
631   block_start_allocnos = (int *) alloca (max_allocno * sizeof (int));
632
633   for (b = 0; b < n_basic_blocks; b++)
634     {
635       bzero ((char *) allocnos_live, allocno_row_words * sizeof (INT_TYPE));
636
637       /* Initialize table of registers currently live
638          to the state at the beginning of this basic block.
639          This also marks the conflicts among them.
640
641          For pseudo-regs, there is only one bit for each one
642          no matter how many hard regs it occupies.
643          This is ok; we know the size from PSEUDO_REGNO_SIZE.
644          For explicit hard regs, we cannot know the size that way
645          since one hard reg can be used with various sizes.
646          Therefore, we must require that all the hard regs
647          implicitly live as part of a multi-word hard reg
648          are explicitly marked in basic_block_live_at_start.  */
649
650       {
651         register regset old = BASIC_BLOCK (b)->global_live_at_start;
652         int ax = 0;
653
654         REG_SET_TO_HARD_REG_SET (hard_regs_live, old);
655         EXECUTE_IF_SET_IN_REG_SET (old, FIRST_PSEUDO_REGISTER, i,
656                                    {
657                                      register int a = reg_allocno[i];
658                                      if (a >= 0)
659                                        {
660                                          SET_ALLOCNO_LIVE (a);
661                                          block_start_allocnos[ax++] = a;
662                                        }
663                                      else if ((a = reg_renumber[i]) >= 0)
664                                        mark_reg_live_nc
665                                          (a, PSEUDO_REGNO_MODE (i));
666                                    });
667
668         /* Record that each allocno now live conflicts with each other
669            allocno now live, and with each hard reg now live.  */
670
671         record_conflicts (block_start_allocnos, ax);
672
673 #ifdef STACK_REGS
674         {
675           /* Pseudos can't go in stack regs at the start of a basic block
676              that is reached by an abnormal edge.  */
677
678           edge e;
679           for (e = BASIC_BLOCK (b)->pred; e ; e = e->pred_next)
680             if (e->flags & EDGE_ABNORMAL)
681               break;
682           if (e != NULL)
683             for (ax = FIRST_STACK_REG; ax <= LAST_STACK_REG; ax++)
684               record_one_conflict (ax);
685         }
686 #endif
687       }
688
689       insn = BLOCK_HEAD (b);
690
691       /* Scan the code of this basic block, noting which allocnos
692          and hard regs are born or die.  When one is born,
693          record a conflict with all others currently live.  */
694
695       while (1)
696         {
697           register RTX_CODE code = GET_CODE (insn);
698           register rtx link;
699
700           /* Make regs_set an empty set.  */
701
702           n_regs_set = 0;
703
704           if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
705             {
706
707 #if 0
708               int i = 0;
709               for (link = REG_NOTES (insn);
710                    link && i < NUM_NO_CONFLICT_PAIRS;
711                    link = XEXP (link, 1))
712                 if (REG_NOTE_KIND (link) == REG_NO_CONFLICT)
713                   {
714                     no_conflict_pairs[i].allocno1
715                       = reg_allocno[REGNO (SET_DEST (PATTERN (insn)))];
716                     no_conflict_pairs[i].allocno2
717                       = reg_allocno[REGNO (XEXP (link, 0))];
718                     i++;
719                   }
720 #endif /* 0 */
721
722               /* Mark any registers clobbered by INSN as live,
723                  so they conflict with the inputs.  */
724
725               note_stores (PATTERN (insn), mark_reg_clobber);
726
727               /* Mark any registers dead after INSN as dead now.  */
728
729               for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
730                 if (REG_NOTE_KIND (link) == REG_DEAD)
731                   mark_reg_death (XEXP (link, 0));
732
733               /* Mark any registers set in INSN as live,
734                  and mark them as conflicting with all other live regs.
735                  Clobbers are processed again, so they conflict with
736                  the registers that are set.  */
737
738               note_stores (PATTERN (insn), mark_reg_store);
739
740 #ifdef AUTO_INC_DEC
741               for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
742                 if (REG_NOTE_KIND (link) == REG_INC)
743                   mark_reg_store (XEXP (link, 0), NULL_RTX);
744 #endif
745
746               /* If INSN has multiple outputs, then any reg that dies here
747                  and is used inside of an output
748                  must conflict with the other outputs.
749
750                  It is unsafe to use !single_set here since it will ignore an
751                  unused output.  Just because an output is unused does not mean
752                  the compiler can assume the side effect will not occur.
753                  Consider if REG appears in the address of an output and we
754                  reload the output.  If we allocate REG to the same hard
755                  register as an unused output we could set the hard register
756                  before the output reload insn.  */
757               if (GET_CODE (PATTERN (insn)) == PARALLEL && multiple_sets (insn))
758                 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
759                   if (REG_NOTE_KIND (link) == REG_DEAD)
760                     {
761                       int used_in_output = 0;
762                       int i;
763                       rtx reg = XEXP (link, 0);
764
765                       for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--)
766                         {
767                           rtx set = XVECEXP (PATTERN (insn), 0, i);
768                           if (GET_CODE (set) == SET
769                               && GET_CODE (SET_DEST (set)) != REG
770                               && !rtx_equal_p (reg, SET_DEST (set))
771                               && reg_overlap_mentioned_p (reg, SET_DEST (set)))
772                             used_in_output = 1;
773                         }
774                       if (used_in_output)
775                         mark_reg_conflicts (reg);
776                     }
777
778               /* Mark any registers set in INSN and then never used.  */
779
780               while (n_regs_set > 0)
781                 if (find_regno_note (insn, REG_UNUSED,
782                                      REGNO (regs_set[--n_regs_set])))
783                   mark_reg_death (regs_set[n_regs_set]);
784             }
785
786           if (insn == BLOCK_END (b))
787             break;
788           insn = NEXT_INSN (insn);
789         }
790     }
791 }
792 /* Expand the preference information by looking for cases where one allocno
793    dies in an insn that sets an allocno.  If those two allocnos don't conflict,
794    merge any preferences between those allocnos.  */
795
796 static void
797 expand_preferences ()
798 {
799   rtx insn;
800   rtx link;
801   rtx set;
802
803   /* We only try to handle the most common cases here.  Most of the cases
804      where this wins are reg-reg copies.  */
805
806   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
807     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
808         && (set = single_set (insn)) != 0
809         && GET_CODE (SET_DEST (set)) == REG
810         && reg_allocno[REGNO (SET_DEST (set))] >= 0)
811       for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
812         if (REG_NOTE_KIND (link) == REG_DEAD
813             && GET_CODE (XEXP (link, 0)) == REG
814             && reg_allocno[REGNO (XEXP (link, 0))] >= 0
815             && ! CONFLICTP (reg_allocno[REGNO (SET_DEST (set))],
816                             reg_allocno[REGNO (XEXP (link, 0))])
817             && ! CONFLICTP (reg_allocno[REGNO (XEXP (link, 0))],
818                             reg_allocno[REGNO (SET_DEST (set))]))
819           {
820             int a1 = reg_allocno[REGNO (SET_DEST (set))];
821             int a2 = reg_allocno[REGNO (XEXP (link, 0))];
822
823             if (XEXP (link, 0) == SET_SRC (set))
824               {
825                 IOR_HARD_REG_SET (hard_reg_copy_preferences[a1],
826                                   hard_reg_copy_preferences[a2]);
827                 IOR_HARD_REG_SET (hard_reg_copy_preferences[a2],
828                                   hard_reg_copy_preferences[a1]);
829               }
830
831             IOR_HARD_REG_SET (hard_reg_preferences[a1],
832                               hard_reg_preferences[a2]);
833             IOR_HARD_REG_SET (hard_reg_preferences[a2],
834                               hard_reg_preferences[a1]);
835             IOR_HARD_REG_SET (hard_reg_full_preferences[a1],
836                               hard_reg_full_preferences[a2]);
837             IOR_HARD_REG_SET (hard_reg_full_preferences[a2],
838                               hard_reg_full_preferences[a1]);
839           }
840 }
841 \f
842 /* Prune the preferences for global registers to exclude registers that cannot
843    be used.
844    
845    Compute `regs_someone_prefers', which is a bitmask of the hard registers
846    that are preferred by conflicting registers of lower priority.  If possible,
847    we will avoid using these registers.  */
848    
849 static void
850 prune_preferences ()
851 {
852   int i, j;
853   int allocno;
854   
855   /* Scan least most important to most important.
856      For each allocno, remove from preferences registers that cannot be used,
857      either because of conflicts or register type.  Then compute all registers
858      preferred by each lower-priority register that conflicts.  */
859
860   for (i = max_allocno - 1; i >= 0; i--)
861     {
862       HARD_REG_SET temp, temp2;
863
864       allocno = allocno_order[i];
865       COPY_HARD_REG_SET (temp, hard_reg_conflicts[allocno]);
866
867       if (allocno_calls_crossed[allocno] == 0)
868         IOR_HARD_REG_SET (temp, fixed_reg_set);
869       else
870         IOR_HARD_REG_SET (temp, call_used_reg_set);
871
872       IOR_COMPL_HARD_REG_SET
873         (temp,
874          reg_class_contents[(int) reg_preferred_class (allocno_reg[allocno])]);
875
876       AND_COMPL_HARD_REG_SET (hard_reg_preferences[allocno], temp);
877       AND_COMPL_HARD_REG_SET (hard_reg_copy_preferences[allocno], temp);
878       AND_COMPL_HARD_REG_SET (hard_reg_full_preferences[allocno], temp);
879
880       /* Merge in the preferences of lower-priority registers (they have
881          already been pruned).  If we also prefer some of those registers,
882          don't exclude them unless we are of a smaller size (in which case
883          we want to give the lower-priority allocno the first chance for
884          these registers).  */
885       CLEAR_HARD_REG_SET (temp);
886       CLEAR_HARD_REG_SET (temp2);
887       for (j = i + 1; j < max_allocno; j++)
888         if (CONFLICTP (allocno, allocno_order[j])
889             || CONFLICTP (allocno_order[j], allocno))
890           {
891             if (allocno_size[allocno_order[j]] <= allocno_size[allocno])
892               IOR_HARD_REG_SET (temp,
893                                 hard_reg_full_preferences[allocno_order[j]]);
894             else
895               IOR_HARD_REG_SET (temp2,
896                                 hard_reg_full_preferences[allocno_order[j]]);
897           }
898       AND_COMPL_HARD_REG_SET (temp, hard_reg_full_preferences[allocno]);
899       IOR_HARD_REG_SET (temp, temp2);
900       COPY_HARD_REG_SET (regs_someone_prefers[allocno], temp);
901     }
902 }
903 \f
904 /* Assign a hard register to ALLOCNO; look for one that is the beginning
905    of a long enough stretch of hard regs none of which conflicts with ALLOCNO.
906    The registers marked in PREFREGS are tried first.
907
908    LOSERS, if non-zero, is a HARD_REG_SET indicating registers that cannot
909    be used for this allocation.
910
911    If ALT_REGS_P is zero, consider only the preferred class of ALLOCNO's reg.
912    Otherwise ignore that preferred class and use the alternate class.
913
914    If ACCEPT_CALL_CLOBBERED is nonzero, accept a call-clobbered hard reg that
915    will have to be saved and restored at calls.
916
917    RETRYING is nonzero if this is called from retry_global_alloc.
918
919    If we find one, record it in reg_renumber.
920    If not, do nothing.  */
921
922 static void
923 find_reg (allocno, losers, alt_regs_p, accept_call_clobbered, retrying)
924      int allocno;
925      HARD_REG_SET losers;
926      int alt_regs_p;
927      int accept_call_clobbered;
928      int retrying;
929 {
930   register int i, best_reg, pass;
931 #ifdef HARD_REG_SET
932   register              /* Declare it register if it's a scalar.  */
933 #endif
934     HARD_REG_SET used, used1, used2;
935
936   enum reg_class class = (alt_regs_p
937                           ? reg_alternate_class (allocno_reg[allocno])
938                           : reg_preferred_class (allocno_reg[allocno]));
939   enum machine_mode mode = PSEUDO_REGNO_MODE (allocno_reg[allocno]);
940
941   if (accept_call_clobbered)
942     COPY_HARD_REG_SET (used1, call_fixed_reg_set);
943   else if (allocno_calls_crossed[allocno] == 0)
944     COPY_HARD_REG_SET (used1, fixed_reg_set);
945   else
946     COPY_HARD_REG_SET (used1, call_used_reg_set);
947
948   /* Some registers should not be allocated in global-alloc.  */
949   IOR_HARD_REG_SET (used1, no_global_alloc_regs);
950   if (losers)
951     IOR_HARD_REG_SET (used1, losers);
952
953   IOR_COMPL_HARD_REG_SET (used1, reg_class_contents[(int) class]);
954   COPY_HARD_REG_SET (used2, used1);
955
956   IOR_HARD_REG_SET (used1, hard_reg_conflicts[allocno]);
957
958 #ifdef CLASS_CANNOT_CHANGE_SIZE
959   if (REG_CHANGES_SIZE (allocno_reg[allocno]))
960     IOR_HARD_REG_SET (used1,
961                       reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE]);
962 #endif
963
964   /* Try each hard reg to see if it fits.  Do this in two passes.
965      In the first pass, skip registers that are preferred by some other pseudo
966      to give it a better chance of getting one of those registers.  Only if
967      we can't get a register when excluding those do we take one of them.
968      However, we never allocate a register for the first time in pass 0.  */
969
970   COPY_HARD_REG_SET (used, used1);
971   IOR_COMPL_HARD_REG_SET (used, regs_used_so_far);
972   IOR_HARD_REG_SET (used, regs_someone_prefers[allocno]);
973   
974   best_reg = -1;
975   for (i = FIRST_PSEUDO_REGISTER, pass = 0;
976        pass <= 1 && i >= FIRST_PSEUDO_REGISTER;
977        pass++)
978     {
979       if (pass == 1)
980         COPY_HARD_REG_SET (used, used1);
981       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
982         {
983 #ifdef REG_ALLOC_ORDER
984           int regno = reg_alloc_order[i];
985 #else
986           int regno = i;
987 #endif
988           if (! TEST_HARD_REG_BIT (used, regno)
989               && HARD_REGNO_MODE_OK (regno, mode)
990               && (allocno_calls_crossed[allocno] == 0
991                   || accept_call_clobbered
992                   || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
993             {
994               register int j;
995               register int lim = regno + HARD_REGNO_NREGS (regno, mode);
996               for (j = regno + 1;
997                    (j < lim
998                     && ! TEST_HARD_REG_BIT (used, j));
999                    j++);
1000               if (j == lim)
1001                 {
1002                   best_reg = regno;
1003                   break;
1004                 }
1005 #ifndef REG_ALLOC_ORDER
1006               i = j;                    /* Skip starting points we know will lose */
1007 #endif
1008             }
1009           }
1010       }
1011
1012   /* See if there is a preferred register with the same class as the register
1013      we allocated above.  Making this restriction prevents register
1014      preferencing from creating worse register allocation.
1015
1016      Remove from the preferred registers and conflicting registers.  Note that
1017      additional conflicts may have been added after `prune_preferences' was
1018      called. 
1019
1020      First do this for those register with copy preferences, then all
1021      preferred registers.  */
1022
1023   AND_COMPL_HARD_REG_SET (hard_reg_copy_preferences[allocno], used);
1024   GO_IF_HARD_REG_SUBSET (hard_reg_copy_preferences[allocno],
1025                          reg_class_contents[(int) NO_REGS], no_copy_prefs);
1026
1027   if (best_reg >= 0)
1028     {
1029       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1030         if (TEST_HARD_REG_BIT (hard_reg_copy_preferences[allocno], i)
1031             && HARD_REGNO_MODE_OK (i, mode)
1032             && (REGNO_REG_CLASS (i) == REGNO_REG_CLASS (best_reg)
1033                 || reg_class_subset_p (REGNO_REG_CLASS (i),
1034                                        REGNO_REG_CLASS (best_reg))
1035                 || reg_class_subset_p (REGNO_REG_CLASS (best_reg),
1036                                        REGNO_REG_CLASS (i))))
1037             {
1038               register int j;
1039               register int lim = i + HARD_REGNO_NREGS (i, mode);
1040               for (j = i + 1;
1041                    (j < lim
1042                     && ! TEST_HARD_REG_BIT (used, j)
1043                     && (REGNO_REG_CLASS (j)
1044                         == REGNO_REG_CLASS (best_reg + (j - i))
1045                         || reg_class_subset_p (REGNO_REG_CLASS (j),
1046                                                REGNO_REG_CLASS (best_reg + (j - i)))
1047                         || reg_class_subset_p (REGNO_REG_CLASS (best_reg + (j - i)),
1048                                                REGNO_REG_CLASS (j))));
1049                    j++);
1050               if (j == lim)
1051                 {
1052                   best_reg = i;
1053                   goto no_prefs;
1054                 }
1055             }
1056     }
1057  no_copy_prefs:
1058
1059   AND_COMPL_HARD_REG_SET (hard_reg_preferences[allocno], used);
1060   GO_IF_HARD_REG_SUBSET (hard_reg_preferences[allocno],
1061                          reg_class_contents[(int) NO_REGS], no_prefs);
1062
1063   if (best_reg >= 0)
1064     {
1065       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1066         if (TEST_HARD_REG_BIT (hard_reg_preferences[allocno], i)
1067             && HARD_REGNO_MODE_OK (i, mode)
1068             && (REGNO_REG_CLASS (i) == REGNO_REG_CLASS (best_reg)
1069                 || reg_class_subset_p (REGNO_REG_CLASS (i),
1070                                        REGNO_REG_CLASS (best_reg))
1071                 || reg_class_subset_p (REGNO_REG_CLASS (best_reg),
1072                                        REGNO_REG_CLASS (i))))
1073             {
1074               register int j;
1075               register int lim = i + HARD_REGNO_NREGS (i, mode);
1076               for (j = i + 1;
1077                    (j < lim
1078                     && ! TEST_HARD_REG_BIT (used, j)
1079                     && (REGNO_REG_CLASS (j)
1080                         == REGNO_REG_CLASS (best_reg + (j - i))
1081                         || reg_class_subset_p (REGNO_REG_CLASS (j),
1082                                                REGNO_REG_CLASS (best_reg + (j - i)))
1083                         || reg_class_subset_p (REGNO_REG_CLASS (best_reg + (j - i)),
1084                                                REGNO_REG_CLASS (j))));
1085                    j++);
1086               if (j == lim)
1087                 {
1088                   best_reg = i;
1089                   break;
1090                 }
1091             }
1092     }
1093  no_prefs:
1094
1095   /* If we haven't succeeded yet, try with caller-saves. 
1096      We need not check to see if the current function has nonlocal
1097      labels because we don't put any pseudos that are live over calls in
1098      registers in that case.  */
1099
1100   if (flag_caller_saves && best_reg < 0)
1101     {
1102       /* Did not find a register.  If it would be profitable to
1103          allocate a call-clobbered register and save and restore it
1104          around calls, do that.  */
1105       if (! accept_call_clobbered
1106           && allocno_calls_crossed[allocno] != 0
1107           && CALLER_SAVE_PROFITABLE (allocno_n_refs[allocno],
1108                                      allocno_calls_crossed[allocno]))
1109         {
1110           HARD_REG_SET new_losers;
1111           if (! losers)
1112             CLEAR_HARD_REG_SET (new_losers);
1113           else
1114             COPY_HARD_REG_SET (new_losers, losers);
1115             
1116           IOR_HARD_REG_SET(new_losers, losing_caller_save_reg_set);
1117           find_reg (allocno, new_losers, alt_regs_p, 1, retrying);
1118           if (reg_renumber[allocno_reg[allocno]] >= 0)
1119             {
1120               caller_save_needed = 1;
1121               return;
1122             }
1123         }
1124     }
1125
1126   /* If we haven't succeeded yet,
1127      see if some hard reg that conflicts with us
1128      was utilized poorly by local-alloc.
1129      If so, kick out the regs that were put there by local-alloc
1130      so we can use it instead.  */
1131   if (best_reg < 0 && !retrying
1132       /* Let's not bother with multi-reg allocnos.  */
1133       && allocno_size[allocno] == 1)
1134     {
1135       /* Count from the end, to find the least-used ones first.  */
1136       for (i = FIRST_PSEUDO_REGISTER - 1; i >= 0; i--)
1137         {
1138 #ifdef REG_ALLOC_ORDER
1139           int regno = reg_alloc_order[i];
1140 #else
1141           int regno = i;
1142 #endif
1143
1144           if (local_reg_n_refs[regno] != 0
1145               /* Don't use a reg no good for this pseudo.  */
1146               && ! TEST_HARD_REG_BIT (used2, regno)
1147               && HARD_REGNO_MODE_OK (regno, mode)
1148 #ifdef CLASS_CANNOT_CHANGE_SIZE
1149               && ! (REG_CHANGES_SIZE (allocno_reg[allocno])
1150                     && (TEST_HARD_REG_BIT
1151                         (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
1152                          regno)))
1153 #endif
1154               )
1155             {
1156               /* We explicitly evaluate the divide results into temporary
1157                  variables so as to avoid excess precision problems that occur
1158                  on a i386-unknown-sysv4.2 (unixware) host.  */
1159                  
1160               double tmp1 = ((double) local_reg_n_refs[regno]
1161                             / local_reg_live_length[regno]);
1162               double tmp2 = ((double) allocno_n_refs[allocno]
1163                              / allocno_live_length[allocno]);
1164
1165               if (tmp1 < tmp2)
1166                 {
1167                   /* Hard reg REGNO was used less in total by local regs
1168                      than it would be used by this one allocno!  */
1169                   int k;
1170                   for (k = 0; k < max_regno; k++)
1171                     if (reg_renumber[k] >= 0)
1172                       {
1173                         int r = reg_renumber[k];
1174                         int endregno
1175                           = r + HARD_REGNO_NREGS (r, PSEUDO_REGNO_MODE (k));
1176
1177                         if (regno >= r && regno < endregno)
1178                           reg_renumber[k] = -1;
1179                       }
1180
1181                   best_reg = regno;
1182                   break;
1183                 }
1184             }
1185         }
1186     }
1187
1188   /* Did we find a register?  */
1189
1190   if (best_reg >= 0)
1191     {
1192       register int lim, j;
1193       HARD_REG_SET this_reg;
1194
1195       /* Yes.  Record it as the hard register of this pseudo-reg.  */
1196       reg_renumber[allocno_reg[allocno]] = best_reg;
1197       /* Also of any pseudo-regs that share with it.  */
1198       if (reg_may_share[allocno_reg[allocno]])
1199         for (j = FIRST_PSEUDO_REGISTER; j < max_regno; j++)
1200           if (reg_allocno[j] == allocno)
1201             reg_renumber[j] = best_reg;
1202
1203       /* Make a set of the hard regs being allocated.  */
1204       CLEAR_HARD_REG_SET (this_reg);
1205       lim = best_reg + HARD_REGNO_NREGS (best_reg, mode);
1206       for (j = best_reg; j < lim; j++)
1207         {
1208           SET_HARD_REG_BIT (this_reg, j);
1209           SET_HARD_REG_BIT (regs_used_so_far, j);
1210           /* This is no longer a reg used just by local regs.  */
1211           local_reg_n_refs[j] = 0;
1212         }
1213       /* For each other pseudo-reg conflicting with this one,
1214          mark it as conflicting with the hard regs this one occupies.  */
1215       lim = allocno;
1216       for (j = 0; j < max_allocno; j++)
1217         if (CONFLICTP (lim, j) || CONFLICTP (j, lim))
1218           {
1219             IOR_HARD_REG_SET (hard_reg_conflicts[j], this_reg);
1220           }
1221     }
1222 }
1223 \f
1224 /* Called from `reload' to look for a hard reg to put pseudo reg REGNO in.
1225    Perhaps it had previously seemed not worth a hard reg,
1226    or perhaps its old hard reg has been commandeered for reloads.
1227    FORBIDDEN_REGS indicates certain hard regs that may not be used, even if
1228    they do not appear to be allocated.
1229    If FORBIDDEN_REGS is zero, no regs are forbidden.  */
1230
1231 void
1232 retry_global_alloc (regno, forbidden_regs)
1233      int regno;
1234      HARD_REG_SET forbidden_regs;
1235 {
1236   int allocno = reg_allocno[regno];
1237   if (allocno >= 0)
1238     {
1239       /* If we have more than one register class,
1240          first try allocating in the class that is cheapest
1241          for this pseudo-reg.  If that fails, try any reg.  */
1242       if (N_REG_CLASSES > 1)
1243         find_reg (allocno, forbidden_regs, 0, 0, 1);
1244       if (reg_renumber[regno] < 0
1245           && reg_alternate_class (regno) != NO_REGS)
1246         find_reg (allocno, forbidden_regs, 1, 0, 1);
1247
1248       /* If we found a register, modify the RTL for the register to
1249          show the hard register, and mark that register live.  */
1250       if (reg_renumber[regno] >= 0)
1251         {
1252           REGNO (regno_reg_rtx[regno]) = reg_renumber[regno];
1253           mark_home_live (regno);
1254         }
1255     }
1256 }
1257 \f
1258 /* Record a conflict between register REGNO
1259    and everything currently live.
1260    REGNO must not be a pseudo reg that was allocated
1261    by local_alloc; such numbers must be translated through
1262    reg_renumber before calling here.  */
1263
1264 static void
1265 record_one_conflict (regno)
1266      int regno;
1267 {
1268   register int j;
1269
1270   if (regno < FIRST_PSEUDO_REGISTER)
1271     /* When a hard register becomes live,
1272        record conflicts with live pseudo regs.  */
1273     for (j = 0; j < max_allocno; j++)
1274       {
1275         if (ALLOCNO_LIVE_P (j))
1276           SET_HARD_REG_BIT (hard_reg_conflicts[j], regno);
1277       }
1278   else
1279     /* When a pseudo-register becomes live,
1280        record conflicts first with hard regs,
1281        then with other pseudo regs.  */
1282     {
1283       register int ialloc = reg_allocno[regno];
1284       register int ialloc_prod = ialloc * allocno_row_words;
1285       IOR_HARD_REG_SET (hard_reg_conflicts[ialloc], hard_regs_live);
1286       for (j = allocno_row_words - 1; j >= 0; j--)
1287         {
1288 #if 0
1289           int k;
1290           for (k = 0; k < n_no_conflict_pairs; k++)
1291             if (! ((j == no_conflict_pairs[k].allocno1
1292                     && ialloc == no_conflict_pairs[k].allocno2)
1293                    ||
1294                    (j == no_conflict_pairs[k].allocno2
1295                     && ialloc == no_conflict_pairs[k].allocno1)))
1296 #endif /* 0 */
1297               conflicts[ialloc_prod + j] |= allocnos_live[j];
1298         }
1299     }
1300 }
1301
1302 /* Record all allocnos currently live as conflicting
1303    with each other and with all hard regs currently live.
1304    ALLOCNO_VEC is a vector of LEN allocnos, all allocnos that
1305    are currently live.  Their bits are also flagged in allocnos_live.  */
1306
1307 static void
1308 record_conflicts (allocno_vec, len)
1309      register int *allocno_vec;
1310      register int len;
1311 {
1312   register int allocno;
1313   register int j;
1314   register int ialloc_prod;
1315
1316   while (--len >= 0)
1317     {
1318       allocno = allocno_vec[len];
1319       ialloc_prod = allocno * allocno_row_words;
1320       IOR_HARD_REG_SET (hard_reg_conflicts[allocno], hard_regs_live);
1321       for (j = allocno_row_words - 1; j >= 0; j--)
1322         conflicts[ialloc_prod + j] |= allocnos_live[j];
1323     }
1324 }
1325 \f
1326 /* Handle the case where REG is set by the insn being scanned,
1327    during the forward scan to accumulate conflicts.
1328    Store a 1 in regs_live or allocnos_live for this register, record how many
1329    consecutive hardware registers it actually needs,
1330    and record a conflict with all other registers already live.
1331
1332    Note that even if REG does not remain alive after this insn,
1333    we must mark it here as live, to ensure a conflict between
1334    REG and any other regs set in this insn that really do live.
1335    This is because those other regs could be considered after this.
1336
1337    REG might actually be something other than a register;
1338    if so, we do nothing.
1339
1340    SETTER is 0 if this register was modified by an auto-increment (i.e.,
1341    a REG_INC note was found for it).  */
1342
1343 static void
1344 mark_reg_store (reg, setter)
1345      rtx reg, setter;
1346 {
1347   register int regno;
1348
1349   /* WORD is which word of a multi-register group is being stored.
1350      For the case where the store is actually into a SUBREG of REG.
1351      Except we don't use it; I believe the entire REG needs to be
1352      made live.  */
1353   int word = 0;
1354
1355   if (GET_CODE (reg) == SUBREG)
1356     {
1357       word = SUBREG_WORD (reg);
1358       reg = SUBREG_REG (reg);
1359     }
1360
1361   if (GET_CODE (reg) != REG)
1362     return;
1363
1364   regs_set[n_regs_set++] = reg;
1365
1366   if (setter && GET_CODE (setter) != CLOBBER)
1367     set_preference (reg, SET_SRC (setter));
1368
1369   regno = REGNO (reg);
1370
1371   /* Either this is one of the max_allocno pseudo regs not allocated,
1372      or it is or has a hardware reg.  First handle the pseudo-regs.  */
1373   if (regno >= FIRST_PSEUDO_REGISTER)
1374     {
1375       if (reg_allocno[regno] >= 0)
1376         {
1377           SET_ALLOCNO_LIVE (reg_allocno[regno]);
1378           record_one_conflict (regno);
1379         }
1380     }
1381
1382   if (reg_renumber[regno] >= 0)
1383     regno = reg_renumber[regno] /* + word */;
1384
1385   /* Handle hardware regs (and pseudos allocated to hard regs).  */
1386   if (regno < FIRST_PSEUDO_REGISTER && ! fixed_regs[regno])
1387     {
1388       register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
1389       while (regno < last)
1390         {
1391           record_one_conflict (regno);
1392           SET_HARD_REG_BIT (hard_regs_live, regno);
1393           regno++;
1394         }
1395     }
1396 }
1397 \f
1398 /* Like mark_reg_set except notice just CLOBBERs; ignore SETs.  */
1399
1400 static void
1401 mark_reg_clobber (reg, setter)
1402      rtx reg, setter;
1403 {
1404   if (GET_CODE (setter) == CLOBBER)
1405     mark_reg_store (reg, setter);
1406 }
1407
1408 /* Record that REG has conflicts with all the regs currently live.
1409    Do not mark REG itself as live.  */
1410
1411 static void
1412 mark_reg_conflicts (reg)
1413      rtx reg;
1414 {
1415   register int regno;
1416
1417   if (GET_CODE (reg) == SUBREG)
1418     reg = SUBREG_REG (reg);
1419
1420   if (GET_CODE (reg) != REG)
1421     return;
1422
1423   regno = REGNO (reg);
1424
1425   /* Either this is one of the max_allocno pseudo regs not allocated,
1426      or it is or has a hardware reg.  First handle the pseudo-regs.  */
1427   if (regno >= FIRST_PSEUDO_REGISTER)
1428     {
1429       if (reg_allocno[regno] >= 0)
1430         record_one_conflict (regno);
1431     }
1432
1433   if (reg_renumber[regno] >= 0)
1434     regno = reg_renumber[regno];
1435
1436   /* Handle hardware regs (and pseudos allocated to hard regs).  */
1437   if (regno < FIRST_PSEUDO_REGISTER && ! fixed_regs[regno])
1438     {
1439       register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
1440       while (regno < last)
1441         {
1442           record_one_conflict (regno);
1443           regno++;
1444         }
1445     }
1446 }
1447 \f
1448 /* Mark REG as being dead (following the insn being scanned now).
1449    Store a 0 in regs_live or allocnos_live for this register.  */
1450
1451 static void
1452 mark_reg_death (reg)
1453      rtx reg;
1454 {
1455   register int regno = REGNO (reg);
1456
1457   /* Either this is one of the max_allocno pseudo regs not allocated,
1458      or it is a hardware reg.  First handle the pseudo-regs.  */
1459   if (regno >= FIRST_PSEUDO_REGISTER)
1460     {
1461       if (reg_allocno[regno] >= 0)
1462         CLEAR_ALLOCNO_LIVE (reg_allocno[regno]);
1463     }
1464
1465   /* For pseudo reg, see if it has been assigned a hardware reg.  */
1466   if (reg_renumber[regno] >= 0)
1467     regno = reg_renumber[regno];
1468
1469   /* Handle hardware regs (and pseudos allocated to hard regs).  */
1470   if (regno < FIRST_PSEUDO_REGISTER && ! fixed_regs[regno])
1471     {
1472       /* Pseudo regs already assigned hardware regs are treated
1473          almost the same as explicit hardware regs.  */
1474       register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));
1475       while (regno < last)
1476         {
1477           CLEAR_HARD_REG_BIT (hard_regs_live, regno);
1478           regno++;
1479         }
1480     }
1481 }
1482
1483 /* Mark hard reg REGNO as currently live, assuming machine mode MODE
1484    for the value stored in it.  MODE determines how many consecutive
1485    registers are actually in use.  Do not record conflicts;
1486    it is assumed that the caller will do that.  */
1487
1488 static void
1489 mark_reg_live_nc (regno, mode)
1490      register int regno;
1491      enum machine_mode mode;
1492 {
1493   register int last = regno + HARD_REGNO_NREGS (regno, mode);
1494   while (regno < last)
1495     {
1496       SET_HARD_REG_BIT (hard_regs_live, regno);
1497       regno++;
1498     }
1499 }
1500 \f
1501 /* Try to set a preference for an allocno to a hard register.
1502    We are passed DEST and SRC which are the operands of a SET.  It is known
1503    that SRC is a register.  If SRC or the first operand of SRC is a register,
1504    try to set a preference.  If one of the two is a hard register and the other
1505    is a pseudo-register, mark the preference.
1506    
1507    Note that we are not as aggressive as local-alloc in trying to tie a
1508    pseudo-register to a hard register.  */
1509
1510 static void
1511 set_preference (dest, src)
1512      rtx dest, src;
1513 {
1514   int src_regno, dest_regno;
1515   /* Amount to add to the hard regno for SRC, or subtract from that for DEST,
1516      to compensate for subregs in SRC or DEST.  */
1517   int offset = 0;
1518   int i;
1519   int copy = 1;
1520
1521   if (GET_RTX_FORMAT (GET_CODE (src))[0] == 'e')
1522     src = XEXP (src, 0), copy = 0;
1523
1524   /* Get the reg number for both SRC and DEST.
1525      If neither is a reg, give up.  */
1526
1527   if (GET_CODE (src) == REG)
1528     src_regno = REGNO (src);
1529   else if (GET_CODE (src) == SUBREG && GET_CODE (SUBREG_REG (src)) == REG)
1530     {
1531       src_regno = REGNO (SUBREG_REG (src));
1532       offset += SUBREG_WORD (src);
1533     }
1534   else
1535     return;
1536
1537   if (GET_CODE (dest) == REG)
1538     dest_regno = REGNO (dest);
1539   else if (GET_CODE (dest) == SUBREG && GET_CODE (SUBREG_REG (dest)) == REG)
1540     {
1541       dest_regno = REGNO (SUBREG_REG (dest));
1542       offset -= SUBREG_WORD (dest);
1543     }
1544   else
1545     return;
1546
1547   /* Convert either or both to hard reg numbers.  */
1548
1549   if (reg_renumber[src_regno] >= 0)
1550     src_regno = reg_renumber[src_regno];
1551
1552   if (reg_renumber[dest_regno] >= 0)
1553     dest_regno = reg_renumber[dest_regno];
1554
1555   /* Now if one is a hard reg and the other is a global pseudo
1556      then give the other a preference.  */
1557
1558   if (dest_regno < FIRST_PSEUDO_REGISTER && src_regno >= FIRST_PSEUDO_REGISTER
1559       && reg_allocno[src_regno] >= 0)
1560     {
1561       dest_regno -= offset;
1562       if (dest_regno >= 0 && dest_regno < FIRST_PSEUDO_REGISTER)
1563         {
1564           if (copy)
1565             SET_REGBIT (hard_reg_copy_preferences,
1566                         reg_allocno[src_regno], dest_regno);
1567
1568           SET_REGBIT (hard_reg_preferences,
1569                       reg_allocno[src_regno], dest_regno);
1570           for (i = dest_regno;
1571                i < dest_regno + HARD_REGNO_NREGS (dest_regno, GET_MODE (dest));
1572                i++)
1573             SET_REGBIT (hard_reg_full_preferences, reg_allocno[src_regno], i);
1574         }
1575     }
1576
1577   if (src_regno < FIRST_PSEUDO_REGISTER && dest_regno >= FIRST_PSEUDO_REGISTER
1578       && reg_allocno[dest_regno] >= 0)
1579     {
1580       src_regno += offset;
1581       if (src_regno >= 0 && src_regno < FIRST_PSEUDO_REGISTER)
1582         {
1583           if (copy)
1584             SET_REGBIT (hard_reg_copy_preferences,
1585                         reg_allocno[dest_regno], src_regno);
1586
1587           SET_REGBIT (hard_reg_preferences,
1588                       reg_allocno[dest_regno], src_regno);
1589           for (i = src_regno;
1590                i < src_regno + HARD_REGNO_NREGS (src_regno, GET_MODE (src));
1591                i++)
1592             SET_REGBIT (hard_reg_full_preferences, reg_allocno[dest_regno], i);
1593         }
1594     }
1595 }
1596 \f
1597 /* Indicate that hard register number FROM was eliminated and replaced with
1598    an offset from hard register number TO.  The status of hard registers live
1599    at the start of a basic block is updated by replacing a use of FROM with
1600    a use of TO.  */
1601
1602 void
1603 mark_elimination (from, to)
1604      int from, to;
1605 {
1606   int i;
1607
1608   for (i = 0; i < n_basic_blocks; i++)
1609     {
1610       register regset r = BASIC_BLOCK (i)->global_live_at_start; 
1611       if (REGNO_REG_SET_P (r, from))
1612         {
1613           CLEAR_REGNO_REG_SET (r, from);
1614           SET_REGNO_REG_SET (r, to);
1615         }
1616     }
1617 }
1618 \f
1619 /* Used for communication between the following functions.  Holds the
1620    current life information.  */
1621 static regset live_relevant_regs;
1622
1623 /* Record in live_relevant_regs that register REG became live.  This
1624    is called via note_stores.  */
1625 static void
1626 reg_becomes_live (reg, setter)
1627      rtx reg;
1628      rtx setter ATTRIBUTE_UNUSED;
1629 {
1630   int regno;
1631
1632   if (GET_CODE (reg) == SUBREG)
1633     reg = SUBREG_REG (reg);
1634
1635   if (GET_CODE (reg) != REG)
1636     return;
1637   
1638   regno = REGNO (reg);
1639   if (regno < FIRST_PSEUDO_REGISTER)
1640     {
1641       int nregs = HARD_REGNO_NREGS (regno, GET_MODE (reg));
1642       while (nregs-- > 0)
1643         SET_REGNO_REG_SET (live_relevant_regs, regno++);
1644     }
1645   else if (reg_renumber[regno] >= 0)
1646     SET_REGNO_REG_SET (live_relevant_regs, regno);
1647 }
1648
1649 /* Record in live_relevant_regs that register REGNO died.  */
1650 static void
1651 reg_dies (regno, mode)
1652      int regno;
1653      enum machine_mode mode;
1654 {
1655   if (regno < FIRST_PSEUDO_REGISTER)
1656     {
1657       int nregs = HARD_REGNO_NREGS (regno, mode);
1658       while (nregs-- > 0)
1659         CLEAR_REGNO_REG_SET (live_relevant_regs, regno++);
1660     }
1661   else
1662     CLEAR_REGNO_REG_SET (live_relevant_regs, regno);
1663 }
1664
1665 /* Walk the insns of the current function and build reload_insn_chain,
1666    and record register life information.  */
1667 static void
1668 build_insn_chain (first)
1669      rtx first;
1670 {
1671   struct insn_chain **p = &reload_insn_chain;
1672   struct insn_chain *prev = 0;
1673   int b = 0;
1674
1675   live_relevant_regs = ALLOCA_REG_SET ();
1676
1677   for (; first; first = NEXT_INSN (first))
1678     {
1679       struct insn_chain *c;
1680
1681       if (first == BLOCK_HEAD (b))
1682         {
1683           int i;
1684           CLEAR_REG_SET (live_relevant_regs);
1685           for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1686             if (REGNO_REG_SET_P (BASIC_BLOCK (b)->global_live_at_start, i)
1687                 && ! TEST_HARD_REG_BIT (eliminable_regset, i))
1688               SET_REGNO_REG_SET (live_relevant_regs, i);
1689
1690           for (; i < max_regno; i++)
1691             if (reg_renumber[i] >= 0
1692                 && REGNO_REG_SET_P (BASIC_BLOCK (b)->global_live_at_start, i))
1693               SET_REGNO_REG_SET (live_relevant_regs, i);
1694         }
1695
1696       if (GET_CODE (first) != NOTE && GET_CODE (first) != BARRIER)
1697         {
1698           c = new_insn_chain ();
1699           c->prev = prev;
1700           prev = c;
1701           *p = c;
1702           p = &c->next;
1703           c->insn = first;
1704           c->block = b;
1705
1706           COPY_REG_SET (c->live_before, live_relevant_regs);
1707
1708           if (GET_RTX_CLASS (GET_CODE (first)) == 'i')
1709             {
1710               rtx link;
1711
1712               /* Mark the death of everything that dies in this instruction.  */
1713
1714               for (link = REG_NOTES (first); link; link = XEXP (link, 1))
1715                 if (REG_NOTE_KIND (link) == REG_DEAD
1716                     && GET_CODE (XEXP (link, 0)) == REG)
1717                   reg_dies (REGNO (XEXP (link, 0)), GET_MODE (XEXP (link, 0)));
1718
1719               /* Mark everything born in this instruction as live.  */
1720
1721               note_stores (PATTERN (first), reg_becomes_live);
1722             }
1723
1724           /* Remember which registers are live at the end of the insn, before
1725              killing those with REG_UNUSED notes.  */
1726           COPY_REG_SET (c->live_after, live_relevant_regs);
1727
1728           if (GET_RTX_CLASS (GET_CODE (first)) == 'i')
1729             {
1730               rtx link;
1731
1732               /* Mark anything that is set in this insn and then unused as dying.  */
1733
1734               for (link = REG_NOTES (first); link; link = XEXP (link, 1))
1735                 if (REG_NOTE_KIND (link) == REG_UNUSED
1736                     && GET_CODE (XEXP (link, 0)) == REG)
1737                   reg_dies (REGNO (XEXP (link, 0)), GET_MODE (XEXP (link, 0)));
1738             }
1739         }
1740
1741       if (first == BLOCK_END (b))
1742         b++;
1743
1744       /* Stop after we pass the end of the last basic block.  Verify that
1745          no real insns are after the end of the last basic block.
1746
1747          We may want to reorganize the loop somewhat since this test should
1748          always be the right exit test.  */
1749       if (b == n_basic_blocks)
1750         {
1751           for (first = NEXT_INSN (first) ; first; first = NEXT_INSN (first))
1752             if (GET_RTX_CLASS (GET_CODE (first)) == 'i'
1753                 && GET_CODE (PATTERN (first)) != USE)
1754               abort ();
1755           break;
1756         }
1757     }
1758   FREE_REG_SET (live_relevant_regs);
1759   *p = 0;
1760 }
1761 \f
1762 /* Print debugging trace information if -dg switch is given,
1763    showing the information on which the allocation decisions are based.  */
1764
1765 static void
1766 dump_conflicts (file)
1767      FILE *file;
1768 {
1769   register int i;
1770   register int has_preferences;
1771   register int nregs;
1772   nregs = 0;
1773   for (i = 0; i < max_allocno; i++)
1774     {
1775       if (reg_renumber[allocno_reg[allocno_order[i]]] >= 0)
1776         continue;
1777       nregs++;
1778     }
1779   fprintf (file, ";; %d regs to allocate:", nregs);
1780   for (i = 0; i < max_allocno; i++)
1781     {
1782       int j;
1783       if (reg_renumber[allocno_reg[allocno_order[i]]] >= 0)
1784         continue;
1785       fprintf (file, " %d", allocno_reg[allocno_order[i]]);
1786       for (j = 0; j < max_regno; j++)
1787         if (reg_allocno[j] == allocno_order[i]
1788             && j != allocno_reg[allocno_order[i]])
1789           fprintf (file, "+%d", j);
1790       if (allocno_size[allocno_order[i]] != 1)
1791         fprintf (file, " (%d)", allocno_size[allocno_order[i]]);
1792     }
1793   fprintf (file, "\n");
1794
1795   for (i = 0; i < max_allocno; i++)
1796     {
1797       register int j;
1798       fprintf (file, ";; %d conflicts:", allocno_reg[i]);
1799       for (j = 0; j < max_allocno; j++)
1800         if (CONFLICTP (i, j) || CONFLICTP (j, i))
1801           fprintf (file, " %d", allocno_reg[j]);
1802       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
1803         if (TEST_HARD_REG_BIT (hard_reg_conflicts[i], j))
1804           fprintf (file, " %d", j);
1805       fprintf (file, "\n");
1806
1807       has_preferences = 0;
1808       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
1809         if (TEST_HARD_REG_BIT (hard_reg_preferences[i], j))
1810           has_preferences = 1;
1811
1812       if (! has_preferences)
1813         continue;
1814       fprintf (file, ";; %d preferences:", allocno_reg[i]);
1815       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
1816         if (TEST_HARD_REG_BIT (hard_reg_preferences[i], j))
1817           fprintf (file, " %d", j);
1818       fprintf (file, "\n");
1819     }
1820   fprintf (file, "\n");
1821 }
1822
1823 void
1824 dump_global_regs (file)
1825      FILE *file;
1826 {
1827   register int i, j;
1828   
1829   fprintf (file, ";; Register dispositions:\n");
1830   for (i = FIRST_PSEUDO_REGISTER, j = 0; i < max_regno; i++)
1831     if (reg_renumber[i] >= 0)
1832       {
1833         fprintf (file, "%d in %d  ", i, reg_renumber[i]);
1834         if (++j % 6 == 0)
1835           fprintf (file, "\n");
1836       }
1837
1838   fprintf (file, "\n\n;; Hard regs used: ");
1839   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1840     if (regs_ever_live[i])
1841       fprintf (file, " %d", i);
1842   fprintf (file, "\n\n");
1843 }