OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [varray.h] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Virtual array support.
2
   Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007
3
   Free Software Foundation, Inc.
4
   Contributed by Cygnus Solutions.
5
 
6
   This file is part of GCC.
7
 
8
   GCC is free software; you can redistribute it and/or modify it
9
   under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3, or (at your option)
11
   any later version.
12
 
13
   GCC is distributed in the hope that it will be useful, but WITHOUT
14
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
   License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with GCC; see the file COPYING3.  If not see
20
   <http://www.gnu.org/licenses/>.  */
21
 
22
#ifndef GCC_VARRAY_H
23
#define GCC_VARRAY_H
24
 
25
#ifndef HOST_WIDE_INT
26
#include "machmode.h"
27
#endif
28
 
29
#ifndef GCC_SYSTEM_H
30
#include "system.h"
31
#include "coretypes.h"
32
#include "tm.h"
33
#endif
34
 
35
/* Enum indicating what the varray contains.
36
   If this is changed, `element' in varray.c needs to be updated.  */
37
 
38
enum varray_data_enum {
39
  VARRAY_DATA_C,
40
  VARRAY_DATA_UC,
41
  VARRAY_DATA_S,
42
  VARRAY_DATA_US,
43
  VARRAY_DATA_I,
44
  VARRAY_DATA_U,
45
  VARRAY_DATA_L,
46
  VARRAY_DATA_UL,
47
  VARRAY_DATA_HINT,
48
  VARRAY_DATA_UHINT,
49
  VARRAY_DATA_GENERIC,
50
  VARRAY_DATA_GENERIC_NOGC,
51
  VARRAY_DATA_CPTR,
52
  VARRAY_DATA_RTX,
53
  VARRAY_DATA_RTVEC,
54
  VARRAY_DATA_TREE,
55
  VARRAY_DATA_BITMAP,
56
  VARRAY_DATA_REG,
57
  VARRAY_DATA_BB,
58
  VARRAY_DATA_TE,
59
  VARRAY_DATA_EDGE,
60
  VARRAY_DATA_TREE_PTR,
61
  NUM_VARRAY_DATA
62
};
63
 
64
/* Union of various array types that are used.  */
65
typedef union varray_data_tag GTY (()) {
66
  char                    GTY ((length ("%0.num_elements"),
67
                                tag ("VARRAY_DATA_C")))         vdt_c[1];
68
  unsigned char           GTY ((length ("%0.num_elements"),
69
                                tag ("VARRAY_DATA_UC")))        vdt_uc[1];
70
  short                   GTY ((length ("%0.num_elements"),
71
                                tag ("VARRAY_DATA_S")))         vdt_s[1];
72
  unsigned short          GTY ((length ("%0.num_elements"),
73
                                tag ("VARRAY_DATA_US")))        vdt_us[1];
74
  int                     GTY ((length ("%0.num_elements"),
75
                                tag ("VARRAY_DATA_I")))         vdt_i[1];
76
  unsigned int            GTY ((length ("%0.num_elements"),
77
                                tag ("VARRAY_DATA_U")))         vdt_u[1];
78
  long                    GTY ((length ("%0.num_elements"),
79
                                tag ("VARRAY_DATA_L")))         vdt_l[1];
80
  unsigned long           GTY ((length ("%0.num_elements"),
81
                                tag ("VARRAY_DATA_UL")))        vdt_ul[1];
82
  HOST_WIDE_INT           GTY ((length ("%0.num_elements"),
83
                                tag ("VARRAY_DATA_HINT")))      vdt_hint[1];
84
  unsigned HOST_WIDE_INT  GTY ((length ("%0.num_elements"),
85
                                tag ("VARRAY_DATA_UHINT")))     vdt_uhint[1];
86
  PTR                     GTY ((length ("%0.num_elements"), use_param,
87
                                tag ("VARRAY_DATA_GENERIC")))   vdt_generic[1];
88
  PTR                     GTY ((length ("%0.num_elements"), skip (""),
89
                                tag ("VARRAY_DATA_GENERIC_NOGC")))      vdt_generic_nogc[1];
90
  char                   *GTY ((length ("%0.num_elements"),
91
                                tag ("VARRAY_DATA_CPTR")))      vdt_cptr[1];
92
  rtx                     GTY ((length ("%0.num_elements"),
93
                                tag ("VARRAY_DATA_RTX")))       vdt_rtx[1];
94
  rtvec                   GTY ((length ("%0.num_elements"),
95
                                tag ("VARRAY_DATA_RTVEC")))     vdt_rtvec[1];
96
  tree                    GTY ((length ("%0.num_elements"),
97
                                tag ("VARRAY_DATA_TREE")))      vdt_tree[1];
98
  struct bitmap_head_def *GTY ((length ("%0.num_elements"),
99
                                tag ("VARRAY_DATA_BITMAP")))    vdt_bitmap[1];
100
  struct reg_info_def    *GTY ((length ("%0.num_elements"), skip,
101
                                tag ("VARRAY_DATA_REG")))       vdt_reg[1];
102
  struct basic_block_def *GTY ((length ("%0.num_elements"), skip,
103
                                tag ("VARRAY_DATA_BB")))        vdt_bb[1];
104
  struct elt_list        *GTY ((length ("%0.num_elements"),
105
                                tag ("VARRAY_DATA_TE")))        vdt_te[1];
106
  struct edge_def        *GTY ((length ("%0.num_elements"),
107
                                tag ("VARRAY_DATA_EDGE")))      vdt_e[1];
108
  tree                   *GTY ((length ("%0.num_elements"), skip (""),
109
                                tag ("VARRAY_DATA_TREE_PTR")))  vdt_tp[1];
110
} varray_data;
111
 
