* java/util/Properties.java (load): Only skip line if the first
[official-gcc.git] / gcc / varray.h
blob7351c2af4c4beb5c9b2140229d8228b651901c1d
1 /* Virtual array support.
2 Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
22 #ifndef GCC_VARRAY_H
23 #define GCC_VARRAY_H
25 #ifndef HOST_WIDE_INT
26 #include "machmode.h"
27 #endif
29 #ifndef GCC_SYSTEM_H
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #endif
35 /* Auxiliary structure used inside the varray structure, used for
36 function integration data. */
38 struct const_equiv_data GTY(()) {
39 /* Map pseudo reg number in calling function to equivalent constant. We
40 cannot in general substitute constants into parameter pseudo registers,
41 since some machine descriptions (many RISCs) won't always handle
42 the resulting insns. So if an incoming parameter has a constant
43 equivalent, we record it here, and if the resulting insn is
44 recognizable, we go with it.
46 We also use this mechanism to convert references to incoming arguments
47 and stacked variables. copy_rtx_and_substitute will replace the virtual
48 incoming argument and virtual stacked variables registers with new
49 pseudos that contain pointers into the replacement area allocated for
50 this inline instance. These pseudos are then marked as being equivalent
51 to the appropriate address and substituted if valid. */
52 struct rtx_def *rtx;
54 /* Record the valid age for each entry. The entry is invalid if its
55 age is less than const_age. */
56 unsigned age;
59 /* Enum indicating what the varray contains.
60 If this is changed, `element' in varray.c needs to be updated. */
62 enum varray_data_enum {
63 VARRAY_DATA_C,
64 VARRAY_DATA_UC,
65 VARRAY_DATA_S,
66 VARRAY_DATA_US,
67 VARRAY_DATA_I,
68 VARRAY_DATA_U,
69 VARRAY_DATA_L,
70 VARRAY_DATA_UL,
71 VARRAY_DATA_HINT,
72 VARRAY_DATA_UHINT,
73 VARRAY_DATA_GENERIC,
74 VARRAY_DATA_CPTR,
75 VARRAY_DATA_RTX,
76 VARRAY_DATA_RTVEC,
77 VARRAY_DATA_TREE,
78 VARRAY_DATA_BITMAP,
79 VARRAY_DATA_REG,
80 VARRAY_DATA_CONST_EQUIV,
81 VARRAY_DATA_BB,
82 VARRAY_DATA_TE,
83 NUM_VARRAY_DATA
86 /* Union of various array types that are used. */
87 typedef union varray_data_tag GTY (()) {
88 char GTY ((length ("%0.num_elements"),
89 tag ("VARRAY_DATA_C"))) c[1];
90 unsigned char GTY ((length ("%0.num_elements"),
91 tag ("VARRAY_DATA_UC"))) uc[1];
92 short GTY ((length ("%0.num_elements"),
93 tag ("VARRAY_DATA_S"))) s[1];
94 unsigned short GTY ((length ("%0.num_elements"),
95 tag ("VARRAY_DATA_US"))) us[1];
96 int GTY ((length ("%0.num_elements"),
97 tag ("VARRAY_DATA_I"))) i[1];
98 unsigned int GTY ((length ("%0.num_elements"),
99 tag ("VARRAY_DATA_U"))) u[1];
100 long GTY ((length ("%0.num_elements"),
101 tag ("VARRAY_DATA_L"))) l[1];
102 unsigned long GTY ((length ("%0.num_elements"),
103 tag ("VARRAY_DATA_UL"))) ul[1];
104 HOST_WIDE_INT GTY ((length ("%0.num_elements"),
105 tag ("VARRAY_DATA_HINT"))) hint[1];
106 unsigned HOST_WIDE_INT GTY ((length ("%0.num_elements"),
107 tag ("VARRAY_DATA_UHINT"))) uhint[1];
108 PTR GTY ((length ("%0.num_elements"), use_param (""),
109 tag ("VARRAY_DATA_GENERIC"))) generic[1];
110 char *GTY ((length ("%0.num_elements"),
111 tag ("VARRAY_DATA_CPTR"))) cptr[1];
112 struct rtx_def *GTY ((length ("%0.num_elements"),
113 tag ("VARRAY_DATA_RTX"))) rtx[1];
114 struct rtvec_def *GTY ((length ("%0.num_elements"),
115 tag ("VARRAY_DATA_RTVEC"))) rtvec[1];
116 union tree_node *GTY ((length ("%0.num_elements"),
117 tag ("VARRAY_DATA_TREE"))) tree[1];
118 struct bitmap_head_def *GTY ((length ("%0.num_elements"),
119 tag ("VARRAY_DATA_BITMAP"))) bitmap[1];
120 struct reg_info_def *GTY ((length ("%0.num_elements"), skip (""),
121 tag ("VARRAY_DATA_REG"))) reg[1];
122 struct const_equiv_data GTY ((length ("%0.num_elements"),
123 tag ("VARRAY_DATA_CONST_EQUIV"))) const_equiv[1];
124 struct basic_block_def *GTY ((length ("%0.num_elements"), skip (""),
125 tag ("VARRAY_DATA_BB"))) bb[1];
126 struct elt_list *GTY ((length ("%0.num_elements"),
127 tag ("VARRAY_DATA_TE"))) te[1];
128 } varray_data;
130 /* Virtual array of pointers header. */
131 struct varray_head_tag GTY(()) {
132 size_t num_elements; /* Maximum element number allocated. */
133 size_t elements_used; /* The number of elements used, if
134 using VARRAY_PUSH/VARRAY_POP. */
135 enum varray_data_enum type; /* The kind of elements in the varray. */
136 const char *name; /* name of the varray for reporting errors */
137 varray_data GTY ((desc ("%0.type"))) data; /* The data elements follow,
138 must be last. */
140 typedef struct varray_head_tag *varray_type;
142 /* Allocate a virtual array with NUM elements, each of which is SIZE bytes
143 long, named NAME. Array elements are zeroed. */
144 extern varray_type varray_init PARAMS ((size_t, enum varray_data_enum,
145 const char *));
147 #define VARRAY_CHAR_INIT(va, num, name) \
148 va = varray_init (num, VARRAY_DATA_C, name)
150 #define VARRAY_UCHAR_INIT(va, num, name) \
151 va = varray_init (num, VARRAY_DATA_UC, name)
153 #define VARRAY_SHORT_INIT(va, num, name) \
154 va = varray_init (num, VARRAY_DATA_S, name)
156 #define VARRAY_USHORT_INIT(va, num, name) \
157 va = varray_init (num, VARRAY_DATA_US, name)
159 #define VARRAY_INT_INIT(va, num, name) \
160 va = varray_init (num, VARRAY_DATA_I, name)
162 #define VARRAY_UINT_INIT(va, num, name) \
163 va = varray_init (num, VARRAY_DATA_U, name)
165 #define VARRAY_LONG_INIT(va, num, name) \
166 va = varray_init (num, VARRAY_DATA_L, name)
168 #define VARRAY_ULONG_INIT(va, num, name) \
169 va = varray_init (num, VARRAY_DATA_UL, name)
171 #define VARRAY_WIDE_INT_INIT(va, num, name) \
172 va = varray_init (num, VARRAY_DATA_HINT, name)
174 #define VARRAY_UWIDE_INT_INIT(va, num, name) \
175 va = varray_init (num, VARRAY_DATA_UHINT, name)
177 #define VARRAY_GENERIC_PTR_INIT(va, num, name) \
178 va = varray_init (num, VARRAY_DATA_GENERIC, name)
180 #define VARRAY_CHAR_PTR_INIT(va, num, name) \
181 va = varray_init (num, VARRAY_DATA_CPTR, name)
183 #define VARRAY_RTX_INIT(va, num, name) \
184 va = varray_init (num, VARRAY_DATA_RTX, name)
186 #define VARRAY_RTVEC_INIT(va, num, name) \
187 va = varray_init (num, VARRAY_DATA_RTVEC, name)
189 #define VARRAY_TREE_INIT(va, num, name) \
190 va = varray_init (num, VARRAY_DATA_TREE, name)
192 #define VARRAY_BITMAP_INIT(va, num, name) \
193 va = varray_init (num, VARRAY_DATA_BITMAP, name)
195 #define VARRAY_REG_INIT(va, num, name) \
196 va = varray_init (num, VARRAY_DATA_REG, name)
198 #define VARRAY_CONST_EQUIV_INIT(va, num, name) \
199 va = varray_init (num, VARRAY_DATA_CONST_EQUIV, name)
201 #define VARRAY_BB_INIT(va, num, name) \
202 va = varray_init (num, VARRAY_DATA_BB, name)
204 #define VARRAY_ELT_LIST_INIT(va, num, name) \
205 va = varray_init (num, VARRAY_DATA_TE, name)
207 /* Free up memory allocated by the virtual array, but do not free any of the
208 elements involved. */
209 #define VARRAY_FREE(vp) \
210 do { if (vp) { free (vp); vp = (varray_type) 0; } } while (0)
212 /* Grow/shrink the virtual array VA to N elements. */
213 extern varray_type varray_grow PARAMS ((varray_type, size_t));
215 #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
217 #define VARRAY_SIZE(VA) ((VA)->num_elements)
219 #define VARRAY_ACTIVE_SIZE(VA) ((VA)->elements_used)
220 #define VARRAY_POP_ALL(VA) ((VA)->elements_used = 0)
222 #define VARRAY_CLEAR(VA) varray_clear(VA)
224 extern void varray_clear PARAMS ((varray_type));
226 /* Check for VARRAY_xxx macros being in bound. */
227 #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
228 extern void varray_check_failed PARAMS ((varray_type, size_t,
229 const char *, int,
230 const char *)) ATTRIBUTE_NORETURN;
231 #define VARRAY_CHECK(VA, N, T) __extension__ \
232 (*({ varray_type const _va = (VA); \
233 const size_t _n = (N); \
234 if (_n >= _va->num_elements) \
235 varray_check_failed (_va, _n, __FILE__, __LINE__, __FUNCTION__); \
236 &_va->data.T[_n]; }))
237 #else
238 #define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N])
239 #endif
241 /* Push X onto VA. T is the name of the field in varray_data
242 corresponding to the type of X. */
243 #define VARRAY_PUSH(VA, T, X) \
244 do \
246 if ((VA)->elements_used >= (VA)->num_elements) \
247 VARRAY_GROW ((VA), 2 * (VA)->num_elements); \
248 (VA)->data.T[(VA)->elements_used++] = (X); \
250 while (0)
252 /* Pop the top element of VA. */
253 #define VARRAY_POP(VA) \
254 ((VA)->elements_used--)
256 /* Return the top element of VA. */
257 #define VARRAY_TOP(VA, T) \
258 ((VA)->data.T[(VA)->elements_used - 1])
260 #define VARRAY_CHAR(VA, N) VARRAY_CHECK (VA, N, c)
261 #define VARRAY_UCHAR(VA, N) VARRAY_CHECK (VA, N, uc)
262 #define VARRAY_SHORT(VA, N) VARRAY_CHECK (VA, N, s)
263 #define VARRAY_USHORT(VA, N) VARRAY_CHECK (VA, N, us)
264 #define VARRAY_INT(VA, N) VARRAY_CHECK (VA, N, i)
265 #define VARRAY_UINT(VA, N) VARRAY_CHECK (VA, N, u)
266 #define VARRAY_LONG(VA, N) VARRAY_CHECK (VA, N, l)
267 #define VARRAY_ULONG(VA, N) VARRAY_CHECK (VA, N, ul)
268 #define VARRAY_WIDE_INT(VA, N) VARRAY_CHECK (VA, N, hint)
269 #define VARRAY_UWIDE_INT(VA, N) VARRAY_CHECK (VA, N, uhint)
270 #define VARRAY_GENERIC_PTR(VA,N) VARRAY_CHECK (VA, N, generic)
271 #define VARRAY_CHAR_PTR(VA,N) VARRAY_CHECK (VA, N, cptr)
272 #define VARRAY_RTX(VA, N) VARRAY_CHECK (VA, N, rtx)
273 #define VARRAY_RTVEC(VA, N) VARRAY_CHECK (VA, N, rtvec)
274 #define VARRAY_TREE(VA, N) VARRAY_CHECK (VA, N, tree)
275 #define VARRAY_BITMAP(VA, N) VARRAY_CHECK (VA, N, bitmap)
276 #define VARRAY_REG(VA, N) VARRAY_CHECK (VA, N, reg)
277 #define VARRAY_CONST_EQUIV(VA, N) VARRAY_CHECK (VA, N, const_equiv)
278 #define VARRAY_BB(VA, N) VARRAY_CHECK (VA, N, bb)
279 #define VARRAY_ELT_LIST(VA, N) VARRAY_CHECK (VA, N, te)
281 /* Push a new element on the end of VA, extending it if necessary. */
282 #define VARRAY_PUSH_CHAR(VA, X) VARRAY_PUSH (VA, c, X)
283 #define VARRAY_PUSH_UCHAR(VA, X) VARRAY_PUSH (VA, uc, X)
284 #define VARRAY_PUSH_SHORT(VA, X) VARRAY_PUSH (VA, s, X)
285 #define VARRAY_PUSH_USHORT(VA, X) VARRAY_PUSH (VA, us, X)
286 #define VARRAY_PUSH_INT(VA, X) VARRAY_PUSH (VA, i, X)
287 #define VARRAY_PUSH_UINT(VA, X) VARRAY_PUSH (VA, u, X)
288 #define VARRAY_PUSH_LONG(VA, X) VARRAY_PUSH (VA, l, X)
289 #define VARRAY_PUSH_ULONG(VA, X) VARRAY_PUSH (VA, ul, X)
290 #define VARRAY_PUSH_WIDE_INT(VA, X) VARRAY_PUSH (VA, hint, X)
291 #define VARRAY_PUSH_UWIDE_INT(VA, X) VARRAY_PUSH (VA, uhint, X)
292 #define VARRAY_PUSH_GENERIC_PTR(VA, X) VARRAY_PUSH (VA, generic, X)
293 #define VARRAY_PUSH_CHAR_PTR(VA, X) VARRAY_PUSH (VA, cptr, X)
294 #define VARRAY_PUSH_RTX(VA, X) VARRAY_PUSH (VA, rtx, X)
295 #define VARRAY_PUSH_RTVEC(VA, X) VARRAY_PUSH (VA, rtvec, X)
296 #define VARRAY_PUSH_TREE(VA, X) VARRAY_PUSH (VA, tree, X)
297 #define VARRAY_PUSH_BITMAP(VA, X) VARRAY_PUSH (VA, bitmap, X)
298 #define VARRAY_PUSH_REG(VA, X) VARRAY_PUSH (VA, reg, X)
299 #define VARRAY_PUSH_CONST_EQUIV(VA, X) VARRAY_PUSH (VA, const_equiv, X)
300 #define VARRAY_PUSH_BB(VA, X) VARRAY_PUSH (VA, bb, X)
302 /* Return the last element of VA. */
303 #define VARRAY_TOP_CHAR(VA) VARRAY_TOP (VA, c)
304 #define VARRAY_TOP_UCHAR(VA) VARRAY_TOP (VA, uc)
305 #define VARRAY_TOP_SHORT(VA) VARRAY_TOP (VA, s)
306 #define VARRAY_TOP_USHORT(VA) VARRAY_TOP (VA, us)
307 #define VARRAY_TOP_INT(VA) VARRAY_TOP (VA, i)
308 #define VARRAY_TOP_UINT(VA) VARRAY_TOP (VA, u)
309 #define VARRAY_TOP_LONG(VA) VARRAY_TOP (VA, l)
310 #define VARRAY_TOP_ULONG(VA) VARRAY_TOP (VA, ul)
311 #define VARRAY_TOP_WIDE_INT(VA) VARRAY_TOP (VA, hint)
312 #define VARRAY_TOP_UWIDE_INT(VA) VARRAY_TOP (VA, uhint)
313 #define VARRAY_TOP_GENERIC_PTR(VA) VARRAY_TOP (VA, generic)
314 #define VARRAY_TOP_CHAR_PTR(VA) VARRAY_TOP (VA, cptr)
315 #define VARRAY_TOP_RTX(VA) VARRAY_TOP (VA, rtx)
316 #define VARRAY_TOP_RTVEC(VA) VARRAY_TOP (VA, rtvec)
317 #define VARRAY_TOP_TREE(VA) VARRAY_TOP (VA, tree)
318 #define VARRAY_TOP_BITMAP(VA) VARRAY_TOP (VA, bitmap)
319 #define VARRAY_TOP_REG(VA) VARRAY_TOP (VA, reg)
320 #define VARRAY_TOP_CONST_EQUIV(VA) VARRAY_TOP (VA, const_equiv)
321 #define VARRAY_TOP_BB(VA) VARRAY_TOP (VA, bb)
323 #endif /* ! GCC_VARRAY_H */