Daily bump.
[official-gcc.git] / gcc / varray.h
blob7d4f6972f268c359edca92fc38131496d0893f84
1 /* Virtual array support.
2 Copyright (C) 1998 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 rtx 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 GENERIC_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 element_size; /* size of each data element */
85 const char *name; /* name of the varray for reporting errors */
86 varray_data data; /* data elements follow, must be last */
87 } *varray_type;
89 /* Allocate a virtual array with NUM elements, each of which is SIZE bytes
90 long, named NAME. Array elements are zeroed. */
91 extern varray_type varray_init PROTO ((size_t, size_t, const char *));
93 #define VARRAY_CHAR_INIT(va, num, name) \
94 va = varray_init (num, sizeof (char), name)
96 #define VARRAY_UCHAR_INIT(va, num, name) \
97 va = varray_init (num, sizeof (unsigned char), name)
99 #define VARRAY_SHORT_INIT(va, num, name) \
100 va = varray_init (num, sizeof (short), name)
102 #define VARRAY_USHORT_INIT(va, num, name) \
103 va = varray_init (num, sizeof (unsigned short), name)
105 #define VARRAY_INT_INIT(va, num, name) \
106 va = varray_init (num, sizeof (int), name)
108 #define VARRAY_UINT_INIT(va, num, name) \
109 va = varray_init (num, sizeof (unsigned int), name)
111 #define VARRAY_LONG_INIT(va, num, name) \
112 va = varray_init (num, sizeof (long), name)
114 #define VARRAY_ULONG_INIT(va, num, name) \
115 va = varray_init (num, sizeof (unsigned long), name)
117 #define VARRAY_WIDE_INT_INIT(va, num, name) \
118 va = varray_init (num, sizeof (HOST_WIDE_INT), name)
120 #define VARRAY_UWIDE_INT_INIT(va, num, name) \
121 va = varray_init (num, sizeof (unsigned HOST_WIDE_INT), name)
123 #define VARRAY_GENERIC_PTR_INIT(va, num, name) \
124 va = varray_init (num, sizeof (GENERIC_PTR), name)
126 #define VARRAY_CHAR_PTR_INIT(va, num, name) \
127 va = varray_init (num, sizeof (char *), name)
129 #define VARRAY_RTX_INIT(va, num, name) \
130 va = varray_init (num, sizeof (struct rtx_def *), name)
132 #define VARRAY_RTVEC_INIT(va, num, name) \
133 va = varray_init (num, sizeof (struct rtvec_def), name)
135 #define VARRAY_TREE_INIT(va, num, name) \
136 va = varray_init (num, sizeof (union tree_node *), name)
138 #define VARRAY_BITMAP_INIT(va, num, name) \
139 va = varray_init (num, sizeof (struct bitmap_head_def *), name)
141 #define VARRAY_SCHED_INIT(va, num, name) \
142 va = varray_init (num, sizeof (struct sched_info_tag *), name)
144 #define VARRAY_REG_INIT(va, num, name) \
145 va = varray_init (num, sizeof (struct reg_info_def *), name)
147 #define VARRAY_CONST_EQUIV_INIT(va, num, name) \
148 va = varray_init (num, sizeof (struct const_equiv_data), name)
150 #define VARRAY_BB_INIT(va, num, name) \
151 va = varray_init (num, sizeof (struct basic_block_def *), name)
153 /* Free up memory allocated by the virtual array, but do not free any of the
154 elements involved. */
155 #define VARRAY_FREE(vp) \
156 do { if (vp) { free (vp); vp = (varray_type)0; } } while (0)
158 /* Grow/shrink the virtual array VA to N elements. */
159 extern varray_type varray_grow PROTO((varray_type, size_t));
161 #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
163 #define VARRAY_SIZE(VA) ((VA)->num_elements)
165 /* Check for VARRAY_xxx macros being in bound, return N for use as an
166 index. */
167 #ifdef ENABLE_CHECKING
168 #define VARRAY_CHECK(VA, N) \
169 ((((size_t)(N) < (VA)->num_elements) \
170 ? 0 \
171 : (fatal ("Virtual array %s element %ld out of bounds, at %s:%d", \
172 (VA)->name, (long)(N), __FILE__, __LINE__), 0)), \
173 (N))
174 #else
175 #define VARRAY_CHECK(VA, N) (N)
176 #endif
178 #define VARRAY_CHAR(VA, N) ((VA)->data.c[ VARRAY_CHECK (VA, N) ])
179 #define VARRAY_UCHAR(VA, N) ((VA)->data.uc[ VARRAY_CHECK (VA, N) ])
180 #define VARRAY_SHORT(VA, N) ((VA)->data.s[ VARRAY_CHECK (VA, N) ])
181 #define VARRAY_USHORT(VA, N) ((VA)->data.us[ VARRAY_CHECK (VA, N) ])
182 #define VARRAY_INT(VA, N) ((VA)->data.i[ VARRAY_CHECK (VA, N) ])
183 #define VARRAY_UINT(VA, N) ((VA)->data.u[ VARRAY_CHECK (VA, N) ])
184 #define VARRAY_LONG(VA, N) ((VA)->data.l[ VARRAY_CHECK (VA, N) ])
185 #define VARRAY_ULONG(VA, N) ((VA)->data.ul[ VARRAY_CHECK (VA, N) ])
186 #define VARRAY_WIDE_INT(VA, N) ((VA)->data.hint[ VARRAY_CHECK (VA, N) ])
187 #define VARRAY_UWIDE_INT(VA, N) ((VA)->data.uhint[ VARRAY_CHECK (VA, N) ])
188 #define VARRAY_GENERIC_PTR(VA,N) ((VA)->data.generic[ VARRAY_CHECK (VA, N) ])
189 #define VARRAY_CHAR_PTR(VA,N) ((VA)->data.cptr[ VARRAY_CHECK (VA, N) ])
190 #define VARRAY_RTX(VA, N) ((VA)->data.rtx[ VARRAY_CHECK (VA, N) ])
191 #define VARRAY_RTVEC(VA, N) ((VA)->data.rtvec[ VARRAY_CHECK (VA, N) ])
192 #define VARRAY_TREE(VA, N) ((VA)->data.tree[ VARRAY_CHECK (VA, N) ])
193 #define VARRAY_BITMAP(VA, N) ((VA)->data.bitmap[ VARRAY_CHECK (VA, N) ])
194 #define VARRAY_SCHED(VA, N) ((VA)->data.sched[ VARRAY_CHECK (VA, N) ])
195 #define VARRAY_REG(VA, N) ((VA)->data.reg[ VARRAY_CHECK (VA, N) ])
196 #define VARRAY_CONST_EQUIV(VA, N) ((VA)->data.const_equiv[VARRAY_CHECK (VA, N)])
197 #define VARRAY_BB(VA, N) ((VA)->data.bb[ VARRAY_CHECK (VA, N) ])
199 #endif /* _VARRAY_H_ */