112
/* Virtual array of pointers header.  */
113
struct varray_head_tag GTY(()) {
114
  size_t        num_elements;   /* Maximum element number allocated.  */
115
  size_t        elements_used;  /* The number of elements used, if
116
                                   using VARRAY_PUSH/VARRAY_POP.  */
117
  enum varray_data_enum type;   /* The kind of elements in the varray.  */
118
  const char   *name;           /* name of the varray for reporting errors */
119
  varray_data   GTY ((desc ("%0.type"))) data;  /* The data elements follow,
120
                                                   must be last.  */
121
};
122
typedef struct varray_head_tag *varray_type;
123
 
124
/* Allocate a virtual array with NUM elements, each of which is SIZE bytes
125
   long, named NAME.  Array elements are zeroed.  */
126
extern varray_type varray_init (size_t, enum varray_data_enum, const char *);
127
 
128
#define VARRAY_CHAR_INIT(va, num, name) \
129
  va = varray_init (num, VARRAY_DATA_C, name)
130
 
131
#define VARRAY_UCHAR_INIT(va, num, name) \
132
  va = varray_init (num, VARRAY_DATA_UC, name)
133
 
134
#define VARRAY_SHORT_INIT(va, num, name) \
135
  va = varray_init (num, VARRAY_DATA_S, name)
136
 
137
#define VARRAY_USHORT_INIT(va, num, name) \
138
  va = varray_init (num, VARRAY_DATA_US, name)
139
 
140
#define VARRAY_INT_INIT(va, num, name) \
141
  va = varray_init (num, VARRAY_DATA_I, name)
142
 
143
#define VARRAY_UINT_INIT(va, num, name) \
144
  va = varray_init (num, VARRAY_DATA_U, name)
145
 
146
#define VARRAY_LONG_INIT(va, num, name) \
147
  va = varray_init (num, VARRAY_DATA_L, name)
148
 
149
#define VARRAY_ULONG_INIT(va, num, name) \
150
  va = varray_init (num, VARRAY_DATA_UL, name)
151
 
152
#define VARRAY_WIDE_INT_INIT(va, num, name) \
153
  va = varray_init (num, VARRAY_DATA_HINT, name)
154
 
155
#define VARRAY_UWIDE_INT_INIT(va, num, name) \
156
  va = varray_init (num, VARRAY_DATA_UHINT, name)
157
 
158
#define VARRAY_GENERIC_PTR_INIT(va, num, name) \
159
  va = varray_init (num, VARRAY_DATA_GENERIC, name)
160
 
