(__ev_set_acc_u64): Use __ev_create_u64 to convert uint64_t into __ev64_opaque__.
[official-gcc.git] / gcc / varray.h
blob8d4dafb6ca66797fa145526634e5eed571a31bc2
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 #endif
33 /* Auxiliary structure used inside the varray structure, used for
34 function integration data. */
36 struct const_equiv_data GTY(()) {
37 /* Map pseudo reg number in calling function to equivalent constant. We
38 cannot in general substitute constants into parameter pseudo registers,
39 since some machine descriptions (many RISCs) won't always handle
40 the resulting insns. So if an incoming parameter has a constant
41 equivalent, we record it here, and if the resulting insn is
42 recognizable, we go with it.
44 We also use this mechanism to convert references to incoming arguments
45 and stacked variables. copy_rtx_and_substitute will replace the virtual
46 incoming argument and virtual stacked variables registers with new
47 pseudos that contain pointers into the replacement area allocated for
48 this inline instance. These pseudos are then marked as being equivalent
49 to the appropriate address and substituted if valid. */
50 struct rtx_def *rtx;
52 /* Record the valid age for each entry. The entry is invalid if its
53 age is less than const_age. */
54 unsigned age;
57 /* Enum indicating what the varray contains.
58 If this is changed, `element_size' in varray.c needs to be updated. */
60 enum varray_data_enum {
61 VARRAY_DATA_C,
62 VARRAY_DATA_UC,
63 VARRAY_DATA_S,
64 VARRAY_DATA_US,
65 VARRAY_DATA_I,
66 VARRAY_DATA_U,
67 VARRAY_DATA_L,
68 VARRAY_DATA_UL,
69 VARRAY_DATA_HINT,
70 VARRAY_DATA_UHINT,
71 VARRAY_DATA_GENERIC,
72 VARRAY_DATA_CPTR,
73 VARRAY_DATA_RTX,
74 VARRAY_DATA_RTVEC,
75 VARRAY_DATA_TREE,
76 VARRAY_DATA_BITMAP,
77 VARRAY_DATA_REG,
78 VARRAY_DATA_CONST_EQUIV,
79 VARRAY_DATA_BB,
80 VARRAY_DATA_TE,
81 NUM_VARRAY_DATA
84 /* Union of various array types that are used. */
85 typedef union varray_data_tag GTY (()) {
86 char GTY ((length ("%0.num_elements"),
87 tag ("VARRAY_DATA_C"))) c[1];
88 unsigned char GTY ((length ("%0.num_elements"),
89 tag ("VARRAY_DATA_UC"))) uc[1];
90 short GTY ((length ("%0.num_elements"),
91 tag ("VARRAY_DATA_S"))) s[1];
92 unsigned short GTY ((length ("%0.num_elements"),
93 tag ("VARRAY_DATA_US"))) us[1];
94 int GTY ((length ("%0.num_elements"),
95 tag ("VARRAY_DATA_I"))) i[1];
96 unsigned int GTY ((length ("%0.num_elements"),
97 tag ("VARRAY_DATA_U"))) u[1];
98 long GTY ((length ("%0.num_elements"),
99 tag ("VARRAY_DATA_L"))) l[1];
100 unsigned long GTY ((length ("%0.num_elements"),
101 tag ("VARRAY_DATA_UL"))) ul[1];
102 HOST_WIDE_INT GTY ((length ("%0.num_elements"),
103 tag ("VARRAY_DATA_HINT"))) hint[1];
104 unsigned HOST_WIDE_INT GTY ((length ("%0.num_elements"),
105 tag ("VARRAY_DATA_UHINT"))) uhint[1];
106 PTR GTY ((length ("%0.num_elements"), use_param (""),
107 tag ("VARRAY_DATA_GENERIC"))) generic[1];
108 char *GTY ((length ("%0.num_elements"),
109 tag ("VARRAY_DATA_CPTR"))) cptr[1];
110 struct rtx_def *GTY ((length ("%0.num_elements"),
111 tag ("VARRAY_DATA_RTX"))) rtx[1];
112 struct rtvec_def *GTY ((length ("%0.num_elements"),
113 tag ("VARRAY_DATA_RTVEC"))) rtvec[1];
114 union tree_node *GTY ((length ("%0.num_elements"),
115 tag ("VARRAY_DATA_TREE"))) tree[1];
116 struct bitmap_head_def *GTY ((length ("%0.num_elements"),
117 tag ("VARRAY_DATA_BITMAP"))) bitmap[1];
118 struct reg_info_def *GTY ((length ("%0.num_elements"), skip (""),
119 tag ("VARRAY_DATA_REG"))) reg[1];
120 struct const_equiv_data GTY ((length ("%0.num_elements"),
121 tag ("VARRAY_DATA_CONST_EQUIV"))) const_equiv[1];
122 struct basic_block_def *GTY ((length ("%0.num_elements"), skip (""),
123 tag ("VARRAY_DATA_BB"))) bb[1];
124 struct elt_list *GTY ((length ("%0.num_elements"),
125 tag ("VARRAY_DATA_TE"))) te[1];
126 } varray_data;
128 /* Virtual array of pointers header. */
129 struct varray_head_tag GTY(()) {
130 size_t num_elements; /* Maximum element number allocated. */
131 size_t elements_used; /* The number of elements used, if
132 using VARRAY_PUSH/VARRAY_POP. */
133 enum varray_data_enum type; /* The kind of elements in the varray. */
134 const char *name; /* name of the varray for reporting errors */
135 varray_data GTY ((desc ("%0.type"))) data; /* The data elements follow,
136 must be last. */
138 typedef struct varray_head_tag *varray_type;
140 /* Allocate a virtual array with NUM elements, each of which is SIZE bytes
141 long, named NAME. Array elements are zeroed. */
142 extern varray_type varray_init PARAMS ((size_t, enum varray_data_enum,
143 const char *));
145 #define VARRAY_CHAR_INIT(va, num, name) \
146 va = varray_init (num, VARRAY_DATA_C, name)
148 #define VARRAY_UCHAR_INIT(va, num, name) \
149 va = varray_init (num, VARRAY_DATA_UC, name)
151 #define VARRAY_SHORT_INIT(va, num, name) \
152 va = varray_init (num, VARRAY_DATA_S, name)
154 #define VARRAY_USHORT_INIT(va, num, name) \
155 va = varray_init (num, VARRAY_DATA_US, name)
157 #define VARRAY_INT_INIT(va, num, name) \
158 va = varray_init (num, VARRAY_DATA_I, name)
160 #define VARRAY_UINT_INIT(va, num, name) \
161 va = varray_init (num, VARRAY_DATA_U, name)
163 #define VARRAY_LONG_INIT(va, num, name) \
164 va = varray_init (num, VARRAY_DATA_L, name)
166 #define VARRAY_ULONG_INIT(va, num, name) \
167 va = varray_init (num, VARRAY_DATA_UL, name)
169 #define VARRAY_WIDE_INT_INIT(va, num, name) \
170 va = varray_init (num, VARRAY_DATA_HINT, name)
172 #define VARRAY_UWIDE_INT_INIT(va, num, name) \
173 va = varray_init (num, VARRAY_DATA_UHINT, name)
175 #define VARRAY_GENERIC_PTR_INIT(va, num, name) \
176 va = varray_init (num, VARRAY_DATA_GENERIC, name)
178 #define VARRAY_CHAR_PTR_INIT(va, num, name) \
179 va = varray_init (num, VARRAY_DATA_CPTR, name)
181 #define VARRAY_RTX_INIT(va, num, name) \
182 va = varray_init (num, VARRAY_DATA_RTX, name)
184 #define VARRAY_RTVEC_INIT(va, num, name) \
185 va = varray_init (num, VARRAY_DATA_RTVEC, name)
187 #define VARRAY_TREE_INIT(va, num, name) \
188 va = varray_init (num, VARRAY_DATA_TREE, name)
190 #define VARRAY_BITMAP_INIT(va, num, name) \
191 va = varray_init (num, VARRAY_DATA_BITMAP, name)
193 #define VARRAY_REG_INIT(va, num, name) \
194 va = varray_init (num, VARRAY_DATA_REG, name)
196 #define VARRAY_CONST_EQUIV_INIT(va, num, name) \
197 va = varray_init (num, VARRAY_DATA_CONST_EQUIV, name)
199 #define VARRAY_BB_INIT(va, num, name) \
200 va = varray_init (num, VARRAY_DATA_BB, name)
202 #define VARRAY_ELT_LIST_INIT(va, num, name) \
203 va = varray_init (num, VARRAY_DATA_TE, name)
205 /* Free up memory allocated by the virtual array, but do not free any of the
206 elements involved. */
207 #define VARRAY_FREE(vp) \
208 do { if (vp) { free (vp); vp = (varray_type) 0; } } while (0)
210 /* Grow/shrink the virtual array VA to N elements. */
211 extern varray_type varray_grow PARAMS ((varray_type, size_t));
213 #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
215 #define VARRAY_SIZE(VA) ((VA)->num_elements)
217 #define VARRAY_ACTIVE_SIZE(VA) ((VA)->elements_used)
218 #define VARRAY_POP_ALL(VA) ((VA)->elements_used = 0)
220 #define VARRAY_CLEAR(VA) varray_clear(VA)
222 extern void varray_clear PARAMS ((varray_type));
224 /* Check for VARRAY_xxx macros being in bound. */
225 #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
226 extern void varray_check_failed PARAMS ((varray_type, size_t,
227 const char *, int,
228 const char *)) ATTRIBUTE_NORETURN;
229 #define VARRAY_CHECK(VA, N, T) __extension__ \
230 (*({ varray_type const _va = (VA); \
231 const size_t _n = (N); \
232 if (_n >= _va->num_elements) \
233 varray_check_failed (_va, _n, __FILE__, __LINE__, __FUNCTION__); \
234 &_va->data.T[_n]; }))
235 #else
236 #define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N])
237 #endif
239 /* Push X onto VA. T is the name of the field in varray_data
240 corresponding to the type of X. */
241 #define VARRAY_PUSH(VA, T, X) \
242 do \
244 if ((VA)->elements_used >= (VA)->num_elements) \
245 VARRAY_GROW ((VA), 2 * (VA)->num_elements); \
246 (VA)->data.T[(VA)->elements_used++] = (X); \
248 while (0)
250 /* Pop the top element of VA. */
251 #define VARRAY_POP(VA) \
252 ((VA)->elements_used--)
254 /* Return the top element of VA. */
255 #define VARRAY_TOP(VA, T) \
256 ((VA)->data.T[(VA)->elements_used - 1])
258 #define VARRAY_CHAR(VA, N) VARRAY_CHECK (VA, N, c)
259 #define VARRAY_UCHAR(VA, N) VARRAY_CHECK (VA, N, uc)
260 #define VARRAY_SHORT(VA, N) VARRAY_CHECK (VA, N, s)
261 #define VARRAY_USHORT(VA, N) VARRAY_CHECK (VA, N, us)
262 #define VARRAY_INT(VA, N) VARRAY_CHECK (VA, N, i)
263 #define VARRAY_UINT(VA, N) VARRAY_CHECK (VA, N, u)
264 #define VARRAY_LONG(VA, N) VARRAY_CHECK (VA, N, l)
265 #define VARRAY_ULONG(VA, N) VARRAY_CHECK (VA, N, ul)
266 #define VARRAY_WIDE_INT(VA, N) VARRAY_CHECK (VA, N, hint)
267 #define VARRAY_UWIDE_INT(VA, N) VARRAY_CHECK (VA, N, uhint)
268 #define VARRAY_GENERIC_PTR(VA,N) VARRAY_CHECK (VA, N, generic)
269 #define VARRAY_CHAR_PTR(VA,N) VARRAY_CHECK (VA, N, cptr)
270 #define VARRAY_RTX(VA, N) VARRAY_CHECK (VA, N, rtx)
271 #define VARRAY_RTVEC(VA, N) VARRAY_CHECK (VA, N, rtvec)
272 #define VARRAY_TREE(VA, N) VARRAY_CHECK (VA, N, tree)
273 #define VARRAY_BITMAP(VA, N) VARRAY_CHECK (VA, N, bitmap)
274 #define VARRAY_REG(VA, N) VARRAY_CHECK (VA, N, reg)
275 #define VARRAY_CONST_EQUIV(VA, N) VARRAY_CHECK (VA, N, const_equiv)
276 #define VARRAY_BB(VA, N) VARRAY_CHECK (VA, N, bb)
277 #define VARRAY_ELT_LIST(VA, N) VARRAY_CHECK (VA, N, te)
279 /* Push a new element on the end of VA, extending it if necessary. */
280 #define VARRAY_PUSH_CHAR(VA, X) VARRAY_PUSH (VA, c, X)
281 #define VARRAY_PUSH_UCHAR(VA, X) VARRAY_PUSH (VA, uc, X)
282 #define VARRAY_PUSH_SHORT(VA, X) VARRAY_PUSH (VA, s, X)
283 #define VARRAY_PUSH_USHORT(VA, X) VARRAY_PUSH (VA, us, X)
284 #define VARRAY_PUSH_INT(VA, X) VARRAY_PUSH (VA, i, X)
285 #define VARRAY_PUSH_UINT(VA, X) VARRAY_PUSH (VA, u, X)
286 #define VARRAY_PUSH_LONG(VA, X) VARRAY_PUSH (VA, l, X)
287 #define VARRAY_PUSH_ULONG(VA, X) VARRAY_PUSH (VA, ul, X)
288 #define VARRAY_PUSH_WIDE_INT(VA, X) VARRAY_PUSH (VA, hint, X)
289 #define VARRAY_PUSH_UWIDE_INT(VA, X) VARRAY_PUSH (VA, uhint, X)
290 #define VARRAY_PUSH_GENERIC_PTR(VA, X) VARRAY_PUSH (VA, generic, X)
291 #define VARRAY_PUSH_CHAR_PTR(VA, X) VARRAY_PUSH (VA, cptr, X)
292 #define VARRAY_PUSH_RTX(VA, X) VARRAY_PUSH (VA, rtx, X)
293 #define VARRAY_PUSH_RTVEC(VA, X) VARRAY_PUSH (VA, rtvec, X)
294 #define VARRAY_PUSH_TREE(VA, X) VARRAY_PUSH (VA, tree, X)
295 #define VARRAY_PUSH_BITMAP(VA, X) VARRAY_PUSH (VA, bitmap, X)
296 #define VARRAY_PUSH_REG(VA, X) VARRAY_PUSH (VA, reg, X)
297 #define VARRAY_PUSH_CONST_EQUIV(VA, X) VARRAY_PUSH (VA, const_equiv, X)
298 #define VARRAY_PUSH_BB(VA, X) VARRAY_PUSH (VA, bb, X)
300 /* Return the last element of VA. */
301 #define VARRAY_TOP_CHAR(VA) VARRAY_TOP (VA, c)
302 #define VARRAY_TOP_UCHAR(VA) VARRAY_TOP (VA, uc)
303 #define VARRAY_TOP_SHORT(VA) VARRAY_TOP (VA, s)
304 #define VARRAY_TOP_USHORT(VA) VARRAY_TOP (VA, us)
305 #define VARRAY_TOP_INT(VA) VARRAY_TOP (VA, i)
306 #define VARRAY_TOP_UINT(VA) VARRAY_TOP (VA, u)
307 #define VARRAY_TOP_LONG(VA) VARRAY_TOP (VA, l)
308 #define VARRAY_TOP_ULONG(VA) VARRAY_TOP (VA, ul)
309 #define VARRAY_TOP_WIDE_INT(VA) VARRAY_TOP (VA, hint)
310 #define VARRAY_TOP_UWIDE_INT(VA) VARRAY_TOP (VA, uhint)
311 #define VARRAY_TOP_GENERIC_PTR(VA) VARRAY_TOP (VA, generic)
312 #define VARRAY_TOP_CHAR_PTR(VA) VARRAY_TOP (VA, cptr)
313 #define VARRAY_TOP_RTX(VA) VARRAY_TOP (VA, rtx)
314 #define VARRAY_TOP_RTVEC(VA) VARRAY_TOP (VA, rtvec)
315 #define VARRAY_TOP_TREE(VA) VARRAY_TOP (VA, tree)
316 #define VARRAY_TOP_BITMAP(VA) VARRAY_TOP (VA, bitmap)
317 #define VARRAY_TOP_REG(VA) VARRAY_TOP (VA, reg)
318 #define VARRAY_TOP_CONST_EQUIV(VA) VARRAY_TOP (VA, const_equiv)
319 #define VARRAY_TOP_BB(VA) VARRAY_TOP (VA, bb)
321 #endif /* ! GCC_VARRAY_H */