]>
Commit | Line | Data |
---|---|---|
848205e6 MM |
1 | /* Virtual array support. |
2 | Copyright (C) 1998 Free Software Foundation, Inc. | |
3 | Contributed by Cygnus Solutions. | |
4 | ||
5 | This file is part of GNU CC. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
21 | ||
22 | #ifndef _VARRAY_H_ | |
23 | #define _VARRAY_H_ | |
24 | ||
848205e6 MM |
25 | #ifndef HOST_WIDE_INT |
26 | #include "machmode.h" | |
27 | #endif | |
28 | ||
4dfb04c6 MM |
29 | #ifndef __GCC_SYSTEM_H__ |
30 | #include "system.h" | |
31 | #endif | |
32 | ||
c68da89c KR |
33 | /* Auxiliary structure used inside the varray structure, used for |
34 | function integration data. */ | |
35 | ||
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. | |
43 | ||
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; | |
51 | ||
52 | /* Record the valid age for each entry. The entry is invalid if its | |
53 | age is less than const_age. */ | |
54 | unsigned age; | |
55 | }; | |
56 | ||
848205e6 MM |
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]; | |
c68da89c | 77 | struct const_equiv_data const_equiv[1]; |
848205e6 MM |
78 | } varray_data; |
79 | ||
80 | /* Virtual array of pointers header. */ | |
81 | typedef struct varray_head_tag { | |
82 | size_t num_elements; /* maximum element number allocated */ | |
83 | size_t element_size; /* size of each data element */ | |
84 | const char *name; /* name of the varray for reporting errors */ | |
85 | varray_data data; /* data elements follow, must be last */ | |
86 | } *varray_type; | |
87 | ||
88 | /* Allocate a virtual array with NUM elements, each of which is SIZE bytes | |
89 | long, named NAME. Array elements are zeroed. */ | |
90 | extern varray_type varray_init PROTO ((size_t, size_t, const char *)); | |
91 | ||
92 | #define VARRAY_CHAR_INIT(va, num, name) \ | |
93 | va = varray_init (num, sizeof (char), name) | |
94 | ||
95 | #define VARRAY_UCHAR_INIT(va, num, name) \ | |
96 | va = varray_init (num, sizeof (unsigned char), name) | |
97 | ||
98 | #define VARRAY_SHORT_INIT(va, num, name) \ | |
99 | va = varray_init (num, sizeof (short), name) | |
100 | ||
101 | #define VARRAY_USHORT_INIT(va, num, name) \ | |
102 | va = varray_init (num, sizeof (unsigned short), name) | |
103 | ||
104 | #define VARRAY_INT_INIT(va, num, name) \ | |
105 | va = varray_init (num, sizeof (int), name) | |
106 | ||
107 | #define VARRAY_UINT_INIT(va, num, name) \ | |
108 | va = varray_init (num, sizeof (unsigned int), name) | |
109 | ||
110 | #define VARRAY_LONG_INIT(va, num, name) \ | |
111 | va = varray_init (num, sizeof (long), name) | |
112 | ||
113 | #define VARRAY_ULONG_INIT(va, num, name) \ | |
114 | va = varray_init (num, sizeof (unsigned long), name) | |
115 | ||
116 | #define VARRAY_WIDE_INT_INIT(va, num, name) \ | |
117 | va = varray_init (num, sizeof (HOST_WIDE_INT), name) | |
118 | ||
119 | #define VARRAY_UWIDE_INT_INIT(va, num, name) \ | |
120 | va = varray_init (num, sizeof (unsigned HOST_WIDE_INT), name) | |
121 | ||
122 | #define VARRAY_GENERIC_PTR_INIT(va, num, name) \ | |
123 | va = varray_init (num, sizeof (GENERIC_PTR), name) | |
124 | ||
125 | #define VARRAY_CHAR_PTR_INIT(va, num, name) \ | |
126 | va = varray_init (num, sizeof (char *), name) | |
127 | ||
128 | #define VARRAY_RTX_INIT(va, num, name) \ | |
129 | va = varray_init (num, sizeof (struct rtx_def *), name) | |
130 | ||
131 | #define VARRAY_RTVEC_INIT(va, num, name) \ | |
132 | va = varray_init (num, sizeof (struct rtvec_def), name) | |
133 | ||
134 | #define VARRAY_TREE_INIT(va, num, name) \ | |
135 | va = varray_init (num, sizeof (union tree_node *), name) | |
136 | ||
137 | #define VARRAY_BITMAP_INIT(va, num, name) \ | |
138 | va = varray_init (num, sizeof (struct bitmap_head_def *), name) | |
139 | ||
140 | #define VARRAY_SCHED_INIT(va, num, name) \ | |
141 | va = varray_init (num, sizeof (struct sched_info_tag *), name) | |
142 | ||
143 | #define VARRAY_REG_INIT(va, num, name) \ | |
144 | va = varray_init (num, sizeof (struct reg_info_def *), name) | |
145 | ||
c68da89c KR |
146 | #define VARRAY_CONST_EQUIV_INIT(va, num, name) \ |
147 | va = varray_init (num, sizeof (struct const_equiv_data), name) | |
148 | ||
848205e6 MM |
149 | /* Free up memory allocated by the virtual array, but do not free any of the |
150 | elements involved. */ | |
804a4e13 KG |
151 | #define VARRAY_FREE(vp) \ |
152 | do { if (vp) { free (vp); vp = (varray_type)0; } } while (0) | |
848205e6 MM |
153 | |
154 | /* Grow/shrink the virtual array VA to N elements. */ | |
155 | extern varray_type varray_grow PROTO((varray_type, size_t)); | |
156 | ||
157 | #define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N)) | |
158 | ||
c68da89c KR |
159 | #define VARRAY_SIZE(VA) ((VA)->num_elements) |
160 | ||
848205e6 MM |
161 | /* Check for VARRAY_xxx macros being in bound, return N for use as an |
162 | index. */ | |
163 | #ifdef ENABLE_CHECKING | |
164 | #define VARRAY_CHECK(VA, N) \ | |
165 | ((((size_t)(N) < (VA)->num_elements) \ | |
166 | ? 0 \ | |
167 | : (fatal ("Virtual array %s element %ld out of bounds, at %s:%d", \ | |
168 | (VA)->name, (long)(N), __FILE__, __LINE__), 0)), \ | |
169 | (N)) | |
170 | #else | |
171 | #define VARRAY_CHECK(VA, N) (N) | |
172 | #endif | |
173 | ||
174 | #define VARRAY_CHAR(VA, N) ((VA)->data.c[ VARRAY_CHECK (VA, N) ]) | |
175 | #define VARRAY_UCHAR(VA, N) ((VA)->data.uc[ VARRAY_CHECK (VA, N) ]) | |
176 | #define VARRAY_SHORT(VA, N) ((VA)->data.s[ VARRAY_CHECK (VA, N) ]) | |
177 | #define VARRAY_USHORT(VA, N) ((VA)->data.us[ VARRAY_CHECK (VA, N) ]) | |
178 | #define VARRAY_INT(VA, N) ((VA)->data.i[ VARRAY_CHECK (VA, N) ]) | |
179 | #define VARRAY_UINT(VA, N) ((VA)->data.u[ VARRAY_CHECK (VA, N) ]) | |
180 | #define VARRAY_LONG(VA, N) ((VA)->data.l[ VARRAY_CHECK (VA, N) ]) | |
181 | #define VARRAY_ULONG(VA, N) ((VA)->data.ul[ VARRAY_CHECK (VA, N) ]) | |
182 | #define VARRAY_WIDE_INT(VA, N) ((VA)->data.hint[ VARRAY_CHECK (VA, N) ]) | |
183 | #define VARRAY_UWIDE_INT(VA, N) ((VA)->data.uhint[ VARRAY_CHECK (VA, N) ]) | |
184 | #define VARRAY_GENERIC_PTR(VA,N) ((VA)->data.generic[ VARRAY_CHECK (VA, N) ]) | |
185 | #define VARRAY_CHAR_PTR(VA,N) ((VA)->data.cptr[ VARRAY_CHECK (VA, N) ]) | |
186 | #define VARRAY_RTX(VA, N) ((VA)->data.rtx[ VARRAY_CHECK (VA, N) ]) | |
187 | #define VARRAY_RTVEC(VA, N) ((VA)->data.rtvec[ VARRAY_CHECK (VA, N) ]) | |
188 | #define VARRAY_TREE(VA, N) ((VA)->data.tree[ VARRAY_CHECK (VA, N) ]) | |
189 | #define VARRAY_BITMAP(VA, N) ((VA)->data.bitmap[ VARRAY_CHECK (VA, N) ]) | |
190 | #define VARRAY_SCHED(VA, N) ((VA)->data.sched[ VARRAY_CHECK (VA, N) ]) | |
191 | #define VARRAY_REG(VA, N) ((VA)->data.reg[ VARRAY_CHECK (VA, N) ]) | |
c68da89c | 192 | #define VARRAY_CONST_EQUIV(VA, N) ((VA)->data.const_equiv[ VARRAY_CHECK (VA, N) ]) |
848205e6 MM |
193 | |
194 | #endif /* _VARRAY_H_ */ |