[ARM] Fix CLZ_DEFINED_VALUE_AT_ZERO for vector modes
[official-gcc.git] / gcc / hard-reg-set.h
blobc32516c6913c7fcc9c2e7e20e0b303fe8ddaa788
1 /* Sets (bit vectors) of hard registers, and operations on them.
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_HARD_REG_SET_H
21 #define GCC_HARD_REG_SET_H
23 #include "hash-table.h"
25 /* Define the type of a set of hard registers. */
27 /* HARD_REG_ELT_TYPE is a typedef of the unsigned integral type which
28 will be used for hard reg sets, either alone or in an array.
30 If HARD_REG_SET is a macro, its definition is HARD_REG_ELT_TYPE,
31 and it has enough bits to represent all the target machine's hard
32 registers. Otherwise, it is a typedef for a suitably sized array
33 of HARD_REG_ELT_TYPEs. HARD_REG_SET_LONGS is defined as how many.
35 Note that lots of code assumes that the first part of a regset is
36 the same format as a HARD_REG_SET. To help make sure this is true,
37 we only try the widest fast integer mode (HOST_WIDEST_FAST_INT)
38 instead of all the smaller types. This approach loses only if
39 there are very few registers and then only in the few cases where
40 we have an array of HARD_REG_SETs, so it needn't be as complex as
41 it used to be. */
43 typedef unsigned HOST_WIDEST_FAST_INT HARD_REG_ELT_TYPE;
45 #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_WIDEST_FAST_INT
47 #define HARD_REG_SET HARD_REG_ELT_TYPE
49 #else
51 #define HARD_REG_SET_LONGS \
52 ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_WIDEST_FAST_INT - 1) \
53 / HOST_BITS_PER_WIDEST_FAST_INT)
54 typedef HARD_REG_ELT_TYPE HARD_REG_SET[HARD_REG_SET_LONGS];
56 #endif
58 /* HARD_REG_SET wrapped into a structure, to make it possible to
59 use HARD_REG_SET even in APIs that should not include
60 hard-reg-set.h. */
61 struct hard_reg_set_container
63 HARD_REG_SET set;
66 /* HARD_CONST is used to cast a constant to the appropriate type
67 for use with a HARD_REG_SET. */
69 #define HARD_CONST(X) ((HARD_REG_ELT_TYPE) (X))
71 /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT
72 to set, clear or test one bit in a hard reg set of type HARD_REG_SET.
73 All three take two arguments: the set and the register number.
75 In the case where sets are arrays of longs, the first argument
76 is actually a pointer to a long.
78 Define two macros for initializing a set:
79 CLEAR_HARD_REG_SET and SET_HARD_REG_SET.
80 These take just one argument.
82 Also define macros for copying hard reg sets:
83 COPY_HARD_REG_SET and COMPL_HARD_REG_SET.
84 These take two arguments TO and FROM; they read from FROM
85 and store into TO. COMPL_HARD_REG_SET complements each bit.
87 Also define macros for combining hard reg sets:
88 IOR_HARD_REG_SET and AND_HARD_REG_SET.
89 These take two arguments TO and FROM; they read from FROM
90 and combine bitwise into TO. Define also two variants
91 IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET
92 which use the complement of the set FROM.
94 Also define:
96 hard_reg_set_subset_p (X, Y), which returns true if X is a subset of Y.
97 hard_reg_set_equal_p (X, Y), which returns true if X and Y are equal.
98 hard_reg_set_intersect_p (X, Y), which returns true if X and Y intersect.
99 hard_reg_set_empty_p (X), which returns true if X is empty. */
101 #define UHOST_BITS_PER_WIDE_INT ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
103 #ifdef HARD_REG_SET
105 #define SET_HARD_REG_BIT(SET, BIT) \
106 ((SET) |= HARD_CONST (1) << (BIT))
107 #define CLEAR_HARD_REG_BIT(SET, BIT) \
108 ((SET) &= ~(HARD_CONST (1) << (BIT)))
109 #define TEST_HARD_REG_BIT(SET, BIT) \
110 (!!((SET) & (HARD_CONST (1) << (BIT))))
112 #define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
113 #define SET_HARD_REG_SET(TO) ((TO) = ~ HARD_CONST (0))
115 #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM))
116 #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM))
118 #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM))
119 #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM))
120 #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM))
121 #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM))
123 static inline bool
124 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
126 return (x & ~y) == HARD_CONST (0);
129 static inline bool
130 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
132 return x == y;
135 static inline bool
136 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
138 return (x & y) != HARD_CONST (0);
141 static inline bool
142 hard_reg_set_empty_p (const HARD_REG_SET x)
144 return x == HARD_CONST (0);
147 #else
149 #define SET_HARD_REG_BIT(SET, BIT) \
150 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
151 |= HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))
153 #define CLEAR_HARD_REG_BIT(SET, BIT) \
154 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
155 &= ~(HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
157 #define TEST_HARD_REG_BIT(SET, BIT) \
158 (!!((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
159 & (HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))))
161 #if FIRST_PSEUDO_REGISTER <= 2*HOST_BITS_PER_WIDEST_FAST_INT
162 #define CLEAR_HARD_REG_SET(TO) \
163 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
164 scan_tp_[0] = 0; \
165 scan_tp_[1] = 0; } while (0)
167 #define SET_HARD_REG_SET(TO) \
168 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
169 scan_tp_[0] = -1; \
170 scan_tp_[1] = -1; } while (0)
172 #define COPY_HARD_REG_SET(TO, FROM) \
173 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
174 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
175 scan_tp_[0] = scan_fp_[0]; \
176 scan_tp_[1] = scan_fp_[1]; } while (0)
178 #define COMPL_HARD_REG_SET(TO, FROM) \
179 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
180 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
181 scan_tp_[0] = ~ scan_fp_[0]; \
182 scan_tp_[1] = ~ scan_fp_[1]; } while (0)
184 #define AND_HARD_REG_SET(TO, FROM) \
185 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
186 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
187 scan_tp_[0] &= scan_fp_[0]; \
188 scan_tp_[1] &= scan_fp_[1]; } while (0)
190 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
191 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
192 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
193 scan_tp_[0] &= ~ scan_fp_[0]; \
194 scan_tp_[1] &= ~ scan_fp_[1]; } while (0)
196 #define IOR_HARD_REG_SET(TO, FROM) \
197 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
198 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
199 scan_tp_[0] |= scan_fp_[0]; \
200 scan_tp_[1] |= scan_fp_[1]; } while (0)
202 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
203 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
204 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
205 scan_tp_[0] |= ~ scan_fp_[0]; \
206 scan_tp_[1] |= ~ scan_fp_[1]; } while (0)
208 static inline bool
209 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
211 return (x[0] & ~y[0]) == 0 && (x[1] & ~y[1]) == 0;
214 static inline bool
215 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
217 return x[0] == y[0] && x[1] == y[1];
220 static inline bool
221 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
223 return (x[0] & y[0]) != 0 || (x[1] & y[1]) != 0;
226 static inline bool
227 hard_reg_set_empty_p (const HARD_REG_SET x)
229 return x[0] == 0 && x[1] == 0;
232 #else
233 #if FIRST_PSEUDO_REGISTER <= 3*HOST_BITS_PER_WIDEST_FAST_INT
234 #define CLEAR_HARD_REG_SET(TO) \
235 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
236 scan_tp_[0] = 0; \
237 scan_tp_[1] = 0; \
238 scan_tp_[2] = 0; } while (0)
240 #define SET_HARD_REG_SET(TO) \
241 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
242 scan_tp_[0] = -1; \
243 scan_tp_[1] = -1; \
244 scan_tp_[2] = -1; } while (0)
246 #define COPY_HARD_REG_SET(TO, FROM) \
247 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
248 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
249 scan_tp_[0] = scan_fp_[0]; \
250 scan_tp_[1] = scan_fp_[1]; \
251 scan_tp_[2] = scan_fp_[2]; } while (0)
253 #define COMPL_HARD_REG_SET(TO, FROM) \
254 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
255 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
256 scan_tp_[0] = ~ scan_fp_[0]; \
257 scan_tp_[1] = ~ scan_fp_[1]; \
258 scan_tp_[2] = ~ scan_fp_[2]; } while (0)
260 #define AND_HARD_REG_SET(TO, FROM) \
261 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
262 const HARD_REG_ELT_TYPE *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 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
268 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
269 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
270 scan_tp_[0] &= ~ scan_fp_[0]; \
271 scan_tp_[1] &= ~ scan_fp_[1]; \
272 scan_tp_[2] &= ~ scan_fp_[2]; } while (0)
274 #define IOR_HARD_REG_SET(TO, FROM) \
275 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
276 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
277 scan_tp_[0] |= scan_fp_[0]; \
278 scan_tp_[1] |= scan_fp_[1]; \
279 scan_tp_[2] |= scan_fp_[2]; } while (0)
281 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
282 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
283 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
284 scan_tp_[0] |= ~ scan_fp_[0]; \
285 scan_tp_[1] |= ~ scan_fp_[1]; \
286 scan_tp_[2] |= ~ scan_fp_[2]; } while (0)
288 static inline bool
289 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
291 return ((x[0] & ~y[0]) == 0
292 && (x[1] & ~y[1]) == 0
293 && (x[2] & ~y[2]) == 0);
296 static inline bool
297 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
299 return x[0] == y[0] && x[1] == y[1] && x[2] == y[2];
302 static inline bool
303 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
305 return ((x[0] & y[0]) != 0
306 || (x[1] & y[1]) != 0
307 || (x[2] & y[2]) != 0);
310 static inline bool
311 hard_reg_set_empty_p (const HARD_REG_SET x)
313 return x[0] == 0 && x[1] == 0 && x[2] == 0;
316 #else
317 #if FIRST_PSEUDO_REGISTER <= 4*HOST_BITS_PER_WIDEST_FAST_INT
318 #define CLEAR_HARD_REG_SET(TO) \
319 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
320 scan_tp_[0] = 0; \
321 scan_tp_[1] = 0; \
322 scan_tp_[2] = 0; \
323 scan_tp_[3] = 0; } while (0)
325 #define SET_HARD_REG_SET(TO) \
326 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
327 scan_tp_[0] = -1; \
328 scan_tp_[1] = -1; \
329 scan_tp_[2] = -1; \
330 scan_tp_[3] = -1; } while (0)
332 #define COPY_HARD_REG_SET(TO, FROM) \
333 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
334 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
335 scan_tp_[0] = scan_fp_[0]; \
336 scan_tp_[1] = scan_fp_[1]; \
337 scan_tp_[2] = scan_fp_[2]; \
338 scan_tp_[3] = scan_fp_[3]; } while (0)
340 #define COMPL_HARD_REG_SET(TO, FROM) \
341 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
342 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
343 scan_tp_[0] = ~ scan_fp_[0]; \
344 scan_tp_[1] = ~ scan_fp_[1]; \
345 scan_tp_[2] = ~ scan_fp_[2]; \
346 scan_tp_[3] = ~ scan_fp_[3]; } while (0)
348 #define AND_HARD_REG_SET(TO, FROM) \
349 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
350 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
351 scan_tp_[0] &= scan_fp_[0]; \
352 scan_tp_[1] &= scan_fp_[1]; \
353 scan_tp_[2] &= scan_fp_[2]; \
354 scan_tp_[3] &= scan_fp_[3]; } while (0)
356 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
357 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
358 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
359 scan_tp_[0] &= ~ scan_fp_[0]; \
360 scan_tp_[1] &= ~ scan_fp_[1]; \
361 scan_tp_[2] &= ~ scan_fp_[2]; \
362 scan_tp_[3] &= ~ scan_fp_[3]; } while (0)
364 #define IOR_HARD_REG_SET(TO, FROM) \
365 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
366 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
367 scan_tp_[0] |= scan_fp_[0]; \
368 scan_tp_[1] |= scan_fp_[1]; \
369 scan_tp_[2] |= scan_fp_[2]; \
370 scan_tp_[3] |= scan_fp_[3]; } while (0)
372 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
373 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
374 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
375 scan_tp_[0] |= ~ scan_fp_[0]; \
376 scan_tp_[1] |= ~ scan_fp_[1]; \
377 scan_tp_[2] |= ~ scan_fp_[2]; \
378 scan_tp_[3] |= ~ scan_fp_[3]; } while (0)
380 static inline bool
381 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
383 return ((x[0] & ~y[0]) == 0
384 && (x[1] & ~y[1]) == 0
385 && (x[2] & ~y[2]) == 0
386 && (x[3] & ~y[3]) == 0);
389 static inline bool
390 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
392 return x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3];
395 static inline bool
396 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
398 return ((x[0] & y[0]) != 0
399 || (x[1] & y[1]) != 0
400 || (x[2] & y[2]) != 0
401 || (x[3] & y[3]) != 0);
404 static inline bool
405 hard_reg_set_empty_p (const HARD_REG_SET x)
407 return x[0] == 0 && x[1] == 0 && x[2] == 0 && x[3] == 0;
410 #else /* FIRST_PSEUDO_REGISTER > 4*HOST_BITS_PER_WIDEST_FAST_INT */
412 #define CLEAR_HARD_REG_SET(TO) \
413 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
414 int i; \
415 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
416 *scan_tp_++ = 0; } while (0)
418 #define SET_HARD_REG_SET(TO) \
419 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
420 int i; \
421 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
422 *scan_tp_++ = -1; } while (0)
424 #define COPY_HARD_REG_SET(TO, FROM) \
425 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
426 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
427 int i; \
428 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
429 *scan_tp_++ = *scan_fp_++; } while (0)
431 #define COMPL_HARD_REG_SET(TO, FROM) \
432 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
433 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
434 int i; \
435 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
436 *scan_tp_++ = ~ *scan_fp_++; } while (0)
438 #define AND_HARD_REG_SET(TO, FROM) \
439 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
440 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
441 int i; \
442 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
443 *scan_tp_++ &= *scan_fp_++; } while (0)
445 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
446 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
447 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
448 int i; \
449 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
450 *scan_tp_++ &= ~ *scan_fp_++; } while (0)
452 #define IOR_HARD_REG_SET(TO, FROM) \
453 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
454 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
455 int i; \
456 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
457 *scan_tp_++ |= *scan_fp_++; } while (0)
459 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
460 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
461 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
462 int i; \
463 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
464 *scan_tp_++ |= ~ *scan_fp_++; } while (0)
466 static inline bool
467 hard_reg_set_subset_p (const HARD_REG_SET x, const HARD_REG_SET y)
469 int i;
471 for (i = 0; i < HARD_REG_SET_LONGS; i++)
472 if ((x[i] & ~y[i]) != 0)
473 return false;
474 return true;
477 static inline bool
478 hard_reg_set_equal_p (const HARD_REG_SET x, const HARD_REG_SET y)
480 int i;
482 for (i = 0; i < HARD_REG_SET_LONGS; i++)
483 if (x[i] != y[i])
484 return false;
485 return true;
488 static inline bool
489 hard_reg_set_intersect_p (const HARD_REG_SET x, const HARD_REG_SET y)
491 int i;
493 for (i = 0; i < HARD_REG_SET_LONGS; i++)
494 if ((x[i] & y[i]) != 0)
495 return true;
496 return false;
499 static inline bool
500 hard_reg_set_empty_p (const HARD_REG_SET x)
502 int i;
504 for (i = 0; i < HARD_REG_SET_LONGS; i++)
505 if (x[i] != 0)
506 return false;
507 return true;
510 #endif
511 #endif
512 #endif
513 #endif
515 /* Iterator for hard register sets. */
517 struct hard_reg_set_iterator
519 /* Pointer to the current element. */
520 HARD_REG_ELT_TYPE *pelt;
522 /* The length of the set. */
523 unsigned short length;
525 /* Word within the current element. */
526 unsigned short word_no;
528 /* Contents of the actually processed word. When finding next bit
529 it is shifted right, so that the actual bit is always the least
530 significant bit of ACTUAL. */
531 HARD_REG_ELT_TYPE bits;
534 #define HARD_REG_ELT_BITS UHOST_BITS_PER_WIDE_INT
536 /* The implementation of the iterator functions is fully analogous to
537 the bitmap iterators. */
538 static inline void
539 hard_reg_set_iter_init (hard_reg_set_iterator *iter, HARD_REG_SET set,
540 unsigned min, unsigned *regno)
542 #ifdef HARD_REG_SET_LONGS
543 iter->pelt = set;
544 iter->length = HARD_REG_SET_LONGS;
545 #else
546 iter->pelt = &set;
547 iter->length = 1;
548 #endif
549 iter->word_no = min / HARD_REG_ELT_BITS;
550 if (iter->word_no < iter->length)
552 iter->bits = iter->pelt[iter->word_no];
553 iter->bits >>= min % HARD_REG_ELT_BITS;
555 /* This is required for correct search of the next bit. */
556 min += !iter->bits;
558 *regno = min;
561 static inline bool
562 hard_reg_set_iter_set (hard_reg_set_iterator *iter, unsigned *regno)
564 while (1)
566 /* Return false when we're advanced past the end of the set. */
567 if (iter->word_no >= iter->length)
568 return false;
570 if (iter->bits)
572 /* Find the correct bit and return it. */
573 while (!(iter->bits & 1))
575 iter->bits >>= 1;
576 *regno += 1;
578 return (*regno < FIRST_PSEUDO_REGISTER);
581 /* Round to the beginning of the next word. */
582 *regno = (*regno + HARD_REG_ELT_BITS - 1);
583 *regno -= *regno % HARD_REG_ELT_BITS;
585 /* Find the next non-zero word. */
586 while (++iter->word_no < iter->length)
588 iter->bits = iter->pelt[iter->word_no];
589 if (iter->bits)
590 break;
591 *regno += HARD_REG_ELT_BITS;
596 static inline void
597 hard_reg_set_iter_next (hard_reg_set_iterator *iter, unsigned *regno)
599 iter->bits >>= 1;
600 *regno += 1;
603 #define EXECUTE_IF_SET_IN_HARD_REG_SET(SET, MIN, REGNUM, ITER) \
604 for (hard_reg_set_iter_init (&(ITER), (SET), (MIN), &(REGNUM)); \
605 hard_reg_set_iter_set (&(ITER), &(REGNUM)); \
606 hard_reg_set_iter_next (&(ITER), &(REGNUM)))
609 /* Define some standard sets of registers. */
611 /* Indexed by hard register number, contains 1 for registers
612 that are being used for global register decls.
613 These must be exempt from ordinary flow analysis
614 and are also considered fixed. */
616 extern char global_regs[FIRST_PSEUDO_REGISTER];
618 struct simplifiable_subregs_hasher;
620 struct target_hard_regs {
621 void finalize ();
623 /* The set of registers that actually exist on the current target. */
624 HARD_REG_SET x_accessible_reg_set;
626 /* The set of registers that should be considered to be register
627 operands. It is a subset of x_accessible_reg_set. */
628 HARD_REG_SET x_operand_reg_set;
630 /* Indexed by hard register number, contains 1 for registers
631 that are fixed use (stack pointer, pc, frame pointer, etc.;.
632 These are the registers that cannot be used to allocate
633 a pseudo reg whose life does not cross calls. */
634 char x_fixed_regs[FIRST_PSEUDO_REGISTER];
636 /* The same info as a HARD_REG_SET. */
637 HARD_REG_SET x_fixed_reg_set;
639 /* Indexed by hard register number, contains 1 for registers
640 that are fixed use or are clobbered by function calls.
641 These are the registers that cannot be used to allocate
642 a pseudo reg whose life crosses calls. */
643 char x_call_used_regs[FIRST_PSEUDO_REGISTER];
645 char x_call_really_used_regs[FIRST_PSEUDO_REGISTER];
647 /* The same info as a HARD_REG_SET. */
648 HARD_REG_SET x_call_used_reg_set;
650 /* Contains registers that are fixed use -- i.e. in fixed_reg_set -- or
651 a function value return register or TARGET_STRUCT_VALUE_RTX or
652 STATIC_CHAIN_REGNUM. These are the registers that cannot hold quantities
653 across calls even if we are willing to save and restore them. */
654 HARD_REG_SET x_call_fixed_reg_set;
656 /* Contains 1 for registers that are set or clobbered by calls. */
657 /* ??? Ideally, this would be just call_used_regs plus global_regs, but
658 for someone's bright idea to have call_used_regs strictly include
659 fixed_regs. Which leaves us guessing as to the set of fixed_regs
660 that are actually preserved. We know for sure that those associated
661 with the local stack frame are safe, but scant others. */
662 HARD_REG_SET x_regs_invalidated_by_call;
664 /* Call used hard registers which can not be saved because there is no
665 insn for this. */
666 HARD_REG_SET x_no_caller_save_reg_set;
668 /* Table of register numbers in the order in which to try to use them. */
669 int x_reg_alloc_order[FIRST_PSEUDO_REGISTER];
671 /* The inverse of reg_alloc_order. */
672 int x_inv_reg_alloc_order[FIRST_PSEUDO_REGISTER];
674 /* For each reg class, a HARD_REG_SET saying which registers are in it. */
675 HARD_REG_SET x_reg_class_contents[N_REG_CLASSES];
677 /* For each reg class, a boolean saying whether the class contains only
678 fixed registers. */
679 bool x_class_only_fixed_regs[N_REG_CLASSES];
681 /* For each reg class, number of regs it contains. */
682 unsigned int x_reg_class_size[N_REG_CLASSES];
684 /* For each reg class, table listing all the classes contained in it. */
685 enum reg_class x_reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES];
687 /* For each pair of reg classes,
688 a largest reg class contained in their union. */
689 enum reg_class x_reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES];
691 /* For each pair of reg classes,
692 the smallest reg class that contains their union. */
693 enum reg_class x_reg_class_superunion[N_REG_CLASSES][N_REG_CLASSES];
695 /* Vector indexed by hardware reg giving its name. */
696 const char *x_reg_names[FIRST_PSEUDO_REGISTER];
698 /* Records which registers can form a particular subreg, with the subreg
699 being identified by its outer mode, inner mode and offset. */
700 hash_table <simplifiable_subregs_hasher> *x_simplifiable_subregs;
703 extern struct target_hard_regs default_target_hard_regs;
704 #if SWITCHABLE_TARGET
705 extern struct target_hard_regs *this_target_hard_regs;
706 #else
707 #define this_target_hard_regs (&default_target_hard_regs)
708 #endif
710 #define accessible_reg_set \
711 (this_target_hard_regs->x_accessible_reg_set)
712 #define operand_reg_set \
713 (this_target_hard_regs->x_operand_reg_set)
714 #define fixed_regs \
715 (this_target_hard_regs->x_fixed_regs)
716 #define fixed_reg_set \
717 (this_target_hard_regs->x_fixed_reg_set)
718 #define call_used_regs \
719 (this_target_hard_regs->x_call_used_regs)
720 #define call_really_used_regs \
721 (this_target_hard_regs->x_call_really_used_regs)
722 #define call_used_reg_set \
723 (this_target_hard_regs->x_call_used_reg_set)
724 #define call_fixed_reg_set \
725 (this_target_hard_regs->x_call_fixed_reg_set)
726 #define regs_invalidated_by_call \
727 (this_target_hard_regs->x_regs_invalidated_by_call)
728 #define no_caller_save_reg_set \
729 (this_target_hard_regs->x_no_caller_save_reg_set)
730 #define reg_alloc_order \
731 (this_target_hard_regs->x_reg_alloc_order)
732 #define inv_reg_alloc_order \
733 (this_target_hard_regs->x_inv_reg_alloc_order)
734 #define reg_class_contents \
735 (this_target_hard_regs->x_reg_class_contents)
736 #define class_only_fixed_regs \
737 (this_target_hard_regs->x_class_only_fixed_regs)
738 #define reg_class_size \
739 (this_target_hard_regs->x_reg_class_size)
740 #define reg_class_subclasses \
741 (this_target_hard_regs->x_reg_class_subclasses)
742 #define reg_class_subunion \
743 (this_target_hard_regs->x_reg_class_subunion)
744 #define reg_class_superunion \
745 (this_target_hard_regs->x_reg_class_superunion)
746 #define reg_names \
747 (this_target_hard_regs->x_reg_names)
749 /* Vector indexed by reg class giving its name. */
751 extern const char * reg_class_names[];
753 /* Given a hard REGN a FROM mode and a TO mode, return nonzero if
754 REGN cannot change modes between the specified modes. */
755 #define REG_CANNOT_CHANGE_MODE_P(REGN, FROM, TO) \
756 CANNOT_CHANGE_MODE_CLASS (FROM, TO, REGNO_REG_CLASS (REGN))
758 #endif /* ! GCC_HARD_REG_SET_H */