home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / hard-reg-set.h < prev    next >
C/C++ Source or Header  |  1991-06-03  |  9KB  |  259 lines

  1. /* Sets (bit vectors) of hard registers, and operations on them.
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* Define the type of a set of hard registers.  */
  22.  
  23. /* If HARD_REG_SET is a macro, its definition is a scalar type
  24.    that has enough bits for all the target machine's hard registers.
  25.    Otherwise, it is a typedef for a suitable array of longs,
  26.    and HARD_REG_SET_LONGS is how many.  */
  27.  
  28. #ifndef HOST_BITS_PER_LONG_LONG
  29. #define HOST_BITS_PER_LONG_LONG (2 * HOST_BITS_PER_LONG)
  30. #endif
  31.  
  32. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_CHAR
  33. #define HARD_REG_SET char
  34. #else
  35. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_SHORT
  36. #define HARD_REG_SET short
  37. #else
  38. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_INT
  39. #define HARD_REG_SET int
  40. #else
  41. #if FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_LONG
  42. #define HARD_REG_SET long
  43. #else
  44. #if 0 && defined (__GNUC__) && FIRST_PSEUDO_REGISTER <= HOST_BITS_PER_LONGLONG
  45. #define HARD_REG_SET long long
  46. #else
  47. #define HARD_REG_SET_LONGS \
  48.  ((FIRST_PSEUDO_REGISTER + HOST_BITS_PER_LONG - 1) / HOST_BITS_PER_LONG)
  49. typedef long HARD_REG_SET[HARD_REG_SET_LONGS];
  50. #endif
  51. #endif
  52. #endif
  53. #endif
  54. #endif
  55.  
  56. /* HARD_CONST is used to cast a constant to a HARD_REG_SET
  57.    if that is a scalar wider than an integer.  */
  58.  
  59. #ifdef HARD_REG_SET
  60. #define HARD_CONST(X) ((HARD_REG_SET) (X))
  61. #else
  62. #define HARD_CONST(X) (X)
  63. #endif
  64.  
  65. /* Define macros SET_HARD_REG_BIT, CLEAR_HARD_REG_BIT and TEST_HARD_REG_BIT
  66.    to set, clear or test one bit in a hard reg set of type HARD_REG_SET.
  67.    All three take two arguments: the set and the register number.
  68.  
  69.    In the case where sets are arrays of longs, the first argument
  70.    is actually a pointer to a long.
  71.  
  72.    Define two macros for initializing a set:
  73.    CLEAR_HARD_REG_SET and SET_HARD_REG_SET.
  74.    These take just one argument.
  75.  
  76.    Also define macros for copying hard reg sets:
  77.    COPY_HARD_REG_SET and COMPL_HARD_REG_SET.
  78.    These take two arguments TO and FROM; they read from FROM
  79.    and store into TO.  COMPL_HARD_REG_SET complements each bit.
  80.  
  81.    Also define macros for combining hard reg sets:
  82.    IOR_HARD_REG_SET and AND_HARD_REG_SET.
  83.    These take two arguments TO and FROM; they read from FROM
  84.    and combine bitwise into TO.  Define also two variants
  85.    IOR_COMPL_HARD_REG_SET and AND_COMPL_HARD_REG_SET
  86.    which use the complement of the set FROM.
  87.  
  88.    Also define GO_IF_HARD_REG_SUBSET (X, Y, TO):
  89.    if X is a subset of Y, go to TO.
  90. */
  91.  
  92. #ifdef HARD_REG_SET
  93.  
  94. #define SET_HARD_REG_BIT(SET, BIT)  \
  95.  ((SET) |= HARD_CONST (1) << (BIT))
  96. #define CLEAR_HARD_REG_BIT(SET, BIT)  \
  97.  ((SET) &= ~(HARD_CONST (1) << (BIT)))
  98. #define TEST_HARD_REG_BIT(SET, BIT)  \
  99.  ((SET) & (HARD_CONST (1) << (BIT)))
  100.  
  101. #define CLEAR_HARD_REG_SET(TO) ((TO) = HARD_CONST (0))
  102. #define SET_HARD_REG_SET(TO) ((TO) = HARD_CONST (-1))
  103.  
  104. #define COPY_HARD_REG_SET(TO, FROM) ((TO) = (FROM))
  105. #define COMPL_HARD_REG_SET(TO, FROM) ((TO) = ~(FROM))
  106.  
  107. #define IOR_HARD_REG_SET(TO, FROM) ((TO) |= (FROM))
  108. #define IOR_COMPL_HARD_REG_SET(TO, FROM) ((TO) |= ~ (FROM))
  109. #define AND_HARD_REG_SET(TO, FROM) ((TO) &= (FROM))
  110. #define AND_COMPL_HARD_REG_SET(TO, FROM) ((TO) &= ~ (FROM))
  111.  
  112. #define GO_IF_HARD_REG_SUBSET(X,Y,TO) if (HARD_CONST (0) == ((X) & ~(Y))) goto TO
  113. #else
  114.  
  115. #define UHOST_BITS_PER_LONG ((unsigned) HOST_BITS_PER_LONG)
  116.  
  117. #define SET_HARD_REG_BIT(SET, BIT)  \
  118.   ((SET)[(BIT) / UHOST_BITS_PER_LONG] |= 1 << ((BIT) % UHOST_BITS_PER_LONG))
  119. #define CLEAR_HARD_REG_BIT(SET, BIT)  \
  120.   ((SET)[(BIT) / UHOST_BITS_PER_LONG] &= ~(1 << ((BIT) % UHOST_BITS_PER_LONG)))
  121. #define TEST_HARD_REG_BIT(SET, BIT)  \
  122.   ((SET)[(BIT) / UHOST_BITS_PER_LONG] & (1 << ((BIT) % UHOST_BITS_PER_LONG)))
  123.  
  124. #define CLEAR_HARD_REG_SET(TO)  \
  125. do { register long *scan_tp_ = (TO);                \
  126.      register int i;                        \
  127.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  128.        *scan_tp_++ = 0; } while (0)
  129.  
  130. #define SET_HARD_REG_SET(TO)  \
  131. do { register long *scan_tp_ = (TO);                \
  132.      register int i;                        \
  133.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  134.        *scan_tp_++ = -1; } while (0)
  135.  
  136. #define COPY_HARD_REG_SET(TO, FROM)  \
  137. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  138.      register int i;                        \
  139.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  140.        *scan_tp_++ = *scan_fp_++; } while (0)
  141.  
  142. #define COMPL_HARD_REG_SET(TO, FROM)  \
  143. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  144.      register int i;                        \
  145.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  146.        *scan_tp_++ = ~ *scan_fp_++; } while (0)
  147.  
  148. #define AND_HARD_REG_SET(TO, FROM)  \
  149. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  150.      register int i;                        \
  151.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  152.        *scan_tp_++ &= *scan_fp_++; } while (0)
  153.  
  154. #define AND_COMPL_HARD_REG_SET(TO, FROM)  \
  155. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  156.      register int i;                        \
  157.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  158.        *scan_tp_++ &= ~ *scan_fp_++; } while (0)
  159.  
  160. #define IOR_HARD_REG_SET(TO, FROM)  \
  161. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  162.      register int i;                        \
  163.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  164.        *scan_tp_++ |= *scan_fp_++; } while (0)
  165.  
  166. #define IOR_COMPL_HARD_REG_SET(TO, FROM)  \
  167. do { register long *scan_tp_ = (TO), *scan_fp_ = (FROM);    \
  168.      register int i;                        \
  169.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  170.        *scan_tp_++ |= ~ *scan_fp_++; } while (0)
  171.  
  172. #define GO_IF_HARD_REG_SUBSET(X,Y,TO)  \
  173. do { register long *scan_xp_ = (X), *scan_yp_ = (Y);        \
  174.      register int i;                        \
  175.      for (i = 0; i < HARD_REG_SET_LONGS; i++)            \
  176.        if (0 != (*scan_xp_++ & ~*scan_yp_++)) break;        \
  177.      if (i == HARD_REG_SET_LONGS) goto TO; } while (0)
  178.  
  179. #endif
  180.  
  181. /* Define some standard sets of registers.  */
  182.  
  183. /* Indexed by hard register number, contains 1 for registers
  184.    that are fixed use (stack pointer, pc, frame pointer, etc.).
  185.    These are the registers that cannot be used to allocate
  186.    a pseudo reg whose life does not cross calls.  */
  187.  
  188. extern char fixed_regs[FIRST_PSEUDO_REGISTER];
  189.  
  190. /* The same info as a HARD_REG_SET.  */
  191.  
  192. extern HARD_REG_SET fixed_reg_set;
  193.  
  194. /* Indexed by hard register number, contains 1 for registers
  195.    that are fixed use or are clobbered by function calls.
  196.    These are the registers that cannot be used to allocate
  197.    a pseudo reg whose life crosses calls.  */
  198.  
  199. extern char call_used_regs[FIRST_PSEUDO_REGISTER];
  200.  
  201. /* The same info as a HARD_REG_SET.  */
  202.  
  203. extern HARD_REG_SET call_used_reg_set;
  204.   
  205. /* Indexed by hard register number, contains 1 for registers that are
  206.    fixed use -- i.e. in fixed_regs -- or a function value return register
  207.    or STRUCT_VALUE_REGNUM or STATIC_CHAIN_REGNUM.  These are the
  208.    registers that cannot hold quantities across calls even if we are
  209.    willing to save and restore them.  */
  210.  
  211. extern char call_fixed_regs[FIRST_PSEUDO_REGISTER];
  212.  
  213. /* The same info as a HARD_REG_SET.  */
  214.  
  215. extern HARD_REG_SET call_fixed_reg_set;
  216.  
  217. /* Indexed by hard register number, contains 1 for registers
  218.    that are being used for global register decls.
  219.    These must be exempt from ordinary flow analysis
  220.    and are also considered fixed.  */
  221.  
  222. extern char global_regs[FIRST_PSEUDO_REGISTER];
  223.  
  224. /* Table of register numbers in the order in which to try to use them.  */
  225.  
  226. #ifdef REG_ALLOC_ORDER   /* Avoid undef symbol in certain broken linkers.  */
  227. extern int reg_alloc_order[FIRST_PSEUDO_REGISTER];
  228. #endif
  229.  
  230. /* For each reg class, a HARD_REG_SET saying which registers are in it.  */
  231.  
  232. extern HARD_REG_SET reg_class_contents[];
  233.  
  234. /* For each reg class, number of regs it contains.  */
  235.  
  236. extern int reg_class_size[N_REG_CLASSES];
  237.  
  238. /* For each reg class, table listing all the containing classes.  */
  239.  
  240. extern enum reg_class reg_class_superclasses[N_REG_CLASSES][N_REG_CLASSES];
  241.  
  242. /* For each reg class, table listing all the classes contained in it.  */
  243.  
  244. extern enum reg_class reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES];
  245.  
  246. /* For each pair of reg classes,
  247.    a largest reg class contained in their union.  */
  248.  
  249. extern enum reg_class reg_class_subunion[N_REG_CLASSES][N_REG_CLASSES];
  250.  
  251. /* For each pair of reg classes,
  252.    the smallest reg class that contains their union.  */
  253.  
  254. extern enum reg_class reg_class_superunion[N_REG_CLASSES][N_REG_CLASSES];
  255.  
  256. /* Number of non-fixed registers.  */
  257.  
  258. extern int n_non_fixed_regs;
  259.