161
#define VARRAY_GENERIC_PTR_NOGC_INIT(va, num, name) \
162
  va = varray_init (num, VARRAY_DATA_GENERIC_NOGC, name)
163
 
164
#define VARRAY_CHAR_PTR_INIT(va, num, name) \
165
  va = varray_init (num, VARRAY_DATA_CPTR, name)
166
 
167
#define VARRAY_RTX_INIT(va, num, name) \
168
  va = varray_init (num, VARRAY_DATA_RTX, name)
169
 
170
#define VARRAY_RTVEC_INIT(va, num, name) \
171
  va = varray_init (num, VARRAY_DATA_RTVEC, name)
172
 
173
#define VARRAY_TREE_INIT(va, num, name) \
174
  va = varray_init (num, VARRAY_DATA_TREE, name)
175
 
176
#define VARRAY_BITMAP_INIT(va, num, name) \
177
  va = varray_init (num, VARRAY_DATA_BITMAP, name)
178
 
179
#define VARRAY_REG_INIT(va, num, name) \
180
  va = varray_init (num, VARRAY_DATA_REG, name)
181
 
182
#define VARRAY_BB_INIT(va, num, name) \
183
  va = varray_init (num, VARRAY_DATA_BB, name)
184
 
185
#define VARRAY_ELT_LIST_INIT(va, num, name) \
186
  va = varray_init (num, VARRAY_DATA_TE, name)
187
 
188
#define VARRAY_EDGE_INIT(va, num, name) \
189
  va = varray_init (num, VARRAY_DATA_EDGE, name)
190
 
191
#define VARRAY_TREE_PTR_INIT(va, num, name) \
192
  va = varray_init (num, VARRAY_DATA_TREE_PTR, name)
193
 
194
/* Free up memory allocated by the virtual array, but do not free any of the
195
   elements involved.  */
196
#define VARRAY_FREE(vp) \
197
  do { if (vp) { free (vp); vp = (varray_type) 0; } } while (0)
198
 
199
/* Grow/shrink the virtual array VA to N elements.  */
200
extern varray_type varray_grow (varray_type, size_t);
201
 
202
#define VARRAY_GROW(VA, N) ((VA) = varray_grow (VA, N))
203
 
204
#define VARRAY_SIZE(VA) ((VA)->num_elements)
205
 
206
#define VARRAY_ACTIVE_SIZE(VA)  ((VA)->elements_used)
207
#define VARRAY_POP_ALL(VA)      ((VA)->elements_used = 0)
208
 
209
#define VARRAY_CLEAR(VA) varray_clear(VA)
210
 
211
extern void varray_clear (varray_type);
212
extern void dump_varray_statistics (void);
213
 
214
/* Check for VARRAY_xxx macros being in bound.  */
215
#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
216
extern void varray_check_failed (varray_type, size_t, const char *, int,
217
                                 const char *) ATTRIBUTE_NORETURN;
218
extern void varray_underflow (varray_type, const char *, int, const char *)
219
     ATTRIBUTE_NORETURN;
220
#define VARRAY_CHECK(VA, N, T) __extension__                    \
221
(*({ varray_type const _va = (VA);                              \
222
     const size_t _n = (N);                                     \
223
     if (_n >= _va->num_elements)                               \
224
       varray_check_failed (_va, _n, __FILE__, __LINE__, __FUNCTION__); \
225
     &_va->data.T[_n]; }))
226
 
227
#define VARRAY_POP(VA) do {                                     \
228
  varray_type const _va = (VA);                                 \
229
  if (_va->elements_used == 0)                                   \
230
    varray_underflow (_va, __FILE__, __LINE__, __FUNCTION__);   \
231
  else                                                          \
232
    _va->elements_used--;                                       \
233
} while (0)
234
 
235
#else
236
#define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N])
237
/* Pop the top element of VA.  */
238
#define VARRAY_POP(VA) do { ((VA)->elements_used--); } while (0)
239
#endif
240
 
241
/* Push X onto VA.  T is the name of the field in varray_data
242
   corresponding to the type of X.  */
243
#define VARRAY_PUSH(VA, T, X)                           \
244
  do                                                    \
