OSDN Git Service

* fixed-value.h: New file.
[pf3gnuchains/gcc-fork.git] / gcc / regclass.c
1 /* Compute register class preferences for pseudo-registers.
2    Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996
3    1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22
23 /* This file contains two passes of the compiler: reg_scan and reg_class.
24    It also defines some tables of information about the hardware registers
25    and a function init_reg_sets to initialize the tables.  */
26
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include "hard-reg-set.h"
32 #include "rtl.h"
33 #include "expr.h"
34 #include "tm_p.h"
35 #include "flags.h"
36 #include "basic-block.h"
37 #include "regs.h"
38 #include "addresses.h"
39 #include "function.h"
40 #include "insn-config.h"
41 #include "recog.h"
42 #include "reload.h"
43 #include "real.h"
44 #include "toplev.h"
45 #include "output.h"
46 #include "ggc.h"
47 #include "timevar.h"
48 #include "hashtab.h"
49 #include "target.h"
50 #include "tree-pass.h"
51 #include "df.h"
52
53 /* Maximum register number used in this function, plus one.  */
54
55 int max_regno;
56
57 static void init_reg_sets_1 (void);
58 static void init_reg_autoinc (void);
59
60 /* If we have auto-increment or auto-decrement and we can have secondary
61    reloads, we are not allowed to use classes requiring secondary
62    reloads for pseudos auto-incremented since reload can't handle it.  */
63 /* We leave it to target hooks to decide if we have secondary reloads, so
64    assume that we might have them.  */
65 #if defined(AUTO_INC_DEC) /* */
66 #define FORBIDDEN_INC_DEC_CLASSES
67 #endif
68 \f
69 /* Register tables used by many passes.  */
70
71 /* Indexed by hard register number, contains 1 for registers
72    that are fixed use (stack pointer, pc, frame pointer, etc.).
73    These are the registers that cannot be used to allocate
74    a pseudo reg for general use.  */
75
76 char fixed_regs[FIRST_PSEUDO_REGISTER];
77
78 /* Same info as a HARD_REG_SET.  */
79
80 HARD_REG_SET fixed_reg_set;
81
82 /* Data for initializing the above.  */
83
84 static const char initial_fixed_regs[] = FIXED_REGISTERS;
85
86 /* Indexed by hard register number, contains 1 for registers
87    that are fixed use or are clobbered by function calls.
88    These are the registers that cannot be used to allocate
89    a pseudo reg whose life crosses calls unless we are able
90    to save/restore them across the calls.  */
91
92 char call_used_regs[FIRST_PSEUDO_REGISTER];
93
94 /* Same info as a HARD_REG_SET.  */
95
96 HARD_REG_SET call_used_reg_set;
97
98 /* HARD_REG_SET of registers we want to avoid caller saving.  */
99 HARD_REG_SET losing_caller_save_reg_set;
100
101 /* Data for initializing the above.  */
102
103 static const char initial_call_used_regs[] = CALL_USED_REGISTERS;
104
105 /* This is much like call_used_regs, except it doesn't have to
106    be a superset of FIXED_REGISTERS. This vector indicates
107    what is really call clobbered, and is used when defining
108    regs_invalidated_by_call.  */
109
110 #ifdef CALL_REALLY_USED_REGISTERS
111 char call_really_used_regs[] = CALL_REALLY_USED_REGISTERS;
112 #endif
113
114 #ifdef CALL_REALLY_USED_REGISTERS
115 #define CALL_REALLY_USED_REGNO_P(X)  call_really_used_regs[X]
116 #else
117 #define CALL_REALLY_USED_REGNO_P(X)  call_used_regs[X]
118 #endif
119
120
121 /* Indexed by hard register number, contains 1 for registers that are
122    fixed use or call used registers that cannot hold quantities across
123    calls even if we are willing to save and restore them.  call fixed
124    registers are a subset of call used registers.  */
125
126 char call_fixed_regs[FIRST_PSEUDO_REGISTER];
127
128 /* The same info as a HARD_REG_SET.  */
129
130 HARD_REG_SET call_fixed_reg_set;
131
132 /* Indexed by hard register number, contains 1 for registers
133    that are being used for global register decls.
134    These must be exempt from ordinary flow analysis
135    and are also considered fixed.  */
136
137 char global_regs[FIRST_PSEUDO_REGISTER];
138
139 /* Contains 1 for registers that are set or clobbered by calls.  */
140 /* ??? Ideally, this would be just call_used_regs plus global_regs, but
141    for someone's bright idea to have call_used_regs strictly include
142    fixed_regs.  Which leaves us guessing as to the set of fixed_regs
143    that are actually preserved.  We know for sure that those associated
144    with the local stack frame are safe, but scant others.  */
145
146 HARD_REG_SET regs_invalidated_by_call;
147
148 /* Table of register numbers in the order in which to try to use them.  */
149 #ifdef REG_ALLOC_ORDER
150 int reg_alloc_order[FIRST_PSEUDO_REGISTER] = REG_ALLOC_ORDER;
151
152 /* The inverse of reg_alloc_order.  */
153 int inv_reg_alloc_order[FIRST_PSEUDO_REGISTER];
154 #endif
155
156 /* For each reg class, a HARD_REG_SET saying which registers are in it.  */
157
158 HARD_REG_SET reg_class_contents[N_REG_CLASSES];
159
160 /* The same information, but as an array of unsigned ints.  We copy from
161    these unsigned ints to the table above.  We do this so the tm.h files
162    do not have to be aware of the wordsize for machines with <= 64 regs.
163    Note that we hard-code 32 here, not HOST_BITS_PER_INT.  */
164
165 #define N_REG_INTS  \
166   ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32)
167
168 static const unsigned int_reg_class_contents[N_REG_CLASSES][N_REG_INTS]
169   = REG_CLASS_CONTENTS;
170
171 /* For each reg class, number of regs it contains.  */
172
173 unsigned int reg_class_size[N_REG_CLASSES];
174
175 /* For each reg class, table listing all the containing classes.  */
176
177 static enum reg_class reg_class_superclasses[N_REG_CLASSES][N_REG_CLASSES];
178
179 /* For each reg class, table listing all the classes contained in it.  */
180
181 static enum reg_class reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES];
182
183 /* For each pair of reg classes,
184    a largest reg class contained in their union.  */
185
186 enum reg_class reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES];
187
188 /* For each pair of reg classes,
189    the smallest reg class containing their union.  */
190
191 enum reg_class reg_class_superunion[N_REG_CLASSES][N_REG_CLASSES];
192
193 /* Array containing all of the register names.  */
194
195 const char * reg_names[] = REGISTER_NAMES;
196
197 /* Array containing all of the register class names.  */
198
199 const char * reg_class_names[] = REG_CLASS_NAMES;
200
201 /* For each hard register, the widest mode object that it can contain.
202    This will be a MODE_INT mode if the register can hold integers.  Otherwise
203    it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
204    register.  */
205
206 enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
207
208 /* 1 if there is a register of given mode.  */
209
210 bool have_regs_of_mode [MAX_MACHINE_MODE];
211
212 /* 1 if class does contain register of given mode.  */
213
214 static char contains_reg_of_mode [N_REG_CLASSES] [MAX_MACHINE_MODE];
215
216 typedef unsigned short move_table[N_REG_CLASSES];
217
218 /* Maximum cost of moving from a register in one class to a register in
219    another class.  Based on REGISTER_MOVE_COST.  */
220
221 static move_table *move_cost[MAX_MACHINE_MODE];
222
223 /* Similar, but here we don't have to move if the first index is a subset
224    of the second so in that case the cost is zero.  */
225
226 static move_table *may_move_in_cost[MAX_MACHINE_MODE];
227
228 /* Similar, but here we don't have to move if the first index is a superset
229    of the second so in that case the cost is zero.  */
230
231 static move_table *may_move_out_cost[MAX_MACHINE_MODE];
232
233 #ifdef FORBIDDEN_INC_DEC_CLASSES
234
235 /* These are the classes that regs which are auto-incremented or decremented
236    cannot be put in.  */
237
238 static int forbidden_inc_dec_class[N_REG_CLASSES];
239
240 /* Indexed by n, is nonzero if (REG n) is used in an auto-inc or auto-dec
241    context.  */
242
243 static char *in_inc_dec;
244
245 #endif /* FORBIDDEN_INC_DEC_CLASSES */
246
247 /* Sample MEM values for use by memory_move_secondary_cost.  */
248
249 static GTY(()) rtx top_of_stack[MAX_MACHINE_MODE];
250
251 /* No more global register variables may be declared; true once
252    regclass has been initialized.  */
253
254 static int no_global_reg_vars = 0;
255
256 /* Specify number of hard registers given machine mode occupy.  */
257 unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
258
259 /* Given a register bitmap, turn on the bits in a HARD_REG_SET that
260    correspond to the hard registers, if any, set in that map.  This
261    could be done far more efficiently by having all sorts of special-cases
262    with moving single words, but probably isn't worth the trouble.  */
263
264 void
265 reg_set_to_hard_reg_set (HARD_REG_SET *to, bitmap from)
266 {
267   unsigned i;
268   bitmap_iterator bi;
269
270   EXECUTE_IF_SET_IN_BITMAP (from, 0, i, bi)
271     {
272       if (i >= FIRST_PSEUDO_REGISTER)
273         return;
274       SET_HARD_REG_BIT (*to, i);
275     }
276 }
277
278
279 /* Function called only once to initialize the above data on reg usage.
280    Once this is done, various switches may override.  */
281
282 void
283 init_reg_sets (void)
284 {
285   int i, j;
286
287   /* First copy the register information from the initial int form into
288      the regsets.  */
289
290   for (i = 0; i < N_REG_CLASSES; i++)
291     {
292       CLEAR_HARD_REG_SET (reg_class_contents[i]);
293
294       /* Note that we hard-code 32 here, not HOST_BITS_PER_INT.  */
295       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
296         if (int_reg_class_contents[i][j / 32]
297             & ((unsigned) 1 << (j % 32)))
298           SET_HARD_REG_BIT (reg_class_contents[i], j);
299     }
300
301   /* Sanity check: make sure the target macros FIXED_REGISTERS and
302      CALL_USED_REGISTERS had the right number of initializers.  */
303   gcc_assert (sizeof fixed_regs == sizeof initial_fixed_regs);
304   gcc_assert (sizeof call_used_regs == sizeof initial_call_used_regs);
305
306   memcpy (fixed_regs, initial_fixed_regs, sizeof fixed_regs);
307   memcpy (call_used_regs, initial_call_used_regs, sizeof call_used_regs);
308   memset (global_regs, 0, sizeof global_regs);
309
310 #ifdef REG_ALLOC_ORDER
311   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
312     inv_reg_alloc_order[reg_alloc_order[i]] = i;
313 #endif
314 }
315
316 /* Initialize may_move_cost and friends for mode M.  */
317
318 static void
319 init_move_cost (enum machine_mode m)
320 {
321   static unsigned short last_move_cost[N_REG_CLASSES][N_REG_CLASSES];
322   static int last_mode = -1;
323   bool all_match = true;
324   unsigned int i, j;
325
326   gcc_assert (have_regs_of_mode[m]);
327   for (i = 0; i < N_REG_CLASSES; i++)
328     if (contains_reg_of_mode[i][m])
329       for (j = 0; j < N_REG_CLASSES; j++)
330         {
331           int cost;
332           if (!contains_reg_of_mode[j][m])
333             cost = 65535;
334           else
335             {
336               cost = REGISTER_MOVE_COST (m, i, j);
337               gcc_assert (cost < 65535);
338             }
339           all_match &= (last_move_cost[i][j] == cost);
340           last_move_cost[i][j] = cost;
341         }
342   if (all_match && last_mode != -1)
343     {
344       move_cost[m] = move_cost[last_mode];
345       may_move_in_cost[m] = may_move_in_cost[last_mode];
346       may_move_out_cost[m] = may_move_out_cost[last_mode];
347       return;
348     }
349   last_mode = m;
350   move_cost[m] = (move_table *)xmalloc (sizeof (move_table)
351                                         * N_REG_CLASSES);
352   may_move_in_cost[m] = (move_table *)xmalloc (sizeof (move_table)
353                                                * N_REG_CLASSES);
354   may_move_out_cost[m] = (move_table *)xmalloc (sizeof (move_table)
355                                                 * N_REG_CLASSES);
356   for (i = 0; i < N_REG_CLASSES; i++)
357     if (contains_reg_of_mode[i][m])
358       for (j = 0; j < N_REG_CLASSES; j++)
359         {
360           int cost;
361           enum reg_class *p1, *p2;
362
363           if (last_move_cost[i][j] == 65535)
364             {
365               move_cost[m][i][j] = 65535;
366               may_move_in_cost[m][i][j] = 65535;
367               may_move_out_cost[m][i][j] = 65535;
368             }
369           else
370             {
371               cost = last_move_cost[i][j];
372
373               for (p2 = &reg_class_subclasses[j][0];
374                    *p2 != LIM_REG_CLASSES; p2++)
375                 if (*p2 != i && contains_reg_of_mode[*p2][m])
376                   cost = MAX (cost, move_cost[m][i][*p2]);
377
378               for (p1 = &reg_class_subclasses[i][0];
379                    *p1 != LIM_REG_CLASSES; p1++)
380                 if (*p1 != j && contains_reg_of_mode[*p1][m])
381                   cost = MAX (cost, move_cost[m][*p1][j]);
382
383               gcc_assert (cost <= 65535);
384               move_cost[m][i][j] = cost;
385
386               if (reg_class_subset_p (i, j))
387                 may_move_in_cost[m][i][j] = 0;
388               else
389                 may_move_in_cost[m][i][j] = cost;
390
391               if (reg_class_subset_p (j, i))
392                 may_move_out_cost[m][i][j] = 0;
393               else
394                 may_move_out_cost[m][i][j] = cost;
395             }
396         }
397     else
398       for (j = 0; j < N_REG_CLASSES; j++)
399         {
400           move_cost[m][i][j] = 65535;
401           may_move_in_cost[m][i][j] = 65535;
402           may_move_out_cost[m][i][j] = 65535;
403         }
404 }
405
406 /* After switches have been processed, which perhaps alter
407    `fixed_regs' and `call_used_regs', convert them to HARD_REG_SETs.  */
408
409 static void
410 init_reg_sets_1 (void)
411 {
412   unsigned int i, j;
413   unsigned int /* enum machine_mode */ m;
414
415   /* This macro allows the fixed or call-used registers
416      and the register classes to depend on target flags.  */
417
418 #ifdef CONDITIONAL_REGISTER_USAGE
419   CONDITIONAL_REGISTER_USAGE;
420 #endif
421
422   /* Compute number of hard regs in each class.  */
423
424   memset (reg_class_size, 0, sizeof reg_class_size);
425   for (i = 0; i < N_REG_CLASSES; i++)
426     for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
427       if (TEST_HARD_REG_BIT (reg_class_contents[i], j))
428         reg_class_size[i]++;
429
430   /* Initialize the table of subunions.
431      reg_class_subunion[I][J] gets the largest-numbered reg-class
432      that is contained in the union of classes I and J.  */
433
434   for (i = 0; i < N_REG_CLASSES; i++)
435     {
436       for (j = 0; j < N_REG_CLASSES; j++)
437         {
438           HARD_REG_SET c;
439           int k;
440
441           COPY_HARD_REG_SET (c, reg_class_contents[i]);
442           IOR_HARD_REG_SET (c, reg_class_contents[j]);
443           for (k = 0; k < N_REG_CLASSES; k++)
444             if (hard_reg_set_subset_p (reg_class_contents[k], c)
445                 && !hard_reg_set_subset_p (reg_class_contents[k],
446                                           reg_class_contents
447                                           [(int) reg_class_subunion[i][j]]))
448               reg_class_subunion[i][j] = (enum reg_class) k;
449         }
450     }
451
452   /* Initialize the table of superunions.
453      reg_class_superunion[I][J] gets the smallest-numbered reg-class
454      containing the union of classes I and J.  */
455
456   for (i = 0; i < N_REG_CLASSES; i++)
457     {
458       for (j = 0; j < N_REG_CLASSES; j++)
459         {
460           HARD_REG_SET c;
461           int k;
462
463           COPY_HARD_REG_SET (c, reg_class_contents[i]);
464           IOR_HARD_REG_SET (c, reg_class_contents[j]);
465           for (k = 0; k < N_REG_CLASSES; k++)
466             if (hard_reg_set_subset_p (c, reg_class_contents[k]))
467               break;
468
469           reg_class_superunion[i][j] = (enum reg_class) k;
470         }
471     }
472
473   /* Initialize the tables of subclasses and superclasses of each reg class.
474      First clear the whole table, then add the elements as they are found.  */
475
476   for (i = 0; i < N_REG_CLASSES; i++)
477     {
478       for (j = 0; j < N_REG_CLASSES; j++)
479         {
480           reg_class_superclasses[i][j] = LIM_REG_CLASSES;
481           reg_class_subclasses[i][j] = LIM_REG_CLASSES;
482         }
483     }
484
485   for (i = 0; i < N_REG_CLASSES; i++)
486     {
487       if (i == (int) NO_REGS)
488         continue;
489
490       for (j = i + 1; j < N_REG_CLASSES; j++)
491         if (hard_reg_set_subset_p (reg_class_contents[i],
492                                   reg_class_contents[j]))
493           {
494             /* Reg class I is a subclass of J.
495                Add J to the table of superclasses of I.  */
496             enum reg_class *p;
497
498             p = &reg_class_superclasses[i][0];
499             while (*p != LIM_REG_CLASSES) p++;
500             *p = (enum reg_class) j;
501             /* Add I to the table of superclasses of J.  */
502             p = &reg_class_subclasses[j][0];
503             while (*p != LIM_REG_CLASSES) p++;
504             *p = (enum reg_class) i;
505           }
506     }
507
508   /* Initialize "constant" tables.  */
509
510   CLEAR_HARD_REG_SET (fixed_reg_set);
511   CLEAR_HARD_REG_SET (call_used_reg_set);
512   CLEAR_HARD_REG_SET (call_fixed_reg_set);
513   CLEAR_HARD_REG_SET (regs_invalidated_by_call);
514
515   memcpy (call_fixed_regs, fixed_regs, sizeof call_fixed_regs);
516
517   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
518     {
519       /* call_used_regs must include fixed_regs.  */
520       gcc_assert (!fixed_regs[i] || call_used_regs[i]);
521 #ifdef CALL_REALLY_USED_REGISTERS
522       /* call_used_regs must include call_really_used_regs.  */
523       gcc_assert (!call_really_used_regs[i] || call_used_regs[i]);
524 #endif
525
526       if (fixed_regs[i])
527         SET_HARD_REG_BIT (fixed_reg_set, i);
528
529       if (call_used_regs[i])
530         SET_HARD_REG_BIT (call_used_reg_set, i);
531       if (call_fixed_regs[i])
532         SET_HARD_REG_BIT (call_fixed_reg_set, i);
533       if (CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (i)))
534         SET_HARD_REG_BIT (losing_caller_save_reg_set, i);
535
536       /* There are a couple of fixed registers that we know are safe to
537          exclude from being clobbered by calls:
538
539          The frame pointer is always preserved across calls.  The arg pointer
540          is if it is fixed.  The stack pointer usually is, unless
541          RETURN_POPS_ARGS, in which case an explicit CLOBBER will be present.
542          If we are generating PIC code, the PIC offset table register is
543          preserved across calls, though the target can override that.  */
544
545       if (i == STACK_POINTER_REGNUM)
546         ;
547       else if (global_regs[i])
548         SET_HARD_REG_BIT (regs_invalidated_by_call, i);
549       else if (i == FRAME_POINTER_REGNUM)
550         ;
551 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
552       else if (i == HARD_FRAME_POINTER_REGNUM)
553         ;
554 #endif
555 #if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
556       else if (i == ARG_POINTER_REGNUM && fixed_regs[i])
557         ;
558 #endif
559 #ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
560       else if (i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i])
561         ;
562 #endif
563       else if (CALL_REALLY_USED_REGNO_P (i))
564         SET_HARD_REG_BIT (regs_invalidated_by_call, i);
565     }
566
567   memset (have_regs_of_mode, 0, sizeof (have_regs_of_mode));
568   memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode));
569   for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++)
570     {
571       HARD_REG_SET ok_regs;
572       CLEAR_HARD_REG_SET (ok_regs);
573       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
574         if (!fixed_regs [j] && HARD_REGNO_MODE_OK (j, m))
575           SET_HARD_REG_BIT (ok_regs, j);
576       
577       for (i = 0; i < N_REG_CLASSES; i++)
578         if ((unsigned) CLASS_MAX_NREGS (i, m) <= reg_class_size[i]
579             && hard_reg_set_intersect_p (ok_regs, reg_class_contents[i]))
580           {
581              contains_reg_of_mode [i][m] = 1;
582              have_regs_of_mode [m] = 1;
583           }
584      }
585 }
586
587 /* Compute the table of register modes.
588    These values are used to record death information for individual registers
589    (as opposed to a multi-register mode).  */
590
591 void
592 init_reg_modes_once (void)
593 {
594   int i, j;
595
596   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
597     for (j = 0; j < MAX_MACHINE_MODE; j++)
598       hard_regno_nregs[i][j] = HARD_REGNO_NREGS(i, (enum machine_mode)j);
599
600   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
601     {
602       reg_raw_mode[i] = choose_hard_reg_mode (i, 1, false);
603
604       /* If we couldn't find a valid mode, just use the previous mode.
605          ??? One situation in which we need to do this is on the mips where
606          HARD_REGNO_NREGS (fpreg, [SD]Fmode) returns 2.  Ideally we'd like
607          to use DF mode for the even registers and VOIDmode for the odd
608          (for the cpu models where the odd ones are inaccessible).  */
609       if (reg_raw_mode[i] == VOIDmode)
610         reg_raw_mode[i] = i == 0 ? word_mode : reg_raw_mode[i-1];
611     }
612 }
613
614 /* Finish initializing the register sets and
615    initialize the register modes.  */
616
617 void
618 init_regs (void)
619 {
620   /* This finishes what was started by init_reg_sets, but couldn't be done
621      until after register usage was specified.  */
622   init_reg_sets_1 ();
623
624   init_reg_autoinc ();
625 }
626
627 /* Initialize some fake stack-frame MEM references for use in
628    memory_move_secondary_cost.  */
629
630 void
631 init_fake_stack_mems (void)
632 {
633   {
634     int i;
635
636     for (i = 0; i < MAX_MACHINE_MODE; i++)
637       top_of_stack[i] = gen_rtx_MEM (i, stack_pointer_rtx);
638   }
639 }
640
641
642 /* Compute extra cost of moving registers to/from memory due to reloads.
643    Only needed if secondary reloads are required for memory moves.  */
644
645 int
646 memory_move_secondary_cost (enum machine_mode mode, enum reg_class class, int in)
647 {
648   enum reg_class altclass;
649   int partial_cost = 0;
650   /* We need a memory reference to feed to SECONDARY... macros.  */
651   /* mem may be unused even if the SECONDARY_ macros are defined.  */
652   rtx mem ATTRIBUTE_UNUSED = top_of_stack[(int) mode];
653
654
655   altclass = secondary_reload_class (in ? 1 : 0, class, mode, mem);
656
657   if (altclass == NO_REGS)
658     return 0;
659
660   if (in)
661     partial_cost = REGISTER_MOVE_COST (mode, altclass, class);
662   else
663     partial_cost = REGISTER_MOVE_COST (mode, class, altclass);
664
665   if (class == altclass)
666     /* This isn't simply a copy-to-temporary situation.  Can't guess
667        what it is, so MEMORY_MOVE_COST really ought not to be calling
668        here in that case.
669
670        I'm tempted to put in an assert here, but returning this will
671        probably only give poor estimates, which is what we would've
672        had before this code anyways.  */
673     return partial_cost;
674
675   /* Check if the secondary reload register will also need a
676      secondary reload.  */
677   return memory_move_secondary_cost (mode, altclass, in) + partial_cost;
678 }
679
680 /* Return a machine mode that is legitimate for hard reg REGNO and large
681    enough to save nregs.  If we can't find one, return VOIDmode.
682    If CALL_SAVED is true, only consider modes that are call saved.  */
683
684 enum machine_mode
685 choose_hard_reg_mode (unsigned int regno ATTRIBUTE_UNUSED,
686                       unsigned int nregs, bool call_saved)
687 {
688   unsigned int /* enum machine_mode */ m;
689   enum machine_mode found_mode = VOIDmode, mode;
690
691   /* We first look for the largest integer mode that can be validly
692      held in REGNO.  If none, we look for the largest floating-point mode.
693      If we still didn't find a valid mode, try CCmode.  */
694
695   for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
696        mode != VOIDmode;
697        mode = GET_MODE_WIDER_MODE (mode))
698     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
699         && HARD_REGNO_MODE_OK (regno, mode)
700         && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
701       found_mode = mode;
702
703   if (found_mode != VOIDmode)
704     return found_mode;
705
706   for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
707        mode != VOIDmode;
708        mode = GET_MODE_WIDER_MODE (mode))
709     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
710         && HARD_REGNO_MODE_OK (regno, mode)
711         && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
712       found_mode = mode;
713
714   if (found_mode != VOIDmode)
715     return found_mode;
716
717   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
718        mode != VOIDmode;
719        mode = GET_MODE_WIDER_MODE (mode))
720     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
721         && HARD_REGNO_MODE_OK (regno, mode)
722         && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
723       found_mode = mode;
724
725   if (found_mode != VOIDmode)
726     return found_mode;
727
728   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
729        mode != VOIDmode;
730        mode = GET_MODE_WIDER_MODE (mode))
731     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
732         && HARD_REGNO_MODE_OK (regno, mode)
733         && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
734       found_mode = mode;
735
736   if (found_mode != VOIDmode)
737     return found_mode;
738
739   /* Iterate over all of the CCmodes.  */
740   for (m = (unsigned int) CCmode; m < (unsigned int) NUM_MACHINE_MODES; ++m)
741     {
742       mode = (enum machine_mode) m;
743       if ((unsigned) hard_regno_nregs[regno][mode] == nregs
744           && HARD_REGNO_MODE_OK (regno, mode)
745           && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
746         return mode;
747     }
748
749   /* We can't find a mode valid for this register.  */
750   return VOIDmode;
751 }
752
753 /* Specify the usage characteristics of the register named NAME.
754    It should be a fixed register if FIXED and a
755    call-used register if CALL_USED.  */
756
757 void
758 fix_register (const char *name, int fixed, int call_used)
759 {
760   int i;
761
762   /* Decode the name and update the primary form of
763      the register info.  */
764
765   if ((i = decode_reg_name (name)) >= 0)
766     {
767       if ((i == STACK_POINTER_REGNUM
768 #ifdef HARD_FRAME_POINTER_REGNUM
769            || i == HARD_FRAME_POINTER_REGNUM
770 #else
771            || i == FRAME_POINTER_REGNUM
772 #endif
773            )
774           && (fixed == 0 || call_used == 0))
775         {
776           static const char * const what_option[2][2] = {
777             { "call-saved", "call-used" },
778             { "no-such-option", "fixed" }};
779
780           error ("can't use '%s' as a %s register", name,
781                  what_option[fixed][call_used]);
782         }
783       else
784         {
785           fixed_regs[i] = fixed;
786           call_used_regs[i] = call_used;
787 #ifdef CALL_REALLY_USED_REGISTERS
788           if (fixed == 0)
789             call_really_used_regs[i] = call_used;
790 #endif
791         }
792     }
793   else
794     {
795       warning (0, "unknown register name: %s", name);
796     }
797 }
798
799 /* Mark register number I as global.  */
800
801 void
802 globalize_reg (int i)
803 {
804   if (fixed_regs[i] == 0 && no_global_reg_vars)
805     error ("global register variable follows a function definition");
806
807   if (global_regs[i])
808     {
809       warning (0, "register used for two global register variables");
810       return;
811     }
812
813   if (call_used_regs[i] && ! fixed_regs[i])
814     warning (0, "call-clobbered register used for global register variable");
815
816   global_regs[i] = 1;
817
818   /* If we're globalizing the frame pointer, we need to set the
819      appropriate regs_invalidated_by_call bit, even if it's already
820      set in fixed_regs.  */
821   if (i != STACK_POINTER_REGNUM)
822     SET_HARD_REG_BIT (regs_invalidated_by_call, i);
823
824   /* If already fixed, nothing else to do.  */
825   if (fixed_regs[i])
826     return;
827
828   fixed_regs[i] = call_used_regs[i] = call_fixed_regs[i] = 1;
829 #ifdef CALL_REALLY_USED_REGISTERS
830   call_really_used_regs[i] = 1;
831 #endif
832
833   SET_HARD_REG_BIT (fixed_reg_set, i);
834   SET_HARD_REG_BIT (call_used_reg_set, i);
835   SET_HARD_REG_BIT (call_fixed_reg_set, i);
836 }
837 \f
838 /* Now the data and code for the `regclass' pass, which happens
839    just before local-alloc.  */
840
841 /* The `costs' struct records the cost of using a hard register of each class
842    and of using memory for each pseudo.  We use this data to set up
843    register class preferences.  */
844
845 struct costs
846 {
847   int cost[N_REG_CLASSES];
848   int mem_cost;
849 };
850
851 /* Structure used to record preferences of given pseudo.  */
852 struct reg_pref
853 {
854   /* (enum reg_class) prefclass is the preferred class.  May be
855      NO_REGS if no class is better than memory.  */
856   char prefclass;
857
858   /* altclass is a register class that we should use for allocating
859      pseudo if no register in the preferred class is available.
860      If no register in this class is available, memory is preferred.
861
862      It might appear to be more general to have a bitmask of classes here,
863      but since it is recommended that there be a class corresponding to the
864      union of most major pair of classes, that generality is not required.  */
865   char altclass;
866 };
867
868 /* Record the cost of each class for each pseudo.  */
869
870 static struct costs *costs;
871
872 /* Initialized once, and used to initialize cost values for each insn.  */
873
874 static struct costs init_cost;
875
876 /* Record preferences of each pseudo.
877    This is available after `regclass' is run.  */
878
879 static struct reg_pref *reg_pref;
880
881 /* Frequency of executions of current insn.  */
882
883 static int frequency;
884
885 static rtx scan_one_insn (rtx, int);
886 static void record_operand_costs (rtx, struct costs *, struct reg_pref *);
887 static void dump_regclass (FILE *);
888 static void record_reg_classes (int, int, rtx *, enum machine_mode *,
889                                 const char **, rtx, struct costs *,
890                                 struct reg_pref *);
891 static int copy_cost (rtx, enum machine_mode, enum reg_class, int,
892                       secondary_reload_info *);
893 static void record_address_regs (enum machine_mode, rtx, int, enum rtx_code,
894                                  enum rtx_code, int);
895 #ifdef FORBIDDEN_INC_DEC_CLASSES
896 static int auto_inc_dec_reg_p (rtx, enum machine_mode);
897 #endif
898 static void reg_scan_mark_refs (rtx, rtx);
899
900 /* Wrapper around REGNO_OK_FOR_INDEX_P, to allow pseudo registers.  */
901
902 static inline bool
903 ok_for_index_p_nonstrict (rtx reg)
904 {
905   unsigned regno = REGNO (reg);
906   return regno >= FIRST_PSEUDO_REGISTER || REGNO_OK_FOR_INDEX_P (regno);
907 }
908
909 /* A version of regno_ok_for_base_p for use during regclass, when all pseudos
910    should count as OK.  Arguments as for regno_ok_for_base_p.  */
911
912 static inline bool
913 ok_for_base_p_nonstrict (rtx reg, enum machine_mode mode,
914                          enum rtx_code outer_code, enum rtx_code index_code)
915 {
916   unsigned regno = REGNO (reg);
917   if (regno >= FIRST_PSEUDO_REGISTER)
918     return true;
919
920   return ok_for_base_p_1 (regno, mode, outer_code, index_code);
921 }
922
923 /* Return the reg_class in which pseudo reg number REGNO is best allocated.
924    This function is sometimes called before the info has been computed.
925    When that happens, just return GENERAL_REGS, which is innocuous.  */
926
927 enum reg_class
928 reg_preferred_class (int regno)
929 {
930   if (reg_pref == 0)
931     return GENERAL_REGS;
932   return (enum reg_class) reg_pref[regno].prefclass;
933 }
934
935 enum reg_class
936 reg_alternate_class (int regno)
937 {
938   if (reg_pref == 0)
939     return ALL_REGS;
940
941   return (enum reg_class) reg_pref[regno].altclass;
942 }
943
944 /* Initialize some global data for this pass.  */
945
946 static unsigned int 
947 regclass_init (void)
948 {
949   int i;
950
951   if (df)
952     df_compute_regs_ever_live (true);
953
954   init_cost.mem_cost = 10000;
955   for (i = 0; i < N_REG_CLASSES; i++)
956     init_cost.cost[i] = 10000;
957
958   /* This prevents dump_flow_info from losing if called
959      before regclass is run.  */
960   reg_pref = NULL;
961
962   /* No more global register variables may be declared.  */
963   no_global_reg_vars = 1;
964   return 1;
965 }
966
967 struct tree_opt_pass pass_regclass_init =
968 {
969   "regclass",                           /* name */
970   NULL,                                 /* gate */
971   regclass_init,                        /* execute */
972   NULL,                                 /* sub */
973   NULL,                                 /* next */
974   0,                                    /* static_pass_number */
975   0,                                    /* tv_id */
976   0,                                    /* properties_required */
977   0,                                    /* properties_provided */
978   0,                                    /* properties_destroyed */
979   0,                                    /* todo_flags_start */
980   0,                                    /* todo_flags_finish */
981   'k'                                   /* letter */
982 };
983
984
985 \f
986 /* Dump register costs.  */
987 static void
988 dump_regclass (FILE *dump)
989 {
990   int i;
991   for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
992     {
993       int /* enum reg_class */ class;
994       if (REG_N_REFS (i))
995         {
996           fprintf (dump, "  Register %i costs:", i);
997           for (class = 0; class < (int) N_REG_CLASSES; class++)
998             if (contains_reg_of_mode [(enum reg_class) class][PSEUDO_REGNO_MODE (i)]
999 #ifdef FORBIDDEN_INC_DEC_CLASSES
1000                 && (!in_inc_dec[i]
1001                     || !forbidden_inc_dec_class[(enum reg_class) class])
1002 #endif
1003 #ifdef CANNOT_CHANGE_MODE_CLASS
1004                 && ! invalid_mode_change_p (i, (enum reg_class) class,
1005                                             PSEUDO_REGNO_MODE (i))
1006 #endif
1007                 )
1008             fprintf (dump, " %s:%i", reg_class_names[class],
1009                      costs[i].cost[(enum reg_class) class]);
1010           fprintf (dump, " MEM:%i\n", costs[i].mem_cost);
1011         }
1012     }
1013 }
1014 \f
1015
1016 /* Calculate the costs of insn operands.  */
1017
1018 static void
1019 record_operand_costs (rtx insn, struct costs *op_costs,
1020                       struct reg_pref *reg_pref)
1021 {
1022   const char *constraints[MAX_RECOG_OPERANDS];
1023   enum machine_mode modes[MAX_RECOG_OPERANDS];
1024   int i;
1025
1026   for (i = 0; i < recog_data.n_operands; i++)
1027     {
1028       constraints[i] = recog_data.constraints[i];
1029       modes[i] = recog_data.operand_mode[i];
1030     }
1031
1032   /* If we get here, we are set up to record the costs of all the
1033      operands for this insn.  Start by initializing the costs.
1034      Then handle any address registers.  Finally record the desired
1035      classes for any pseudos, doing it twice if some pair of
1036      operands are commutative.  */
1037
1038   for (i = 0; i < recog_data.n_operands; i++)
1039     {
1040       op_costs[i] = init_cost;
1041
1042       if (GET_CODE (recog_data.operand[i]) == SUBREG)
1043         recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
1044
1045       if (MEM_P (recog_data.operand[i]))
1046         record_address_regs (GET_MODE (recog_data.operand[i]),
1047                              XEXP (recog_data.operand[i], 0),
1048                              0, MEM, SCRATCH, frequency * 2);
1049       else if (constraints[i][0] == 'p'
1050                || EXTRA_ADDRESS_CONSTRAINT (constraints[i][0], constraints[i]))
1051         record_address_regs (VOIDmode, recog_data.operand[i], 0, ADDRESS,
1052                              SCRATCH, frequency * 2);
1053     }
1054
1055   /* Check for commutative in a separate loop so everything will
1056      have been initialized.  We must do this even if one operand
1057      is a constant--see addsi3 in m68k.md.  */
1058
1059   for (i = 0; i < (int) recog_data.n_operands - 1; i++)
1060     if (constraints[i][0] == '%')
1061       {
1062         const char *xconstraints[MAX_RECOG_OPERANDS];
1063         int j;
1064
1065         /* Handle commutative operands by swapping the constraints.
1066            We assume the modes are the same.  */
1067
1068         for (j = 0; j < recog_data.n_operands; j++)
1069           xconstraints[j] = constraints[j];
1070
1071         xconstraints[i] = constraints[i+1];
1072         xconstraints[i+1] = constraints[i];
1073         record_reg_classes (recog_data.n_alternatives, recog_data.n_operands,
1074                             recog_data.operand, modes,
1075                             xconstraints, insn, op_costs, reg_pref);
1076       }
1077
1078   record_reg_classes (recog_data.n_alternatives, recog_data.n_operands,
1079                       recog_data.operand, modes,
1080                       constraints, insn, op_costs, reg_pref);
1081 }
1082 \f
1083 /* Subroutine of regclass, processes one insn INSN.  Scan it and record each
1084    time it would save code to put a certain register in a certain class.
1085    PASS, when nonzero, inhibits some optimizations which need only be done
1086    once.
1087    Return the last insn processed, so that the scan can be continued from
1088    there.  */
1089
1090 static rtx
1091 scan_one_insn (rtx insn, int pass ATTRIBUTE_UNUSED)
1092 {
1093   enum rtx_code pat_code;
1094   rtx set, note;
1095   int i, j;
1096   struct costs op_costs[MAX_RECOG_OPERANDS];
1097
1098   if (!INSN_P (insn))
1099     return insn;
1100
1101   pat_code = GET_CODE (PATTERN (insn));
1102   if (pat_code == USE
1103       || pat_code == CLOBBER
1104       || pat_code == ASM_INPUT
1105       || pat_code == ADDR_VEC
1106       || pat_code == ADDR_DIFF_VEC)
1107     return insn;
1108
1109   set = single_set (insn);
1110   extract_insn (insn);
1111
1112   /* If this insn loads a parameter from its stack slot, then
1113      it represents a savings, rather than a cost, if the
1114      parameter is stored in memory.  Record this fact.  */
1115
1116   if (set != 0 && REG_P (SET_DEST (set))
1117       && MEM_P (SET_SRC (set))
1118       && (note = find_reg_note (insn, REG_EQUIV,
1119                                 NULL_RTX)) != 0
1120       && MEM_P (XEXP (note, 0)))
1121     {
1122       costs[REGNO (SET_DEST (set))].mem_cost
1123         -= (MEMORY_MOVE_COST (GET_MODE (SET_DEST (set)),
1124                               GENERAL_REGS, 1)
1125             * frequency);
1126       record_address_regs (GET_MODE (SET_SRC (set)), XEXP (SET_SRC (set), 0),
1127                            0, MEM, SCRATCH, frequency * 2);
1128       return insn;
1129     }
1130
1131   record_operand_costs (insn, op_costs, reg_pref);
1132
1133   /* Now add the cost for each operand to the total costs for
1134      its register.  */
1135
1136   for (i = 0; i < recog_data.n_operands; i++)
1137     if (REG_P (recog_data.operand[i])
1138         && REGNO (recog_data.operand[i]) >= FIRST_PSEUDO_REGISTER)
1139       {
1140         int regno = REGNO (recog_data.operand[i]);
1141         struct costs *p = &costs[regno], *q = &op_costs[i];
1142
1143         p->mem_cost += q->mem_cost * frequency;
1144         for (j = 0; j < N_REG_CLASSES; j++)
1145           p->cost[j] += q->cost[j] * frequency;
1146       }
1147
1148   return insn;
1149 }
1150
1151 /* Initialize information about which register classes can be used for
1152    pseudos that are auto-incremented or auto-decremented.  */
1153
1154 static void
1155 init_reg_autoinc (void)
1156 {
1157 #ifdef FORBIDDEN_INC_DEC_CLASSES
1158   int i;
1159
1160   for (i = 0; i < N_REG_CLASSES; i++)
1161     {
1162       rtx r = gen_rtx_raw_REG (VOIDmode, 0);
1163       enum machine_mode m;
1164       int j;
1165
1166       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
1167         if (TEST_HARD_REG_BIT (reg_class_contents[i], j))
1168           {
1169             SET_REGNO (r, j);
1170
1171             for (m = VOIDmode; (int) m < (int) MAX_MACHINE_MODE;
1172                  m = (enum machine_mode) ((int) m + 1))
1173               if (HARD_REGNO_MODE_OK (j, m))
1174                 {
1175                   /* ??? There are two assumptions here; that the base class does not
1176                      depend on the exact outer code (POST_INC vs. PRE_INC etc.), and
1177                      that it does not depend on the machine mode of the memory
1178                      reference.  */
1179                   enum reg_class base_class
1180                     = base_reg_class (VOIDmode, POST_INC, SCRATCH);
1181
1182                   PUT_MODE (r, m);
1183
1184                   /* If a register is not directly suitable for an
1185                      auto-increment or decrement addressing mode and
1186                      requires secondary reloads, disallow its class from
1187                      being used in such addresses.  */
1188
1189                   if ((secondary_reload_class (1, base_class, m, r)
1190                        || secondary_reload_class (1, base_class, m, r))
1191                       && ! auto_inc_dec_reg_p (r, m))
1192                     forbidden_inc_dec_class[i] = 1;
1193                 }
1194           }
1195     }
1196 #endif /* FORBIDDEN_INC_DEC_CLASSES */
1197 }
1198
1199 /* This is a pass of the compiler that scans all instructions
1200    and calculates the preferred class for each pseudo-register.
1201    This information can be accessed later by calling `reg_preferred_class'.
1202    This pass comes just before local register allocation.  */
1203
1204 void
1205 regclass (rtx f, int nregs)
1206 {
1207   rtx insn;
1208   int i;
1209   int pass;
1210   max_regno = max_reg_num ();
1211
1212   init_recog ();
1213
1214   reg_renumber = xmalloc (max_regno * sizeof (short));
1215   reg_pref = XCNEWVEC (struct reg_pref, max_regno);
1216   memset (reg_renumber, -1, max_regno * sizeof (short));
1217
1218   costs = XNEWVEC (struct costs, nregs);
1219
1220 #ifdef FORBIDDEN_INC_DEC_CLASSES
1221
1222   in_inc_dec = XNEWVEC (char, nregs);
1223
1224 #endif /* FORBIDDEN_INC_DEC_CLASSES */
1225
1226   /* Normally we scan the insns once and determine the best class to use for
1227      each register.  However, if -fexpensive_optimizations are on, we do so
1228      twice, the second time using the tentative best classes to guide the
1229      selection.  */
1230
1231   for (pass = 0; pass <= flag_expensive_optimizations; pass++)
1232     {
1233       basic_block bb;
1234
1235       if (dump_file)
1236         fprintf (dump_file, "\n\nPass %i\n\n",pass);
1237       /* Zero out our accumulation of the cost of each class for each reg.  */
1238
1239       memset (costs, 0, nregs * sizeof (struct costs));
1240
1241 #ifdef FORBIDDEN_INC_DEC_CLASSES
1242       memset (in_inc_dec, 0, nregs);
1243 #endif
1244
1245       /* Scan the instructions and record each time it would
1246          save code to put a certain register in a certain class.  */
1247
1248       if (!optimize)
1249         {
1250           frequency = REG_FREQ_MAX;
1251           for (insn = f; insn; insn = NEXT_INSN (insn))
1252             insn = scan_one_insn (insn, pass);
1253         }
1254       else
1255         FOR_EACH_BB (bb)
1256           {
1257             /* Show that an insn inside a loop is likely to be executed three
1258                times more than insns outside a loop.  This is much more
1259                aggressive than the assumptions made elsewhere and is being
1260                tried as an experiment.  */
1261             frequency = REG_FREQ_FROM_BB (bb);
1262             for (insn = BB_HEAD (bb); ; insn = NEXT_INSN (insn))
1263               {
1264                 insn = scan_one_insn (insn, pass);
1265                 if (insn == BB_END (bb))
1266                   break;
1267               }
1268           }
1269
1270       /* Now for each register look at how desirable each class is
1271          and find which class is preferred.  Store that in
1272          `prefclass'.  Record in `altclass' the largest register
1273          class any of whose registers is better than memory.  */
1274
1275       if (dump_file)
1276         {
1277           dump_regclass (dump_file);
1278           fprintf (dump_file,"\n");
1279         }
1280       for (i = FIRST_PSEUDO_REGISTER; i < nregs; i++)
1281         {
1282           int best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
1283           enum reg_class best = ALL_REGS, alt = NO_REGS;
1284           /* This is an enum reg_class, but we call it an int
1285              to save lots of casts.  */
1286           int class;
1287           struct costs *p = &costs[i];
1288
1289           if (regno_reg_rtx[i] == NULL)
1290             continue;
1291
1292           /* In non-optimizing compilation REG_N_REFS is not initialized
1293              yet.  */
1294           if (optimize && !REG_N_REFS (i) && !REG_N_SETS (i))
1295             continue;
1296
1297           for (class = (int) ALL_REGS - 1; class > 0; class--)
1298             {
1299               /* Ignore classes that are too small for this operand or
1300                  invalid for an operand that was auto-incremented.  */
1301               if (!contains_reg_of_mode [class][PSEUDO_REGNO_MODE (i)]
1302 #ifdef FORBIDDEN_INC_DEC_CLASSES
1303                   || (in_inc_dec[i] && forbidden_inc_dec_class[class])
1304 #endif
1305 #ifdef CANNOT_CHANGE_MODE_CLASS
1306                   || invalid_mode_change_p (i, (enum reg_class) class,
1307                                             PSEUDO_REGNO_MODE (i))
1308 #endif
1309                   )
1310                 ;
1311               else if (p->cost[class] < best_cost)
1312                 {
1313                   best_cost = p->cost[class];
1314                   best = (enum reg_class) class;
1315                 }
1316               else if (p->cost[class] == best_cost)
1317                 best = reg_class_subunion[(int) best][class];
1318             }
1319
1320           /* If no register class is better than memory, use memory. */
1321           if (p->mem_cost < best_cost)
1322             best = NO_REGS;
1323
1324           /* Record the alternate register class; i.e., a class for which
1325              every register in it is better than using memory.  If adding a
1326              class would make a smaller class (i.e., no union of just those
1327              classes exists), skip that class.  The major unions of classes
1328              should be provided as a register class.  Don't do this if we
1329              will be doing it again later.  */
1330
1331           if ((pass == 1  || dump_file) || ! flag_expensive_optimizations)
1332             for (class = 0; class < N_REG_CLASSES; class++)
1333               if (p->cost[class] < p->mem_cost
1334                   && (reg_class_size[(int) reg_class_subunion[(int) alt][class]]
1335                       > reg_class_size[(int) alt])
1336 #ifdef FORBIDDEN_INC_DEC_CLASSES
1337                   && ! (in_inc_dec[i] && forbidden_inc_dec_class[class])
1338 #endif
1339 #ifdef CANNOT_CHANGE_MODE_CLASS
1340                   && ! invalid_mode_change_p (i, (enum reg_class) class,
1341                                               PSEUDO_REGNO_MODE (i))
1342 #endif
1343                   )
1344                 alt = reg_class_subunion[(int) alt][class];
1345
1346           /* If we don't add any classes, nothing to try.  */
1347           if (alt == best)
1348             alt = NO_REGS;
1349
1350           if (dump_file
1351               && (reg_pref[i].prefclass != (int) best
1352                   || reg_pref[i].altclass != (int) alt))
1353             {
1354               fprintf (dump_file, "  Register %i", i);
1355               if (alt == ALL_REGS || best == ALL_REGS)
1356                 fprintf (dump_file, " pref %s\n", reg_class_names[(int) best]);
1357               else if (alt == NO_REGS)
1358                 fprintf (dump_file, " pref %s or none\n", reg_class_names[(int) best]);
1359               else
1360                 fprintf (dump_file, " pref %s, else %s\n",
1361                          reg_class_names[(int) best],
1362                          reg_class_names[(int) alt]);
1363             }
1364
1365           /* We cast to (int) because (char) hits bugs in some compilers.  */
1366           reg_pref[i].prefclass = (int) best;
1367           reg_pref[i].altclass = (int) alt;
1368         }
1369     }
1370
1371 #ifdef FORBIDDEN_INC_DEC_CLASSES
1372   free (in_inc_dec);
1373 #endif
1374   free (costs);
1375 }
1376 \f
1377 /* Record the cost of using memory or registers of various classes for
1378    the operands in INSN.
1379
1380    N_ALTS is the number of alternatives.
1381
1382    N_OPS is the number of operands.
1383
1384    OPS is an array of the operands.
1385
1386    MODES are the modes of the operands, in case any are VOIDmode.
1387
1388    CONSTRAINTS are the constraints to use for the operands.  This array
1389    is modified by this procedure.
1390
1391    This procedure works alternative by alternative.  For each alternative
1392    we assume that we will be able to allocate all pseudos to their ideal
1393    register class and calculate the cost of using that alternative.  Then
1394    we compute for each operand that is a pseudo-register, the cost of
1395    having the pseudo allocated to each register class and using it in that
1396    alternative.  To this cost is added the cost of the alternative.
1397
1398    The cost of each class for this insn is its lowest cost among all the
1399    alternatives.  */
1400
1401 static void
1402 record_reg_classes (int n_alts, int n_ops, rtx *ops,
1403                     enum machine_mode *modes, const char **constraints,
1404                     rtx insn, struct costs *op_costs,
1405                     struct reg_pref *reg_pref)
1406 {
1407   int alt;
1408   int i, j;
1409   rtx set;
1410
1411   /* Process each alternative, each time minimizing an operand's cost with
1412      the cost for each operand in that alternative.  */
1413
1414   for (alt = 0; alt < n_alts; alt++)
1415     {
1416       struct costs this_op_costs[MAX_RECOG_OPERANDS];
1417       int alt_fail = 0;
1418       int alt_cost = 0;
1419       enum reg_class classes[MAX_RECOG_OPERANDS];
1420       int allows_mem[MAX_RECOG_OPERANDS];
1421       int class;
1422
1423       for (i = 0; i < n_ops; i++)
1424         {
1425           const char *p = constraints[i];
1426           rtx op = ops[i];
1427           enum machine_mode mode = modes[i];
1428           int allows_addr = 0;
1429           int win = 0;
1430           unsigned char c;
1431
1432           /* Initially show we know nothing about the register class.  */
1433           classes[i] = NO_REGS;
1434           allows_mem[i] = 0;
1435
1436           /* If this operand has no constraints at all, we can conclude
1437              nothing about it since anything is valid.  */
1438
1439           if (*p == 0)
1440             {
1441               if (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER)
1442                 memset (&this_op_costs[i], 0, sizeof this_op_costs[i]);
1443
1444               continue;
1445             }
1446
1447           /* If this alternative is only relevant when this operand
1448              matches a previous operand, we do different things depending
1449              on whether this operand is a pseudo-reg or not.  We must process
1450              any modifiers for the operand before we can make this test.  */
1451
1452           while (*p == '%' || *p == '=' || *p == '+' || *p == '&')
1453             p++;
1454
1455           if (p[0] >= '0' && p[0] <= '0' + i && (p[1] == ',' || p[1] == 0))
1456             {
1457               /* Copy class and whether memory is allowed from the matching
1458                  alternative.  Then perform any needed cost computations
1459                  and/or adjustments.  */
1460               j = p[0] - '0';
1461               classes[i] = classes[j];
1462               allows_mem[i] = allows_mem[j];
1463
1464               if (!REG_P (op) || REGNO (op) < FIRST_PSEUDO_REGISTER)
1465                 {
1466                   /* If this matches the other operand, we have no added
1467                      cost and we win.  */
1468                   if (rtx_equal_p (ops[j], op))
1469                     win = 1;
1470
1471                   /* If we can put the other operand into a register, add to
1472                      the cost of this alternative the cost to copy this
1473                      operand to the register used for the other operand.  */
1474
1475                   else if (classes[j] != NO_REGS)
1476                     {
1477                       alt_cost += copy_cost (op, mode, classes[j], 1, NULL);
1478                       win = 1;
1479                     }
1480                 }
1481               else if (!REG_P (ops[j])
1482                        || REGNO (ops[j]) < FIRST_PSEUDO_REGISTER)
1483                 {
1484                   /* This op is a pseudo but the one it matches is not.  */
1485
1486                   /* If we can't put the other operand into a register, this
1487                      alternative can't be used.  */
1488
1489                   if (classes[j] == NO_REGS)
1490                     alt_fail = 1;
1491
1492                   /* Otherwise, add to the cost of this alternative the cost
1493                      to copy the other operand to the register used for this
1494                      operand.  */
1495
1496                   else
1497                     alt_cost += copy_cost (ops[j], mode, classes[j], 1, NULL);
1498                 }
1499               else
1500                 {
1501                   /* The costs of this operand are not the same as the other
1502                      operand since move costs are not symmetric.  Moreover,
1503                      if we cannot tie them, this alternative needs to do a
1504                      copy, which is one instruction.  */
1505
1506                   struct costs *pp = &this_op_costs[i];
1507                   move_table *intable = NULL;
1508                   move_table *outtable = NULL;
1509                   int op_class = (int) classes[i];
1510
1511                   if (!move_cost[mode])
1512                     init_move_cost (mode);
1513                   intable = may_move_in_cost[mode];
1514                   outtable = may_move_out_cost[mode];
1515
1516                   /* The loop is performance critical, so unswitch it manually.
1517                    */
1518                   switch (recog_data.operand_type[i])
1519                     {
1520                     case OP_INOUT:
1521                       for (class = 0; class < N_REG_CLASSES; class++)
1522                         pp->cost[class] = (intable[class][op_class]
1523                                            + outtable[op_class][class]);
1524                       break;
1525                     case OP_IN:
1526                       for (class = 0; class < N_REG_CLASSES; class++)
1527                         pp->cost[class] = intable[class][op_class];
1528                       break;
1529                     case OP_OUT:
1530                       for (class = 0; class < N_REG_CLASSES; class++)
1531                         pp->cost[class] = outtable[op_class][class];
1532                       break;
1533                     }
1534
1535                   /* If the alternative actually allows memory, make things
1536                      a bit cheaper since we won't need an extra insn to
1537                      load it.  */
1538
1539                   pp->mem_cost
1540                     = ((recog_data.operand_type[i] != OP_IN
1541                         ? MEMORY_MOVE_COST (mode, classes[i], 0)
1542                         : 0)
1543                        + (recog_data.operand_type[i] != OP_OUT
1544                           ? MEMORY_MOVE_COST (mode, classes[i], 1)
1545                           : 0) - allows_mem[i]);
1546
1547                   /* If we have assigned a class to this register in our
1548                      first pass, add a cost to this alternative corresponding
1549                      to what we would add if this register were not in the
1550                      appropriate class.  */
1551
1552                   if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
1553                     alt_cost
1554                       += (may_move_in_cost[mode]
1555                           [(unsigned char) reg_pref[REGNO (op)].prefclass]
1556                           [(int) classes[i]]);
1557
1558                   if (REGNO (ops[i]) != REGNO (ops[j])
1559                       && ! find_reg_note (insn, REG_DEAD, op))
1560                     alt_cost += 2;
1561
1562                   /* This is in place of ordinary cost computation
1563                      for this operand, so skip to the end of the
1564                      alternative (should be just one character).  */
1565                   while (*p && *p++ != ',')
1566                     ;
1567
1568                   constraints[i] = p;
1569                   continue;
1570                 }
1571             }
1572
1573           /* Scan all the constraint letters.  See if the operand matches
1574              any of the constraints.  Collect the valid register classes
1575              and see if this operand accepts memory.  */
1576
1577           while ((c = *p))
1578             {
1579               switch (c)
1580                 {
1581                 case ',':
1582                   break;
1583                 case '*':
1584                   /* Ignore the next letter for this pass.  */
1585                   c = *++p;
1586                   break;
1587
1588                 case '?':
1589                   alt_cost += 2;
1590                 case '!':  case '#':  case '&':
1591                 case '0':  case '1':  case '2':  case '3':  case '4':
1592                 case '5':  case '6':  case '7':  case '8':  case '9':
1593                   break;
1594
1595                 case 'p':
1596                   allows_addr = 1;
1597                   win = address_operand (op, GET_MODE (op));
1598                   /* We know this operand is an address, so we want it to be
1599                      allocated to a register that can be the base of an
1600                      address, i.e. BASE_REG_CLASS.  */
1601                   classes[i]
1602                     = reg_class_subunion[(int) classes[i]]
1603                     [(int) base_reg_class (VOIDmode, ADDRESS, SCRATCH)];
1604                   break;
1605
1606                 case 'm':  case 'o':  case 'V':
1607                   /* It doesn't seem worth distinguishing between offsettable
1608                      and non-offsettable addresses here.  */
1609                   allows_mem[i] = 1;
1610                   if (MEM_P (op))
1611                     win = 1;
1612                   break;
1613
1614                 case '<':
1615                   if (MEM_P (op)
1616                       && (GET_CODE (XEXP (op, 0)) == PRE_DEC
1617                           || GET_CODE (XEXP (op, 0)) == POST_DEC))
1618                     win = 1;
1619                   break;
1620
1621                 case '>':
1622                   if (MEM_P (op)
1623                       && (GET_CODE (XEXP (op, 0)) == PRE_INC
1624                           || GET_CODE (XEXP (op, 0)) == POST_INC))
1625                     win = 1;
1626                   break;
1627
1628                 case 'E':
1629                 case 'F':
1630                   if (GET_CODE (op) == CONST_DOUBLE
1631                       || (GET_CODE (op) == CONST_VECTOR
1632                           && (GET_MODE_CLASS (GET_MODE (op))
1633                               == MODE_VECTOR_FLOAT)))
1634                     win = 1;
1635                   break;
1636
1637                 case 'G':
1638                 case 'H':
1639                   if (GET_CODE (op) == CONST_DOUBLE
1640                       && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, c, p))
1641                     win = 1;
1642                   break;
1643
1644                 case 's':
1645                   if (GET_CODE (op) == CONST_INT
1646                       || (GET_CODE (op) == CONST_DOUBLE
1647                           && GET_MODE (op) == VOIDmode))
1648                     break;
1649                 case 'i':
1650                   if (CONSTANT_P (op)
1651                       && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op)))
1652                     win = 1;
1653                   break;
1654
1655                 case 'n':
1656                   if (GET_CODE (op) == CONST_INT
1657                       || (GET_CODE (op) == CONST_DOUBLE
1658                           && GET_MODE (op) == VOIDmode))
1659                     win = 1;
1660                   break;
1661
1662                 case 'I':
1663                 case 'J':
1664                 case 'K':
1665                 case 'L':
1666                 case 'M':
1667                 case 'N':
1668                 case 'O':
1669                 case 'P':
1670                   if (GET_CODE (op) == CONST_INT
1671                       && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), c, p))
1672                     win = 1;
1673                   break;
1674
1675                 case 'X':
1676                   win = 1;
1677                   break;
1678
1679                 case 'g':
1680                   if (MEM_P (op)
1681                       || (CONSTANT_P (op)
1682                           && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op))))
1683                     win = 1;
1684                   allows_mem[i] = 1;
1685                 case 'r':
1686                   classes[i]
1687                     = reg_class_subunion[(int) classes[i]][(int) GENERAL_REGS];
1688                   break;
1689
1690                 default:
1691                   if (REG_CLASS_FROM_CONSTRAINT (c, p) != NO_REGS)
1692                     classes[i]
1693                       = reg_class_subunion[(int) classes[i]]
1694                         [(int) REG_CLASS_FROM_CONSTRAINT (c, p)];
1695 #ifdef EXTRA_CONSTRAINT_STR
1696                   else if (EXTRA_CONSTRAINT_STR (op, c, p))
1697                     win = 1;
1698
1699                   if (EXTRA_MEMORY_CONSTRAINT (c, p))
1700                     {
1701                       /* Every MEM can be reloaded to fit.  */
1702                       allows_mem[i] = 1;
1703                       if (MEM_P (op))
1704                         win = 1;
1705                     }
1706                   if (EXTRA_ADDRESS_CONSTRAINT (c, p))
1707                     {
1708                       /* Every address can be reloaded to fit.  */
1709                       allows_addr = 1;
1710                       if (address_operand (op, GET_MODE (op)))
1711                         win = 1;
1712                       /* We know this operand is an address, so we want it to
1713                          be allocated to a register that can be the base of an
1714                          address, i.e. BASE_REG_CLASS.  */
1715                       classes[i]
1716                         = reg_class_subunion[(int) classes[i]]
1717                         [(int) base_reg_class (VOIDmode, ADDRESS, SCRATCH)];
1718                     }
1719 #endif
1720                   break;
1721                 }
1722               p += CONSTRAINT_LEN (c, p);
1723               if (c == ',')
1724                 break;
1725             }
1726
1727           constraints[i] = p;
1728
1729           /* How we account for this operand now depends on whether it is  a
1730              pseudo register or not.  If it is, we first check if any
1731              register classes are valid.  If not, we ignore this alternative,
1732              since we want to assume that all pseudos get allocated for
1733              register preferencing.  If some register class is valid, compute
1734              the costs of moving the pseudo into that class.  */
1735
1736           if (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER)
1737             {
1738               if (classes[i] == NO_REGS)
1739                 {
1740                   /* We must always fail if the operand is a REG, but
1741                      we did not find a suitable class.
1742
1743                      Otherwise we may perform an uninitialized read
1744                      from this_op_costs after the `continue' statement
1745                      below.  */
1746                   alt_fail = 1;
1747                 }
1748               else
1749                 {
1750                   struct costs *pp = &this_op_costs[i];
1751                   move_table *intable = NULL;
1752                   move_table *outtable = NULL;
1753                   int op_class = (int) classes[i];
1754
1755                   if (!move_cost[mode])
1756                     init_move_cost (mode);
1757                   intable = may_move_in_cost[mode];
1758                   outtable = may_move_out_cost[mode];
1759
1760                   /* The loop is performance critical, so unswitch it manually.
1761                    */
1762                   switch (recog_data.operand_type[i])
1763                     {
1764                     case OP_INOUT:
1765                       for (class = 0; class < N_REG_CLASSES; class++)
1766                         pp->cost[class] = (intable[class][op_class]
1767                                            + outtable[op_class][class]);
1768                       break;
1769                     case OP_IN:
1770                       for (class = 0; class < N_REG_CLASSES; class++)
1771                         pp->cost[class] = intable[class][op_class];
1772                       break;
1773                     case OP_OUT:
1774                       for (class = 0; class < N_REG_CLASSES; class++)
1775                         pp->cost[class] = outtable[op_class][class];
1776                       break;
1777                     }
1778
1779                   /* If the alternative actually allows memory, make things
1780                      a bit cheaper since we won't need an extra insn to
1781                      load it.  */
1782
1783                   pp->mem_cost
1784                     = ((recog_data.operand_type[i] != OP_IN
1785                         ? MEMORY_MOVE_COST (mode, classes[i], 0)
1786                         : 0)
1787                        + (recog_data.operand_type[i] != OP_OUT
1788                           ? MEMORY_MOVE_COST (mode, classes[i], 1)
1789                           : 0) - allows_mem[i]);
1790
1791                   /* If we have assigned a class to this register in our
1792                      first pass, add a cost to this alternative corresponding
1793                      to what we would add if this register were not in the
1794                      appropriate class.  */
1795
1796                   if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
1797                     alt_cost
1798                       += (may_move_in_cost[mode]
1799                           [(unsigned char) reg_pref[REGNO (op)].prefclass]
1800                           [(int) classes[i]]);
1801                 }
1802             }
1803
1804           /* Otherwise, if this alternative wins, either because we
1805              have already determined that or if we have a hard register of
1806              the proper class, there is no cost for this alternative.  */
1807
1808           else if (win
1809                    || (REG_P (op)
1810                        && reg_fits_class_p (op, classes[i], 0, GET_MODE (op))))
1811             ;
1812
1813           /* If registers are valid, the cost of this alternative includes
1814              copying the object to and/or from a register.  */
1815
1816           else if (classes[i] != NO_REGS)
1817             {
1818               if (recog_data.operand_type[i] != OP_OUT)
1819                 alt_cost += copy_cost (op, mode, classes[i], 1, NULL);
1820
1821               if (recog_data.operand_type[i] != OP_IN)
1822                 alt_cost += copy_cost (op, mode, classes[i], 0, NULL);
1823             }
1824
1825           /* The only other way this alternative can be used is if this is a
1826              constant that could be placed into memory.  */
1827
1828           else if (CONSTANT_P (op) && (allows_addr || allows_mem[i]))
1829             alt_cost += MEMORY_MOVE_COST (mode, classes[i], 1);
1830           else
1831             alt_fail = 1;
1832         }
1833
1834       if (alt_fail)
1835         continue;
1836
1837       /* Finally, update the costs with the information we've calculated
1838          about this alternative.  */
1839
1840       for (i = 0; i < n_ops; i++)
1841         if (REG_P (ops[i])
1842             && REGNO (ops[i]) >= FIRST_PSEUDO_REGISTER)
1843           {
1844             struct costs *pp = &op_costs[i], *qq = &this_op_costs[i];
1845             int scale = 1 + (recog_data.operand_type[i] == OP_INOUT);
1846
1847             pp->mem_cost = MIN (pp->mem_cost,
1848                                 (qq->mem_cost + alt_cost) * scale);
1849
1850             for (class = 0; class < N_REG_CLASSES; class++)
1851               pp->cost[class] = MIN (pp->cost[class],
1852                                      (qq->cost[class] + alt_cost) * scale);
1853           }
1854     }
1855
1856   /* If this insn is a single set copying operand 1 to operand 0
1857      and one operand is a pseudo with the other a hard reg or a pseudo
1858      that prefers a register that is in its own register class then
1859      we may want to adjust the cost of that register class to -1.
1860
1861      Avoid the adjustment if the source does not die to avoid stressing of
1862      register allocator by preferrencing two colliding registers into single
1863      class.
1864
1865      Also avoid the adjustment if a copy between registers of the class
1866      is expensive (ten times the cost of a default copy is considered
1867      arbitrarily expensive).  This avoids losing when the preferred class
1868      is very expensive as the source of a copy instruction.  */
1869
1870   if ((set = single_set (insn)) != 0
1871       && ops[0] == SET_DEST (set) && ops[1] == SET_SRC (set)
1872       && REG_P (ops[0]) && REG_P (ops[1])
1873       && find_regno_note (insn, REG_DEAD, REGNO (ops[1])))
1874     for (i = 0; i <= 1; i++)
1875       if (REGNO (ops[i]) >= FIRST_PSEUDO_REGISTER)
1876         {
1877           unsigned int regno = REGNO (ops[!i]);
1878           enum machine_mode mode = GET_MODE (ops[!i]);
1879           int class;
1880
1881           if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0
1882               && reg_pref[regno].prefclass != NO_REGS)
1883             {
1884               enum reg_class pref = reg_pref[regno].prefclass;
1885
1886               if ((reg_class_size[(unsigned char) pref]
1887                    == (unsigned) CLASS_MAX_NREGS (pref, mode))
1888                   && REGISTER_MOVE_COST (mode, pref, pref) < 10 * 2)
1889                 op_costs[i].cost[(unsigned char) pref] = -1;
1890             }
1891           else if (regno < FIRST_PSEUDO_REGISTER)
1892             for (class = 0; class < N_REG_CLASSES; class++)
1893               if (TEST_HARD_REG_BIT (reg_class_contents[class], regno)
1894                   && reg_class_size[class] == (unsigned) CLASS_MAX_NREGS (class, mode))
1895                 {
1896                   if (reg_class_size[class] == 1)
1897                     op_costs[i].cost[class] = -1;
1898                   else if (in_hard_reg_set_p (reg_class_contents[class],
1899                                              mode, regno))
1900                     op_costs[i].cost[class] = -1;
1901                 }
1902         }
1903 }
1904 \f
1905 /* Compute the cost of loading X into (if TO_P is nonzero) or from (if
1906    TO_P is zero) a register of class CLASS in mode MODE.
1907
1908    X must not be a pseudo.  */
1909
1910 static int
1911 copy_cost (rtx x, enum machine_mode mode, enum reg_class class, int to_p,
1912            secondary_reload_info *prev_sri)
1913 {
1914   enum reg_class secondary_class = NO_REGS;
1915   secondary_reload_info sri;
1916
1917   /* If X is a SCRATCH, there is actually nothing to move since we are
1918      assuming optimal allocation.  */
1919
1920   if (GET_CODE (x) == SCRATCH)
1921     return 0;
1922
1923   /* Get the class we will actually use for a reload.  */
1924   class = PREFERRED_RELOAD_CLASS (x, class);
1925
1926   /* If we need a secondary reload for an intermediate, the
1927      cost is that to load the input into the intermediate register, then
1928      to copy it.  */
1929
1930   sri.prev_sri = prev_sri;
1931   sri.extra_cost = 0;
1932   secondary_class = targetm.secondary_reload (to_p, x, class, mode, &sri);
1933
1934   if (!move_cost[mode])
1935     init_move_cost (mode);
1936
1937   if (secondary_class != NO_REGS)
1938     return (move_cost[mode][(int) secondary_class][(int) class]
1939             + sri.extra_cost
1940             + copy_cost (x, mode, secondary_class, to_p, &sri));
1941
1942   /* For memory, use the memory move cost, for (hard) registers, use the
1943      cost to move between the register classes, and use 2 for everything
1944      else (constants).  */
1945
1946   if (MEM_P (x) || class == NO_REGS)
1947     return sri.extra_cost + MEMORY_MOVE_COST (mode, class, to_p);
1948
1949   else if (REG_P (x))
1950     return (sri.extra_cost
1951             + move_cost[mode][(int) REGNO_REG_CLASS (REGNO (x))][(int) class]);
1952
1953   else
1954     /* If this is a constant, we may eventually want to call rtx_cost here.  */
1955     return sri.extra_cost + COSTS_N_INSNS (1);
1956 }
1957 \f
1958 /* Record the pseudo registers we must reload into hard registers
1959    in a subexpression of a memory address, X.
1960
1961    If CONTEXT is 0, we are looking at the base part of an address, otherwise we
1962    are looking at the index part.
1963
1964    MODE is the mode of the memory reference; OUTER_CODE and INDEX_CODE
1965    give the context that the rtx appears in.  These three arguments are
1966    passed down to base_reg_class.
1967
1968    SCALE is twice the amount to multiply the cost by (it is twice so we
1969    can represent half-cost adjustments).  */
1970
1971 static void
1972 record_address_regs (enum machine_mode mode, rtx x, int context,
1973                      enum rtx_code outer_code, enum rtx_code index_code,
1974                      int scale)
1975 {
1976   enum rtx_code code = GET_CODE (x);
1977   enum reg_class class;
1978
1979   if (context == 1)
1980     class = INDEX_REG_CLASS;
1981   else
1982     class = base_reg_class (mode, outer_code, index_code);
1983
1984   switch (code)
1985     {
1986     case CONST_INT:
1987     case CONST:
1988     case CC0:
1989     case PC:
1990     case SYMBOL_REF:
1991     case LABEL_REF:
1992       return;
1993
1994     case PLUS:
1995       /* When we have an address that is a sum,
1996          we must determine whether registers are "base" or "index" regs.
1997          If there is a sum of two registers, we must choose one to be
1998          the "base".  Luckily, we can use the REG_POINTER to make a good
1999          choice most of the time.  We only need to do this on machines
2000          that can have two registers in an address and where the base
2001          and index register classes are different.
2002
2003          ??? This code used to set REGNO_POINTER_FLAG in some cases, but
2004          that seems bogus since it should only be set when we are sure
2005          the register is being used as a pointer.  */
2006
2007       {
2008         rtx arg0 = XEXP (x, 0);
2009         rtx arg1 = XEXP (x, 1);
2010         enum rtx_code code0 = GET_CODE (arg0);
2011         enum rtx_code code1 = GET_CODE (arg1);
2012
2013         /* Look inside subregs.  */
2014         if (code0 == SUBREG)
2015           arg0 = SUBREG_REG (arg0), code0 = GET_CODE (arg0);
2016         if (code1 == SUBREG)
2017           arg1 = SUBREG_REG (arg1), code1 = GET_CODE (arg1);
2018
2019         /* If this machine only allows one register per address, it must
2020            be in the first operand.  */
2021
2022         if (MAX_REGS_PER_ADDRESS == 1)
2023           record_address_regs (mode, arg0, 0, PLUS, code1, scale);
2024
2025         /* If index and base registers are the same on this machine, just
2026            record registers in any non-constant operands.  We assume here,
2027            as well as in the tests below, that all addresses are in
2028            canonical form.  */
2029
2030         else if (INDEX_REG_CLASS == base_reg_class (VOIDmode, PLUS, SCRATCH))
2031           {
2032             record_address_regs (mode, arg0, context, PLUS, code1, scale);
2033             if (! CONSTANT_P (arg1))
2034               record_address_regs (mode, arg1, context, PLUS, code0, scale);
2035           }
2036
2037         /* If the second operand is a constant integer, it doesn't change
2038            what class the first operand must be.  */
2039
2040         else if (code1 == CONST_INT || code1 == CONST_DOUBLE)
2041           record_address_regs (mode, arg0, context, PLUS, code1, scale);
2042
2043         /* If the second operand is a symbolic constant, the first operand
2044            must be an index register.  */
2045
2046         else if (code1 == SYMBOL_REF || code1 == CONST || code1 == LABEL_REF)
2047           record_address_regs (mode, arg0, 1, PLUS, code1, scale);
2048
2049         /* If both operands are registers but one is already a hard register
2050            of index or reg-base class, give the other the class that the
2051            hard register is not.  */
2052
2053         else if (code0 == REG && code1 == REG
2054                  && REGNO (arg0) < FIRST_PSEUDO_REGISTER
2055                  && (ok_for_base_p_nonstrict (arg0, mode, PLUS, REG)
2056                      || ok_for_index_p_nonstrict (arg0)))
2057           record_address_regs (mode, arg1,
2058                                ok_for_base_p_nonstrict (arg0, mode, PLUS, REG)
2059                                ? 1 : 0,
2060                                PLUS, REG, scale);
2061         else if (code0 == REG && code1 == REG
2062                  && REGNO (arg1) < FIRST_PSEUDO_REGISTER
2063                  && (ok_for_base_p_nonstrict (arg1, mode, PLUS, REG)
2064                      || ok_for_index_p_nonstrict (arg1)))
2065           record_address_regs (mode, arg0,
2066                                ok_for_base_p_nonstrict (arg1, mode, PLUS, REG)
2067                                ? 1 : 0,
2068                                PLUS, REG, scale);
2069
2070         /* If one operand is known to be a pointer, it must be the base
2071            with the other operand the index.  Likewise if the other operand
2072            is a MULT.  */
2073
2074         else if ((code0 == REG && REG_POINTER (arg0))
2075                  || code1 == MULT)
2076           {
2077             record_address_regs (mode, arg0, 0, PLUS, code1, scale);
2078             record_address_regs (mode, arg1, 1, PLUS, code0, scale);
2079           }
2080         else if ((code1 == REG && REG_POINTER (arg1))
2081                  || code0 == MULT)
2082           {
2083             record_address_regs (mode, arg0, 1, PLUS, code1, scale);
2084             record_address_regs (mode, arg1, 0, PLUS, code0, scale);
2085           }
2086
2087         /* Otherwise, count equal chances that each might be a base
2088            or index register.  This case should be rare.  */
2089
2090         else
2091           {
2092             record_address_regs (mode, arg0, 0, PLUS, code1, scale / 2);
2093             record_address_regs (mode, arg0, 1, PLUS, code1, scale / 2);
2094             record_address_regs (mode, arg1, 0, PLUS, code0, scale / 2);
2095             record_address_regs (mode, arg1, 1, PLUS, code0, scale / 2);
2096           }
2097       }
2098       break;
2099
2100       /* Double the importance of a pseudo register that is incremented
2101          or decremented, since it would take two extra insns
2102          if it ends up in the wrong place.  */
2103     case POST_MODIFY:
2104     case PRE_MODIFY:
2105       record_address_regs (mode, XEXP (x, 0), 0, code,
2106                            GET_CODE (XEXP (XEXP (x, 1), 1)), 2 * scale);
2107       if (REG_P (XEXP (XEXP (x, 1), 1)))
2108         record_address_regs (mode, XEXP (XEXP (x, 1), 1), 1, code, REG,
2109                              2 * scale);
2110       break;
2111
2112     case POST_INC:
2113     case PRE_INC:
2114     case POST_DEC:
2115     case PRE_DEC:
2116       /* Double the importance of a pseudo register that is incremented
2117          or decremented, since it would take two extra insns
2118          if it ends up in the wrong place.  If the operand is a pseudo,
2119          show it is being used in an INC_DEC context.  */
2120
2121 #ifdef FORBIDDEN_INC_DEC_CLASSES
2122       if (REG_P (XEXP (x, 0))
2123           && REGNO (XEXP (x, 0)) >= FIRST_PSEUDO_REGISTER)
2124         in_inc_dec[REGNO (XEXP (x, 0))] = 1;
2125 #endif
2126
2127       record_address_regs (mode, XEXP (x, 0), 0, code, SCRATCH, 2 * scale);
2128       break;
2129
2130     case REG:
2131       {
2132         struct costs *pp = &costs[REGNO (x)];
2133         int i;
2134
2135         pp->mem_cost += (MEMORY_MOVE_COST (Pmode, class, 1) * scale) / 2;
2136
2137         if (!move_cost[Pmode])
2138           init_move_cost (Pmode);
2139         for (i = 0; i < N_REG_CLASSES; i++)
2140           pp->cost[i] += (may_move_in_cost[Pmode][i][(int) class] * scale) / 2;
2141       }
2142       break;
2143
2144     default:
2145       {
2146         const char *fmt = GET_RTX_FORMAT (code);
2147         int i;
2148         for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2149           if (fmt[i] == 'e')
2150             record_address_regs (mode, XEXP (x, i), context, code, SCRATCH,
2151                                  scale);
2152       }
2153     }
2154 }
2155 \f
2156 #ifdef FORBIDDEN_INC_DEC_CLASSES
2157
2158 /* Return 1 if REG is valid as an auto-increment memory reference
2159    to an object of MODE.  */
2160
2161 static int
2162 auto_inc_dec_reg_p (rtx reg, enum machine_mode mode)
2163 {
2164   if (HAVE_POST_INCREMENT
2165       && memory_address_p (mode, gen_rtx_POST_INC (Pmode, reg)))
2166     return 1;
2167
2168   if (HAVE_POST_DECREMENT
2169       && memory_address_p (mode, gen_rtx_POST_DEC (Pmode, reg)))
2170     return 1;
2171
2172   if (HAVE_PRE_INCREMENT
2173       && memory_address_p (mode, gen_rtx_PRE_INC (Pmode, reg)))
2174     return 1;
2175
2176   if (HAVE_PRE_DECREMENT
2177       && memory_address_p (mode, gen_rtx_PRE_DEC (Pmode, reg)))
2178     return 1;
2179
2180   return 0;
2181 }
2182 #endif
2183 \f
2184 /* Free up the space allocated by allocate_reg_info.  */
2185 void
2186 free_reg_info (void)
2187 {
2188   if (reg_pref)
2189     {
2190       free (reg_pref);
2191       reg_pref = NULL;
2192     }
2193
2194   if (reg_renumber)
2195     {
2196       free (reg_renumber);
2197       reg_renumber = NULL;
2198     }
2199 }
2200
2201 \f
2202 /* This is the `regscan' pass of the compiler, run just before cse and
2203    again just before loop.  It finds the first and last use of each
2204    pseudo-register.  */
2205
2206 void
2207 reg_scan (rtx f, unsigned int nregs ATTRIBUTE_UNUSED)
2208 {
2209   rtx insn;
2210
2211   timevar_push (TV_REG_SCAN);
2212
2213   for (insn = f; insn; insn = NEXT_INSN (insn))
2214     if (INSN_P (insn))
2215       {
2216         reg_scan_mark_refs (PATTERN (insn), insn);
2217         if (REG_NOTES (insn))
2218           reg_scan_mark_refs (REG_NOTES (insn), insn);
2219       }
2220
2221   timevar_pop (TV_REG_SCAN);
2222 }
2223
2224
2225 /* X is the expression to scan.  INSN is the insn it appears in.
2226    NOTE_FLAG is nonzero if X is from INSN's notes rather than its body.
2227    We should only record information for REGs with numbers
2228    greater than or equal to MIN_REGNO.  */
2229
2230 extern struct tree_opt_pass *current_pass;
2231
2232 static void
2233 reg_scan_mark_refs (rtx x, rtx insn)
2234 {
2235   enum rtx_code code;
2236   rtx dest;
2237   rtx note;
2238
2239   if (!x)
2240     return;
2241   code = GET_CODE (x);
2242   switch (code)
2243     {
2244     case CONST:
2245     case CONST_INT:
2246     case CONST_DOUBLE:
2247     case CONST_VECTOR:
2248     case CC0:
2249     case PC:
2250     case SYMBOL_REF:
2251     case LABEL_REF:
2252     case ADDR_VEC:
2253     case ADDR_DIFF_VEC:
2254     case REG:
2255       return;
2256
2257     case EXPR_LIST:
2258       if (XEXP (x, 0))
2259         reg_scan_mark_refs (XEXP (x, 0), insn);
2260       if (XEXP (x, 1))
2261         reg_scan_mark_refs (XEXP (x, 1), insn);
2262       break;
2263
2264     case INSN_LIST:
2265       if (XEXP (x, 1))
2266         reg_scan_mark_refs (XEXP (x, 1), insn);
2267       break;
2268
2269     case CLOBBER:
2270       if (MEM_P (XEXP (x, 0)))
2271         reg_scan_mark_refs (XEXP (XEXP (x, 0), 0), insn);
2272       break;
2273
2274     case SET:
2275       /* Count a set of the destination if it is a register.  */
2276       for (dest = SET_DEST (x);
2277            GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
2278            || GET_CODE (dest) == ZERO_EXTEND;
2279            dest = XEXP (dest, 0))
2280         ;
2281
2282       /* If this is setting a pseudo from another pseudo or the sum of a
2283          pseudo and a constant integer and the other pseudo is known to be
2284          a pointer, set the destination to be a pointer as well.
2285
2286          Likewise if it is setting the destination from an address or from a
2287          value equivalent to an address or to the sum of an address and
2288          something else.
2289
2290          But don't do any of this if the pseudo corresponds to a user
2291          variable since it should have already been set as a pointer based
2292          on the type.  */
2293
2294       if (REG_P (SET_DEST (x))
2295           && REGNO (SET_DEST (x)) >= FIRST_PSEUDO_REGISTER
2296           /* If the destination pseudo is set more than once, then other
2297              sets might not be to a pointer value (consider access to a
2298              union in two threads of control in the presence of global
2299              optimizations).  So only set REG_POINTER on the destination
2300              pseudo if this is the only set of that pseudo.  */
2301           && DF_REG_DEF_COUNT (REGNO (SET_DEST (x))) == 1
2302           && ! REG_USERVAR_P (SET_DEST (x))
2303           && ! REG_POINTER (SET_DEST (x))
2304           && ((REG_P (SET_SRC (x))
2305                && REG_POINTER (SET_SRC (x)))
2306               || ((GET_CODE (SET_SRC (x)) == PLUS
2307                    || GET_CODE (SET_SRC (x)) == LO_SUM)
2308                   && GET_CODE (XEXP (SET_SRC (x), 1)) == CONST_INT
2309                   && REG_P (XEXP (SET_SRC (x), 0))
2310                   && REG_POINTER (XEXP (SET_SRC (x), 0)))
2311               || GET_CODE (SET_SRC (x)) == CONST
2312               || GET_CODE (SET_SRC (x)) == SYMBOL_REF
2313               || GET_CODE (SET_SRC (x)) == LABEL_REF
2314               || (GET_CODE (SET_SRC (x)) == HIGH
2315                   && (GET_CODE (XEXP (SET_SRC (x), 0)) == CONST
2316                       || GET_CODE (XEXP (SET_SRC (x), 0)) == SYMBOL_REF
2317                       || GET_CODE (XEXP (SET_SRC (x), 0)) == LABEL_REF))
2318               || ((GET_CODE (SET_SRC (x)) == PLUS
2319                    || GET_CODE (SET_SRC (x)) == LO_SUM)
2320                   && (GET_CODE (XEXP (SET_SRC (x), 1)) == CONST
2321                       || GET_CODE (XEXP (SET_SRC (x), 1)) == SYMBOL_REF
2322                       || GET_CODE (XEXP (SET_SRC (x), 1)) == LABEL_REF))
2323               || ((note = find_reg_note (insn, REG_EQUAL, 0)) != 0
2324                   && (GET_CODE (XEXP (note, 0)) == CONST
2325                       || GET_CODE (XEXP (note, 0)) == SYMBOL_REF
2326                       || GET_CODE (XEXP (note, 0)) == LABEL_REF))))
2327         REG_POINTER (SET_DEST (x)) = 1;
2328
2329       /* If this is setting a register from a register or from a simple
2330          conversion of a register, propagate REG_EXPR.  */
2331       if (REG_P (dest) && !REG_ATTRS (dest))
2332         {
2333           rtx src = SET_SRC (x);
2334
2335           while (GET_CODE (src) == SIGN_EXTEND
2336                  || GET_CODE (src) == ZERO_EXTEND
2337                  || GET_CODE (src) == TRUNCATE
2338                  || (GET_CODE (src) == SUBREG && subreg_lowpart_p (src)))
2339             src = XEXP (src, 0);
2340
2341           if (REG_P (src))
2342             REG_ATTRS (dest) = REG_ATTRS (src);
2343           if (MEM_P (src))
2344             set_reg_attrs_from_mem (dest, src);
2345         }
2346
2347       /* ... fall through ...  */
2348
2349     default:
2350       {
2351         const char *fmt = GET_RTX_FORMAT (code);
2352         int i;
2353         for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2354           {
2355             if (fmt[i] == 'e')
2356               reg_scan_mark_refs (XEXP (x, i), insn);
2357             else if (fmt[i] == 'E' && XVEC (x, i) != 0)
2358               {
2359                 int j;
2360                 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2361                   reg_scan_mark_refs (XVECEXP (x, i, j), insn);
2362               }
2363           }
2364       }
2365     }
2366 }
2367 \f
2368 /* Return nonzero if C1 is a subset of C2, i.e., if every register in C1
2369    is also in C2.  */
2370
2371 int
2372 reg_class_subset_p (enum reg_class c1, enum reg_class c2)
2373 {
2374   return (c1 == c2
2375           || c2 == ALL_REGS
2376           || hard_reg_set_subset_p (reg_class_contents[(int) c1],
2377                                    reg_class_contents[(int) c2]));
2378 }
2379
2380 /* Return nonzero if there is a register that is in both C1 and C2.  */
2381
2382 int
2383 reg_classes_intersect_p (enum reg_class c1, enum reg_class c2)
2384 {
2385   return (c1 == c2
2386           || c1 == ALL_REGS
2387           || c2 == ALL_REGS
2388           || hard_reg_set_intersect_p (reg_class_contents[(int) c1],
2389                                       reg_class_contents[(int) c2]));
2390 }
2391
2392 #ifdef CANNOT_CHANGE_MODE_CLASS
2393
2394 struct subregs_of_mode_node
2395 {
2396   unsigned int block;
2397   unsigned char modes[MAX_MACHINE_MODE];
2398 };
2399
2400 static htab_t subregs_of_mode;
2401
2402 static hashval_t
2403 som_hash (const void *x)
2404 {
2405   const struct subregs_of_mode_node *a = x;
2406   return a->block;
2407 }
2408
2409 static int
2410 som_eq (const void *x, const void *y)
2411 {
2412   const struct subregs_of_mode_node *a = x;
2413   const struct subregs_of_mode_node *b = y;
2414   return a->block == b->block;
2415 }
2416
2417
2418 static void
2419 record_subregs_of_mode (rtx subreg)
2420 {
2421   struct subregs_of_mode_node dummy, *node;
2422   enum machine_mode mode;
2423   unsigned int regno;
2424   void **slot;
2425
2426   if (!REG_P (SUBREG_REG (subreg)))
2427     return;
2428
2429   regno = REGNO (SUBREG_REG (subreg));
2430   mode = GET_MODE (subreg);
2431
2432   if (regno < FIRST_PSEUDO_REGISTER)
2433     return;
2434
2435   dummy.block = regno & -8;
2436   slot = htab_find_slot_with_hash (subregs_of_mode, &dummy,
2437                                    dummy.block, INSERT);
2438   node = *slot;
2439   if (node == NULL)
2440     {
2441       node = XCNEW (struct subregs_of_mode_node);
2442       node->block = regno & -8;
2443       *slot = node;
2444     }
2445
2446   node->modes[mode] |= 1 << (regno & 7);
2447 }
2448
2449
2450 /* Call record_subregs_of_mode for all the subregs in X.  */
2451
2452 static void 
2453 find_subregs_of_mode (rtx x)
2454 {
2455   enum rtx_code code = GET_CODE (x);
2456   const char * const fmt = GET_RTX_FORMAT (code);
2457   int i;
2458
2459   if (code == SUBREG)
2460     record_subregs_of_mode (x);
2461     
2462   /* Time for some deep diving.  */
2463   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2464     {
2465       if (fmt[i] == 'e')
2466         find_subregs_of_mode (XEXP (x, i));
2467       else if (fmt[i] == 'E')
2468         {
2469           int j;
2470           for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2471             find_subregs_of_mode (XVECEXP (x, i, j));
2472         }
2473     }
2474 }
2475
2476 static unsigned int
2477 init_subregs_of_mode (void)
2478 {
2479   basic_block bb;
2480   rtx insn;
2481
2482   if (subregs_of_mode)
2483     htab_empty (subregs_of_mode);
2484   else
2485     subregs_of_mode = htab_create (100, som_hash, som_eq, free);
2486
2487   FOR_EACH_BB (bb)
2488     FOR_BB_INSNS (bb, insn)
2489     if (INSN_P (insn))
2490       find_subregs_of_mode (PATTERN (insn));
2491
2492   return 0;
2493 }
2494
2495
2496 /* Set bits in *USED which correspond to registers which can't change
2497    their mode from FROM to any mode in which REGNO was encountered.  */
2498
2499 void
2500 cannot_change_mode_set_regs (HARD_REG_SET *used, enum machine_mode from,
2501                              unsigned int regno)
2502 {
2503   struct subregs_of_mode_node dummy, *node;
2504   enum machine_mode to;
2505   unsigned char mask;
2506   unsigned int i;
2507
2508   gcc_assert (subregs_of_mode);
2509   dummy.block = regno & -8;
2510   node = htab_find_with_hash (subregs_of_mode, &dummy, dummy.block);
2511   if (node == NULL)
2512     return;
2513
2514   mask = 1 << (regno & 7);
2515   for (to = VOIDmode; to < NUM_MACHINE_MODES; to++)
2516     if (node->modes[to] & mask)
2517       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
2518         if (!TEST_HARD_REG_BIT (*used, i)
2519             && REG_CANNOT_CHANGE_MODE_P (i, from, to))
2520           SET_HARD_REG_BIT (*used, i);
2521 }
2522
2523 /* Return 1 if REGNO has had an invalid mode change in CLASS from FROM
2524    mode.  */
2525
2526 bool
2527 invalid_mode_change_p (unsigned int regno,
2528                        enum reg_class class ATTRIBUTE_UNUSED,
2529                        enum machine_mode from)
2530 {
2531   struct subregs_of_mode_node dummy, *node;
2532   enum machine_mode to;
2533   unsigned char mask;
2534
2535   gcc_assert (subregs_of_mode);
2536   dummy.block = regno & -8;
2537   node = htab_find_with_hash (subregs_of_mode, &dummy, dummy.block);
2538   if (node == NULL)
2539     return false;
2540
2541   mask = 1 << (regno & 7);
2542   for (to = VOIDmode; to < NUM_MACHINE_MODES; to++)
2543     if (node->modes[to] & mask)
2544       if (CANNOT_CHANGE_MODE_CLASS (from, to, class))
2545         return true;
2546
2547   return false;
2548 }
2549
2550 static unsigned int
2551 finish_subregs_of_mode (void)
2552 {
2553   htab_delete (subregs_of_mode);
2554   subregs_of_mode = 0;
2555   return 0;
2556 }
2557 #else
2558 static unsigned int
2559 init_subregs_of_mode (void)
2560 {
2561   return 0;
2562 }
2563 static unsigned int
2564 finish_subregs_of_mode (void)
2565 {
2566   return 0;
2567 }
2568
2569 #endif /* CANNOT_CHANGE_MODE_CLASS */
2570
2571 static bool
2572 gate_subregs_of_mode_init (void)
2573 {
2574 #ifdef CANNOT_CHANGE_MODE_CLASS
2575   return true;
2576 #else
2577   return false;
2578 #endif
2579 }
2580
2581 struct tree_opt_pass pass_subregs_of_mode_init =
2582 {
2583   "subregs_of_mode_init",               /* name */
2584   gate_subregs_of_mode_init,            /* gate */
2585   init_subregs_of_mode,                 /* execute */
2586   NULL,                                 /* sub */
2587   NULL,                                 /* next */
2588   0,                                    /* static_pass_number */
2589   0,                                    /* tv_id */
2590   0,                                    /* properties_required */
2591   0,                                    /* properties_provided */
2592   0,                                    /* properties_destroyed */
2593   0,                                    /* todo_flags_start */
2594   0,                                    /* todo_flags_finish */
2595   0                                     /* letter */
2596 };
2597
2598 struct tree_opt_pass pass_subregs_of_mode_finish =
2599 {
2600   "subregs_of_mode_finish",               /* name */
2601   gate_subregs_of_mode_init,            /* gate */
2602   finish_subregs_of_mode,               /* execute */
2603   NULL,                                 /* sub */
2604   NULL,                                 /* next */
2605   0,                                    /* static_pass_number */
2606   0,                                    /* tv_id */
2607   0,                                    /* properties_required */
2608   0,                                    /* properties_provided */
2609   0,                                    /* properties_destroyed */
2610   0,                                    /* todo_flags_start */
2611   0,                                    /* todo_flags_finish */
2612   0                                     /* letter */
2613 };
2614
2615
2616
2617 #include "gt-regclass.h"