Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* Sets (bit vectors) of hard registers, and operations on them. |
2 | Copyright (C) 1987 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GNU CC | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 1, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | ||
21 | /* Define the type of a set of hard registers. */ | |
22 | ||
23 | /* If HARD_REG_SET is a macro, its definition is a scalar type | |
24 | that has enough bits for all the target machine's hard registers. | |
25 | Otherwise, it is a typedef for a suitable array of longs, | |
26 | and HARD_REG_SET_LONGS is how many. */ | |
27 | ||
28 | #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_CHAR | |
29 | #define HARD_REG_SET char | |
30 | #else | |
31 | #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_SHORT | |
32 | #define HARD_REG_SET short | |
33 | #else | |
34 | #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_INT | |
35 | #define HARD_REG_SET int | |
36 | #else | |
37 | #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_LONG | |
38 | #define HARD_REG_SET long | |
39 | #else | |
40 | #define HARD_REG_SET_LONGS \ | |
41 | ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_LONG - 1) / HOST_BITS_PER_LONG) | |
42 | typedef long HARD_REG_SET[HARD_REG_SET_LONGS]; | |
43 | #endif | |
44 | #endif | |
45 | #endif | |
46 | #endif | |
47 | ||
48 | /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT | |
49 | to set, clear or test one bit in a hard reg set of type HARD_REG_SET. | |
50 | All three take two arguments: the set and the register number. | |
51 | ||
52 | In the case where sets are arrays of longs, the first argument | |
53 | is actually a pointer to a long. | |
54 | ||
55 | Define two macros for initializing a set: | |
56 | CLEAR_HARD_REG_SET and SET_HARD_REG_SET. | |
57 | These take just one argument. | |
58 | ||
59 | Also define macros for copying hard reg sets: | |
60 | COPY_HARD_REG_SET and COMPL_HARD_REG_SET. | |
61 | These take two arguments TO and FROM; they read from FROM | |
62 | and store into TO. COMPL_HARD_REG_SET complements each bit. | |
63 | ||
64 | Also define macros for combining hard reg sets: | |
65 | IOR_HARD_REG_SET and AND_HARD_REG_SET. | |
66 | These take two arguments TO and FROM; they read from FROM | |
67 | and combine bitwise into TO. Define also two variants | |
68 | IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET | |
69 | which use the complement of the set FROM. | |
70 | ||
71 | Also define GO_IF_HARD_REG_SUBSET (X, Y, TO): | |
72 | if X is a subset of Y, go to TO. | |
73 | */ | |
74 | ||
75 | #ifdef HARD_REG_SET | |
76 | ||
77 | #define SET_HARD_REG_BIT(SET, BIT) \ | |
78 | ((SET) |= 1 << (BIT)) | |
79 | #define CLEAR_HARD_REG_BIT(SET, BIT) \ | |
80 | ((SET) &= ~(1 << (BIT))) | |
81 | #define TEST_HARD_REG_BIT(SET, BIT) \ | |
82 | ((SET) & (1 << (BIT))) | |
83 | ||
84 | #define CLEAR_HARD_REG_SET(TO) ((TO) = 0) | |
85 | #define SET_HARD_REG_SET(TO) ((TO) = -1) | |
86 | ||
87 | #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM)) | |
88 | #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM)) | |
89 | ||
90 | #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM)) | |
91 | #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM)) | |
92 | #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM)) | |
93 | #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM)) | |
94 | ||
95 | #define GO_IF_HARD_REG_SUBSET(X,Y,TO) if (0 == ((X) & ~(Y))) goto TO | |
96 | #else | |
97 | ||
98 | #define SET_HARD_REG_BIT(SET, BIT) \ | |
99 | ((SET)[(BIT) / HOST_BITS_PER_LONG] |= 1 << ((BIT) % HOST_BITS_PER_LONG)) | |
100 | #define CLEAR_HARD_REG_BIT(SET, BIT) \ | |
101 | ((SET)[(BIT) / HOST_BITS_PER_LONG] &= ~(1 << ((BIT) % HOST_BITS_PER_LONG))) | |
102 | #define TEST_HARD_REG_BIT(SET, BIT) \ | |
103 | ((SET)[(BIT) / HOST_BITS_PER_LONG] & (1 << ((BIT) % HOST_BITS_PER_LONG))) | |
104 | ||
105 | #define CLEAR_HARD_REG_SET(TO) \ | |
106 | do { register long *scan_tp_ = (TO); \ | |
107 | register int i; \ | |
108 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
109 | *scan_tp_++ = 0; } while (0) | |
110 | ||
111 | #define SET_HARD_REG_SET(TO) \ | |
112 | do { register long *scan_tp_ = (TO); \ | |
113 | register int i; \ | |
114 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
115 | *scan_tp_++ = -1; } while (0) | |
116 | ||
117 | #define COPY_HARD_REG_SET(TO, FROM) \ | |
118 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
119 | register int i; \ | |
120 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
121 | *scan_tp_++ = *scan_fp_++; } while (0) | |
122 | ||
123 | #define COMPL_HARD_REG_SET(TO, FROM) \ | |
124 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
125 | register int i; \ | |
126 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
127 | *scan_tp_++ = ~ *scan_fp_++; } while (0) | |
128 | ||
129 | #define AND_HARD_REG_SET(TO, FROM) \ | |
130 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
131 | register int i; \ | |
132 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
133 | *scan_tp_++ &= *scan_fp_++; } while (0) | |
134 | ||
135 | #define AND_COMPL_HARD_REG_SET(TO, FROM) \ | |
136 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
137 | register int i; \ | |
138 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
139 | *scan_tp_++ &= ~ *scan_fp_++; } while (0) | |
140 | ||
141 | #define IOR_HARD_REG_SET(TO, FROM) \ | |
142 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
143 | register int i; \ | |
144 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
145 | *scan_tp_++ |= *scan_fp_++; } while (0) | |
146 | ||
147 | #define IOR_COMPL_HARD_REG_SET(TO, FROM) \ | |
148 | do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \ | |
149 | register int i; \ | |
150 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
151 | *scan_tp_++ |= ~ *scan_fp_++; } while (0) | |
152 | ||
153 | #define GO_IF_HARD_REG_SUBSET(X,Y,TO) \ | |
154 | do { register long *scan_xp_ = (X), *scan_yp_ = (Y); \ | |
155 | register int i; \ | |
156 | for (i = 0; i < HARD_REG_SET_LONGS; i++) \ | |
157 | if (0 != (*scan_xp_++ & ~*scan_yp_++)) break; \ | |
158 | if (i == HARD_REG_SET_LONGS) goto TO; } while (0) | |
159 | ||
160 | #endif | |
161 | ||
162 | /* Define some standard sets of registers. */ | |
163 | ||
164 | /* Indexed by hard register number, contains 1 for registers | |
165 | that are fixed use (stack pointer, pc, frame pointer, etc.). | |
166 | These are the registers that cannot be used to allocate | |
167 | a pseudo reg whose life does not cross calls. */ | |
168 | ||
169 | extern char fixed_regs[FIRST_PSEUDO_REGISTER]; | |
170 | ||
171 | /* The same info as a HARD_REG_SET. */ | |
172 | ||
173 | extern HARD_REG_SET fixed_reg_set; | |
174 | ||
175 | /* Indexed by hard register number, contains 1 for registers | |
176 | that are fixed use or are clobbered by function calls. | |
177 | These are the registers that cannot be used to allocate | |
178 | a pseudo reg whose life crosses calls. */ | |
179 | ||
180 | extern char call_used_regs[FIRST_PSEUDO_REGISTER]; | |
181 | ||
182 | /* The same info as a HARD_REG_SET. */ | |
183 | ||
184 | extern HARD_REG_SET call_used_reg_set; | |
185 | ||
186 | /* Indexed by hard register number, contains 1 for registers that are | |
187 | fixed use -- i.e. in fixed_regs -- or a function value return register | |
188 | or STRUCT_VALUE_REGNUM or STATIC_CHAIN_REGNUM. These are the | |
189 | registers that cannot hold quantities across calls even if we are | |
190 | willing to save and restore them. */ | |
191 | ||
192 | extern char call_fixed_regs[FIRST_PSEUDO_REGISTER]; | |
193 | ||
194 | /* The same info as a HARD_REG_SET. */ | |
195 | ||
196 | extern HARD_REG_SET call_fixed_reg_set; | |
197 | ||
198 | /* Indexed by hard register number, contains 1 for registers | |
199 | that are being used for global register decls. | |
200 | These must be exempt from ordinary flow analysis | |
201 | and are also considered fixed. */ | |
202 | ||
203 | extern char global_regs[FIRST_PSEUDO_REGISTER]; | |
204 | ||
205 | /* Table of register numbers in the order in which to try to use them. */ | |
206 | ||
207 | extern int reg_alloc_order[FIRST_PSEUDO_REGISTER]; | |
208 | ||
209 | /* For each reg class, a HARD_REG_SET saying which registers are in it. */ | |
210 | ||
211 | extern HARD_REG_SET reg_class_contents[]; | |
212 | ||
213 | /* For each reg class, number of regs it contains. */ | |
214 | ||
215 | extern int reg_class_size[N_REG_CLASSES]; | |
216 | ||
217 | /* For each reg class, table listing all the containing classes. */ | |
218 | ||
219 | extern enum reg_class reg_class_superclasses[N_REG_CLASSES][N_REG_CLASSES]; | |
220 | ||
221 | /* For each reg class, table listing all the classes contained in it. */ | |
222 | ||
223 | extern enum reg_class reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES]; | |
224 | ||
225 | /* For each pair of reg classes, | |
226 | a largest reg class contained in their union. */ | |
227 | ||
228 | extern enum reg_class reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES]; | |
229 |