245
    {                                                   \
246
      if ((VA)->elements_used >= (VA)->num_elements)    \
247
        VARRAY_GROW ((VA), 2 * (VA)->num_elements);     \
248
      (VA)->data.T[(VA)->elements_used++] = (X);        \
249
    }                                                   \
250
  while (0)
251
 
252
#define VARRAY_CHAR(VA, N)              VARRAY_CHECK (VA, N, vdt_c)
253
#define VARRAY_UCHAR(VA, N)             VARRAY_CHECK (VA, N, vdt_uc)
254
#define VARRAY_SHORT(VA, N)             VARRAY_CHECK (VA, N, vdt_s)
255
#define VARRAY_USHORT(VA, N)            VARRAY_CHECK (VA, N, vdt_us)
256
#define VARRAY_INT(VA, N)               VARRAY_CHECK (VA, N, vdt_i)
257
#define VARRAY_UINT(VA, N)              VARRAY_CHECK (VA, N, vdt_u)
258
#define VARRAY_LONG(VA, N)              VARRAY_CHECK (VA, N, vdt_l)
259
#define VARRAY_ULONG(VA, N)             VARRAY_CHECK (VA, N, vdt_ul)
260
#define VARRAY_WIDE_INT(VA, N)          VARRAY_CHECK (VA, N, vdt_hint)
261
#define VARRAY_UWIDE_INT(VA, N)         VARRAY_CHECK (VA, N, vdt_uhint)
262
#define VARRAY_GENERIC_PTR(VA,N)        VARRAY_CHECK (VA, N, vdt_generic)
263
#define VARRAY_GENERIC_PTR_NOGC(VA,N)   VARRAY_CHECK (VA, N, vdt_generic_nogc)
264
#define VARRAY_CHAR_PTR(VA,N)           VARRAY_CHECK (VA, N, vdt_cptr)
265
#define VARRAY_RTX(VA, N)               VARRAY_CHECK (VA, N, vdt_rtx)
266
#define VARRAY_RTVEC(VA, N)             VARRAY_CHECK (VA, N, vdt_rtvec)
267
#define VARRAY_TREE(VA, N)              VARRAY_CHECK (VA, N, vdt_tree)
268
#define VARRAY_BITMAP(VA, N)            VARRAY_CHECK (VA, N, vdt_bitmap)
269
#define VARRAY_REG(VA, N)               VARRAY_CHECK (VA, N, vdt_reg)
270
#define VARRAY_BB(VA, N)                VARRAY_CHECK (VA, N, vdt_bb)
271
#define VARRAY_ELT_LIST(VA, N)          VARRAY_CHECK (VA, N, vdt_te)
272
#define VARRAY_EDGE(VA, N)              VARRAY_CHECK (VA, N, vdt_e)
273
#define VARRAY_TREE_PTR(VA, N)          VARRAY_CHECK (VA, N, vdt_tp)
274
 
