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