* g77install.texi: Remove obsolete parts only used for INSTALL,
[official-gcc.git] / gcc / varray.h
blob1456ffebe456d4d9a380dff2785429212a5c6a5f
1 /* Virtual array support.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
5 This file is part of GNU CC.
7 GNU CC 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 GNU CC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to the Free
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #ifndef _VARRAY_H_
23 #define _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 {
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 /* Union of various array types that are used. */
58 typedef union varray_data_tag {
59 char c[1];
60 unsigned char uc[1];
61 short s[1];
62 unsigned short us[1];
63 int i[1];
64 unsigned int u[1];
65 long l[1];
66 unsigned long ul[1];
67 HOST_WIDE_INT hint[1];
68 unsigned HOST_WIDE_INT uhint[1];
69 PTR generic[1];
70 char *cptr[1];
71 struct rtx_def *rtx[1];
72 struct rtvec_def *rtvec[1];
73 union tree_node *tree[1];
74 struct bitmap_head_def *bitmap[1];
75 struct sched_info_tag *sched[1];
76 struct reg_info_def *reg[1];
77 struct const_equiv_data const_equiv[1];
78 struct basic_block_def *bb[1];
79 struct elt_list *te[1];
80 } varray_data;
82 /* Virtual array of pointers header. */
83 typedef struct varray_head_tag {
84 size_t num_elements; /* maximum element number allocated */
85 size_t elements_used; /* the number of elements used, if
86 using VARRAY_PUSH/VARRAY_POP. */
87 size_t element_size; /* size of each data element */
88 const char *name; /* name of the varray for reporting errors */
89 varray_data data; /* data elements follow, must be last */
90 } *varray_type;
92 /* Allocate a virtual array with NUM elements, each of which is SIZE bytes
93 long, named NAME. Array elements are zeroed. */
94 extern varray_type varray_init PARAMS ((size_t, size_t, const char *));
96 #define VARRAY_CHAR_INIT(va, num, name) \
97 va = varray_init (num, sizeof (char), name)
99 #define VARRAY_UCHAR_INIT(va, num, name) \
100 va = varray_init (num, sizeof (unsigned char), name)
102 #define VARRAY_SHORT_INIT(va, num, name) \
103 va = varray_init (num, sizeof (short), name)
105 #define VARRAY_USHORT_INIT(va, num, name) \
106 va = varray_init (num, sizeof (unsigned short), name)
108 #define VARRAY_INT_INIT(va, num, name) \
109 va = varray_init (num, sizeof (int), name)
111 #define VARRAY_UINT_INIT(va, num, name) \
112 va = varray_init (num, sizeof (unsigned int), name)
114 #define VARRAY_LONG_INIT(va, num, name) \
115 va = varray_init (num, sizeof (long), name)
117 #define VARRAY_ULONG_INIT(va, num, name) \
118 va = varray_init (num, sizeof (unsigned long), name)
120 #define VARRAY_WIDE_INT_INIT(va, num, name) \
121 va = varray_init (num, sizeof (HOST_WIDE_INT), name)
123 #define VARRAY_UWIDE_INT_INIT(va, num, name) \
124 va = varray_init (num, sizeof (unsigned HOST_WIDE_INT), name)
126 #define VARRAY_GENERIC_PTR_INIT(va, num, name) \
127 va = varray_init (num, sizeof (PTR), name)
129 #define VARRAY_CHAR_PTR_INIT(va, num, name) \
130 va = varray_init (num, sizeof (char *), name)
132 #define VARRAY_RTX_INIT(va, num, name) \
133 va = varray_init (num, sizeof (struct rtx_def *), name)
135 #define VARRAY_RTVEC_INIT(va, num, name) \
136 va = varray_init (num, sizeof (struct rtvec_def), name)
138 #define VARRAY_TREE_INIT(va, num, name) \
139 va = varray_init (num, sizeof (union tree_node *), name)
141 #define VARRAY_BITMAP_INIT(va, num, name) \
142 va = varray_init (num, sizeof (struct bitmap_head_def *), name)
144 #define VARRAY_SCHED_INIT(va, num, name) \
145 va = varray_init (num, sizeof (struct sched_info_tag *), name)
147 #define VARRAY_REG_INIT(va, num, name) \
148 va = varray_init (num, sizeof (struct reg_info_def *), name)
150 #define VARRAY_CONST_EQUIV_INIT(va, num, name) \
151 va = varray_init (num, sizeof (struct const_equiv_data), name)
153 #define VARRAY_BB_INIT(va, num, name) \
154 va = varray_init (num, sizeof (struct basic_block_def *), name)
156 #define VARRAY_ELT_LIST_INIT(va, num, name) \
157 va = varray_init (num, sizeof (struct elt_list *), name)
159 /* Free up memory allocated by the virtual array, but do not free any of the
160 elements involved. */
161 #define VARRAY_FREE(vp) \
162 do { if (vp) { free (vp); vp = (varray_type)0; } } while (0)
164 /* Grow/shrink the virtual array VA to N elements. */
165 extern varray_type varray_grow PARAMS ((varray_type, size_t));
167 #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
169 #define VARRAY_SIZE(VA) ((VA)->num_elements)
171 #define VARRAY_ACTIVE_SIZE(VA) ((VA)->elements_used)
172 #define VARRAY_POP_ALL(VA) ((VA)->elements_used = 0)
174 /* Check for VARRAY_xxx macros being in bound. */
175 #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
176 extern void varray_check_failed PARAMS ((varray_type, size_t,
177 const char *, int,
178 const char *)) ATTRIBUTE_NORETURN;
179 #define VARRAY_CHECK(VA, N, T) __extension__ \
180 (*({ varray_type _va = VA; \
181 size_t _n = N; \
182 if (_n >= _va->num_elements) \
183 varray_check_failed (_va, _n, __FILE__, __LINE__, __FUNCTION__); \
184 &_va->data.T[_n]; }))
185 #else
186 #define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N])
187 #endif
189 /* Push X onto VA. T is the name of the field in varray_data
190 corresponding to the type of X. */
191 #define VARRAY_PUSH(VA, T, X) \
192 do \
194 if ((VA)->elements_used >= (VA)->num_elements) \
195 VARRAY_GROW ((VA), 2 * (VA)->num_elements); \
196 (VA)->data.T[(VA)->elements_used++] = (X); \
198 while (0)
200 /* Pop the top element of VA. */
201 #define VARRAY_POP(VA) \
202 ((VA)->elements_used--)
204 /* Return the top element of VA. */
205 #define VARRAY_TOP(VA, T) \
206 ((VA)->data.T[(VA)->elements_used - 1])
208 #define VARRAY_CHAR(VA, N) VARRAY_CHECK (VA, N, c)
209 #define VARRAY_UCHAR(VA, N) VARRAY_CHECK (VA, N, uc)
210 #define VARRAY_SHORT(VA, N) VARRAY_CHECK (VA, N, s)
211 #define VARRAY_USHORT(VA, N) VARRAY_CHECK (VA, N, us)
212 #define VARRAY_INT(VA, N) VARRAY_CHECK (VA, N, i)
213 #define VARRAY_UINT(VA, N) VARRAY_CHECK (VA, N, u)
214 #define VARRAY_LONG(VA, N) VARRAY_CHECK (VA, N, l)
215 #define VARRAY_ULONG(VA, N) VARRAY_CHECK (VA, N, ul)
216 #define VARRAY_WIDE_INT(VA, N) VARRAY_CHECK (VA, N, hint)
217 #define VARRAY_UWIDE_INT(VA, N) VARRAY_CHECK (VA, N, uhint)
218 #define VARRAY_GENERIC_PTR(VA,N) VARRAY_CHECK (VA, N, generic)
219 #define VARRAY_CHAR_PTR(VA,N) VARRAY_CHECK (VA, N, cptr)
220 #define VARRAY_RTX(VA, N) VARRAY_CHECK (VA, N, rtx)
221 #define VARRAY_RTVEC(VA, N) VARRAY_CHECK (VA, N, rtvec)
222 #define VARRAY_TREE(VA, N) VARRAY_CHECK (VA, N, tree)
223 #define VARRAY_BITMAP(VA, N) VARRAY_CHECK (VA, N, bitmap)
224 #define VARRAY_SCHED(VA, N) VARRAY_CHECK (VA, N, sched)
225 #define VARRAY_REG(VA, N) VARRAY_CHECK (VA, N, reg)
226 #define VARRAY_CONST_EQUIV(VA, N) VARRAY_CHECK (VA, N, const_equiv)
227 #define VARRAY_BB(VA, N) VARRAY_CHECK (VA, N, bb)
228 #define VARRAY_ELT_LIST(VA, N) VARRAY_CHECK (VA, N, te)
230 /* Push a new element on the end of VA, extending it if necessary. */
231 #define VARRAY_PUSH_CHAR(VA, X) VARRAY_PUSH (VA, c, X)
232 #define VARRAY_PUSH_UCHAR(VA, X) VARRAY_PUSH (VA, uc, X)
233 #define VARRAY_PUSH_SHORT(VA, X) VARRAY_PUSH (VA, s, X)
234 #define VARRAY_PUSH_USHORT(VA, X) VARRAY_PUSH (VA, us, X)
235 #define VARRAY_PUSH_INT(VA, X) VARRAY_PUSH (VA, i, X)
236 #define VARRAY_PUSH_UINT(VA, X) VARRAY_PUSH (VA, u, X)
237 #define VARRAY_PUSH_LONG(VA, X) VARRAY_PUSH (VA, l, X)
238 #define VARRAY_PUSH_ULONG(VA, X) VARRAY_PUSH (VA, ul, X)
239 #define VARRAY_PUSH_WIDE_INT(VA, X) VARRAY_PUSH (VA, hint, X)
240 #define VARRAY_PUSH_UWIDE_INT(VA, X) VARRAY_PUSH (VA, uhint, X)
241 #define VARRAY_PUSH_GENERIC_PTR(VA, X) VARRAY_PUSH (VA, generic, X)
242 #define VARRAY_PUSH_CHAR_PTR(VA, X) VARRAY_PUSH (VA, cptr, X)
243 #define VARRAY_PUSH_RTX(VA, X) VARRAY_PUSH (VA, rtx, X)
244 #define VARRAY_PUSH_RTVEC(VA, X) VARRAY_PUSH (VA, rtvec, X)
245 #define VARRAY_PUSH_TREE(VA, X) VARRAY_PUSH (VA, tree, X)
246 #define VARRAY_PUSH_BITMAP(VA, X) VARRAY_PUSH (VA, bitmap, X)
247 #define VARRAY_PUSH_SCHED(VA, X) VARRAY_PUSH (VA, sched, X)
248 #define VARRAY_PUSH_REG(VA, X) VARRAY_PUSH (VA, reg, X)
249 #define VARRAY_PUSH_CONST_EQUIV(VA, X) VARRAY_PUSH (VA, const_equiv, X)
250 #define VARRAY_PUSH_BB(VA, X) VARRAY_PUSH (VA, bb, X)
252 /* Return the last element of VA. */
253 #define VARRAY_TOP_CHAR(VA) VARRAY_TOP (VA, c)
254 #define VARRAY_TOP_UCHAR(VA) VARRAY_TOP (VA, uc)
255 #define VARRAY_TOP_SHORT(VA) VARRAY_TOP (VA, s)
256 #define VARRAY_TOP_USHORT(VA) VARRAY_TOP (VA, us)
257 #define VARRAY_TOP_INT(VA) VARRAY_TOP (VA, i)
258 #define VARRAY_TOP_UINT(VA) VARRAY_TOP (VA, u)
259 #define VARRAY_TOP_LONG(VA) VARRAY_TOP (VA, l)
260 #define VARRAY_TOP_ULONG(VA) VARRAY_TOP (VA, ul)
261 #define VARRAY_TOP_WIDE_INT(VA) VARRAY_TOP (VA, hint)
262 #define VARRAY_TOP_UWIDE_INT(VA) VARRAY_TOP (VA, uhint)
263 #define VARRAY_TOP_GENERIC_PTR(VA,N) VARRAY_TOP (VA, generic)
264 #define VARRAY_TOP_CHAR_PTR(VA,N) VARRAY_TOP (VA, cptr)
265 #define VARRAY_TOP_RTX(VA) VARRAY_TOP (VA, rtx)
266 #define VARRAY_TOP_RTVEC(VA) VARRAY_TOP (VA, rtvec)
267 #define VARRAY_TOP_TREE(VA) VARRAY_TOP (VA, tree)
268 #define VARRAY_TOP_BITMAP(VA) VARRAY_TOP (VA, bitmap)
269 #define VARRAY_TOP_SCHED(VA) VARRAY_TOP (VA, sched)
270 #define VARRAY_TOP_REG(VA) VARRAY_TOP (VA, reg)
271 #define VARRAY_TOP_CONST_EQUIV(VA) VARRAY_TOP (VA, const_equiv)
272 #define VARRAY_TOP_BB(VA) VARRAY_TOP (VA, bb)
274 #endif /* _VARRAY_H_ */