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