hard-reg-set.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_LONGS] HARD_REG_SET;
  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 int i; \
  87. register long *tp = (TO); \
  88. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  89. *tp++ = 0 }
  90. #define SET_HARD_REG_SET(TO) \
  91. { register int i; \
  92. register long *tp = (TO); \
  93. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  94. *tp++ = -1 }
  95. #define COPY_HARD_REG_SET(TO, FROM) \
  96. { register int i; \
  97. register long *tp = (TO), *fp = (FROM); \
  98. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  99. *tp++ = *fp++; }
  100. #define COMPL_HARD_REG_SET(TO, FROM) \
  101. { register int i; \
  102. register long *tp = (TO), *fp = (FROM); \
  103. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  104. *tp++ = ~ *fp++; }
  105. #define AND_HARD_REG_SET(TO, FROM) \
  106. { register int i; \
  107. register long *tp = (TO), *fp = (FROM); \
  108. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  109. *tp++ &= *fp++; }
  110. #define AND_COMPL_HARD_REG_SET(TO, FROM) \
  111. { register int i; \
  112. register long *tp = (TO), *fp = (FROM); \
  113. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  114. *tp++ &= ~ *fp++; }
  115. #define IOR_HARD_REG_SET(TO, FROM) \
  116. { register int i; \
  117. register long *tp = (TO), *fp = (FROM); \
  118. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  119. *tp++ |= *fp++; }
  120. #define IOR_COMPL_HARD_REG_SET(TO, FROM) \
  121. { register int i; \
  122. register long *tp = (TO), *fp = (FROM); \
  123. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  124. *tp++ |= ~ *fp++; }
  125. #define GO_IF_HARD_REG_SUBSET(X,Y,TO) \
  126. { register int i; \
  127. register long *xp = (X), *yp = (Y); \
  128. for (i = 0; i < HARD_REG_SET_LONGS; i++) \
  129. if (0 != (*xp++ & ~yp++)) break; \
  130. if (i == HARD_REG_SET_LONGS) goto TO; }
  131. #endif