OSDN Git Service

($(OBJC_O)): Also depend on $(GCC_PASSES).
[pf3gnuchains/gcc-fork.git] / gcc / basic-block.h
1 /* Define control and data flow tables, and regsets.
2    Copyright (C) 1987, 1997 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, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21
22 /* Number of bits in each actual element of a regset.  We get slightly
23    better code for reg%bits and reg/bits if bits is unsigned, assuming
24    it is a power of 2.  */
25
26 #define REGSET_ELT_BITS ((unsigned) HOST_BITS_PER_WIDE_INT)
27
28 /* Type to use for a regset element.  Note that lots of code assumes
29    that the initial part of a regset that contains information on the
30    hard registers is the same format as a HARD_REG_SET.  */
31
32 #define REGSET_ELT_TYPE unsigned HOST_WIDE_INT
33
34 /* Define the type for a pointer to a set with a bit for each
35    (hard or pseudo) register.  */
36
37 typedef REGSET_ELT_TYPE *regset;
38
39 /* Size of a regset for the current function,
40    in (1) bytes and (2) elements.  */
41
42 extern int regset_bytes;
43 extern int regset_size;
44
45 /* clear a register set */
46 #define CLEAR_REG_SET(TO)                                               \
47 do { register REGSET_ELT_TYPE *scan_tp_ = (TO);                         \
48      register int i_;                                                   \
49      for (i_ = 0; i_ < regset_size; i_++)                               \
50        *scan_tp_++ = 0; } while (0)
51
52 /* copy a register to another register */
53 #define COPY_REG_SET(TO, FROM)                                          \
54 do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM);     \
55      register int i_;                                                   \
56      for (i_ = 0; i_ < regset_size; i_++)                               \
57        *scan_tp_++ = *scan_fp_++; } while (0)
58
59 /* complent a register set, storing it in a second register set.  */
60 #define COMPL_REG_SET(TO, FROM)                                         \
61 do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM);     \
62      register int i_;                                                   \
63      for (i_ = 0; i_ < regset_size; i_++)                               \
64        *scan_tp_++ = ~ *scan_fp_++; } while (0)
65
66 /* and a register set with a second register set.  */
67 #define AND_REG_SET(TO, FROM)                                           \
68 do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM);     \
69      register int i_;                                                   \
70      for (i_ = 0; i_ < regset_size; i_++)                               \
71        *scan_tp_++ &= *scan_fp_++; } while (0)
72
73 /* and the complement of a register set to a register set.  */
74 #define AND_COMPL_REG_SET(TO, FROM)                                     \
75 do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM);     \
76      register int i_;                                                   \
77      for (i_ = 0; i_ < regset_size; i_++)                               \
78        *scan_tp_++ &= ~ *scan_fp_++; } while (0)
79
80 /* inclusive or a register set with a second register set.  */
81 #define IOR_REG_SET(TO, FROM)                                           \
82 do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM);     \
83      register int i_;                                                   \
84      for (i_ = 0; i_ < regset_size; i_++)                               \
85        *scan_tp_++ |= *scan_fp_++; } while (0)
86
87 /* complement two register sets and or in the result into a third.  */
88 #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2)                         \
89 do { register REGSET_ELT_TYPE *scan_tp_ = (TO);                         \
90      register REGSET_ELT_TYPE *scan_fp1_ = (FROM1);                     \
91      register REGSET_ELT_TYPE *scan_fp2_ = (FROM2);                     \
92      register int i_;                                                   \
93      for (i_ = 0; i_ < regset_size; i_++)                               \
94        *scan_tp_++ |= *scan_fp1_++ & ~ *scan_fp2_++; } while (0)
95
96 /* Clear a single register in a register set.  */
97 #define CLEAR_REGNO_REG_SET(TO, REG)                                    \
98 do {                                                                    \
99   register REGSET_ELT_TYPE *tp_ = (TO);                                 \
100   tp_[ (REG) / REGSET_ELT_BITS ]                                        \
101     &= ~ ((REGSET_ELT_TYPE) 1 << ((REG) % REGSET_ELT_BITS)); } while (0);
102
103 /* Set a single register in a register set.  */
104 #define SET_REGNO_REG_SET(TO, REG)                                      \
105 do {                                                                    \
106   register REGSET_ELT_TYPE *tp_ = (TO);                                 \
107   tp_[ (REG) / REGSET_ELT_BITS ]                                        \
108     |= ((REGSET_ELT_TYPE) 1 << ((REG) % REGSET_ELT_BITS)); } while (0);
109
110 /* Return true if a register is set in a register set.  */
111 #define REGNO_REG_SET_P(TO, REG)                                        \
112  (((TO)[ (REG) / REGSET_ELT_BITS ]                                      \
113    & (((REGSET_ELT_TYPE)1) << (REG) % REGSET_ELT_BITS)) != 0)
114
115 /* Copy the hard registers in a register set to the hard register set.  */
116 #define REG_SET_TO_HARD_REG_SET(TO, FROM)                               \
117 do {                                                                    \
118   int i_;                                                               \
119   CLEAR_HARD_REG_SET (TO);                                              \
120   for (i_ = 0; i_ < FIRST_PSEUDO_REGISTER; i_++)                        \
121     if (REGNO_REG_SET_P (FROM, i_))                                     \
122       SET_HARD_REG_BIT (TO, i_);                                        \
123 } while (0)
124
125 /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
126    register number and executing CODE for all registers that are set. */
127 #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE)            \
128 do {                                                                    \
129   register int i_ = (MIN) / REGSET_ELT_BITS;                            \
130   register int shift_ = (MIN) % REGSET_ELT_BITS;                        \
131   register REGSET_ELT_TYPE *scan_rs_ = (REGSET) + i_;                   \
132   for ( ; i_ < regset_size; i_++)                                       \
133     {                                                                   \
134       REGSET_ELT_TYPE word_ = *scan_rs_++;                              \
135       if (word_)                                                        \
136         {                                                               \
137           REGSET_ELT_TYPE j_;                                           \
138           REGNUM = (i_ * REGSET_ELT_BITS) + shift_;                     \
139           for (j_ = ((REGSET_ELT_TYPE)1) << shift_;                     \
140                j_ != 0;                                                 \
141                (j_ <<= 1), REGNUM++)                                    \
142             {                                                           \
143               if (word_ & j_)                                           \
144                 {                                                       \
145                   CODE;                                                 \
146                   word_ &= ~ j_;                                        \
147                   if (!word_)                                           \
148                     break;                                              \
149                 }                                                       \
150             }                                                           \
151         }                                                               \
152       shift_ = 0;                                                       \
153     }                                                                   \
154 } while (0)
155
156 /* Like EXECUTE_IF_SET_IN_REG_SET, but also clear the register set.  */
157 #define EXECUTE_IF_SET_AND_RESET_IN_REG_SET(REGSET, MIN, REGNUM, CODE)  \
158 do {                                                                    \
159   register int i_ = (MIN) / REGSET_ELT_BITS;                            \
160   register int shift_ = (MIN) % REGSET_ELT_BITS;                        \
161   register REGSET_ELT_TYPE *scan_rs_ = (REGSET) + i_;                   \
162   for ( ; i_ < regset_size; i_++)                                       \
163     {                                                                   \
164       REGSET_ELT_TYPE word_ = *scan_rs_++;                              \
165       if (word_)                                                        \
166         {                                                               \
167           REGSET_ELT_TYPE j_;                                           \
168           REGNUM = (i_ * REGSET_ELT_BITS) + shift_;                     \
169           scan_rs_[-1] = 0;                                             \
170           for (j_ = ((REGSET_ELT_TYPE)1) << shift_;                     \
171                j_ != 0;                                                 \
172                (j_ <<= 1), REGNUM++)                                    \
173             {                                                           \
174               if (word_ & j_)                                           \
175                 {                                                       \
176                   CODE;                                                 \
177                   word_ &= ~ j_;                                        \
178                   if (!word_)                                           \
179                     break;                                              \
180                 }                                                       \
181             }                                                           \
182         }                                                               \
183       shift_ = 0;                                                       \
184     }                                                                   \
185 } while (0)
186
187 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
188    REGNUM to the register number and executing CODE for all registers that are
189    set in both regsets. */
190 #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE)  \
191 do {                                                                    \
192   register int i_ = (MIN) / REGSET_ELT_BITS;                            \
193   register int shift_ = (MIN) % REGSET_ELT_BITS;                        \
194   register REGSET_ELT_TYPE *scan_rs1_ = (REGSET1) + i_;                 \
195   register REGSET_ELT_TYPE *scan_rs2_ = (REGSET2) + i_;                 \
196   for ( ; i_ < regset_size; i_++)                                       \
197     {                                                                   \
198       REGSET_ELT_TYPE word_ = *scan_rs1_++ & *scan_rs2_++;              \
199       if (word_)                                                        \
200         {                                                               \
201           REGSET_ELT_TYPE j_;                                           \
202           REGNUM = (i_ * REGSET_ELT_BITS) + shift_;                     \
203           for (j_ = ((REGSET_ELT_TYPE)1) << shift_;                     \
204                j_ != 0;                                                 \
205                (j_ <<= 1), REGNUM++)                                    \
206             {                                                           \
207               if (word_ & j_)                                           \
208                 {                                                       \
209                   CODE;                                                 \
210                   word_ &= ~ j_;                                        \
211                   if (!word_)                                           \
212                     break;                                              \
213                 }                                                       \
214             }                                                           \
215         }                                                               \
216       shift_ = 0;                                                       \
217     }                                                                   \
218 } while (0)
219
220 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
221    REGNUM to the register number and executing CODE for all registers that are
222    set in the first regset and not set in the second. */
223 #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
224 do {                                                                    \
225   register int i_ = (MIN) / REGSET_ELT_BITS;                            \
226   register int shift_ = (MIN) % REGSET_ELT_BITS;                        \
227   register REGSET_ELT_TYPE *scan_rs1_ = (REGSET1) + i_;                 \
228   register REGSET_ELT_TYPE *scan_rs2_ = (REGSET2) + i_;                 \
229   for ( ; i_ < regset_size; i_++)                                       \
230     {                                                                   \
231       REGSET_ELT_TYPE word_ = *scan_rs1_++ & ~ *scan_rs2_++;            \
232       if (word_)                                                        \
233         {                                                               \
234           REGSET_ELT_TYPE j_;                                           \
235           REGNUM = (i_ * REGSET_ELT_BITS) + shift_;                     \
236           for (j_ = ((REGSET_ELT_TYPE)1) << shift_;                     \
237                j_ != 0;                                                 \
238                (j_ <<= 1), REGNUM++)                                    \
239             {                                                           \
240               if (word_ & j_)                                           \
241                 {                                                       \
242                   CODE;                                                 \
243                   word_ &= ~ j_;                                        \
244                   if (!word_)                                           \
245                     break;                                              \
246                 }                                                       \
247             }                                                           \
248         }                                                               \
249       shift_ = 0;                                                       \
250     }                                                                   \
251 } while (0)
252
253 /* Allocate a register set with oballoc.  */
254 #define OBSTACK_ALLOC_REG_SET(OBSTACK)                                  \
255   ((regset) obstack_alloc (OBSTACK, regset_bytes))
256
257 /* Allocate a register set with alloca.  */
258 #define ALLOCA_REG_SET() ((regset) alloca (regset_bytes))
259
260 /* Number of basic blocks in the current function.  */
261
262 extern int n_basic_blocks;
263
264 /* Index by basic block number, get first insn in the block.  */
265
266 extern rtx *basic_block_head;
267
268 /* Index by basic block number, get last insn in the block.  */
269
270 extern rtx *basic_block_end;
271
272 /* Index by basic block number, get address of regset
273    describing the registers live at the start of that block.  */
274
275 extern regset *basic_block_live_at_start;
276
277 /* Indexed by n, gives number of basic block that  (REG n) is used in.
278    If the value is REG_BLOCK_GLOBAL (-2),
279    it means (REG n) is used in more than one basic block.
280    REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know.
281    This information remains valid for the rest of the compilation
282    of the current function; it is used to control register allocation.  */
283
284 #define REG_BLOCK_UNKNOWN -1
285 #define REG_BLOCK_GLOBAL -2
286
287 #define REG_BASIC_BLOCK(N) (reg_n_info[(N)].basic_block)