275
/* Push a new element on the end of VA, extending it if necessary.  */
276
#define VARRAY_PUSH_CHAR(VA, X)         VARRAY_PUSH (VA, vdt_c, X)
277
#define VARRAY_PUSH_UCHAR(VA, X)        VARRAY_PUSH (VA, vdt_uc, X)
278
#define VARRAY_PUSH_SHORT(VA, X)        VARRAY_PUSH (VA, vdt_s, X)
279
#define VARRAY_PUSH_USHORT(VA, X)       VARRAY_PUSH (VA, vdt_us, X)
280
#define VARRAY_PUSH_INT(VA, X)          VARRAY_PUSH (VA, vdt_i, X)
281
#define VARRAY_PUSH_UINT(VA, X)         VARRAY_PUSH (VA, vdt_u, X)
282
#define VARRAY_PUSH_LONG(VA, X)         VARRAY_PUSH (VA, vdt_l, X)
283
#define VARRAY_PUSH_ULONG(VA, X)        VARRAY_PUSH (VA, vdt_ul, X)
284
#define VARRAY_PUSH_WIDE_INT(VA, X)     VARRAY_PUSH (VA, vdt_hint, X)
285
#define VARRAY_PUSH_UWIDE_INT(VA, X)    VARRAY_PUSH (VA, vdt_uhint, X)
286
#define VARRAY_PUSH_GENERIC_PTR(VA, X)  VARRAY_PUSH (VA, vdt_generic, X)
287
#define VARRAY_PUSH_GENERIC_PTR_NOGC(VA, X)     VARRAY_PUSH (VA, vdt_generic_nogc, X)
288
#define VARRAY_PUSH_CHAR_PTR(VA, X)     VARRAY_PUSH (VA, vdt_cptr, X)
289
#define VARRAY_PUSH_RTX(VA, X)          VARRAY_PUSH (VA, vdt_rtx, X)
290
#define VARRAY_PUSH_RTVEC(VA, X)        VARRAY_PUSH (VA, vdt_rtvec, X)
291
#define VARRAY_PUSH_TREE(VA, X)         VARRAY_PUSH (VA, vdt_tree, X)
292
#define VARRAY_PUSH_BITMAP(VA, X)       VARRAY_PUSH (VA, vdt_bitmap, X)
293
#define VARRAY_PUSH_REG(VA, X)          VARRAY_PUSH (VA, vdt_reg, X)
294
#define VARRAY_PUSH_BB(VA, X)           VARRAY_PUSH (VA, vdt_bb, X)
295
#define VARRAY_PUSH_EDGE(VA, X)         VARRAY_PUSH (VA, vdt_e, X)
296
#define VARRAY_PUSH_TREE_PTR(VA, X)     VARRAY_PUSH (VA, vdt_tp, X)
297
 
298
/* Return the last element of VA.  */
299
#define VARRAY_TOP(VA, T) VARRAY_CHECK(VA, (VA)->elements_used - 1, T)
300
 
301
#define VARRAY_TOP_CHAR(VA)             VARRAY_TOP (VA, vdt_c)
302
#define VARRAY_TOP_UCHAR(VA)            VARRAY_TOP (VA, vdt_uc)
303
#define VARRAY_TOP_SHORT(VA)            VARRAY_TOP (VA, vdt_s)
304
#define VARRAY_TOP_USHORT(VA)           VARRAY_TOP (VA, vdt_us)
305
#define VARRAY_TOP_INT(VA)              VARRAY_TOP (VA, vdt_i)
306
#define VARRAY_TOP_UINT(VA)             VARRAY_TOP (VA, vdt_u)
307
#define VARRAY_TOP_LONG(VA)             VARRAY_TOP (VA, vdt_l)
308
#define VARRAY_TOP_ULONG(VA)            VARRAY_TOP (VA, vdt_ul)
309
#define VARRAY_TOP_WIDE_INT(VA)         VARRAY_TOP (VA, vdt_hint)
310
#define VARRAY_TOP_UWIDE_INT(VA)        VARRAY_TOP (VA, vdt_uhint)
311
#define VARRAY_TOP_GENERIC_PTR(VA)      VARRAY_TOP (VA, vdt_generic)
312
#define VARRAY_TOP_GENERIC_PTR_NOGC(VA) VARRAY_TOP (VA, vdt_generic_nogc)
313
#define VARRAY_TOP_CHAR_PTR(VA)         VARRAY_TOP (VA, vdt_cptr)
314
#define VARRAY_TOP_RTX(VA)              VARRAY_TOP (VA, vdt_rtx)
315
#define VARRAY_TOP_RTVEC(VA)            VARRAY_TOP (VA, vdt_rtvec)
316
#define VARRAY_TOP_TREE(VA)             VARRAY_TOP (VA, vdt_tree)
317
#define VARRAY_TOP_BITMAP(VA)           VARRAY_TOP (VA, vdt_bitmap)
318
#define VARRAY_TOP_REG(VA)              VARRAY_TOP (VA, vdt_reg)
319
#define VARRAY_TOP_BB(VA)               VARRAY_TOP (VA, vdt_bb)
320
#define VARRAY_TOP_EDGE(VA)             VARRAY_TOP (VA, vdt_e)
321
#define VARRAY_TOP_TREE_PTR(VA)         VARRAY_TOP (VA, vdt_tp)
322
 
323
#endif /* ! GCC_VARRAY_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.