1 /* Sets (bit vectors) of hard registers, and operations on them.
2 Copyright (C) 1987-2015 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
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
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 /* Define the type of a set of hard registers. */
25 /* HARD_REG_ELT_TYPE is a typedef of the unsigned integral type which
26 will be used for hard reg sets, either alone or in an array.
28 If HARD_REG_SET is a macro, its definition is HARD_REG_ELT_TYPE,
29 and it has enough bits to represent all the target machine's hard
30 registers. Otherwise, it is a typedef for a suitably sized array
31 of HARD_REG_ELT_TYPEs. HARD_REG_SET_LONGS is defined as how many.
33 Note that lots of code assumes that the first part of a regset is
34 the same format as a HARD_REG_SET. To help make sure this is true,
35 we only try the widest fast integer mode (HOST_WIDEST_FAST_INT)
36 instead of all the smaller types. This approach loses only if
37 there are very few registers and then only in the few cases where
38 we have an array of HARD_REG_SETs, so it needn't be as complex as
41 typedef unsigned HOST_WIDEST_FAST_INT HARD_REG_ELT_TYPE
;
43 #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_WIDEST_FAST_INT
45 #define HARD_REG_SET HARD_REG_ELT_TYPE
49 #define HARD_REG_SET_LONGS \
50 ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_WIDEST_FAST_INT - 1) \
51 / HOST_BITS_PER_WIDEST_FAST_INT)
52 typedef HARD_REG_ELT_TYPE HARD_REG_SET
[HARD_REG_SET_LONGS
];
56 /* HARD_REG_SET wrapped into a structure, to make it possible to
57 use HARD_REG_SET even in APIs that should not include
59 struct hard_reg_set_container
64 /* HARD_CONST is used to cast a constant to the appropriate type
65 for use with a HARD_REG_SET. */
67 #define HARD_CONST(X) ((HARD_REG_ELT_TYPE) (X))
69 /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT
70 to set, clear or test one bit in a hard reg set of type HARD_REG_SET.
71 All three take two arguments: the set and the register number.
73 In the case where sets are arrays of longs, the first argument
74 is actually a pointer to a long.
76 Define two macros for initializing a set:
77 CLEAR_HARD_REG_SET and SET_HARD_REG_SET.
78 These take just one argument.
80 Also define macros for copying hard reg sets:
81 COPY_HARD_REG_SET and COMPL_HARD_REG_SET.
82 These take two arguments TO and FROM; they read from FROM
83 and store into TO. COMPL_HARD_REG_SET complements each bit.
85 Also define macros for combining hard reg sets:
86 IOR_HARD_REG_SET and AND_HARD_REG_SET.
87 These take two arguments TO and FROM; they read from FROM
88 and combine bitwise into TO. Define also two variants
89 IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET
90 which use the complement of the set FROM.
94 hard_reg_set_subset_p (X, Y), which returns true if X is a subset of Y.
95 hard_reg_set_equal_p (X, Y), which returns true if X and Y are equal.
96 hard_reg_set_intersect_p (X, Y), which returns true if X and Y intersect.
97 hard_reg_set_empty_p (X), which returns true if X is empty. */
99 #define UHOST_BITS_PER_WIDE_INT ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
103 #define SET_HARD_REG_BIT(SET, BIT) \
104 ((SET) |= HARD_CONST (1) << (BIT))
105 #define CLEAR_HARD_REG_BIT(SET, BIT) \
106 ((SET) &= ~(HARD_CONST (1) << (BIT)))
107 #define TEST_HARD_REG_BIT(SET, BIT) \
108 (!!((SET) & (HARD_CONST (1) << (BIT))))
110 #define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
111 #define SET_HARD_REG_SET(TO) ((TO) = ~ HARD_CONST (0))
113 #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM))
114 #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM))
116 #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM))
117 #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM))
118 #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM))
119 #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM))
122 hard_reg_set_subset_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
124 return (x
& ~y
) == HARD_CONST (0);
128 hard_reg_set_equal_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
134 hard_reg_set_intersect_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
136 return (x
& y
) != HARD_CONST (0);
140 hard_reg_set_empty_p (const HARD_REG_SET x
)
142 return x
== HARD_CONST (0);
147 #define SET_HARD_REG_BIT(SET, BIT) \
148 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
149 |= HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))
151 #define CLEAR_HARD_REG_BIT(SET, BIT) \
152 ((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
153 &= ~(HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT)))
155 #define TEST_HARD_REG_BIT(SET, BIT) \
156 (!!((SET)[(BIT) / UHOST_BITS_PER_WIDE_INT] \
157 & (HARD_CONST (1) << ((BIT) % UHOST_BITS_PER_WIDE_INT))))
159 #if FIRST_PSEUDO_REGISTER <= 2*HOST_BITS_PER_WIDEST_FAST_INT
160 #define CLEAR_HARD_REG_SET(TO) \
161 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
163 scan_tp_[1] = 0; } while (0)
165 #define SET_HARD_REG_SET(TO) \
166 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
168 scan_tp_[1] = -1; } while (0)
170 #define COPY_HARD_REG_SET(TO, FROM) \
171 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
172 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
173 scan_tp_[0] = scan_fp_[0]; \
174 scan_tp_[1] = scan_fp_[1]; } while (0)
176 #define COMPL_HARD_REG_SET(TO, FROM) \
177 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
178 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
179 scan_tp_[0] = ~ scan_fp_[0]; \
180 scan_tp_[1] = ~ scan_fp_[1]; } while (0)
182 #define AND_HARD_REG_SET(TO, FROM) \
183 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
184 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
185 scan_tp_[0] &= scan_fp_[0]; \
186 scan_tp_[1] &= scan_fp_[1]; } while (0)
188 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
189 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
190 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
191 scan_tp_[0] &= ~ scan_fp_[0]; \
192 scan_tp_[1] &= ~ scan_fp_[1]; } while (0)
194 #define IOR_HARD_REG_SET(TO, FROM) \
195 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
196 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
197 scan_tp_[0] |= scan_fp_[0]; \
198 scan_tp_[1] |= scan_fp_[1]; } while (0)
200 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
201 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
202 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
203 scan_tp_[0] |= ~ scan_fp_[0]; \
204 scan_tp_[1] |= ~ scan_fp_[1]; } while (0)
207 hard_reg_set_subset_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
209 return (x
[0] & ~y
[0]) == 0 && (x
[1] & ~y
[1]) == 0;
213 hard_reg_set_equal_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
215 return x
[0] == y
[0] && x
[1] == y
[1];
219 hard_reg_set_intersect_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
221 return (x
[0] & y
[0]) != 0 || (x
[1] & y
[1]) != 0;
225 hard_reg_set_empty_p (const HARD_REG_SET x
)
227 return x
[0] == 0 && x
[1] == 0;
231 #if FIRST_PSEUDO_REGISTER <= 3*HOST_BITS_PER_WIDEST_FAST_INT
232 #define CLEAR_HARD_REG_SET(TO) \
233 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
236 scan_tp_[2] = 0; } while (0)
238 #define SET_HARD_REG_SET(TO) \
239 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
242 scan_tp_[2] = -1; } while (0)
244 #define COPY_HARD_REG_SET(TO, FROM) \
245 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
246 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
247 scan_tp_[0] = scan_fp_[0]; \
248 scan_tp_[1] = scan_fp_[1]; \
249 scan_tp_[2] = scan_fp_[2]; } while (0)
251 #define COMPL_HARD_REG_SET(TO, FROM) \
252 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
253 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
254 scan_tp_[0] = ~ scan_fp_[0]; \
255 scan_tp_[1] = ~ scan_fp_[1]; \
256 scan_tp_[2] = ~ scan_fp_[2]; } while (0)
258 #define AND_HARD_REG_SET(TO, FROM) \
259 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
260 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
261 scan_tp_[0] &= scan_fp_[0]; \
262 scan_tp_[1] &= scan_fp_[1]; \
263 scan_tp_[2] &= scan_fp_[2]; } while (0)
265 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
266 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
267 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
268 scan_tp_[0] &= ~ scan_fp_[0]; \
269 scan_tp_[1] &= ~ scan_fp_[1]; \
270 scan_tp_[2] &= ~ scan_fp_[2]; } while (0)
272 #define IOR_HARD_REG_SET(TO, FROM) \
273 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
274 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
275 scan_tp_[0] |= scan_fp_[0]; \
276 scan_tp_[1] |= scan_fp_[1]; \
277 scan_tp_[2] |= scan_fp_[2]; } while (0)
279 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
280 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
281 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
282 scan_tp_[0] |= ~ scan_fp_[0]; \
283 scan_tp_[1] |= ~ scan_fp_[1]; \
284 scan_tp_[2] |= ~ scan_fp_[2]; } while (0)
287 hard_reg_set_subset_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
289 return ((x
[0] & ~y
[0]) == 0
290 && (x
[1] & ~y
[1]) == 0
291 && (x
[2] & ~y
[2]) == 0);
295 hard_reg_set_equal_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
297 return x
[0] == y
[0] && x
[1] == y
[1] && x
[2] == y
[2];
301 hard_reg_set_intersect_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
303 return ((x
[0] & y
[0]) != 0
304 || (x
[1] & y
[1]) != 0
305 || (x
[2] & y
[2]) != 0);
309 hard_reg_set_empty_p (const HARD_REG_SET x
)
311 return x
[0] == 0 && x
[1] == 0 && x
[2] == 0;
315 #if FIRST_PSEUDO_REGISTER <= 4*HOST_BITS_PER_WIDEST_FAST_INT
316 #define CLEAR_HARD_REG_SET(TO) \
317 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
321 scan_tp_[3] = 0; } while (0)
323 #define SET_HARD_REG_SET(TO) \
324 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
328 scan_tp_[3] = -1; } while (0)
330 #define COPY_HARD_REG_SET(TO, FROM) \
331 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
332 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
333 scan_tp_[0] = scan_fp_[0]; \
334 scan_tp_[1] = scan_fp_[1]; \
335 scan_tp_[2] = scan_fp_[2]; \
336 scan_tp_[3] = scan_fp_[3]; } while (0)
338 #define COMPL_HARD_REG_SET(TO, FROM) \
339 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
340 const HARD_REG_ELT_TYPE *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 AND_HARD_REG_SET(TO, FROM) \
347 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
348 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
349 scan_tp_[0] &= scan_fp_[0]; \
350 scan_tp_[1] &= scan_fp_[1]; \
351 scan_tp_[2] &= scan_fp_[2]; \
352 scan_tp_[3] &= scan_fp_[3]; } while (0)
354 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
355 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
356 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
357 scan_tp_[0] &= ~ scan_fp_[0]; \
358 scan_tp_[1] &= ~ scan_fp_[1]; \
359 scan_tp_[2] &= ~ scan_fp_[2]; \
360 scan_tp_[3] &= ~ scan_fp_[3]; } while (0)
362 #define IOR_HARD_REG_SET(TO, FROM) \
363 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
364 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
365 scan_tp_[0] |= scan_fp_[0]; \
366 scan_tp_[1] |= scan_fp_[1]; \
367 scan_tp_[2] |= scan_fp_[2]; \
368 scan_tp_[3] |= scan_fp_[3]; } while (0)
370 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
371 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
372 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
373 scan_tp_[0] |= ~ scan_fp_[0]; \
374 scan_tp_[1] |= ~ scan_fp_[1]; \
375 scan_tp_[2] |= ~ scan_fp_[2]; \
376 scan_tp_[3] |= ~ scan_fp_[3]; } while (0)
379 hard_reg_set_subset_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
381 return ((x
[0] & ~y
[0]) == 0
382 && (x
[1] & ~y
[1]) == 0
383 && (x
[2] & ~y
[2]) == 0
384 && (x
[3] & ~y
[3]) == 0);
388 hard_reg_set_equal_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
390 return x
[0] == y
[0] && x
[1] == y
[1] && x
[2] == y
[2] && x
[3] == y
[3];
394 hard_reg_set_intersect_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
396 return ((x
[0] & y
[0]) != 0
397 || (x
[1] & y
[1]) != 0
398 || (x
[2] & y
[2]) != 0
399 || (x
[3] & y
[3]) != 0);
403 hard_reg_set_empty_p (const HARD_REG_SET x
)
405 return x
[0] == 0 && x
[1] == 0 && x
[2] == 0 && x
[3] == 0;
408 #else /* FIRST_PSEUDO_REGISTER > 4*HOST_BITS_PER_WIDEST_FAST_INT */
410 #define CLEAR_HARD_REG_SET(TO) \
411 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
413 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
414 *scan_tp_++ = 0; } while (0)
416 #define SET_HARD_REG_SET(TO) \
417 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
419 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
420 *scan_tp_++ = -1; } while (0)
422 #define COPY_HARD_REG_SET(TO, FROM) \
423 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
424 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
426 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
427 *scan_tp_++ = *scan_fp_++; } while (0)
429 #define COMPL_HARD_REG_SET(TO, FROM) \
430 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
431 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
433 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
434 *scan_tp_++ = ~ *scan_fp_++; } while (0)
436 #define AND_HARD_REG_SET(TO, FROM) \
437 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
438 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
440 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
441 *scan_tp_++ &= *scan_fp_++; } while (0)
443 #define AND_COMPL_HARD_REG_SET(TO, FROM) \
444 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
445 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
447 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
448 *scan_tp_++ &= ~ *scan_fp_++; } while (0)
450 #define IOR_HARD_REG_SET(TO, FROM) \
451 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
452 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
454 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
455 *scan_tp_++ |= *scan_fp_++; } while (0)
457 #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
458 do { HARD_REG_ELT_TYPE *scan_tp_ = (TO); \
459 const HARD_REG_ELT_TYPE *scan_fp_ = (FROM); \
461 for (i = 0; i < HARD_REG_SET_LONGS; i++) \
462 *scan_tp_++ |= ~ *scan_fp_++; } while (0)
465 hard_reg_set_subset_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
469 for (i
= 0; i
< HARD_REG_SET_LONGS
; i
++)
470 if ((x
[i
] & ~y
[i
]) != 0)
476 hard_reg_set_equal_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
480 for (i
= 0; i
< HARD_REG_SET_LONGS
; i
++)
487 hard_reg_set_intersect_p (const HARD_REG_SET x
, const HARD_REG_SET y
)
491 for (i
= 0; i
< HARD_REG_SET_LONGS
; i
++)
492 if ((x
[i
] & y
[i
]) != 0)
498 hard_reg_set_empty_p (const HARD_REG_SET x
)
502 for (i
= 0; i
< HARD_REG_SET_LONGS
; i
++)
513 /* Iterator for hard register sets. */
515 struct hard_reg_set_iterator
517 /* Pointer to the current element. */
518 HARD_REG_ELT_TYPE
*pelt
;
520 /* The length of the set. */
521 unsigned short length
;
523 /* Word within the current element. */
524 unsigned short word_no
;
526 /* Contents of the actually processed word. When finding next bit
527 it is shifted right, so that the actual bit is always the least
528 significant bit of ACTUAL. */
529 HARD_REG_ELT_TYPE bits
;
532 #define HARD_REG_ELT_BITS UHOST_BITS_PER_WIDE_INT
534 /* The implementation of the iterator functions is fully analogous to
535 the bitmap iterators. */
537 hard_reg_set_iter_init (hard_reg_set_iterator
*iter
, HARD_REG_SET set
,
538 unsigned min
, unsigned *regno
)
540 #ifdef HARD_REG_SET_LONGS
542 iter
->length
= HARD_REG_SET_LONGS
;
547 iter
->word_no
= min
/ HARD_REG_ELT_BITS
;
548 if (iter
->word_no
< iter
->length
)
550 iter
->bits
= iter
->pelt
[iter
->word_no
];
551 iter
->bits
>>= min
% HARD_REG_ELT_BITS
;
553 /* This is required for correct search of the next bit. */
560 hard_reg_set_iter_set (hard_reg_set_iterator
*iter
, unsigned *regno
)
564 /* Return false when we're advanced past the end of the set. */
565 if (iter
->word_no
>= iter
->length
)
570 /* Find the correct bit and return it. */
571 while (!(iter
->bits
& 1))
576 return (*regno
< FIRST_PSEUDO_REGISTER
);
579 /* Round to the beginning of the next word. */
580 *regno
= (*regno
+ HARD_REG_ELT_BITS
- 1);
581 *regno
-= *regno
% HARD_REG_ELT_BITS
;
583 /* Find the next non-zero word. */
584 while (++iter
->word_no
< iter
->length
)
586 iter
->bits
= iter
->pelt
[iter
->word_no
];
589 *regno
+= HARD_REG_ELT_BITS
;
595 hard_reg_set_iter_next (hard_reg_set_iterator
*iter
, unsigned *regno
)
601 #define EXECUTE_IF_SET_IN_HARD_REG_SET(SET, MIN, REGNUM, ITER) \
602 for (hard_reg_set_iter_init (&(ITER), (SET), (MIN), &(REGNUM)); \
603 hard_reg_set_iter_set (&(ITER), &(REGNUM)); \
604 hard_reg_set_iter_next (&(ITER), &(REGNUM)))
607 /* Define some standard sets of registers. */
609 /* Indexed by hard register number, contains 1 for registers
610 that are being used for global register decls.
611 These must be exempt from ordinary flow analysis
612 and are also considered fixed. */
614 extern char global_regs
[FIRST_PSEUDO_REGISTER
];
616 struct simplifiable_subreg
;
619 struct simplifiable_subregs_hasher
: typed_noop_remove
<simplifiable_subreg
>
621 typedef simplifiable_subreg
*value_type
;
622 typedef const subreg_shape
*compare_type
;
624 static inline hashval_t
hash (const simplifiable_subreg
*);
625 static inline bool equal (const simplifiable_subreg
*, const subreg_shape
*);
628 struct target_hard_regs
{
631 /* The set of registers that actually exist on the current target. */
632 HARD_REG_SET x_accessible_reg_set
;
634 /* The set of registers that should be considered to be register
635 operands. It is a subset of x_accessible_reg_set. */
636 HARD_REG_SET x_operand_reg_set
;
638 /* Indexed by hard register number, contains 1 for registers
639 that are fixed use (stack pointer, pc, frame pointer, etc.;.
640 These are the registers that cannot be used to allocate
641 a pseudo reg whose life does not cross calls. */
642 char x_fixed_regs
[FIRST_PSEUDO_REGISTER
];
644 /* The same info as a HARD_REG_SET. */
645 HARD_REG_SET x_fixed_reg_set
;
647 /* Indexed by hard register number, contains 1 for registers
648 that are fixed use or are clobbered by function calls.
649 These are the registers that cannot be used to allocate
650 a pseudo reg whose life crosses calls. */
651 char x_call_used_regs
[FIRST_PSEUDO_REGISTER
];
653 char x_call_really_used_regs
[FIRST_PSEUDO_REGISTER
];
655 /* The same info as a HARD_REG_SET. */
656 HARD_REG_SET x_call_used_reg_set
;
658 /* Contains registers that are fixed use -- i.e. in fixed_reg_set -- or
659 a function value return register or TARGET_STRUCT_VALUE_RTX or
660 STATIC_CHAIN_REGNUM. These are the registers that cannot hold quantities
661 across calls even if we are willing to save and restore them. */
662 HARD_REG_SET x_call_fixed_reg_set
;
664 /* Contains 1 for registers that are set or clobbered by calls. */
665 /* ??? Ideally, this would be just call_used_regs plus global_regs, but
666 for someone's bright idea to have call_used_regs strictly include
667 fixed_regs. Which leaves us guessing as to the set of fixed_regs
668 that are actually preserved. We know for sure that those associated
669 with the local stack frame are safe, but scant others. */
670 HARD_REG_SET x_regs_invalidated_by_call
;
672 /* Call used hard registers which can not be saved because there is no
674 HARD_REG_SET x_no_caller_save_reg_set
;
676 /* Table of register numbers in the order in which to try to use them. */
677 int x_reg_alloc_order
[FIRST_PSEUDO_REGISTER
];
679 /* The inverse of reg_alloc_order. */
680 int x_inv_reg_alloc_order
[FIRST_PSEUDO_REGISTER
];
682 /* For each reg class, a HARD_REG_SET saying which registers are in it. */
683 HARD_REG_SET x_reg_class_contents
[N_REG_CLASSES
];
685 /* For each reg class, a boolean saying whether the class contains only
687 bool x_class_only_fixed_regs
[N_REG_CLASSES
];
689 /* For each reg class, number of regs it contains. */
690 unsigned int x_reg_class_size
[N_REG_CLASSES
];
692 /* For each reg class, table listing all the classes contained in it. */
693 enum reg_class x_reg_class_subclasses
[N_REG_CLASSES
][N_REG_CLASSES
];
695 /* For each pair of reg classes,
696 a largest reg class contained in their union. */
697 enum reg_class x_reg_class_subunion
[N_REG_CLASSES
][N_REG_CLASSES
];
699 /* For each pair of reg classes,
700 the smallest reg class that contains their union. */
701 enum reg_class x_reg_class_superunion
[N_REG_CLASSES
][N_REG_CLASSES
];
703 /* Vector indexed by hardware reg giving its name. */
704 const char *x_reg_names
[FIRST_PSEUDO_REGISTER
];
706 /* Records which registers can form a particular subreg, with the subreg
707 being identified by its outer mode, inner mode and offset. */
708 hash_table
<simplifiable_subregs_hasher
> *x_simplifiable_subregs
;
711 extern struct target_hard_regs default_target_hard_regs
;
712 #if SWITCHABLE_TARGET
713 extern struct target_hard_regs
*this_target_hard_regs
;
715 #define this_target_hard_regs (&default_target_hard_regs)
718 #define accessible_reg_set \
719 (this_target_hard_regs->x_accessible_reg_set)
720 #define operand_reg_set \
721 (this_target_hard_regs->x_operand_reg_set)
723 (this_target_hard_regs->x_fixed_regs)
724 #define fixed_reg_set \
725 (this_target_hard_regs->x_fixed_reg_set)
726 #define call_used_regs \
727 (this_target_hard_regs->x_call_used_regs)
728 #define call_really_used_regs \
729 (this_target_hard_regs->x_call_really_used_regs)
730 #define call_used_reg_set \
731 (this_target_hard_regs->x_call_used_reg_set)
732 #define call_fixed_reg_set \
733 (this_target_hard_regs->x_call_fixed_reg_set)
734 #define regs_invalidated_by_call \
735 (this_target_hard_regs->x_regs_invalidated_by_call)
736 #define no_caller_save_reg_set \
737 (this_target_hard_regs->x_no_caller_save_reg_set)
738 #define reg_alloc_order \
739 (this_target_hard_regs->x_reg_alloc_order)
740 #define inv_reg_alloc_order \
741 (this_target_hard_regs->x_inv_reg_alloc_order)
742 #define reg_class_contents \
743 (this_target_hard_regs->x_reg_class_contents)
744 #define class_only_fixed_regs \
745 (this_target_hard_regs->x_class_only_fixed_regs)
746 #define reg_class_size \
747 (this_target_hard_regs->x_reg_class_size)
748 #define reg_class_subclasses \
749 (this_target_hard_regs->x_reg_class_subclasses)
750 #define reg_class_subunion \
751 (this_target_hard_regs->x_reg_class_subunion)
752 #define reg_class_superunion \
753 (this_target_hard_regs->x_reg_class_superunion)
755 (this_target_hard_regs->x_reg_names)
757 /* Vector indexed by reg class giving its name. */
759 extern const char * reg_class_names
[];
761 /* Given a hard REGN a FROM mode and a TO mode, return nonzero if
762 REGN cannot change modes between the specified modes. */
763 #define REG_CANNOT_CHANGE_MODE_P(REGN, FROM, TO) \
764 CANNOT_CHANGE_MODE_CLASS (FROM, TO, REGNO_REG_CLASS (REGN))
766 #endif /* ! GCC_HARD_REG_SET_H */