PR tree-optimization/45830
[official-gcc.git] / gcc / hard-reg-set.h
blob9823a5b34410f5af6ff81d7ba69b34c115c6a64e
1 /* Sets (bit vectors) of hard registers, and operations on them.
2 Copyright (C) 1987, 1992, 1994, 2000, 2003, 2004, 2005, 2007, 2008, 2009,
3 2010 Free Software Foundation, Inc.
5 This file is part of GCC
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_HARD_REG_SET_H
22 #define GCC_HARD_REG_SET_H
24 /* Define the type of a set of hard registers. */
26 /* HARD_REG_ELT_TYPE is a typedef of the unsigned integral type which
27 will be used for hard reg sets, either alone or in an array.
29 If HARD_REG_SET is a macro, its definition is HARD_REG_ELT_TYPE,
30 and it has enough bits to represent all the target machine's hard
31 registers. Otherwise, it is a typedef for a suitably sized array
32 of HARD_REG_ELT_TYPEs. HARD_REG_SET_LONGS is defined as how many.
34 Note that lots of code assumes that the first part of a regset is
35 the same format as a HARD_REG_SET. To help make sure this is true,
36 we only try the widest fast integer mode (HOST_WIDEST_FAST_INT)
37 instead of all the smaller types. This approach loses only if
38 there are very few registers and then only in the few cases where
39 we have an array of HARD_REG_SETs, so it needn't be as complex as
40 it used to be. */
42 typedef unsigned HOST_WIDEST_FAST_INT HARD_REG_ELT_TYPE;
44 #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_WIDEST_FAST_INT
46 #define HARD_REG_SET HARD_REG_ELT_TYPE
48 #else
50 #define HARD_REG_SET_LONGS \
51 ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_WIDEST_FAST_INT - 1) \
52 / HOST_BITS_PER_WIDEST_FAST_INT)
53 typedef HARD_REG_ELT_TYPE HARD_REG_SET[HARD_REG_SET_LONGS];
55 #endif
57 /* HARD_CONST is used to cast a constant to the appropriate type
58 for use with a HARD_REG_SET. */
60 #define HARD_CONST(X) ((HARD_REG_ELT_TYPE) (X))
62 /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT
63 to set, clear or test one bit in a hard reg set of type HARD_REG_SET.
64 All three take two arguments: the set and the register number.
66 In the case where sets are arrays of longs, the first argument
67 is actually a pointer to a long.
69 Define two macros for initializing a set:
70 CLEAR_HARD_REG_SET and SET_HARD_REG_SET.
71 These take just one argument.
73 Also define macros for copying hard reg sets:
74 COPY_HARD_REG_SET and COMPL_HARD_REG_SET.
75 These take two arguments TO and FROM; they read from FROM
76 and store into TO. COMPL_HARD_REG_SET complements each bit.
78 Also define macros for combining hard reg sets:
79 IOR_HARD_REG_SET and AND_HARD_REG_SET.
80 These take two arguments TO and FROM; they read from FROM
81 and combine bitwise into TO. Define also two variants
82 IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET
83 which use the complement of the set FROM.
85 Also define:
87 hard_reg_set_subset_p (X, Y), which returns true if X is a subset of Y.
88 hard_reg_set_equal_p (X, Y), which returns true if X and Y are equal.
89 hard_reg_set_intersect_p (X, Y), which returns true if X and Y intersect.
90 hard_reg_set_empty_p (X), which returns true if X is empty. */
92 #define UHOST_BITS_PER_WIDE_INT ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
94 #ifdef HARD_REG_SET
96 #define SET_HARD_REG_BIT(SET, BIT) \
97 ((SET) |= HARD_CONST (1) << (BIT))
98 #define CLEAR_HARD_REG_BIT(SET, BIT) \
99 ((SET) &= ~(HARD_CONST (1) << (BIT)))
100 #define TEST_HARD_REG_BIT(SET, BIT) \
101 (!!((SET) & (HARD_CONST (1) << (BIT))))
103 #define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
104 #define SET_HARD_REG_SET(TO) ((TO) = ~ HARD_CONST (0))
106 #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM))
107 #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM))
109 #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM))
110 #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM))
111 #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM))
112 #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM))
114 static inline bool
115 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
117 return (x & ~y) == HARD_CONST (0);
120 static inline bool
121 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
123 return x == y;
126 static inline bool
127 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
129 return (x & y) != HARD_CONST (0);
132 static inline bool
133 hard_reg_set_empty_p (const HARD_REG_SET x)
135 return x == HARD_CONST (0);
138 #else
140 #define SET_HARD_REG_BIT(SET, BIT) \
141 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
142 |= HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))
144 #define CLEAR_HARD_REG_BIT(SET, BIT) \
145 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
146 &= ~(HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
148 #define TEST_HARD_REG_BIT(SET, BIT) \
149 (!!((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
150 & (HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))))
152 #if FIRST_PSEUDO_REGISTER <= 2*HOST_BITS_PER_WIDEST_FAST_INT
153 #define CLEAR_HARD_REG_SET(TO) \
154 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
155 scan_tp_[0] = 0; \
156 scan_tp_[1] = 0; } while (0)
158 #define SET_HARD_REG_SET(TO) \
159 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
160 scan_tp_[0] = -1; \
161 scan_tp_[1] = -1; } while (0)
163 #define COPY_HARD_REG_SET(TO, FROM) \
164 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
165 scan_tp_[0] = scan_fp_[0]; \
166 scan_tp_[1] = scan_fp_[1]; } while (0)
168 #define COMPL_HARD_REG_SET(TO, FROM) \
169 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
170 scan_tp_[0] = ~ scan_fp_[0]; \
171 scan_tp_[1] = ~ scan_fp_[1]; } while (0)
173 #define AND_HARD_REG_SET(TO, FROM) \
174 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
175 scan_tp_[0] &= scan_fp_[0]; \
176 scan_tp_[1] &= scan_fp_[1]; } while (0)
178 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
179 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
180 scan_tp_[0] &= ~ scan_fp_[0]; \
181 scan_tp_[1] &= ~ scan_fp_[1]; } while (0)
183 #define IOR_HARD_REG_SET(TO, FROM) \
184 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
185 scan_tp_[0] |= scan_fp_[0]; \
186 scan_tp_[1] |= scan_fp_[1]; } while (0)
188 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
189 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
190 scan_tp_[0] |= ~ scan_fp_[0]; \
191 scan_tp_[1] |= ~ scan_fp_[1]; } while (0)
193 static inline bool
194 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
196 return (x[0] & ~y[0]) == 0 && (x[1] & ~y[1]) == 0;
199 static inline bool
200 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
202 return x[0] == y[0] && x[1] == y[1];
205 static inline bool
206 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
208 return (x[0] & y[0]) != 0 || (x[1] & y[1]) != 0;
211 static inline bool
212 hard_reg_set_empty_p (const HARD_REG_SET x)
214 return x[0] == 0 && x[1] == 0;
217 #else
218 #if FIRST_PSEUDO_REGISTER <= 3*HOST_BITS_PER_WIDEST_FAST_INT
219 #define CLEAR_HARD_REG_SET(TO) \
220 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
221 scan_tp_[0] = 0; \
222 scan_tp_[1] = 0; \
223 scan_tp_[2] = 0; } while (0)
225 #define SET_HARD_REG_SET(TO) \
226 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
227 scan_tp_[0] = -1; \
228 scan_tp_[1] = -1; \
229 scan_tp_[2] = -1; } while (0)
231 #define COPY_HARD_REG_SET(TO, FROM) \
232 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
233 scan_tp_[0] = scan_fp_[0]; \
234 scan_tp_[1] = scan_fp_[1]; \
235 scan_tp_[2] = scan_fp_[2]; } while (0)
237 #define COMPL_HARD_REG_SET(TO, FROM) \
238 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
239 scan_tp_[0] = ~ scan_fp_[0]; \
240 scan_tp_[1] = ~ scan_fp_[1]; \
241 scan_tp_[2] = ~ scan_fp_[2]; } while (0)
243 #define AND_HARD_REG_SET(TO, FROM) \
244 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
245 scan_tp_[0] &= scan_fp_[0]; \
246 scan_tp_[1] &= scan_fp_[1]; \
247 scan_tp_[2] &= scan_fp_[2]; } while (0)
249 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
250 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
251 scan_tp_[0] &= ~ scan_fp_[0]; \
252 scan_tp_[1] &= ~ scan_fp_[1]; \
253 scan_tp_[2] &= ~ scan_fp_[2]; } while (0)
255 #define IOR_HARD_REG_SET(TO, FROM) \
256 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
257 scan_tp_[0] |= scan_fp_[0]; \
258 scan_tp_[1] |= scan_fp_[1]; \
259 scan_tp_[2] |= scan_fp_[2]; } while (0)
261 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
262 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
263 scan_tp_[0] |= ~ scan_fp_[0]; \
264 scan_tp_[1] |= ~ scan_fp_[1]; \
265 scan_tp_[2] |= ~ scan_fp_[2]; } while (0)
267 static inline bool
268 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
270 return ((x[0] & ~y[0]) == 0
271 && (x[1] & ~y[1]) == 0
272 && (x[2] & ~y[2]) == 0);
275 static inline bool
276 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
278 return x[0] == y[0] && x[1] == y[1] && x[2] == y[2];
281 static inline bool
282 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
284 return ((x[0] & y[0]) != 0
285 || (x[1] & y[1]) != 0
286 || (x[2] & y[2]) != 0);
289 static inline bool
290 hard_reg_set_empty_p (const HARD_REG_SET x)
292 return x[0] == 0 && x[1] == 0 && x[2] == 0;
295 #else
296 #if FIRST_PSEUDO_REGISTER <= 4*HOST_BITS_PER_WIDEST_FAST_INT
297 #define CLEAR_HARD_REG_SET(TO) \
298 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
299 scan_tp_[0] = 0; \
300 scan_tp_[1] = 0; \
301 scan_tp_[2] = 0; \
302 scan_tp_[3] = 0; } while (0)
304 #define SET_HARD_REG_SET(TO) \
305 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
306 scan_tp_[0] = -1; \
307 scan_tp_[1] = -1; \
308 scan_tp_[2] = -1; \
309 scan_tp_[3] = -1; } while (0)
311 #define COPY_HARD_REG_SET(TO, FROM) \
312 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
313 scan_tp_[0] = scan_fp_[0]; \
314 scan_tp_[1] = scan_fp_[1]; \
315 scan_tp_[2] = scan_fp_[2]; \
316 scan_tp_[3] = scan_fp_[3]; } while (0)
318 #define COMPL_HARD_REG_SET(TO, FROM) \
319 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
320 scan_tp_[0] = ~ scan_fp_[0]; \
321 scan_tp_[1] = ~ scan_fp_[1]; \
322 scan_tp_[2] = ~ scan_fp_[2]; \
323 scan_tp_[3] = ~ scan_fp_[3]; } while (0)
325 #define AND_HARD_REG_SET(TO, FROM) \
326 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
327 scan_tp_[0] &= scan_fp_[0]; \
328 scan_tp_[1] &= scan_fp_[1]; \
329 scan_tp_[2] &= scan_fp_[2]; \
330 scan_tp_[3] &= scan_fp_[3]; } while (0)
332 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
333 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
334 scan_tp_[0] &= ~ scan_fp_[0]; \
335 scan_tp_[1] &= ~ scan_fp_[1]; \
336 scan_tp_[2] &= ~ scan_fp_[2]; \
337 scan_tp_[3] &= ~ scan_fp_[3]; } while (0)
339 #define IOR_HARD_REG_SET(TO, FROM) \
340 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
341 scan_tp_[0] |= scan_fp_[0]; \
342 scan_tp_[1] |= scan_fp_[1]; \
343 scan_tp_[2] |= scan_fp_[2]; \
344 scan_tp_[3] |= scan_fp_[3]; } while (0)
346 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
347 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
348 scan_tp_[0] |= ~ scan_fp_[0]; \
349 scan_tp_[1] |= ~ scan_fp_[1]; \
350 scan_tp_[2] |= ~ scan_fp_[2]; \
351 scan_tp_[3] |= ~ scan_fp_[3]; } while (0)
353 static inline bool
354 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
356 return ((x[0] & ~y[0]) == 0
357 && (x[1] & ~y[1]) == 0
358 && (x[2] & ~y[2]) == 0
359 && (x[3] & ~y[3]) == 0);
362 static inline bool
363 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
365 return x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3];
368 static inline bool
369 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
371 return ((x[0] & y[0]) != 0
372 || (x[1] & y[1]) != 0
373 || (x[2] & y[2]) != 0
374 || (x[3] & y[3]) != 0);
377 static inline bool
378 hard_reg_set_empty_p (const HARD_REG_SET x)
380 return x[0] == 0 && x[1] == 0 && x[2] == 0 && x[3] == 0;
383 #else /* FIRST_PSEUDO_REGISTER > 4*HOST_BITS_PER_WIDEST_FAST_INT */
385 #define CLEAR_HARD_REG_SET(TO) \
386 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
387 int i; \
388 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
389 *scan_tp_++ = 0; } while (0)
391 #define SET_HARD_REG_SET(TO) \
392 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
393 int i; \
394 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
395 *scan_tp_++ = -1; } while (0)
397 #define COPY_HARD_REG_SET(TO, FROM) \
398 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
399 int i; \
400 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
401 *scan_tp_++ = *scan_fp_++; } while (0)
403 #define COMPL_HARD_REG_SET(TO, FROM) \
404 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
405 int i; \
406 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
407 *scan_tp_++ = ~ *scan_fp_++; } while (0)
409 #define AND_HARD_REG_SET(TO, FROM) \
410 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
411 int i; \
412 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
413 *scan_tp_++ &= *scan_fp_++; } while (0)
415 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
416 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
417 int i; \
418 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
419 *scan_tp_++ &= ~ *scan_fp_++; } while (0)
421 #define IOR_HARD_REG_SET(TO, FROM) \
422 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
423 int i; \
424 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
425 *scan_tp_++ |= *scan_fp_++; } while (0)
427 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
428 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
429 int i; \
430 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
431 *scan_tp_++ |= ~ *scan_fp_++; } while (0)
433 static inline bool
434 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
436 int i;
438 for (i = 0; i < HARD_REG_SET_LONGS; i++)
439 if ((x[i] & ~y[i]) != 0)
440 return false;
441 return true;
444 static inline bool
445 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
447 int i;
449 for (i = 0; i < HARD_REG_SET_LONGS; i++)
450 if (x[i] != y[i])
451 return false;
452 return true;
455 static inline bool
456 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
458 int i;
460 for (i = 0; i < HARD_REG_SET_LONGS; i++)
461 if ((x[i] & y[i]) != 0)
462 return true;
463 return false;
466 static inline bool
467 hard_reg_set_empty_p (const HARD_REG_SET x)
469 int i;
471 for (i = 0; i < HARD_REG_SET_LONGS; i++)
472 if (x[i] != 0)
473 return false;
474 return true;
477 #endif
478 #endif
479 #endif
480 #endif
482 /* Iterator for hard register sets. */
484 typedef struct
486 /* Pointer to the current element. */
487 HARD_REG_ELT_TYPE *pelt;
489 /* The length of the set. */
490 unsigned short length;
492 /* Word within the current element. */
493 unsigned short word_no;
495 /* Contents of the actually processed word. When finding next bit
496 it is shifted right, so that the actual bit is always the least
497 significant bit of ACTUAL. */
498 HARD_REG_ELT_TYPE bits;
499 } hard_reg_set_iterator;
501 #define HARD_REG_ELT_BITS UHOST_BITS_PER_WIDE_INT
503 /* The implementation of the iterator functions is fully analogous to
504 the bitmap iterators. */
505 static inline void
506 hard_reg_set_iter_init (hard_reg_set_iterator *iter, HARD_REG_SET set,
507 unsigned min, unsigned *regno)
509 #ifdef HARD_REG_SET_LONGS
510 iter->pelt = set;
511 iter->length = HARD_REG_SET_LONGS;
512 #else
513 iter->pelt = &set;
514 iter->length = 1;
515 #endif
516 iter->word_no = min / HARD_REG_ELT_BITS;
517 if (iter->word_no < iter->length)
519 iter->bits = iter->pelt[iter->word_no];
520 iter->bits >>= min % HARD_REG_ELT_BITS;
522 /* This is required for correct search of the next bit. */
523 min += !iter->bits;
525 *regno = min;
528 static inline bool
529 hard_reg_set_iter_set (hard_reg_set_iterator *iter, unsigned *regno)
531 while (1)
533 /* Return false when we're advanced past the end of the set. */
534 if (iter->word_no >= iter->length)
535 return false;
537 if (iter->bits)
539 /* Find the correct bit and return it. */
540 while (!(iter->bits & 1))
542 iter->bits >>= 1;
543 *regno += 1;
545 return (*regno < FIRST_PSEUDO_REGISTER);
548 /* Round to the beginning of the next word. */
549 *regno = (*regno + HARD_REG_ELT_BITS - 1);
550 *regno -= *regno % HARD_REG_ELT_BITS;
552 /* Find the next non-zero word. */
553 while (++iter->word_no < iter->length)
555 iter->bits = iter->pelt[iter->word_no];
556 if (iter->bits)
557 break;
558 *regno += HARD_REG_ELT_BITS;
563 static inline void
564 hard_reg_set_iter_next (hard_reg_set_iterator *iter, unsigned *regno)
566 iter->bits >>= 1;
567 *regno += 1;
570 #define EXECUTE_IF_SET_IN_HARD_REG_SET(SET, MIN, REGNUM, ITER) \
571 for (hard_reg_set_iter_init (&(ITER), (SET), (MIN), &(REGNUM)); \
572 hard_reg_set_iter_set (&(ITER), &(REGNUM)); \
573 hard_reg_set_iter_next (&(ITER), &(REGNUM)))
576 /* Define some standard sets of registers. */
578 /* Indexed by hard register number, contains 1 for registers
579 that are being used for global register decls.
580 These must be exempt from ordinary flow analysis
581 and are also considered fixed. */
583 extern char global_regs[FIRST_PSEUDO_REGISTER];
585 struct target_hard_regs {
586 /* The set of registers that actually exist on the current target. */
587 HARD_REG_SET x_accessible_reg_set;
589 /* The set of registers that should be considered to be register
590 operands. It is a subset of x_accessible_reg_set. */
591 HARD_REG_SET x_operand_reg_set;
593 /* Indexed by hard register number, contains 1 for registers
594 that are fixed use (stack pointer, pc, frame pointer, etc.;.
595 These are the registers that cannot be used to allocate
596 a pseudo reg whose life does not cross calls. */
597 char x_fixed_regs[FIRST_PSEUDO_REGISTER];
599 /* The same info as a HARD_REG_SET. */
600 HARD_REG_SET x_fixed_reg_set;
602 /* Indexed by hard register number, contains 1 for registers
603 that are fixed use or are clobbered by function calls.
604 These are the registers that cannot be used to allocate
605 a pseudo reg whose life crosses calls. */
606 char x_call_used_regs[FIRST_PSEUDO_REGISTER];
608 char x_call_really_used_regs[FIRST_PSEUDO_REGISTER];
610 /* The same info as a HARD_REG_SET. */
611 HARD_REG_SET x_call_used_reg_set;
613 /* Contains registers that are fixed use -- i.e. in fixed_reg_set -- or
614 a function value return register or TARGET_STRUCT_VALUE_RTX or
615 STATIC_CHAIN_REGNUM. These are the registers that cannot hold quantities
616 across calls even if we are willing to save and restore them. */
617 HARD_REG_SET x_call_fixed_reg_set;
619 /* Contains 1 for registers that are set or clobbered by calls. */
620 /* ??? Ideally, this would be just call_used_regs plus global_regs, but
621 for someone's bright idea to have call_used_regs strictly include
622 fixed_regs. Which leaves us guessing as to the set of fixed_regs
623 that are actually preserved. We know for sure that those associated
624 with the local stack frame are safe, but scant others. */
625 HARD_REG_SET x_regs_invalidated_by_call;
627 /* Call used hard registers which can not be saved because there is no
628 insn for this. */
629 HARD_REG_SET x_no_caller_save_reg_set;
631 /* Table of register numbers in the order in which to try to use them. */
632 int x_reg_alloc_order[FIRST_PSEUDO_REGISTER];
634 /* The inverse of reg_alloc_order. */
635 int x_inv_reg_alloc_order[FIRST_PSEUDO_REGISTER];
637 /* For each reg class, a HARD_REG_SET saying which registers are in it. */
638 HARD_REG_SET x_reg_class_contents[N_REG_CLASSES];
640 /* For each reg class, a boolean saying whether the class contains only
641 fixed registers. */
642 bool x_class_only_fixed_regs[N_REG_CLASSES];
644 /* For each reg class, number of regs it contains. */
645 unsigned int x_reg_class_size[N_REG_CLASSES];
647 /* For each reg class, table listing all the classes contained in it. */
648 enum reg_class x_reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES];
650 /* For each pair of reg classes,
651 a largest reg class contained in their union. */
652 enum reg_class x_reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES];
654 /* For each pair of reg classes,
655 the smallest reg class that contains their union. */
656 enum reg_class x_reg_class_superunion[N_REG_CLASSES][N_REG_CLASSES];
658 /* Vector indexed by hardware reg giving its name. */
659 const char *x_reg_names[FIRST_PSEUDO_REGISTER];
662 extern struct target_hard_regs default_target_hard_regs;
663 #if SWITCHABLE_TARGET
664 extern struct target_hard_regs *this_target_hard_regs;
665 #else
666 #define this_target_hard_regs (&default_target_hard_regs)
667 #endif
669 #define accessible_reg_set \
670 (this_target_hard_regs->x_accessible_reg_set)
671 #define operand_reg_set \
672 (this_target_hard_regs->x_operand_reg_set)
673 #define fixed_regs \
674 (this_target_hard_regs->x_fixed_regs)
675 #define fixed_reg_set \
676 (this_target_hard_regs->x_fixed_reg_set)
677 #define call_used_regs \
678 (this_target_hard_regs->x_call_used_regs)
679 #define call_really_used_regs \
680 (this_target_hard_regs->x_call_really_used_regs)
681 #define call_used_reg_set \
682 (this_target_hard_regs->x_call_used_reg_set)
683 #define call_fixed_reg_set \
684 (this_target_hard_regs->x_call_fixed_reg_set)
685 #define regs_invalidated_by_call \
686 (this_target_hard_regs->x_regs_invalidated_by_call)
687 #define no_caller_save_reg_set \
688 (this_target_hard_regs->x_no_caller_save_reg_set)
689 #define reg_alloc_order \
690 (this_target_hard_regs->x_reg_alloc_order)
691 #define inv_reg_alloc_order \
692 (this_target_hard_regs->x_inv_reg_alloc_order)
693 #define reg_class_contents \
694 (this_target_hard_regs->x_reg_class_contents)
695 #define class_only_fixed_regs \
696 (this_target_hard_regs->x_class_only_fixed_regs)
697 #define reg_class_size \
698 (this_target_hard_regs->x_reg_class_size)
699 #define reg_class_subclasses \
700 (this_target_hard_regs->x_reg_class_subclasses)
701 #define reg_class_subunion \
702 (this_target_hard_regs->x_reg_class_subunion)
703 #define reg_class_superunion \
704 (this_target_hard_regs->x_reg_class_superunion)
705 #define reg_names \
706 (this_target_hard_regs->x_reg_names)
708 /* Vector indexed by reg class giving its name. */
710 extern const char * reg_class_names[];
712 /* Given a hard REGN a FROM mode and a TO mode, return nonzero if
713 REGN cannot change modes between the specified modes. */
714 #define REG_CANNOT_CHANGE_MODE_P(REGN, FROM, TO) \
715 CANNOT_CHANGE_MODE_CLASS (FROM, TO, REGNO_REG_CLASS (REGN))
717 #endif /* ! GCC_HARD_REG_SET_H */