Mercurial > hg > CbC > CbC_gcc
comparison gcc/reginfo.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Compute different info about registers. | 1 /* Compute different info about registers. |
2 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996 | 2 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996 |
3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, | 3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
4 2009 Free Software Foundation, Inc. | 4 2009, 2010 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 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 | 9 the terms of the GNU General Public License as published by the Free |
41 #include "addresses.h" | 41 #include "addresses.h" |
42 #include "function.h" | 42 #include "function.h" |
43 #include "insn-config.h" | 43 #include "insn-config.h" |
44 #include "recog.h" | 44 #include "recog.h" |
45 #include "reload.h" | 45 #include "reload.h" |
46 #include "toplev.h" | 46 #include "diagnostic-core.h" |
47 #include "output.h" | 47 #include "output.h" |
48 #include "ggc.h" | |
49 #include "timevar.h" | 48 #include "timevar.h" |
50 #include "hashtab.h" | 49 #include "hashtab.h" |
51 #include "target.h" | 50 #include "target.h" |
52 #include "tree-pass.h" | 51 #include "tree-pass.h" |
53 #include "df.h" | 52 #include "df.h" |
56 /* Maximum register number used in this function, plus one. */ | 55 /* Maximum register number used in this function, plus one. */ |
57 | 56 |
58 int max_regno; | 57 int max_regno; |
59 | 58 |
60 | 59 |
61 /* Register tables used by many passes. */ | 60 struct target_hard_regs default_target_hard_regs; |
62 | 61 struct target_regs default_target_regs; |
63 /* Indexed by hard register number, contains 1 for registers | 62 #if SWITCHABLE_TARGET |
64 that are fixed use (stack pointer, pc, frame pointer, etc.). | 63 struct target_hard_regs *this_target_hard_regs = &default_target_hard_regs; |
65 These are the registers that cannot be used to allocate | 64 struct target_regs *this_target_regs = &default_target_regs; |
66 a pseudo reg for general use. */ | 65 #endif |
67 char fixed_regs[FIRST_PSEUDO_REGISTER]; | 66 |
68 | 67 /* Data for initializing fixed_regs. */ |
69 /* Same info as a HARD_REG_SET. */ | |
70 HARD_REG_SET fixed_reg_set; | |
71 | |
72 /* Data for initializing the above. */ | |
73 static const char initial_fixed_regs[] = FIXED_REGISTERS; | 68 static const char initial_fixed_regs[] = FIXED_REGISTERS; |
74 | 69 |
75 /* Indexed by hard register number, contains 1 for registers | 70 /* Data for initializing call_used_regs. */ |
76 that are fixed use or are clobbered by function calls. | |
77 These are the registers that cannot be used to allocate | |
78 a pseudo reg whose life crosses calls unless we are able | |
79 to save/restore them across the calls. */ | |
80 char call_used_regs[FIRST_PSEUDO_REGISTER]; | |
81 | |
82 /* Same info as a HARD_REG_SET. */ | |
83 HARD_REG_SET call_used_reg_set; | |
84 | |
85 /* Data for initializing the above. */ | |
86 static const char initial_call_used_regs[] = CALL_USED_REGISTERS; | 71 static const char initial_call_used_regs[] = CALL_USED_REGISTERS; |
87 | 72 |
88 /* This is much like call_used_regs, except it doesn't have to | |
89 be a superset of FIXED_REGISTERS. This vector indicates | |
90 what is really call clobbered, and is used when defining | |
91 regs_invalidated_by_call. */ | |
92 #ifdef CALL_REALLY_USED_REGISTERS | 73 #ifdef CALL_REALLY_USED_REGISTERS |
93 char call_really_used_regs[] = CALL_REALLY_USED_REGISTERS; | 74 /* Data for initializing call_really_used_regs. */ |
75 static const char initial_call_really_used_regs[] = CALL_REALLY_USED_REGISTERS; | |
94 #endif | 76 #endif |
95 | 77 |
96 #ifdef CALL_REALLY_USED_REGISTERS | 78 #ifdef CALL_REALLY_USED_REGISTERS |
97 #define CALL_REALLY_USED_REGNO_P(X) call_really_used_regs[X] | 79 #define CALL_REALLY_USED_REGNO_P(X) call_really_used_regs[X] |
98 #else | 80 #else |
99 #define CALL_REALLY_USED_REGNO_P(X) call_used_regs[X] | 81 #define CALL_REALLY_USED_REGNO_P(X) call_used_regs[X] |
100 #endif | 82 #endif |
101 | |
102 | |
103 /* Contains registers that are fixed use -- i.e. in fixed_reg_set -- or | |
104 a function value return register or TARGET_STRUCT_VALUE_RTX or | |
105 STATIC_CHAIN_REGNUM. These are the registers that cannot hold quantities | |
106 across calls even if we are willing to save and restore them. */ | |
107 | |
108 HARD_REG_SET call_fixed_reg_set; | |
109 | 83 |
110 /* Indexed by hard register number, contains 1 for registers | 84 /* Indexed by hard register number, contains 1 for registers |
111 that are being used for global register decls. | 85 that are being used for global register decls. |
112 These must be exempt from ordinary flow analysis | 86 These must be exempt from ordinary flow analysis |
113 and are also considered fixed. */ | 87 and are also considered fixed. */ |
114 char global_regs[FIRST_PSEUDO_REGISTER]; | 88 char global_regs[FIRST_PSEUDO_REGISTER]; |
115 | 89 |
116 /* Contains 1 for registers that are set or clobbered by calls. */ | |
117 /* ??? Ideally, this would be just call_used_regs plus global_regs, but | |
118 for someone's bright idea to have call_used_regs strictly include | |
119 fixed_regs. Which leaves us guessing as to the set of fixed_regs | |
120 that are actually preserved. We know for sure that those associated | |
121 with the local stack frame are safe, but scant others. */ | |
122 HARD_REG_SET regs_invalidated_by_call; | |
123 | |
124 /* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used | 90 /* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used |
125 in dataflow more conveniently. */ | 91 in dataflow more conveniently. */ |
126 regset regs_invalidated_by_call_regset; | 92 regset regs_invalidated_by_call_regset; |
127 | 93 |
128 /* The bitmap_obstack is used to hold some static variables that | 94 /* The bitmap_obstack is used to hold some static variables that |
129 should not be reset after each function is compiled. */ | 95 should not be reset after each function is compiled. */ |
130 static bitmap_obstack persistent_obstack; | 96 static bitmap_obstack persistent_obstack; |
131 | 97 |
132 /* Table of register numbers in the order in which to try to use them. */ | 98 /* Used to initialize reg_alloc_order. */ |
133 #ifdef REG_ALLOC_ORDER | 99 #ifdef REG_ALLOC_ORDER |
134 int reg_alloc_order[FIRST_PSEUDO_REGISTER] = REG_ALLOC_ORDER; | 100 static int initial_reg_alloc_order[FIRST_PSEUDO_REGISTER] = REG_ALLOC_ORDER; |
135 | 101 #endif |
136 /* The inverse of reg_alloc_order. */ | |
137 int inv_reg_alloc_order[FIRST_PSEUDO_REGISTER]; | |
138 #endif | |
139 | |
140 /* For each reg class, a HARD_REG_SET saying which registers are in it. */ | |
141 HARD_REG_SET reg_class_contents[N_REG_CLASSES]; | |
142 | 102 |
143 /* The same information, but as an array of unsigned ints. We copy from | 103 /* The same information, but as an array of unsigned ints. We copy from |
144 these unsigned ints to the table above. We do this so the tm.h files | 104 these unsigned ints to the table above. We do this so the tm.h files |
145 do not have to be aware of the wordsize for machines with <= 64 regs. | 105 do not have to be aware of the wordsize for machines with <= 64 regs. |
146 Note that we hard-code 32 here, not HOST_BITS_PER_INT. */ | 106 Note that we hard-code 32 here, not HOST_BITS_PER_INT. */ |
148 ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32) | 108 ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32) |
149 | 109 |
150 static const unsigned int_reg_class_contents[N_REG_CLASSES][N_REG_INTS] | 110 static const unsigned int_reg_class_contents[N_REG_CLASSES][N_REG_INTS] |
151 = REG_CLASS_CONTENTS; | 111 = REG_CLASS_CONTENTS; |
152 | 112 |
153 /* For each reg class, number of regs it contains. */ | |
154 unsigned int reg_class_size[N_REG_CLASSES]; | |
155 | |
156 /* For each reg class, table listing all the classes contained in it. */ | |
157 enum reg_class reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES]; | |
158 | |
159 /* For each pair of reg classes, | |
160 a largest reg class contained in their union. */ | |
161 enum reg_class reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES]; | |
162 | |
163 /* For each pair of reg classes, | |
164 the smallest reg class containing their union. */ | |
165 enum reg_class reg_class_superunion[N_REG_CLASSES][N_REG_CLASSES]; | |
166 | |
167 /* Array containing all of the register names. */ | 113 /* Array containing all of the register names. */ |
168 const char * reg_names[] = REGISTER_NAMES; | 114 static const char *const initial_reg_names[] = REGISTER_NAMES; |
169 | 115 |
170 /* Array containing all of the register class names. */ | 116 /* Array containing all of the register class names. */ |
171 const char * reg_class_names[] = REG_CLASS_NAMES; | 117 const char * reg_class_names[] = REG_CLASS_NAMES; |
172 | 118 |
173 /* For each hard register, the widest mode object that it can contain. | 119 #define last_mode_for_init_move_cost \ |
174 This will be a MODE_INT mode if the register can hold integers. Otherwise | 120 (this_target_regs->x_last_mode_for_init_move_cost) |
175 it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the | |
176 register. */ | |
177 enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER]; | |
178 | |
179 /* 1 if there is a register of given mode. */ | |
180 bool have_regs_of_mode [MAX_MACHINE_MODE]; | |
181 | |
182 /* 1 if class does contain register of given mode. */ | |
183 char contains_reg_of_mode [N_REG_CLASSES] [MAX_MACHINE_MODE]; | |
184 | |
185 /* Maximum cost of moving from a register in one class to a register in | |
186 another class. Based on REGISTER_MOVE_COST. */ | |
187 move_table *move_cost[MAX_MACHINE_MODE]; | |
188 | |
189 /* Similar, but here we don't have to move if the first index is a subset | |
190 of the second so in that case the cost is zero. */ | |
191 move_table *may_move_in_cost[MAX_MACHINE_MODE]; | |
192 | |
193 /* Similar, but here we don't have to move if the first index is a superset | |
194 of the second so in that case the cost is zero. */ | |
195 move_table *may_move_out_cost[MAX_MACHINE_MODE]; | |
196 | |
197 /* Keep track of the last mode we initialized move costs for. */ | |
198 static int last_mode_for_init_move_cost; | |
199 | |
200 /* Sample MEM values for use by memory_move_secondary_cost. */ | |
201 static GTY(()) rtx top_of_stack[MAX_MACHINE_MODE]; | |
202 | 121 |
203 /* No more global register variables may be declared; true once | 122 /* No more global register variables may be declared; true once |
204 reginfo has been initialized. */ | 123 reginfo has been initialized. */ |
205 static int no_global_reg_vars = 0; | 124 static int no_global_reg_vars = 0; |
206 | |
207 /* Specify number of hard registers given machine mode occupy. */ | |
208 unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE]; | |
209 | 125 |
210 /* Given a register bitmap, turn on the bits in a HARD_REG_SET that | 126 /* Given a register bitmap, turn on the bits in a HARD_REG_SET that |
211 correspond to the hard registers, if any, set in that map. This | 127 correspond to the hard registers, if any, set in that map. This |
212 could be done far more efficiently by having all sorts of special-cases | 128 could be done far more efficiently by having all sorts of special-cases |
213 with moving single words, but probably isn't worth the trouble. */ | 129 with moving single words, but probably isn't worth the trouble. */ |
223 return; | 139 return; |
224 SET_HARD_REG_BIT (*to, i); | 140 SET_HARD_REG_BIT (*to, i); |
225 } | 141 } |
226 } | 142 } |
227 | 143 |
228 /* Function called only once to initialize the above data on reg usage. | 144 /* Function called only once per target_globals to initialize the |
229 Once this is done, various switches may override. */ | 145 target_hard_regs structure. Once this is done, various switches |
146 may override. */ | |
230 void | 147 void |
231 init_reg_sets (void) | 148 init_reg_sets (void) |
232 { | 149 { |
233 int i, j; | 150 int i, j; |
234 | 151 |
248 | 165 |
249 /* Sanity check: make sure the target macros FIXED_REGISTERS and | 166 /* Sanity check: make sure the target macros FIXED_REGISTERS and |
250 CALL_USED_REGISTERS had the right number of initializers. */ | 167 CALL_USED_REGISTERS had the right number of initializers. */ |
251 gcc_assert (sizeof fixed_regs == sizeof initial_fixed_regs); | 168 gcc_assert (sizeof fixed_regs == sizeof initial_fixed_regs); |
252 gcc_assert (sizeof call_used_regs == sizeof initial_call_used_regs); | 169 gcc_assert (sizeof call_used_regs == sizeof initial_call_used_regs); |
170 #ifdef CALL_REALLY_USED_REGISTERS | |
171 gcc_assert (sizeof call_really_used_regs | |
172 == sizeof initial_call_really_used_regs); | |
173 #endif | |
174 #ifdef REG_ALLOC_ORDER | |
175 gcc_assert (sizeof reg_alloc_order == sizeof initial_reg_alloc_order); | |
176 #endif | |
177 gcc_assert (sizeof reg_names == sizeof initial_reg_names); | |
253 | 178 |
254 memcpy (fixed_regs, initial_fixed_regs, sizeof fixed_regs); | 179 memcpy (fixed_regs, initial_fixed_regs, sizeof fixed_regs); |
255 memcpy (call_used_regs, initial_call_used_regs, sizeof call_used_regs); | 180 memcpy (call_used_regs, initial_call_used_regs, sizeof call_used_regs); |
256 memset (global_regs, 0, sizeof global_regs); | 181 #ifdef CALL_REALLY_USED_REGISTERS |
182 memcpy (call_really_used_regs, initial_call_really_used_regs, | |
183 sizeof call_really_used_regs); | |
184 #endif | |
185 #ifdef REG_ALLOC_ORDER | |
186 memcpy (reg_alloc_order, initial_reg_alloc_order, sizeof reg_alloc_order); | |
187 #endif | |
188 memcpy (reg_names, initial_reg_names, sizeof reg_names); | |
257 } | 189 } |
258 | 190 |
259 /* Initialize may_move_cost and friends for mode M. */ | 191 /* Initialize may_move_cost and friends for mode M. */ |
260 void | 192 void |
261 init_move_cost (enum machine_mode m) | 193 init_move_cost (enum machine_mode m) |
272 int cost; | 204 int cost; |
273 if (!contains_reg_of_mode[j][m]) | 205 if (!contains_reg_of_mode[j][m]) |
274 cost = 65535; | 206 cost = 65535; |
275 else | 207 else |
276 { | 208 { |
277 cost = REGISTER_MOVE_COST (m, (enum reg_class) i, | 209 cost = register_move_cost (m, (enum reg_class) i, |
278 (enum reg_class) j); | 210 (enum reg_class) j); |
279 gcc_assert (cost < 65535); | 211 gcc_assert (cost < 65535); |
280 } | 212 } |
281 all_match &= (last_move_cost[i][j] == cost); | 213 all_match &= (last_move_cost[i][j] == cost); |
282 last_move_cost[i][j] = cost; | 214 last_move_cost[i][j] = cost; |
407 #ifdef REG_ALLOC_ORDER | 339 #ifdef REG_ALLOC_ORDER |
408 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) | 340 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) |
409 inv_reg_alloc_order[reg_alloc_order[i]] = i; | 341 inv_reg_alloc_order[reg_alloc_order[i]] = i; |
410 #endif | 342 #endif |
411 | 343 |
412 /* This macro allows the fixed or call-used registers | 344 /* Let the target tweak things if necessary. */ |
413 and the register classes to depend on target flags. */ | 345 |
414 | 346 targetm.conditional_register_usage (); |
415 #ifdef CONDITIONAL_REGISTER_USAGE | |
416 CONDITIONAL_REGISTER_USAGE; | |
417 #endif | |
418 | 347 |
419 /* Compute number of hard regs in each class. */ | 348 /* Compute number of hard regs in each class. */ |
420 | 349 |
421 memset (reg_class_size, 0, sizeof reg_class_size); | 350 memset (reg_class_size, 0, sizeof reg_class_size); |
422 for (i = 0; i < N_REG_CLASSES; i++) | 351 for (i = 0; i < N_REG_CLASSES; i++) |
423 for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) | 352 { |
424 if (TEST_HARD_REG_BIT (reg_class_contents[i], j)) | 353 bool any_nonfixed = false; |
425 reg_class_size[i]++; | 354 for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) |
355 if (TEST_HARD_REG_BIT (reg_class_contents[i], j)) | |
356 { | |
357 reg_class_size[i]++; | |
358 if (!fixed_regs[j]) | |
359 any_nonfixed = true; | |
360 } | |
361 class_only_fixed_regs[i] = !any_nonfixed; | |
362 } | |
426 | 363 |
427 /* Initialize the table of subunions. | 364 /* Initialize the table of subunions. |
428 reg_class_subunion[I][J] gets the largest-numbered reg-class | 365 reg_class_subunion[I][J] gets the largest-numbered reg-class |
429 that is contained in the union of classes I and J. */ | 366 that is contained in the union of classes I and J. */ |
430 | 367 |
528 SET_HARD_REG_BIT (call_used_reg_set, i); | 465 SET_HARD_REG_BIT (call_used_reg_set, i); |
529 | 466 |
530 /* There are a couple of fixed registers that we know are safe to | 467 /* There are a couple of fixed registers that we know are safe to |
531 exclude from being clobbered by calls: | 468 exclude from being clobbered by calls: |
532 | 469 |
533 The frame pointer is always preserved across calls. The arg pointer | 470 The frame pointer is always preserved across calls. The arg |
534 is if it is fixed. The stack pointer usually is, unless | 471 pointer is if it is fixed. The stack pointer usually is, |
535 RETURN_POPS_ARGS, in which case an explicit CLOBBER will be present. | 472 unless TARGET_RETURN_POPS_ARGS, in which case an explicit |
536 If we are generating PIC code, the PIC offset table register is | 473 CLOBBER will be present. If we are generating PIC code, the |
537 preserved across calls, though the target can override that. */ | 474 PIC offset table register is preserved across calls, though the |
475 target can override that. */ | |
538 | 476 |
539 if (i == STACK_POINTER_REGNUM) | 477 if (i == STACK_POINTER_REGNUM) |
540 ; | 478 ; |
541 else if (global_regs[i]) | 479 else if (global_regs[i]) |
542 { | 480 { |
543 SET_HARD_REG_BIT (regs_invalidated_by_call, i); | 481 SET_HARD_REG_BIT (regs_invalidated_by_call, i); |
544 SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); | 482 SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); |
545 } | 483 } |
546 else if (i == FRAME_POINTER_REGNUM) | 484 else if (i == FRAME_POINTER_REGNUM) |
547 ; | 485 ; |
548 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM | 486 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER |
549 else if (i == HARD_FRAME_POINTER_REGNUM) | 487 else if (i == HARD_FRAME_POINTER_REGNUM) |
550 ; | 488 ; |
551 #endif | 489 #endif |
552 #if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM | 490 #if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM |
553 else if (i == ARG_POINTER_REGNUM && fixed_regs[i]) | 491 else if (i == ARG_POINTER_REGNUM && fixed_regs[i]) |
554 ; | 492 ; |
555 #endif | 493 #endif |
556 #ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED | 494 else if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED |
557 else if (i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i]) | 495 && i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i]) |
558 ; | 496 ; |
559 #endif | |
560 else if (CALL_REALLY_USED_REGNO_P (i)) | 497 else if (CALL_REALLY_USED_REGNO_P (i)) |
561 { | 498 { |
562 SET_HARD_REG_BIT (regs_invalidated_by_call, i); | 499 SET_HARD_REG_BIT (regs_invalidated_by_call, i); |
563 SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); | 500 SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); |
564 } | 501 } |
680 for (i = 0; i < MAX_MACHINE_MODE; i++) | 617 for (i = 0; i < MAX_MACHINE_MODE; i++) |
681 top_of_stack[i] = gen_rtx_MEM ((enum machine_mode) i, stack_pointer_rtx); | 618 top_of_stack[i] = gen_rtx_MEM ((enum machine_mode) i, stack_pointer_rtx); |
682 } | 619 } |
683 | 620 |
684 | 621 |
622 /* Compute cost of moving data from a register of class FROM to one of | |
623 TO, using MODE. */ | |
624 | |
625 int | |
626 register_move_cost (enum machine_mode mode, reg_class_t from, reg_class_t to) | |
627 { | |
628 return targetm.register_move_cost (mode, from, to); | |
629 } | |
630 | |
631 /* Compute cost of moving registers to/from memory. */ | |
632 int | |
633 memory_move_cost (enum machine_mode mode, enum reg_class rclass, bool in) | |
634 { | |
635 return targetm.memory_move_cost (mode, rclass, in); | |
636 } | |
637 | |
685 /* Compute extra cost of moving registers to/from memory due to reloads. | 638 /* Compute extra cost of moving registers to/from memory due to reloads. |
686 Only needed if secondary reloads are required for memory moves. */ | 639 Only needed if secondary reloads are required for memory moves. */ |
687 int | 640 int |
688 memory_move_secondary_cost (enum machine_mode mode, enum reg_class rclass, | 641 memory_move_secondary_cost (enum machine_mode mode, reg_class_t rclass, |
689 int in) | 642 bool in) |
690 { | 643 { |
691 enum reg_class altclass; | 644 reg_class_t altclass; |
692 int partial_cost = 0; | 645 int partial_cost = 0; |
693 /* We need a memory reference to feed to SECONDARY... macros. */ | 646 /* We need a memory reference to feed to SECONDARY... macros. */ |
694 /* mem may be unused even if the SECONDARY_ macros are defined. */ | 647 /* mem may be unused even if the SECONDARY_ macros are defined. */ |
695 rtx mem ATTRIBUTE_UNUSED = top_of_stack[(int) mode]; | 648 rtx mem ATTRIBUTE_UNUSED = top_of_stack[(int) mode]; |
696 | 649 |
698 | 651 |
699 if (altclass == NO_REGS) | 652 if (altclass == NO_REGS) |
700 return 0; | 653 return 0; |
701 | 654 |
702 if (in) | 655 if (in) |
703 partial_cost = REGISTER_MOVE_COST (mode, altclass, rclass); | 656 partial_cost = register_move_cost (mode, altclass, rclass); |
704 else | 657 else |
705 partial_cost = REGISTER_MOVE_COST (mode, rclass, altclass); | 658 partial_cost = register_move_cost (mode, rclass, altclass); |
706 | 659 |
707 if (rclass == altclass) | 660 if (rclass == altclass) |
708 /* This isn't simply a copy-to-temporary situation. Can't guess | 661 /* This isn't simply a copy-to-temporary situation. Can't guess |
709 what it is, so MEMORY_MOVE_COST really ought not to be calling | 662 what it is, so TARGET_MEMORY_MOVE_COST really ought not to be |
710 here in that case. | 663 calling here in that case. |
711 | 664 |
712 I'm tempted to put in an assert here, but returning this will | 665 I'm tempted to put in an assert here, but returning this will |
713 probably only give poor estimates, which is what we would've | 666 probably only give poor estimates, which is what we would've |
714 had before this code anyways. */ | 667 had before this code anyways. */ |
715 return partial_cost; | 668 return partial_cost; |
796 call-used register if CALL_USED. */ | 749 call-used register if CALL_USED. */ |
797 void | 750 void |
798 fix_register (const char *name, int fixed, int call_used) | 751 fix_register (const char *name, int fixed, int call_used) |
799 { | 752 { |
800 int i; | 753 int i; |
754 int reg, nregs; | |
801 | 755 |
802 /* Decode the name and update the primary form of | 756 /* Decode the name and update the primary form of |
803 the register info. */ | 757 the register info. */ |
804 | 758 |
805 if ((i = decode_reg_name (name)) >= 0) | 759 if ((reg = decode_reg_name_and_count (name, &nregs)) >= 0) |
806 { | 760 { |
807 if ((i == STACK_POINTER_REGNUM | 761 gcc_assert (nregs >= 1); |
762 for (i = reg; i < reg + nregs; i++) | |
763 { | |
764 if ((i == STACK_POINTER_REGNUM | |
808 #ifdef HARD_FRAME_POINTER_REGNUM | 765 #ifdef HARD_FRAME_POINTER_REGNUM |
809 || i == HARD_FRAME_POINTER_REGNUM | 766 || i == HARD_FRAME_POINTER_REGNUM |
810 #else | 767 #else |
811 || i == FRAME_POINTER_REGNUM | 768 || i == FRAME_POINTER_REGNUM |
812 #endif | 769 #endif |
813 ) | 770 ) |
814 && (fixed == 0 || call_used == 0)) | 771 && (fixed == 0 || call_used == 0)) |
815 { | 772 { |
816 static const char * const what_option[2][2] = { | 773 switch (fixed) |
817 { "call-saved", "call-used" }, | 774 { |
818 { "no-such-option", "fixed" }}; | 775 case 0: |
819 | 776 switch (call_used) |
820 error ("can't use '%s' as a %s register", name, | 777 { |
821 what_option[fixed][call_used]); | 778 case 0: |
779 error ("can%'t use %qs as a call-saved register", name); | |
780 break; | |
781 | |
782 case 1: | |
783 error ("can%'t use %qs as a call-used register", name); | |
784 break; | |
785 | |
786 default: | |
787 gcc_unreachable (); | |
788 } | |
789 break; | |
790 | |
791 case 1: | |
792 switch (call_used) | |
793 { | |
794 case 1: | |
795 error ("can%'t use %qs as a fixed register", name); | |
796 break; | |
797 | |
798 case 0: | |
799 default: | |
800 gcc_unreachable (); | |
801 } | |
802 break; | |
803 | |
804 default: | |
805 gcc_unreachable (); | |
806 } | |
807 } | |
808 else | |
809 { | |
810 fixed_regs[i] = fixed; | |
811 call_used_regs[i] = call_used; | |
812 #ifdef CALL_REALLY_USED_REGISTERS | |
813 if (fixed == 0) | |
814 call_really_used_regs[i] = call_used; | |
815 #endif | |
816 } | |
822 } | 817 } |
823 else | |
824 { | |
825 fixed_regs[i] = fixed; | |
826 call_used_regs[i] = call_used; | |
827 #ifdef CALL_REALLY_USED_REGISTERS | |
828 if (fixed == 0) | |
829 call_really_used_regs[i] = call_used; | |
830 #endif | |
831 } | |
832 } | 818 } |
833 else | 819 else |
834 { | 820 { |
835 warning (0, "unknown register name: %s", name); | 821 warning (0, "unknown register name: %s", name); |
836 } | 822 } |
838 | 824 |
839 /* Mark register number I as global. */ | 825 /* Mark register number I as global. */ |
840 void | 826 void |
841 globalize_reg (int i) | 827 globalize_reg (int i) |
842 { | 828 { |
829 #ifdef STACK_REGS | |
830 if (IN_RANGE (i, FIRST_STACK_REG, LAST_STACK_REG)) | |
831 { | |
832 error ("stack register used for global register variable"); | |
833 return; | |
834 } | |
835 #endif | |
836 | |
843 if (fixed_regs[i] == 0 && no_global_reg_vars) | 837 if (fixed_regs[i] == 0 && no_global_reg_vars) |
844 error ("global register variable follows a function definition"); | 838 error ("global register variable follows a function definition"); |
845 | 839 |
846 if (global_regs[i]) | 840 if (global_regs[i]) |
847 { | 841 { |
1019 NULL, /* gate */ | 1013 NULL, /* gate */ |
1020 reginfo_init, /* execute */ | 1014 reginfo_init, /* execute */ |
1021 NULL, /* sub */ | 1015 NULL, /* sub */ |
1022 NULL, /* next */ | 1016 NULL, /* next */ |
1023 0, /* static_pass_number */ | 1017 0, /* static_pass_number */ |
1024 TV_NONE, /* tv_id */ | 1018 TV_NONE, /* tv_id */ |
1025 0, /* properties_required */ | 1019 0, /* properties_required */ |
1026 0, /* properties_provided */ | 1020 0, /* properties_provided */ |
1027 0, /* properties_destroyed */ | 1021 0, /* properties_destroyed */ |
1028 0, /* todo_flags_start */ | 1022 0, /* todo_flags_start */ |
1029 0 /* todo_flags_finish */ | 1023 0 /* todo_flags_finish */ |
1213 | 1207 |
1214 | 1208 |
1215 /* Return nonzero if C1 is a subset of C2, i.e., if every register in C1 | 1209 /* Return nonzero if C1 is a subset of C2, i.e., if every register in C1 |
1216 is also in C2. */ | 1210 is also in C2. */ |
1217 int | 1211 int |
1218 reg_class_subset_p (enum reg_class c1, enum reg_class c2) | 1212 reg_class_subset_p (reg_class_t c1, reg_class_t c2) |
1219 { | 1213 { |
1220 return (c1 == c2 | 1214 return (c1 == c2 |
1221 || c2 == ALL_REGS | 1215 || c2 == ALL_REGS |
1222 || hard_reg_set_subset_p (reg_class_contents[(int) c1], | 1216 || hard_reg_set_subset_p (reg_class_contents[(int) c1], |
1223 reg_class_contents[(int) c2])); | 1217 reg_class_contents[(int) c2])); |
1224 } | 1218 } |
1225 | 1219 |
1226 /* Return nonzero if there is a register that is in both C1 and C2. */ | 1220 /* Return nonzero if there is a register that is in both C1 and C2. */ |
1227 int | 1221 int |
1228 reg_classes_intersect_p (enum reg_class c1, enum reg_class c2) | 1222 reg_classes_intersect_p (reg_class_t c1, reg_class_t c2) |
1229 { | 1223 { |
1230 return (c1 == c2 | 1224 return (c1 == c2 |
1231 || c1 == ALL_REGS | 1225 || c1 == ALL_REGS |
1232 || c2 == ALL_REGS | 1226 || c2 == ALL_REGS |
1233 || hard_reg_set_intersect_p (reg_class_contents[(int) c1], | 1227 || hard_reg_set_intersect_p (reg_class_contents[(int) c1], |
1239 /* Passes for keeping and updating info about modes of registers | 1233 /* Passes for keeping and updating info about modes of registers |
1240 inside subregisters. */ | 1234 inside subregisters. */ |
1241 | 1235 |
1242 #ifdef CANNOT_CHANGE_MODE_CLASS | 1236 #ifdef CANNOT_CHANGE_MODE_CLASS |
1243 | 1237 |
1244 struct subregs_of_mode_node | 1238 static bitmap invalid_mode_changes; |
1245 { | |
1246 unsigned int block; | |
1247 unsigned char modes[MAX_MACHINE_MODE]; | |
1248 }; | |
1249 | |
1250 static htab_t subregs_of_mode; | |
1251 | |
1252 static hashval_t | |
1253 som_hash (const void *x) | |
1254 { | |
1255 const struct subregs_of_mode_node *const a = | |
1256 (const struct subregs_of_mode_node *) x; | |
1257 return a->block; | |
1258 } | |
1259 | |
1260 static int | |
1261 som_eq (const void *x, const void *y) | |
1262 { | |
1263 const struct subregs_of_mode_node *const a = | |
1264 (const struct subregs_of_mode_node *) x; | |
1265 const struct subregs_of_mode_node *const b = | |
1266 (const struct subregs_of_mode_node *) y; | |
1267 return a->block == b->block; | |
1268 } | |
1269 | 1239 |
1270 static void | 1240 static void |
1271 record_subregs_of_mode (rtx subreg) | 1241 record_subregs_of_mode (rtx subreg, bitmap subregs_of_mode) |
1272 { | 1242 { |
1273 struct subregs_of_mode_node dummy, *node; | |
1274 enum machine_mode mode; | 1243 enum machine_mode mode; |
1275 unsigned int regno; | 1244 unsigned int regno; |
1276 void **slot; | |
1277 | 1245 |
1278 if (!REG_P (SUBREG_REG (subreg))) | 1246 if (!REG_P (SUBREG_REG (subreg))) |
1279 return; | 1247 return; |
1280 | 1248 |
1281 regno = REGNO (SUBREG_REG (subreg)); | 1249 regno = REGNO (SUBREG_REG (subreg)); |
1282 mode = GET_MODE (subreg); | 1250 mode = GET_MODE (subreg); |
1283 | 1251 |
1284 if (regno < FIRST_PSEUDO_REGISTER) | 1252 if (regno < FIRST_PSEUDO_REGISTER) |
1285 return; | 1253 return; |
1286 | 1254 |
1287 dummy.block = regno & -8; | 1255 if (bitmap_set_bit (subregs_of_mode, |
1288 slot = htab_find_slot_with_hash (subregs_of_mode, &dummy, | 1256 regno * NUM_MACHINE_MODES + (unsigned int) mode)) |
1289 dummy.block, INSERT); | 1257 { |
1290 node = (struct subregs_of_mode_node *) *slot; | 1258 unsigned int rclass; |
1291 if (node == NULL) | 1259 for (rclass = 0; rclass < N_REG_CLASSES; rclass++) |
1292 { | 1260 if (!bitmap_bit_p (invalid_mode_changes, |
1293 node = XCNEW (struct subregs_of_mode_node); | 1261 regno * N_REG_CLASSES + rclass) |
1294 node->block = regno & -8; | 1262 && CANNOT_CHANGE_MODE_CLASS (PSEUDO_REGNO_MODE (regno), |
1295 *slot = node; | 1263 mode, (enum reg_class) rclass)) |
1296 } | 1264 bitmap_set_bit (invalid_mode_changes, |
1297 | 1265 regno * N_REG_CLASSES + rclass); |
1298 node->modes[mode] |= 1 << (regno & 7); | 1266 } |
1299 } | 1267 } |
1300 | 1268 |
1301 /* Call record_subregs_of_mode for all the subregs in X. */ | 1269 /* Call record_subregs_of_mode for all the subregs in X. */ |
1302 static void | 1270 static void |
1303 find_subregs_of_mode (rtx x) | 1271 find_subregs_of_mode (rtx x, bitmap subregs_of_mode) |
1304 { | 1272 { |
1305 enum rtx_code code = GET_CODE (x); | 1273 enum rtx_code code = GET_CODE (x); |
1306 const char * const fmt = GET_RTX_FORMAT (code); | 1274 const char * const fmt = GET_RTX_FORMAT (code); |
1307 int i; | 1275 int i; |
1308 | 1276 |
1309 if (code == SUBREG) | 1277 if (code == SUBREG) |
1310 record_subregs_of_mode (x); | 1278 record_subregs_of_mode (x, subregs_of_mode); |
1311 | 1279 |
1312 /* Time for some deep diving. */ | 1280 /* Time for some deep diving. */ |
1313 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | 1281 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) |
1314 { | 1282 { |
1315 if (fmt[i] == 'e') | 1283 if (fmt[i] == 'e') |
1316 find_subregs_of_mode (XEXP (x, i)); | 1284 find_subregs_of_mode (XEXP (x, i), subregs_of_mode); |
1317 else if (fmt[i] == 'E') | 1285 else if (fmt[i] == 'E') |
1318 { | 1286 { |
1319 int j; | 1287 int j; |
1320 for (j = XVECLEN (x, i) - 1; j >= 0; j--) | 1288 for (j = XVECLEN (x, i) - 1; j >= 0; j--) |
1321 find_subregs_of_mode (XVECEXP (x, i, j)); | 1289 find_subregs_of_mode (XVECEXP (x, i, j), subregs_of_mode); |
1322 } | 1290 } |
1323 } | 1291 } |
1324 } | 1292 } |
1325 | 1293 |
1326 void | 1294 void |
1327 init_subregs_of_mode (void) | 1295 init_subregs_of_mode (void) |
1328 { | 1296 { |
1329 basic_block bb; | 1297 basic_block bb; |
1330 rtx insn; | 1298 rtx insn; |
1331 | 1299 bitmap_obstack srom_obstack; |
1332 if (subregs_of_mode) | 1300 bitmap subregs_of_mode; |
1333 htab_empty (subregs_of_mode); | 1301 |
1334 else | 1302 gcc_assert (invalid_mode_changes == NULL); |
1335 subregs_of_mode = htab_create (100, som_hash, som_eq, free); | 1303 invalid_mode_changes = BITMAP_ALLOC (NULL); |
1304 bitmap_obstack_initialize (&srom_obstack); | |
1305 subregs_of_mode = BITMAP_ALLOC (&srom_obstack); | |
1336 | 1306 |
1337 FOR_EACH_BB (bb) | 1307 FOR_EACH_BB (bb) |
1338 FOR_BB_INSNS (bb, insn) | 1308 FOR_BB_INSNS (bb, insn) |
1339 if (INSN_P (insn)) | 1309 if (NONDEBUG_INSN_P (insn)) |
1340 find_subregs_of_mode (PATTERN (insn)); | 1310 find_subregs_of_mode (PATTERN (insn), subregs_of_mode); |
1311 | |
1312 BITMAP_FREE (subregs_of_mode); | |
1313 bitmap_obstack_release (&srom_obstack); | |
1341 } | 1314 } |
1342 | 1315 |
1343 /* Return 1 if REGNO has had an invalid mode change in CLASS from FROM | 1316 /* Return 1 if REGNO has had an invalid mode change in CLASS from FROM |
1344 mode. */ | 1317 mode. */ |
1345 bool | 1318 bool |
1346 invalid_mode_change_p (unsigned int regno, | 1319 invalid_mode_change_p (unsigned int regno, |
1347 enum reg_class rclass ATTRIBUTE_UNUSED, | 1320 enum reg_class rclass) |
1348 enum machine_mode from) | 1321 { |
1349 { | 1322 return bitmap_bit_p (invalid_mode_changes, |
1350 struct subregs_of_mode_node dummy, *node; | 1323 regno * N_REG_CLASSES + (unsigned) rclass); |
1351 unsigned int to; | |
1352 unsigned char mask; | |
1353 | |
1354 gcc_assert (subregs_of_mode); | |
1355 dummy.block = regno & -8; | |
1356 node = (struct subregs_of_mode_node *) | |
1357 htab_find_with_hash (subregs_of_mode, &dummy, dummy.block); | |
1358 if (node == NULL) | |
1359 return false; | |
1360 | |
1361 mask = 1 << (regno & 7); | |
1362 for (to = VOIDmode; to < NUM_MACHINE_MODES; to++) | |
1363 if (node->modes[to] & mask) | |
1364 if (CANNOT_CHANGE_MODE_CLASS (from, (enum machine_mode) to, rclass)) | |
1365 return true; | |
1366 | |
1367 return false; | |
1368 } | 1324 } |
1369 | 1325 |
1370 void | 1326 void |
1371 finish_subregs_of_mode (void) | 1327 finish_subregs_of_mode (void) |
1372 { | 1328 { |
1373 htab_delete (subregs_of_mode); | 1329 BITMAP_FREE (invalid_mode_changes); |
1374 subregs_of_mode = 0; | |
1375 } | 1330 } |
1376 #else | 1331 #else |
1377 void | 1332 void |
1378 init_subregs_of_mode (void) | 1333 init_subregs_of_mode (void) |
1379 { | 1334 { |
1382 finish_subregs_of_mode (void) | 1337 finish_subregs_of_mode (void) |
1383 { | 1338 { |
1384 } | 1339 } |
1385 | 1340 |
1386 #endif /* CANNOT_CHANGE_MODE_CLASS */ | 1341 #endif /* CANNOT_CHANGE_MODE_CLASS */ |
1387 | |
1388 #include "gt-reginfo.h" |