]>
Commit | Line | Data |
---|---|---|
c3bcc836 | 1 | /* Define per-register tables for data flow info and register allocation. |
9311a396 | 2 | Copyright (C) 1987, 93-99, 2000 Free Software Foundation, Inc. |
c3bcc836 RK |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e99215a3 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
c3bcc836 RK |
20 | |
21 | ||
6feacd09 | 22 | #include "varray.h" |
c3bcc836 RK |
23 | |
24 | #define REG_BYTES(R) mode_size[(int) GET_MODE (R)] | |
25 | ||
26 | /* Get the number of consecutive hard regs required to hold the REG rtx R. | |
27 | When something may be an explicit hard reg, REG_SIZE is the only | |
28 | valid way to get this value. You cannot get it from the regno. */ | |
29 | ||
30 | #define REG_SIZE(R) \ | |
31 | ((mode_size[(int) GET_MODE (R)] + UNITS_PER_WORD - 1) / UNITS_PER_WORD) | |
32 | ||
31031edd JL |
33 | #ifndef SMALL_REGISTER_CLASSES |
34 | #define SMALL_REGISTER_CLASSES 0 | |
35 | #endif | |
36 | ||
c3bcc836 RK |
37 | /* Maximum register number used in this function, plus one. */ |
38 | ||
39 | extern int max_regno; | |
40 | ||
b1f21e0a | 41 | /* Register information indexed by register number */ |
d4b60170 RK |
42 | typedef struct reg_info_def |
43 | { /* fields set by reg_scan */ | |
b1f21e0a MM |
44 | int first_uid; /* UID of first insn to use (REG n) */ |
45 | int last_uid; /* UID of last insn to use (REG n) */ | |
46 | int last_note_uid; /* UID of last note to use (REG n) */ | |
47 | ||
d4b60170 | 48 | /* fields set by reg_scan & flow_analysis */ |
b1f21e0a MM |
49 | int sets; /* # of times (REG n) is set */ |
50 | ||
51 | /* fields set by flow_analysis */ | |
52 | int refs; /* # of times (REG n) is used or set */ | |
53 | int deaths; /* # of times (REG n) dies */ | |
54 | int live_length; /* # of instructions (REG n) is live */ | |
55 | int calls_crossed; /* # of calls (REG n) is live across */ | |
56 | int basic_block; /* # of basic blocks (REG n) is used in */ | |
57 | char changes_size; /* whether (SUBREG (REG n)) changes size */ | |
58 | } reg_info; | |
59 | ||
6feacd09 | 60 | extern varray_type reg_n_info; |
b1f21e0a | 61 | |
a494747c MM |
62 | extern unsigned int reg_n_max; |
63 | ||
c3bcc836 RK |
64 | /* Indexed by n, gives number of times (REG n) is used or set. |
65 | References within loops may be counted more times. */ | |
66 | ||
6feacd09 | 67 | #define REG_N_REFS(N) (VARRAY_REG (reg_n_info, N)->refs) |
c3bcc836 | 68 | |
b1f21e0a MM |
69 | /* Indexed by n, gives number of times (REG n) is set. |
70 | ??? both regscan and flow allocate space for this. We should settle | |
71 | on just copy. */ | |
c3bcc836 | 72 | |
6feacd09 | 73 | #define REG_N_SETS(N) (VARRAY_REG (reg_n_info, N)->sets) |
c3bcc836 RK |
74 | |
75 | /* Indexed by N, gives number of insns in which register N dies. | |
76 | Note that if register N is live around loops, it can die | |
77 | in transitions between basic blocks, and that is not counted here. | |
78 | So this is only a reliable indicator of how many regions of life there are | |
79 | for registers that are contained in one basic block. */ | |
80 | ||
6feacd09 | 81 | #define REG_N_DEATHS(N) (VARRAY_REG (reg_n_info, N)->deaths) |
c3bcc836 | 82 | |
9faa82d8 | 83 | /* Indexed by N; says whether a pseudo register N was ever used |
ffceec83 RK |
84 | within a SUBREG that changes the size of the reg. Some machines prohibit |
85 | such objects to be in certain (usually floating-point) registers. */ | |
86 | ||
6feacd09 | 87 | #define REG_CHANGES_SIZE(N) (VARRAY_REG (reg_n_info, N)->changes_size) |
ffceec83 | 88 | |
c3bcc836 RK |
89 | /* Get the number of consecutive words required to hold pseudo-reg N. */ |
90 | ||
91 | #define PSEUDO_REGNO_SIZE(N) \ | |
92 | ((GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) + UNITS_PER_WORD - 1) \ | |
93 | / UNITS_PER_WORD) | |
94 | ||
95 | /* Get the number of bytes required to hold pseudo-reg N. */ | |
96 | ||
97 | #define PSEUDO_REGNO_BYTES(N) \ | |
98 | GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) | |
99 | ||
100 | /* Get the machine mode of pseudo-reg N. */ | |
101 | ||
102 | #define PSEUDO_REGNO_MODE(N) GET_MODE (regno_reg_rtx[N]) | |
103 | ||
104 | /* Indexed by N, gives number of CALL_INSNS across which (REG n) is live. */ | |
105 | ||
6feacd09 | 106 | #define REG_N_CALLS_CROSSED(N) (VARRAY_REG (reg_n_info, N)->calls_crossed) |
c3bcc836 RK |
107 | |
108 | /* Total number of instructions at which (REG n) is live. | |
109 | The larger this is, the less priority (REG n) gets for | |
110 | allocation in a hard register (in global-alloc). | |
111 | This is set in flow.c and remains valid for the rest of the compilation | |
112 | of the function; it is used to control register allocation. | |
113 | ||
114 | local-alloc.c may alter this number to change the priority. | |
115 | ||
116 | Negative values are special. | |
117 | -1 is used to mark a pseudo reg which has a constant or memory equivalent | |
118 | and is used infrequently enough that it should not get a hard register. | |
119 | -2 is used to mark a pseudo reg for a parameter, when a frame pointer | |
cfb2c0b1 | 120 | is not required. global.c makes an allocno for this but does |
c3bcc836 RK |
121 | not try to assign a hard register to it. */ |
122 | ||
6feacd09 | 123 | #define REG_LIVE_LENGTH(N) (VARRAY_REG (reg_n_info, N)->live_length) |
c3bcc836 RK |
124 | |
125 | /* Vector of substitutions of register numbers, | |
b1f21e0a MM |
126 | used to map pseudo regs into hardware regs. |
127 | ||
128 | This can't be folded into reg_n_info without changing all of the | |
129 | machine dependent directories, since the reload functions | |
39379e67 | 130 | in the machine dependent files access it. */ |
c3bcc836 RK |
131 | |
132 | extern short *reg_renumber; | |
133 | ||
134 | /* Vector indexed by hardware reg | |
135 | saying whether that reg is ever used. */ | |
136 | ||
137 | extern char regs_ever_live[FIRST_PSEUDO_REGISTER]; | |
138 | ||
139 | /* Vector indexed by hardware reg giving its name. */ | |
140 | ||
99f44eba | 141 | extern const char *reg_names[FIRST_PSEUDO_REGISTER]; |
c3bcc836 | 142 | |
04569dfb DE |
143 | /* For each hard register, the widest mode object that it can contain. |
144 | This will be a MODE_INT mode if the register can hold integers. Otherwise | |
145 | it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the | |
146 | register. */ | |
147 | ||
148 | extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER]; | |
149 | ||
c3bcc836 RK |
150 | /* Vector indexed by regno; gives uid of first insn using that reg. |
151 | This is computed by reg_scan for use by cse and loop. | |
152 | It is sometimes adjusted for subsequent changes during loop, | |
153 | but not adjusted by cse even if cse invalidates it. */ | |
154 | ||
6feacd09 | 155 | #define REGNO_FIRST_UID(N) (VARRAY_REG (reg_n_info, N)->first_uid) |
c3bcc836 RK |
156 | |
157 | /* Vector indexed by regno; gives uid of last insn using that reg. | |
158 | This is computed by reg_scan for use by cse and loop. | |
159 | It is sometimes adjusted for subsequent changes during loop, | |
160 | but not adjusted by cse even if cse invalidates it. | |
161 | This is harmless since cse won't scan through a loop end. */ | |
162 | ||
6feacd09 | 163 | #define REGNO_LAST_UID(N) (VARRAY_REG (reg_n_info, N)->last_uid) |
c3bcc836 | 164 | |
2cb547d8 RS |
165 | /* Similar, but includes insns that mention the reg in their notes. */ |
166 | ||
6feacd09 | 167 | #define REGNO_LAST_NOTE_UID(N) (VARRAY_REG (reg_n_info, N)->last_note_uid) |
2cb547d8 | 168 | |
c3bcc836 RK |
169 | /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers |
170 | that have to go in the same hard reg. */ | |
171 | extern rtx regs_may_share; | |
172 | ||
c3bcc836 RK |
173 | /* Flag set by local-alloc or global-alloc if they decide to allocate |
174 | something in a call-clobbered register. */ | |
175 | ||
176 | extern int caller_save_needed; | |
177 | ||
178 | /* Predicate to decide whether to give a hard reg to a pseudo which | |
179 | is referenced REFS times and would need to be saved and restored | |
180 | around a call CALLS times. */ | |
181 | ||
182 | #ifndef CALLER_SAVE_PROFITABLE | |
183 | #define CALLER_SAVE_PROFITABLE(REFS, CALLS) (4 * (CALLS) < (REFS)) | |
184 | #endif | |
a65b6597 | 185 | |
6cad67d2 JL |
186 | /* On most machines a register class is likely to be spilled if it |
187 | only has one register. */ | |
188 | #ifndef CLASS_LIKELY_SPILLED_P | |
189 | #define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1) | |
190 | #endif | |
191 | ||
8d5c8167 JL |
192 | /* Select a register mode required for caller save of hard regno REGNO. */ |
193 | #ifndef HARD_REGNO_CALLER_SAVE_MODE | |
194 | #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS) \ | |
195 | choose_hard_reg_mode (REGNO, NREGS) | |
196 | #endif | |
197 | ||
1e326708 MH |
198 | /* Registers that get partially clobbered by a call in a given mode. |
199 | These must not be call used registers. */ | |
200 | #ifndef HARD_REGNO_CALL_PART_CLOBBERED | |
201 | #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) 0 | |
202 | #endif | |
203 | ||
b1f21e0a | 204 | /* Allocate reg_n_info tables */ |
13536812 | 205 | extern void allocate_reg_info PARAMS ((size_t, int, int)); |