(arm_comp_type_attributes): Simply and comment tests on type attributes.
[official-gcc.git] / gcc / varray.h
blobd08bfa94ca2b0faeaef5b38f70bb251918f03839
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 } varray_data;
81 /* Virtual array of pointers header. */
82 typedef struct varray_head_tag {
83 size_t num_elements; /* maximum element number allocated */
84 size_t elements_used; /* the number of elements used, if
85 using VARRAY_PUSH/VARRAY_POP. */
86 size_t element_size; /* size of each data element */
87 const char *name; /* name of the varray for reporting errors */
88 varray_data data; /* data elements follow, must be last */
89 } *varray_type;
91 /* Allocate a virtual array with NUM elements, each of which is SIZE bytes
92 long, named NAME. Array elements are zeroed. */
93 extern varray_type varray_init PARAMS ((size_t, size_t, const char *));
95 #define VARRAY_CHAR_INIT(va, num, name) \
96 va = varray_init (num, sizeof (char), name)
98 #define VARRAY_UCHAR_INIT(va, num, name) \
99 va = varray_init (num, sizeof (unsigned char), name)
101 #define VARRAY_SHORT_INIT(va, num, name) \
102 va = varray_init (num, sizeof (short), name)
104 #define VARRAY_USHORT_INIT(va, num, name) \
105 va = varray_init (num, sizeof (unsigned short), name)
107 #define VARRAY_INT_INIT(va, num, name) \
108 va = varray_init (num, sizeof (int), name)
110 #define VARRAY_UINT_INIT(va, num, name) \
111 va = varray_init (num, sizeof (unsigned int), name)
113 #define VARRAY_LONG_INIT(va, num, name) \
114 va = varray_init (num, sizeof (long), name)
116 #define VARRAY_ULONG_INIT(va, num, name) \
117 va = varray_init (num, sizeof (unsigned long), name)
119 #define VARRAY_WIDE_INT_INIT(va, num, name) \
120 va = varray_init (num, sizeof (HOST_WIDE_INT), name)
122 #define VARRAY_UWIDE_INT_INIT(va, num, name) \
123 va = varray_init (num, sizeof (unsigned HOST_WIDE_INT), name)
125 #define VARRAY_GENERIC_PTR_INIT(va, num, name) \
126 va = varray_init (num, sizeof (PTR), name)
128 #define VARRAY_CHAR_PTR_INIT(va, num, name) \
129 va = varray_init (num, sizeof (char *), name)
131 #define VARRAY_RTX_INIT(va, num, name) \
132 va = varray_init (num, sizeof (struct rtx_def *), name)
134 #define VARRAY_RTVEC_INIT(va, num, name) \
135 va = varray_init (num, sizeof (struct rtvec_def), name)
137 #define VARRAY_TREE_INIT(va, num, name) \
138 va = varray_init (num, sizeof (union tree_node *), name)
140 #define VARRAY_BITMAP_INIT(va, num, name) \
141 va = varray_init (num, sizeof (struct bitmap_head_def *), name)
143 #define VARRAY_SCHED_INIT(va, num, name) \
144 va = varray_init (num, sizeof (struct sched_info_tag *), name)
146 #define VARRAY_REG_INIT(va, num, name) \
147 va = varray_init (num, sizeof (struct reg_info_def *), name)
149 #define VARRAY_CONST_EQUIV_INIT(va, num, name) \
150 va = varray_init (num, sizeof (struct const_equiv_data), name)
152 #define VARRAY_BB_INIT(va, num, name) \
153 va = varray_init (num, sizeof (struct basic_block_def *), name)
155 /* Free up memory allocated by the virtual array, but do not free any of the
156 elements involved. */
157 #define VARRAY_FREE(vp) \
158 do { if (vp) { free (vp); vp = (varray_type)0; } } while (0)
160 /* Grow/shrink the virtual array VA to N elements. */
161 extern varray_type varray_grow PARAMS ((varray_type, size_t));
163 #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
165 #define VARRAY_SIZE(VA) ((VA)->num_elements)
167 /* Check for VARRAY_xxx macros being in bound. */
168 #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
169 extern void varray_check_failed PARAMS ((varray_type, size_t,
170 const char *, int,
171 const char *)) ATTRIBUTE_NORETURN;
172 #define VARRAY_CHECK(VA, N, T) \
173 (*({ varray_type _va = VA; \
174 size_t _n = N; \
175 if (_n >= _va->num_elements) \
176 varray_check_failed (_va, _n, __FILE__, __LINE__, \
177 __PRETTY_FUNCTION__); \
178 &_va->data.T[_n]; }))
179 #else
180 #define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N])
181 #endif
183 /* Push X onto VA. T is the name of the field in varray_data
184 corresponding to the type of X. */
185 #define VARRAY_PUSH(VA, T, X) \
186 do \
188 if ((VA)->elements_used >= (VA)->num_elements) \
189 VARRAY_GROW ((VA), 2 * (VA)->num_elements); \
190 (VA)->data.T[(VA)->elements_used++] = (X); \
192 while (0)
194 /* Pop the top element of VA. */
195 #define VARRAY_POP(VA) \
196 ((VA)->elements_used--)
198 /* Return the top element of VA. */
199 #define VARRAY_TOP(VA, T) \
200 ((VA)->data.T[(VA)->elements_used - 1])
202 #define VARRAY_CHAR(VA, N) VARRAY_CHECK (VA, N, c)
203 #define VARRAY_UCHAR(VA, N) VARRAY_CHECK (VA, N, uc)
204 #define VARRAY_SHORT(VA, N) VARRAY_CHECK (VA, N, s)
205 #define VARRAY_USHORT(VA, N) VARRAY_CHECK (VA, N, us)
206 #define VARRAY_INT(VA, N) VARRAY_CHECK (VA, N, i)
207 #define VARRAY_UINT(VA, N) VARRAY_CHECK (VA, N, u)
208 #define VARRAY_LONG(VA, N) VARRAY_CHECK (VA, N, l)
209 #define VARRAY_ULONG(VA, N) VARRAY_CHECK (VA, N, ul)
210 #define VARRAY_WIDE_INT(VA, N) VARRAY_CHECK (VA, N, hint)
211 #define VARRAY_UWIDE_INT(VA, N) VARRAY_CHECK (VA, N, uhint)
212 #define VARRAY_GENERIC_PTR(VA,N) VARRAY_CHECK (VA, N, generic)
213 #define VARRAY_CHAR_PTR(VA,N) VARRAY_CHECK (VA, N, cptr)
214 #define VARRAY_RTX(VA, N) VARRAY_CHECK (VA, N, rtx)
215 #define VARRAY_RTVEC(VA, N) VARRAY_CHECK (VA, N, rtvec)
216 #define VARRAY_TREE(VA, N) VARRAY_CHECK (VA, N, tree)
217 #define VARRAY_BITMAP(VA, N) VARRAY_CHECK (VA, N, bitmap)
218 #define VARRAY_SCHED(VA, N) VARRAY_CHECK (VA, N, sched)
219 #define VARRAY_REG(VA, N) VARRAY_CHECK (VA, N, reg)
220 #define VARRAY_CONST_EQUIV(VA, N) VARRAY_CHECK (VA, N, const_equiv)
221 #define VARRAY_BB(VA, N) VARRAY_CHECK (VA, N, bb)
223 /* Push a new element on the end of VA, extending it if necessary. */
224 #define VARRAY_PUSH_CHAR(VA, X) VARRAY_PUSH (VA, c, X)
225 #define VARRAY_PUSH_UCHAR(VA, X) VARRAY_PUSH (VA, uc, X)
226 #define VARRAY_PUSH_SHORT(VA, X) VARRAY_PUSH (VA, s, X)
227 #define VARRAY_PUSH_USHORT(VA, X) VARRAY_PUSH (VA, us, X)
228 #define VARRAY_PUSH_INT(VA, X) VARRAY_PUSH (VA, i, X)
229 #define VARRAY_PUSH_UINT(VA, X) VARRAY_PUSH (VA, u, X)
230 #define VARRAY_PUSH_LONG(VA, X) VARRAY_PUSH (VA, l, X)
231 #define VARRAY_PUSH_ULONG(VA, X) VARRAY_PUSH (VA, ul, X)
232 #define VARRAY_PUSH_WIDE_INT(VA, X) VARRAY_PUSH (VA, hint, X)
233 #define VARRAY_PUSH_UWIDE_INT(VA, X) VARRAY_PUSH (VA, uhint, X)
234 #define VARRAY_PUSH_GENERIC_PTR(VA,N) VARRAY_PUSH (VA, generic, X)
235 #define VARRAY_PUSH_CHAR_PTR(VA,N) VARRAY_PUSH (VA, cptr, X)
236 #define VARRAY_PUSH_RTX(VA, X) VARRAY_PUSH (VA, rtx, X)
237 #define VARRAY_PUSH_RTVEC(VA, X) VARRAY_PUSH (VA, rtvec, X)
238 #define VARRAY_PUSH_TREE(VA, X) VARRAY_PUSH (VA, tree, X)
239 #define VARRAY_PUSH_BITMAP(VA, X) VARRAY_PUSH (VA, bitmap, X)
240 #define VARRAY_PUSH_SCHED(VA, X) VARRAY_PUSH (VA, sched, X)
241 #define VARRAY_PUSH_REG(VA, X) VARRAY_PUSH (VA, reg, X)
242 #define VARRAY_PUSH_CONST_EQUIV(VA, X) VARRAY_PUSH (VA, const_equiv, X)
243 #define VARRAY_PUSH_BB(VA, X) VARRAY_PUSH (VA, bb, X)
245 /* Return the last element of VA. */
246 #define VARRAY_TOP_CHAR(VA) VARRAY_TOP (VA, c)
247 #define VARRAY_TOP_UCHAR(VA) VARRAY_TOP (VA, uc)
248 #define VARRAY_TOP_SHORT(VA) VARRAY_TOP (VA, s)
249 #define VARRAY_TOP_USHORT(VA) VARRAY_TOP (VA, us)
250 #define VARRAY_TOP_INT(VA) VARRAY_TOP (VA, i)
251 #define VARRAY_TOP_UINT(VA) VARRAY_TOP (VA, u)
252 #define VARRAY_TOP_LONG(VA) VARRAY_TOP (VA, l)
253 #define VARRAY_TOP_ULONG(VA) VARRAY_TOP (VA, ul)
254 #define VARRAY_TOP_WIDE_INT(VA) VARRAY_TOP (VA, hint)
255 #define VARRAY_TOP_UWIDE_INT(VA) VARRAY_TOP (VA, uhint)
256 #define VARRAY_TOP_GENERIC_PTR(VA,N) VARRAY_TOP (VA, generic)
257 #define VARRAY_TOP_CHAR_PTR(VA,N) VARRAY_TOP (VA, cptr)
258 #define VARRAY_TOP_RTX(VA) VARRAY_TOP (VA, rtx)
259 #define VARRAY_TOP_RTVEC(VA) VARRAY_TOP (VA, rtvec)
260 #define VARRAY_TOP_TREE(VA) VARRAY_TOP (VA, tree)
261 #define VARRAY_TOP_BITMAP(VA) VARRAY_TOP (VA, bitmap)
262 #define VARRAY_TOP_SCHED(VA) VARRAY_TOP (VA, sched)
263 #define VARRAY_TOP_REG(VA) VARRAY_TOP (VA, reg)
264 #define VARRAY_TOP_CONST_EQUIV(VA) VARRAY_TOP (VA, const_equiv)
265 #define VARRAY_TOP_BB(VA) VARRAY_TOP (VA, bb)
267 #endif /* _VARRAY_H_ */