hard-reg-set.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* Sets (bit vectors) of hard registers, and operations on them.
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GNU CC
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* Define the type of a set of hard registers. */
  18. /* If HARD_REG_SET is a macro, its definition is a scalar type
  19. that has enough bits for all the target machine's hard registers.
  20. Otherwise, it is a typedef for a suitable array of longs,
  21. and HARD_REG_SET_LONGS is how many. */
  22. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_CHAR
  23. #define HARD_REG_SET char
  24. #else
  25. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_SHORT
  26. #define HARD_REG_SET short
  27. #else
  28. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_INT
  29. #define HARD_REG_SET int
  30. #else
  31. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_LONG
  32. #define HARD_REG_SET long
  33. #else
  34. #define HARD_REG_SET_LONGS \
  35. ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_LONG - 1) / HOST_BITS_PER_LONG)
  36. typedef long HARD_REG_SET[HARD_REG_SET_LONGS];
  37. #endif
  38. #endif
  39. #endif
  40. #endif
  41. /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT
  42. to set, clear or test one bit in a hard reg set of type HARD_REG_SET.
  43. All three take two arguments: the set and the register number.
  44. In the case where sets are arrays of longs, the first argument
  45. is actually a pointer to a long.
  46. Define two macros for initializing a set:
  47. CLEAR_HARD_REG_SET and SET_HARD_REG_SET.
  48. These take just one argument.
  49. Also define macros for copying hard reg sets:
  50. COPY_HARD_REG_SET and COMPL_HARD_REG_SET.
  51. These take two arguments TO and FROM; they read from FROM
  52. and store into TO. COMPL_HARD_REG_SET complements each bit.
  53. Also define macros for combining hard reg sets:
  54. IOR_HARD_REG_SET and AND_HARD_REG_SET.
  55. These take two arguments TO and FROM; they read from FROM
  56. and combine bitwise into TO. Define also two variants
  57. IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET
  58. which use the complement of the set FROM.
  59. Also define GO_IF_HARD_REG_SUBSET (X, Y, TO):
  60. if X is a subset of Y, go to TO.
  61. */
  62. #ifdef HARD_REG_SET
  63. #define SET_HARD_REG_BIT(SET, BIT) \
  64. ((SET) |= 1 << (BIT))
  65. #define CLEAR_HARD_REG_BIT(SET, BIT) \
  66. ((SET) &= ~(1 << (BIT)))
  67. #define TEST_HARD_REG_BIT(SET, BIT) \
  68. ((SET) & (1 << (BIT)))
  69. #define CLEAR_HARD_REG_SET(TO) ((TO) = 0)
  70. #define SET_HARD_REG_SET(TO) ((TO) = -1)
  71. #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM))
  72. #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM))
  73. #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM))
  74. #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM))
  75. #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM))
  76. #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM))
  77. #define GO_IF_HARD_REG_SUBSET(X,Y,TO) if (0 == ((X) & ~(Y))) goto TO
  78. #else
  79. #define SET_HARD_REG_BIT(SET, BIT) \
  80. ((SET)[(BIT) / HOST_BITS_PER_LONG] |= 1 << ((BIT) % HOST_BITS_PER_LONG))
  81. #define CLEAR_HARD_REG_BIT(SET, BIT) \
  82. ((SET)[(BIT) / HOST_BITS_PER_LONG] &= ~(1 << ((BIT) % HOST_BITS_PER_LONG)))
  83. #define TEST_HARD_REG_BIT(SET, BIT) \
  84. ((SET)[(BIT) / HOST_BITS_PER_LONG] & (1 << ((BIT) % HOST_BITS_PER_LONG)))
  85. #define CLEAR_HARD_REG_SET(TO) \
  86. { register long *scan_tp_ = (TO); \
  87. register int i; \
  88. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  89. *scan_tp_++ = 0; }
  90. #define SET_HARD_REG_SET(TO) \
  91. { register long *scan_tp_ = (TO); \
  92. register int i; \
  93. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  94. *scan_tp_++ = -1; }
  95. #define COPY_HARD_REG_SET(TO, FROM) \
  96. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  97. register int i; \
  98. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  99. *scan_tp_++ = *scan_fp_++; }
  100. #define COMPL_HARD_REG_SET(TO, FROM) \
  101. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  102. register int i; \
  103. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  104. *scan_tp_++ = ~ *scan_fp_++; }
  105. #define AND_HARD_REG_SET(TO, FROM) \
  106. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  107. register int i; \
  108. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  109. *scan_tp_++ &= *scan_fp_++; }
  110. #define AND_COMPL_HARD_REG_SET(TO, FROM) \
  111. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  112. register int i; \
  113. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  114. *scan_tp_++ &= ~ *scan_fp_++; }
  115. #define IOR_HARD_REG_SET(TO, FROM) \
  116. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  117. register int i; \
  118. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  119. *scan_tp_++ |= *scan_fp_++; }
  120. #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
  121. { register long *scan_tp_ = (TO), *scan_fp_ = (FROM); \
  122. register int i; \
  123. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  124. *scan_tp_++ |= ~ *scan_fp_++; }
  125. #define GO_IF_HARD_REG_SUBSET(X,Y,TO) \
  126. { register long *scan_xp_ = (X), *scan_yp_ = (Y); \
  127. register int i; \
  128. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  129. if (0 != (*scan_xp_++ & ~*scan_yp_++)) break; \
  130. if (i == HARD_REG_SET_LONGS) goto TO; }
  131. #endif
  132. /* Define some standard sets of registers. */
  133. /* Indexed by hard register number, contains 1 for registers
  134. that are fixed use (stack pointer, pc, frame pointer, etc.).
  135. These are the registers that cannot be used to allocate
  136. a pseudo reg whose life does not cross calls. */
  137. extern char fixed_regs[FIRST_PSEUDO_REGISTER];
  138. /* The same info as a HARD_REG_SET. */
  139. extern HARD_REG_SET fixed_reg_set;
  140. /* Indexed by hard register number, contains 1 for registers
  141. that are fixed use or are clobbered by function calls.
  142. These are the registers that cannot be used to allocate
  143. a pseudo reg whose life crosses calls. */
  144. extern char call_used_regs[FIRST_PSEUDO_REGISTER];
  145. /* The same info as a HARD_REG_SET. */
  146. extern HARD_REG_SET call_used_reg_set;
  147. /* For each reg class, a HARD_REG_SET saying which registers are in it. */
  148. extern HARD_REG_SET reg_class_contents[];
  149. /* For each reg class, table listing all the containing classes. */
  150. extern enum reg_class reg_class_superclasses[N_REG_CLASSES][N_REG_CLASSES];
  151. /* For each reg class, table listing all the classes contained in it. */
  152. extern enum reg_class reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES];
  153. /* For each pair of reg classes,
  154. a largest reg class contained in their union. */
  155. extern enum reg_class reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES];